From bbe7acfbe5a4c08d6edc91eaf81dcecf9d630e18 Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期日, 15 十二月 2024 15:10:50 +0800
Subject: [PATCH] collectQuality

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/service/impl/DaPointCollectStatusServiceImpl.java |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 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..23c9df6 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;
 
 /**
@@ -40,4 +46,47 @@
         }
 
     }
+
+    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