mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-11-15 07:03:48 +08:00
【V3.5.0】1、【新增】轻量级定时任务 SmartJob;2、【新增】站内信;3、【新增】个人中心;4、【新增】岗位管理;5、【优化】部门员工管理
This commit is contained in:
@@ -88,8 +88,11 @@ public class SmartJobExecutor implements Runnable {
|
||||
* @param executorName
|
||||
*/
|
||||
public SmartJobLogEntity execute(String executorName) {
|
||||
// 执行计时
|
||||
// 保存执行记录
|
||||
LocalDateTime startTime = LocalDateTime.now();
|
||||
Long logId = this.saveLogBeforeExecute(jobEntity, executorName, startTime);
|
||||
|
||||
// 执行计时
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
|
||||
@@ -107,33 +110,49 @@ public class SmartJobExecutor implements Runnable {
|
||||
log.error("==== SmartJob ==== execute err:", t);
|
||||
}
|
||||
|
||||
// 保存执行记录
|
||||
// 更新执行记录
|
||||
SmartJobLogEntity logEntity = new SmartJobLogEntity();
|
||||
logEntity.setLogId(logId);
|
||||
logEntity.setSuccessFlag(successFlag);
|
||||
long totalTimeMillis = stopWatch.getTotalTimeMillis();
|
||||
logEntity.setExecuteTimeMillis(totalTimeMillis);
|
||||
logEntity.setExecuteEndTime(startTime.plus(totalTimeMillis, ChronoUnit.MILLIS));
|
||||
logEntity.setExecuteResult(executeResult);
|
||||
jobRepository.getJobLogDao().updateById(logEntity);
|
||||
return logEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行前 保存执行记录
|
||||
*
|
||||
* @param jobEntity
|
||||
* @param executorName
|
||||
* @param executeTime
|
||||
* @return 返回执行记录id
|
||||
*/
|
||||
private Long saveLogBeforeExecute(SmartJobEntity jobEntity,
|
||||
String executorName,
|
||||
LocalDateTime executeTime) {
|
||||
Integer jobId = jobEntity.getJobId();
|
||||
// 保存执行记录
|
||||
SmartJobLogEntity logEntity = new SmartJobLogEntity();
|
||||
logEntity.setJobId(jobId);
|
||||
logEntity.setJobName(jobEntity.getJobName());
|
||||
logEntity.setParam(jobEntity.getParam());
|
||||
logEntity.setSuccessFlag(successFlag);
|
||||
// 执行开始 结束时间
|
||||
logEntity.setExecuteStartTime(startTime);
|
||||
long totalTimeMillis = stopWatch.getTotalTimeMillis();
|
||||
logEntity.setExecuteTimeMillis(totalTimeMillis);
|
||||
logEntity.setExecuteEndTime(startTime.plus(totalTimeMillis, ChronoUnit.MILLIS));
|
||||
// 执行结果
|
||||
logEntity.setExecuteResult(executeResult);
|
||||
logEntity.setSuccessFlag(true);
|
||||
// 执行开始时间
|
||||
logEntity.setExecuteStartTime(executeTime);
|
||||
logEntity.setCreateName(executorName);
|
||||
logEntity.setIp(SmartIpUtil.getLocalFirstIp());
|
||||
logEntity.setProcessId(SmartJobUtil.getProcessId());
|
||||
logEntity.setProgramPath(SmartJobUtil.getProgramPath());
|
||||
logEntity.setCreateName(executorName);
|
||||
|
||||
// 更新上次执行
|
||||
// 更新最后执行时间
|
||||
SmartJobEntity updateJobEntity = new SmartJobEntity();
|
||||
updateJobEntity.setJobId(jobId);
|
||||
updateJobEntity.setLastExecuteTime(startTime);
|
||||
|
||||
// 持久化数据
|
||||
updateJobEntity.setLastExecuteTime(executeTime);
|
||||
jobRepository.saveLog(logEntity, updateJobEntity);
|
||||
return logEntity;
|
||||
return logEntity.getLogId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,10 @@ public class SmartJobRepository {
|
||||
return jobDao;
|
||||
}
|
||||
|
||||
public SmartJobLogDao getJobLogDao() {
|
||||
return jobLogDao;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存执行记录
|
||||
*
|
||||
@@ -38,5 +42,4 @@ public class SmartJobRepository {
|
||||
jobEntity.setLastExecuteLogId(logEntity.getLogId());
|
||||
jobDao.updateById(jobEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.lab1024.sa.base.module.support.redis;
|
||||
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import org.redisson.config.Config;
|
||||
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
*
|
||||
* redission对于password 为空处理有问题,重新设置下
|
||||
*
|
||||
* @Author 1024创新实验室-主任:卓大
|
||||
* @Date 2024/7/16 01:04:18
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> ,Since 2012
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class RedissonPasswordConfigurationCustomizer implements RedissonAutoConfigurationCustomizer {
|
||||
@Override
|
||||
public void customize(Config configuration) {
|
||||
if (configuration.isSingleConfig() && SmartStringUtil.isEmpty(configuration.useSingleServer().getPassword())) {
|
||||
configuration.useSingleServer().setPassword(null);
|
||||
}
|
||||
|
||||
if (configuration.isClusterConfig() && SmartStringUtil.isEmpty(configuration.useClusterServers().getPassword())) {
|
||||
configuration.useClusterServers().setPassword(null);
|
||||
}
|
||||
if (configuration.isSentinelConfig() && SmartStringUtil.isEmpty(configuration.useSentinelServers().getPassword())) {
|
||||
configuration.useSentinelServers().setPassword(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user