Skip to content

Commit 50f5324

Browse files
author
zhuoda
committed
【V3.5.0】1、【新增】轻量级定时任务 SmartJob;2、【新增】站内信;3、【新增】个人中心;4、【新增】岗位管理;5、【优化】部门员工管理
1 parent ba115a0 commit 50f5324

File tree

8 files changed

+116
-37
lines changed

8 files changed

+116
-37
lines changed

.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**
5+
!**/src/test/**
6+
7+
### STS ###
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
15+
### IntelliJ IDEA ###
16+
.idea
17+
*.iws
18+
*.iml
19+
*.ipr
20+
21+
### front ###
22+
**/dist
23+
**/node_modules
24+
**/.vscode
25+

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/role/manager/RoleEmployeeManager.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public class RoleEmployeeManager extends ServiceImpl<RoleEmployeeDao, RoleEmploy
2626
*
2727
*/
2828
@Transactional(rollbackFor = Throwable.class)
29-
public void saveRoleEmployee(List<RoleEmployeeEntity> roleEmployeeList) {
29+
public void saveRoleEmployee(Long roleId, List<RoleEmployeeEntity> roleEmployeeList) {
30+
this.getBaseMapper().deleteByRoleId(roleId);
3031
if (CollectionUtils.isNotEmpty(roleEmployeeList)) {
3132
this.saveBatch(roleEmployeeList);
3233
}

smart-admin-api/sa-admin/src/main/java/net/lab1024/sa/admin/module/system/role/service/RoleEmployeeService.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public ResponseDTO<String> batchRemoveRoleEmployee(RoleEmployeeUpdateForm roleEm
110110
* 批量添加角色的成员员工
111111
*
112112
*/
113-
@Transactional(rollbackFor = Throwable.class)
114113
public ResponseDTO<String> batchAddRoleEmployee(RoleEmployeeUpdateForm roleEmployeeUpdateForm) {
115114
Long roleId = roleEmployeeUpdateForm.getRoleId();
116115
List<Long> employeeIdList = roleEmployeeUpdateForm.getEmployeeIdList();
@@ -121,10 +120,8 @@ public ResponseDTO<String> batchAddRoleEmployee(RoleEmployeeUpdateForm roleEmplo
121120
.map(employeeId -> new RoleEmployeeEntity(roleId, employeeId))
122121
.collect(Collectors.toList());
123122
}
124-
// 防重,删除此次角色员工数据
125-
roleEmployeeDao.batchDeleteEmployeeRole(roleId, employeeIdList);
126123
// 保存数据
127-
roleEmployeeManager.saveRoleEmployee(roleEmployeeList);
124+
roleEmployeeManager.saveRoleEmployee(roleId, roleEmployeeList);
128125
return ResponseDTO.ok();
129126
}
130127

smart-admin-api/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/core/SmartJobExecutor.java

+34-15
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,11 @@ public void run() {
8888
* @param executorName
8989
*/
9090
public SmartJobLogEntity execute(String executorName) {
91-
// 执行计时
91+
// 保存执行记录
9292
LocalDateTime startTime = LocalDateTime.now();
93+
Long logId = this.saveLogBeforeExecute(jobEntity, executorName, startTime);
94+
95+
// 执行计时
9396
StopWatch stopWatch = new StopWatch();
9497
stopWatch.start();
9598

@@ -107,33 +110,49 @@ public SmartJobLogEntity execute(String executorName) {
107110
log.error("==== SmartJob ==== execute err:", t);
108111
}
109112

110-
// 保存执行记录
111-
Integer jobId = jobEntity.getJobId();
113+
// 更新执行记录
112114
SmartJobLogEntity logEntity = new SmartJobLogEntity();
113-
logEntity.setJobId(jobId);
114-
logEntity.setJobName(jobEntity.getJobName());
115-
logEntity.setParam(jobEntity.getParam());
115+
logEntity.setLogId(logId);
116116
logEntity.setSuccessFlag(successFlag);
117-
// 执行开始 结束时间
118-
logEntity.setExecuteStartTime(startTime);
119117
long totalTimeMillis = stopWatch.getTotalTimeMillis();
120118
logEntity.setExecuteTimeMillis(totalTimeMillis);
121119
logEntity.setExecuteEndTime(startTime.plus(totalTimeMillis, ChronoUnit.MILLIS));
122-
// 执行结果
123120
logEntity.setExecuteResult(executeResult);
121+
jobRepository.getJobLogDao().updateById(logEntity);
122+
return logEntity;
123+
}
124+
125+
/**
126+
* 执行前 保存执行记录
127+
*
128+
* @param jobEntity
129+
* @param executorName
130+
* @param executeTime
131+
* @return 返回执行记录id
132+
*/
133+
private Long saveLogBeforeExecute(SmartJobEntity jobEntity,
134+
String executorName,
135+
LocalDateTime executeTime) {
136+
Integer jobId = jobEntity.getJobId();
137+
// 保存执行记录
138+
SmartJobLogEntity logEntity = new SmartJobLogEntity();
139+
logEntity.setJobId(jobId);
140+
logEntity.setJobName(jobEntity.getJobName());
141+
logEntity.setParam(jobEntity.getParam());
142+
logEntity.setSuccessFlag(true);
143+
// 执行开始时间
144+
logEntity.setExecuteStartTime(executeTime);
145+
logEntity.setCreateName(executorName);
124146
logEntity.setIp(SmartIpUtil.getLocalFirstIp());
125147
logEntity.setProcessId(SmartJobUtil.getProcessId());
126148
logEntity.setProgramPath(SmartJobUtil.getProgramPath());
127-
logEntity.setCreateName(executorName);
128149

129-
// 更新上次执行
150+
// 更新最后执行时间
130151
SmartJobEntity updateJobEntity = new SmartJobEntity();
131152
updateJobEntity.setJobId(jobId);
132-
updateJobEntity.setLastExecuteTime(startTime);
133-
134-
// 持久化数据
153+
updateJobEntity.setLastExecuteTime(executeTime);
135154
jobRepository.saveLog(logEntity, updateJobEntity);
136-
return logEntity;
155+
return logEntity.getLogId();
137156
}
138157

139158
/**

smart-admin-api/sa-base/src/main/java/net/lab1024/sa/base/module/support/job/repository/SmartJobRepository.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public SmartJobDao getJobDao() {
2525
return jobDao;
2626
}
2727

28+
public SmartJobLogDao getJobLogDao() {
29+
return jobLogDao;
30+
}
31+
2832
/**
2933
* 保存执行记录
3034
*
@@ -38,5 +42,4 @@ public void saveLog(SmartJobLogEntity logEntity, SmartJobEntity jobEntity) {
3842
jobEntity.setLastExecuteLogId(logEntity.getLogId());
3943
jobDao.updateById(jobEntity);
4044
}
41-
4245
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package net.lab1024.sa.base.module.support.redis;
2+
3+
import net.lab1024.sa.base.common.util.SmartStringUtil;
4+
import org.redisson.config.Config;
5+
import org.redisson.spring.starter.RedissonAutoConfigurationCustomizer;
6+
import org.springframework.stereotype.Component;
7+
8+
/**
9+
*
10+
* redission对于password 为空处理有问题,重新设置下
11+
*
12+
* @Author 1024创新实验室-主任:卓大
13+
* @Date 2024/7/16 01:04:18
14+
* @Wechat zhuoda1024
15+
16+
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> ,Since 2012
17+
*/
18+
19+
@Component
20+
public class RedissonPasswordConfigurationCustomizer implements RedissonAutoConfigurationCustomizer {
21+
@Override
22+
public void customize(Config configuration) {
23+
if (configuration.isSingleConfig() && SmartStringUtil.isEmpty(configuration.useSingleServer().getPassword())) {
24+
configuration.useSingleServer().setPassword(null);
25+
}
26+
27+
if (configuration.isClusterConfig() && SmartStringUtil.isEmpty(configuration.useClusterServers().getPassword())) {
28+
configuration.useClusterServers().setPassword(null);
29+
}
30+
if (configuration.isSentinelConfig() && SmartStringUtil.isEmpty(configuration.useSentinelServers().getPassword())) {
31+
configuration.useSentinelServers().setPassword(null);
32+
}
33+
}
34+
}

smart-admin-api/sa-base/src/main/resources/pre/sa-base.yaml

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
spring:
22
# 数据库连接信息
33
datasource:
4-
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
4+
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
55
username: root
6-
password: Zhuoda#1024lab
7-
initial-size: 5
8-
min-idle: 5
9-
max-active: 20
6+
password: Zhuoda1024lab
7+
initial-size: 2
8+
min-idle: 2
9+
max-active: 10
1010
max-wait: 60000
1111
time-between-eviction-runs-millis: 60000
1212
min-evictable-idle-time-millis: 300000
13-
driver-class-name: com.mysql.cj.jdbc.Driver
13+
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
1414
filters: stat
1515
druid:
1616
username: druid
17-
password: 1024lab
17+
password: 1024
1818
login:
1919
enabled: false
2020
method:
@@ -29,9 +29,9 @@ spring:
2929
timeout: 10000ms
3030
lettuce:
3131
pool:
32-
max-active: 50
33-
min-idle: 5
34-
max-idle: 5
32+
max-active: 5
33+
min-idle: 1
34+
max-idle: 3
3535
max-wait: 30000ms
3636

3737
# 上传文件大小配置
@@ -74,9 +74,9 @@ file:
7474
upload-path: /home/smart_admin_v3/upload/ #文件上传目录
7575
url-prefix:
7676
cloud:
77-
region: oss-cn-qingdao
78-
endpoint: oss-cn-qingdao.aliyuncs.com
79-
bucket-name: common
77+
region: oss-cn-hangzhou
78+
endpoint: oss-cn-hangzhou.aliyuncs.com
79+
bucket-name: 1024lab-smart-admin
8080
access-key:
8181
secret-key:
8282
url-prefix: https://${file.storage.cloud.bucket-name}.${file.storage.cloud.endpoint}/

smart_admin_v3.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -1245,14 +1245,14 @@ INSERT INTO `t_smart_job` VALUES (2, '示例任务2', 'net.lab1024.sa.base.modul
12451245
-- ----------------------------
12461246
DROP TABLE IF EXISTS `t_smart_job_log`;
12471247
CREATE TABLE `t_smart_job_log` (
1248-
`log_id` int(0) NOT NULL AUTO_INCREMENT,
1248+
`log_id` bigint(0) NOT NULL AUTO_INCREMENT,
12491249
`job_id` int(0) NOT NULL COMMENT '任务id',
12501250
`job_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务名称',
12511251
`param` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '执行参数',
12521252
`success_flag` tinyint(1) NOT NULL COMMENT '是否成功',
12531253
`execute_start_time` datetime(0) NOT NULL COMMENT '执行开始时间',
1254-
`execute_time_millis` int(0) NOT NULL COMMENT '执行时长',
1255-
`execute_end_time` datetime(0) NOT NULL COMMENT '执行结束时间',
1254+
`execute_time_millis` int(0) NULL DEFAULT NULL COMMENT '执行时长',
1255+
`execute_end_time` datetime(0) NULL DEFAULT NULL COMMENT '执行结束时间',
12561256
`execute_result` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
12571257
`ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ip',
12581258
`process_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '进程id',

0 commit comments

Comments
 (0)