| | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos) { |
| | | public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos,List<String> listGood,List<String> listBad) { |
| | | List<InfluxPointValuePOJO> result = new ArrayList<>(); |
| | | try { |
| | | log.info("累计点处理开始"); |
| | |
| | | } |
| | | dtos.forEach(dto -> { |
| | | try { |
| | | Object value = singleCompute(dto, collectTime); |
| | | Object value = singleCompute(dto, collectTime,listGood,listBad); |
| | | InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, value); |
| | | pojo.setTimestamp(collectTime.toInstant()); |
| | | result.add(pojo); |
| | |
| | | return data; |
| | | } |
| | | |
| | | |
| | | private Object singleCompute(DaPointDTO dto, Date collectTime) { |
| | | return singleCompute(dto,collectTime,null,null); |
| | | } |
| | | |
| | | private Object singleCompute(DaPointDTO dto, Date collectTime,List<String> listGood,List<String> listBad) { |
| | | ApiPointDTO pointDTO = dataPointApi.getInfoByNo(dto.getMomentPoint()); |
| | | if (pointDTO == null) { |
| | | if (listBad != null) { |
| | | listBad.add(dto.getPointNo()); |
| | | } |
| | | return CommonConstant.BAD_VALUE; |
| | | } |
| | | Calendar calendar = Calendar.getInstance(); |
| | |
| | | |
| | | List<ApiPointValueDTO> dataList = dataPointApi.queryPointHistoryValue(queryDto); |
| | | if (CollectionUtils.isEmpty(dataList)) { |
| | | if (listGood != null) { |
| | | listGood.add(dto.getPointNo()); |
| | | } |
| | | return BigDecimal.ZERO; |
| | | } else if (dataList.size() < dto.getLength()) { |
| | | // 补全数据 |
| | | dataList = completionData(dto.getLength(), dataList, startTime, endTime, pointDTO); |
| | | } |
| | | double total = dataList.stream().mapToDouble(ApiPointValueDTO::getV).sum(); |
| | | if (listGood != null) { |
| | | listGood.add(dto.getPointNo()); |
| | | } |
| | | return new BigDecimal(total).divide(new BigDecimal(dto.getDivisor()), 2, BigDecimal.ROUND_HALF_UP); |
| | | } |
| | | |
| | |
| | | return item.getValue(); |
| | | } |
| | | } |
| | | return null; |
| | | return 0.0; |
| | | } |
| | | } |