| | |
| | | @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)) { |
| | |
| | | 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); |
| | | } |
| | | }); |
| | |
| | | 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(); |