From c7ec0ceff9cf30cabbd8d071c1ef75d20d04548f Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期二, 01 四月 2025 17:33:28 +0800 Subject: [PATCH] Day频率数据采集时分秒置0 getByMin --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/point/collection/handler/CumulateHandle.java | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 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 23a3287..c6fb0f2 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 @@ -43,7 +43,7 @@ @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("累计点处理开始"); @@ -52,9 +52,9 @@ } 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()); + pojo.setTimestamp(GenInfluxPointValueUtils.getByMin(collectTime, DataPointFreqEnum.getEumByCode(dto.getMinfreqid()))); result.add(pojo); } catch (Exception ex) { ex.printStackTrace(); @@ -89,10 +89,16 @@ 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(); @@ -108,12 +114,18 @@ 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); } @@ -169,6 +181,6 @@ return item.getValue(); } } - return null; + return 0.0; } } \ No newline at end of file -- Gitblit v1.9.3