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 ce9176c..adec388 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 @@ -9,6 +9,7 @@ import com.njcn.algorithm.pojo.bo.BaseParam; import com.njcn.algorithm.pojo.bo.CalculatedParam; import com.njcn.algorithm.pojo.bo.HourParam; import com.njcn.algorithm.pojo.enums.PrepareResponseEnum; +import com.njcn.algorithm.utils.MemorySizeUtil; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.exception.BusinessException; @@ -91,20 +92,7 @@ public class ExecutionCenter extends BaseController { * @date 2023/11/7 14:44 */ private void dealResponse(CalculatedParam calculatedParam, LiteflowResponse liteflowResponse, String methodDescribe) { - Runtime runtime = Runtime.getRuntime(); - // 获取 JVM 最大可用内存(以字节为单位) - long maxMemory = runtime.maxMemory(); - // 获取 JVM 当前已分配的内存(以字节为单位) - long totalMemory = runtime.totalMemory(); - // 获取 JVM 当前空闲内存(以字节为单位) - long freeMemory = runtime.freeMemory(); - // 计算已使用的内存 - long usedMemory = totalMemory - freeMemory; - - System.out.println("最大可用内存: " + maxMemory / (1024 * 1024) + " MB"); - System.out.println("当前已分配的内存: " + totalMemory / (1024 * 1024) + " MB"); - System.out.println("当前空闲内存: " + freeMemory / (1024 * 1024) + " MB"); - System.out.println("已使用的内存: " + usedMemory / (1024 * 1024) + " MB"); + MemorySizeUtil.getNowMemory(); if (liteflowResponse.isSuccess()) { // 获取执行步骤列表 long allTime = 0; 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 6c56c97..06b1a04 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 @@ -71,21 +71,7 @@ public class DataCleanServiceImpl implements IDataCleanService { @Override public void dataVCleanHandler(CalculatedParam calculatedParam) { - Runtime runtime = Runtime.getRuntime(); - // 获取 JVM 最大可用内存(以字节为单位) - long maxMemory = runtime.maxMemory(); - // 获取 JVM 当前已分配的内存(以字节为单位) - long totalMemory = runtime.totalMemory(); - // 获取 JVM 当前空闲内存(以字节为单位) - long freeMemory = runtime.freeMemory(); - // 计算已使用的内存 - long usedMemory = totalMemory - freeMemory; - - System.out.println("最大可用内存: " + maxMemory / (1024 * 1024) + " MB"); - System.out.println("当前已分配的内存: " + totalMemory / (1024 * 1024) + " MB"); - System.out.println("当前空闲内存: " + freeMemory / (1024 * 1024) + " MB"); - System.out.println("已使用的内存: " + usedMemory / (1024 * 1024) + " MB"); - System.out.println("第一次分析结束-----------------------------------------"); + MemorySizeUtil.getNowMemory(); logger.info("{},dataV表异常数据算法执行=====》", LocalDateTime.now()); 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 b15d571..d22fdf0 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 @@ -9,6 +9,7 @@ import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSON; import com.njcn.algorithm.pojo.bo.CalculatedParam; import com.njcn.algorithm.service.line.IDataCrossingService; +import com.njcn.algorithm.utils.MemorySizeUtil; import com.njcn.common.utils.PubUtils; import com.njcn.dataProcess.api.*; import com.njcn.dataProcess.constant.PhaseType; @@ -80,6 +81,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService { @Override public void limitRateHandler(CalculatedParam calculatedParam) { + MemorySizeUtil.getNowMemory(); logger.info("{},limitRate表转r_stat_limit_rate_d算法开始=====》", LocalDateTime.now()); List result = new ArrayList<>(); //远程接口获取分钟数据 @@ -95,6 +97,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService { //以100个监测点分片处理 List> pendingIds = ListUtils.partition(lineIds, NUM); ArrayList phase = ListUtil.toList(PhaseType.PHASE_A, PhaseType.PHASE_B, PhaseType.PHASE_C); + MemorySizeUtil.getNowMemory(); pendingIds.forEach(list -> { lineParam.setLineId(list); //获取电压数据 @@ -107,7 +110,6 @@ public class IDataCrossingServiceImpl implements IDataCrossingService { List dataVInHarmList = dataInharmVFeignClient.getRawData(lineParam).getData(); //电流数据 List dataIList = dataIFeignClient.getRawData(lineParam).getData(); - /** * 功能描述:获取influxDB -> data_v -> * 总计算次数(用data_v中phasic_type=A,value_type=avg,quality_flag=0来参与统计) @@ -122,7 +124,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService { * 闪变总计算次数(用data_plt中phasic_type=A,quality_flag=0来参与统计) */ Map> flickerAllTime = dataFlickerAllTime.stream() - .filter(x -> PhaseType.PHASE_A.equals(x.getValueType())) + .filter(x -> PhaseType.PHASE_A.equals(x.getPhasicType())) .collect(Collectors.groupingBy(DataPltDto::getLineId)); /** @@ -218,7 +220,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService { } } }); - + MemorySizeUtil.getNowMemory(); if (CollUtil.isNotEmpty(result)) { //存储数据 List dataLimitRate = result.stream().map(DataLimitDetailDto::getDataLimitRate).filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList()); 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 5a9e733..011d711 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 @@ -158,9 +158,6 @@ public class PollutionServiceImpl implements IPollutionService { if (ObjectUtil.isNotNull(dto.getUnitId())) { lineParam.setLineId(Arrays.asList(dto.getUnitId())); List data = dataPollutionFeignClient.getRawDataOrgD(lineParam).getData(); - if (CollUtil.isNotEmpty(data)) { - System.out.println(data); - } Map> pollutionMap = data.stream().collect(Collectors.groupingBy(DataPollutionOrgD::getPollutionType)); pollutionMap.forEach((key, value) -> { DataPollutionOrgM orgD = new DataPollutionOrgM(); diff --git a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/utils/MemorySizeUtil.java b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/utils/MemorySizeUtil.java index e6b98e0..2a6173b 100644 --- a/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/utils/MemorySizeUtil.java +++ b/algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/utils/MemorySizeUtil.java @@ -4,6 +4,7 @@ import org.apache.commons.lang.SerializationUtils; import org.springframework.stereotype.Component; import java.lang.instrument.Instrumentation; +import java.time.LocalDateTime; import java.util.List; /** @@ -19,4 +20,22 @@ public class MemorySizeUtil { return (double)serialized.length/1024/1024; } + + public static void getNowMemory(){ + Runtime runtime = Runtime.getRuntime(); + // 获取 JVM 最大可用内存(以字节为单位) + long maxMemory = runtime.maxMemory(); + // 获取 JVM 当前已分配的内存(以字节为单位) + long totalMemory = runtime.totalMemory(); + // 获取 JVM 当前空闲内存(以字节为单位) + long freeMemory = runtime.freeMemory(); + // 计算已使用的内存 + long usedMemory = totalMemory - freeMemory; + System.out.println("--------------------------华丽的分隔符--------------------------------------------------------------"+ LocalDateTime.now()); + System.out.println("最大可用内存: " + maxMemory / (1024 * 1024) + " MB"); + System.out.println("当前已分配的内存: " + totalMemory / (1024 * 1024) + " MB"); + System.out.println("当前空闲内存: " + freeMemory / (1024 * 1024) + " MB"); + System.out.println("已使用的内存: " + usedMemory / (1024 * 1024) + " MB"); + } + }