From 76743b009ca5ea67557fcab597b332f8d1947813 Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期二, 24 十二月 2024 14:09:04 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java index 5dbff70..23a3287 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java @@ -7,14 +7,18 @@ 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.*; @@ -29,9 +33,15 @@ @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<>(); @@ -57,6 +67,26 @@ log.info("累计点处理异常!"); } 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; } @@ -102,6 +132,10 @@ //找出缺少项 Map<Long, Double> sourceDataMap = new HashMap<>(dataList.size()); + for (ApiPointValueDTO pv : dataList) { + sourceDataMap.put(pv.getT().getTime(), pv.getV()); + } + Map<Long, Double> dataMap = new LinkedHashMap<>(); for (int i = 0; i < mins; i++) { Long key = start + oneMin * i; -- Gitblit v1.9.3