TpPPdaDaoImpl.java
7.24 KB
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
195
196
197
198
199
200
201
202
203
204
205
package com.zteits.park.dao.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.zteits.clouds.api.dto.pda.param.QueryEqpByPlNoAndOrtherRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaoleilu.hutool.util.CollectionUtil;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.apibase.constants.ErrorType;
import com.zteits.clouds.api.apibase.exception.BizException;
import com.zteits.clouds.api.dto.park.dto.StatisticEqpCountByEqpTypeDTO;
import com.zteits.clouds.api.dto.park.dto.StatisticEqpCountByPlNoDTO;
import com.zteits.clouds.api.dto.park.param.TpPPdaDeleteRequest;
import com.zteits.clouds.api.dto.park.param.TpPPdaPageQueryRequest;
import com.zteits.clouds.api.dto.park.param.TpPPdaRequest;
import com.zteits.clouds.api.dto.park.param.TpPPdaSRequest;
import com.zteits.park.dao.TpPPdaDao;
import com.zteits.park.domain.TpPPda;
import com.zteits.park.domain.TpPPdaExample;
import com.zteits.park.domain.TpPPdaExample.Criteria;
import com.zteits.park.mapper.TpPPdaMapper;
import com.zteits.park.mapper.smapper.TpPPdaSMapper;
@Component
public class TpPPdaDaoImpl implements TpPPdaDao {
@Autowired
private TpPPdaSMapper tpPPdaSMapper;
@Autowired
private TpPPdaMapper tpPPdaMapper;
@Override
public Integer insertPad(TpPPda tpPPda) {
tpPPda.setCreateTime(new Date());
tpPPda.setDataState(DataStatusEnum.DATA_STATUS_VALID.value());
return tpPPdaMapper.insertSelective(tpPPda);
}
@Override
public Integer deletetPda(TpPPdaDeleteRequest tpPPda) {
//删除pda表
TpPPdaExample example = new TpPPdaExample();
TpPPda record = new TpPPda();
record.setModifyTime(new Date());
record.setModifyOp(tpPPda.getModifyOp());
record.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value());
example.createCriteria().andIdIn(tpPPda.getIds());
return tpPPdaMapper.updateByExampleSelective(record, example);
}
@Override
public PageInfo<TpPPda> queryPdaInfo4pabe(TpPPdaPageQueryRequest request) {
PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
List<TpPPda> list = tpPPdaSMapper.queryPdaInfo(request);
if (CollectionUtils.isNotEmpty(list)) {
return new PageInfo<TpPPda>(list);
}
return new PageInfo<TpPPda>(new ArrayList<TpPPda>());
}
@Override
public Integer deleteBatchPda(List<Long> list) {
TpPPdaExample example = new TpPPdaExample();
example.createCriteria().andIdIn(list);
TpPPda record = new TpPPda();
record.setModifyTime(new Date());
record.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value());
return tpPPdaMapper.updateByExampleSelective(record, example);
}
@Override
public TpPPda queryPdaByid(Long id) {
return tpPPdaMapper.selectByPrimaryKey(id);
}
@Override
public Integer updatePda(TpPPda record) {
return tpPPdaMapper.updateByPrimaryKeySelective(record);
}
@Override
public Integer insertBatchPda(TpPPdaSRequest request) {
List<TpPPdaRequest> requestList = request.getPadList();
Integer i = 0;
if (CollectionUtil.isNotEmpty(requestList)) {
i = tpPPdaSMapper.insertBatchPda(requestList);
}
return i;
}
@Override
public TpPPda queryPdaByPdaNo(TpPPda tpPPda) {
if(StringUtils.isBlank(tpPPda.getPdaNo()) && tpPPda.getId()==null){
throw new BizException(ErrorType.PARAM_NOT_VALID);
}
TpPPdaExample example = new TpPPdaExample();
Criteria sql = example.createCriteria();
sql.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
if(!StringUtils.isBlank(tpPPda.getPdaNo())){
sql.andPdaNoEqualTo(tpPPda.getPdaNo());
}
if(tpPPda.getId()!=null){
sql.andIdEqualTo(tpPPda.getId());
}
List<TpPPda> pPdas = tpPPdaMapper.selectByExample(example);
if(CollectionUtils.isEmpty(pPdas)){
return null;
}
return pPdas.get(0);
}
@Override
public List<TpPPda> queryPdaByPlNo(TpPPda tpPPda) {
TpPPdaExample example = new TpPPdaExample();
Criteria sql = example.createCriteria();
sql.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
.andPlNoEqualTo(tpPPda.getPlNo());
if(!StringUtils.isBlank(tpPPda.getPdaType())){
sql.andPdaTypeEqualTo(tpPPda.getPdaType());
}
if(tpPPda.getId()!=null){
sql.andIdEqualTo(tpPPda.getId());
}
return tpPPdaMapper.selectByExample(example );
}
@Override
public List<TpPPda> queryPdaByPlNoAndPdaType(TpPPdaRequest request) {
TpPPdaExample example = new TpPPdaExample();
Criteria sql = example.createCriteria();
sql.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
.andPlNoEqualTo(request.getPlNo());
if(CollectionUtils.isNotEmpty(request.getPdaTypes())){
sql.andPdaTypeIn(request.getPdaTypes());
}
if(!StringUtils.isBlank(request.getPdaType())){
sql.andPdaTypeEqualTo(request.getPdaType());
}
return tpPPdaMapper.selectByExample(example );
}
@Override
public List<TpPPda> queryPdaInfoByPlNoAndOther(QueryEqpByPlNoAndOrtherRequest request) {
return tpPPdaSMapper.queryPdaInfoByPlNoAndOther(request);
}
@Override
public int updateByExampleSelective(TpPPda record, TpPPdaExample example) {
return tpPPdaMapper.updateByExampleSelective(record, example);
}
@Override
public List<TpPPda> selectByExample(TpPPdaExample example) {
return tpPPdaMapper.selectByExample(example);
}
@Override
public TpPPda queryPdaByPdaNo(String pdaNo) {
TpPPdaExample example = new TpPPdaExample();
example.createCriteria().andPdaNoEqualTo(pdaNo)
.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
List<TpPPda> tpPPdas = tpPPdaMapper.selectByExample(example );
if(CollectionUtils.isEmpty(tpPPdas)){
return null;
}
return tpPPdas.get(0);
}
@Override
public int updatePDAByPdaNo(TpPPda record, String pdaNo) {
TpPPdaExample example = new TpPPdaExample();
example.createCriteria().andPdaNoEqualTo(pdaNo)
.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
return tpPPdaMapper.updateByExampleSelective(record, example );
}
@Override
public Map<Integer, StatisticEqpCountByEqpTypeDTO> statisticEqpCountGroupByEqpType(TpPPdaPageQueryRequest request) {
List<StatisticEqpCountByEqpTypeDTO> byEqpTypeDTOs = tpPPdaSMapper.statisticEqpCountGroupByEqpType(request);
if(CollectionUtil.isEmpty(byEqpTypeDTOs)){
return null;
}
return byEqpTypeDTOs.stream().collect(Collectors.toMap(StatisticEqpCountByEqpTypeDTO::getEqpType, Function.identity()));
}
@Override
public Map<String, List<StatisticEqpCountByPlNoDTO>> statisticEqpCountGroupByPlNo(TpPPdaPageQueryRequest request) {
List<StatisticEqpCountByPlNoDTO> byplNoDTOs = tpPPdaSMapper.statisticEqpCountGroupByPlNo(request);
if(CollectionUtil.isEmpty(byplNoDTOs)){
return null;
}
return byplNoDTOs.stream().collect(Collectors.groupingBy(StatisticEqpCountByPlNoDTO::getPlNo));
}
}