添加定时任务——insert时间完整性

This commit is contained in:
sh
2026-04-03 18:40:33 +08:00
parent 0f09dfbd2c
commit 5cfa574f0b

View File

@@ -1,6 +1,11 @@
package com.ruoyi.quartz.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.EncryptDecryptUtil;
import com.ruoyi.common.utils.StringUtils;
import org.quickssl.api.CryptoClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.quartz.domain.SysJobLog;
@@ -17,6 +22,8 @@ public class SysJobLogServiceImpl implements ISysJobLogService
{
@Autowired
private SysJobLogMapper jobLogMapper;
@Autowired
private EncryptDecryptUtil encryptDecryptUtil;
/**
* 获取quartz调度器日志的计划任务
@@ -50,6 +57,10 @@ public class SysJobLogServiceImpl implements ISysJobLogService
@Override
public void addJobLog(SysJobLog jobLog)
{
String createTime= DateUtils.getTime();
String createTimeCipher=saveCrateTimeSm3(createTime);
jobLog.setCreateTimeCipher(createTimeCipher);
jobLog.setCreateTime(createTime);
jobLogMapper.insertJobLog(jobLog);
}
@@ -84,4 +95,21 @@ public class SysJobLogServiceImpl implements ISysJobLogService
{
jobLogMapper.cleanJobLog();
}
/**
* 时间完整性
* @param createTime
* @return
*/
public String saveCrateTimeSm3(String createTime) {
if (StringUtils.isBlank(createTime)) {
throw new RuntimeException("加密失败createTime 不能为空");
}
try {
return encryptDecryptUtil.sm3Hash(createTime);
} catch (CryptoClient.CryptoException e) {
System.out.println("createTime加密失败"+e);
throw new RuntimeException("加密失败:" + e.getMessage(), e);
}
}
}