|
@@ -112,187 +112,191 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
@Override
|
|
|
@Async("asyncPoolTaskExecutor")
|
|
|
public void createTask(Task task) {
|
|
|
- //1.任务日志
|
|
|
- Long createUser = task.getCreateUser();
|
|
|
- if (createUser != null) {
|
|
|
- R<User> userR = userClient.userInfoById(createUser);
|
|
|
- if (userR.isSuccess()) {
|
|
|
- List<TaskLog> logs = new ArrayList<>();
|
|
|
- List<ProjectAuth> auths = new ArrayList<>();
|
|
|
- List<ProjectGroup> groups = new ArrayList<>();
|
|
|
+ Long projectId = task.getProjectId();
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
+ if (project != null) {
|
|
|
+ //1.任务日志
|
|
|
+ Long createUser = task.getCreateUser();
|
|
|
+ if (createUser != null) {
|
|
|
+ R<User> userR = userClient.userInfoById(createUser);
|
|
|
+ if (userR.isSuccess()) {
|
|
|
+ List<TaskLog> logs = new ArrayList<>();
|
|
|
+ List<ProjectAuth> auths = new ArrayList<>();
|
|
|
+ List<ProjectGroup> groups = new ArrayList<>();
|
|
|
|
|
|
- TaskLog log = new TaskLog();
|
|
|
- log.setTaskId(task.getId());
|
|
|
- log.setContent(userR.getData().getName() + " 创建了任务");
|
|
|
- log.setCreateDept(task.getCreateDept());
|
|
|
- log.setCreateUser(task.getCreateUser());
|
|
|
- log.setUpdateUser(task.getUpdateUser());
|
|
|
- log.setCreateTime(DateUtil.now());
|
|
|
- log.setUpdateTime(DateUtil.now());
|
|
|
- logs.add(log);
|
|
|
- Long orgDeptId = null;
|
|
|
- if (task.getOrgDeptId() != null && task.getOrgDeptId() > 0L) {
|
|
|
- orgDeptId = task.getOrgDeptId();
|
|
|
- R<Dept> dept = sysClient.getDept(orgDeptId);
|
|
|
- if (dept.isSuccess()) {
|
|
|
- TaskLog taskLog = new TaskLog();
|
|
|
- taskLog.setTaskId(task.getId());
|
|
|
- taskLog.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
|
|
|
- taskLog.setCreateDept(task.getCreateDept());
|
|
|
- taskLog.setCreateUser(task.getCreateUser());
|
|
|
- taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
- taskLog.setCreateTime(DateUtil.now());
|
|
|
- taskLog.setUpdateTime(DateUtil.now());
|
|
|
- logs.add(taskLog);
|
|
|
- }
|
|
|
- }
|
|
|
- if (task.getExecuteDept() != null && task.getExecuteDept() > 0L) {
|
|
|
- Long executeDept = task.getExecuteDept();
|
|
|
- R<Dept> dept = sysClient.getDept(executeDept);
|
|
|
- if (dept.isSuccess()) {
|
|
|
- TaskLog taskLog = new TaskLog();
|
|
|
- taskLog.setTaskId(task.getId());
|
|
|
- taskLog.setContent(userR.getData().getName() + " 指定了任务执行部门为" + dept.getData().getDeptName());
|
|
|
- taskLog.setCreateDept(task.getCreateDept());
|
|
|
- taskLog.setCreateUser(task.getCreateUser());
|
|
|
- taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
- taskLog.setCreateTime(DateUtil.now());
|
|
|
- taskLog.setUpdateTime(DateUtil.now());
|
|
|
- logs.add(taskLog);
|
|
|
+ TaskLog log = new TaskLog();
|
|
|
+ log.setTaskId(task.getId());
|
|
|
+ log.setContent(userR.getData().getName() + " 创建了任务");
|
|
|
+ log.setCreateDept(task.getCreateDept());
|
|
|
+ log.setCreateUser(task.getCreateUser());
|
|
|
+ log.setUpdateUser(task.getUpdateUser());
|
|
|
+ log.setCreateTime(DateUtil.now());
|
|
|
+ log.setUpdateTime(DateUtil.now());
|
|
|
+ logs.add(log);
|
|
|
+ Long orgDeptId = null;
|
|
|
+ if (task.getOrgDeptId() != null && task.getOrgDeptId() > 0L) {
|
|
|
+ orgDeptId = task.getOrgDeptId();
|
|
|
+ R<Dept> dept = sysClient.getDept(orgDeptId);
|
|
|
+ if (dept.isSuccess()) {
|
|
|
+ TaskLog taskLog = new TaskLog();
|
|
|
+ taskLog.setTaskId(task.getId());
|
|
|
+ taskLog.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
|
|
|
+ taskLog.setCreateDept(task.getCreateDept());
|
|
|
+ taskLog.setCreateUser(task.getCreateUser());
|
|
|
+ taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
+ taskLog.setCreateTime(DateUtil.now());
|
|
|
+ taskLog.setUpdateTime(DateUtil.now());
|
|
|
+ logs.add(taskLog);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- if (task.getProjectManager() != null && task.getProjectManager() > 0L) {
|
|
|
- Long projectManager = task.getProjectManager();
|
|
|
- //1.任务动态
|
|
|
- R<User> userR1 = userClient.userInfoById(projectManager);
|
|
|
- if (userR1.isSuccess()) {
|
|
|
- TaskLog taskLog = new TaskLog();
|
|
|
- taskLog.setTaskId(task.getId());
|
|
|
- taskLog.setContent(userR.getData().getName() + " 指定了项目经理为 " + userR1.getData().getName());
|
|
|
- taskLog.setCreateDept(task.getCreateDept());
|
|
|
- taskLog.setCreateUser(task.getCreateUser());
|
|
|
- taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
- taskLog.setCreateTime(DateUtil.now());
|
|
|
- taskLog.setUpdateTime(DateUtil.now());
|
|
|
- logs.add(taskLog);
|
|
|
-
|
|
|
- String deptStr = userR1.getData().getDeptId();
|
|
|
- if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
|
|
|
- //2.项目权限
|
|
|
- Long deptId = Func.firstLong(deptStr);
|
|
|
- ProjectAuth auth = new ProjectAuth();
|
|
|
- auth.setTopDept(orgDeptId);
|
|
|
- auth.setUserDept(deptId);
|
|
|
- auth.setProjectId(task.getProjectId());
|
|
|
- auth.setUserId(projectManager);
|
|
|
- auths.add(auth);
|
|
|
-
|
|
|
- //3.项目组成员
|
|
|
- ProjectGroup group = new ProjectGroup();
|
|
|
- group.setInviteDept(null);
|
|
|
- group.setProjectId(task.getProjectId());
|
|
|
- group.setStageId(task.getStageId());
|
|
|
- group.setBeInvitedDept(orgDeptId);
|
|
|
- group.setUserId(projectManager);
|
|
|
- groups.add(group);
|
|
|
+ if (task.getExecuteDept() != null && task.getExecuteDept() > 0L) {
|
|
|
+ Long executeDept = task.getExecuteDept();
|
|
|
+ R<Dept> dept = sysClient.getDept(executeDept);
|
|
|
+ if (dept.isSuccess()) {
|
|
|
+ TaskLog taskLog = new TaskLog();
|
|
|
+ taskLog.setTaskId(task.getId());
|
|
|
+ taskLog.setContent(userR.getData().getName() + " 指定了任务执行部门为" + dept.getData().getDeptName());
|
|
|
+ taskLog.setCreateDept(task.getCreateDept());
|
|
|
+ taskLog.setCreateUser(task.getCreateUser());
|
|
|
+ taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
+ taskLog.setCreateTime(DateUtil.now());
|
|
|
+ taskLog.setUpdateTime(DateUtil.now());
|
|
|
+ logs.add(taskLog);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- }
|
|
|
- if (StringUtil.isNotBlank(task.getExecuteUser())) {
|
|
|
- List<Long> userIds = Func.toLongList(task.getExecuteUser());
|
|
|
- List<String> str = new ArrayList<>();
|
|
|
- Long finalOrgDeptId = orgDeptId;
|
|
|
- userIds.forEach(userId -> {
|
|
|
- R<User> rpc = userClient.userInfoById(userId);
|
|
|
- if (rpc.isSuccess()) {
|
|
|
- str.add(rpc.getData().getName());
|
|
|
+ if (task.getProjectManager() != null && task.getProjectManager() > 0L) {
|
|
|
+ Long projectManager = task.getProjectManager();
|
|
|
+ //1.任务动态
|
|
|
+ R<User> userR1 = userClient.userInfoById(projectManager);
|
|
|
+ if (userR1.isSuccess()) {
|
|
|
+ TaskLog taskLog = new TaskLog();
|
|
|
+ taskLog.setTaskId(task.getId());
|
|
|
+ taskLog.setContent(userR.getData().getName() + " 指定了项目经理为 " + userR1.getData().getName());
|
|
|
+ taskLog.setCreateDept(task.getCreateDept());
|
|
|
+ taskLog.setCreateUser(task.getCreateUser());
|
|
|
+ taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
+ taskLog.setCreateTime(DateUtil.now());
|
|
|
+ taskLog.setUpdateTime(DateUtil.now());
|
|
|
+ logs.add(taskLog);
|
|
|
|
|
|
- String deptStr = rpc.getData().getDeptId();
|
|
|
- if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId != null) {
|
|
|
+ String deptStr = userR1.getData().getDeptId();
|
|
|
+ if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
|
|
|
+ //2.项目权限
|
|
|
Long deptId = Func.firstLong(deptStr);
|
|
|
ProjectAuth auth = new ProjectAuth();
|
|
|
- auth.setTopDept(finalOrgDeptId);
|
|
|
+ auth.setTopDept(orgDeptId);
|
|
|
auth.setUserDept(deptId);
|
|
|
- auth.setProjectId(task.getProjectId());
|
|
|
- auth.setUserId(userId);
|
|
|
+ auth.setProjectId(projectId);
|
|
|
+ auth.setUserId(projectManager);
|
|
|
auths.add(auth);
|
|
|
|
|
|
- //项目组成员
|
|
|
+ //3.项目组成员
|
|
|
ProjectGroup group = new ProjectGroup();
|
|
|
- group.setInviteDept(null);
|
|
|
- group.setProjectId(task.getProjectId());
|
|
|
+ group.setInviteDept(project.getCompetentUnit());
|
|
|
+ group.setProjectId(projectId);
|
|
|
group.setStageId(task.getStageId());
|
|
|
- group.setBeInvitedDept(finalOrgDeptId);
|
|
|
- group.setUserId(userId);
|
|
|
+ group.setBeInvitedDept(orgDeptId);
|
|
|
+ group.setUserId(projectManager);
|
|
|
groups.add(group);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- });
|
|
|
- if (!CollectionUtils.isEmpty(str)) {
|
|
|
- TaskLog taskLog = new TaskLog();
|
|
|
- taskLog.setTaskId(task.getId());
|
|
|
- taskLog.setContent(userR.getData().getName() + " 指定了任务执行者 " + Func.join(str));
|
|
|
- taskLog.setCreateDept(task.getCreateDept());
|
|
|
- taskLog.setCreateUser(task.getCreateUser());
|
|
|
- taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
- taskLog.setCreateTime(DateUtil.now());
|
|
|
- taskLog.setUpdateTime(DateUtil.now());
|
|
|
- logs.add(taskLog);
|
|
|
}
|
|
|
- }
|
|
|
+ if (StringUtil.isNotBlank(task.getExecuteUser())) {
|
|
|
+ List<Long> userIds = Func.toLongList(task.getExecuteUser());
|
|
|
+ List<String> str = new ArrayList<>();
|
|
|
+ Long finalOrgDeptId = orgDeptId;
|
|
|
+ userIds.forEach(userId -> {
|
|
|
+ R<User> rpc = userClient.userInfoById(userId);
|
|
|
+ if (rpc.isSuccess()) {
|
|
|
+ str.add(rpc.getData().getName());
|
|
|
|
|
|
- if (StringUtil.isNotBlank(task.getCheckUser())) {
|
|
|
- List<Long> userIds = Func.toLongList(task.getCheckUser());
|
|
|
- List<String> str = new ArrayList<>();
|
|
|
- Long finalOrgDeptId1 = orgDeptId;
|
|
|
- userIds.forEach(userId -> {
|
|
|
- R<User> rpc = userClient.userInfoById(userId);
|
|
|
- if (rpc.isSuccess()) {
|
|
|
- str.add(rpc.getData().getName());
|
|
|
+ String deptStr = rpc.getData().getDeptId();
|
|
|
+ if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId != null) {
|
|
|
+ Long deptId = Func.firstLong(deptStr);
|
|
|
+ ProjectAuth auth = new ProjectAuth();
|
|
|
+ auth.setTopDept(finalOrgDeptId);
|
|
|
+ auth.setUserDept(deptId);
|
|
|
+ auth.setProjectId(projectId);
|
|
|
+ auth.setUserId(userId);
|
|
|
+ auths.add(auth);
|
|
|
|
|
|
- String deptStr = rpc.getData().getDeptId();
|
|
|
- if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId1 != null) {
|
|
|
- Long deptId = Func.firstLong(deptStr);
|
|
|
- ProjectAuth auth = new ProjectAuth();
|
|
|
- auth.setTopDept(finalOrgDeptId1);
|
|
|
- auth.setUserDept(deptId);
|
|
|
- auth.setProjectId(task.getProjectId());
|
|
|
- auth.setUserId(userId);
|
|
|
- auths.add(auth);
|
|
|
+ //项目组成员
|
|
|
+ ProjectGroup group = new ProjectGroup();
|
|
|
+ group.setInviteDept(project.getCompetentUnit());
|
|
|
+ group.setProjectId(projectId);
|
|
|
+ group.setStageId(task.getStageId());
|
|
|
+ group.setBeInvitedDept(finalOrgDeptId);
|
|
|
+ group.setUserId(userId);
|
|
|
+ groups.add(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!CollectionUtils.isEmpty(str)) {
|
|
|
+ TaskLog taskLog = new TaskLog();
|
|
|
+ taskLog.setTaskId(task.getId());
|
|
|
+ taskLog.setContent(userR.getData().getName() + " 指定了任务执行者 " + Func.join(str));
|
|
|
+ taskLog.setCreateDept(task.getCreateDept());
|
|
|
+ taskLog.setCreateUser(task.getCreateUser());
|
|
|
+ taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
+ taskLog.setCreateTime(DateUtil.now());
|
|
|
+ taskLog.setUpdateTime(DateUtil.now());
|
|
|
+ logs.add(taskLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- ProjectGroup group = new ProjectGroup();
|
|
|
- group.setInviteDept(null);
|
|
|
- group.setProjectId(task.getProjectId());
|
|
|
- group.setStageId(task.getStageId());
|
|
|
- group.setBeInvitedDept(finalOrgDeptId1);
|
|
|
- group.setUserId(userId);
|
|
|
- groups.add(group);
|
|
|
+ if (StringUtil.isNotBlank(task.getCheckUser())) {
|
|
|
+ List<Long> userIds = Func.toLongList(task.getCheckUser());
|
|
|
+ List<String> str = new ArrayList<>();
|
|
|
+ Long finalOrgDeptId1 = orgDeptId;
|
|
|
+ userIds.forEach(userId -> {
|
|
|
+ R<User> rpc = userClient.userInfoById(userId);
|
|
|
+ if (rpc.isSuccess()) {
|
|
|
+ str.add(rpc.getData().getName());
|
|
|
+
|
|
|
+ String deptStr = rpc.getData().getDeptId();
|
|
|
+ if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId1 != null) {
|
|
|
+ Long deptId = Func.firstLong(deptStr);
|
|
|
+ ProjectAuth auth = new ProjectAuth();
|
|
|
+ auth.setTopDept(finalOrgDeptId1);
|
|
|
+ auth.setUserDept(deptId);
|
|
|
+ auth.setProjectId(projectId);
|
|
|
+ auth.setUserId(userId);
|
|
|
+ auths.add(auth);
|
|
|
+
|
|
|
+ ProjectGroup group = new ProjectGroup();
|
|
|
+ group.setInviteDept(project.getCompetentUnit());
|
|
|
+ group.setProjectId(projectId);
|
|
|
+ group.setStageId(task.getStageId());
|
|
|
+ group.setBeInvitedDept(finalOrgDeptId1);
|
|
|
+ group.setUserId(userId);
|
|
|
+ groups.add(group);
|
|
|
+ }
|
|
|
}
|
|
|
+ });
|
|
|
+ if (!CollectionUtils.isEmpty(str)) {
|
|
|
+ TaskLog taskLog = new TaskLog();
|
|
|
+ taskLog.setTaskId(task.getId());
|
|
|
+ taskLog.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(str));
|
|
|
+ taskLog.setCreateDept(task.getCreateDept());
|
|
|
+ taskLog.setCreateUser(task.getCreateUser());
|
|
|
+ taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
+ taskLog.setCreateTime(DateUtil.now());
|
|
|
+ taskLog.setUpdateTime(DateUtil.now());
|
|
|
+ logs.add(taskLog);
|
|
|
}
|
|
|
- });
|
|
|
- if (!CollectionUtils.isEmpty(str)) {
|
|
|
- TaskLog taskLog = new TaskLog();
|
|
|
- taskLog.setTaskId(task.getId());
|
|
|
- taskLog.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(str));
|
|
|
- taskLog.setCreateDept(task.getCreateDept());
|
|
|
- taskLog.setCreateUser(task.getCreateUser());
|
|
|
- taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
- taskLog.setCreateTime(DateUtil.now());
|
|
|
- taskLog.setUpdateTime(DateUtil.now());
|
|
|
- logs.add(taskLog);
|
|
|
}
|
|
|
- }
|
|
|
- taskLogService.saveBatch(logs);
|
|
|
- if (!CollectionUtils.isEmpty(auths)) {
|
|
|
- projectAuthService.saveBatch(auths);
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(groups)) {
|
|
|
- projectGroupService.saveBatch(groups);
|
|
|
+ taskLogService.saveBatch(logs);
|
|
|
+ if (!CollectionUtils.isEmpty(auths)) {
|
|
|
+ projectAuthService.saveBatch(auths);
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(groups)) {
|
|
|
+ projectGroupService.saveBatch(groups);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ // todo 2.任务下发通知
|
|
|
}
|
|
|
- // todo 2.任务下发通知
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -450,6 +454,13 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
log4.setUpdateTime(DateUtil.now());
|
|
|
logs.add(log4);
|
|
|
}
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ // todo 提交任务
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ //确认任务
|
|
|
+ break;
|
|
|
}
|
|
|
taskLogService.saveBatch(logs);
|
|
|
if (!CollectionUtils.isEmpty(auths)) {
|