潘志宝
2025-01-18 6a8e248a786e4a3f5ec76d46e21057f8fd84300a
提交 | 用户 | 时间
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
2fcc1a 60     public void recordStatusList(List<String> listGood,List<String> listBad, Date collectTime) {
161f55 61         if (!CollectionUtils.isEmpty(listGood)) {
62             QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>();
63             queryWrapper.in("point_no", listGood);
64             DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity();
65             entity.setCollectTime(collectTime);
66             entity.setCollectQuality(DataQualityEnum.GOOD.getCode());
67             baseDao.update(entity, queryWrapper);
68         }
69         if (!CollectionUtils.isEmpty(listBad)) {
70             QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>();
71             queryWrapper.in("point_no", listBad);
72             DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity();
73             entity.setCollectTime(collectTime);
74             entity.setCollectQuality(DataQualityEnum.BAD.getCode());
75             baseDao.update(entity, queryWrapper);
76         }
77     }
2228b6 78 }