提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.point.service.impl; |
H |
2 |
|
139c6a
|
3 |
import cn.hutool.core.collection.CollUtil; |
a6de49
|
4 |
import com.alibaba.fastjson.JSONArray; |
cfbd83
|
5 |
import com.baomidou.dynamic.datasource.annotation.DSTransactional; |
a6de49
|
6 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
250190
|
7 |
import com.baomidou.mybatisplus.core.metadata.IPage; |
6bf63b
|
8 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
L |
9 |
import com.iailab.framework.common.pojo.PageResult; |
139c6a
|
10 |
import com.iailab.framework.common.util.object.BeanUtils; |
6bf63b
|
11 |
import com.iailab.framework.common.util.object.ConvertUtils; |
01d6f8
|
12 |
import com.iailab.module.data.channel.common.service.ChannelSourceService; |
a6de49
|
13 |
import com.iailab.module.data.common.enums.CommonConstant; |
H |
14 |
import com.iailab.module.data.common.enums.IsEnableEnum; |
c96e44
|
15 |
import com.iailab.module.data.common.enums.IncreaseCodeEnum; |
a6de49
|
16 |
import com.iailab.module.data.point.common.PointTypeEnum; |
6bf63b
|
17 |
import com.iailab.module.data.point.dao.DaPointDao; |
0ed8ac
|
18 |
import com.iailab.module.data.point.dto.DaCumulatePointDTO; |
潘 |
19 |
import com.iailab.module.data.point.dto.DaMathPointDTO; |
a6de49
|
20 |
import com.iailab.module.data.point.dto.DaMeasurePointDTO; |
H |
21 |
import com.iailab.module.data.point.dto.DaPointDTO; |
139c6a
|
22 |
import com.iailab.module.data.point.entity.DaMeasurePointEntity; |
a6de49
|
23 |
import com.iailab.module.data.point.entity.DaPointEntity; |
0ed8ac
|
24 |
import com.iailab.module.data.point.service.*; |
f21253
|
25 |
import com.iailab.module.data.point.vo.DaPointPageReqVO; |
J |
26 |
import com.iailab.module.data.point.vo.PointImportExcelVO; |
|
27 |
import com.iailab.module.data.point.vo.PointImportRespVO; |
48c57b
|
28 |
import org.apache.commons.lang3.ObjectUtils; |
0ed8ac
|
29 |
import org.springframework.beans.factory.annotation.Autowired; |
a6de49
|
30 |
import org.springframework.stereotype.Service; |
H |
31 |
import org.springframework.util.CollectionUtils; |
|
32 |
|
6bf63b
|
33 |
import javax.annotation.Resource; |
a6de49
|
34 |
import java.util.*; |
9df837
|
35 |
import java.util.concurrent.ConcurrentHashMap; |
139c6a
|
36 |
|
D |
37 |
import static com.iailab.framework.common.exception.util.ServiceExceptionUtil.exception; |
f21253
|
38 |
import static com.iailab.module.data.enums.ErrorCodeConstants.POINT_EXISTS; |
J |
39 |
import static com.iailab.module.data.enums.ErrorCodeConstants.POINT_IMPORT_LIST_IS_EMPTY; |
a6de49
|
40 |
|
H |
41 |
/** |
6bf63b
|
42 |
* @author lirm |
a6de49
|
43 |
* @Description |
6bf63b
|
44 |
* @createTime 2024年09月2日 |
a6de49
|
45 |
*/ |
H |
46 |
@Service |
6bf63b
|
47 |
public class DaPointServiceImpl extends ServiceImpl<DaPointDao, DaPointEntity> implements DaPointService { |
a6de49
|
48 |
|
0ed8ac
|
49 |
@Autowired |
a6de49
|
50 |
private DaMeasurePointService daMeasurePointService; |
H |
51 |
|
0ed8ac
|
52 |
@Autowired |
a6de49
|
53 |
private DaMathPointService daMathPointService; |
H |
54 |
|
0ed8ac
|
55 |
@Autowired |
潘 |
56 |
private DaCumulatePointService daCumulatePointService; |
|
57 |
|
|
58 |
@Autowired |
a6de49
|
59 |
private DaSequenceNumService daSequenceNumService; |
6bf63b
|
60 |
|
L |
61 |
@Resource |
|
62 |
private DaPointDao daPointDao; |
|
63 |
|
139c6a
|
64 |
@Resource |
01d6f8
|
65 |
private ChannelSourceService channelSourceService; |
9df837
|
66 |
|
90e342
|
67 |
@Resource |
潘 |
68 |
private DaPointCollectStatusService daPointCollectStatusService; |
|
69 |
|
a4891a
|
70 |
private static Map<String, DaPointDTO> pointIdMap = new ConcurrentHashMap<>(); |
潘 |
71 |
|
9df837
|
72 |
private static Map<String, DaPointDTO> pointNoMap = new ConcurrentHashMap<>(); |
a6de49
|
73 |
|
H |
74 |
@Override |
250190
|
75 |
public PageResult<DaPointDTO> queryPage(DaPointPageReqVO reqVO) { |
139c6a
|
76 |
IPage<DaPointDTO> page = daPointDao.selectPageList(reqVO); |
a4891a
|
77 |
return new PageResult<>(page.getRecords(), page.getTotal()); |
潘 |
78 |
} |
|
79 |
|
|
80 |
private void clearCache() { |
|
81 |
pointIdMap.clear(); |
|
82 |
pointNoMap.clear(); |
a6de49
|
83 |
} |
H |
84 |
|
|
85 |
@Override |
6bf63b
|
86 |
public DaPointDTO info(String id) { |
L |
87 |
DaPointEntity entity = daPointDao.selectById(id); |
a6de49
|
88 |
DaPointDTO result = ConvertUtils.sourceToTarget(entity, DaPointDTO.class); |
0ed8ac
|
89 |
result.setMeasurePoint(new DaMeasurePointDTO()); |
潘 |
90 |
result.setMathPoint(new DaMathPointDTO()); |
|
91 |
result.setCumulatePoint(new DaCumulatePointDTO()); |
|
92 |
switch (PointTypeEnum.getEumByCode(result.getPointType())) { |
|
93 |
case MEASURE_POINT: |
|
94 |
DaMeasurePointDTO measurePoint = daMeasurePointService.getByPoint(id); |
|
95 |
result.setMeasurePoint(measurePoint); |
|
96 |
List<String> sourceOption = new ArrayList<>(); |
|
97 |
sourceOption.add(measurePoint.getSourceType()); |
|
98 |
sourceOption.add(measurePoint.getSourceId()); |
|
99 |
sourceOption.add(measurePoint.getTagNo()); |
|
100 |
result.setSourceOption(sourceOption); |
|
101 |
break; |
|
102 |
case CALCULATE_POINT: |
|
103 |
result.setMathPoint(daMathPointService.getByPoint(id)); |
|
104 |
break; |
|
105 |
case CUMULATE: |
|
106 |
result.setCumulatePoint(daCumulatePointService.getByPoint(id)); |
|
107 |
break; |
|
108 |
default: |
|
109 |
break; |
a6de49
|
110 |
} |
H |
111 |
return result; |
|
112 |
} |
|
113 |
|
|
114 |
@Override |
b8b8cb
|
115 |
public DaPointDTO getSimpleInfoById(String id) { |
a4891a
|
116 |
if (pointIdMap.containsKey(id)) { |
潘 |
117 |
return pointIdMap.get(id); |
|
118 |
} |
|
119 |
DaPointDTO dto = ConvertUtils.sourceToTarget(daPointDao.selectById(id), DaPointDTO.class); |
5f7008
|
120 |
if (dto == null) { |
潘 |
121 |
return null; |
|
122 |
} |
a4891a
|
123 |
pointIdMap.put(id, dto); |
5f7008
|
124 |
return pointIdMap.get(id); |
b8b8cb
|
125 |
} |
潘 |
126 |
|
|
127 |
@Override |
|
128 |
public DaPointDTO getSimpleInfoByNo(String no) { |
29b971
|
129 |
QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper<>(); |
7511af
|
130 |
queryWrapper.eq("point_no", no); |
b8b8cb
|
131 |
return ConvertUtils.sourceToTarget(daPointDao.selectOne(queryWrapper), DaPointDTO.class); |
潘 |
132 |
} |
|
133 |
|
|
134 |
@Override |
a6de49
|
135 |
public List<DaPointDTO> list(Map<String, Object> params) { |
48c57b
|
136 |
Object pointType = params.get("pointType"); |
a6de49
|
137 |
List<String> pointNos = new ArrayList<>(); |
H |
138 |
if (params.get("pointNos") != null) { |
|
139 |
pointNos = JSONArray.parseArray(JSONArray.toJSONString(params.get("pointNos")), String.class); |
|
140 |
} |
14cb32
|
141 |
List<String> pointTypes = new ArrayList<>(); |
潘 |
142 |
if (params.get("pointTypes") != null) { |
|
143 |
pointTypes = Arrays.asList(params.get("pointTypes").toString().split(",")); |
|
144 |
} |
|
145 |
|
48c57b
|
146 |
Object pointNoLike = params.get("pointNoLike"); |
a6de49
|
147 |
QueryWrapper<DaPointEntity> queryWrapper = new QueryWrapper(); |
48c57b
|
148 |
queryWrapper.eq(!ObjectUtils.isEmpty(pointType), "point_type", pointType); |
L |
149 |
queryWrapper.in(pointNos.size() != 0,"point_no", pointNos); |
|
150 |
queryWrapper.like(!ObjectUtils.isEmpty(pointNoLike), "point_no", pointNoLike); |
14cb32
|
151 |
queryWrapper.in(pointTypes.size() != 0,"point_type", pointTypes); |
6bf63b
|
152 |
List<DaPointEntity> list = daPointDao.selectList(queryWrapper); |
a6de49
|
153 |
return ConvertUtils.sourceToTarget(list, DaPointDTO.class); |
H |
154 |
} |
|
155 |
|
|
156 |
@Override |
cfbd83
|
157 |
@DSTransactional(rollbackFor = Exception.class) |
a6de49
|
158 |
public void add(DaPointDTO dataPoint) { |
H |
159 |
DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class); |
|
160 |
daPointEntity.setId(UUID.randomUUID().toString()); |
01d6f8
|
161 |
switch (PointTypeEnum.getEumByCode(dataPoint.getPointType())) { |
潘 |
162 |
case MEASURE_POINT: |
|
163 |
DaMeasurePointDTO measurePoint = new DaMeasurePointDTO(); |
|
164 |
measurePoint.setSourceType(dataPoint.getSourceOption().get(0)); |
|
165 |
measurePoint.setSourceId(dataPoint.getSourceOption().get(1)); |
|
166 |
measurePoint.setTagNo(dataPoint.getSourceOption().get(2)); |
|
167 |
daMeasurePointService.add(measurePoint, daPointEntity.getId()); |
|
168 |
daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_M.name())); |
|
169 |
break; |
|
170 |
case CALCULATE_POINT: |
|
171 |
daMathPointService.add(dataPoint.getMathPoint(), daPointEntity.getId()); |
|
172 |
daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_C.name())); |
|
173 |
break; |
|
174 |
case CONSTANT: |
|
175 |
daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name())); |
|
176 |
break; |
0ed8ac
|
177 |
case CUMULATE: |
潘 |
178 |
daCumulatePointService.add(dataPoint.getCumulatePoint(), daPointEntity.getId()); |
|
179 |
daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_L.name())); |
|
180 |
break; |
01d6f8
|
181 |
default: |
潘 |
182 |
break; |
a6de49
|
183 |
} |
H |
184 |
daPointEntity.setIsEnable(CommonConstant.IS_ENABLE); |
|
185 |
daPointEntity.setCreateTime(new Date()); |
6bf63b
|
186 |
daPointDao.insert(daPointEntity); |
9df837
|
187 |
|
90e342
|
188 |
daPointCollectStatusService.add(daPointEntity.getPointNo()); |
9df837
|
189 |
// 清空缓存 |
a4891a
|
190 |
clearCache(); |
a6de49
|
191 |
} |
H |
192 |
|
|
193 |
@Override |
cfbd83
|
194 |
@DSTransactional(rollbackFor = Exception.class) |
a6de49
|
195 |
public void update(DaPointDTO dataPoint) { |
H |
196 |
DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(dataPoint, DaPointEntity.class); |
|
197 |
daPointEntity.setUpdateTime(new Date()); |
6bf63b
|
198 |
daPointDao.updateById(daPointEntity); |
01d6f8
|
199 |
switch (PointTypeEnum.getEumByCode(dataPoint.getPointType())) { |
潘 |
200 |
case MEASURE_POINT: |
|
201 |
DaMeasurePointDTO measurePoint = dataPoint.getMeasurePoint(); |
|
202 |
measurePoint.setSourceType(dataPoint.getSourceOption().get(0)); |
|
203 |
measurePoint.setSourceId(dataPoint.getSourceOption().get(1)); |
|
204 |
measurePoint.setTagNo(dataPoint.getSourceOption().get(2)); |
|
205 |
daMeasurePointService.update(measurePoint); |
|
206 |
break; |
|
207 |
case CALCULATE_POINT: |
|
208 |
daMathPointService.update(dataPoint.getMathPoint()); |
|
209 |
break; |
0ed8ac
|
210 |
case CUMULATE: |
潘 |
211 |
daCumulatePointService.update(dataPoint.getCumulatePoint()); |
|
212 |
break; |
01d6f8
|
213 |
default: |
潘 |
214 |
break; |
a6de49
|
215 |
} |
9df837
|
216 |
// 清空缓存 |
a4891a
|
217 |
clearCache(); |
a6de49
|
218 |
} |
H |
219 |
|
|
220 |
@Override |
cfbd83
|
221 |
@DSTransactional(rollbackFor = Exception.class) |
eb1c5f
|
222 |
public void delete(String[] ids) { |
潘 |
223 |
daPointDao.deleteBatchIds(Arrays.asList(ids)); |
|
224 |
daMeasurePointService.deleteByPoint(ids); |
|
225 |
daMathPointService.deleteByPoint(ids); |
|
226 |
daCumulatePointService.deleteByPoint(ids); |
9df837
|
227 |
// 清空缓存 |
a4891a
|
228 |
clearCache(); |
a6de49
|
229 |
} |
H |
230 |
|
|
231 |
@Override |
14cb32
|
232 |
public List<DaPointDTO> getConstantPoint(DaPointPageReqVO reqVO) { |
潘 |
233 |
Map<String, Object> params = new HashMap<>(); |
|
234 |
params.put("pointType", PointTypeEnum.CONSTANT.getCode()); |
|
235 |
params.put("pointNo", reqVO.getPointNo()); |
|
236 |
params.put("pointName", reqVO.getPointName()); |
|
237 |
return daPointDao.getConstantPoint(params); |
|
238 |
} |
|
239 |
|
|
240 |
@Override |
a6de49
|
241 |
public List<DaPointDTO> getConstantPoint(String freq) { |
H |
242 |
Map<String, Object> params = new HashMap<>(); |
|
243 |
params.put("pointType", PointTypeEnum.CONSTANT.getCode()); |
|
244 |
params.put("isEnable", CommonConstant.IS_ENABLE); |
|
245 |
params.put("minfreqid", freq); |
6bf63b
|
246 |
return daPointDao.getConstantPoint(params); |
a6de49
|
247 |
} |
H |
248 |
|
|
249 |
@Override |
|
250 |
public List<DaPointDTO> getConstantPoint(List<String> pointNos) { |
|
251 |
Map<String, Object> params = new HashMap<>(); |
|
252 |
params.put("pointType", PointTypeEnum.CONSTANT.getCode()); |
|
253 |
params.put("isEnable", CommonConstant.IS_ENABLE); |
|
254 |
params.put("pointNos", pointNos); |
6bf63b
|
255 |
return daPointDao.getConstantPoint(params); |
14cb32
|
256 |
} |
潘 |
257 |
|
|
258 |
@Override |
|
259 |
public List<DaPointDTO> getMeasurePoint(DaPointPageReqVO reqVO) { |
|
260 |
Map<String, Object> params = new HashMap<>(); |
|
261 |
params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); |
|
262 |
params.put("pointNo", reqVO.getPointNo()); |
|
263 |
params.put("pointName", reqVO.getPointName()); |
|
264 |
params.put("sourceName", reqVO.getSourceName()); |
|
265 |
return daPointDao.getMeasurePoint(params); |
a6de49
|
266 |
} |
H |
267 |
|
|
268 |
@Override |
|
269 |
public List<DaPointDTO> getMeasurePoint(String freq) { |
|
270 |
Map<String, Object> params = new HashMap<>(); |
|
271 |
params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); |
|
272 |
params.put("isEnable", CommonConstant.IS_ENABLE); |
|
273 |
params.put("minfreqid", freq); |
6bf63b
|
274 |
return daPointDao.getMeasurePoint(params); |
a6de49
|
275 |
} |
H |
276 |
|
|
277 |
@Override |
|
278 |
public List<DaPointDTO> getMeasurePoint(List<String> pointNos) { |
|
279 |
Map<String, Object> params = new HashMap<>(); |
|
280 |
params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); |
|
281 |
params.put("isEnable", CommonConstant.IS_ENABLE); |
|
282 |
params.put("pointNos", pointNos); |
6bf63b
|
283 |
return daPointDao.getMeasurePoint(params); |
a6de49
|
284 |
} |
H |
285 |
|
|
286 |
@Override |
|
287 |
public DaPointDTO getMeasurePointByNo(String pointNo) { |
|
288 |
Map<String, Object> params = new HashMap<>(); |
|
289 |
params.put("pointType", PointTypeEnum.MEASURE_POINT.getCode()); |
|
290 |
params.put("pointNo", pointNo); |
6bf63b
|
291 |
List<DaPointDTO> list = daPointDao.getMeasurePoint(params); |
a6de49
|
292 |
if (CollectionUtils.isEmpty(list)) { |
H |
293 |
return null; |
|
294 |
} |
|
295 |
return list.get(0); |
14cb32
|
296 |
} |
潘 |
297 |
|
|
298 |
@Override |
|
299 |
public List<DaPointDTO> getMathPoint(DaPointPageReqVO reqVO) { |
|
300 |
Map<String, Object> params = new HashMap<>(); |
|
301 |
params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); |
|
302 |
params.put("pointNo", reqVO.getPointNo()); |
|
303 |
params.put("pointName", reqVO.getPointName()); |
|
304 |
return daPointDao.getMathPoint(params); |
a6de49
|
305 |
} |
H |
306 |
|
|
307 |
@Override |
|
308 |
public List<DaPointDTO> getMathPoint(String freq) { |
|
309 |
Map<String, Object> params = new HashMap<>(); |
|
310 |
params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); |
|
311 |
params.put("isEnable", CommonConstant.IS_ENABLE); |
|
312 |
params.put("minfreqid", freq); |
6bf63b
|
313 |
return daPointDao.getMathPoint(params); |
a6de49
|
314 |
} |
H |
315 |
|
|
316 |
@Override |
|
317 |
public List<DaPointDTO> getMathPoint(List<String> pointNos) { |
|
318 |
Map<String, Object> params = new HashMap<>(); |
|
319 |
params.put("pointType", PointTypeEnum.CALCULATE_POINT.getCode()); |
|
320 |
params.put("isEnable", CommonConstant.IS_ENABLE); |
|
321 |
params.put("pointNos", pointNos); |
6bf63b
|
322 |
return daPointDao.getMathPoint(params); |
a6de49
|
323 |
} |
H |
324 |
|
|
325 |
@Override |
56dba6
|
326 |
public List<DaPointDTO> getCumulatePoint(String freq) { |
eb1c5f
|
327 |
Map<String, Object> params = new HashMap<>(3); |
56dba6
|
328 |
params.put("pointType", PointTypeEnum.CUMULATE.getCode()); |
潘 |
329 |
params.put("isEnable", CommonConstant.IS_ENABLE); |
|
330 |
params.put("minfreqid", freq); |
eb1c5f
|
331 |
return daPointDao.getCumulatePoint(params); |
潘 |
332 |
} |
|
333 |
|
|
334 |
@Override |
|
335 |
public List<DaPointDTO> getCumulatePoint(DaPointPageReqVO reqVO) { |
|
336 |
Map<String, Object> params = new HashMap<>(3); |
|
337 |
params.put("pointType", PointTypeEnum.CUMULATE.getCode()); |
|
338 |
params.put("pointNo", reqVO.getPointNo()); |
|
339 |
params.put("pointName", reqVO.getPointName()); |
56dba6
|
340 |
return daPointDao.getCumulatePoint(params); |
潘 |
341 |
} |
|
342 |
|
|
343 |
@Override |
a6de49
|
344 |
public DaPointDTO getByNo(String pointNo) { |
9df837
|
345 |
if (pointNoMap.containsKey(pointNo)) { |
潘 |
346 |
return pointNoMap.get(pointNo); |
|
347 |
} |
a6de49
|
348 |
QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); |
H |
349 |
wrapper.eq("point_no", pointNo); |
6bf63b
|
350 |
DaPointEntity entity = daPointDao.selectOne(wrapper); |
9df837
|
351 |
DaPointDTO dto = ConvertUtils.sourceToTarget(entity, DaPointDTO.class); |
潘 |
352 |
pointNoMap.put(pointNo, dto); |
|
353 |
return dto; |
a6de49
|
354 |
} |
H |
355 |
|
|
356 |
@Override |
|
357 |
public List<DaPointDTO> getByNos(List<String> pointNos) { |
|
358 |
QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); |
|
359 |
wrapper.in("point_no", pointNos); |
6bf63b
|
360 |
List<DaPointEntity> list = daPointDao.selectList(wrapper); |
a6de49
|
361 |
return ConvertUtils.sourceToTarget(list, DaPointDTO.class); |
H |
362 |
} |
|
363 |
|
|
364 |
@Override |
|
365 |
public void updateDefaultValue(DaPointDTO dto) { |
|
366 |
QueryWrapper<DaPointEntity> wrapper = new QueryWrapper<>(); |
|
367 |
wrapper.eq("point_no", dto.getPointNo()); |
|
368 |
DaPointEntity entity = new DaPointEntity(); |
|
369 |
entity.setDefaultValue(dto.getDefaultValue()); |
6bf63b
|
370 |
daPointDao.update(entity, wrapper); |
a6de49
|
371 |
} |
H |
372 |
|
|
373 |
@Override |
139c6a
|
374 |
@DSTransactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入 |
D |
375 |
public PointImportRespVO importPointList(List<PointImportExcelVO> importPoints, boolean isUpdateSupport) { |
|
376 |
// 1.1 参数校验 |
|
377 |
if (CollUtil.isEmpty(importPoints)) { |
|
378 |
throw exception(POINT_IMPORT_LIST_IS_EMPTY); |
|
379 |
} |
01d6f8
|
380 |
|
潘 |
381 |
Map<String, Map<String, String>> sourcesIdMap = channelSourceService.getSourcesId(); |
139c6a
|
382 |
// 2. 遍历,逐个创建 or 更新 |
D |
383 |
PointImportRespVO respVO = PointImportRespVO.builder().createPointnames(new ArrayList<>()) |
|
384 |
.updatePointnames(new ArrayList<>()).failurePointnames(new LinkedHashMap<>()).build(); |
|
385 |
importPoints.forEach(importPoint -> { |
|
386 |
|
|
387 |
// 判断如果不存在,再进行插入 |
|
388 |
DaPointEntity existPoint = baseMapper.selectByPointName(importPoint.getPointName()); |
|
389 |
if (existPoint == null) { |
|
390 |
DaPointEntity daPointEntity = ConvertUtils.sourceToTarget(importPoint, DaPointEntity.class); |
|
391 |
daPointEntity.setId(UUID.randomUUID().toString()); |
|
392 |
daPointEntity.setIsEnable(CommonConstant.IS_ENABLE); |
|
393 |
daPointEntity.setCreateTime(new Date()); |
01d6f8
|
394 |
switch (PointTypeEnum.getEumByCode(daPointEntity.getPointType())) { |
潘 |
395 |
case MEASURE_POINT: |
|
396 |
DaMeasurePointDTO measurePoint = new DaMeasurePointDTO(); |
|
397 |
measurePoint.setSourceType(importPoint.getSourceType()); |
|
398 |
measurePoint.setSourceId(sourcesIdMap.get(importPoint.getSourceType()).get(importPoint.getSourceName())); |
|
399 |
measurePoint.setTagNo(importPoint.getTagNo()); |
|
400 |
measurePoint.setValueType(importPoint.getValueType()); |
|
401 |
measurePoint.setDimension(importPoint.getDimension()); |
|
402 |
daMeasurePointService.add(measurePoint, daPointEntity.getId()); |
|
403 |
daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_M.name())); |
|
404 |
break; |
|
405 |
case CALCULATE_POINT: |
|
406 |
daMathPointService.add(importPoint.getExpression(), daPointEntity.getId()); |
|
407 |
daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_C.name())); |
|
408 |
break; |
|
409 |
case CONSTANT: |
|
410 |
daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_F.name())); |
|
411 |
break; |
eb1c5f
|
412 |
case CUMULATE: |
潘 |
413 |
DaCumulatePointDTO cumulatePoint = new DaCumulatePointDTO(); |
|
414 |
cumulatePoint.setMomentPoint(importPoint.getMomentPoint()); |
|
415 |
cumulatePoint.setLength(importPoint.getLength()); |
|
416 |
cumulatePoint.setDivisor(importPoint.getDivisor()); |
|
417 |
daCumulatePointService.add(cumulatePoint, daPointEntity.getId()); |
|
418 |
daPointEntity.setPointNo(daSequenceNumService.getAndIncreaseByCode(IncreaseCodeEnum.POINT_L.name())); |
01d6f8
|
419 |
default: |
潘 |
420 |
break; |
|
421 |
} |
139c6a
|
422 |
|
D |
423 |
daPointDao.insert(daPointEntity); |
13e045
|
424 |
daPointCollectStatusService.add(daPointEntity.getPointNo()); |
139c6a
|
425 |
respVO.getCreatePointnames().add(importPoint.getPointName()); |
D |
426 |
return; |
|
427 |
} |
|
428 |
|
|
429 |
// 如果存在,判断是否允许更新 |
|
430 |
if (!isUpdateSupport) { |
|
431 |
respVO.getFailurePointnames().put(importPoint.getPointName(), POINT_EXISTS.getMsg()); |
|
432 |
return; |
|
433 |
} |
|
434 |
|
|
435 |
DaPointEntity updatePoint = BeanUtils.toBean(importPoint, DaPointEntity.class); |
|
436 |
updatePoint.setId(existPoint.getId()); |
|
437 |
baseMapper.updateById(updatePoint); |
|
438 |
DaMeasurePointEntity measurePoint = new DaMeasurePointEntity(); |
|
439 |
measurePoint.setSourceType(importPoint.getSourceType()); |
01d6f8
|
440 |
measurePoint.setSourceId(sourcesIdMap.get(importPoint.getSourceType()).get(importPoint.getSourceName())); |
139c6a
|
441 |
measurePoint.setTagNo(importPoint.getTagNo()); |
D |
442 |
daMeasurePointService.update(measurePoint, new QueryWrapper<DaMeasurePointEntity>().eq("point_id",updatePoint.getId())); |
|
443 |
respVO.getUpdatePointnames().add(importPoint.getPointName()); |
|
444 |
}); |
|
445 |
return respVO; |
|
446 |
} |
|
447 |
|
|
448 |
@Override |
14cb32
|
449 |
public List<DaPointDTO> getList(DaPointPageReqVO exportReqVO) { |
潘 |
450 |
return daPointDao.getList(exportReqVO); |
139c6a
|
451 |
} |
D |
452 |
|
|
453 |
@Override |
ee9f60
|
454 |
@DSTransactional(rollbackFor = Exception.class) |
a6de49
|
455 |
public void enableByIds(String[] ids) { |
H |
456 |
if (CollectionUtils.isEmpty(Arrays.asList(ids))) { |
|
457 |
return; |
|
458 |
} |
|
459 |
Arrays.asList(ids).forEach(item -> { |
|
460 |
DaPointEntity entity = new DaPointEntity(); |
|
461 |
entity.setId(item); |
f21253
|
462 |
entity.setIsEnable(IsEnableEnum.ENABLE.getCode()); |
ee9f60
|
463 |
entity.setUpdateTime(new Date()); |
6bf63b
|
464 |
daPointDao.updateById(entity); |
a6de49
|
465 |
}); |
H |
466 |
} |
|
467 |
|
|
468 |
@Override |
ee9f60
|
469 |
@DSTransactional(rollbackFor = Exception.class) |
a6de49
|
470 |
public void disableByIds(String[] ids) { |
H |
471 |
if (CollectionUtils.isEmpty(Arrays.asList(ids))) { |
|
472 |
return; |
|
473 |
} |
|
474 |
Arrays.asList(ids).forEach(item -> { |
|
475 |
DaPointEntity entity = new DaPointEntity(); |
|
476 |
entity.setId(item); |
f21253
|
477 |
entity.setIsEnable(IsEnableEnum.DISABLE.getCode()); |
ee9f60
|
478 |
entity.setUpdateTime(new Date()); |
6bf63b
|
479 |
daPointDao.updateById(entity); |
a6de49
|
480 |
}); |
H |
481 |
} |
|
482 |
} |