From bd0cabbd7f67613002d254531de60f91a1521cfc Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Tue, 1 Apr 2025 11:05:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9C=A8=E7=BA=BF=E7=8E=87?= =?UTF-8?q?=E8=A1=A5=E6=8B=9B=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../line/IDataCrossingServiceImpl.java | 14 ++++++++--- .../line/IDataOnlineRateServiceImpl.java | 10 ++++++-- .../line/PollutionServiceImpl.java | 25 +++++++++++++------ 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataCrossingServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataCrossingServiceImpl.java index 4aedc66..f6d660d 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataCrossingServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataCrossingServiceImpl.java @@ -222,19 +222,25 @@ public class IDataCrossingServiceImpl implements IDataCrossingService { if (CollUtil.isNotEmpty(result)) { //存储数据 List dataLimitRate = result.stream().map(DataLimitDetailDto::getDataLimitRate).filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList()); - dataLimitRateFeignClient.batchInsertion(dataLimitRate); + if(CollUtil.isNotEmpty(dataLimitRate)){ + dataLimitRateFeignClient.batchInsertion(dataLimitRate); + } + } if (CollUtil.isNotEmpty(result)) { //存储数据 List detail = result.stream().map(DataLimitDetailDto::getDataLimitRateDetail).filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList()); - dataLimitRateDetailFeignClient.batchInsertion(detail); + if(CollUtil.isNotEmpty(detail)){ + dataLimitRateDetailFeignClient.batchInsertion(detail); + } + } } @Override public void limitTargetHandler(CalculatedParam calculatedParam) { - log.info(LocalDateTime.now() + "r_stat_limit_target_d开始执行=======》"); + logger.info(LocalDateTime.now() + "r_stat_limit_target_d开始执行=======》"); List list = new ArrayList<>(); List limitRateData = new ArrayList<>(); //远程接口获取分钟数据 @@ -1063,7 +1069,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService { if (CollUtil.isNotEmpty(info)) { return JSON.toJSONString(info); } - return ""; + return null; } private void addAbnormalData(List list, String phasicType, String valueType, String time, Double value, float overLimitValue) { diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataOnlineRateServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataOnlineRateServiceImpl.java index 007b5c4..114fa69 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataOnlineRateServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataOnlineRateServiceImpl.java @@ -3,6 +3,7 @@ package com.njcn.algorithm.serviceimpl.line; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; @@ -49,6 +50,7 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService { private Integer NUM = 100; private final Integer online = 1; + private final Integer offline = 0; @Resource private PqsCommunicateFeignClient communicateFeignClient; @Resource @@ -219,8 +221,12 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService { } else { List communicateDataOld = communicateFeignClient.getRawDataEnd(lineParam).getData(); if (communicateDataOld.size() > 0) { - if (online.equals(communicateDataOld.get(0).getType())) { - minute = InfluxDBPublicParam.DAY_MINUTE; + DateTime parse = DateUtil.parse(communicateDataOld.get(0).getTime()); + long differ = DateUtil.between(date, parse, DateUnit.MINUTE); + if (offline.equals(communicateDataOld.get(0).getType())) { + minute = (int) differ; + }else{ + minute = (int) (InfluxDBPublicParam.DAY_MINUTE-differ); } } } diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/PollutionServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/PollutionServiceImpl.java index 402a214..72c1896 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/PollutionServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/PollutionServiceImpl.java @@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.time.LocalDate; import java.util.*; import java.util.function.BinaryOperator; @@ -44,14 +45,22 @@ import java.util.stream.Stream; @RequiredArgsConstructor public class PollutionServiceImpl implements IPollutionService { - private final PqDataVerifyFeignClient pqDataVerifyFeignClient; - private final DicDataFeignClient dicDataFeignClient; - private final CommTerminalGeneralClient commTerminalGeneralClient; - private final DataVFeignClient dataVFeignClient; - private final DataHarmRateVFeignClient dataHarmRateVFeignClient; - private final DataPltFeignClient dataPltFeignClient; - private final DataIFeignClient dataIFeignClient; - private final DataPollutionFeignClient dataPollutionFeignClient; + @Resource + private PqDataVerifyFeignClient pqDataVerifyFeignClient; + @Resource + private DicDataFeignClient dicDataFeignClient; + @Resource + private CommTerminalGeneralClient commTerminalGeneralClient; + @Resource + private DataVFeignClient dataVFeignClient; + @Resource + private DataHarmRateVFeignClient dataHarmRateVFeignClient; + @Resource + private DataPltFeignClient dataPltFeignClient; + @Resource + private DataIFeignClient dataIFeignClient; + @Resource + private DataPollutionFeignClient dataPollutionFeignClient; @Override