From a4cb2ce790a7e118f57b9d5a247b0a1bc8fd91da Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 26 Aug 2024 19:25:21 +0800 Subject: [PATCH] =?UTF-8?q?#=E7=AB=99=E7=82=B9=E9=A6=96=E9=A1=B5=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduled/RealTargetScheduledTask.java | 14 ++++---- .../operation/home/impl/RealTargetServiceImpl.java | 42 ++++++++++++++-------- .../service/impl/HydroelectricServiceImpl.java | 12 +++++-- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java index 9591c87..9986873 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java @@ -46,9 +46,10 @@ public class RealTargetScheduledTask { /** * 水电站-机组实时加载 */ - @XxlJob(LOAD_HYDROPOWER_UNIT_REAL) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadHydropowerReal(String param) { + //@XxlJob(LOAD_HYDROPOWER_UNIT_REAL) + @Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadHydropowerReal() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } @@ -59,9 +60,10 @@ public class RealTargetScheduledTask { /** * 水电站-机组指标加载 */ - @XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) - //@Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadHydropowerTarget(String param) { + //@XxlJob(LOAD_HYDROPOWER_UNIT_TARGET) + @Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadHydropowerTarget() { + String param = ""; if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); } diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java index 53e1ecc..af7b0a1 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java @@ -1485,24 +1485,36 @@ public class RealTargetServiceImpl implements RealTargetService { private List getLoadsByDay(EminfoAndEmParamVo device) { Calendar calendar = Calendar.getInstance(); // 结束日期 - String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); + Date end = calendar.getTime(); calendar.add(Calendar.DAY_OF_MONTH,-1); // 开始日期 - String start = DateUtil.format(calendar.getTime(),"yyyy-MM-dd HH") + ":00:00"; - List records = dataService.periodTargetData(start, end, 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); - if (CollectionUtil.isEmpty(records)) { - return new ArrayList<>(); - } - return records.stream().map(record -> { - ActivePowerVo load = new ActivePowerVo(); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss"); - load.setStrHour(DateUtil.format(time,"yyyy-MM-dd HH")); - load.setHour(time.getHours()); - if(StringUtil.isNotBlank(record.getVal())){ - load.setActivePower(record.getVal()); + Date start = calendar.getTime(); + List records = dataService.periodTargetData(DateUtil.format(start,"yyyy-MM-dd HH") + ":00:00", DateUtil.format(end,DateUtil.PATTERN_DATETIME), 3, 2, device.getEmCode(), HomePageConstant.PV_LOAD); + List activePowers = new ArrayList<>(); + while (start.compareTo(end) < 0){ + String time = DateUtil.format(start,"yyyy-MM-dd HH"); + ActivePowerVo active = new ActivePowerVo(); + active.setStrHour(time); + active.setHour(start.getHours()); + if(CollectionUtil.isNotEmpty(records)){ + Optional analyseData = records.stream().filter(o->o.getTs().contains(time)).findFirst(); + if(analyseData.isPresent()){ + if(StringUtil.isNotBlank(analyseData.get().getVal())){ + active.setActivePower(analyseData.get().getVal()); + }else{ + active.setActivePower("0.0"); + } + }else{ + active.setActivePower("0.0"); + } + }else{ + active.setActivePower("0.0"); } - return load; - }).sorted(Comparator.comparing(ActivePowerVo::getStrHour)).collect(Collectors.toList()); + activePowers.add(active); + calendar.add(Calendar.HOUR_OF_DAY,1); + start = calendar.getTime(); + } + return activePowers.stream().sorted(Comparator.comparing(ActivePowerVo::getStrHour)).collect(Collectors.toList()); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java index 5450ff6..4de937d 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/homePage/service/impl/HydroelectricServiceImpl.java @@ -105,9 +105,10 @@ public class HydroelectricServiceImpl implements HydroelectricService { result.setWeather(week.getDaily()); } } + List statonDevices = devices.stream().filter(device-> station.getRefDept().equals(device.getCreateDept())).collect(Collectors.toList()); // 设备 - if(CollectionUtil.isNotEmpty(devices)){ - result.setDevices(devices.stream().filter(device-> station.getRefDept().equals(device.getCreateDept())).map(iter->{ + if(CollectionUtil.isNotEmpty(statonDevices)){ + result.setDevices(statonDevices.stream().map(iter->{ HydroelectricDeviceVo device = new HydroelectricDeviceVo(); device.setDeivceCode(iter.getEmCode()); device.setDeivceName(iter.getName()); @@ -124,6 +125,13 @@ public class HydroelectricServiceImpl implements HydroelectricService { }else{ device.setCapacityRate(0.0); } + }else{ + device.setState(false); + device.setInstalledCapacity(0.0); + device.setActivePower(0.0); + device.setReactivePower(0.0); + device.setGuideOpen(0.0); + device.setCapacityRate(0.0); } // 指标数据 Optional target = targets.stream().filter(o-> iter.getEmCode().equals(o.getDeviceCode())).findFirst();