| | |
| | | package com.iailab.module.data.point.collection.handler; |
| | | |
| | | import com.iailab.module.data.enums.DataPointFreqEnum; |
| | | import com.iailab.module.data.point.collection.utils.GenInfluxPointValueUtils; |
| | | import com.iailab.module.data.point.dto.DaPointDTO; |
| | | import com.iailab.module.data.point.service.DaPointService; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | private DaPointService daPointService; |
| | | |
| | | 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)) { |
| | | return result; |
| | | } |
| | | dtos.forEach(dto -> { |
| | | InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto); |
| | | pojo.setTimestamp(collectTime.toInstant()); |
| | | dataMap.put(dto.getPointNo(), dto.getDefaultValue()); |
| | | BigDecimal defaultValue = dto.getDefaultValue(); |
| | | BigDecimal coefficient = dto.getUnittransfactor() == null ? BigDecimal.ONE : dto.getUnittransfactor(); |
| | | defaultValue = defaultValue.multiply(coefficient); |
| | | InfluxPointValuePOJO pojo = GenInfluxPointValueUtils.getByPoint(dto,defaultValue); |
| | | pojo.setTimestamp(GenInfluxPointValueUtils.getByMin(collectTime, DataPointFreqEnum.getEumByCode(dto.getMinfreqid()))); |
| | | |
| | | dataMap.put(dto.getPointNo(), defaultValue); |
| | | result.add(pojo); |
| | | listGood.add(dto.getPointNo()); |
| | | }); |
| | | log.info("常量点处理结束"); |
| | | return result; |
| | |
| | | List<DaPointDTO> pointConstantList = daPointService.getConstantPoint(pointNos); |
| | | if (!CollectionUtils.isEmpty(pointConstantList)) { |
| | | pointConstantList.forEach(item -> { |
| | | data.put(item.getPointNo(), item.getDefaultValue()); |
| | | BigDecimal coefficient = item.getUnittransfactor() == null ? BigDecimal.ONE : item.getUnittransfactor(); |
| | | data.put(item.getPointNo(), item.getDefaultValue().multiply(coefficient)); |
| | | }); |
| | | } |
| | | return data; |