From 5536f25c8f0f6d28937242dfd8cb9ead9d3f2475 Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Tue, 19 Jul 2022 19:14:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activiti/service/ActTaskService.java | 4 +- .../modules/log/dao/SysLogErrorDao.java | 5 ++- .../modules/log/dao/SysLogOperationDao.java | 5 ++- .../renren/modules/log/task/clearLogTask.java | 45 +++++++++++++++++++ .../service/impl/ResourceServiceImpl.java | 1 - .../taskList/task/InsertTaskListJob.java | 1 - .../src/main/resources/application.yml | 2 +- .../resources/mapper/log/SysLogErrorDao.xml | 3 ++ .../mapper/log/SysLogOperationDao.xml | 3 ++ 9 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java diff --git a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java index 580bd6db..1380766c 100644 --- a/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java +++ b/renren-admin/src/main/java/io/renren/modules/activiti/service/ActTaskService.java @@ -21,6 +21,7 @@ import io.renren.modules.resourceMountApply.dto.TResourceMountApplyDTO; import io.renren.modules.resourceMountApply.service.TResourceMountApplyService; import io.renren.modules.security.user.SecurityUser; import io.renren.modules.sys.dto.SysUserDTO; +import io.renren.modules.sys.entity.SysUserEntity; import io.renren.modules.sys.service.SysRoleUserService; import io.renren.modules.sys.service.SysUserService; import org.activiti.engine.HistoryService; @@ -186,7 +187,6 @@ public class ActTaskService extends BaseServiceImpl { }).collect(Collectors.toList()); CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[completableFutureList.size()])).join(); Page page = new Page(curPage, limit); - int j = Math.min(curPage * limit, taskDtoList.size()); if (taskDtoList.isEmpty()) { page.setRecords(null); page.setTotal(0); @@ -216,6 +216,8 @@ public class ActTaskService extends BaseServiceImpl { if (dto.getBusinessKey().startsWith("{") || dto.getBusinessKey().startsWith("[")) { // 为json内容 (特殊处理批量) processVariable.putAll(task.getProcessVariables()); dto.setParams(processVariable); + Optional creator = Optional.ofNullable(sysUserService.selectById(Long.parseLong(processVariable.get("creator").toString()))); + dto.setUserName(creator.get().getRealName()); listDto.add(dto); continue; } diff --git a/renren-admin/src/main/java/io/renren/modules/log/dao/SysLogErrorDao.java b/renren-admin/src/main/java/io/renren/modules/log/dao/SysLogErrorDao.java index bb7d21c3..c01e30eb 100644 --- a/renren-admin/src/main/java/io/renren/modules/log/dao/SysLogErrorDao.java +++ b/renren-admin/src/main/java/io/renren/modules/log/dao/SysLogErrorDao.java @@ -1,8 +1,10 @@ package io.renren.modules.log.dao; +import cn.hutool.core.date.DateTime; import io.renren.common.dao.BaseDao; import io.renren.modules.log.entity.SysLogErrorEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 异常日志 @@ -11,5 +13,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface SysLogErrorDao extends BaseDao { - + + Integer clearLog(@Param("offsetDay") DateTime offsetDay); } diff --git a/renren-admin/src/main/java/io/renren/modules/log/dao/SysLogOperationDao.java b/renren-admin/src/main/java/io/renren/modules/log/dao/SysLogOperationDao.java index 742ef251..d2332174 100644 --- a/renren-admin/src/main/java/io/renren/modules/log/dao/SysLogOperationDao.java +++ b/renren-admin/src/main/java/io/renren/modules/log/dao/SysLogOperationDao.java @@ -1,8 +1,10 @@ package io.renren.modules.log.dao; +import cn.hutool.core.date.DateTime; import io.renren.common.dao.BaseDao; import io.renren.modules.log.entity.SysLogOperationEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 操作日志 @@ -11,5 +13,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface SysLogOperationDao extends BaseDao { - + + Integer clearLog(@Param("offsetDay") DateTime offsetDay); } diff --git a/renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java b/renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java new file mode 100644 index 00000000..b56f686c --- /dev/null +++ b/renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java @@ -0,0 +1,45 @@ +package io.renren.modules.log.task; + +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import io.renren.modules.job.task.ITask; +import io.renren.modules.log.dao.SysLogErrorDao; +import io.renren.modules.log.dao.SysLogOperationDao; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; + +/** + * 清理操作日志表任务 + */ +@Component("clearLogTask") +public class clearLogTask implements ITask { + + private static final Logger logger = LoggerFactory.getLogger(clearLogTask.class); + + @Autowired + private SysLogOperationDao sysLogOperationDao; + + @Autowired + private SysLogErrorDao sysLogErrorDao; + + + /** + * + * @param params 日志保留天数 + */ + @Override + @Transactional + public void run(String params) { + logger.info("---------------------开始清理日志表数据---------------------"); + int offset = -Integer.parseInt(params); + DateTime offsetDay = DateUtil.offsetDay(new Date(), offset); + sysLogOperationDao.clearLog(offsetDay); + sysLogErrorDao.clearLog(offsetDay); + logger.info("---------------------结束清理日志表数据---------------------"); + } +} 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 9f5967c1..7284feb3 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 @@ -624,7 +624,6 @@ public class ResourceServiceImpl extends CrudServiceImpl() { { QueryWrapper queryWrapper = new QueryWrapper<>(); diff --git a/renren-admin/src/main/java/io/renren/modules/taskList/task/InsertTaskListJob.java b/renren-admin/src/main/java/io/renren/modules/taskList/task/InsertTaskListJob.java index b9b14735..0e8a41a3 100644 --- a/renren-admin/src/main/java/io/renren/modules/taskList/task/InsertTaskListJob.java +++ b/renren-admin/src/main/java/io/renren/modules/taskList/task/InsertTaskListJob.java @@ -14,7 +14,6 @@ import org.springframework.stereotype.Component; import java.util.Map; import java.util.Optional; - /** * 商汤 场景任务列表插入 */ diff --git a/renren-admin/src/main/resources/application.yml b/renren-admin/src/main/resources/application.yml index 6f073a2c..a84bd4ef 100644 --- a/renren-admin/src/main/resources/application.yml +++ b/renren-admin/src/main/resources/application.yml @@ -7,7 +7,7 @@ project: big_date: name: 青岛市大数据发展管理局 assignee_role_name: 部门审批人 -# 需要进行统计数目的资源 type +# 需要进行统计数目的资源 type/需要进行统计申请的资源类型 applyType census: type: 组件服务,应用资源,基础设施,数据资源,知识库 applyType: 应用资源,业务组件,图层服务,开发组件,智能算法 diff --git a/renren-admin/src/main/resources/mapper/log/SysLogErrorDao.xml b/renren-admin/src/main/resources/mapper/log/SysLogErrorDao.xml index 0babe80a..c0df9526 100644 --- a/renren-admin/src/main/resources/mapper/log/SysLogErrorDao.xml +++ b/renren-admin/src/main/resources/mapper/log/SysLogErrorDao.xml @@ -3,4 +3,7 @@ + + DELETE FROM sys_log_error WHERE 1 = 1 AND #{offsetDay} > create_date + \ No newline at end of file diff --git a/renren-admin/src/main/resources/mapper/log/SysLogOperationDao.xml b/renren-admin/src/main/resources/mapper/log/SysLogOperationDao.xml index 35881acf..d50185fb 100644 --- a/renren-admin/src/main/resources/mapper/log/SysLogOperationDao.xml +++ b/renren-admin/src/main/resources/mapper/log/SysLogOperationDao.xml @@ -3,4 +3,7 @@ + + DELETE FROM sys_log_operation WHERE 1 = 1 AND #{offsetDay} > create_date + \ No newline at end of file From b306ce533d6ff18e86bcfa5e6d7ef70b54ba24fa Mon Sep 17 00:00:00 2001 From: dinggang <2498628697@qq.com> Date: Tue, 19 Jul 2022 19:16:19 +0800 Subject: [PATCH 2/2] . --- .../src/main/java/io/renren/modules/log/task/clearLogTask.java | 1 + 1 file changed, 1 insertion(+) diff --git a/renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java b/renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java index b56f686c..45300d47 100644 --- a/renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java +++ b/renren-admin/src/main/java/io/renren/modules/log/task/clearLogTask.java @@ -38,6 +38,7 @@ public class clearLogTask implements ITask { logger.info("---------------------开始清理日志表数据---------------------"); int offset = -Integer.parseInt(params); DateTime offsetDay = DateUtil.offsetDay(new Date(), offset); + logger.info("日志保留开始日期-------->" + offsetDay); sysLogOperationDao.clearLog(offsetDay); sysLogErrorDao.clearLog(offsetDay); logger.info("---------------------结束清理日志表数据---------------------");