From 4286d508724c57957407922f336eb805c61591f7 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Wed, 4 Jan 2023 11:41:14 +0800 Subject: [PATCH] npe --- .../service/SysDateSnapshotService.java | 1 + .../impl/SysDateSnapshotServiceImpl.java | 8 +++- .../date_snapshot/task/MonthSnapshot.java | 19 ++++++++-- .../date_snapshot/task/WeeklySnapshot.java | 18 +++++++-- .../service/impl/ResourceServiceImpl.java | 37 ++++++++++++------- 5 files changed, 61 insertions(+), 22 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java index c0b0baa0..8d926474 100644 --- a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/SysDateSnapshotService.java @@ -25,6 +25,7 @@ public interface SysDateSnapshotService extends CrudService> resultList = (List>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap()); // 能力上架统计原始数据 + List> resultList = (List>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap() {{ + put("snapshot", true); + }}); // 能力上架统计原始数据 List> snapshot = new ArrayList>() {{ addAll(resultList); }}; @@ -93,7 +95,9 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl> resultList = (List>) resourceService.selectDeptDetailTypeCountList(new HashMap()); // 能力上架统计原始数据 + List> resultList = (List>) resourceService.selectDeptDetailTypeCountList(new HashMap() {{ + put("snapshot", true); + }}); // 能力上架统计原始数据 List> snapshot = new ArrayList>() {{ addAll(resultList); }}; diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java index 5d01d01f..3cb7a3a7 100644 --- a/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java @@ -8,11 +8,18 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + @Component("monthSnapshot") public class MonthSnapshot implements ITask { private static final Logger logger = LoggerFactory.getLogger(MonthSnapshot.class); + private static final Integer CPUNUM = Runtime.getRuntime().availableProcessors(); + + private static final ExecutorService executor = Executors.newWorkStealingPool(CPUNUM); + @Autowired private SysDateSnapshotService sysDateSnapshotService; @@ -24,8 +31,14 @@ public class MonthSnapshot implements ITask { @Override public void run(String params) { logger.info("月快照计划"); - sysDateSnapshotService.snapshotAction(SnapshotType.DATA_MONTH.getFlag()); - sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_MONTH.getFlag()); - sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_MONTH.getFlag()); + executor.execute(() -> { + sysDateSnapshotService.snapshotAction(SnapshotType.DATA_MONTH.getFlag()); + }); + executor.execute(() -> { + sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_MONTH.getFlag()); + }); + executor.execute(() -> { + sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_MONTH.getFlag()); + }); } } diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java index 3b0d25be..43879dcf 100644 --- a/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java @@ -8,6 +8,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + /** * 周快照计划任务 @@ -15,6 +18,9 @@ import org.springframework.stereotype.Component; @Component("weeklySnapshot") public class WeeklySnapshot implements ITask { private static final Logger logger = LoggerFactory.getLogger(WeeklySnapshot.class); + private static final Integer CPUNUM = Runtime.getRuntime().availableProcessors(); + + private static final ExecutorService executor = Executors.newWorkStealingPool(CPUNUM); @Autowired private SysDateSnapshotService sysDateSnapshotService; @@ -27,8 +33,14 @@ public class WeeklySnapshot implements ITask { @Override public void run(String params) { logger.info("周快照计划"); - sysDateSnapshotService.snapshotAction(SnapshotType.DATA_WEEKLY.getFlag()); - sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_WEEKLY.getFlag()); - sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_WEEKLY.getFlag()); + executor.execute(() -> { + sysDateSnapshotService.snapshotAction(SnapshotType.DATA_WEEKLY.getFlag()); + }); + executor.execute(() -> { + sysDateSnapshotService.snapshotApplyAction(SnapshotType.APPLY_WEEKLY.getFlag()); + }); + executor.execute(() -> { + sysDateSnapshotService.snapshotResourceAction(SnapshotType.RESOURCE_WEEKLY.getFlag()); + }); } } diff --git a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java index cdfc7e4e..b3f4a83d 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/service/impl/ResourceServiceImpl.java @@ -2328,13 +2328,17 @@ public class ResourceServiceImpl extends CrudServiceImpl