From 1aa0c912a34cc294304ef386efb342e7dd6ba6db Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 24 Jul 2024 16:13:04 +0800 Subject: [PATCH] =?UTF-8?q?#sdk=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7fix.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/scheduled/ScheduledApplication.java | 4 +- .../scheduled/RealTargetScheduledTask.java | 7 +- .../operation/home/impl/RealTargetServiceImpl.java | 81 ++++++++++------------ pom.xml | 15 ++-- 4 files changed, 50 insertions(+), 57 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java index 676adbb..6b524df 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java @@ -21,11 +21,11 @@ import javax.annotation.Resource; @Resource public class ScheduledApplication extends SpringBootServletInitializer { public static void main(String[] args) { - BladeApplication.run("hzims-scheduled-ysj", ScheduledApplication.class, args); + BladeApplication.run("hzims-scheduled", ScheduledApplication.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { - return BladeApplication.createSpringApplicationBuilder(builder, "hzims-scheduled-ysj", ScheduledApplication.class); + return BladeApplication.createSpringApplicationBuilder(builder, "hzims-scheduled", ScheduledApplication.class); } } 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 a2b873f..9591c87 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 @@ -110,10 +110,9 @@ public class RealTargetScheduledTask { /** * 水利-站点水位数据 */ - //@XxlJob(LOAD_WATER_LEVEL) - @Scheduled(cron = "0/40 * * * * ? ") - public ReturnT loadWaterLevel() { - String param = ""; + @XxlJob(LOAD_WATER_LEVEL) + //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT loadWaterLevel(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 522184b..0392d17 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 @@ -1,5 +1,6 @@ package com.hnac.hzims.scheduled.service.operation.home.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -39,6 +40,7 @@ import com.hnac.hzinfo.sdk.core.response.Result; import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; import com.hnac.hzinfo.sdk.v5.device.dto.ReductionDataDTO; import com.hnac.hzinfo.sdk.v5.device.vo.ReductionDataVO; +import com.xxl.job.core.log.XxlJobLogger; import io.undertow.util.CopyOnWriteMap; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -546,59 +548,52 @@ public class RealTargetServiceImpl implements RealTargetService { CountDownLatch countDownLatch = new CountDownLatch(modelList.size()); for(HzimsAnalyzeModelStationEntity item : modelList){ pool.execute(() -> { - this.queryWaterLeve(list,item); - countDownLatch.countDown(); + try{ + 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); + if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData())){ + WaterLevelVo waterLevelVo=new WaterLevelVo(); + waterLevelVo.setStationCode(item.getStationId()); + // 前水位 + double frontWaterLevel=this.getWaterLevel(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); + waterLevelVo.setFrontWaterLevel(frontWaterLevel); + // 后水位 + double rearWaterLevel=this.getWaterLevel(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); + waterLevelVo.setRearWaterLevel(rearWaterLevel); + // 下泄流量 + double dischargeFlow=this.getWaterLevel(item.getInstanceCode(),HomePageConstant.DISCHARGE_FLOW); + waterLevelVo.setDischargeFlow(dischargeFlow); + // 前水位当日曲线 + Map frontCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); + waterLevelVo.setFrontCurveMap(frontCurveMap); + // 后水位当日曲线 + Map rearCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); + waterLevelVo.setRearCurveMap(rearCurveMap); + list.add(waterLevelVo); + } + countDownLatch.countDown(); + XxlJobLogger.log("load_water_level : 子线程执行完成 {}", item.getInstanceCode()); + } catch (Exception exception) { + countDownLatch.countDown(); + XxlJobLogger.log("load_water_level_error : 子线程执行失败 {}", exception.getMessage()); + } }); - } + } try { - log.error("load_water_level :等待线程执行"); + XxlJobLogger.log("load_water_level :等待线程执行"); countDownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); Thread.currentThread().interrupt(); } - log.error("load_water_level :线程执行结束"); + XxlJobLogger.log("load_water_level :线程执行结束"); redisTemplate.opsForValue().set(loadwater_level_key,list); } - /** - * 水位数据查询 - * @param list - * @param item - */ - private void queryWaterLeve(List list,HzimsAnalyzeModelStationEntity item) { - try{ - 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); - if(result.isSuccess() && CollectionUtil.isNotEmpty(result.getData())){ - WaterLevelVo waterLevelVo=new WaterLevelVo(); - waterLevelVo.setStationCode(item.getStationId()); - // 前水位 - double frontWaterLevel=this.getWaterLevel(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); - waterLevelVo.setFrontWaterLevel(frontWaterLevel); - // 后水位 - double rearWaterLevel=this.getWaterLevel(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); - waterLevelVo.setRearWaterLevel(rearWaterLevel); - // 下泄流量 - double dischargeFlow=this.getWaterLevel(item.getInstanceCode(),HomePageConstant.DISCHARGE_FLOW); - waterLevelVo.setDischargeFlow(dischargeFlow); - // 前水位当日曲线 - Map frontCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.FRONT_WATER_LEVEL); - waterLevelVo.setFrontCurveMap(frontCurveMap); - // 后水位当日曲线 - Map rearCurveMap=this.getWaterLevelMap(item.getInstanceCode(),HomePageConstant.REAR_WATER_LEVEL); - waterLevelVo.setRearCurveMap(rearCurveMap); - list.add(waterLevelVo); - } - log.error("load_water_level : 小节线程执行完成 {}", item.getInstanceCode()); - } catch (Exception exception) { - log.error("load_water_level_error : 线程执行失败 {}", exception.getMessage()); - } - } /** * 光伏站-逆变器实时加载 diff --git a/pom.xml b/pom.xml index fee8f9d..90876d9 100644 --- a/pom.xml +++ b/pom.xml @@ -75,8 +75,7 @@ com.hnac.hzinfo.data hzinfo-data-sdk - - 5.1.1.RELEASE.fix.5 + 5.1.1.RELEASE.fix.8 com.xuxueli @@ -89,6 +88,12 @@ 3.3.2 + + org.apache.httpcomponents + httpclient + 4.5.2 + + com.hnac.hzims @@ -163,12 +168,6 @@ - org.apache.httpcomponents - httpclient - 4.5.2 - - - com.google.zxing core 3.1.0