Blame view

parking-module-park/src/main/java/com/zteits/park/dao/impl/ChannelDaoImpl.java 7.11 KB
9af4a544   王彪总   新项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  package com.zteits.park.dao.impl;
  
  import com.clouds.common.utils.ListCopyUtil;
  import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
  import com.zteits.clouds.api.dto.park.dto.ChannelInfoDTO;
  import com.zteits.clouds.api.dto.park.param.closecarpark.CheckChannelNumRequest;
  import com.zteits.clouds.api.dto.park.param.closecarpark.QueryChannelInfoByNoRequest;
  import com.zteits.clouds.api.dto.park.param.closecarpark.QueryChannelInfoRequest;
  import com.zteits.clouds.api.dto.park.param.closecarpark.QueryChannelNameByChannelNumsRequest;
  import com.zteits.park.dao.ChannelDao;
  import com.zteits.park.domain.ParkingLotChannel;
  import com.zteits.park.domain.ParkingLotChannelExample;
  import com.zteits.park.mapper.ParkingLotChannelMapper;
  import com.zteits.park.mapper.ParkingLotEquipmentMapper;
  import com.zteits.park.mapper.smapper.ParkingLotChannelSMapper;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  import org.springframework.util.StringUtils;
  
  import java.util.ArrayList;
  import java.util.List;
  
  @Component
  public class ChannelDaoImpl implements ChannelDao {
  
      @Autowired
      private ParkingLotChannelMapper parkingLotChannelMapper;
  
      @Autowired
      private ParkingLotChannelSMapper parkingLotChannelSMapper;
  
      @Autowired
      private ParkingLotEquipmentMapper parkingLotEquipmentMapper;
  
  
      /**
       * 每一页大小.
       */
      private static final Integer PAGE_SIZE = 500;
  
      @Override
      public ChannelInfoDTO QueryChannelInfo(QueryChannelInfoRequest request) {
          ChannelInfoDTO channelInfoDTO = new ChannelInfoDTO();
          ParkingLotChannelExample example = new ParkingLotChannelExample();
          example.createCriteria().andIdEqualTo(request.getId()).andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
          channelInfoDTO = parkingLotChannelSMapper.selectByChannel(request);
  
  
          return channelInfoDTO;
      }
  
      @Override
      public int insertSelective(ParkingLotChannel record) {
          if (record == null) {
              return 0;
          }
          if (record.getDataStatus() == null) {
              record.setDataStatus(DataStatusEnum.DATA_STATUS_NO_VALID.value());
          }
          return parkingLotChannelMapper.insertSelective(record);
      }
  
      @Override
      public int updateSelective(ParkingLotChannel record) {
          if (record == null) {
              return 0;
          }
          if (record.getDataStatus() == null) {
              record.setDataStatus(DataStatusEnum.DATA_STATUS_NO_VALID.value());
          }
          return parkingLotChannelSMapper.updateChannelByPrimaryKey(record);
      }
  
      @Override
      public int deleteSelective(ParkingLotChannel record) {
          if (record == null) {
              return 0;
          }
          if (record.getDataStatus() == null) {
              record.setDataStatus(DataStatusEnum.DATA_STATUS_NO_VALID.value());
          }
  
          return parkingLotChannelSMapper.deleteChannelByPrimaryKey(record);
      }
  
      @Override
      public int updateTideChannelByNum(ParkingLotChannel record) {
          if (record == null) {
              return 0;
          }
  
          ParkingLotChannelExample example = new ParkingLotChannelExample();
          ParkingLotChannelExample.Criteria sql = example.createCriteria();
  
          //
          if(!StringUtils.isEmpty(record.getId())){
              sql.andIdEqualTo(record.getId());
          }
  
          sql.andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
          return parkingLotChannelMapper.updateByExampleSelective(record,example);
      }
  
      @Override
      public ParkingLotChannel queryChannelInfoByNo(QueryChannelInfoByNoRequest record) {
          if (record == null) {
              return null;
          }
  
          ParkingLotChannelExample example = new ParkingLotChannelExample();
          ParkingLotChannelExample.Criteria sql = example.createCriteria();
  
          //
          if(!StringUtils.isEmpty(record.getPlNo())){
              sql.andPlNoEqualTo(record.getPlNo());
          }
          if(!StringUtils.isEmpty(record.getChannelNumber())){
              sql.andChannelNumberEqualTo(record.getChannelNumber());
          }
          sql.andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
  
          List<ParkingLotChannel> list = parkingLotChannelMapper.selectByExample(example);
          ParkingLotChannel parkingLotChannel = list.get(0);
          return parkingLotChannel;
      }
  
      @Override
      public List<ChannelInfoDTO> tideChannelChoice(ParkingLotChannel record) {
          ParkingLotChannelExample example = new ParkingLotChannelExample();
          ParkingLotChannelExample.Criteria sql = example.createCriteria();
  
          //
          if(!StringUtils.isEmpty(record.getPlNo())){
              sql.andPlNoEqualTo(record.getPlNo());
          }
          if(!StringUtils.isEmpty(record.getAreaId())){
              sql.andAreaIdEqualTo(record.getAreaId());
          }
          if(!StringUtils.isEmpty(record.getChannelDirection())){
              sql.andChannelDirectionEqualTo(record.getChannelDirection());
          }
          sql.andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
          List<ParkingLotChannel> list = parkingLotChannelMapper.selectByExample(example);
          List<ChannelInfoDTO> dtoList = new ArrayList<>();
          ListCopyUtil.listCopyProperties(list,dtoList,ChannelInfoDTO.class);
          return dtoList;
      }
  
      @Override
      public List<ChannelInfoDTO> queryChannelNameByChannelNums(QueryChannelNameByChannelNumsRequest request) {
          ParkingLotChannelExample example = new ParkingLotChannelExample();
          ParkingLotChannelExample.Criteria sql = example.createCriteria();
          sql.andChannelNumberIn(request.getChannelNums()).andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
          List<ParkingLotChannel> list = parkingLotChannelMapper.selectByExample(example);
          List<ChannelInfoDTO> dtoList = new ArrayList<>();
          ListCopyUtil.listCopyProperties(list,dtoList,ChannelInfoDTO.class);
          return dtoList;
      }
  
      @Override
      public int checkChannelNum(CheckChannelNumRequest request) {
          ParkingLotChannelExample example = new ParkingLotChannelExample();
          ParkingLotChannelExample.Criteria sql = example.createCriteria();
          if(!StringUtils.isEmpty(request.getId())){
              sql.andIdNotEqualTo(request.getId());
          }
          sql.andPlNoEqualTo(request.getPlNo())
                  .andChannelNumberEqualTo(request.getChannelNumber()).andDataStatusEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
          List<ParkingLotChannel> list = parkingLotChannelMapper.selectByExample(example);
          int flag = 0;
          if(list != null){
              flag  = list.size();
          }
  
          return flag;
      }
  
      /**
       * 根据ID 获取通道信息
       */
      @Override
      public ParkingLotChannel queryParkingLotChannelById(Long id) {
          ParkingLotChannelExample example = new ParkingLotChannelExample();
          ParkingLotChannelExample.Criteria sql = example.createCriteria();
          sql.andIdEqualTo(id);
  
          List<ParkingLotChannel> list =parkingLotChannelMapper.selectByExample(example);
          if(list != null && list.size() > 0){
              return list.get(0);
          }else{
              return null;
          }
      }
  }