From cd069965f32189683598ac1096dab66c992c517b Mon Sep 17 00:00:00 2001
From: 潘志宝 <979469083@qq.com>
Date: 星期五, 14 三月 2025 16:36:10 +0800
Subject: [PATCH] BAD点值修复

---
 iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java
index fd55e6d..6002f45 100644
--- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java
+++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java
@@ -1,6 +1,8 @@
 package com.iailab.module.data.point.collection.handler;
 
+import com.iailab.framework.common.util.string.StrUtils;
 import com.iailab.module.data.channel.http.collector.SourceApiEnum;
+import com.iailab.module.data.channel.http.collector.asdb.HttpCollectorForAsdb;
 import com.iailab.module.data.channel.http.collector.ihdb.HttpCollectorForIhd;
 import com.iailab.module.data.channel.opcda.collector.OpcDACollector;
 import com.iailab.module.data.common.enums.CommonConstant;
@@ -39,10 +41,6 @@
 @Component
 public class MeasureHandle {
 
-    private BigDecimal maxValue = new BigDecimal("1000000000");
-
-    private BigDecimal minValue = new BigDecimal("0");
-
     @Resource
     private ModBusCollector modBusCollector;
 
@@ -57,6 +55,9 @@
 
     @Autowired
     private HttpCollectorForIhd httpCollectorForIhd;
+
+    @Autowired
+    private HttpCollectorForAsdb httpCollectorForAsdb;
 
     @Resource
     private DaPointService daPointService;
@@ -76,7 +77,7 @@
         List<String[]> modbusTagIds = new ArrayList<>();
         List<String[]> kioTagIds = new ArrayList<>();
         List<Object[]> httpTagIhd = new ArrayList<>();
-
+        List<Object[]> httpTagAsdb = new ArrayList<>();
 
         dtos.stream().forEach(item -> {
             if (DataSourceType.OPCUA.getCode().equals(item.getSourceType())) {
@@ -91,6 +92,10 @@
                 if (SourceApiEnum.iHyperDB.getCode().equals(item.getSourceName())) {
                     if (item.getTagNo() != null && item.getDimension() != null && item.getValueType() != null) {
                         httpTagIhd.add(new Object[]{item.getSourceId(), item.getTagNo(), item.getDimension(), item.getValueType()});
+                    }
+                } else if (SourceApiEnum.ASDB.getCode().equals(item.getSourceName())) {
+                    if (item.getTagNo() != null && item.getDimension() != null && item.getValueType() != null) {
+                        httpTagAsdb.add(new Object[]{item.getSourceId(), item.getTagNo(), item.getDimension(), item.getValueType()});
                     }
                 }
             }
@@ -111,6 +116,9 @@
         }
         if (!CollectionUtils.isEmpty(httpTagIhd)) {
             tagValues.putAll(httpCollectorForIhd.getTagValues(httpTagIhd, collectTime));
+        }
+        if (!CollectionUtils.isEmpty(httpTagAsdb)) {
+            tagValues.putAll(httpCollectorForAsdb.getTagValues(httpTagAsdb, collectTime));
         }
         this.toCommonResult(collectTime, dtos, tagValues, dataMap, result,listGood,listBad);
         log.info("测量点处理结束");
@@ -182,9 +190,13 @@
         pointMeasureList.forEach(
                 item -> {
                     try {
-                        boolean hasKey = redisTemplate.hasKey(PointCollector.PV + item.getPointNo());
                         Object value = CommonConstant.BAD_VALUE;
+                        boolean hasKey = redisTemplate.hasKey(PointCollector.PV + item.getPointNo());
                         if (hasKey) {
+                            value = redisTemplate.opsForValue().get(PointCollector.PV + item.getPointNo());
+                        }
+                        if(hasKey && StrUtils.isNumeric(value.toString()) &&
+                                new BigDecimal(value.toString()).compareTo(CommonConstant.BAD_VALUE) != 0 ) {
                             value = redisTemplate.opsForValue().get(PointCollector.PV + item.getPointNo());
                         } else if (DataSourceType.OPCUA.getCode().equals(item.getSourceType())) {
                             value = opcUaCollector.getTagValue(item.getSourceId(), item.getTagNo());
@@ -193,7 +205,11 @@
                         } else if (DataSourceType.KIO.getCode().equals(item.getSourceType())) {
                             value = kingIOCollector.getTagValue(item.getSourceId(), item.getTagNo());
                         } else if (DataSourceType.HTTP.getCode().equals(item.getSourceType())) {
-                            value = httpCollectorForIhd.getTagValue(item.getSourceId(), item.getTagNo(), item.getDimension(), item.getValueType());
+                            if (SourceApiEnum.iHyperDB.getCode().equals(item.getSourceName())) {
+                                value = httpCollectorForIhd.getTagValue(item.getSourceId(), item.getTagNo(), item.getDimension(), item.getValueType());
+                            } else if (SourceApiEnum.ASDB.getCode().equals(item.getSourceName())) {
+                                value = httpCollectorForAsdb.getTagValue(item.getSourceId(), item.getTagNo());
+                            }
                         } else {
                             log.info("没有匹配的TagNo=" + item.getTagNo());
                         }

--
Gitblit v1.9.3