From 8a4dd04d410689444775ba203ec350c3da7b5c61 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 3 Sep 2024 21:26:46 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=B0=B4=E4=BD=8D=E6=95=B0=E6=8D=AE&=E6=B0=B4?= =?UTF-8?q?=E7=94=B5=E7=AB=99=E7=94=9F=E4=BA=A7=E8=BF=90=E8=A1=8C=E6=9C=88?= =?UTF-8?q?=E6=8A=A5=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operation/home/impl/RealTargetServiceImpl.java | 84 +++++++++++++++++----- .../impl/EcologyFlowStationServiceImpl.java | 7 +- .../main/service/impl/HydropowerServiceImpl.java | 1 + .../main/service/impl/PhotovoltaicServiceImpl.java | 8 ++- .../report/service/impl/RunMonthServiceImpl.java | 7 +- 5 files changed, 88 insertions(+), 19 deletions(-) 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 640ea90..98aaa2b 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 @@ -41,6 +41,8 @@ import com.hnac.hzinfo.sdk.analyse.po.MultiAnalyzeCodePO; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +import com.xxl.job.core.log.XxlJobLogger; +import io.undertow.util.CopyOnWriteMap; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.MapUtils; @@ -642,14 +644,16 @@ public class RealTargetServiceImpl implements RealTargetService { List list = new CopyOnWriteArrayList<>(); CountDownLatch countDownLatch = new CountDownLatch(modelList.size()); for(HzimsAnalyzeModelStationEntity item : modelList){ - pool.submit(() -> { + pool.execute(() -> { try{ - List multiAnalyzeCodePOList=new ArrayList<>(); - MultiAnalyzeCodePO multiAnalyzeCodePO=new MultiAnalyzeCodePO(); + List multiAnalyzeCodePOList = new ArrayList<>(); + MultiAnalyzeCodePO multiAnalyzeCodePO = new MultiAnalyzeCodePO(); multiAnalyzeCodePO.setDeviceCode(item.getInstanceCode()); multiAnalyzeCodePO.setSignages(Collections.singletonList(HomePageConstant.FRONT_WATER_LEVEL)); multiAnalyzeCodePOList.add(multiAnalyzeCodePO); - R>result=analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); + R> result = analyseDataSearchClient.getAnalyzeCodeBySignages(multiAnalyzeCodePOList); + + if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData())){ WaterLevelVo waterLevelVo=new WaterLevelVo(); waterLevelVo.setStationCode(item.getStationId()); @@ -671,21 +675,25 @@ public class RealTargetServiceImpl implements RealTargetService { list.add(waterLevelVo); } countDownLatch.countDown(); - }catch (Exception exception){ - log.error("load_water_level_error : {}",exception.getMessage()); + XxlJobLogger.log("load_water_level : 子线程执行完成 {}", item.getInstanceCode()); + } catch (Exception exception) { countDownLatch.countDown(); + XxlJobLogger.log("load_water_level_error : 子线程执行失败 {}", exception.getMessage()); } }); - } + } try { + XxlJobLogger.log("load_water_level :等待线程执行"); countDownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); Thread.currentThread().interrupt(); } + XxlJobLogger.log("load_water_level :线程执行结束"); redisTemplate.opsForValue().set(loadwater_level_key,list); } + /** * 光伏站-逆变器实时加载 * @@ -947,7 +955,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"); @@ -974,7 +987,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; @@ -1004,7 +1022,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); @@ -1217,7 +1240,12 @@ public class RealTargetServiceImpl implements RealTargetService { if(StringUtil.isEmpty(time) || "-".equals(time)){ return 0.0; } - Date date = DateUtil.parse(time, "yyyy-MM-dd HH:mm:ss.sss"); + Date date; + if(time.contains(".000")){ + date = DateUtil.parse(time, "yyyy-MM-dd HH:mm:ss.sss"); + }else{ + date = DateUtil.parse(time, DateUtil.PATTERN_DATETIME); + } if(System.currentTimeMillis() - date.getTime() > 30 * 60 * 1000L){ return 0.0; } @@ -1245,7 +1273,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 -> { @@ -1417,7 +1449,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)){ @@ -1535,7 +1572,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); @@ -1782,7 +1824,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(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.setHour(time.getHours()); load.setActivePower(Optional.ofNullable(record.getVal()).orElse("0")); return load; @@ -1809,7 +1856,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/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java index 52f2c7f..024c854 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/ecology/service/impl/EcologyFlowStationServiceImpl.java @@ -310,7 +310,12 @@ public class EcologyFlowStationServiceImpl extends ServiceImpl { WaterVo water = new WaterVo(); - 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"); + } water.setTime(DateUtil.format(time,DateUtil.PATTERN_DATE)); water.setWater(Double.valueOf(Optional.ofNullable(record.getVal()).orElse("0"))); if(Math.abs(water.getWater()) == 0){ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index 9815c00..dd93e24 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -569,6 +569,7 @@ public class HydropowerServiceImpl implements HydropowerService { WaterLevelVo level = validList.get(0); // 前池水位、当日水位曲线 response.setFrontWaterLevel(level.getFrontWaterLevel()); + response.setFrontCurveMap(level.getFrontCurveMap()); } /** diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java index 7c3d32b..a554ad8 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/PhotovoltaicServiceImpl.java @@ -780,7 +780,13 @@ public class PhotovoltaicServiceImpl implements PhotovoltaicService { } return list.stream().collect(Collectors.groupingBy(AnalyseDataTaosVO::getTs)).entrySet().stream().map(entry ->{ PhotovoltaicLoadGenerateVo target = new PhotovoltaicLoadGenerateVo(); - LocalDateTime time = LocalDateTime.parse(DateUtil.format(DateUtil.parse(entry.getKey(), "yyyy-MM-dd HH:mm:ss.s"),DateUtil.PATTERN_DATETIME), DateUtil.DATETIME_FORMATTER); + Date date; + if(entry.getKey().contains(".0")){ + date = DateUtil.parse(entry.getKey(), "yyyy-MM-dd HH:mm:ss.s"); + }else{ + date = DateUtil.parse(entry.getKey() + ".0", "yyyy-MM-dd HH:mm:ss.s"); + } + LocalDateTime time = LocalDateTime.parse(DateUtil.format(date,DateUtil.PATTERN_DATETIME), DateUtil.DATETIME_FORMATTER); target.setPeriod(String.valueOf(time.getHour())); target.setValue((float) entry.getValue().stream().filter(val -> !StringUtil.isEmpty(val.getVal())).mapToDouble(o-> Double.parseDouble(String.valueOf(o.getVal()))).sum()); return target; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java index f2a3c89..8c45a95 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java @@ -721,7 +721,12 @@ public class RunMonthServiceImpl extends ServiceImpl{ 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()));