From 611d995be244caa712640db5ece7aa41eb69c464 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Thu, 29 Aug 2024 15:11:55 +0800 Subject: [PATCH] =?UTF-8?q?#=E6=97=A0=E5=8A=9F=E7=94=B5=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/scheduled/ScheduledApplication.java | 2 +- .../hzims/scheduled/scheduled/GenerationScheduledTask.java | 4 +++- .../operation/home/impl/ObtainGenerationServiceImpl.java | 14 +++++++------- 3 files changed, 11 insertions(+), 9 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..17f210b 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,7 +21,7 @@ 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 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 80be76b..c42a00e 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 @@ -8,7 +8,6 @@ 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; @@ -49,6 +48,7 @@ public class GenerationScheduledTask { * @return */ @XxlJob(THIRTY_DAY_POWER_GENERATION) + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT thirtyDayPowerGeneration(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); @@ -63,6 +63,7 @@ public class GenerationScheduledTask { * @return */ @XxlJob(THIS_DAY_POWER_GENERATION) + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT thisDayPowerGeneration(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); @@ -77,6 +78,7 @@ public class GenerationScheduledTask { * @return */ @XxlJob(LOAD_THREE_YEAR_POWER_GENERATION) + //@Scheduled(cron = "0/40 * * * * ? ") public ReturnT loadThreeYearPowerGeneration(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/ObtainGenerationServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/ObtainGenerationServiceImpl.java index f304eaf..6e74235 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 @@ -297,8 +297,8 @@ public class ObtainGenerationServiceImpl implements ObtainGenerationService { List> limits = Stream.iterate(0, n -> n + 1).limit(limit).parallel().map(a -> stations.stream().skip((long) a * 3).limit(3).parallel().collect(Collectors.toList())).collect(Collectors.toList()); CountDownLatch countDownLatch = new CountDownLatch(limits.size()); 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()); @@ -354,11 +354,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){ - countDownLatch.countDown(); - log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); - } + }catch (Exception e){ + countDownLatch.countDown(); + log.error("save_generation_execute_complete_error : {}" ,e.getMessage()); + } + }); } // 等待所有线程执行完成 try {