提交 | 用户 | 时间
|
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 |
|
6b1383
|
29 |
public void recordStatus(String pointNo, String collectValue, Date collectTime) { |
2228b6
|
30 |
QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>(); |
6b1383
|
31 |
queryWrapper.eq("point_no", pointNo); |
2228b6
|
32 |
DaPointCollectStatusEntity entity = baseDao.selectOne(queryWrapper); |
潘 |
33 |
if (entity == null) { |
|
34 |
entity = new DaPointCollectStatusEntity(); |
|
35 |
entity.setId(UUID.randomUUID().toString()); |
6b1383
|
36 |
entity.setPointNo(pointNo); |
2228b6
|
37 |
entity.setCollectValue(collectValue); |
潘 |
38 |
entity.setCollectQuality(DataQualityEnum.getEumByValue(collectValue).getCode()); |
|
39 |
entity.setCollectTime(collectTime); |
|
40 |
baseDao.insert(entity); |
|
41 |
} else { |
|
42 |
entity.setCollectValue(collectValue); |
|
43 |
entity.setCollectQuality(DataQualityEnum.getEumByValue(collectValue).getCode()); |
|
44 |
entity.setCollectTime(collectTime); |
|
45 |
baseDao.updateById(entity); |
|
46 |
} |
|
47 |
|
|
48 |
} |
161f55
|
49 |
|
潘 |
50 |
public void recordStatusList(List<InfluxPointValuePOJO> pointValues, Date collectTime) { |
|
51 |
List<String> listGood = new ArrayList<>(); |
|
52 |
List<String> listBad = new ArrayList<>(); |
|
53 |
Object collectValue = null; |
|
54 |
for (InfluxPointValuePOJO pointValue : pointValues) { |
|
55 |
if (pointValue instanceof InfluxPointValueSimPOJO) { |
|
56 |
InfluxPointValueSimPOJO pvo = (InfluxPointValueSimPOJO) pointValue; |
|
57 |
collectValue = pvo.getValue(); |
|
58 |
} else if (pointValue instanceof InfluxPointValueDigPOJO) { |
|
59 |
InfluxPointValueDigPOJO pvo = (InfluxPointValueDigPOJO) pointValue; |
|
60 |
collectValue = pvo.getValue(); |
|
61 |
} else { |
|
62 |
continue; |
|
63 |
} |
|
64 |
switch (DataQualityEnum.getEumByValue(collectValue)) { |
|
65 |
case GOOD: |
|
66 |
listGood.add(pointValue.getPoint()); |
|
67 |
break; |
|
68 |
case BAD: |
|
69 |
listBad.add(pointValue.getPoint()); |
|
70 |
break; |
|
71 |
default: |
|
72 |
break; |
|
73 |
} |
|
74 |
} |
|
75 |
if (!CollectionUtils.isEmpty(listGood)) { |
|
76 |
QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>(); |
|
77 |
queryWrapper.in("point_no", listGood); |
|
78 |
DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity(); |
|
79 |
entity.setCollectTime(collectTime); |
|
80 |
entity.setCollectQuality(DataQualityEnum.GOOD.getCode()); |
|
81 |
baseDao.update(entity, queryWrapper); |
|
82 |
} |
|
83 |
if (!CollectionUtils.isEmpty(listBad)) { |
|
84 |
QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>(); |
|
85 |
queryWrapper.in("point_no", listBad); |
|
86 |
DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity(); |
|
87 |
entity.setCollectTime(collectTime); |
|
88 |
entity.setCollectQuality(DataQualityEnum.BAD.getCode()); |
|
89 |
baseDao.update(entity, queryWrapper); |
|
90 |
} |
|
91 |
} |
2228b6
|
92 |
} |