From e0a898c3d55e86428421aaad9b8bf811daddddbe Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 28 May 2024 15:46:26 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=B0=B4=E7=94=B5=E7=AB=99=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E6=9C=88=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operation/report/impl/ReportServiceImpl.java | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java index e071cd8..843473d 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/report/impl/ReportServiceImpl.java @@ -620,6 +620,9 @@ public class ReportServiceImpl implements ReportService { if(CollectionUtil.isEmpty(stations)){ return; } + // 删除上个月手动生成月报记录 + this.deleteGenerateReport(stations); + // 计划发电量 List plans = planService.planGeneration(stations.stream().map(StationEntity::getCode).collect(Collectors.toList()), null ,DateUtil.format(new Date(),"yyyy")); // 查询站点设备 @@ -633,7 +636,7 @@ public class ReportServiceImpl implements ReportService { run.setStationCode(station.getCode()); run.setStationName(station.getName()); Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); + calendar.setTime(new Date()); calendar.add(Calendar.DAY_OF_MONTH,-1); run.setMonth(DateUtil.format(calendar.getTime(),"yyyy-MM")); List stationDevices = devices.stream().filter(device->device.getDepartment().equals(station.getRefDept())).collect(Collectors.toList()); @@ -654,6 +657,24 @@ public class ReportServiceImpl implements ReportService { } /** + * 删除上月手动生成月报记录 + * @param stations + */ + private void deleteGenerateReport(List stations) { + Calendar calendar = Calendar.getInstance(); + calendar.setTime(new Date()); + calendar.add(Calendar.MONTH,-1); + List runs = runMonService.list(Wrappers.lambdaQuery() + .eq(RunMonthEntity::getMonth,DateUtil.format(calendar.getTime(),"yyyy-MM")) + .in(RunMonthEntity::getStationCode,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) + ); + if(CollectionUtil.isEmpty(runs)){ + return; + } + runMonService.deleteLogic(runs.stream().map(RunMonthEntity::getId).collect(Collectors.toList())); + } + + /** * 运行数据 * @param devices * @return @@ -699,7 +720,7 @@ public class ReportServiceImpl implements ReportService { */ private Double generate(int type,String deviceCode,double ride) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); + calendar.setTime(new Date()); String end = null,start = null; int cycleType = 5; switch (type){ @@ -773,7 +794,7 @@ public class ReportServiceImpl implements ReportService { // 确定查询时间范围: 年、月 Date startDate,endDate; Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); + calendar.setTime(new Date()); endDate = calendar.getTime(); calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); @@ -846,7 +867,7 @@ public class ReportServiceImpl implements ReportService { */ private String alarmData(String code) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); + calendar.setTime(new Date()); calendar.add(Calendar.DAY_OF_MONTH,-1); String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); calendar.add(Calendar.MONTH,-1); @@ -952,8 +973,7 @@ public class ReportServiceImpl implements ReportService { */ private List curve(List attributes, String deviceCode) { Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateUtil.parse("2024-05-01 00:00:00",DateUtil.PATTERN_DATETIME)); - //calendar.setTime(DateUtil.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59",DateUtil.PATTERN_DATETIME)); + calendar.setTime(DateUtil.parse(DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 23:59:59",DateUtil.PATTERN_DATETIME)); calendar.add(Calendar.DAY_OF_MONTH,-1); String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATETIME); calendar.add(Calendar.MONTH,-1);