Skip to content

Commit

Permalink
【V3.5.0】1、【新增】轻量级定时任务 SmartJob;2、【新增】站内信;3、【新增】个人中心;4、【新增】岗位管理;5、【优化】…
Browse files Browse the repository at this point in the history
…部门员工管理
  • Loading branch information
zhuoda committed Jul 16, 2024
1 parent ba115a0 commit 50f5324
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 37 deletions.
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public ResponseDTO<String> batchRemoveRoleEmployee(RoleEmployeeUpdateForm roleEm
* 批量添加角色的成员员工
*
*/
@Transactional(rollbackFor = Throwable.class)
public ResponseDTO<String> batchAddRoleEmployee(RoleEmployeeUpdateForm roleEmployeeUpdateForm) {
Long roleId = roleEmployeeUpdateForm.getRoleId();
List<Long> employeeIdList = roleEmployeeUpdateForm.getEmployeeIdList();
Expand All @@ -121,10 +120,8 @@ public ResponseDTO<String> batchAddRoleEmployee(RoleEmployeeUpdateForm roleEmplo
.map(employeeId -> new RoleEmployeeEntity(roleId, employeeId))
.collect(Collectors.toList());
}
// 防重,删除此次角色员工数据
roleEmployeeDao.batchDeleteEmployeeRole(roleId, employeeIdList);
// 保存数据
roleEmployeeManager.saveRoleEmployee(roleEmployeeList);
roleEmployeeManager.saveRoleEmployee(roleId, roleEmployeeList);
return ResponseDTO.ok();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ public void run() {
* @param executorName
*/
public SmartJobLogEntity execute(String executorName) {
// 执行计时
// 保存执行记录
LocalDateTime startTime = LocalDateTime.now();
Long logId = this.saveLogBeforeExecute(jobEntity, executorName, startTime);

// 执行计时
StopWatch stopWatch = new StopWatch();
stopWatch.start();

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

// 保存执行记录
Integer jobId = jobEntity.getJobId();
// 更新执行记录
SmartJobLogEntity logEntity = new SmartJobLogEntity();
logEntity.setJobId(jobId);
logEntity.setJobName(jobEntity.getJobName());
logEntity.setParam(jobEntity.getParam());
logEntity.setLogId(logId);
logEntity.setSuccessFlag(successFlag);
// 执行开始 结束时间
logEntity.setExecuteStartTime(startTime);
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(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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public SmartJobDao getJobDao() {
return jobDao;
}

public SmartJobLogDao getJobLogDao() {
return jobLogDao;
}

/**
* 保存执行记录
*
Expand All @@ -38,5 +42,4 @@ public void saveLog(SmartJobLogEntity logEntity, SmartJobEntity jobEntity) {
jobEntity.setLastExecuteLogId(logEntity.getLogId());
jobDao.updateById(jobEntity);
}

}
Original file line number Diff line number Diff line change
@@ -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 [email protected]
* @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);
}
}
}
26 changes: 13 additions & 13 deletions smart-admin-api/sa-base/src/main/resources/pre/sa-base.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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

# 上传文件大小配置
Expand Down Expand Up @@ -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}/
Expand Down
6 changes: 3 additions & 3 deletions smart_admin_v3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 50f5324

Please sign in to comment.