From 92d16479efa544381669dc58b01eccdb98064403 Mon Sep 17 00:00:00 2001 From: TS-QD1 Date: Mon, 15 May 2023 09:04:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9F=A5=E7=9C=8B=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cm/bigdata/monitor/KpiUpdateMonitor.java | 4 ++++ .../service/kpi/impl/KpiKhxzServiceImpl.java | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/cm/bigdata/monitor/KpiUpdateMonitor.java b/src/main/java/com/cm/bigdata/monitor/KpiUpdateMonitor.java index 6d997de..5d58b3f 100644 --- a/src/main/java/com/cm/bigdata/monitor/KpiUpdateMonitor.java +++ b/src/main/java/com/cm/bigdata/monitor/KpiUpdateMonitor.java @@ -25,6 +25,10 @@ public class KpiUpdateMonitor { completeTaskCount.getAndAdd(1); } + public int getCompleteCount() { + return completeTaskCount.get(); + } + public double getPercent() { LOG.debug("task: {}, complete: {}", taskCount, completeTaskCount); if (taskCount == 0) { diff --git a/src/main/java/com/cm/bigdata/service/kpi/impl/KpiKhxzServiceImpl.java b/src/main/java/com/cm/bigdata/service/kpi/impl/KpiKhxzServiceImpl.java index e5a6186..4af7925 100644 --- a/src/main/java/com/cm/bigdata/service/kpi/impl/KpiKhxzServiceImpl.java +++ b/src/main/java/com/cm/bigdata/service/kpi/impl/KpiKhxzServiceImpl.java @@ -45,7 +45,7 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi private KpiKhxzWgzTask kpiKhxzWgzTask; @Autowired private KpiKhxzZnbmTask kpiKhxzZnbmTask; - private ExecutorService executorService = Executors.newFixedThreadPool(2); + private ExecutorService executorService = Executors.newFixedThreadPool(10); @Override public void update(Integer khYear, Integer khMonth) { @@ -95,13 +95,21 @@ public class KpiKhxzServiceImpl extends AbstractService implements IKpiKhxzServi }); executorService.execute(() -> { - // 网格长,3任务 - kpiKhxzWgzTask.update(khYear, khMonth); + // 职能部门,4任务 + kpiKhxzZnbmTask.update(khYear, khMonth); }); executorService.execute(() -> { - // 职能部门,4任务 - kpiKhxzZnbmTask.update(khYear, khMonth); + while(KpiUpdateMonitor.getInstance().getCompleteCount() < 26) { + try { + Thread.sleep(3000); + LOG.debug("等待其他任务执行完成"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + // 网格长,3任务 + kpiKhxzWgzTask.update(khYear, khMonth); }); }); }