From c7ec0ceff9cf30cabbd8d071c1ef75d20d04548f Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 01 四月 2025 17:33:28 +0800 Subject: [PATCH] Day频率数据采集时分秒置0 getByMin --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java | 84 ++++++++++++++++++++++++++++++++---------- 1 files changed, 64 insertions(+), 20 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..9fbd7ee 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,10 @@ 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.asdb.HttpCollectorForAsdc; +import com.iailab.module.data.channel.http.collector.asdb.HttpCollectorForAsde; 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; @@ -10,6 +14,7 @@ import com.iailab.module.data.channel.kio.collector.KingIOCollector; import com.iailab.module.data.channel.modbus.collector.ModBusCollector; import com.iailab.module.data.channel.opcua.collector.OpcUaCollector; +import com.iailab.module.data.enums.DataPointFreqEnum; import com.iailab.module.data.point.collection.PointCollector; import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; import com.iailab.module.data.point.common.PointDataTypeEnum; @@ -39,10 +44,6 @@ @Component public class MeasureHandle { - private BigDecimal maxValue = new BigDecimal("1000000000"); - - private BigDecimal minValue = new BigDecimal("0"); - @Resource private ModBusCollector modBusCollector; @@ -58,13 +59,22 @@ @Autowired private HttpCollectorForIhd httpCollectorForIhd; + @Autowired + private HttpCollectorForAsdb httpCollectorForAsdb; + + @Autowired + private HttpCollectorForAsde httpCollectorForAsde; + + @Autowired + private HttpCollectorForAsdc httpCollectorForAsdc; + @Resource private DaPointService daPointService; @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)) { @@ -76,7 +86,9 @@ List<String[]> modbusTagIds = new ArrayList<>(); List<String[]> kioTagIds = new ArrayList<>(); List<Object[]> httpTagIhd = new ArrayList<>(); - + List<Object[]> httpTagAsdb = new ArrayList<>(); + List<Object[]> httpTagAsde = new ArrayList<>(); + List<Object[]> httpTagAsdc = new ArrayList<>(); dtos.stream().forEach(item -> { if (DataSourceType.OPCUA.getCode().equals(item.getSourceType())) { @@ -91,6 +103,18 @@ 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()}); + } + } else if (SourceApiEnum.ASDE.getCode().equals(item.getSourceName())) { + if (item.getTagNo() != null && item.getDimension() != null && item.getValueType() != null) { + httpTagAsde.add(new Object[]{item.getSourceId(), item.getTagNo(), item.getDimension(), item.getValueType()}); + } + } else if (SourceApiEnum.ASDC.getCode().equals(item.getSourceName())) { + if (item.getTagNo() != null && item.getDimension() != null && item.getValueType() != null) { + httpTagAsdc.add(new Object[]{item.getSourceId(), item.getTagNo(), item.getDimension(), item.getValueType()}); } } } @@ -112,27 +136,39 @@ if (!CollectionUtils.isEmpty(httpTagIhd)) { tagValues.putAll(httpCollectorForIhd.getTagValues(httpTagIhd, collectTime)); } - this.toCommonResult(collectTime, dtos, tagValues, dataMap, result); + if (!CollectionUtils.isEmpty(httpTagAsdb)) { + tagValues.putAll(httpCollectorForAsdb.getTagValues(httpTagAsdb, collectTime)); + } + if (!CollectionUtils.isEmpty(httpTagAsde)) { + tagValues.putAll(httpCollectorForAsde.getTagValues(httpTagAsde, collectTime)); + } + if (!CollectionUtils.isEmpty(httpTagAsdc)) { + tagValues.putAll(httpCollectorForAsdc.getTagValues(httpTagAsdc, collectTime)); + } + 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()); + pojo.setTimestamp(GenInfluxPointValueUtils.getByMin(collectTime, DataPointFreqEnum.getEumByCode(dto.getMinfreqid()))); dataMap.put(dto.getPointNo(), value); result.add(pojo); + listGood.add(dto.getPointNo()); } else { - System.out.println("值异常!TagId=" + tagId); + InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, CommonConstant.BAD_VALUE); + pojo.setTimestamp(GenInfluxPointValueUtils.getByMin(collectTime, DataPointFreqEnum.getEumByCode(dto.getMinfreqid()))); + result.add(pojo); + listBad.add(dto.getPointNo()); + log.info("值异常!TagId=" + tagId); } }); } @@ -147,10 +183,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,9 +215,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()); @@ -194,7 +230,15 @@ } 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 if (SourceApiEnum.ASDE.getCode().equals(item.getSourceName())) { + value = httpCollectorForAsde.getTagValue(item.getSourceId(), item.getTagNo()); + } else if (SourceApiEnum.ASDC.getCode().equals(item.getSourceName())) { + value = httpCollectorForAsdc.getTagValue(item.getSourceId(), item.getTagNo()); + } } else { log.info("没有匹配的TagNo=" + item.getTagNo()); } -- Gitblit v1.9.3