From 5bf42aa9950058f391805e6fb8d7376f4378924b Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期一, 23 十二月 2024 16:16:55 +0800
Subject: [PATCH] cumulateHandle.getCurrent

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java
index d66ceab..e2baacc 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java
@@ -9,11 +9,14 @@
 import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO;
 import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils;
 import com.iailab.module.data.point.dto.DaPointDTO;
+import com.iailab.module.data.point.service.DaPointService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.*;
 
@@ -28,7 +31,11 @@
 @Component
 public class CumulateHandle {
 
+    @Resource
+    private DaPointService daPointService;
+
     @Autowired
+    @Lazy
     private DataPointApi dataPointApi;
 
     public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos) {
@@ -55,6 +62,20 @@
             log.info("累计点处理异常!");
         }
         return result;
+    }
+
+    public Map<String, Object> getCurrent(List<String> pointNos) {
+        Map<String, Object> data = new HashMap<>();
+        List<DaPointDTO> pointMathList = daPointService.getCumulatePoint(pointNos);
+        if (CollectionUtils.isEmpty(pointMathList)) {
+            return data;
+        }
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.MILLISECOND, 0);
+        pointMathList.forEach(item -> {
+            data.put(item.getPointNo(), singleCompute(item, calendar.getTime()));
+        });
+        return data;
     }
 
 
@@ -100,6 +121,10 @@
 
         //找出缺少项
         Map<Long, Double> sourceDataMap = new HashMap<>(dataList.size());
+        for (ApiPointValueDTO pv : dataList) {
+            sourceDataMap.put(pv.getT().getTime(), pv.getV());
+        }
+
         Map<Long, Double> dataMap = new LinkedHashMap<>();
         for (int i = 0; i < mins; i++) {
             Long key = start + oneMin * i;

--
Gitblit v1.9.3