|
@@ -7,6 +7,7 @@ import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springblade.system.user.entity.User;
|
|
@@ -68,27 +69,25 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
String deptIdStr = user.getDeptId();
|
|
|
if (deptIdStr != null) {
|
|
|
Long deptId = Func.firstLong(deptIdStr);
|
|
|
- if (!deptId.equals(project.getCompetentUnit())) {
|
|
|
- ProjectAuth auth = new ProjectAuth();
|
|
|
- auth.setUserId(user.getUserId());
|
|
|
- R<Dept> rpc = sysClient.getDept(deptId);
|
|
|
- if (rpc.isSuccess()) {
|
|
|
- String ancestors = rpc.getData().getAncestors();
|
|
|
- if (ancestors != null && ancestors.contains(String.valueOf(ZERO))) {
|
|
|
- List<Long> longList = Func.toLongList(ancestors);
|
|
|
- if (!CollectionUtils.isEmpty(longList)) {
|
|
|
- if (longList.size() > 2) {
|
|
|
- auth.setTopDept(longList.get(1));
|
|
|
- } else {
|
|
|
- auth.setTopDept(Long.valueOf(deptIdStr));
|
|
|
- }
|
|
|
+ ProjectAuth auth = new ProjectAuth();
|
|
|
+ auth.setUserId(user.getUserId());
|
|
|
+ R<Dept> rpc = sysClient.getDept(deptId);
|
|
|
+ if (rpc.isSuccess()) {
|
|
|
+ String ancestors = rpc.getData().getAncestors();
|
|
|
+ if (ancestors != null && ancestors.contains(String.valueOf(ZERO))) {
|
|
|
+ List<Long> parentIds = Func.toLongList(ancestors);
|
|
|
+ if (!CollectionUtils.isEmpty(parentIds)) {
|
|
|
+ if (parentIds.size() > 2) {
|
|
|
+ auth.setTopDept(parentIds.get(1));
|
|
|
+ } else {
|
|
|
+ auth.setTopDept(Long.valueOf(deptIdStr));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- auth.setUserDept(deptId);
|
|
|
- auth.setProjectId(project.getId());
|
|
|
- projectAuthService.save(auth);
|
|
|
}
|
|
|
+ auth.setUserDept(deptId);
|
|
|
+ auth.setProjectId(project.getId());
|
|
|
+ projectAuthService.save(auth);
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -108,6 +107,7 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
R<User> userR = userClient.userInfoById(createUser);
|
|
|
if (userR.isSuccess()) {
|
|
|
List<TaskLog> logs = new ArrayList<>();
|
|
|
+ List<ProjectAuth> auths = new ArrayList<>();
|
|
|
TaskLog log = new TaskLog();
|
|
|
log.setTaskId(task.getId());
|
|
|
log.setContent(userR.getData().getName() + " 创建了任务");
|
|
@@ -117,8 +117,9 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
log.setCreateTime(DateUtil.now());
|
|
|
log.setUpdateTime(DateUtil.now());
|
|
|
logs.add(log);
|
|
|
- if (task.getOrgDeptId() != null) {
|
|
|
- Long orgDeptId = task.getOrgDeptId();
|
|
|
+ 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();
|
|
@@ -132,7 +133,7 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
logs.add(taskLog);
|
|
|
}
|
|
|
}
|
|
|
- if (task.getExecuteDept() != null) {
|
|
|
+ if (task.getExecuteDept() != null && task.getExecuteDept() > 0L) {
|
|
|
Long executeDept = task.getExecuteDept();
|
|
|
R<Dept> dept = sysClient.getDept(executeDept);
|
|
|
if (dept.isSuccess()) {
|
|
@@ -147,8 +148,9 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
logs.add(taskLog);
|
|
|
}
|
|
|
}
|
|
|
- if (task.getProjectManager() != null) {
|
|
|
+ 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();
|
|
@@ -160,15 +162,39 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
taskLog.setCreateTime(DateUtil.now());
|
|
|
taskLog.setUpdateTime(DateUtil.now());
|
|
|
logs.add(taskLog);
|
|
|
+
|
|
|
+ //2.项目权限
|
|
|
+ String deptStr = userR1.getData().getDeptId();
|
|
|
+ if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- if (task.getExecuteUser() != null) {
|
|
|
+ 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());
|
|
|
+
|
|
|
+ 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(task.getProjectId());
|
|
|
+ auth.setUserId(userId);
|
|
|
+ auths.add(auth);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
if (!CollectionUtils.isEmpty(str)) {
|
|
@@ -183,7 +209,44 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
logs.add(taskLog);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ 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(task.getProjectId());
|
|
|
+ auth.setUserId(userId);
|
|
|
+ auths.add(auth);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// todo 2.任务下发通知
|
|
@@ -195,9 +258,10 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
R<User> userR = userClient.userInfoById(userId);
|
|
|
if (userR.isSuccess()) {
|
|
|
List<TaskLog> logs = new ArrayList<>();
|
|
|
+ List<ProjectAuth> auths = new ArrayList<>();
|
|
|
+ Long orgDeptId = task.getOrgDeptId();
|
|
|
switch (type) {
|
|
|
case 1:
|
|
|
- Long orgDeptId = task.getOrgDeptId();
|
|
|
R<Dept> dept = sysClient.getDept(orgDeptId);
|
|
|
if (dept.isSuccess()) {
|
|
|
TaskLog log = new TaskLog();
|
|
@@ -239,6 +303,17 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
log2.setCreateTime(DateUtil.now());
|
|
|
log2.setUpdateTime(DateUtil.now());
|
|
|
logs.add(log2);
|
|
|
+
|
|
|
+ String deptStr = userR1.getData().getDeptId();
|
|
|
+ if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
break;
|
|
|
case 4:
|
|
@@ -248,6 +323,17 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
R<User> rpc = userClient.userInfoById(id);
|
|
|
if (rpc.isSuccess()) {
|
|
|
str.add(rpc.getData().getName());
|
|
|
+
|
|
|
+ String deptStr = rpc.getData().getDeptId();
|
|
|
+ if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
|
|
|
+ Long deptId = Func.firstLong(deptStr);
|
|
|
+ ProjectAuth auth = new ProjectAuth();
|
|
|
+ auth.setTopDept(orgDeptId);
|
|
|
+ auth.setUserDept(deptId);
|
|
|
+ auth.setProjectId(task.getProjectId());
|
|
|
+ auth.setUserId(id);
|
|
|
+ auths.add(auth);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
if (!CollectionUtils.isEmpty(str)) {
|
|
@@ -262,9 +348,42 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
logs.add(log3);
|
|
|
}
|
|
|
break;
|
|
|
- }
|
|
|
+ case 5:
|
|
|
+ List<Long> checkUsers = Func.toLongList(task.getCheckUser());
|
|
|
+ List<String> checks = new ArrayList<>();
|
|
|
+ checkUsers.forEach(id -> {
|
|
|
+ R<User> rpc = userClient.userInfoById(id);
|
|
|
+ if (rpc.isSuccess()) {
|
|
|
+ checks.add(rpc.getData().getName());
|
|
|
|
|
|
+ String deptStr = rpc.getData().getDeptId();
|
|
|
+ if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
|
|
|
+ Long deptId = Func.firstLong(deptStr);
|
|
|
+ ProjectAuth auth = new ProjectAuth();
|
|
|
+ auth.setTopDept(orgDeptId);
|
|
|
+ auth.setUserDept(deptId);
|
|
|
+ auth.setProjectId(task.getProjectId());
|
|
|
+ auth.setUserId(id);
|
|
|
+ auths.add(auth);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!CollectionUtils.isEmpty(checks)) {
|
|
|
+ TaskLog log4 = new TaskLog();
|
|
|
+ log4.setTaskId(task.getId());
|
|
|
+ log4.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(checks));
|
|
|
+ log4.setCreateDept(task.getCreateDept());
|
|
|
+ log4.setCreateUser(task.getCreateUser());
|
|
|
+ log4.setUpdateUser(task.getUpdateUser());
|
|
|
+ log4.setCreateTime(DateUtil.now());
|
|
|
+ log4.setUpdateTime(DateUtil.now());
|
|
|
+ logs.add(log4);
|
|
|
+ }
|
|
|
+ }
|
|
|
taskLogService.saveBatch(logs);
|
|
|
+ if (!CollectionUtils.isEmpty(auths)) {
|
|
|
+ projectAuthService.saveBatch(auths);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|