dengzedong
2025-01-10 2fcc1a1b8f09a731af53247d0b5e88397649fb44
iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/MeasureHandle.java
@@ -64,7 +64,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 +112,31 @@
        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);
            });
            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 +152,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();