From a3771fc40fc1c36307cf84cdc6a0179bd22bf6ef Mon Sep 17 00:00:00 2001 From: liwen Date: Mon, 22 Jul 2024 15:01:53 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=BD=A6=E8=BE=86?= =?UTF-8?q?=E9=87=8C=E7=A8=8B=E7=BB=9F=E8=AE=A1=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=88=E7=BC=BA=E5=B0=91=E6=8E=88=E6=9D=83?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml index 61bea9f..82c6fae 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/CarMapper.xml @@ -4,7 +4,7 @@ SELECT - t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles + t1.unit, t1.car_brand, t1.plate_number, DATE_FORMAT(t2.end_time, '%m') as dateTime, sum(t2.miles) as miles, + t1.create_user, t1.create_dept FROM hzims_car t1 LEFT JOIN hzims_car_used_record t2 ON t1.id = t2.car_id From c74dea48bc0852ff36c23618558463ad89038f84 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 23 Jul 2024 16:43:48 +0800 Subject: [PATCH 2/6] =?UTF-8?q?#=E6=96=B0=E7=89=88=E8=BF=913=E5=B9=B4?= =?UTF-8?q?=E5=8F=91=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduled/GenerationScheduledTask.java | 14 ++++++ .../operation/home/ObtainGenerationService.java | 4 ++ .../home/impl/ObtainGenerationServiceImpl.java | 56 ++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java index bd21b68..b574b22 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/GenerationScheduledTask.java @@ -69,4 +69,18 @@ public class GenerationScheduledTask { return new ReturnT<>("SUCCESS"); } + /** + * 新版-近3年发电量 + * @param param + * @return + */ + @XxlJob(LOAD_THREE_YEAR_POWER_GENERATION) + public ReturnT loadThreeYearPowerGeneration(String param) { + if (Func.isBlank(param)) { + param = DateUtil.format(new Date(), "yyyy-MM"); + } + service.loadThreeYearPowerGeneration(param,Arrays.asList(HomePageConstant.HYDROPOWER,HomePageConstant.PHOTOVOLTAIC),2,3); + return new ReturnT<>("SUCCESS"); + } + } \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/ObtainGenerationService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/ObtainGenerationService.java index 61c6fc7..50210c2 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/ObtainGenerationService.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/ObtainGenerationService.java @@ -1,5 +1,7 @@ package com.hnac.hzims.scheduled.service.operation.home; +import java.util.List; + /** * @author ysj */ @@ -10,4 +12,6 @@ public interface ObtainGenerationService { void thirtyDayPowerGeneration(String param); void thisDayPowerGeneration(String param); + + void loadThreeYearPowerGeneration(String param, List types, Integer serveType,int year); } 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 632c2f2..a6ff70d 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 @@ -2,6 +2,7 @@ package com.hnac.hzims.scheduled.service.operation.home.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.hnac.hzims.equipment.entity.ThirtyGenerationEntity; @@ -18,6 +19,7 @@ import com.hnac.hzims.scheduled.service.operation.home.ObtainGenerationService; import com.hnac.hzims.scheduled.service.operation.plate.DataService; import com.hnac.hzims.scheduled.service.operation.station.StationService; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; +import io.undertow.util.CopyOnWriteMap; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.CollectionUtil; @@ -59,6 +61,8 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { @Value("${hzims.equipment.emInfo.emInfoList}") public String device_cache_cofig_final; + private final static String recent_year_power_data = "hzims:operation:key:power:data"; + private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("obtain-generation-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); /** @@ -437,4 +441,56 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { private static Integer countStep(Integer size) { return (size + 3 - 1) / 3; } + + + /** + * 新版-近3年发电量 + * @param param + */ + @Override + public void loadThreeYearPowerGeneration(String param, List types, Integer serveType,int year) { + // 站点查询 + List stations = stationService.list(new LambdaQueryWrapper() {{ + if (CollectionUtil.isNotEmpty(types)) { + in(StationEntity::getType, types); + } + }}); + // 开始时间 + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH) + 12); + calendar.add(Calendar.DATE, -calendar.get(Calendar.DATE) + 1); + String end = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + // 结束日期 + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - year); + calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); + String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE); + + List generations = threeGenerateService.list(Wrappers.lambdaQuery() + .in(ThreeGenerationEntity::getStationId,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())) + .ge(ThreeGenerationEntity::getStrMonth,start) + .le(ThreeGenerationEntity::getStrMonth,end) + ); + if(CollectionUtil.isEmpty(generations)){ + return; + } + Map> map = generations.stream().collect(Collectors.groupingBy(ThreeGenerationEntity::getStationId)); + // 定义接收参数 + Map> container = new HashMap<>(); + map.forEach((key, value) -> { + Optional optional = stations.stream().filter(o -> o.getCode().equals(key)).findFirst(); + if (!optional.isPresent()) { + return; + } + // 根据月份分组 + Map> months = value.stream().collect(Collectors.groupingBy(ThreeGenerationEntity::getStrMonth)); + // 接收月份发电量对象 + Map son = new HashMap<>(); + // 遍历月份数据 + months.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(iter -> { + son.put(iter.getKey(), (float) iter.getValue().stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum()); + }); + container.put(optional.get().getId(), son); + }); + redisTemplate.opsForValue().set(recent_year_power_data, container); + } } \ No newline at end of file From da774a20ef1b88686c8645420ca60f6070622733 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 23 Jul 2024 16:43:57 +0800 Subject: [PATCH 3/6] =?UTF-8?q?#=E6=96=B0=E7=89=88=E8=BF=913=E5=B9=B4?= =?UTF-8?q?=E5=8F=91=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/operational/main/constant/ScheduledConstant.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java index c5b9176..5dee662 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/ScheduledConstant.java @@ -11,4 +11,6 @@ public interface ScheduledConstant { String THIRTY_DAY_POWER_GENERATION = "thirtyDayPowerGeneration"; String THIS_DAY_POWER_GENERATION = "thisDayPowerGeneration"; + + String LOAD_THREE_YEAR_POWER_GENERATION = "loadThreeYearPowerGeneration"; } \ No newline at end of file From 4abd5e9c815cbbfccfe97fc0b2bca612b2b24991 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 24 Jul 2024 10:50:46 +0800 Subject: [PATCH 4/6] =?UTF-8?q?#=E6=B0=B4=E4=BD=8D=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduled/RealTargetScheduledTask.java | 1 + .../home/impl/ObtainGenerationServiceImpl.java | 25 +++++++++++----------- .../operation/home/impl/RealTargetServiceImpl.java | 11 ++++++---- 3 files changed, 20 insertions(+), 17 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 4e68cab..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 @@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.util.Arrays; 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 a6ff70d..0259de2 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 @@ -19,7 +19,6 @@ import com.hnac.hzims.scheduled.service.operation.home.ObtainGenerationService; import com.hnac.hzims.scheduled.service.operation.plate.DataService; import com.hnac.hzims.scheduled.service.operation.station.StationService; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyseDataTaosVO; -import io.undertow.util.CopyOnWriteMap; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.CollectionUtil; @@ -65,6 +64,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("obtain-generation-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); + /** * 设备近3年发电量数据 : 按月分割 * @param param @@ -135,8 +135,8 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { CountDownLatch countDownLatch = new CountDownLatch(limits.size()); List saves = new CopyOnWriteArrayList<>(); for(List item : limits){ - try{ - pool.submit(()->{ + pool.submit(()->{ + try{ item.forEach(station->{ // 站点设备集合 List eminfos = devices.stream().filter(device -> device.getCreateDept().equals(station.getRefDept())).collect(Collectors.toList()); @@ -179,10 +179,11 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { }); countDownLatch.countDown(); log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); - }); - }catch (Exception e){ - log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); - } + }catch (Exception e){ + countDownLatch.countDown(); + log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); + } + }); } // 等待所有线程执行完成 try { @@ -220,9 +221,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 3); calendar.add(Calendar.MONTH, -calendar.get(Calendar.MONTH)); String start = DateUtil.format(calendar.getTime(),DateUtil.PATTERN_DATE) + " 00:00:00"; - stations.forEach(station->{ - this.threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end)); - }); + stations.forEach(station-> this.threeGenerateService.saveBatch(this.saveFillGenerate(station,start,end))); } /** @@ -310,6 +309,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); }); }catch (Exception e){ + countDownLatch.countDown(); log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); } } @@ -382,6 +382,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { log.error("save_generation_execute_complete: {}" ,item.stream().map(StationEntity::getName).collect(Collectors.toList())); }); }catch (Exception e){ + countDownLatch.countDown(); log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); } } @@ -486,9 +487,7 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { // 接收月份发电量对象 Map son = new HashMap<>(); // 遍历月份数据 - months.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(iter -> { - son.put(iter.getKey(), (float) iter.getValue().stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum()); - }); + months.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(iter -> son.put(iter.getKey(), (float) iter.getValue().stream().mapToDouble(o -> o.getGenerate().doubleValue()).sum())); container.put(optional.get().getId(), son); }); redisTemplate.opsForValue().set(recent_year_power_data, container); 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 67f90ce..52e5fd1 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 @@ -127,7 +127,7 @@ public class RealTargetServiceImpl implements RealTargetService { private final static String load_photovoltaic_target_key = "hzims:operation:photovoltaic:target:key"; // 创建线程池 - private static final ExecutorService pool = new ThreadPoolExecutor(20, 20, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); + private static final ExecutorService pool = new ThreadPoolExecutor(10, 10, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1024), new ThreadFactoryBuilder().setNameFormat("load-power-data-pool-%d").build() , new ThreadPoolExecutor.CallerRunsPolicy()); @Override public void loadEmInfo(String param) { @@ -573,19 +573,22 @@ public class RealTargetServiceImpl implements RealTargetService { waterLevelVo.setRearCurveMap(rearCurveMap); list.add(waterLevelVo); } + log.error("load_water_level : 线程执行完成 {}", item.getInstanceCode()); countDownLatch.countDown(); - }catch (Exception exception){ - log.error("load_water_level_error : {}",exception.getMessage()); + } catch (Exception exception) { + log.error("load_water_level_error : 线程执行失败 {}", exception.getMessage()); countDownLatch.countDown(); } }); } try { + log.error("load_water_level :等待线程执行"); countDownLatch.await(); } catch (InterruptedException e) { e.printStackTrace(); Thread.currentThread().interrupt(); } + log.error("load_water_level :线程执行完成"); redisTemplate.opsForValue().set(loadwater_level_key,list); } @@ -1132,7 +1135,7 @@ public class RealTargetServiceImpl implements RealTargetService { } /** - * 获取水位当年数据 + * 获取水位当日数据 * @param instanceCode * @param signage * @return From a919638092a4c2ed5e0c6546ceee23af5630e5b2 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Wed, 24 Jul 2024 12:29:35 +0800 Subject: [PATCH 5/6] =?UTF-8?q?#=E6=B0=B4=E4=BD=8D=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=89=A7=E8=A1=8C?= 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 | 78 ++++++++++++---------- 3 files changed, 49 insertions(+), 40 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 6b524df..676adbb 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", ScheduledApplication.class, args); + BladeApplication.run("hzims-scheduled-ysj", ScheduledApplication.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { - return BladeApplication.createSpringApplicationBuilder(builder, "hzims-scheduled", ScheduledApplication.class); + return BladeApplication.createSpringApplicationBuilder(builder, "hzims-scheduled-ysj", 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 9591c87..a2b873f 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,9 +110,10 @@ 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 52e5fd1..522184b 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 @@ -545,40 +545,9 @@ public class RealTargetServiceImpl implements RealTargetService { List list = new CopyOnWriteArrayList<>(); CountDownLatch countDownLatch = new CountDownLatch(modelList.size()); for(HzimsAnalyzeModelStationEntity item : modelList){ - pool.submit(() -> { - 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()); - countDownLatch.countDown(); - } catch (Exception exception) { - log.error("load_water_level_error : 线程执行失败 {}", exception.getMessage()); - countDownLatch.countDown(); - } + pool.execute(() -> { + this.queryWaterLeve(list,item); + countDownLatch.countDown(); }); } try { @@ -588,11 +557,50 @@ public class RealTargetServiceImpl implements RealTargetService { e.printStackTrace(); Thread.currentThread().interrupt(); } - log.error("load_water_level :线程执行完成"); + log.error("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()); + } + } + + /** * 光伏站-逆变器实时加载 * * @param param 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 6/6] =?UTF-8?q?#sdk=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7fix?= =?UTF-8?q?.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