提交 | 用户 | 时间
|
2228b6
|
1 |
package com.iailab.module.data.point.service.impl; |
潘 |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.iailab.framework.common.service.impl.BaseServiceImpl; |
|
5 |
import com.iailab.module.data.common.enums.DataQualityEnum; |
161f55
|
6 |
import com.iailab.module.data.influxdb.pojo.InfluxPointValueDigPOJO; |
潘 |
7 |
import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
|
8 |
import com.iailab.module.data.influxdb.pojo.InfluxPointValueSimPOJO; |
2228b6
|
9 |
import com.iailab.module.data.point.dao.DaPointCollectStatusDao; |
潘 |
10 |
import com.iailab.module.data.point.entity.DaPointCollectStatusEntity; |
|
11 |
import com.iailab.module.data.point.service.DaPointCollectStatusService; |
|
12 |
import org.springframework.stereotype.Service; |
161f55
|
13 |
import org.springframework.util.CollectionUtils; |
2228b6
|
14 |
|
161f55
|
15 |
import java.util.ArrayList; |
2228b6
|
16 |
import java.util.Date; |
161f55
|
17 |
import java.util.List; |
2228b6
|
18 |
import java.util.UUID; |
潘 |
19 |
|
|
20 |
/** |
|
21 |
* @author PanZhibao |
|
22 |
* @Description |
|
23 |
* @createTime 2024年12月13日 |
|
24 |
*/ |
|
25 |
@Service |
|
26 |
public class DaPointCollectStatusServiceImpl extends BaseServiceImpl<DaPointCollectStatusDao, DaPointCollectStatusEntity> |
|
27 |
implements DaPointCollectStatusService { |
|
28 |
|
90e342
|
29 |
@Override |
潘 |
30 |
public void add(String pointNo) { |
|
31 |
DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity(); |
|
32 |
entity.setId(UUID.randomUUID().toString()); |
|
33 |
entity.setPointNo(pointNo); |
|
34 |
baseDao.insert(entity); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
6b1383
|
38 |
public void recordStatus(String pointNo, String collectValue, Date collectTime) { |
2228b6
|
39 |
QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>(); |
6b1383
|
40 |
queryWrapper.eq("point_no", pointNo); |
2228b6
|
41 |
DaPointCollectStatusEntity entity = baseDao.selectOne(queryWrapper); |
潘 |
42 |
if (entity == null) { |
|
43 |
entity = new DaPointCollectStatusEntity(); |
|
44 |
entity.setId(UUID.randomUUID().toString()); |
6b1383
|
45 |
entity.setPointNo(pointNo); |
2228b6
|
46 |
entity.setCollectValue(collectValue); |
潘 |
47 |
entity.setCollectQuality(DataQualityEnum.getEumByValue(collectValue).getCode()); |
|
48 |
entity.setCollectTime(collectTime); |
|
49 |
baseDao.insert(entity); |
|
50 |
} else { |
|
51 |
entity.setCollectValue(collectValue); |
|
52 |
entity.setCollectQuality(DataQualityEnum.getEumByValue(collectValue).getCode()); |
|
53 |
entity.setCollectTime(collectTime); |
|
54 |
baseDao.updateById(entity); |
|
55 |
} |
|
56 |
|
|
57 |
} |
161f55
|
58 |
|
90e342
|
59 |
@Override |
161f55
|
60 |
public void recordStatusList(List<InfluxPointValuePOJO> pointValues, Date collectTime) { |
潘 |
61 |
List<String> listGood = new ArrayList<>(); |
|
62 |
List<String> listBad = new ArrayList<>(); |
|
63 |
Object collectValue = null; |
|
64 |
for (InfluxPointValuePOJO pointValue : pointValues) { |
|
65 |
if (pointValue instanceof InfluxPointValueSimPOJO) { |
|
66 |
InfluxPointValueSimPOJO pvo = (InfluxPointValueSimPOJO) pointValue; |
|
67 |
collectValue = pvo.getValue(); |
|
68 |
} else if (pointValue instanceof InfluxPointValueDigPOJO) { |
|
69 |
InfluxPointValueDigPOJO pvo = (InfluxPointValueDigPOJO) pointValue; |
|
70 |
collectValue = pvo.getValue(); |
|
71 |
} else { |
|
72 |
continue; |
|
73 |
} |
|
74 |
switch (DataQualityEnum.getEumByValue(collectValue)) { |
|
75 |
case GOOD: |
|
76 |
listGood.add(pointValue.getPoint()); |
|
77 |
break; |
|
78 |
case BAD: |
|
79 |
listBad.add(pointValue.getPoint()); |
|
80 |
break; |
|
81 |
default: |
|
82 |
break; |
|
83 |
} |
|
84 |
} |
|
85 |
if (!CollectionUtils.isEmpty(listGood)) { |
|
86 |
QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>(); |
|
87 |
queryWrapper.in("point_no", listGood); |
|
88 |
DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity(); |
|
89 |
entity.setCollectTime(collectTime); |
|
90 |
entity.setCollectQuality(DataQualityEnum.GOOD.getCode()); |
|
91 |
baseDao.update(entity, queryWrapper); |
|
92 |
} |
|
93 |
if (!CollectionUtils.isEmpty(listBad)) { |
|
94 |
QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>(); |
|
95 |
queryWrapper.in("point_no", listBad); |
|
96 |
DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity(); |
|
97 |
entity.setCollectTime(collectTime); |
|
98 |
entity.setCollectQuality(DataQualityEnum.BAD.getCode()); |
|
99 |
baseDao.update(entity, queryWrapper); |
|
100 |
} |
|
101 |
} |
2228b6
|
102 |
} |