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/handler/MeasureHandle.java | 28 ++++++++++++++++------------ 1 files changed, 16 insertions(+), 12 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 482c718..14395b3 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,5 +1,6 @@ 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.ihdb.HttpCollectorForIhd; import com.iailab.module.data.channel.opcda.collector.OpcDACollector; @@ -64,7 +65,7 @@ @Autowired private RedisTemplate<String, Object> redisTemplate; - public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> dataMap) { + public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> dataMap,List<String> listGood,List<String> listBad) { log.info("测量点处理开始"); List<InfluxPointValuePOJO> result = new ArrayList<>(); if (CollectionUtils.isEmpty(dtos)) { @@ -112,26 +113,29 @@ if (!CollectionUtils.isEmpty(httpTagIhd)) { tagValues.putAll(httpCollectorForIhd.getTagValues(httpTagIhd, collectTime)); } - this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + this.toCommonResult(collectTime, dtos, tagValues, dataMap, result,listGood,listBad); log.info("测量点处理结束"); return result; } private void toCommonResult(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> tagValues, - Map<String, Object> dataMap, List<InfluxPointValuePOJO> result) { + 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.get(tagId) != null) { + if (tagValues.containsKey(tagId)) { Object value = handleData(dto, tagValues.get(tagId)); InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, value); pojo.setTimestamp(collectTime.toInstant()); dataMap.put(dto.getPointNo(), value); result.add(pojo); + listGood.add(dto.getPointNo()); } else { + InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, CommonConstant.BAD_VALUE); + pojo.setTimestamp(collectTime.toInstant()); + result.add(pojo); + listBad.add(dto.getPointNo()); System.out.println("值异常!TagId=" + tagId); } }); @@ -147,10 +151,6 @@ if (DataTypeEnum.FLOAT.getCode().equals(dto.getDataType()) || DataTypeEnum.INT.getCode().equals(dto.getDataType())) { BigDecimal rawValue = new BigDecimal(value.toString()); if(CommonConstant.BAD_VALUE.compareTo(rawValue) == 0) { - return CommonConstant.BAD_VALUE; - } - // 异常值处理 - if (rawValue.compareTo(maxValue) > 0 || rawValue.compareTo(minValue) < 0) { return CommonConstant.BAD_VALUE; } BigDecimal coefficient = dto.getUnittransfactor() == null ? BigDecimal.ONE : dto.getUnittransfactor(); @@ -183,10 +183,14 @@ 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()); } else if (DataSourceType.ModBus.getCode().equals(item.getSourceType())) { -- Gitblit v1.9.3