mirror of
https://github.com/1024-lab/smart-admin.git
synced 2025-08-29 09:29:57 +00:00
【V3.5.0】1、【新增】轻量级定时任务 SmartJob;2、【新增】站内信;3、【新增】个人中心;4、【新增】岗位管理;5、【优化】部门员工管理
This commit is contained in:
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**
|
||||
!**/src/test/**
|
||||
|
||||
### STS ###
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### front ###
|
||||
**/dist
|
||||
**/node_modules
|
||||
**/.vscode
|
||||
|
@@ -26,7 +26,8 @@ public class RoleEmployeeManager extends ServiceImpl<RoleEmployeeDao, RoleEmploy
|
||||
*
|
||||
*/
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
public void saveRoleEmployee(List<RoleEmployeeEntity> roleEmployeeList) {
|
||||
public void saveRoleEmployee(Long roleId, List<RoleEmployeeEntity> roleEmployeeList) {
|
||||
this.getBaseMapper().deleteByRoleId(roleId);
|
||||
if (CollectionUtils.isNotEmpty(roleEmployeeList)) {
|
||||
this.saveBatch(roleEmployeeList);
|
||||
}
|
||||
|
@@ -110,7 +110,6 @@ public class RoleEmployeeService {
|
||||
* 批量添加角色的成员员工
|
||||
*
|
||||
*/
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
public ResponseDTO<String> batchAddRoleEmployee(RoleEmployeeUpdateForm roleEmployeeUpdateForm) {
|
||||
Long roleId = roleEmployeeUpdateForm.getRoleId();
|
||||
List<Long> employeeIdList = roleEmployeeUpdateForm.getEmployeeIdList();
|
||||
@@ -121,10 +120,8 @@ public class RoleEmployeeService {
|
||||
.map(employeeId -> new RoleEmployeeEntity(roleId, employeeId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// 防重,删除此次角色员工数据
|
||||
roleEmployeeDao.batchDeleteEmployeeRole(roleId, employeeIdList);
|
||||
// 保存数据
|
||||
roleEmployeeManager.saveRoleEmployee(roleEmployeeList);
|
||||
roleEmployeeManager.saveRoleEmployee(roleId, roleEmployeeList);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,20 +1,20 @@
|
||||
spring:
|
||||
# 数据库连接信息
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:3306/smart_admin_v3?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:p6spy:mysql://127.0.0.1:3306/smart_admin_v3?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: Zhuoda#1024lab
|
||||
initial-size: 5
|
||||
min-idle: 5
|
||||
max-active: 20
|
||||
password: Zhuoda1024lab
|
||||
initial-size: 2
|
||||
min-idle: 2
|
||||
max-active: 10
|
||||
max-wait: 60000
|
||||
time-between-eviction-runs-millis: 60000
|
||||
min-evictable-idle-time-millis: 300000
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
|
||||
filters: stat
|
||||
druid:
|
||||
username: druid
|
||||
password: 1024lab
|
||||
password: 1024
|
||||
login:
|
||||
enabled: false
|
||||
method:
|
||||
@@ -29,9 +29,9 @@ spring:
|
||||
timeout: 10000ms
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 50
|
||||
min-idle: 5
|
||||
max-idle: 5
|
||||
max-active: 5
|
||||
min-idle: 1
|
||||
max-idle: 3
|
||||
max-wait: 30000ms
|
||||
|
||||
# 上传文件大小配置
|
||||
@@ -74,9 +74,9 @@ file:
|
||||
upload-path: /home/smart_admin_v3/upload/ #文件上传目录
|
||||
url-prefix:
|
||||
cloud:
|
||||
region: oss-cn-qingdao
|
||||
endpoint: oss-cn-qingdao.aliyuncs.com
|
||||
bucket-name: common
|
||||
region: oss-cn-hangzhou
|
||||
endpoint: oss-cn-hangzhou.aliyuncs.com
|
||||
bucket-name: 1024lab-smart-admin
|
||||
access-key:
|
||||
secret-key:
|
||||
url-prefix: https://${file.storage.cloud.bucket-name}.${file.storage.cloud.endpoint}/
|
||||
|
@@ -1245,14 +1245,14 @@ INSERT INTO `t_smart_job` VALUES (2, '示例任务2', 'net.lab1024.sa.base.modul
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `t_smart_job_log`;
|
||||
CREATE TABLE `t_smart_job_log` (
|
||||
`log_id` int(0) NOT NULL AUTO_INCREMENT,
|
||||
`log_id` bigint(0) NOT NULL AUTO_INCREMENT,
|
||||
`job_id` int(0) NOT NULL COMMENT '任务id',
|
||||
`job_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务名称',
|
||||
`param` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行参数',
|
||||
`success_flag` tinyint(1) NOT NULL COMMENT '是否成功',
|
||||
`execute_start_time` datetime(0) NOT NULL COMMENT '执行开始时间',
|
||||
`execute_time_millis` int(0) NOT NULL COMMENT '执行时长',
|
||||
`execute_end_time` datetime(0) NOT NULL COMMENT '执行结束时间',
|
||||
`execute_time_millis` int(0) NULL DEFAULT NULL COMMENT '执行时长',
|
||||
`execute_end_time` datetime(0) NULL DEFAULT NULL COMMENT '执行结束时间',
|
||||
`execute_result` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
||||
`ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ip',
|
||||
`process_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '进程id',
|
||||
|
Reference in New Issue
Block a user