| | |
| | | import com.iailab.module.data.common.enums.CommonConstant; |
| | | import com.iailab.module.data.enums.DataPointFreqEnum; |
| | | import com.iailab.module.data.influxdb.pojo.InfluxPointValuePOJO; |
| | | import com.iailab.module.data.point.collection.PointCollector; |
| | | 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 lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | |
| | |
| | | @Component |
| | | public class CumulateHandle { |
| | | |
| | | @Resource |
| | | private DaPointService daPointService; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private DataPointApi dataPointApi; |
| | | |
| | | @Autowired |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | public List<InfluxPointValuePOJO> handle(Date collectTime, List<DaPointDTO> dtos) { |
| | | List<InfluxPointValuePOJO> result = new ArrayList<>(); |
| | |
| | | return result; |
| | | } |
| | | |
| | | public Map<String, Object> getCurrent(List<String> pointNos) { |
| | | Map<String, Object> data = new HashMap<>(); |
| | | List<DaPointDTO> pointMathList = daPointService.getCumulatePoint(pointNos); |
| | | if (CollectionUtils.isEmpty(pointMathList)) { |
| | | return data; |
| | | } |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.set(Calendar.MILLISECOND, 0); |
| | | pointMathList.forEach(item -> { |
| | | Object value = CommonConstant.BAD_VALUE; |
| | | if (redisTemplate.hasKey(PointCollector.PV + item.getPointNo())) { |
| | | value = redisTemplate.opsForValue().get(PointCollector.PV + item.getPointNo()); |
| | | } else { |
| | | value = singleCompute(item, calendar.getTime()); |
| | | } |
| | | data.put(item.getPointNo(), value); |
| | | }); |
| | | return data; |
| | | } |
| | | |
| | | |
| | | private Object singleCompute(DaPointDTO dto, Date collectTime) { |
| | | ApiPointDTO pointDTO = dataPointApi.getInfoByNo(dto.getMomentPoint()); |