| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, List<String> listGood, List<String> listBad) { |
| | | public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos, Map<String, Object> dataMap, List<String> listGood, List<String> listBad) { |
| | | List<InfluxPointValuePOJO> result = new ArrayList<>(); |
| | | try { |
| | | log.info("极值点处理开始"); |
| | |
| | | } |
| | | dtos.forEach(dto -> { |
| | | try { |
| | | Object value = singleCompute(dto, collectTime, listGood, listBad); |
| | | InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, value); |
| | | Object rawValue = singleCompute(dto, collectTime, listGood, listBad); |
| | | BigDecimal coefficient = dto.getUnittransfactor() == null ? BigDecimal.ONE : dto.getUnittransfactor(); |
| | | BigDecimal calValue = new BigDecimal(rawValue.toString()).multiply(coefficient); |
| | | InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto, calValue); |
| | | pojo.setTimestamp(GenInfluxPointValueUtils.getByMin(collectTime, DataPointFreqEnum.getEumByCode(dto.getMinfreqid()))); |
| | | dataMap.put(dto.getPointNo(), calValue); |
| | | result.add(pojo); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | |
| | | value = redisTemplate.opsForValue().get(PointCollector.PV + item.getPointNo()); |
| | | } else { |
| | | value = singleCompute(item, calendar.getTime(), new ArrayList<>(), new ArrayList<>()); |
| | | BigDecimal coefficient = item.getUnittransfactor() == null ? BigDecimal.ONE : item.getUnittransfactor(); |
| | | value = new BigDecimal(value.toString()).multiply(coefficient); |
| | | } |
| | | data.put(item.getPointNo(), value); |
| | | }); |
| | |
| | | |
| | | private Object singleCompute(DaPointDTO dto, Date collectTime, List<String> listGood, List<String> listBad) { |
| | | Object value = CommonConstant.BAD_VALUE; |
| | | ApiPointDTO pointDTO = dataPointApi.getInfoByNo(dto.getMomentPoint()); |
| | | if (pointDTO == null) { |
| | | ApiPointDTO momentPoint = dataPointApi.getInfoByNo(dto.getMomentPoint()); |
| | | if (momentPoint == null) { |
| | | if (listBad != null) { |
| | | listBad.add(dto.getPointNo()); |
| | | } |
| | |
| | | log.info("极值:" + dto.getPointNo()); |
| | | |
| | | // 动态长度 |
| | | ApiPointDTO momentPoint = dataPointApi.getInfoByNo(dto.getMomentPoint()); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(collectTime); |
| | | calendar.add(Calendar.SECOND, -1 * DataPointFreqEnum.getEumByCode(momentPoint.getMinfreqid()).getValue()); |
| | | Date endTime = calendar.getTime(); |
| | | Date startTime = ExtremaUnitEnum.getStartTime(calendar, dto.getLength(), dto.getCumulateUnit()); |
| | | Date startTime = ExtremaUnitEnum.getStartTime(calendar, dto.getLength(), dto.getExtremalUnit()); |
| | | ApiPointValueQueryDTO queryDto = new ApiPointValueQueryDTO(); |
| | | queryDto.setPointNo(momentPoint.getPointNo()); |
| | | queryDto.setStart(startTime); |