From df99e46312fdd5ee830f1451e478f6658e09f9ed Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期一, 16 十二月 2024 13:41:41 +0800
Subject: [PATCH] 导出测点数据 修改

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointCollectStatusServiceImpl.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointCollectStatusServiceImpl.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointCollectStatusServiceImpl.java
index 74e4931..c426c92 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointCollectStatusServiceImpl.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointCollectStatusServiceImpl.java
@@ -3,12 +3,18 @@
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.iailab.framework.common.service.impl.BaseServiceImpl;
 import com.iailab.module.data.common.enums.DataQualityEnum;
+import com.iailab.module.data.influxdb.pojo.InfluxPointValueDigPOJO;
+import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO;
+import com.iailab.module.data.influxdb.pojo.InfluxPointValueSimPOJO;
 import com.iailab.module.data.point.dao.DaPointCollectStatusDao;
 import com.iailab.module.data.point.entity.DaPointCollectStatusEntity;
 import com.iailab.module.data.point.service.DaPointCollectStatusService;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.List;
 import java.util.UUID;
 
 /**
@@ -20,6 +26,15 @@
 public class DaPointCollectStatusServiceImpl extends BaseServiceImpl<DaPointCollectStatusDao, DaPointCollectStatusEntity>
         implements DaPointCollectStatusService {
 
+    @Override
+    public void add(String pointNo) {
+        DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity();
+        entity.setId(UUID.randomUUID().toString());
+        entity.setPointNo(pointNo);
+        baseDao.insert(entity);
+    }
+
+    @Override
     public void recordStatus(String pointNo, String collectValue, Date collectTime) {
         QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("point_no", pointNo);
@@ -40,4 +55,48 @@
         }
 
     }
+
+    @Override
+    public void recordStatusList(List<InfluxPointValuePOJO> pointValues, Date collectTime) {
+        List<String> listGood = new ArrayList<>();
+        List<String> listBad = new ArrayList<>();
+        Object collectValue = null;
+        for (InfluxPointValuePOJO pointValue : pointValues) {
+            if (pointValue instanceof InfluxPointValueSimPOJO) {
+                InfluxPointValueSimPOJO pvo = (InfluxPointValueSimPOJO) pointValue;
+                collectValue = pvo.getValue();
+            } else if (pointValue instanceof InfluxPointValueDigPOJO) {
+                InfluxPointValueDigPOJO pvo = (InfluxPointValueDigPOJO) pointValue;
+                collectValue = pvo.getValue();
+            } else {
+                continue;
+            }
+            switch (DataQualityEnum.getEumByValue(collectValue)) {
+                case GOOD:
+                    listGood.add(pointValue.getPoint());
+                    break;
+                case BAD:
+                    listBad.add(pointValue.getPoint());
+                    break;
+                default:
+                    break;
+            }
+        }
+        if (!CollectionUtils.isEmpty(listGood)) {
+            QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>();
+            queryWrapper.in("point_no", listGood);
+            DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity();
+            entity.setCollectTime(collectTime);
+            entity.setCollectQuality(DataQualityEnum.GOOD.getCode());
+            baseDao.update(entity, queryWrapper);
+        }
+        if (!CollectionUtils.isEmpty(listBad)) {
+            QueryWrapper<DaPointCollectStatusEntity> queryWrapper = new QueryWrapper<>();
+            queryWrapper.in("point_no", listBad);
+            DaPointCollectStatusEntity entity = new DaPointCollectStatusEntity();
+            entity.setCollectTime(collectTime);
+            entity.setCollectQuality(DataQualityEnum.BAD.getCode());
+            baseDao.update(entity, queryWrapper);
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3