From 1d87f545e6378bbe27602cc58699d63e04f79cb5 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Tue, 3 Jan 2023 16:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=A8=E3=80=81=E6=9C=88=20=E5=BA=A6?= =?UTF-8?q?=E5=BF=AB=E7=85=A7=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/SysDateSnapshotService.java | 5 ++- .../impl/SysDateSnapshotServiceImpl.java | 29 ++++++++++++++++- .../date_snapshot/task/MonthSnapshot.java | 28 +++++++++++++++++ .../date_snapshot/task/WeeklySnapshot.java | 31 +++++++++++++++++++ 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java create mode 100644 renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java 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 13ef9005..bfcaf009 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 @@ -11,5 +11,8 @@ import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity; * @since 1.0 2023-01-03 */ public interface SysDateSnapshotService extends CrudService { - + /** + * 数据快s照行为 + */ + void snapshotAction(Integer type); } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java index ead91d1a..c4917688 100644 --- a/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/service/impl/SysDateSnapshotServiceImpl.java @@ -6,9 +6,12 @@ import io.renren.modules.date_snapshot.dao.SysDateSnapshotDao; import io.renren.modules.date_snapshot.dto.SysDateSnapshotDTO; import io.renren.modules.date_snapshot.entity.SysDateSnapshotEntity; import io.renren.modules.date_snapshot.service.SysDateSnapshotService; +import io.renren.modules.processForm.service.TAbilityApplicationService; +import io.renren.modules.resource.service.ResourceService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Map; +import java.util.*; /** * 运行数据快照(资源数量、申请数量) @@ -18,6 +21,10 @@ import java.util.Map; */ @Service public class SysDateSnapshotServiceImpl extends CrudServiceImpl implements SysDateSnapshotService { + @Autowired + private TAbilityApplicationService tAbilityApplicationService; + @Autowired + private ResourceService resourceService; @Override public QueryWrapper getWrapper(Map params) { @@ -28,4 +35,24 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl> snapshot = new ArrayList>() {{ + add(new LinkedHashMap() {{ + put("count", countApply); + put("type", "资源申请量"); + }}); + addAll((Collection>) resourceService.selectTotal()); // 资源汇聚量 + }}; + + sysDateSnapshotDTO.setCreateDate(new Date()); + sysDateSnapshotDTO.setType(type); + sysDateSnapshotDTO.setSnapshot(snapshot); + save(sysDateSnapshotDTO); + } } \ No newline at end of file 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 new file mode 100644 index 00000000..e2ea404c --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/MonthSnapshot.java @@ -0,0 +1,28 @@ +package io.renren.modules.date_snapshot.task; + +import io.renren.modules.date_snapshot.service.SysDateSnapshotService; +import io.renren.modules.job.task.ITask; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +@Component("monthSnapshot") +public class MonthSnapshot implements ITask { + private static final Logger logger = LoggerFactory.getLogger(MonthSnapshot.class); + + @Autowired + private SysDateSnapshotService sysDateSnapshotService; + + /** + * 执行定时任务接口 + * + * @param params 参数,多参数使用JSON数据 + */ + @Override + public void run(String params) { + logger.info("月快照计划"); + sysDateSnapshotService.snapshotAction(2); + } +} 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 new file mode 100644 index 00000000..2724ac9c --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/date_snapshot/task/WeeklySnapshot.java @@ -0,0 +1,31 @@ +package io.renren.modules.date_snapshot.task; + +import io.renren.modules.date_snapshot.service.SysDateSnapshotService; +import io.renren.modules.job.task.ITask; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * 周快照计划任务 + */ +@Component("weeklySnapshot") +public class WeeklySnapshot implements ITask { + private static final Logger logger = LoggerFactory.getLogger(WeeklySnapshot.class); + + @Autowired + private SysDateSnapshotService sysDateSnapshotService; + + /** + * 执行定时任务接口 + * + * @param params 参数,多参数使用JSON数据 + */ + @Override + public void run(String params) { + logger.info("周快照计划"); + sysDateSnapshotService.snapshotAction(1); + } +}