From 9ea4f65782dc4a3cc52d700950b8d77df7f4b6c9 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Fri, 23 Aug 2024 14:48:46 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=B9=B3=E5=8F=B0=E6=8E=A5=E5=8F=A3=E6=94=B9?= =?UTF-8?q?=E9=80=A0=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/impl/ObtainGenerationServiceImpl.java | 21 ++++++- .../operation/home/impl/RealTargetServiceImpl.java | 64 +++++++++++++++++++--- .../operation/report/impl/ReportServiceImpl.java | 7 ++- .../data/service/impl/HzimsDataServiceImpl.java | 7 ++- 4 files changed, 85 insertions(+), 14 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java index 0259de2..e791794 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java @@ -165,7 +165,12 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { generate.setCreateDept(station.getRefDept()); generate.setCreateUser(station.getCreateUser()); generate.setUpdateUser(station.getUpdateUser()); - Date time = DateUtil.parse(records.get(0).getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(records.get(0).getTs().contains(".0")){ + time = DateUtil.parse(records.get(0).getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(records.get(0).getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } generate.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME)); generate.setDay(time.getDate()); if(StringUtil.isEmpty(records.get(0).getVal())){ @@ -293,7 +298,12 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { generate.setCreateDept(station.getRefDept()); generate.setCreateUser(station.getCreateUser()); generate.setUpdateUser(station.getUpdateUser()); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(record.getTs().contains(".0")){ + time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } generate.setStrDay(DateUtil.format(time,DateUtil.PATTERN_DATETIME)); generate.setDay(time.getDate()); if(StringUtil.isEmpty(record.getVal())){ @@ -364,7 +374,12 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { generate.setCreateDept(station.getRefDept()); generate.setCreateUser(station.getCreateUser()); generate.setUpdateUser(station.getUpdateUser()); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(record.getTs().contains(".0")){ + time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); generate.setMonth(time.getMonth() + 1); if(StringUtil.isEmpty(record.getVal())){ 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 527d67a..81bdc75 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 @@ -633,6 +633,8 @@ public class RealTargetServiceImpl implements RealTargetService { multiAnalyzeCodePO.setSignages(Collections.singletonList(HomePageConstant.FRONT_WATER_LEVEL)); multiAnalyzeCodePOList.add(multiAnalyzeCodePO); R> result = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); + + if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData())){ WaterLevelVo waterLevelVo=new WaterLevelVo(); waterLevelVo.setStationCode(item.getStationId()); @@ -934,7 +936,12 @@ public class RealTargetServiceImpl implements RealTargetService { } return datas.stream().map(data->{ ActivePowerVo active = new ActivePowerVo(); - Date dateTime = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date dateTime; + if(data.getTs().contains(".0")){ + dateTime = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + dateTime = DateUtil.parse(data.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } active.setHour(dateTime.getHours()); if (StringUtil.isBlank(data.getVal())) { active.setActivePower("0"); @@ -961,7 +968,12 @@ public class RealTargetServiceImpl implements RealTargetService { } return records.stream().map(record -> { UsrPowerVo usr = new UsrPowerVo(); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(record.getTs().contains(".0")){ + time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } usr.setDate(DateUtil.format(time,DateUtil.PATTERN_DATE)); usr.setUsrPower(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); return usr; @@ -991,7 +1003,12 @@ public class RealTargetServiceImpl implements RealTargetService { } return records.stream().map(record -> { PowerMonthVo generate = new PowerMonthVo(); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(record.getTs().contains(".0")){ + time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } generate.setStrMonth(DateUtil.format(time, DateUtil.PATTERN_DATE)); if(StringUtil.isEmpty(record.getVal())){ generate.setPower(0f); @@ -1232,7 +1249,11 @@ public class RealTargetServiceImpl implements RealTargetService { } return datas.stream().collect(Collectors.toMap( key-> { - Date dateTime = DateUtil.parse(key.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + if(key.getTs().contains(".0")){ + Date dateTime = DateUtil.parse(key.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + return dateTime.getHours(); + } + Date dateTime = DateUtil.parse(key.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); return dateTime.getHours(); }, value -> { @@ -1404,7 +1425,12 @@ public class RealTargetServiceImpl implements RealTargetService { } datas.addAll(records.stream().map(record -> { PowerMonthVo generate = new PowerMonthVo(); - Date time = DateUtil.parse(record.get("ts"), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(record.get("ts").contains(".0")){ + time = DateUtil.parse(record.get("ts"), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(record.get("ts") + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); String val = record.get(HomePageConstant.HYDROPOWER_GENERATE_POWER); if(StringUtil.isEmpty(val)){ @@ -1480,7 +1506,12 @@ public class RealTargetServiceImpl implements RealTargetService { } return records.stream().map(record -> { ActivePowerVo load = new ActivePowerVo(); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(record.getTs().contains(".0")){ + time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } load.setStrHour(DateUtil.format(time,"yyyy-MM-dd HH")); load.setHour(time.getHours()); if(StringUtil.isNotBlank(record.getVal())){ @@ -1508,7 +1539,12 @@ public class RealTargetServiceImpl implements RealTargetService { } datas.addAll(records.stream().map(record -> { PowerMonthVo generate = new PowerMonthVo(); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(record.getTs().contains(".0")){ + time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } generate.setStrMonth(DateUtil.format(time,DateUtil.PATTERN_DATE)); if(StringUtil.isEmpty(record.getVal())){ generate.setPower(0f); @@ -1751,7 +1787,12 @@ public class RealTargetServiceImpl implements RealTargetService { } return records.stream().map(record -> { PhotovoltaicPowerVo load = new PhotovoltaicPowerVo(); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(records.get(0).getTs().contains(".0")){ + time = DateUtil.parse(records.get(0).getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(records.get(0).getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } load.setHour(time.getHours()); load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); return load; @@ -1778,7 +1819,12 @@ public class RealTargetServiceImpl implements RealTargetService { } return records.stream().map(record -> { GenerationPowerVo generate = new GenerationPowerVo(); - Date time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date time; + if(record.getTs().contains(".0")){ + time = DateUtil.parse(record.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + time = DateUtil.parse(record.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } generate.setDate(DateUtil.format(time, DateUtil.PATTERN_DATE)); generate.setGenerate(Float.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); return generate; 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 843473d..a6bca20 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 @@ -993,7 +993,12 @@ public class ReportServiceImpl implements ReportService { } analyseDatas.addAll(data.getList().stream().peek(item->{ item.setSignage(data.getSignage()); - Date date = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date date; + if(item.getTs().contains(".0")){ + date = DateUtil.parse(item.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + date = DateUtil.parse(item.getTs() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } day.setTime(date); item.setTs(String.valueOf(day.get(Calendar.DAY_OF_MONTH))); }).collect(Collectors.toList())); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java index 59b40ab..86f9972 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/data/service/impl/HzimsDataServiceImpl.java @@ -456,7 +456,12 @@ public class HzimsDataServiceImpl implements HzimsDataService { } datas.forEach(data->{ ConverElectricityVo electricity = new ConverElectricityVo(); - Date date = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + Date date; + if(data.getTs().contains(".0")){ + date = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + date = DateUtil.parse(data.getTs(), "yyyy-MM-dd HH:mm:ss"); + } electricity.setTime(DateUtil.format(date,DateUtil.PATTERN_DATE)); if(StringUtil.isEmpty(data.getVal())){ electricity.setElectricity(0.0);