From ff0cbc7151b19aaafb20dad2ff564f2678226f03 Mon Sep 17 00:00:00 2001 From: hzj <826100833@qq.com> Date: Tue, 9 Jun 2026 16:28:04 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E5=B0=86=E5=85=A5=E5=BA=93=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=A4=9A=E7=BA=BF=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/LnDataDealServiceImpl.java | 55 ++++++++++++++----- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java index 572771c..3c6aece 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java @@ -16,10 +16,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import javax.annotation.Resource; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; import java.util.stream.Collectors; /** @@ -66,22 +70,45 @@ public class LnDataDealServiceImpl implements LnDataDealService { private LineFeignClient lineFeignClient; @QueryBean private IPqsCommunicate iPqsCommunicate; - + @Resource(name="asyncExecutor") + private Executor executor; @Override public void batchInsertion(LnDataDTO lnDataDTO) { - dataVService.batchInsertion(lnDataDTO.getDataVList()); - dataHarmrateVQuery.batchInsertion(lnDataDTO.getDataHarmrateVDTOList()); - dataFlickerQuery.batchInsertion(lnDataDTO.getDataFlickerDTOList()); - dataFlucQuery.batchInsertion(lnDataDTO.getDataFlucDTOList()); - dataHarmphasicIQuery.batchInsertion(lnDataDTO.getDataHarmphasicIDTOList()); - dataHarmphasicVQuery.batchInsertion(lnDataDTO.getDataHarmphasicVDTOList()); - dataHarmpowerPService.batchInsertion(lnDataDTO.getDataHarmpowerPDTOList()); - dataHarmpowerQService.batchInsertion(lnDataDTO.getDataHarmpowerQDTOList()); - dataHarmpowerSService.batchInsertion(lnDataDTO.getDataHarmpowerSDTOList()); - dataIService.batchInsertion(lnDataDTO.getDataIDTOList()); - dataInharmIService.batchInsertion(lnDataDTO.getDataInharmIDTOList()); - dataInharmVService.batchInsertion(lnDataDTO.getDataInharmVDTOList()); - dataPltService.batchInsertion(lnDataDTO.getDataPltDTOList()); + + List> futures = new ArrayList<>(); +// 提交每个批量插入任务 + futures.add(CompletableFuture.runAsync(() -> dataVService.batchInsertion(lnDataDTO.getDataVList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataHarmrateVQuery.batchInsertion(lnDataDTO.getDataHarmrateVDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataFlickerQuery.batchInsertion(lnDataDTO.getDataFlickerDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataFlucQuery.batchInsertion(lnDataDTO.getDataFlucDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataHarmphasicIQuery.batchInsertion(lnDataDTO.getDataHarmphasicIDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataHarmphasicVQuery.batchInsertion(lnDataDTO.getDataHarmphasicVDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataHarmpowerPService.batchInsertion(lnDataDTO.getDataHarmpowerPDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataHarmpowerQService.batchInsertion(lnDataDTO.getDataHarmpowerQDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataHarmpowerSService.batchInsertion(lnDataDTO.getDataHarmpowerSDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataIService.batchInsertion(lnDataDTO.getDataIDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataInharmIService.batchInsertion(lnDataDTO.getDataInharmIDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataInharmVService.batchInsertion(lnDataDTO.getDataInharmVDTOList()), executor)); + futures.add(CompletableFuture.runAsync(() -> dataPltService.batchInsertion(lnDataDTO.getDataPltDTOList()), executor)); + + // 等待所有任务完成,如果任一任务抛出异常,这里会重新抛出 + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); + + // 关闭线程池(优雅关闭,等待已提交任务完成) + +// dataVService.batchInsertion(lnDataDTO.getDataVList()); +// dataHarmrateVQuery.batchInsertion(lnDataDTO.getDataHarmrateVDTOList()); +// dataFlickerQuery.batchInsertion(lnDataDTO.getDataFlickerDTOList()); +// dataFlucQuery.batchInsertion(lnDataDTO.getDataFlucDTOList()); +// dataHarmphasicIQuery.batchInsertion(lnDataDTO.getDataHarmphasicIDTOList()); +// dataHarmphasicVQuery.batchInsertion(lnDataDTO.getDataHarmphasicVDTOList()); +// dataHarmpowerPService.batchInsertion(lnDataDTO.getDataHarmpowerPDTOList()); +// dataHarmpowerQService.batchInsertion(lnDataDTO.getDataHarmpowerQDTOList()); +// dataHarmpowerSService.batchInsertion(lnDataDTO.getDataHarmpowerSDTOList()); +// dataIService.batchInsertion(lnDataDTO.getDataIDTOList()); +// dataInharmIService.batchInsertion(lnDataDTO.getDataInharmIDTOList()); +// dataInharmVService.batchInsertion(lnDataDTO.getDataInharmVDTOList()); +// dataPltService.batchInsertion(lnDataDTO.getDataPltDTOList()); //更新mysqldevice表最新数据时间 if(!CollectionUtils.isEmpty(lnDataDTO.getDataVList())){ From cf0c0085e92f45473ed28d7abc66a35421f4745a Mon Sep 17 00:00:00 2001 From: hzj <826100833@qq.com> Date: Tue, 9 Jun 2026 16:43:33 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E5=B0=86=E5=85=A5=E5=BA=93=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=A4=9A=E7=BA=BF=E7=A8=8B=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/LnDataDealServiceImpl.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java index 3c6aece..2d7c593 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java @@ -12,16 +12,14 @@ import com.njcn.device.pq.api.DeviceFeignClient; import com.njcn.device.pq.api.LineFeignClient; import com.njcn.device.pq.pojo.dto.DevComFlagDTO; import com.njcn.device.pq.pojo.vo.LineDeviceStateVO; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.stream.Collectors; @@ -34,6 +32,7 @@ import java.util.stream.Collectors; * @version V1.0.0 */ @Service("RelationLnDataDealServiceImpl") +@Slf4j public class LnDataDealServiceImpl implements LnDataDealService { @QueryBean private IDataFlicker dataFlickerQuery; @@ -74,6 +73,8 @@ public class LnDataDealServiceImpl implements LnDataDealService { private Executor executor; @Override public void batchInsertion(LnDataDTO lnDataDTO) { + long start = System.currentTimeMillis(); + List> futures = new ArrayList<>(); // 提交每个批量插入任务 @@ -94,6 +95,9 @@ public class LnDataDealServiceImpl implements LnDataDealService { // 等待所有任务完成,如果任一任务抛出异常,这里会重新抛出 CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); + long end = System.currentTimeMillis(); + log.info("入库方法执行耗时:" + (end - start) + " ms"); + // 关闭线程池(优雅关闭,等待已提交任务完成) // dataVService.batchInsertion(lnDataDTO.getDataVList()); @@ -132,6 +136,8 @@ public class LnDataDealServiceImpl implements LnDataDealService { iPqsCommunicate.insertion(pqsCommunicateDto); }); + long end2 = System.currentTimeMillis(); + log.info("更新device表:" + (end2 - end) + " ms"); } From fce3f74da12b10deede2aac98ae32c733c8b8217 Mon Sep 17 00:00:00 2001 From: hzj <826100833@qq.com> Date: Wed, 10 Jun 2026 08:44:16 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E5=B0=86=E5=85=A5=E5=BA=93=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=A4=9A=E7=BA=BF=E7=A8=8B=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=EF=BC=8C=E6=8E=92=E6=9F=A5=E8=80=97=E6=97=B6=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/LnDataDealServiceImpl.java | 15 +++++++++++---- .../impl/influxdb/InfluxdbPqsCommunicateImpl.java | 11 +++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java index 2d7c593..a3f8e15 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java @@ -98,7 +98,6 @@ public class LnDataDealServiceImpl implements LnDataDealService { long end = System.currentTimeMillis(); log.info("入库方法执行耗时:" + (end - start) + " ms"); - // 关闭线程池(优雅关闭,等待已提交任务完成) // dataVService.batchInsertion(lnDataDTO.getDataVList()); // dataHarmrateVQuery.batchInsertion(lnDataDTO.getDataHarmrateVDTOList()); @@ -119,11 +118,17 @@ public class LnDataDealServiceImpl implements LnDataDealService { List lineIdList = lnDataDTO.getDataVList().stream().map(DataVDTO::getLineid).distinct().collect(Collectors.toList()); List data = lineFeignClient.getAllLine(lineIdList).getData(); + long end2 = System.currentTimeMillis(); + log.info("查询台账耗时:" + (end2 - end) + " ms"); + + Map map = data.stream().collect(Collectors.toMap(LineDeviceStateVO::getId, temp -> temp.getPids().split(",")[4])); lnDataDTO.getDataVList().forEach(temp->{ temp.setDevId(map.get(temp.getLineid())); }); Map> collect = lnDataDTO.getDataVList().stream().collect(Collectors.groupingBy(DataVDTO::getDevId)); + List> updatefutures = new ArrayList<>(); + collect.forEach((temp,dataVDTOList)->{ PqsCommunicateDto pqsCommunicateDto = new PqsCommunicateDto(); DataVDTO dataVDTO =dataVDTOList.stream().max(Comparator.comparing(DataVDTO::getTimeid)).get(); @@ -132,12 +137,14 @@ public class LnDataDealServiceImpl implements LnDataDealService { pqsCommunicateDto.setDevId(temp); pqsCommunicateDto.setType(1); pqsCommunicateDto.setFlag(1); + updatefutures.add(CompletableFuture.runAsync(() -> iPqsCommunicate.insertion(pqsCommunicateDto), executor)); + - iPqsCommunicate.insertion(pqsCommunicateDto); }); + CompletableFuture.allOf(updatefutures.toArray(new CompletableFuture[0])).join(); - long end2 = System.currentTimeMillis(); - log.info("更新device表:" + (end2 - end) + " ms"); + long end3 = System.currentTimeMillis(); + log.info("更新device表:" + (end3 - end2) + " ms"); } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java index d56058e..6c4d058 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java @@ -112,11 +112,16 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { public void insertion(PqsCommunicateDto pqsCommunicateDto) { // log.info("进出Influxdb实现类"); //获取最新一条数据 + long start = System.currentTimeMillis(); + PqsCommunicate dto = new PqsCommunicate(); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class); influxQueryWrapper.eq(PqsCommunicate::getDevId,pqsCommunicateDto.getDevId()).timeDesc().limit(1); List pqsCommunicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper); + long end1 = System.currentTimeMillis(); + + log.info("更新device表:" + (end1 - start) + " ms"); PqsCommunicate pqsCommunicate = new PqsCommunicate(); pqsCommunicate.setTime(LocalDateTime.parse(pqsCommunicateDto.getTime(), DATE_TIME_FORMATTER).atZone(ZoneId.systemDefault()).toInstant()); pqsCommunicate.setDevId(pqsCommunicateDto.getDevId()); @@ -127,6 +132,9 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { pqsCommunicateMapper.insertOne(pqsCommunicate); } + long end2 = System.currentTimeMillis(); + log.info("更新device表:" + (end2 - end1) + " ms"); + //更新mysql数据 DevComFlagDTO devComFlagDTO = new DevComFlagDTO(); devComFlagDTO.setId(pqsCommunicateDto.getDevId()); @@ -136,6 +144,9 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { devComFlagDTO.setStatus(pqsCommunicateDto.getType()); deviceFeignClient.updateDevComFlag(devComFlagDTO); + long end3 = System.currentTimeMillis(); + log.info("更新device表状态和时间:" + (end3 - end2) + " ms"); + } From 5cb4ab0e8f0c34f8f8255be827b21ab35cdbcd09 Mon Sep 17 00:00:00 2001 From: hzj <826100833@qq.com> Date: Wed, 10 Jun 2026 09:03:00 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E5=B0=86=E5=85=A5=E5=BA=93=E6=94=B9?= =?UTF-8?q?=E6=88=90=E5=A4=9A=E7=BA=BF=E7=A8=8B=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=EF=BC=8C=E6=8E=92=E6=9F=A5=E8=80=97=E6=97=B6=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/influxdb/InfluxdbPqsCommunicateImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java index 6c4d058..6a771f2 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java @@ -121,7 +121,7 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { long end1 = System.currentTimeMillis(); - log.info("更新device表:" + (end1 - start) + " ms"); + log.info("查询通讯表最新数据:" + (end1 - start) + " ms"); PqsCommunicate pqsCommunicate = new PqsCommunicate(); pqsCommunicate.setTime(LocalDateTime.parse(pqsCommunicateDto.getTime(), DATE_TIME_FORMATTER).atZone(ZoneId.systemDefault()).toInstant()); pqsCommunicate.setDevId(pqsCommunicateDto.getDevId()); @@ -133,7 +133,7 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { } long end2 = System.currentTimeMillis(); - log.info("更新device表:" + (end2 - end1) + " ms"); + log.info("更新通讯表最新数据:" + (end2 - end1) + " ms"); //更新mysql数据 DevComFlagDTO devComFlagDTO = new DevComFlagDTO(); From 5090e023b191fd140e0ed55b105f044d5b83bae9 Mon Sep 17 00:00:00 2001 From: hzj <826100833@qq.com> Date: Wed, 10 Jun 2026 10:05:57 +0800 Subject: [PATCH 05/16] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=A5=E4=BA=86=E4=B8=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E9=80=9A=E8=AE=AF=E8=A1=A8=E6=95=B0=E6=8D=AE=EF=BC=8C=E9=80=9A?= =?UTF-8?q?=E8=AE=AF=E8=A1=A8=E7=94=B1=E5=89=8D=E7=BD=AE=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/dto/PqsCommunicateDto.java | 3 ++ .../service/impl/LnDataDealServiceImpl.java | 1 + .../influxdb/InfluxdbPqsCommunicateImpl.java | 45 ++++++++++--------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/dto/PqsCommunicateDto.java b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/dto/PqsCommunicateDto.java index 6271716..4b7f81a 100644 --- a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/dto/PqsCommunicateDto.java +++ b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/pojo/dto/PqsCommunicateDto.java @@ -20,6 +20,9 @@ public class PqsCommunicateDto { private Integer type; //是否更新updateTime标志;数据上送更新1,状态翻转不更新0 private Integer flag=0; + //是否更新、pqs_communicate标志,0更新,1不更新 + + private Integer updateCommunicateFlag=0; } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java index a3f8e15..44d0af7 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java @@ -137,6 +137,7 @@ public class LnDataDealServiceImpl implements LnDataDealService { pqsCommunicateDto.setDevId(temp); pqsCommunicateDto.setType(1); pqsCommunicateDto.setFlag(1); + pqsCommunicateDto.setUpdateCommunicateFlag(1); updatefutures.add(CompletableFuture.runAsync(() -> iPqsCommunicate.insertion(pqsCommunicateDto), executor)); diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java index 6a771f2..c332b91 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java @@ -112,28 +112,33 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { public void insertion(PqsCommunicateDto pqsCommunicateDto) { // log.info("进出Influxdb实现类"); //获取最新一条数据 - long start = System.currentTimeMillis(); + if(Objects.equals(pqsCommunicateDto.getUpdateCommunicateFlag(),0)){ + long start = System.currentTimeMillis(); - PqsCommunicate dto = new PqsCommunicate(); - InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class); - influxQueryWrapper.eq(PqsCommunicate::getDevId,pqsCommunicateDto.getDevId()).timeDesc().limit(1); - List pqsCommunicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper); + PqsCommunicate dto = new PqsCommunicate(); + InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class); + influxQueryWrapper.eq(PqsCommunicate::getDevId,pqsCommunicateDto.getDevId()).timeDesc().limit(1); + List pqsCommunicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper); - long end1 = System.currentTimeMillis(); + long end1 = System.currentTimeMillis(); - log.info("查询通讯表最新数据:" + (end1 - start) + " ms"); - PqsCommunicate pqsCommunicate = new PqsCommunicate(); - pqsCommunicate.setTime(LocalDateTime.parse(pqsCommunicateDto.getTime(), DATE_TIME_FORMATTER).atZone(ZoneId.systemDefault()).toInstant()); - pqsCommunicate.setDevId(pqsCommunicateDto.getDevId()); - pqsCommunicate.setType(pqsCommunicateDto.getType()); - //如果不存数据或者状态不一样则插入数据 - //可能存在掉线后最后一组数据还未入库,添加时间判断 - if(CollectionUtils.isEmpty(pqsCommunicates)|| (!Objects.equals( pqsCommunicates.get(0).getType(),pqsCommunicateDto.getType())&&pqsCommunicates.get(0).getTime().isBefore(pqsCommunicate.getTime()))){ - pqsCommunicateMapper.insertOne(pqsCommunicate); + log.info("查询通讯表最新数据:" + (end1 - start) + " ms"); + PqsCommunicate pqsCommunicate = new PqsCommunicate(); + pqsCommunicate.setTime(LocalDateTime.parse(pqsCommunicateDto.getTime(), DATE_TIME_FORMATTER).atZone(ZoneId.systemDefault()).toInstant()); + pqsCommunicate.setDevId(pqsCommunicateDto.getDevId()); + pqsCommunicate.setType(pqsCommunicateDto.getType()); + //如果不存数据或者状态不一样则插入数据 + //可能存在掉线后最后一组数据还未入库,添加时间判断 + if(CollectionUtils.isEmpty(pqsCommunicates)|| (!Objects.equals( pqsCommunicates.get(0).getType(),pqsCommunicateDto.getType())&&pqsCommunicates.get(0).getTime().isBefore(pqsCommunicate.getTime()))){ + pqsCommunicateMapper.insertOne(pqsCommunicate); + + } + long end2 = System.currentTimeMillis(); + log.info("更新通讯表最新数据:" + (end2 - end1) + " ms"); + } + + long end3 = System.currentTimeMillis(); - } - long end2 = System.currentTimeMillis(); - log.info("更新通讯表最新数据:" + (end2 - end1) + " ms"); //更新mysql数据 DevComFlagDTO devComFlagDTO = new DevComFlagDTO(); @@ -144,8 +149,8 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { devComFlagDTO.setStatus(pqsCommunicateDto.getType()); deviceFeignClient.updateDevComFlag(devComFlagDTO); - long end3 = System.currentTimeMillis(); - log.info("更新device表状态和时间:" + (end3 - end2) + " ms"); + long end4 = System.currentTimeMillis(); + log.info("更新device表状态和时间:" + (end4 - end3) + " ms"); } From 7bf8b9d393199d89386e062ecbced3df5d7501e7 Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Mon, 22 Jun 2026 19:29:39 +0800 Subject: [PATCH 06/16] =?UTF-8?q?refactor(influxdb):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=86=97=E4=BD=99=E7=9A=84=E7=9B=B8=E4=BD=8D=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 注释掉 InfluxdbDataHarmpowerPImpl 中 phasicType 和 lineParam.type 的条件判断 - 注释掉 InfluxdbDataHarmpowerQImpl 中 phasicType 和 lineParam.type 的条件判断 - 注释掉 InfluxdbDataHarmpowerSImpl 中 phasicType 和 lineParam.type 的条件判断 - 统一使用 extractDataLists(valueTypeList, "") 进行数据提取 - 简化代码逻辑,提高可读性 --- .../impl/influxdb/InfluxdbDataHarmpowerPImpl.java | 11 ++++++----- .../impl/influxdb/InfluxdbDataHarmpowerQImpl.java | 12 ++++++------ .../impl/influxdb/InfluxdbDataHarmpowerSImpl.java | 11 ++++++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java index 9b567a4..28831bb 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java @@ -107,11 +107,12 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl> lists; - if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { - lists = extractDataLists(valueTypeList, "Tot"); - } else { - lists = extractDataLists(valueTypeList, ""); - } +// if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { +// lists = extractDataLists(valueTypeList, "Tot"); +// } else { +// lists = extractDataLists(valueTypeList, ""); +// } + lists = extractDataLists(valueTypeList, ""); value.setValueList(lists); valueTypes.add(value); }); diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java index 4d77559..0d90276 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java @@ -105,13 +105,13 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl{ CommonMinuteDto.ValueType value = new CommonMinuteDto.ValueType(); value.setValueType(valueType); - List> lists; - if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { - lists = extractDataLists(valueTypeList, "Tot"); - } else { - lists = extractDataLists(valueTypeList, ""); - } +// if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { +// lists = extractDataLists(valueTypeList, "Tot"); +// } else { +// lists = extractDataLists(valueTypeList, ""); +// } + lists = extractDataLists(valueTypeList, ""); value.setValueList(lists); valueTypes.add(value); }); diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java index 11df88a..581883b 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java @@ -106,11 +106,12 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl> lists; - if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { - lists = extractDataLists(valueTypeList, "Tot"); - } else { - lists = extractDataLists(valueTypeList, ""); - } +// if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { +// lists = extractDataLists(valueTypeList, "Tot"); +// } else { +// lists = extractDataLists(valueTypeList, ""); +// } + lists = extractDataLists(valueTypeList, ""); value.setValueList(lists); valueTypes.add(value); }); From e56dc8c4be5b4439fbee1328bfcb70e3a47a1335 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Tue, 23 Jun 2026 15:01:40 +0800 Subject: [PATCH 07/16] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=B8=85=E6=B4=97=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E7=BB=93=E6=9E=84=EF=BC=8C=E7=BB=93=E6=9E=84=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=9B=A0=E7=9B=AE=E5=BD=95=E8=BF=87=E5=A4=9A=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E9=98=BF=E9=87=8C=E4=BA=91=E6=96=87=E4=BB=B6=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E5=8D=A1=E9=A1=BF=E9=97=AE=E9=A2=98=EF=BC=9B?= =?UTF-8?q?=202.=E4=BC=98=E5=8C=96=E7=AE=97=E6=B3=95=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=BE=93=E5=87=BA=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/line/IDataCleanService.java | 1 - .../line/DataCleanServiceImpl.java | 10 ++-- .../line/DataComAssServiceImpl.java | 8 ++-- .../serviceimpl/line/DayDataServiceImpl.java | 48 ++++++++++++------- .../line/FlowAsyncServiceImpl.java | 4 +- .../line/IDataCrossingServiceImpl.java | 48 +++++++++---------- .../line/IDataIntegrityServiceImpl.java | 8 ++-- .../line/IDataLimitRateAsyncImpl.java | 8 ++-- .../line/IDataOnlineRateServiceImpl.java | 8 ++-- .../line/IEventDetailServiceImpl.java | 17 ++++--- .../line/PollutionServiceImpl.java | 4 +- .../line/SpecialAnalysisServiceImpl.java | 4 +- .../service/impl/LnDataDealServiceImpl.java | 10 +--- .../influxdb/InfluxdbPqsCommunicateImpl.java | 15 ++---- 14 files changed, 101 insertions(+), 92 deletions(-) diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/IDataCleanService.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/IDataCleanService.java index aa4742a..2c9f6ca 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/IDataCleanService.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/service/line/IDataCleanService.java @@ -2,7 +2,6 @@ package com.njcn.algorithm.service.line; import com.njcn.algorithm.pojo.bo.CalculatedParam; -import java.util.concurrent.CompletableFuture; /** * @author xy diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataCleanServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataCleanServiceImpl.java index eb1ef64..a2c6cac 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataCleanServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataCleanServiceImpl.java @@ -52,8 +52,8 @@ public class DataCleanServiceImpl implements IDataCleanService { private static final Logger logger = LoggerFactory.getLogger(DataCleanServiceImpl.class); - @Value("${line.num}") - private Integer NUM = 100; + @Value("${line.num:10}") + private Integer NUM; @Resource private DataVFeignClient dataVFeignClient; @@ -101,7 +101,7 @@ public class DataCleanServiceImpl implements IDataCleanService { public void dataQualityCleanHandler(CalculatedParam calculatedParam) { MemorySizeUtil.getNowMemory(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); - logger.info("{},数据质量清洗算法执行=====》", LocalDateTime.now()); + logger.info("{},{}数据质量清洗算法执行=====》", LocalDateTime.now(),calculatedParam.getDataDate()); //获取监测点的统计间隔 List listOfString = (List) (List) calculatedParam.getIdList(); List lineDetailDataVOS = lineFeignClient.getLineDetailList(listOfString).getData(); @@ -290,7 +290,7 @@ public class DataCleanServiceImpl implements IDataCleanService { DictData dip = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.VOLTAGE_DIP.getCode(), DicDataTypeEnum.EVENT_STATIS.getCode()).getData(); DictData rise = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.VOLTAGE_RISE.getCode(), DicDataTypeEnum.EVENT_STATIS.getCode()).getData(); MemorySizeUtil.getNowMemory(); - logger.info("{},原始表数据清洗=====》", LocalDateTime.now()); + logger.info("{},{}原始表数据清洗=====》", LocalDateTime.now(),calculatedParam.getDataDate()); //获取标准 Map> map = getStandardData(); //获取监测点台账信息 @@ -304,7 +304,7 @@ public class DataCleanServiceImpl implements IDataCleanService { lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate())); lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate())); for (int i = 0; i < lineDetail.size(); i++) { - logger.info( calculatedParam.getDataDate()+"总数据:" + lineDetail.size() + "=====》当前第" + (i + 1)); +// logger.info( calculatedParam.getDataDate()+"总数据:" + lineDetail.size() + "=====》当前第" + (i + 1)); LineDetailVO.Detail item = lineDetail.get(i); flowService.lineDataClean(item, map, calculatedParam.getDataDate(), dip, rise,lineDetail.size(),(i + 1)); } diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java index a5f9cdd..5bd2119 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java @@ -3,6 +3,7 @@ package com.njcn.algorithm.serviceimpl.line; import cn.hutool.core.collection.CollUtil; import com.njcn.algorithm.pojo.bo.CalculatedParam; import com.njcn.algorithm.service.line.IDataComAssService; +import com.njcn.algorithm.utils.MemorySizeUtil; import com.njcn.dataProcess.api.DataComAssFeignClient; import com.njcn.dataProcess.api.DataFlickerFeignClient; import com.njcn.dataProcess.api.DataVFeignClient; @@ -38,8 +39,8 @@ import java.util.stream.Collectors; public class DataComAssServiceImpl implements IDataComAssService { private static final Logger logger = LoggerFactory.getLogger(DayDataServiceImpl.class); - @Value("${line.num}") - private Integer NUM = 100; + + @Resource private DataVFeignClient dataVFeignClient; @@ -53,7 +54,8 @@ public class DataComAssServiceImpl implements IDataComAssService { @Override public void dataComAssHandler(CalculatedParam calculatedParam) { List list = new ArrayList<>(); - logger.info("{},r_stat_comasses_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}r_stat_comasses_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate())); lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate())); diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DayDataServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DayDataServiceImpl.java index 65ad1d4..d7e7bd9 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DayDataServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DayDataServiceImpl.java @@ -35,8 +35,9 @@ public class DayDataServiceImpl implements IDayDataService { private static final Logger logger = LoggerFactory.getLogger(DayDataServiceImpl.class); - @Value("${line.num}") - private Integer NUM = 100; + @Value("${line.num:10}") + private Integer NUM; + @Resource private DataVFeignClient dataVFeignClient; @Resource @@ -75,7 +76,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataVHandler(CalculatedParam calculatedParam) { - logger.info("{},dataV表转r_stat_data_v_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataV表转r_stat_data_v_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -91,7 +93,6 @@ public class DayDataServiceImpl implements IDayDataService { //获取原始数据 List partList = dataVFeignClient.getBaseData(lineParam).getData(); if (CollUtil.isNotEmpty(partList)) { - logger.info("{}dataV集合大小为>>>>>>>>>>>>{}",lineParam.getStartTime(),MemorySizeUtil.getObjectSize(partList)); partList.forEach(item->{ //相别 List phasicTypeList = item.getPhasicTypeList(); @@ -125,7 +126,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataIHandler(CalculatedParam calculatedParam) { - logger.info("{},dataI表转r_stat_data_i_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataI表转r_stat_data_i_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -173,7 +175,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataFlickerHandler(CalculatedParam calculatedParam) { - logger.info("{},dataFlicker表转r_stat_data_flicker_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataFlicker表转r_stat_data_flicker_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List valueList = Arrays.asList("AVG","MAX","MIN","CP95"); List result = new ArrayList<>(); //远程接口获取分钟数据 @@ -222,7 +225,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataFlucHandler(CalculatedParam calculatedParam) { - logger.info("{},dataFluc表转r_stat_data_fluc_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataFluc表转r_stat_data_fluc_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List valueList = Arrays.asList("AVG","MAX","MIN","CP95"); List result = new ArrayList<>(); //远程接口获取分钟数据 @@ -271,7 +275,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataHarmPhasicIHandler(CalculatedParam calculatedParam) { - logger.info("{},dataHarmPhasicI表转r_stat_data_harmphasic_i_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataHarmPhasicI表转r_stat_data_harmphasic_i_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -319,7 +324,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataHarmPhasicVHandler(CalculatedParam calculatedParam) { - logger.info("{},dataHarmPhasicV表转r_stat_data_harmphasic_v_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataHarmPhasicV表转r_stat_data_harmphasic_v_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -367,7 +373,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataHarmPowerPHandler(CalculatedParam calculatedParam) { - logger.info("{},dataHarmPowerP表转r_stat_data_harmpower_p_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataHarmPowerP表转r_stat_data_harmpower_p_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -415,7 +422,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataHarmPowerQHandler(CalculatedParam calculatedParam) { - logger.info("{},dataHarmPowerQ表转r_stat_data_harmpower_q_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataHarmPowerQ表转r_stat_data_harmpower_q_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -463,7 +471,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataHarmPowerSHandler(CalculatedParam calculatedParam) { - logger.info("{},dataHarmPowerS表转r_stat_data_harmpower_s_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataHarmPowerS表转r_stat_data_harmpower_s_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -511,7 +520,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataHarmRateIHandler(CalculatedParam calculatedParam) { - logger.info("{},dataHarmRateI表转r_stat_data_harmRate_i_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataHarmRateI表转r_stat_data_harmRate_i_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -559,7 +569,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataHarmRateVHandler(CalculatedParam calculatedParam) { - logger.info("{},dataHarmRateV表转r_stat_data_harmRate_v_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataHarmRateV表转r_stat_data_harmRate_v_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -607,7 +618,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataInHarmIHandler(CalculatedParam calculatedParam) { - logger.info("{},dataInHarmI表转r_stat_data_inharm_i_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataInHarmI表转r_stat_data_inharm_i_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -655,7 +667,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataInHarmVHandler(CalculatedParam calculatedParam) { - logger.info("{},dataInHarmV表转r_stat_data_inharm_v_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataInHarmV表转r_stat_data_inharm_v_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -703,7 +716,8 @@ public class DayDataServiceImpl implements IDayDataService { @Override public void dataPltHandler(CalculatedParam calculatedParam) { - logger.info("{},dataPlt表转r_stat_data_plt_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}dataPlt表转r_stat_data_plt_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); List valueList = Arrays.asList("AVG","MAX","MIN","CP95"); //远程接口获取分钟数据 diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/FlowAsyncServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/FlowAsyncServiceImpl.java index 51acadd..ce276f9 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/FlowAsyncServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/FlowAsyncServiceImpl.java @@ -390,16 +390,16 @@ public class FlowAsyncServiceImpl implements FlowAsyncService { bak.setState(1); //存储文件 InputStream reportStream = IoUtil.toStream(new Gson().toJson(resultData), CharsetUtil.UTF_8); + String[] date = dataDate.split("-"); String fileName = fileStorageUtil.uploadStreamSpecifyName( reportStream - , OssPath.DATA_CLEAN + dataDate + "/" + , OssPath.DATA_CLEAN + date[0] + "/"+ date[1] + "/"+ date[2] + "/" , item.getLineId() + ".txt"); //存储数据 bak.setFilePath(fileName); } pqDataVerifyNewFeignClient.insertData(bak); resultData=null; - logger.info( dataDate+"总数据:" + size + "=====》当前第" + i+"已完成!"); System.gc(); } 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 1ca4af5..38ee5ba 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 @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ObjectUtil; import com.njcn.algorithm.pojo.bo.CalculatedParam; import com.njcn.algorithm.service.line.IDataCrossingService; @@ -42,10 +43,7 @@ import java.lang.reflect.Method; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.Function; import java.util.stream.Collectors; @@ -61,7 +59,7 @@ import java.util.stream.Collectors; public class IDataCrossingServiceImpl implements IDataCrossingService { private static final Logger logger = LoggerFactory.getLogger(DayDataServiceImpl.class); - @Value("${line.num}") + @Value("${line.num:10}") private Integer NUM; @Resource @@ -106,29 +104,28 @@ public class IDataCrossingServiceImpl implements IDataCrossingService { } Map overLimitMap = overLimitList.stream().collect(Collectors.toMap(Overlimit::getId, Function.identity())); //以100个监测点分片处理 - List> pendingIds = ListUtils.partition(lineIds, 1); - ArrayList phase = ListUtil.toList(PhaseType.PHASE_A, PhaseType.PHASE_B, PhaseType.PHASE_C); MemorySizeUtil.getNowMemory(); + List> pendingIds = ListUtils.partition(lineIds, 20); + ArrayList phase = ListUtil.toList(PhaseType.PHASE_A, PhaseType.PHASE_B, PhaseType.PHASE_C); - List> futures = new ArrayList<>(); - for (int i = 0; i < pendingIds.size(); i++) { - logger.info(calculatedParam.getDataDate()+" 总分区数据:" + pendingIds.size() + "=====》当前第"+(i + 1)+"小分区"); - List list = pendingIds.get(i); - // 获取Future - CompletableFuture future = dataLimitRateAsync.lineDataRate( - calculatedParam.getDataDate(), - list, - phase, - overLimitMap, - pendingIds.size(), - (i + 1), - lineParam.getType() - ); - - futures.add(future); + for (List pendingId : pendingIds) { + List> futures = new ArrayList<>(); + for (String s : pendingId) { + CompletableFuture future = dataLimitRateAsync.lineDataRate( + calculatedParam.getDataDate(), + Arrays.asList(s), + phase, + overLimitMap, + pendingId.size(), + pendingId.size(), + lineParam.getType() + ); + futures.add(future); + } + CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); } // 等待所有任务完成 - CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); + System.err.println("limitRate表转r_stat_limit_rate_d算法开始,执行日期为{},执行完成=====》"+calculatedParam.getDataDate()); System.gc(); } @@ -169,7 +166,8 @@ public class IDataCrossingServiceImpl implements IDataCrossingService { @Override public void limitQualifiedDayHandler(CalculatedParam calculatedParam) { - logger.info("{},r_stat_limit_qualified_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}r_stat_limit_qualified_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate())); lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate())); diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataIntegrityServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataIntegrityServiceImpl.java index 8c67c98..6136050 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataIntegrityServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataIntegrityServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.LocalDateTimeUtil; import com.njcn.algorithm.pojo.bo.CalculatedParam; import com.njcn.algorithm.service.line.IDataIntegrityService; +import com.njcn.algorithm.utils.MemorySizeUtil; import com.njcn.dataProcess.api.DataIntegrityFeignClient; import com.njcn.dataProcess.api.DataVFeignClient; import com.njcn.dataProcess.dto.MeasurementCountDTO; @@ -42,8 +43,8 @@ public class IDataIntegrityServiceImpl implements IDataIntegrityService { private static final Logger logger = LoggerFactory.getLogger(IDataIntegrityServiceImpl.class); - @Value("${line.num}") - private Integer NUM = 100; + @Value("${line.num:10}") + private Integer NUM; @Resource private CommTerminalGeneralClient commTerminalGeneralClient; @Resource @@ -54,7 +55,8 @@ public class IDataIntegrityServiceImpl implements IDataIntegrityService { @Override public void dataIntegrity(CalculatedParam calculatedParam) { - logger.info("{},integrity表转r_stat_integrity_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}integrity表转r_stat_integrity_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List poList = new ArrayList<>(); List lineIds = calculatedParam.getIdList(); String beginDay = LocalDateTimeUtil.format( diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataLimitRateAsyncImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataLimitRateAsyncImpl.java index 73d0126..5abb704 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataLimitRateAsyncImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataLimitRateAsyncImpl.java @@ -294,11 +294,11 @@ public class IDataLimitRateAsyncImpl implements IDataLimitRateAsync { dataLimitRateDetailFeignClient.batchInsertion(detail); } } - logger.info(dataDate + " 总分区数据:" + size + "=====》当前第" + i + "小分区已完成!"); +// logger.info(dataDate + " 总分区数据:" + size + "=====》当前第" + i + "小分区已完成!"); result = null; - if(i==size){ - MemorySizeUtil.getNowMemory(); - } +// if(i==size){ +// MemorySizeUtil.getNowMemory(); +// } System.gc(); return CompletableFuture.completedFuture(null); 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 c5a6a2b..e13b950 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 @@ -9,6 +9,7 @@ import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import com.njcn.algorithm.pojo.bo.CalculatedParam; import com.njcn.algorithm.service.line.IDataOnlineRateService; +import com.njcn.algorithm.utils.MemorySizeUtil; import com.njcn.dataProcess.api.DataIntegrityFeignClient; import com.njcn.dataProcess.api.DataOnlineRateFeignClient; import com.njcn.dataProcess.api.DataVFeignClient; @@ -48,8 +49,8 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService { private static final Logger logger = LoggerFactory.getLogger(IDataOnlineRateServiceImpl.class); - @Value("${line.num}") - private Integer NUM = 100; + @Value("${line.num:10}") + private Integer NUM; private final Integer online = 1; private final Integer offline = 0; @@ -69,7 +70,8 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService { @Override public void dataOnlineRate(CalculatedParam calculatedParam) { - logger.info("{},onlineRate表转r_stat_onlinerate_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}onlineRate表转r_stat_onlinerate_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate())); lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate())); diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IEventDetailServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IEventDetailServiceImpl.java index 0c2b72e..f2dafe3 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IEventDetailServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IEventDetailServiceImpl.java @@ -7,6 +7,7 @@ import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.ObjectUtil; import com.njcn.algorithm.pojo.bo.CalculatedParam; import com.njcn.algorithm.service.line.IEventDetailService; +import com.njcn.algorithm.utils.MemorySizeUtil; import com.njcn.dataProcess.api.EventDetailFeignClient; import com.njcn.dataProcess.api.RmpEventDetailFeignClient; import com.njcn.dataProcess.dto.RmpEventDetailDTO; @@ -44,8 +45,8 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class IEventDetailServiceImpl implements IEventDetailService { private static final Logger logger = LoggerFactory.getLogger(IDataOnlineRateServiceImpl.class); - @Value("${line.num}") - private Integer NUM = 10; + @Value("${line.num:10}") + private Integer NUM; @Resource private RmpEventDetailFeignClient eventDetailFeignClient; @Resource @@ -55,7 +56,8 @@ public class IEventDetailServiceImpl implements IEventDetailService { @Override public void dataDayHandle(CalculatedParam calculatedParam) { - logger.info("{},r_mp_event_detail_d算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}r_mp_event_detail_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -106,7 +108,8 @@ public class IEventDetailServiceImpl implements IEventDetailService { @Override public void dataMonthHandle(CalculatedParam calculatedParam) { - logger.info("{},r_mp_event_detail_m算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}r_mp_event_detail_m算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -139,7 +142,8 @@ public class IEventDetailServiceImpl implements IEventDetailService { @Override public void dataQuarterHandle(CalculatedParam calculatedParam) { - logger.info("{},r_mp_event_detail_q算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}r_mp_event_detail_q算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); @@ -172,7 +176,8 @@ public class IEventDetailServiceImpl implements IEventDetailService { @Override public void dataYearHandle(CalculatedParam calculatedParam) { - logger.info("{},r_mp_event_detail_y算法开始=====》", LocalDateTime.now()); + MemorySizeUtil.getNowMemory(); + logger.info("{},{}r_mp_event_detail_y算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate()); List result = new ArrayList<>(); //远程接口获取分钟数据 LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); 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 4092d68..ac0be54 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 @@ -49,8 +49,8 @@ import java.util.stream.Stream; @RequiredArgsConstructor public class PollutionServiceImpl implements IPollutionService { - @Value("${line.num}") - private Integer NUM = 100; + @Value("${line.num:10}") + private Integer NUM; @Resource private PqDataVerifyFeignClient pqDataVerifyFeignClient; diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java index 85ceb40..7bb7e30 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java @@ -65,8 +65,8 @@ import java.util.stream.Collectors; @RequiredArgsConstructor public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService { - - private Integer NUM=10; + @Value("${line.num:10}") + private Integer NUM; @Resource private EventDetailFeignClient eventDetailFeignClient; @Resource diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java index 44d0af7..4e1726a 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/LnDataDealServiceImpl.java @@ -73,11 +73,10 @@ public class LnDataDealServiceImpl implements LnDataDealService { private Executor executor; @Override public void batchInsertion(LnDataDTO lnDataDTO) { - long start = System.currentTimeMillis(); List> futures = new ArrayList<>(); -// 提交每个批量插入任务 + // 提交每个批量插入任务 futures.add(CompletableFuture.runAsync(() -> dataVService.batchInsertion(lnDataDTO.getDataVList()), executor)); futures.add(CompletableFuture.runAsync(() -> dataHarmrateVQuery.batchInsertion(lnDataDTO.getDataHarmrateVDTOList()), executor)); futures.add(CompletableFuture.runAsync(() -> dataFlickerQuery.batchInsertion(lnDataDTO.getDataFlickerDTOList()), executor)); @@ -95,8 +94,6 @@ public class LnDataDealServiceImpl implements LnDataDealService { // 等待所有任务完成,如果任一任务抛出异常,这里会重新抛出 CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join(); - long end = System.currentTimeMillis(); - log.info("入库方法执行耗时:" + (end - start) + " ms"); // dataVService.batchInsertion(lnDataDTO.getDataVList()); @@ -118,8 +115,6 @@ public class LnDataDealServiceImpl implements LnDataDealService { List lineIdList = lnDataDTO.getDataVList().stream().map(DataVDTO::getLineid).distinct().collect(Collectors.toList()); List data = lineFeignClient.getAllLine(lineIdList).getData(); - long end2 = System.currentTimeMillis(); - log.info("查询台账耗时:" + (end2 - end) + " ms"); Map map = data.stream().collect(Collectors.toMap(LineDeviceStateVO::getId, temp -> temp.getPids().split(",")[4])); @@ -144,9 +139,6 @@ public class LnDataDealServiceImpl implements LnDataDealService { }); CompletableFuture.allOf(updatefutures.toArray(new CompletableFuture[0])).join(); - long end3 = System.currentTimeMillis(); - log.info("更新device表:" + (end3 - end2) + " ms"); - } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java index c332b91..497a3f3 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbPqsCommunicateImpl.java @@ -110,19 +110,16 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { @Override public void insertion(PqsCommunicateDto pqsCommunicateDto) { -// log.info("进出Influxdb实现类"); + //获取最新一条数据 if(Objects.equals(pqsCommunicateDto.getUpdateCommunicateFlag(),0)){ - long start = System.currentTimeMillis(); + PqsCommunicate dto = new PqsCommunicate(); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class); influxQueryWrapper.eq(PqsCommunicate::getDevId,pqsCommunicateDto.getDevId()).timeDesc().limit(1); List pqsCommunicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper); - long end1 = System.currentTimeMillis(); - - log.info("查询通讯表最新数据:" + (end1 - start) + " ms"); PqsCommunicate pqsCommunicate = new PqsCommunicate(); pqsCommunicate.setTime(LocalDateTime.parse(pqsCommunicateDto.getTime(), DATE_TIME_FORMATTER).atZone(ZoneId.systemDefault()).toInstant()); pqsCommunicate.setDevId(pqsCommunicateDto.getDevId()); @@ -133,11 +130,10 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { pqsCommunicateMapper.insertOne(pqsCommunicate); } - long end2 = System.currentTimeMillis(); - log.info("更新通讯表最新数据:" + (end2 - end1) + " ms"); + } - long end3 = System.currentTimeMillis(); + //更新mysql数据 @@ -149,8 +145,7 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate { devComFlagDTO.setStatus(pqsCommunicateDto.getType()); deviceFeignClient.updateDevComFlag(devComFlagDTO); - long end4 = System.currentTimeMillis(); - log.info("更新device表状态和时间:" + (end4 - end3) + " ms"); + } From 69df89f2e8103c45510a2d4d4a9dea58d628fefc Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Wed, 24 Jun 2026 14:47:05 +0800 Subject: [PATCH 08/16] =?UTF-8?q?feat(algorithm):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=9B=91=E6=B5=8B=E7=82=B9=E6=8E=A5=E7=BA=BF=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在ExecutionCenter中引入CsLineDTO和RedisUtil依赖 - 实现监测点、接线方式数据缓存到Redis功能,设置3小时过期时间 - 修改wlMeasurementPointExecutor方法使用缓存的线路ID列表 - 在数据处理服务中添加Gson和TypeToken用于JSON序列化 - 实现根据接线方式过滤电压类型数据的功能 - 添加线电压和相电压类型常量定义 - 优化数据查询逻辑,按监测点分组后根据接线方式过滤多余数据 - 实现线电压数据向相电压数据的特殊处理逻辑 - 统一返回经过接线方式过滤后的数据结果 --- .../com/njcn/algorithm/ExecutionCenter.java | 24 ++++- .../influxdb/InfluxdbDataFlickerImpl.java | 51 ++++++++-- .../impl/influxdb/InfluxdbDataFlucImpl.java | 51 ++++++++-- .../influxdb/InfluxdbDataHarmRateVImpl.java | 53 +++++++++-- .../influxdb/InfluxdbDataHarmphasicVImpl.java | 50 ++++++++-- .../impl/influxdb/InfluxdbDataPltImpl.java | 50 ++++++++-- .../impl/influxdb/InfluxdbDataVImpl.java | 94 +++++++++++++++++-- 7 files changed, 319 insertions(+), 54 deletions(-) diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/ExecutionCenter.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/ExecutionCenter.java index 2c60b7c..e01a5fe 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/ExecutionCenter.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/ExecutionCenter.java @@ -16,6 +16,7 @@ import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.csdevice.api.CsLineFeignClient; +import com.njcn.csdevice.pojo.dto.CsLineDTO; import com.njcn.device.biz.commApi.CommTerminalGeneralClient; import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO; import com.njcn.device.biz.pojo.dto.DeptGetDeviceDTO; @@ -23,6 +24,7 @@ import com.njcn.device.biz.pojo.dto.DeptGetSubStationDTO; import com.njcn.device.biz.pojo.dto.LineDevGetDTO; import com.njcn.device.biz.pojo.param.DeptGetLineParam; import com.njcn.device.pq.api.DeptLineFeignClient; +import com.njcn.redis.utils.RedisUtil; import com.njcn.user.api.DeptFeignClient; import com.njcn.user.pojo.po.Dept; import com.njcn.web.controller.BaseController; @@ -73,6 +75,8 @@ public class ExecutionCenter extends BaseController { private CsLineFeignClient csLineFeignClient; @Resource private FlowAsyncService flowService; + @Resource + private RedisUtil redisUtil; /*** * 1、校验非全链执行时,tagNames节点标签集合必须为非空,否则提示---无可执行节点 @@ -143,9 +147,27 @@ public class ExecutionCenter extends BaseController { String methodDescribe = getMethodDescribe("wlMeasurementPointExecutor"); //手动判断参数是否合法, CalculatedParam calculatedParam = judgeExecuteParam(baseParam); + //缓存监测点、接线方式数据 + List csLineDTOList = csLineFeignClient.getAllLineDetail().getData(); + List lineIdList = new ArrayList<>(); + Map lineConTypeMap = new HashMap<>(); + if (CollectionUtils.isNotEmpty(csLineDTOList)) { + lineIdList = csLineDTOList.stream().map(CsLineDTO::getLineId).collect(Collectors.toList()); + //接线方式(0-星型 1-角型 2-V型) + lineConTypeMap = csLineDTOList.stream() + .filter(dto -> dto.getLineId() != null) + .collect(Collectors.toMap( + CsLineDTO::getLineId, + dto -> dto.getConType() != null ? dto.getConType() : 0, + (v1, v2) -> v1 + )); + redisUtil.saveByKeyWithExpire("wlLineDetail", lineConTypeMap, 3600L*3); + } // 测点索引 if (CollectionUtils.isEmpty(calculatedParam.getIdList())) { - calculatedParam.setIdList(csLineFeignClient.getAllLine().getData()); + calculatedParam.setIdList(lineIdList); + } else { + calculatedParam.setIdList(calculatedParam.getIdList()); } LiteflowResponse liteflowResponse; if (baseParam.isRepair()) { diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlickerImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlickerImpl.java index e9e804e..c4a22a3 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlickerImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlickerImpl.java @@ -3,6 +3,8 @@ package com.njcn.dataProcess.service.impl.influxdb; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken; +import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.dataProcess.dao.imapper.DataFlickerMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataFlickerRelationMapper; @@ -15,11 +17,14 @@ import com.njcn.dataProcess.pojo.po.RStatDataFlickerD; import com.njcn.dataProcess.service.IDataFlicker; import com.njcn.dataProcess.util.TimeUtils; import com.njcn.influx.query.InfluxQueryWrapper; +import com.njcn.redis.utils.RedisUtil; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.lang.reflect.Type; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -38,15 +43,19 @@ import java.util.stream.Collectors; public class InfluxdbDataFlickerImpl extends MppServiceImpl implements IDataFlicker { private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); - private final DataFlickerMapper dataFlickerMapper; - private static final Map PHASE_MAPPING = new HashMap() {{ put("AB", "A"); put("BC", "B"); put("CA", "C"); put("M", "T"); }}; + @Resource + private RedisUtil redisUtil; + private static final Set LINE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T"))); + private static final Set PHASE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T"))); @Override @@ -229,6 +238,13 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl getMinuteData(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); + List data = new ArrayList<>(); + //获取监测点、接线方式数据 + Type type = new TypeToken>(){}.getType(); + Map map = new Gson().fromJson( + String.valueOf(redisUtil.getObjectByKey("wlLineDetail")), + type + ); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataFlicker.class); influxQueryWrapper.regular(DataFlicker::getLineId, lineParam.getLineId()) .select(DataFlicker::getLineId) @@ -242,13 +258,30 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); + if (!Objects.isNull(map)) { + //现根据监测点分组,然后根据接线方式排除多于数据,在修改相别 + Map> lineMap = result.stream().collect(Collectors.groupingBy(DataFlicker::getLineId)); + lineMap.forEach((k,v)->{ + if (Objects.isNull(map.get(k))) { + return; + } + Integer conType = map.get(k); + Set validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES; + List result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList()); + data.addAll(result2); + }); + } else { + data.addAll(result); + } + if (CollectionUtil.isNotEmpty(data)) { + data.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); + } + }); + } } - return result; + return data; } } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlucImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlucImpl.java index 4b7ac26..486ace8 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlucImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataFlucImpl.java @@ -1,6 +1,8 @@ package com.njcn.dataProcess.service.impl.influxdb; import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken; +import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.dataProcess.dao.imapper.DataFlucMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataFlucRelationMapper; @@ -13,11 +15,14 @@ import com.njcn.dataProcess.pojo.po.RStatDataFlucD; import com.njcn.dataProcess.service.IDataFluc; import com.njcn.dataProcess.util.TimeUtils; import com.njcn.influx.query.InfluxQueryWrapper; +import com.njcn.redis.utils.RedisUtil; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.lang.reflect.Type; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -36,15 +41,19 @@ import java.util.stream.Collectors; public class InfluxdbDataFlucImpl extends MppServiceImpl implements IDataFluc { private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); - private final DataFlucMapper dataFlucMapper; - private static final Map PHASE_MAPPING = new HashMap() {{ put("AB", "A"); put("BC", "B"); put("CA", "C"); put("M", "T"); }}; + @Resource + private RedisUtil redisUtil; + private static final Set LINE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T"))); + private static final Set PHASE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T"))); @Override public void batchInsertion(List dataFlucDTOList) { @@ -147,6 +156,13 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl getMinuteData(List lineList, String startTime, String endTime, Map> timeMap, Boolean dataType) { List dataList; List result = new ArrayList<>(); + List data = new ArrayList<>(); + //获取监测点、接线方式数据 + Type type = new TypeToken>(){}.getType(); + Map map = new Gson().fromJson( + String.valueOf(redisUtil.getObjectByKey("wlLineDetail")), + type + ); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataFluc.class); influxQueryWrapper.regular(DataFluc::getLineId, lineList) .select(DataFluc::getLineId) @@ -195,14 +211,31 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); + if (!Objects.isNull(map)) { + //现根据监测点分组,然后根据接线方式排除多于数据,在修改相别 + Map> lineMap = result.stream().collect(Collectors.groupingBy(DataFluc::getLineId)); + lineMap.forEach((k,v)->{ + if (Objects.isNull(map.get(k))) { + return; + } + Integer conType = map.get(k); + Set validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES; + List result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList()); + data.addAll(result2); + }); + } else { + data.addAll(result); + } + if (CollectionUtil.isNotEmpty(data)) { + data.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); + } + }); + } } - return result; + return data; } } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateVImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateVImpl.java index 052e359..615ac8a 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateVImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmRateVImpl.java @@ -2,6 +2,8 @@ package com.njcn.dataProcess.service.impl.influxdb; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken; +import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; import com.njcn.dataProcess.constant.InfluxDBTableConstant; @@ -9,6 +11,7 @@ import com.njcn.dataProcess.dao.imapper.DataHarmRateVMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmRateVRelationMapper; import com.njcn.dataProcess.dto.DataHarmrateVDTO; import com.njcn.dataProcess.param.LineCountEvaluateParam; +import com.njcn.dataProcess.po.influx.DataFlicker; import com.njcn.dataProcess.po.influx.DataHarmrateV; import com.njcn.dataProcess.po.influx.DataV; import com.njcn.dataProcess.pojo.dto.CommonMinuteDto; @@ -19,11 +22,14 @@ import com.njcn.dataProcess.service.IDataHarmRateV; import com.njcn.dataProcess.util.TimeUtils; import com.njcn.influx.constant.InfluxDbSqlConstant; import com.njcn.influx.query.InfluxQueryWrapper; +import com.njcn.redis.utils.RedisUtil; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.lang.reflect.Type; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -36,17 +42,20 @@ import java.util.stream.Collectors; @Service("InfluxdbDataHarmRateVImpl") @RequiredArgsConstructor public class InfluxdbDataHarmRateVImpl extends MppServiceImpl implements IDataHarmRateV { - private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); - private final DataHarmRateVMapper dataHarmRateVMapper; - private static final Map PHASE_MAPPING = new HashMap() {{ put("AB", "A"); put("BC", "B"); put("CA", "C"); put("M", "T"); }}; + @Resource + private RedisUtil redisUtil; + private static final Set LINE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T"))); + private static final Set PHASE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T"))); @Override public List getRawData(LineCountEvaluateParam lineParam) { @@ -244,6 +253,13 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl getMinuteData(LineCountEvaluateParam lineParam) { List dataList; List result = new ArrayList<>(); + List data = new ArrayList<>(); + //获取监测点、接线方式数据 + Type type = new TypeToken>(){}.getType(); + Map map = new Gson().fromJson( + String.valueOf(redisUtil.getObjectByKey("wlLineDetail")), + type + ); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateV.class); influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); influxQueryWrapper.regular(DataHarmrateV::getLineId, lineParam.getLineId()) @@ -295,13 +311,30 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); + if (!Objects.isNull(map)) { + //现根据监测点分组,然后根据接线方式排除多于数据,在修改相别 + Map> lineMap = result.stream().collect(Collectors.groupingBy(DataHarmrateV::getLineId)); + lineMap.forEach((k,v)->{ + if (Objects.isNull(map.get(k))) { + return; + } + Integer conType = map.get(k); + Set validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES; + List result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList()); + data.addAll(result2); + }); + } else { + data.addAll(result); + } + if (CollectionUtil.isNotEmpty(data)) { + data.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); + } + }); + } } - return result; + return data; } } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicVImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicVImpl.java index 8e297c5..719849e 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicVImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmphasicVImpl.java @@ -2,6 +2,8 @@ package com.njcn.dataProcess.service.impl.influxdb; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken; +import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; import com.njcn.dataProcess.dao.imapper.DataHarmphasicVMapper; @@ -17,11 +19,14 @@ import com.njcn.dataProcess.service.IDataHarmphasicV; import com.njcn.dataProcess.util.TimeUtils; import com.njcn.influx.constant.InfluxDbSqlConstant; import com.njcn.influx.query.InfluxQueryWrapper; +import com.njcn.redis.utils.RedisUtil; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.lang.reflect.Type; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -41,13 +46,18 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); put("BC", "B"); put("CA", "C"); put("M", "T"); }}; + @Resource + private RedisUtil redisUtil; + private static final Set LINE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T"))); + private static final Set PHASE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T"))); @Override @@ -205,6 +215,13 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl getMinuteData(List lineList, String startTime, String endTime, Map> timeMap, Boolean dataType) { List dataList; List result = new ArrayList<>(); + List data = new ArrayList<>(); + //获取监测点、接线方式数据 + Type type = new TypeToken>(){}.getType(); + Map map = new Gson().fromJson( + String.valueOf(redisUtil.getObjectByKey("wlLineDetail")), + type + ); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicV.class); influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); influxQueryWrapper.regular(DataHarmphasicV::getLineId, lineList) @@ -253,13 +270,30 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); + if (!Objects.isNull(map)) { + //现根据监测点分组,然后根据接线方式排除多于数据,在修改相别 + Map> lineMap = result.stream().collect(Collectors.groupingBy(DataHarmphasicV::getLineId)); + lineMap.forEach((k,v)->{ + if (Objects.isNull(map.get(k))) { + return; + } + Integer conType = map.get(k); + Set validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES; + List result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList()); + data.addAll(result2); + }); + } else { + data.addAll(result); + } + if (CollectionUtil.isNotEmpty(data)) { + data.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); + } + }); + } } - return result; + return data; } } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataPltImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataPltImpl.java index 960dbcc..95cdbdf 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataPltImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataPltImpl.java @@ -2,6 +2,8 @@ package com.njcn.dataProcess.service.impl.influxdb; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken; +import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.dataProcess.dao.imapper.DataPltMapper; import com.njcn.dataProcess.dao.relation.mapper.RStatDataPltRelationMapper; @@ -15,11 +17,14 @@ import com.njcn.dataProcess.pojo.po.RStatDataPltD; import com.njcn.dataProcess.service.IDataPlt; import com.njcn.dataProcess.util.TimeUtils; import com.njcn.influx.query.InfluxQueryWrapper; +import com.njcn.redis.utils.RedisUtil; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.lang.reflect.Type; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -39,13 +44,18 @@ public class InfluxdbDataPltImpl extends MppServiceImpl PHASE_MAPPING = new HashMap() {{ put("AB", "A"); put("BC", "B"); put("CA", "C"); put("M", "T"); }}; + @Resource + private RedisUtil redisUtil; + private static final Set LINE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T"))); + private static final Set PHASE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T"))); @Override public void batchInsertion(List dataPltDTOList) { @@ -152,6 +162,13 @@ public class InfluxdbDataPltImpl extends MppServiceImpl getMinuteDataPlt(LineCountEvaluateParam lineParam) { List dataList; List result = new ArrayList<>(); + List data = new ArrayList<>(); + //获取监测点、接线方式数据 + Type type = new TypeToken>(){}.getType(); + Map map = new Gson().fromJson( + String.valueOf(redisUtil.getObjectByKey("wlLineDetail")), + type + ); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataPlt.class); influxQueryWrapper.regular(DataPlt::getLineId, lineParam.getLineId()) .select(DataPlt::getLineId) @@ -202,13 +219,30 @@ public class InfluxdbDataPltImpl extends MppServiceImpl { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); + if (!Objects.isNull(map)) { + //现根据监测点分组,然后根据接线方式排除多于数据,在修改相别 + Map> lineMap = result.stream().collect(Collectors.groupingBy(DataPlt::getLineId)); + lineMap.forEach((k,v)->{ + if (Objects.isNull(map.get(k))) { + return; + } + Integer conType = map.get(k); + Set validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES; + List result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList()); + data.addAll(result2); + }); + } else { + data.addAll(result); + } + if (CollectionUtil.isNotEmpty(data)) { + data.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); + } + }); + } } - return result; + return data; } } diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataVImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataVImpl.java index 89e91e6..20d47d4 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataVImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataVImpl.java @@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.ObjectUtil; +import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken; +import com.alibaba.nacos.shaded.com.google.gson.Gson; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.utils.HarmonicTimesUtil; import com.njcn.dataProcess.constant.InfluxDBTableConstant; @@ -24,16 +26,19 @@ import com.njcn.dataProcess.service.IDataV; import com.njcn.dataProcess.util.TimeUtils; import com.njcn.influx.constant.InfluxDbSqlConstant; import com.njcn.influx.query.InfluxQueryWrapper; +import com.njcn.redis.utils.RedisUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.ListUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.lang.reflect.Type; import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -46,16 +51,20 @@ import java.util.stream.Collectors; public class InfluxdbDataVImpl extends MppServiceImpl implements IDataV { private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()); - private static final Map PHASE_MAPPING = new HashMap() {{ put("AB", "A"); put("BC", "B"); put("CA", "C"); put("M", "T"); }}; - @Resource private DataVMapper dataVMapper; + @Resource + private RedisUtil redisUtil; + private static final Set LINE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T"))); + private static final Set PHASE_VOLTAGE_TYPES = + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T"))); /** * 注意:influxdb不推荐采用in函数的方式批量查询监测点的数据,效率很低,容易造成崩溃,故每次单测点查询 @@ -437,6 +446,13 @@ public class InfluxdbDataVImpl extends MppServiceImpl getMinuteDataV(LineCountEvaluateParam lineParam) { List result = new ArrayList<>(); + List data = new ArrayList<>(); + //获取监测点、接线方式数据 + Type type = new TypeToken>(){}.getType(); + Map map = new Gson().fromJson( + String.valueOf(redisUtil.getObjectByKey("wlLineDetail")), + type + ); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class); influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); influxQueryWrapper.regular(DataV::getLineId, lineParam.getLineId()) @@ -463,14 +479,74 @@ public class InfluxdbDataVImpl extends MppServiceImpl { - String newType = PHASE_MAPPING.get(item.getPhasicType()); - if (newType != null) { - item.setPhasicType(newType); - } - }); + if (!Objects.isNull(map)) { + //现根据监测点分组,然后根据接线方式排除多于数据,在修改相别 + Map> lineMap = result.stream().collect(Collectors.groupingBy(DataV::getLineId)); + lineMap.forEach((k,v)->{ + if (Objects.isNull(map.get(k))) { + return; + } + //这边需要特殊处理下,将线电压数据赋值 + Map lineVoltageIndex = v.stream() + .filter(d -> PHASE_MAPPING.containsKey(d.getPhasicType())) + .filter(d -> d.getRmsLvr() != null) + .collect(Collectors.toMap( + d -> buildKey(d.getTime(), d.getValueType(), d.getPhasicType()), + Function.identity(), + (existing, replacement) -> existing + )); + v.stream() + .filter(d -> PHASE_VOLTAGE_TYPES.contains(d.getPhasicType())) + .forEach(phaseData -> { + // 根据当前相电压反查对应的线电压相别 + String targetLinePhasic = getReverseLinePhasic(phaseData.getPhasicType()); + if (targetLinePhasic == null) { + return; + } + String key = buildKey(phaseData.getTime(), phaseData.getValueType(), targetLinePhasic); + DataV matchedLineData = lineVoltageIndex.get(key); + if (matchedLineData != null && matchedLineData.getRmsLvr() != null) { + phaseData.setRmsLvr(matchedLineData.getRmsLvr()); + } + }); + Integer conType = map.get(k); + Set validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES; + List result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList()); + data.addAll(result2); + }); + } else { + data.addAll(result); + } + if (CollectionUtil.isNotEmpty(data)) { + data.forEach(item -> { + String newType = PHASE_MAPPING.get(item.getPhasicType()); + if (newType != null) { + item.setPhasicType(newType); + } + }); + } + } + return data; + } + + private static String buildKey(Object time, Object valueType, Object phasicType) { + return time + "|" + valueType + "|" + phasicType; + } + + private static String getReverseLinePhasic(String phaseType) { + if (phaseType == null) { + return null; + } + switch (phaseType) { + case "A": + return "AB"; + case "B": + return "BC"; + case "C": + return "CA"; + default: + return null; } - return result; } private void quality(List result, InfluxQueryWrapper influxQueryWrapper, LineCountEvaluateParam lineParam) { From 587e9365546d0e022949d100320adebdf1dce275 Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Fri, 26 Jun 2026 18:01:04 +0800 Subject: [PATCH 09/16] =?UTF-8?q?fix(influxdb):=20=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E5=8A=9F=E7=8E=87=E6=95=B0=E6=8D=AE=E6=8F=90=E5=8F=96=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E7=9B=B8=E4=BD=8D=E7=B1=BB=E5=9E=8B=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 InfluxdbDataHarmpowerPImpl 中启用相位类型条件判断 - 在 InfluxdbDataHarmpowerQImpl 中启用相位类型条件判断 - 在 InfluxdbDataHarmpowerSImpl 中启用相位类型条件判断 - 恢复了被注释掉的 Tot 参数提取逻辑 - 确保三相类型且线路参数为2时正确提取总量数据 --- .../impl/influxdb/InfluxdbDataHarmpowerPImpl.java | 11 +++++------ .../impl/influxdb/InfluxdbDataHarmpowerQImpl.java | 11 +++++------ .../impl/influxdb/InfluxdbDataHarmpowerSImpl.java | 11 +++++------ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java index 28831bb..9b567a4 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java @@ -107,12 +107,11 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl> lists; -// if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { -// lists = extractDataLists(valueTypeList, "Tot"); -// } else { -// lists = extractDataLists(valueTypeList, ""); -// } - lists = extractDataLists(valueTypeList, ""); + if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { + lists = extractDataLists(valueTypeList, "Tot"); + } else { + lists = extractDataLists(valueTypeList, ""); + } value.setValueList(lists); valueTypes.add(value); }); diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java index 0d90276..27b42f8 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerQImpl.java @@ -106,12 +106,11 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl> lists; -// if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { -// lists = extractDataLists(valueTypeList, "Tot"); -// } else { -// lists = extractDataLists(valueTypeList, ""); -// } - lists = extractDataLists(valueTypeList, ""); + if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { + lists = extractDataLists(valueTypeList, "Tot"); + } else { + lists = extractDataLists(valueTypeList, ""); + } value.setValueList(lists); valueTypes.add(value); }); diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java index 581883b..11df88a 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java @@ -106,12 +106,11 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl> lists; -// if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { -// lists = extractDataLists(valueTypeList, "Tot"); -// } else { -// lists = extractDataLists(valueTypeList, ""); -// } - lists = extractDataLists(valueTypeList, ""); + if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) { + lists = extractDataLists(valueTypeList, "Tot"); + } else { + lists = extractDataLists(valueTypeList, ""); + } value.setValueList(lists); valueTypes.add(value); }); From 0b950b3c35e23266d918a2667e1df2c962a8dd79 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Mon, 29 Jun 2026 11:16:02 +0800 Subject: [PATCH 10/16] =?UTF-8?q?feat(message-boot):=20=E6=8E=A5=E5=85=A5?= =?UTF-8?q?=20mq-starter=20=E9=80=9A=E7=94=A8=20MQ=20=E6=8A=BD=E8=B1=A1?= =?UTF-8?q?=E5=B1=82=EF=BC=88Task=209=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 FrontDataMqListener:@MqListener(LN_Topic),仅 redis-stream 模式激活 - 新增 RecallMqSender:MqTemplate.send 下行下发 Recall 消息 - FrontDataConsumer 加 @ConditionalOnProperty(mq.type=rocketmq, matchIfMissing=true) 互斥保护 - 新增 MqSliceWiringTest:4 个 ApplicationContextRunner 切片测试,全部通过 - 关键修复:用 withUserConfiguration(依赖顺序列举) 替代 AutoConfigurations.of(), 避免字母序排序导致 MqCoreAutoConfiguration 在 driver autoconfig 前处理, @ConditionalOnBean(MqDriver.class) 因此失败 Co-Authored-By: Claude Sonnet 4.6 --- message/message-boot/pom.xml | 22 ++ .../message/consumer/FrontDataConsumer.java | 2 + .../njcn/message/mq/FrontDataMqListener.java | 23 ++ .../com/njcn/message/mq/RecallMqSender.java | 19 ++ .../njcn/message/mq/MqSliceWiringTest.java | 200 ++++++++++++++++++ 5 files changed, 266 insertions(+) create mode 100644 message/message-boot/src/main/java/com/njcn/message/mq/FrontDataMqListener.java create mode 100644 message/message-boot/src/main/java/com/njcn/message/mq/RecallMqSender.java create mode 100644 message/message-boot/src/test/java/com/njcn/message/mq/MqSliceWiringTest.java diff --git a/message/message-boot/pom.xml b/message/message-boot/pom.xml index a5e3fc3..0e5f597 100644 --- a/message/message-boot/pom.xml +++ b/message/message-boot/pom.xml @@ -100,12 +100,34 @@ spring-boot-starter-websocket 2.7.12 + + com.njcn + mq-spring-boot-starter + 1.0.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-test + 2.7.12 + test + + + junit + junit + 4.13.2 + test + messageboot + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + org.apache.maven.plugins maven-compiler-plugin diff --git a/message/message-boot/src/main/java/com/njcn/message/consumer/FrontDataConsumer.java b/message/message-boot/src/main/java/com/njcn/message/consumer/FrontDataConsumer.java index a60a78c..f8d30fd 100644 --- a/message/message-boot/src/main/java/com/njcn/message/consumer/FrontDataConsumer.java +++ b/message/message-boot/src/main/java/com/njcn/message/consumer/FrontDataConsumer.java @@ -39,6 +39,8 @@ import java.util.concurrent.TimeUnit; * @createTime 2023/8/11 15:32 */ @Component +@org.springframework.boot.autoconfigure.condition.ConditionalOnProperty( + name = "mq.type", havingValue = "rocketmq", matchIfMissing = true) @RocketMQMessageListener( topic = "LN_Topic", consumerGroup = "ln_consumer", diff --git a/message/message-boot/src/main/java/com/njcn/message/mq/FrontDataMqListener.java b/message/message-boot/src/main/java/com/njcn/message/mq/FrontDataMqListener.java new file mode 100644 index 0000000..2219940 --- /dev/null +++ b/message/message-boot/src/main/java/com/njcn/message/mq/FrontDataMqListener.java @@ -0,0 +1,23 @@ +package com.njcn.message.mq; + +import com.njcn.message.messagedto.MessageDataDTO; +import com.njcn.mq.annotation.MqListener; +import com.njcn.stat.api.MessAnalysisFeignClient; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Collections; + +@Component +@ConditionalOnProperty(name = "mq.type", havingValue = "redis-stream") +public class FrontDataMqListener { + + @Resource + private MessAnalysisFeignClient messAnalysisFeignClient; + + @MqListener(topic = "LN_Topic", group = "ln_consumer") + public void onFrontData(MessageDataDTO msg) { + messAnalysisFeignClient.analysis(Collections.singletonList(msg)); + } +} diff --git a/message/message-boot/src/main/java/com/njcn/message/mq/RecallMqSender.java b/message/message-boot/src/main/java/com/njcn/message/mq/RecallMqSender.java new file mode 100644 index 0000000..22998e2 --- /dev/null +++ b/message/message-boot/src/main/java/com/njcn/message/mq/RecallMqSender.java @@ -0,0 +1,19 @@ +package com.njcn.message.mq; + +import com.njcn.message.constant.BusinessTopic; +import com.njcn.message.message.RecallMessage; +import com.njcn.mq.core.MqTemplate; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component +public class RecallMqSender { + + @Resource + private MqTemplate mqTemplate; + + public void send(RecallMessage message, String nodeId) { + mqTemplate.send(nodeId + "_" + BusinessTopic.RECALL_TOPIC, message); + } +} diff --git a/message/message-boot/src/test/java/com/njcn/message/mq/MqSliceWiringTest.java b/message/message-boot/src/test/java/com/njcn/message/mq/MqSliceWiringTest.java new file mode 100644 index 0000000..d7157b8 --- /dev/null +++ b/message/message-boot/src/test/java/com/njcn/message/mq/MqSliceWiringTest.java @@ -0,0 +1,200 @@ +package com.njcn.message.mq; + +import com.alibaba.fastjson.JSON; +import com.njcn.message.message.RecallMessage; +import com.njcn.message.messagedto.MessageDataDTO; +import com.njcn.middle.stream.autoconfig.RedisStreamAutoConfiguration; +import com.njcn.mq.autoconfig.MqCoreAutoConfiguration; +import com.njcn.mq.driver.redis.RedisStreamMqDriver; +import com.njcn.mq.driver.redis.RedisStreamMqDriverAutoConfiguration; +import com.njcn.mq.driver.rocketmq.RocketMqDriver; +import com.njcn.mq.driver.rocketmq.RocketMqDriverAutoConfiguration; +import com.njcn.mq.spi.MqDriver; +import com.njcn.stat.api.MessAnalysisFeignClient; +import org.apache.rocketmq.spring.autoconfigure.RocketMQProperties; +import org.apache.rocketmq.spring.core.RocketMQTemplate; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.data.redis.connection.stream.MapRecord; +import org.springframework.data.redis.connection.stream.ReadOffset; +import org.springframework.data.redis.connection.stream.StreamOffset; +import org.springframework.data.redis.connection.stream.StreamReadOptions; +import org.springframework.data.redis.connection.stream.StreamRecords; +import org.springframework.data.redis.core.StringRedisTemplate; + +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; + +/** + * MQ starter 切片接入验证测试(ApplicationContextRunner,不启动全应用)。 + * 真实 Redis 要求:localhost:6379(docker redis-stream-it)。 + * 无 Redis 时,依赖 Redis 的用例通过 Assumptions 跳过。 + * + *

注意:withConfiguration(AutoConfigurations.of(...)) 会对 autoconfig 类名做字母序排序, + * 导致 MqCoreAutoConfiguration 在 driver autoconfig 之前处理,@ConditionalOnBean(MqDriver.class) + * 因此失败。改用 withUserConfiguration(...) 按依赖顺序显式列出,避免排序问题。 + */ +public class MqSliceWiringTest { + + private static boolean redisAvailable() { + try { + Socket s = new Socket(); + s.connect(new InetSocketAddress("localhost", 6379), 500); + s.close(); + return true; + } catch (Exception e) { + return false; + } + } + + /** + * redis-stream 模式的基础 runner。 + * 按依赖顺序列出:Redis → Phase1 stream → redis driver → rocket driver(inactive) → mq core → 业务 bean + * 这样 @ConditionalOnBean(MqDriver.class) 在 MqCoreAutoConfiguration 被解析时已能找到 MqDriver 定义。 + */ + private ApplicationContextRunner redisStreamRunner() { + return new ApplicationContextRunner() + .withUserConfiguration( + RedisAutoConfiguration.class, // 1. StringRedisTemplate + RedisStreamAutoConfiguration.class, // 2. StreamKeyBuilder, RedisStreamProperties + RedisStreamMqDriverAutoConfiguration.class, // 3. MqDriver(RedisStreamMqDriver) + RocketMqDriverAutoConfiguration.class, // 4. inactive for redis-stream + MqCoreAutoConfiguration.class, // 5. MqTemplate, MqListenerRegistry + FrontDataMqListener.class, // 6. 上行 listener + RecallMqSender.class // 7. 下行 sender + ) + .withBean(MessAnalysisFeignClient.class, + () -> mock(MessAnalysisFeignClient.class)) + .withPropertyValues( + "mq.type=redis-stream", + "spring.redis.host=localhost", + "spring.redis.port=6379" + ); + } + + // ------------------------------------------------------------------ + // 1. Driver 二选一 + // ------------------------------------------------------------------ + + @Test + void testRedisStreamDriverSelected() { + Assumptions.assumeTrue(redisAvailable(), "Redis not available at localhost:6379, skipping"); + redisStreamRunner().run(ctx -> { + assertThat(ctx).hasSingleBean(MqDriver.class); + assertThat(ctx.getBean(MqDriver.class)).isInstanceOf(RedisStreamMqDriver.class); + }); + } + + @Test + void testRocketMqDriverSelected() { + // rocket 测试不依赖真实 Redis,仅引入 rocket 相关 + core + new ApplicationContextRunner() + .withUserConfiguration( + RocketMqDriverAutoConfiguration.class, // 1. MqDriver(RocketMqDriver) + RedisStreamMqDriverAutoConfiguration.class, // 2. inactive for rocketmq + MqCoreAutoConfiguration.class, // 3. MqTemplate, MqListenerRegistry + FrontDataMqListener.class, // 4. inactive for rocketmq + RecallMqSender.class // 5. sender + ) + .withBean(MessAnalysisFeignClient.class, + () -> mock(MessAnalysisFeignClient.class)) + .withBean(RocketMQTemplate.class, + () -> mock(RocketMQTemplate.class)) + .withBean(RocketMQProperties.class, RocketMQProperties::new) + .withPropertyValues("mq.type=rocketmq") + .run(ctx -> { + assertThat(ctx).hasSingleBean(MqDriver.class); + assertThat(ctx.getBean(MqDriver.class)).isInstanceOf(RocketMqDriver.class); + }); + } + + // ------------------------------------------------------------------ + // 2. 上行(需要真实 Redis) + // 向 LN_Topic stream XADD 一条消息,验证 FrontDataMqListener 触发了 + // messAnalysisFeignClient.analysis(...) + // ------------------------------------------------------------------ + + @Test + void testUpstreamFrontData() { + Assumptions.assumeTrue(redisAvailable(), "Redis not available at localhost:6379, skipping"); + redisStreamRunner().run(ctx -> { + StringRedisTemplate redis = ctx.getBean(StringRedisTemplate.class); + MessAnalysisFeignClient mockClient = ctx.getBean(MessAnalysisFeignClient.class); + + // 构造 RedisStreamMqDriver 消费时期望的字段格式 + // enc=plain → body 即为原始 JSON(参见 MessageCodec.encodeBody(json, false)) + // stream key = StreamKeyBuilder.buildStream("LN_Topic") = "LN_Topic" + // (默认 envIsolation=false,无 env 前缀) + MessageDataDTO dto = new MessageDataDTO(); + dto.setDataType(1); + String json = JSON.toJSONString(dto); + + Map fields = new HashMap(); + fields.put("key", "test-key-upstream-1"); + fields.put("tag", ""); + fields.put("enc", "plain"); + fields.put("body", json); + fields.put("ts", String.valueOf(System.currentTimeMillis())); + + // XADD 到 LN_Topic(MqListenerRegistry.start() 已在 context 启动时订阅该 stream) + redis.opsForStream().add( + StreamRecords.newRecord().in("LN_Topic").ofMap(fields) + ); + + // 等待消费线程处理(blockMs 默认 2000ms,timeout=5000ms 足够) + verify(mockClient, timeout(5000)).analysis(anyList()); + }); + } + + // ------------------------------------------------------------------ + // 3. 下行(需要真实 Redis) + // 通过 RecallMqSender 发送 RecallMessage,验证 stream 内容正确 + // ------------------------------------------------------------------ + + @Test + void testDownstreamRecall() { + Assumptions.assumeTrue(redisAvailable(), "Redis not available at localhost:6379, skipping"); + redisStreamRunner().run(ctx -> { + StringRedisTemplate redis = ctx.getBean(StringRedisTemplate.class); + RecallMqSender sender = ctx.getBean(RecallMqSender.class); + + // 清理,确保只有本次发送的消息 + redis.delete("n1_recall_Topic"); + + RecallMessage msg = new RecallMessage(); + msg.setGuid("g1"); + // MqTemplate.send("n1_recall_Topic", msg) → RedisStreamMqDriver XADD + // stream key = StreamKeyBuilder.buildStream("n1_recall_Topic") = "n1_recall_Topic" + sender.send(msg, "n1"); + + Long size = redis.opsForStream().size("n1_recall_Topic"); + assertThat(size).isGreaterThanOrEqualTo(1L); + + @SuppressWarnings("unchecked") + List> records = + redis.opsForStream().read( + StreamReadOptions.empty().count(1L), + StreamOffset.create("n1_recall_Topic", ReadOffset.from("0-0")) + ); + assertThat(records).isNotEmpty(); + + Map firstFields = records.get(0).getValue(); + // DefaultMqTemplate.send(topic, payload) 使用 encodeBody(json, false) → enc="plain" + // 因此 body 即为原始 JSON,无需 gzip 解压 + String body = (String) firstFields.get("body"); + RecallMessage result = JSON.parseObject(body, RecallMessage.class); + assertThat(result.getGuid()).isEqualTo("g1"); + }); + } +} From 79374ea6eca537222749815fc81f85e4cae2069a Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Mon, 29 Jun 2026 12:01:49 +0800 Subject: [PATCH 11/16] =?UTF-8?q?test(message):=20=E5=88=87=E7=89=87=20wir?= =?UTF-8?q?ing=20=E6=B5=8B=E8=AF=95=E6=94=B9=E7=94=A8=E7=9C=9F=E5=AE=9E=20?= =?UTF-8?q?autoconfig=20=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MqSliceWiringTest 从 withUserConfiguration 手动排序改为 AutoConfigurations.of (等价真实 boot 的 AutoConfigurationSorter),并断言 MqTemplate / MqListenerRegistry 在真实顺序下装配,防止 core 装配顺序回归;配合 mq-starter driver autoconfig 的 @AutoConfigureBefore 修复。同时去掉 driver 选择用例多余的 Redis 守卫。 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../njcn/message/mq/MqSliceWiringTest.java | 88 +++++++++++-------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/message/message-boot/src/test/java/com/njcn/message/mq/MqSliceWiringTest.java b/message/message-boot/src/test/java/com/njcn/message/mq/MqSliceWiringTest.java index d7157b8..de2d75f 100644 --- a/message/message-boot/src/test/java/com/njcn/message/mq/MqSliceWiringTest.java +++ b/message/message-boot/src/test/java/com/njcn/message/mq/MqSliceWiringTest.java @@ -5,6 +5,8 @@ import com.njcn.message.message.RecallMessage; import com.njcn.message.messagedto.MessageDataDTO; import com.njcn.middle.stream.autoconfig.RedisStreamAutoConfiguration; import com.njcn.mq.autoconfig.MqCoreAutoConfiguration; +import com.njcn.mq.container.MqListenerRegistry; +import com.njcn.mq.core.MqTemplate; import com.njcn.mq.driver.redis.RedisStreamMqDriver; import com.njcn.mq.driver.redis.RedisStreamMqDriverAutoConfiguration; import com.njcn.mq.driver.rocketmq.RocketMqDriver; @@ -15,6 +17,7 @@ import org.apache.rocketmq.spring.autoconfigure.RocketMQProperties; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.data.redis.connection.stream.MapRecord; @@ -38,12 +41,16 @@ import static org.mockito.Mockito.verify; /** * MQ starter 切片接入验证测试(ApplicationContextRunner,不启动全应用)。 - * 真实 Redis 要求:localhost:6379(docker redis-stream-it)。 - * 无 Redis 时,依赖 Redis 的用例通过 Assumptions 跳过。 + * 真实 Redis 要求:localhost:6379(docker redis-stream-it);仅上/下行收发用例需要, + * 纯装配用例不需要(Lettuce 懒连接,不触发实际连接)。 * - *

注意:withConfiguration(AutoConfigurations.of(...)) 会对 autoconfig 类名做字母序排序, - * 导致 MqCoreAutoConfiguration 在 driver autoconfig 之前处理,@ConditionalOnBean(MqDriver.class) - * 因此失败。改用 withUserConfiguration(...) 按依赖顺序显式列出,避免排序问题。 + *

装配一律用 {@code withConfiguration(AutoConfigurations.of(...))},让 Spring 按 + * 真实 autoconfig 顺序(AutoConfigurationSorter)处理,与生产环境一致。以此 + * 验证 {@link MqCoreAutoConfiguration} 的 {@code @ConditionalOnBean(MqDriver)} 能在 + * 真实顺序下拿到 driver bean —— 这依赖 driver autoconfig 上的 + * {@code @AutoConfigureBefore(MqCoreAutoConfiguration.class)}。若缺该保障,按类名字母序 + * {@code com.njcn.mq.autoconfig.*} 先于 {@code com.njcn.mq.driver.*},core 会在 driver + * bean 注册前求值条件失败,导致 MqTemplate / MqListenerRegistry 不装配。 */ public class MqSliceWiringTest { @@ -58,64 +65,67 @@ public class MqSliceWiringTest { } } - /** - * redis-stream 模式的基础 runner。 - * 按依赖顺序列出:Redis → Phase1 stream → redis driver → rocket driver(inactive) → mq core → 业务 bean - * 这样 @ConditionalOnBean(MqDriver.class) 在 MqCoreAutoConfiguration 被解析时已能找到 MqDriver 定义。 - */ + /** redis-stream 模式:真实 autoconfig 顺序装 5 个 autoconfig + 业务 bean(上/下行用)。 */ private ApplicationContextRunner redisStreamRunner() { return new ApplicationContextRunner() - .withUserConfiguration( - RedisAutoConfiguration.class, // 1. StringRedisTemplate - RedisStreamAutoConfiguration.class, // 2. StreamKeyBuilder, RedisStreamProperties - RedisStreamMqDriverAutoConfiguration.class, // 3. MqDriver(RedisStreamMqDriver) - RocketMqDriverAutoConfiguration.class, // 4. inactive for redis-stream - MqCoreAutoConfiguration.class, // 5. MqTemplate, MqListenerRegistry - FrontDataMqListener.class, // 6. 上行 listener - RecallMqSender.class // 7. 下行 sender - ) + .withConfiguration(AutoConfigurations.of( + RedisAutoConfiguration.class, + RedisStreamAutoConfiguration.class, + RedisStreamMqDriverAutoConfiguration.class, + RocketMqDriverAutoConfiguration.class, + MqCoreAutoConfiguration.class)) + .withUserConfiguration(FrontDataMqListener.class, RecallMqSender.class) .withBean(MessAnalysisFeignClient.class, () -> mock(MessAnalysisFeignClient.class)) .withPropertyValues( "mq.type=redis-stream", "spring.redis.host=localhost", - "spring.redis.port=6379" - ); + "spring.redis.port=6379"); } // ------------------------------------------------------------------ - // 1. Driver 二选一 + // 1. 装配:mq.type 二选一 + core bean 在真实 autoconfig 顺序下装配 // ------------------------------------------------------------------ @Test void testRedisStreamDriverSelected() { - Assumptions.assumeTrue(redisAvailable(), "Redis not available at localhost:6379, skipping"); - redisStreamRunner().run(ctx -> { - assertThat(ctx).hasSingleBean(MqDriver.class); - assertThat(ctx.getBean(MqDriver.class)).isInstanceOf(RedisStreamMqDriver.class); - }); + // 纯装配检查,不依赖真实 Redis(Lettuce 懒连接)。 + new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of( + RedisAutoConfiguration.class, + RedisStreamAutoConfiguration.class, + RedisStreamMqDriverAutoConfiguration.class, + RocketMqDriverAutoConfiguration.class, + MqCoreAutoConfiguration.class)) + .withPropertyValues( + "mq.type=redis-stream", + "spring.redis.host=localhost", + "spring.redis.port=6379") + .run(ctx -> { + assertThat(ctx).hasSingleBean(MqDriver.class); + assertThat(ctx.getBean(MqDriver.class)).isInstanceOf(RedisStreamMqDriver.class); + // 真实顺序下 core 的 @ConditionalOnBean(MqDriver) 必须命中 + assertThat(ctx).hasSingleBean(MqTemplate.class); + assertThat(ctx).hasSingleBean(MqListenerRegistry.class); + }); } @Test void testRocketMqDriverSelected() { - // rocket 测试不依赖真实 Redis,仅引入 rocket 相关 + core + // rocket 测试不依赖真实 Redis;不装 RedisAutoConfiguration,redis driver 因 mq.type 不匹配而 inactive。 new ApplicationContextRunner() - .withUserConfiguration( - RocketMqDriverAutoConfiguration.class, // 1. MqDriver(RocketMqDriver) - RedisStreamMqDriverAutoConfiguration.class, // 2. inactive for rocketmq - MqCoreAutoConfiguration.class, // 3. MqTemplate, MqListenerRegistry - FrontDataMqListener.class, // 4. inactive for rocketmq - RecallMqSender.class // 5. sender - ) - .withBean(MessAnalysisFeignClient.class, - () -> mock(MessAnalysisFeignClient.class)) - .withBean(RocketMQTemplate.class, - () -> mock(RocketMQTemplate.class)) + .withConfiguration(AutoConfigurations.of( + RedisStreamMqDriverAutoConfiguration.class, + RocketMqDriverAutoConfiguration.class, + MqCoreAutoConfiguration.class)) + .withBean(RocketMQTemplate.class, () -> mock(RocketMQTemplate.class)) .withBean(RocketMQProperties.class, RocketMQProperties::new) .withPropertyValues("mq.type=rocketmq") .run(ctx -> { assertThat(ctx).hasSingleBean(MqDriver.class); assertThat(ctx.getBean(MqDriver.class)).isInstanceOf(RocketMqDriver.class); + assertThat(ctx).hasSingleBean(MqTemplate.class); + assertThat(ctx).hasSingleBean(MqListenerRegistry.class); }); } From 88cd32dd1064c251f35c71c12bab323cc98a2d85 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Tue, 30 Jun 2026 15:57:50 +0800 Subject: [PATCH 12/16] =?UTF-8?q?=E4=B8=93=E9=A1=B9=E5=88=86=E6=9E=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=8C=E7=BB=BC=E5=90=88=E8=AF=84=E4=BC=B0?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../line/DataComAssServiceImpl.java | 21 +++++++++++++++++-- .../line/SpecialAnalysisServiceImpl.java | 3 ++- .../dataProcess/api/SpThroughFeignClient.java | 3 --- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java index 5bd2119..5d18181 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java @@ -51,6 +51,12 @@ public class DataComAssServiceImpl implements IDataComAssService { @Resource private PqDataVerifyFeignClient pqDataVerifyFeignClient; + /** + * 查询配置 辽宁版本比较特殊,没有CP95值,采用平均值进行判断 + */ + @Value("${version.used:master}") + private String versionUsed; + @Override public void dataComAssHandler(CalculatedParam calculatedParam) { List list = new ArrayList<>(); @@ -138,7 +144,7 @@ public class DataComAssServiceImpl implements IDataComAssService { BigDecimal hundred = BigDecimal.valueOf(100); //************************************电压偏差******************************************** lineParam.setPhasicType(Arrays.asList("A", "B", "C")); - lineParam.setValueType(Arrays.asList("AVG")); + lineParam.setValueType(Collections.singletonList("AVG")); lineParam.setColumnName("vu_dev"); lineParam.setGe("10"); Integer vuDev1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); @@ -196,7 +202,13 @@ public class DataComAssServiceImpl implements IDataComAssService { } //************************************谐波畸变率******************************************** lineParam.setColumnName("v_thd"); - lineParam.setValueType(Arrays.asList("CP95")); + + if("liaoning".equals(versionUsed)){ + lineParam.setValueType(Collections.singletonList("AVG")); + }else { + lineParam.setValueType(Collections.singletonList("CP95")); + } + lineParam.setGe("6"); Integer vThd1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); @@ -226,6 +238,10 @@ public class DataComAssServiceImpl implements IDataComAssService { //************************************三相电压不平衡度******************************************** lineParam.setColumnName("v_unbalance"); + if("liaoning".equals(versionUsed)){ + lineParam.setValueType(Collections.singletonList("MAX")); + } + lineParam.setPhasicType(Collections.singletonList("T")); lineParam.setGe("4"); Integer vUnbalance1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); @@ -255,6 +271,7 @@ public class DataComAssServiceImpl implements IDataComAssService { //************************************电压波动(短时闪变)******************************************** lineParam.setColumnName("pst"); lineParam.setValueType(null); + lineParam.setPhasicType(Arrays.asList("A", "B", "C")); lineParam.setGe("0.8"); Integer plt1 = dataFlickerFeignClient.getColumnNameCountRawData(lineParam).getData(); diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java index 7bb7e30..9255510 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/SpecialAnalysisServiceImpl.java @@ -21,6 +21,7 @@ import com.njcn.device.biz.commApi.CommLineClient; import com.njcn.device.biz.pojo.dto.LineDTO; import com.njcn.device.pms.pojo.param.MonitorTerminalParam; import com.njcn.device.pq.api.LineFeignClient; +import com.njcn.device.pq.api.UserLedgerFeignClient; import com.njcn.device.pq.pojo.vo.LineDetailDataVO; import com.njcn.event.api.EventDetailFeignClient; import com.njcn.event.api.TransientFeignClient; @@ -84,7 +85,7 @@ public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService { @Resource private CommLineClient commLineClient; @Resource - private UserLedgerOldFeignClient userLedgerFeignClient; + private UserLedgerFeignClient userLedgerFeignClient; @Resource private DataLimitRateDetailFeignClient dataLimitRateDetailFeignClient; diff --git a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/api/SpThroughFeignClient.java b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/api/SpThroughFeignClient.java index d438d19..bcd44e3 100644 --- a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/api/SpThroughFeignClient.java +++ b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/api/SpThroughFeignClient.java @@ -2,10 +2,7 @@ package com.njcn.dataProcess.api; import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.response.HttpResult; -import com.njcn.dataProcess.api.fallback.RmpEventFeignClientFallbackFactory; import com.njcn.dataProcess.api.fallback.SpThroughFeignClientFallbackFactory; -import com.njcn.dataProcess.dto.RmpEventDetailDTO; -import com.njcn.dataProcess.param.LineCountEvaluateParam; import com.njcn.dataProcess.pojo.dto.RActivePowerRangeDto; import com.njcn.dataProcess.pojo.dto.SpThroughDto; import org.springframework.cloud.openfeign.FeignClient; From ac40e92c79fec6d80ce9c6a48a19174128e288b1 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Tue, 30 Jun 2026 18:21:53 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E4=B8=93=E9=A1=B9=E5=88=86=E6=9E=90?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=8C=E7=BB=BC=E5=90=88=E8=AF=84=E4=BC=B0?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/line/DataComAssServiceImpl.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java index 5d18181..476e707 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java @@ -175,6 +175,7 @@ public class DataComAssServiceImpl implements IDataComAssService { //************************************频率偏差******************************************** lineParam.setColumnName("freq_dev"); lineParam.setGe("0.3"); + lineParam.setGe(null); Integer freqDev1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); lineParam.setGe("0.2"); @@ -210,6 +211,7 @@ public class DataComAssServiceImpl implements IDataComAssService { } lineParam.setGe("6"); + lineParam.setLt(null); Integer vThd1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); lineParam.setGe("4"); @@ -243,6 +245,7 @@ public class DataComAssServiceImpl implements IDataComAssService { } lineParam.setPhasicType(Collections.singletonList("T")); lineParam.setGe("4"); + lineParam.setLt(null); Integer vUnbalance1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); lineParam.setGe("2"); @@ -273,6 +276,7 @@ public class DataComAssServiceImpl implements IDataComAssService { lineParam.setValueType(null); lineParam.setPhasicType(Arrays.asList("A", "B", "C")); lineParam.setGe("0.8"); + lineParam.setLt("1"); Integer plt1 = dataFlickerFeignClient.getColumnNameCountRawData(lineParam).getData(); lineParam.setGe("0.6"); @@ -292,11 +296,11 @@ public class DataComAssServiceImpl implements IDataComAssService { Integer plt5 = dataFlickerFeignClient.getColumnNameCountRawData(lineParam).getData(); BigDecimal pltAll = BigDecimal.valueOf(plt1 + plt2 + plt3 + plt4 + plt5); if (pltAll.compareTo(BigDecimal.ZERO) != 0) { - outMap.put("data_plt1", BigDecimal.valueOf(plt1).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); - outMap.put("data_plt2", BigDecimal.valueOf(plt2).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); - outMap.put("data_plt3", BigDecimal.valueOf(plt3).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); - outMap.put("data_plt4", BigDecimal.valueOf(plt4).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); - outMap.put("data_plt5", BigDecimal.valueOf(plt5).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); + outMap.put("data_pst1", BigDecimal.valueOf(plt1).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); + outMap.put("data_pst2", BigDecimal.valueOf(plt2).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); + outMap.put("data_pst3", BigDecimal.valueOf(plt3).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); + outMap.put("data_pst4", BigDecimal.valueOf(plt4).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); + outMap.put("data_pst5", BigDecimal.valueOf(plt5).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); } if (!CollUtil.isEmpty(outMap)) { From 274d787b049fcfcf50fca59d4a92c2101dca8e46 Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Wed, 1 Jul 2026 17:16:21 +0800 Subject: [PATCH 14/16] =?UTF-8?q?refactor(data):=20=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AD=97=E6=AE=B5=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将DataHarmpowerP类中的totPf、totDf、totP等字段的@Column注解名称规范化为下划线格式 - 将DataHarmpowerP类中的totP1-totP50字段名统一调整为tot_tp_1-tot_tp_50格式 - 将DataHarmpowerQ类中的totQ字段名调整为tot_q,totQ1-totQ50调整为tot_tq_1-tot_tq_50格式 - 将DataHarmpowerS类中的totS字段名调整为tot_s,totS1-totS50调整为tot_ts_1-tot_ts_50格式 - 在InfluxdbDataHarmpowerPImpl服务中添加tot_tp_1-tot_tp_50字段的查询条件配置 - 在InfluxdbDataHarmpowerPImpl服务中增加TotP、TotDf、TotPf字段的选择查询 - 在InfluxdbDataHarmpowerQImpl服务中添加tot_tq_1-tot_tq_50字段的查询条件配置 - 在InfluxdbDataHarmpowerQImpl服务中增加TotQ字段的选择查询 - 在InfluxdbDataHarmpowerSImpl服务中添加tot_ts_1-tot_ts_50字段的查询条件配置 - 在InfluxdbDataHarmpowerSImpl服务中增加TotS字段的选择查询 --- .../dataProcess/po/influx/DataHarmpowerP.java | 110 +++++++++--------- .../dataProcess/po/influx/DataHarmpowerQ.java | 102 ++++++++-------- .../dataProcess/po/influx/DataHarmpowerS.java | 102 ++++++++-------- .../influxdb/InfluxdbDataHarmpowerPImpl.java | 4 + .../influxdb/InfluxdbDataHarmpowerQImpl.java | 2 + .../influxdb/InfluxdbDataHarmpowerSImpl.java | 2 + 6 files changed, 165 insertions(+), 157 deletions(-) diff --git a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerP.java b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerP.java index 49d9cc3..1e75132 100644 --- a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerP.java +++ b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerP.java @@ -214,111 +214,111 @@ public class DataHarmpowerP { private Double p50; //在线监测添加的字段 - @Column(name = "totPf") - private Double totPf; - @Column(name = "totDf") - private Double totDf; - @Column(name = "totP") + @Column(name = "tot_p") private Double totP; - @Column(name = "totP1") + @Column(name = "tot_df") + private Double totDf; + @Column(name = "tot_pf") + private Double totPf; + @Column(name = "tot_tp_1") private Double totP1; - @Column(name = "totP2") + @Column(name = "tot_tp_2") private Double totP2; - @Column(name = "totP3") + @Column(name = "tot_tp_3") private Double totP3; - @Column(name = "totP4") + @Column(name = "tot_tp_4") private Double totP4; - @Column(name = "totP5") + @Column(name = "tot_tp_5") private Double totP5; - @Column(name = "totP6") + @Column(name = "tot_tp_6") private Double totP6; - @Column(name = "totP7") + @Column(name = "tot_tp_7") private Double totP7; - @Column(name = "totP8") + @Column(name = "tot_tp_8") private Double totP8; - @Column(name = "totP9") + @Column(name = "tot_tp_9") private Double totP9; - @Column(name = "totP10") + @Column(name = "tot_tp_10") private Double totP10; - @Column(name = "totP11") + @Column(name = "tot_tp_11") private Double totP11; - @Column(name = "totP12") + @Column(name = "tot_tp_12") private Double totP12; - @Column(name = "totP13") + @Column(name = "tot_tp_13") private Double totP13; - @Column(name = "totP14") + @Column(name = "tot_tp_14") private Double totP14; - @Column(name = "totP15") + @Column(name = "tot_tp_15") private Double totP15; - @Column(name = "totP16") + @Column(name = "tot_tp_16") private Double totP16; - @Column(name = "totP17") + @Column(name = "tot_tp_17") private Double totP17; - @Column(name = "totP18") + @Column(name = "tot_tp_18") private Double totP18; - @Column(name = "totP19") + @Column(name = "tot_tp_19") private Double totP19; - @Column(name = "totP20") + @Column(name = "tot_tp_20") private Double totP20; - @Column(name = "totP21") + @Column(name = "tot_tp_21") private Double totP21; - @Column(name = "totP22") + @Column(name = "tot_tp_22") private Double totP22; - @Column(name = "totP23") + @Column(name = "tot_tp_23") private Double totP23; - @Column(name = "totP24") + @Column(name = "tot_tp_24") private Double totP24; - @Column(name = "totP25") + @Column(name = "tot_tp_25") private Double totP25; - @Column(name = "totP26") + @Column(name = "tot_tp_26") private Double totP26; - @Column(name = "totP27") + @Column(name = "tot_tp_27") private Double totP27; - @Column(name = "totP28") + @Column(name = "tot_tp_28") private Double totP28; - @Column(name = "totP29") + @Column(name = "tot_tp_29") private Double totP29; - @Column(name = "totP30") + @Column(name = "tot_tp_30") private Double totP30; - @Column(name = "totP31") + @Column(name = "tot_tp_31") private Double totP31; - @Column(name = "totP32") + @Column(name = "tot_tp_32") private Double totP32; - @Column(name = "totP33") + @Column(name = "tot_tp_33") private Double totP33; - @Column(name = "totP34") + @Column(name = "tot_tp_34") private Double totP34; - @Column(name = "totP35") + @Column(name = "tot_tp_35") private Double totP35; - @Column(name = "totP36") + @Column(name = "tot_tp_36") private Double totP36; - @Column(name = "totP37") + @Column(name = "tot_tp_37") private Double totP37; - @Column(name = "totP38") + @Column(name = "tot_tp_38") private Double totP38; - @Column(name = "totP39") + @Column(name = "tot_tp_39") private Double totP39; - @Column(name = "totP40") + @Column(name = "tot_tp_40") private Double totP40; - @Column(name = "totP41") + @Column(name = "tot_tp_41") private Double totP41; - @Column(name = "totP42") + @Column(name = "tot_tp_42") private Double totP42; - @Column(name = "totP43") + @Column(name = "tot_tp_43") private Double totP43; - @Column(name = "totP44") + @Column(name = "tot_tp_44") private Double totP44; - @Column(name = "totP45") + @Column(name = "tot_tp_45") private Double totP45; - @Column(name = "totP46") + @Column(name = "tot_tp_46") private Double totP46; - @Column(name = "totP47") + @Column(name = "tot_tp_47") private Double totP47; - @Column(name = "totP49") + @Column(name = "tot_tp_49") private Double totP48; - @Column(name = "totP49") + @Column(name = "tot_tp_49") private Double totP49; - @Column(name = "totP50") + @Column(name = "tot_tp_50") private Double totP50; diff --git a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerQ.java b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerQ.java index beaeb33..5ca76a7 100644 --- a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerQ.java +++ b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerQ.java @@ -208,107 +208,107 @@ public class DataHarmpowerQ { private Double q50; //在线监测添加的字段 - @Column(name = "totQ") + @Column(name = "tot_q") private Double totQ; - @Column(name = "totQ1") + @Column(name = "tot_tq_1") private Double totQ1; - @Column(name = "totQ2") + @Column(name = "tot_tq_2") private Double totQ2; - @Column(name = "totQ3") + @Column(name = "tot_tq_3") private Double totQ3; - @Column(name = "totQ4") + @Column(name = "tot_tq_4") private Double totQ4; - @Column(name = "totQ5") + @Column(name = "tot_tq_5") private Double totQ5; - @Column(name = "totQ6") + @Column(name = "tot_tq_6") private Double totQ6; - @Column(name = "totQ7") + @Column(name = "tot_tq_7") private Double totQ7; - @Column(name = "totQ8") + @Column(name = "tot_tq_8") private Double totQ8; - @Column(name = "totQ9") + @Column(name = "tot_tq_9") private Double totQ9; - @Column(name = "totQ10") + @Column(name = "tot_tq_10") private Double totQ10; - @Column(name = "totQ11") + @Column(name = "tot_tq_11") private Double totQ11; - @Column(name = "totQ12") + @Column(name = "tot_tq_12") private Double totQ12; - @Column(name = "totQ13") + @Column(name = "tot_tq_13") private Double totQ13; - @Column(name = "totQ14") + @Column(name = "tot_tq_14") private Double totQ14; - @Column(name = "totQ15") + @Column(name = "tot_tq_15") private Double totQ15; - @Column(name = "totQ16") + @Column(name = "tot_tq_16") private Double totQ16; - @Column(name = "totQ17") + @Column(name = "tot_tq_17") private Double totQ17; - @Column(name = "totQ18") + @Column(name = "tot_tq_18") private Double totQ18; - @Column(name = "totQ19") + @Column(name = "tot_tq_19") private Double totQ19; - @Column(name = "totQ20") + @Column(name = "tot_tq_20") private Double totQ20; - @Column(name = "totQ21") + @Column(name = "tot_tq_21") private Double totQ21; - @Column(name = "totQ22") + @Column(name = "tot_tq_22") private Double totQ22; - @Column(name = "totQ23") + @Column(name = "tot_tq_23") private Double totQ23; - @Column(name = "totQ24") + @Column(name = "tot_tq_24") private Double totQ24; - @Column(name = "totQ25") + @Column(name = "tot_tq_25") private Double totQ25; - @Column(name = "totQ26") + @Column(name = "tot_tq_26") private Double totQ26; - @Column(name = "totQ27") + @Column(name = "tot_tq_27") private Double totQ27; - @Column(name = "totQ28") + @Column(name = "tot_tq_28") private Double totQ28; - @Column(name = "totQ29") + @Column(name = "tot_tq_29") private Double totQ29; - @Column(name = "totQ30") + @Column(name = "tot_tq_30") private Double totQ30; - @Column(name = "totQ31") + @Column(name = "tot_tq_31") private Double totQ31; - @Column(name = "totQ32") + @Column(name = "tot_tq_32") private Double totQ32; - @Column(name = "totQ33") + @Column(name = "tot_tq_33") private Double totQ33; - @Column(name = "totQ34") + @Column(name = "tot_tq_34") private Double totQ34; - @Column(name = "totQ35") + @Column(name = "tot_tq_35") private Double totQ35; - @Column(name = "totQ36") + @Column(name = "tot_tq_36") private Double totQ36; - @Column(name = "totQ37") + @Column(name = "tot_tq_37") private Double totQ37; - @Column(name = "totQ38") + @Column(name = "tot_tq_38") private Double totQ38; - @Column(name = "totQ39") + @Column(name = "tot_tq_39") private Double totQ39; - @Column(name = "totQ40") + @Column(name = "tot_tq_40") private Double totQ40; - @Column(name = "totQ41") + @Column(name = "tot_tq_41") private Double totQ41; - @Column(name = "totQ42") + @Column(name = "tot_tq_42") private Double totQ42; - @Column(name = "totQ43") + @Column(name = "tot_tq_43") private Double totQ43; - @Column(name = "totQ44") + @Column(name = "tot_tq_44") private Double totQ44; - @Column(name = "totQ45") + @Column(name = "tot_tq_45") private Double totQ45; - @Column(name = "totQ46") + @Column(name = "tot_tq_46") private Double totQ46; - @Column(name = "totQ47") + @Column(name = "tot_tq_47") private Double totQ47; - @Column(name = "totQ49") + @Column(name = "tot_tq_49") private Double totQ48; - @Column(name = "totQ49") + @Column(name = "tot_tq_49") private Double totQ49; - @Column(name = "totQ50") + @Column(name = "tot_tq_50") private Double totQ50; diff --git a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerS.java b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerS.java index ddb0094..feb8162 100644 --- a/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerS.java +++ b/data-processing/data-processing-api/src/main/java/com/njcn/dataProcess/po/influx/DataHarmpowerS.java @@ -208,107 +208,107 @@ public class DataHarmpowerS { private Double s50; //在线监测添加的字段 - @Column(name = "totS") + @Column(name = "tot_s") private Double totS; - @Column(name = "totS1") + @Column(name = "tot_ts_1") private Double totS1; - @Column(name = "totS2") + @Column(name = "tot_ts_2") private Double totS2; - @Column(name = "totS3") + @Column(name = "tot_ts_3") private Double totS3; - @Column(name = "totS4") + @Column(name = "tot_ts_4") private Double totS4; - @Column(name = "totS5") + @Column(name = "tot_ts_5") private Double totS5; - @Column(name = "totS6") + @Column(name = "tot_ts_6") private Double totS6; - @Column(name = "totS7") + @Column(name = "tot_ts_7") private Double totS7; - @Column(name = "totS8") + @Column(name = "tot_ts_8") private Double totS8; - @Column(name = "totS9") + @Column(name = "tot_ts_9") private Double totS9; - @Column(name = "totS10") + @Column(name = "tot_ts_10") private Double totS10; - @Column(name = "totS11") + @Column(name = "tot_ts_11") private Double totS11; - @Column(name = "totS12") + @Column(name = "tot_ts_12") private Double totS12; - @Column(name = "totS13") + @Column(name = "tot_ts_13") private Double totS13; - @Column(name = "totS14") + @Column(name = "tot_ts_14") private Double totS14; - @Column(name = "totS15") + @Column(name = "tot_ts_15") private Double totS15; - @Column(name = "totS16") + @Column(name = "tot_ts_16") private Double totS16; - @Column(name = "totS17") + @Column(name = "tot_ts_17") private Double totS17; - @Column(name = "totS18") + @Column(name = "tot_ts_18") private Double totS18; - @Column(name = "totS19") + @Column(name = "tot_ts_19") private Double totS19; - @Column(name = "totS20") + @Column(name = "tot_ts_20") private Double totS20; - @Column(name = "totS21") + @Column(name = "tot_ts_21") private Double totS21; - @Column(name = "totS22") + @Column(name = "tot_ts_22") private Double totS22; - @Column(name = "totS23") + @Column(name = "tot_ts_23") private Double totS23; - @Column(name = "totS24") + @Column(name = "tot_ts_24") private Double totS24; - @Column(name = "totS25") + @Column(name = "tot_ts_25") private Double totS25; - @Column(name = "totS26") + @Column(name = "tot_ts_26") private Double totS26; - @Column(name = "totS27") + @Column(name = "tot_ts_27") private Double totS27; - @Column(name = "totS28") + @Column(name = "tot_ts_28") private Double totS28; - @Column(name = "totS29") + @Column(name = "tot_ts_29") private Double totS29; - @Column(name = "totS30") + @Column(name = "tot_ts_30") private Double totS30; - @Column(name = "totS31") + @Column(name = "tot_ts_31") private Double totS31; - @Column(name = "totS32") + @Column(name = "tot_ts_32") private Double totS32; - @Column(name = "totS33") + @Column(name = "tot_ts_33") private Double totS33; - @Column(name = "totS34") + @Column(name = "tot_ts_34") private Double totS34; - @Column(name = "totS35") + @Column(name = "tot_ts_35") private Double totS35; - @Column(name = "totS36") + @Column(name = "tot_ts_36") private Double totS36; - @Column(name = "totS37") + @Column(name = "tot_ts_37") private Double totS37; - @Column(name = "totS38") + @Column(name = "tot_ts_38") private Double totS38; - @Column(name = "totS39") + @Column(name = "tot_ts_39") private Double totS39; - @Column(name = "totS40") + @Column(name = "tot_ts_40") private Double totS40; - @Column(name = "totS41") + @Column(name = "tot_ts_41") private Double totS41; - @Column(name = "totS42") + @Column(name = "tot_ts_42") private Double totS42; - @Column(name = "totS43") + @Column(name = "tot_ts_43") private Double totS43; - @Column(name = "totS44") + @Column(name = "tot_ts_44") private Double totS44; - @Column(name = "totS45") + @Column(name = "tot_ts_45") private Double totS45; - @Column(name = "totS46") + @Column(name = "tot_ts_46") private Double totS46; - @Column(name = "totS47") + @Column(name = "tot_ts_47") private Double totS47; - @Column(name = "totS49") + @Column(name = "tot_ts_49") private Double totS48; - @Column(name = "totS49") + @Column(name = "tot_ts_49") private Double totS49; - @Column(name = "totS50") + @Column(name = "tot_ts_50") private Double totS50; diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java index 9b567a4..989f9a8 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerPImpl.java @@ -192,6 +192,7 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl result = new ArrayList<>(); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerP.class); influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.P, InfluxDbSqlConstant.P, HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); + influxQueryWrapper.samePrefixAndSuffix("tot_tp_", "tot_tp_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); influxQueryWrapper.regular(DataHarmpowerP::getLineId, lineList) .select(DataHarmpowerP::getLineId) .select(DataHarmpowerP::getPhasicType) @@ -199,6 +200,9 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl result = new ArrayList<>(); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerQ.class); influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.Q, InfluxDbSqlConstant.Q, HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); + influxQueryWrapper.samePrefixAndSuffix("tot_tq_", "tot_tq_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); influxQueryWrapper.regular(DataHarmpowerQ::getLineId, lineList) .select(DataHarmpowerQ::getLineId) .select(DataHarmpowerQ::getPhasicType) .select(DataHarmpowerQ::getValueType) .select(DataHarmpowerQ::getQ) + .select(DataHarmpowerQ::getTotQ) .select(DataHarmpowerQ::getQualityFlag) .select(DataHarmpowerQ::getAbnormalFlag) .between(DataHarmpowerQ::getTime, startTime, endTime) diff --git a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java index 11df88a..80866ea 100644 --- a/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java +++ b/data-processing/data-processing-boot/src/main/java/com/njcn/dataProcess/service/impl/influxdb/InfluxdbDataHarmpowerSImpl.java @@ -187,11 +187,13 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl result = new ArrayList<>(); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerS.class); influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.S, InfluxDbSqlConstant.S, HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); + influxQueryWrapper.samePrefixAndSuffix("tot_ts_", "tot_ts_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); influxQueryWrapper.regular(DataHarmpowerS::getLineId, lineList) .select(DataHarmpowerS::getLineId) .select(DataHarmpowerS::getPhasicType) .select(DataHarmpowerS::getValueType) .select(DataHarmpowerS::getS) + .select(DataHarmpowerS::getTotS) .select(DataHarmpowerS::getQualityFlag) .select(DataHarmpowerS::getAbnormalFlag) .between(DataHarmpowerS::getTime, startTime, endTime) From c0e686d5407ea1bf16f3d7337473e3f329a7eceb Mon Sep 17 00:00:00 2001 From: cdf <857448963@qq.com> Date: Wed, 15 Jul 2026 13:15:10 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=89=8D=E7=BD=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/njcn/message/message/DeviceRebootMessage.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/message/message-api/src/main/java/com/njcn/message/message/DeviceRebootMessage.java b/message/message-api/src/main/java/com/njcn/message/message/DeviceRebootMessage.java index 4d24027..20fd7a3 100644 --- a/message/message-api/src/main/java/com/njcn/message/message/DeviceRebootMessage.java +++ b/message/message-api/src/main/java/com/njcn/message/message/DeviceRebootMessage.java @@ -31,6 +31,8 @@ public class DeviceRebootMessage { private String ip; //终端型号 private String devType; + //前置类型 + private String comType; //挂载单位 private String org_name; //组织名称 From 73a316d7fb711e98a621bc47ed5b9fe1cfed0221 Mon Sep 17 00:00:00 2001 From: chendaofei <857448963@qq.com> Date: Thu, 16 Jul 2026 09:00:45 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E7=BB=BC=E5=90=88=E8=AF=84=E4=BC=B0?= =?UTF-8?q?=E7=AE=97=E6=B3=95=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java index 476e707..ab3155b 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/DataComAssServiceImpl.java @@ -175,7 +175,7 @@ public class DataComAssServiceImpl implements IDataComAssService { //************************************频率偏差******************************************** lineParam.setColumnName("freq_dev"); lineParam.setGe("0.3"); - lineParam.setGe(null); + lineParam.setLt(null); Integer freqDev1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); lineParam.setGe("0.2");