潘志宝
2025-03-14 cd069965f32189683598ac1096dab66c992c517b
BAD点值修复
已修改4个文件
40 ■■■■ 文件已修改
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/impl/InfluxDBServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CalculateHandle.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/influxdb/service/impl/InfluxDBServiceImpl.java
@@ -304,8 +304,10 @@
            sql.append("'");
            InfluxQLQueryResult data = influxQLQueryApi.query(new InfluxQLQuery(sql.toString(), influxDBInstance.getBucket()));
            Object value = data.getResults().get(0).getSeries().get(0).getValues().get(0).getValueByKey("last");
            if (value != null) {
            result.put(point.getPoint(), value);
        }
        }
        return result;
    }
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/PointCollector.java
@@ -1,5 +1,6 @@
package com.iailab.module.data.point.collection;
import com.alibaba.fastjson.JSONObject;
import com.iailab.module.data.common.enums.DataSourceType;
import com.iailab.module.data.common.utils.R;
import com.iailab.module.data.channel.kio.collector.KingIOCollector;
@@ -100,13 +101,40 @@
            List<DaPointDTO> pointMeasureList = daPointService.getMeasurePoint(minfreq);
            pointValues.addAll(measureHandle.handle(collectTime, pointMeasureList, dataMap, listGood, listBad));
            List<String> listBadNew = new ArrayList<>();
            if (!CollectionUtils.isEmpty(listBad)) {
                log.info("BAD点值修复");
                List<InfluxPointValuePOJO> influxParams = new ArrayList<>();
                for (String bad : listBad) {
                    DaPointDTO daPointDTO = daPointService.getByNo(bad);
                    InfluxPointValuePOJO pojo = new InfluxPointValuePOJO();
                    pojo.setPoint(bad);
                    pojo.setType(daPointDTO.getDataType());
                    influxParams.add(pojo);
                }
                Map<String, Object> lastValue = influxDBService.queryPointsLastValue(influxParams);
                log.info("lastValue=" + JSONObject.toJSONString(lastValue));
                if (!CollectionUtils.isEmpty(lastValue)) {
                    for (String bad : listBad) {
                        if (lastValue.containsKey(bad)) {
                            listGood.add(bad);
                            dataMap.put(bad, lastValue.get(bad));
                        } else {
                            listBadNew.add(bad);
                        }
                    }
                } else {
                    listBadNew = listBad;
                }
            }
            log.info("读取计算点");
            List<DaPointDTO> pointCalculateList = daPointService.getMathPoint(minfreq);
            pointValues.addAll(calculateHandle.handle(collectTime, pointCalculateList, dataMap, listGood, listBad));
            pointValues.addAll(calculateHandle.handle(collectTime, pointCalculateList, dataMap, listGood, listBadNew));
            log.info("读取累计点");
            List<DaPointDTO> pointCumulateList = daPointService.getCumulatePoint(minfreq);
            pointValues.addAll(cumulateHandle.handle(collectTime, pointCumulateList, listGood, listBad));
            pointValues.addAll(cumulateHandle.handle(collectTime, pointCumulateList, listGood, listBadNew));
            log.info("存入时序库");
            influxDBService.asyncWritePointValues(pointValues);
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CalculateHandle.java
@@ -13,6 +13,7 @@
import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
@@ -22,7 +23,6 @@
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java
@@ -41,10 +41,6 @@
@Component
public class MeasureHandle {
    private BigDecimal maxValue = new BigDecimal("1000000000");
    private BigDecimal minValue = new BigDecimal("0");
    @Resource
    private ModBusCollector modBusCollector;