From a657d11cb3d3f70a536da25ef54acfa46602f62c Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期六, 07 六月 2025 15:35:30 +0800 Subject: [PATCH] 系统概览获取半小时核容设备信息添加负载电流load_curr --- src/main/java/com/whyc/service/PwrdevHistorydataIdService.java | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/whyc/service/PwrdevHistorydataIdService.java b/src/main/java/com/whyc/service/PwrdevHistorydataIdService.java index 26f1e48..f5646de 100644 --- a/src/main/java/com/whyc/service/PwrdevHistorydataIdService.java +++ b/src/main/java/com/whyc/service/PwrdevHistorydataIdService.java @@ -12,6 +12,8 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; @@ -28,24 +30,39 @@ //绯荤粺姒傝鑾峰彇鍗婂皬鏃朵氦娴佽緭鍏ョ粺璁� public Response getHalfHourPwrHisAcinData(Integer powerId,Integer granularity) { String dateTime = ActionUtil.sdfwithOutday.format(new Date()); + //鑾峰彇鍓嶅崐涓皬鏃舵暟鎹� + LocalDateTime now = LocalDateTime.now(); + // 璁$畻鍗婂皬鏃跺墠鐨勬椂闂寸偣 + LocalDateTime halfHourAgo = now.minusMinutes(30); + // 鏍煎紡鍖栬緭鍑� + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String halfHourAgoTime=halfHourAgo.format(formatter); String tableName ="db_data_history.tb_pwrdev_historydata_"+powerId+"_"+dateTime; String existTableName = commonMapper.existTable("db_data_history", "tb_pwrdev_historydata_"+powerId+"_"+dateTime); if(existTableName == null){ return new Response().set(1,false,"褰撳墠鐢垫睜缁勪笉瀛樺湪鍓嶉潰灏忔椂鏁版嵁"); } - List<PwrHisRealAcInDto> datalist=subTablePageInfoService.getHalfHourPwrHisAcinData(tableName,granularity); + List<PwrHisRealAcInDto> datalist=subTablePageInfoService.getHalfHourPwrHisAcinData(tableName,granularity,halfHourAgoTime); return new Response().setII(1,datalist.size()>0,datalist,"鑾峰彇鍗婂皬鏃跺唴浜ゆ祦杈撳叆缁熻"); } //绯荤粺姒傝鑾峰彇鍗婂皬鏃剁洿娴佽緭鍑虹粺璁� public Response getHalfHourPwrHisDcoutData(Integer powerId,Integer granularity) { String dateTime = ActionUtil.sdfwithOutday.format(new Date()); + //鑾峰彇鍓嶅崐涓皬鏃舵暟鎹� + LocalDateTime now = LocalDateTime.now(); + // 璁$畻鍗婂皬鏃跺墠鐨勬椂闂寸偣 + LocalDateTime halfHourAgo = now.minusMinutes(30); + // 鏍煎紡鍖栬緭鍑� + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + String halfHourAgoTime=halfHourAgo.format(formatter); + String tableName ="db_data_history.tb_pwrdev_historydata_"+powerId+"_"+dateTime; String existTableName = commonMapper.existTable("db_data_history", "tb_pwrdev_historydata_"+powerId+"_"+dateTime); if(existTableName == null){ return new Response().set(1,false,"褰撳墠鐢垫簮涓嶅瓨鍦ㄥ墠闈㈠皬鏃舵暟鎹�"); } - List<PwrHisRealDcoutInDto> datalist=subTablePageInfoService.getHalfHourPwrHisDcoutData(tableName,granularity); + List<PwrHisRealDcoutInDto> datalist=subTablePageInfoService.getHalfHourPwrHisDcoutData(tableName,granularity,halfHourAgoTime); Long modelCfg=0l; PowerInf pinf=powerInfService.getPowerInfById(powerId); if(pinf!=null){ -- Gitblit v1.9.1