工单系统初始化数据
This commit is contained in:
@@ -56,8 +56,7 @@ public class MybatisPlusConfig {
|
|||||||
"sys_tenant",
|
"sys_tenant",
|
||||||
"sys_dictionary",
|
"sys_dictionary",
|
||||||
"sys_dictionary_data",
|
"sys_dictionary_data",
|
||||||
"apps_test_data",
|
"apps_test_data"
|
||||||
"oa_task_count"
|
|
||||||
).contains(tableName);
|
).contains(tableName);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ package com.gxwebsoft.common.core.utils;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
|
import cn.hutool.crypto.symmetric.AES;
|
||||||
|
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
|
||||||
import com.gxwebsoft.common.core.Constants;
|
import com.gxwebsoft.common.core.Constants;
|
||||||
import com.gxwebsoft.common.core.web.ApiResult;
|
import com.gxwebsoft.common.core.web.ApiResult;
|
||||||
import com.gxwebsoft.common.system.entity.Dict;
|
|
||||||
import com.gxwebsoft.common.system.entity.Role;
|
import com.gxwebsoft.common.system.entity.Role;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -26,6 +29,7 @@ import java.util.stream.Collectors;
|
|||||||
* @since 2017-06-10 10:10:22
|
* @since 2017-06-10 10:10:22
|
||||||
*/
|
*/
|
||||||
public class CommonUtil {
|
public class CommonUtil {
|
||||||
|
|
||||||
// 生成uuid的字符
|
// 生成uuid的字符
|
||||||
private static final String[] chars = new String[]{
|
private static final String[] chars = new String[]{
|
||||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
||||||
@@ -269,4 +273,22 @@ public class CommonUtil {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AES aes(){
|
||||||
|
// 随机生成密钥
|
||||||
|
byte[] key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
|
||||||
|
return SecureUtil.aes(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 机密文本
|
||||||
|
public static String encrypt(String text){
|
||||||
|
final AES aes = aes();
|
||||||
|
return aes.encryptHex(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解密
|
||||||
|
public static String decrypt(String encrypt){
|
||||||
|
final AES aes = aes();
|
||||||
|
return aes.decryptStr(encrypt, CharsetUtil.CHARSET_UTF_8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ public class TaskController extends BaseController {
|
|||||||
public ApiResult<?> update(@RequestBody Task task) {
|
public ApiResult<?> update(@RequestBody Task task) {
|
||||||
if (taskService.updateById(task)) {
|
if (taskService.updateById(task)) {
|
||||||
// 更新统计表
|
// 更新统计表
|
||||||
|
task.setLoginUserId(getLoginUserId());
|
||||||
taskService.updateCount(task);
|
taskService.updateCount(task);
|
||||||
return success("修改成功");
|
return success("修改成功");
|
||||||
}
|
}
|
||||||
@@ -199,7 +200,7 @@ public class TaskController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@Scheduled(cron="*/1 * * * * *")
|
@Scheduled(cron="*/1 * * * * *")
|
||||||
public void updateProgressTask() {
|
public void updateProgressTask() {
|
||||||
System.out.println("定时任务开始:updateProgressTask = " + DateUtil.now());
|
// System.out.println("定时任务开始:updateProgressTask = " + DateUtil.now());
|
||||||
TaskParam taskParam = new TaskParam();
|
TaskParam taskParam = new TaskParam();
|
||||||
taskParam.setProgress(TOBECONFIRMED);
|
taskParam.setProgress(TOBECONFIRMED);
|
||||||
taskParam.setLimit(10L);
|
taskParam.setLimit(10L);
|
||||||
@@ -211,7 +212,6 @@ public class TaskController extends BaseController {
|
|||||||
if (!CollectionUtils.isEmpty(list)) {
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
list.forEach(task -> {
|
list.forEach(task -> {
|
||||||
try {
|
try {
|
||||||
System.out.println("task = " + task);
|
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
Date newDate = DateUtil.offset(task.getUpdateTime(), DateField.MINUTE, 1);
|
Date newDate = DateUtil.offset(task.getUpdateTime(), DateField.MINUTE, 1);
|
||||||
Date date1 = df.parse(newDate.toString());
|
Date date1 = df.parse(newDate.toString());
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -137,4 +138,8 @@ public class Task implements Serializable {
|
|||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Integer loginUserId;
|
private Integer loginUserId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "机密信息")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String confidential;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package com.gxwebsoft.oa.entity;
|
package com.gxwebsoft.oa.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.gxwebsoft.common.system.entity.User;
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工单回复记录表
|
* 工单回复记录表
|
||||||
*
|
*
|
||||||
@@ -38,6 +37,9 @@ public class TaskRecord implements Serializable {
|
|||||||
@ApiModelProperty(value = "任务内容")
|
@ApiModelProperty(value = "任务内容")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "机密信息")
|
||||||
|
private String confidential;
|
||||||
|
|
||||||
@ApiModelProperty(value = "工单附件")
|
@ApiModelProperty(value = "工单附件")
|
||||||
private String files;
|
private String files;
|
||||||
|
|
||||||
@@ -81,5 +83,4 @@ public class TaskRecord implements Serializable {
|
|||||||
@ApiModelProperty(value = "回复者")
|
@ApiModelProperty(value = "回复者")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
<if test="param.userId != null">
|
<if test="param.userId != null">
|
||||||
AND a.user_id = #{param.userId}
|
AND a.user_id = #{param.userId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="param.roleCode != null">
|
||||||
|
AND a.role_code = #{param.roleCode}
|
||||||
|
</if>
|
||||||
<if test="param.pending != null">
|
<if test="param.pending != null">
|
||||||
AND a.pending = #{param.pending}
|
AND a.pending = #{param.pending}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -60,4 +60,7 @@ public class TaskCountParam extends BaseParam {
|
|||||||
@ApiModelProperty(value = "角色ID")
|
@ApiModelProperty(value = "角色ID")
|
||||||
private Integer roleId;
|
private Integer roleId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "角色标识")
|
||||||
|
private String roleCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public class TaskCountServiceImpl extends ServiceImpl<TaskCountMapper, TaskCount
|
|||||||
final PageResult<TaskCount> result = new PageResult<>(list, page.getTotal());
|
final PageResult<TaskCount> result = new PageResult<>(list, page.getTotal());
|
||||||
// 请求主服务器获取用户信息
|
// 请求主服务器获取用户信息
|
||||||
final List<TaskCount> taskCountList = result.getList();
|
final List<TaskCount> taskCountList = result.getList();
|
||||||
|
System.out.println("taskCountList = " + taskCountList);
|
||||||
final Set<Integer> userIds = taskCountList.stream().map(TaskCount::getUserId).collect(Collectors.toSet());
|
final Set<Integer> userIds = taskCountList.stream().map(TaskCount::getUserId).collect(Collectors.toSet());
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put("userIds", userIds);
|
map.put("userIds", userIds);
|
||||||
@@ -61,9 +62,12 @@ public class TaskCountServiceImpl extends ServiceImpl<TaskCountMapper, TaskCount
|
|||||||
.timeout(20000)//超时,毫秒
|
.timeout(20000)//超时,毫秒
|
||||||
.execute().body();
|
.execute().body();
|
||||||
|
|
||||||
|
System.out.println("response = " + response);
|
||||||
|
|
||||||
final ApiResult<PageResult<User>> userResult = JSONObject.parseObject(response, new TypeReference<ApiResult<PageResult<User>>>() {
|
final ApiResult<PageResult<User>> userResult = JSONObject.parseObject(response, new TypeReference<ApiResult<PageResult<User>>>() {
|
||||||
});
|
});
|
||||||
final Map<Integer, List<User>> collect = userResult.getData().getList().stream().collect(Collectors.groupingBy(User::getUserId));
|
final Map<Integer, List<User>> collect = userResult.getData().getList().stream().collect(Collectors.groupingBy(User::getUserId));
|
||||||
|
System.out.println("collect = " + collect);
|
||||||
if (!CollectionUtils.isEmpty(collect)) {
|
if (!CollectionUtils.isEmpty(collect)) {
|
||||||
taskCountList.forEach(item -> {
|
taskCountList.forEach(item -> {
|
||||||
final List<User> users = collect.get(item.getUserId());
|
final List<User> users = collect.get(item.getUserId());
|
||||||
|
|||||||
@@ -199,8 +199,14 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|||||||
// 查询受理人已处理的总工单数量
|
// 查询受理人已处理的总工单数量
|
||||||
final int commanderTotalTasks = count(new LambdaQueryWrapper<Task>().eq(Task::getStatus, TASK_STATUS_1).eq(Task::getCommander,task.getCommander()));
|
final int commanderTotalTasks = count(new LambdaQueryWrapper<Task>().eq(Task::getStatus, TASK_STATUS_1).eq(Task::getCommander,task.getCommander()));
|
||||||
|
|
||||||
// 统计项目发起人
|
// 统计工单发起人
|
||||||
|
if (taskCountService.count(new LambdaQueryWrapper<TaskCount>().eq(TaskCount::getUserId,task.getUserId())) == 0) {
|
||||||
|
final TaskCount taskCount = new TaskCount();
|
||||||
|
taskCount.setUserId(task.getUserId());
|
||||||
|
taskCountService.save(taskCount);
|
||||||
|
}
|
||||||
TaskCount user = taskCountService.getByUserId(task.getUserId());
|
TaskCount user = taskCountService.getByUserId(task.getUserId());
|
||||||
|
System.out.println("user = " + user);
|
||||||
user.setPending(userPendingTasks);
|
user.setPending(userPendingTasks);
|
||||||
user.setToday(userTodayTasks);
|
user.setToday(userTodayTasks);
|
||||||
user.setMonth(userMonthTasks);
|
user.setMonth(userMonthTasks);
|
||||||
@@ -208,7 +214,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|||||||
user.setTotal(userTotalTasks);
|
user.setTotal(userTotalTasks);
|
||||||
taskCountService.updateById(user);
|
taskCountService.updateById(user);
|
||||||
if(!user.getUserId().equals(task.getCommander())){
|
if(!user.getUserId().equals(task.getCommander())){
|
||||||
// 统计项目受理人
|
// 统计工单受理人
|
||||||
TaskCount commander = taskCountService.getByUserId(task.getCommander());
|
TaskCount commander = taskCountService.getByUserId(task.getCommander());
|
||||||
if(commander != null){
|
if(commander != null){
|
||||||
commander.setPending(commanderPendingTasks);
|
commander.setPending(commanderPendingTasks);
|
||||||
@@ -220,13 +226,18 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 统计公司数据
|
// 统计公司数据
|
||||||
final TaskCount company = taskCountService.getByUserId(0);
|
if (taskCountService.count(new LambdaQueryWrapper<TaskCount>().eq(TaskCount::getUserId,0).eq(TaskCount::getRoleCode, "superAdmin")) == 0) {
|
||||||
company.setPending(pendingTasks);
|
final TaskCount taskCount = new TaskCount();
|
||||||
company.setToday(todayTasks);
|
taskCount.setRoleCode("superAdmin");
|
||||||
company.setMonth(monthTasks);
|
taskCountService.save(taskCount);
|
||||||
company.setYear(yearTasks);
|
}
|
||||||
company.setTotal(totalTasks);
|
final TaskCount superAdmin = taskCountService.getOne(new LambdaQueryWrapper<TaskCount>().eq(TaskCount::getUserId,0).eq(TaskCount::getRoleCode, "superAdmin"));
|
||||||
taskCountService.updateById(company);
|
superAdmin.setPending(pendingTasks);
|
||||||
|
superAdmin.setToday(todayTasks);
|
||||||
|
superAdmin.setMonth(monthTasks);
|
||||||
|
superAdmin.setYear(yearTasks);
|
||||||
|
superAdmin.setTotal(totalTasks);
|
||||||
|
taskCountService.updateById(superAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.gxwebsoft;
|
package com.gxwebsoft;
|
||||||
|
|
||||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
@@ -14,6 +13,12 @@ public class TestMain {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGenJwtKey() {
|
public void testGenJwtKey() {
|
||||||
System.out.println(JwtUtil.encodeKey(JwtUtil.randomKey()));
|
// System.out.println(JwtUtil.encodeKey(JwtUtil.randomKey()));
|
||||||
|
|
||||||
|
// final String encrypt = CommonUtil.encrypt("123");
|
||||||
|
// System.out.println("encrypt = " + encrypt);
|
||||||
|
//
|
||||||
|
// final String decrypt = CommonUtil.decrypt(encrypt);
|
||||||
|
// System.out.println("decrypt = " + decrypt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user