From 6a8e248a786e4a3f5ec76d46e21057f8fd84300a Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期六, 18 一月 2025 13:41:45 +0800
Subject: [PATCH] singleCompute 修改

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java
index c7475c9..0ab1552 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java
@@ -29,7 +29,9 @@
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
+import java.time.Duration;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 
 /**
  * @author PanZhibao
@@ -73,9 +75,9 @@
     @Autowired
     private RedisTemplate<String, Object> redisTemplate;
 
-    public static final String PV = "PV_";
+    public static final String PV = "point_value:";
 
-    public static final int offset = 60 * 3;
+    public static final long offset = 60 * 2L;
 
     /**
      * 采集
@@ -87,22 +89,24 @@
         try {
             Map<String, Object> dataMap = new HashMap<>();
             List<InfluxPointValuePOJO> pointValues = new ArrayList<>();
-
+            // 记录点位状态
+            List<String> listGood = new ArrayList<>();
+            List<String> listBad = new ArrayList<>();
             log.info("读取常量点");
             List<DaPointDTO> pointConstantList = daPointService.getConstantPoint(minfreq);
-            pointValues.addAll(constantHandle.handle(collectTime, pointConstantList, dataMap));
+            pointValues.addAll(constantHandle.handle(collectTime, pointConstantList, dataMap, listGood, listBad));
 
             log.info("读取测量点");
             List<DaPointDTO> pointMeasureList = daPointService.getMeasurePoint(minfreq);
-            pointValues.addAll(measureHandle.handle(collectTime, pointMeasureList, dataMap));
+            pointValues.addAll(measureHandle.handle(collectTime, pointMeasureList, dataMap, listGood, listBad));
 
             log.info("读取计算点");
             List<DaPointDTO> pointCalculateList = daPointService.getMathPoint(minfreq);
-            pointValues.addAll(calculateHandle.handle(collectTime, pointCalculateList, dataMap));
+            pointValues.addAll(calculateHandle.handle(collectTime, pointCalculateList, dataMap, listGood, listBad));
 
             log.info("读取累计点");
             List<DaPointDTO> pointCumulateList = daPointService.getCumulatePoint(minfreq);
-            pointValues.addAll(cumulateHandle.handle(collectTime, pointCumulateList));
+            pointValues.addAll(cumulateHandle.handle(collectTime, pointCumulateList, listGood, listBad));
 
             log.info("存入时序库");
             influxDBService.asyncWritePointValues(pointValues);
@@ -111,17 +115,17 @@
             for (InfluxPointValuePOJO pointValue : pointValues) {
                 if (pointValue instanceof InfluxPointValueSimPOJO) {
                     InfluxPointValueSimPOJO simPOJO = (InfluxPointValueSimPOJO) pointValue;
-                    redisTemplate.opsForValue().set(PV + simPOJO.getPoint(), simPOJO.getValue(), offset);
+                    redisTemplate.opsForValue().set(PV + simPOJO.getPoint(), simPOJO.getValue().doubleValue(), offset, TimeUnit.SECONDS);
                 } else if (pointValue instanceof InfluxPointValueDigPOJO) {
                     InfluxPointValueDigPOJO digPOJO = (InfluxPointValueDigPOJO) pointValue;
-                    redisTemplate.opsForValue().set(PV + digPOJO.getPoint(), digPOJO.getValue(), offset);
+                    redisTemplate.opsForValue().set(PV + digPOJO.getPoint(), digPOJO.getValue().intValue(), offset, TimeUnit.SECONDS);
                 } else if (pointValue instanceof InfluxPointValueBoolPOJO) {
                     InfluxPointValueBoolPOJO boolPOJO = (InfluxPointValueBoolPOJO) pointValue;
-                    redisTemplate.opsForValue().set(PV + boolPOJO.getPoint(), boolPOJO.getValue(), offset);
+                    redisTemplate.opsForValue().set(PV + boolPOJO.getPoint(), boolPOJO.getValue().booleanValue(), offset, TimeUnit.SECONDS);
                 }
             }
             log.info("更新采集状态");
-            daPointCollectStatusService.recordStatusList(pointValues, collectTime);
+            daPointCollectStatusService.recordStatusList(listGood, listBad, collectTime);
             log.info("采集完成");
         } catch (Exception ex) {
             log.info("采集异常!");
@@ -141,6 +145,7 @@
             data.putAll(cumulateHandle.getCurrent(pointNos));
             return data;
         } catch (Exception ex) {
+            ex.printStackTrace();
             return R.error(ex.getMessage());
         }
 

--
Gitblit v1.9.3