Merge remote-tracking branch 'remotes/origin/dev' into test

yun-zuoyi
汪云昊 6 years ago
commit 8a814612e9

@ -35,7 +35,7 @@ public class CoreLogClearJob extends BaseImppScheduleJob {
}
@Value("${impp.log.retention-time:-1}")
public Integer retentionTime;
private Integer retentionTime;
@Autowired
private ISysLogSystemService sysLogSystemService;
@ -58,30 +58,32 @@ public class CoreLogClearJob extends BaseImppScheduleJob {
JSONObject clearParam = JSONObject.parseObject(getJobParam());
// 计算保留日期
String dateTime = TimeTool.pareDateToString("yyyy-MM-dd HH:mm:ss",
TimeTool.timeCalc(new Date(), Calendar.DAY_OF_MONTH, -retentionTime)
);
String dateTime = TimeTool.timeCalc(new Date(), Calendar.DAY_OF_MONTH, -retentionTime,"yyyy-MM-dd HH:mm:ss");
long count;
// 系统日志
if (clearParam.containsKey("logSystem") && clearParam.getInteger("logSystem") != -1) {
dateTime = TimeTool.timeCalc(new Date(), Calendar.DAY_OF_MONTH, -clearParam.getInteger("logSystem"),"yyyy-MM-dd HH:mm:ss");
count = sysLogSystemService.deleteSysLogSystemByDateTimeAfter(dateTime);
LOGGER.info("【日志清理】 清理系统日志 {} 条", count);
}
// 异常日志
if (clearParam.containsKey("logException") && clearParam.getInteger("logException") != -1) {
dateTime = TimeTool.timeCalc(new Date(), Calendar.DAY_OF_MONTH, -clearParam.getInteger("logException"),"yyyy-MM-dd HH:mm:ss");
count = sysLogExceptionService.deleteSysLogExceptionByDateTimeAfter(dateTime);
LOGGER.info("【日志清理】 清理异常日志 {} 条", count);
}
// 操作日志
if (clearParam.containsKey("logOperate") && clearParam.getInteger("logOperate") != -1) {
dateTime = TimeTool.timeCalc(new Date(), Calendar.DAY_OF_MONTH, -clearParam.getInteger("logException"),"yyyy-MM-dd HH:mm:ss");
count = sysLogOperateService.deleteSysLogOperateByDateTimeAfter(dateTime);
LOGGER.info("【日志清理】 清理操作日志 {} 条", count);
}
// 任务日志
if (clearParam.containsKey("logTask") && clearParam.getInteger("logTask") != -1) {
dateTime = TimeTool.timeCalc(new Date(), Calendar.DAY_OF_MONTH, -clearParam.getInteger("logException"),"yyyy-MM-dd HH:mm:ss");
count = sysLogTaskTimeService.deleteSysLogTaskTimeByDateTimeAfter(dateTime);
LOGGER.info("【日志清理】 清理定时任务日志 {} 条", count);
}
@ -94,5 +96,13 @@ public class CoreLogClearJob extends BaseImppScheduleJob {
clearParam.put("logOperate",30);
clearParam.put("logTask",30);
System.out.println(clearParam.toJSONString());
clearParam = JSONObject.parseObject("{\"logOperate\":10,\"logException\":10,\"logSystem\":10,\"logTask\":10}");
// 计算保留日期
String dateTime = TimeTool.pareDateToString("yyyy-MM-dd HH:mm:ss",
TimeTool.timeCalc(new Date(), Calendar.DAY_OF_MONTH, 1)
);
}
}

Loading…
Cancel
Save