dengzedong
2025-02-27 6205c22a959fbb3b69735f34af8d3316c4082a5d
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;
@@ -58,6 +60,9 @@
    @Autowired
    private HttpCollectorForIhd httpCollectorForIhd;
    @Autowired
    private HttpCollectorForAsdb httpCollectorForAsdb;
    @Resource
    private DaPointService daPointService;
@@ -76,7 +81,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 +96,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()});
                    }
                }
            }
@@ -112,6 +121,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("测量点处理结束");
        return result;
@@ -120,9 +132,7 @@
    private void toCommonResult(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> tagValues,
                          Map<String, Object> dataMap, List<InfluxPointValuePOJO> result,List<String> listGood,List<String> listBad) {
        if (!CollectionUtils.isEmpty(tagValues)) {
            tagValues.forEach((k, v) -> {
                dataMap.put(k, v);
            });
//            dataMap.putAll(tagValues);
            dtos.forEach(dto -> {
                String tagId = TagUtils.genTagId(dto.getSourceType(), dto.getSourceName(), dto.getTagNo());
                if (tagValues.containsKey(tagId)) {
@@ -184,9 +194,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());
@@ -195,7 +209,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());
                        }