|  | @@ -77,7 +77,7 @@ public class AsyncServiceImpl implements IAsyncService {
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		//3.如果主管单位和当前登录用户不是同一机构
 | 
	
		
			
				|  |  | +		//权限
 | 
	
		
			
				|  |  |  		String deptIdStr = user.getDeptId();
 | 
	
		
			
				|  |  |  		if (deptIdStr != null) {
 | 
	
		
			
				|  |  |  			Long deptId = Func.firstLong(deptIdStr);
 | 
	
	
		
			
				|  | @@ -89,7 +89,7 @@ public class AsyncServiceImpl implements IAsyncService {
 | 
	
		
			
				|  |  |  				if (ancestors != null && ancestors.contains(String.valueOf(ZERO))) {
 | 
	
		
			
				|  |  |  					List<Long> parentIds = Func.toLongList(ancestors);
 | 
	
		
			
				|  |  |  					if (!CollectionUtils.isEmpty(parentIds)) {
 | 
	
		
			
				|  |  | -						if (parentIds.size() > 2) {
 | 
	
		
			
				|  |  | +						if (parentIds.size() > 1) {
 | 
	
		
			
				|  |  |  							auth.setTopDept(parentIds.get(1));
 | 
	
		
			
				|  |  |  						} else {
 | 
	
		
			
				|  |  |  							auth.setTopDept(Long.valueOf(deptIdStr));
 | 
	
	
		
			
				|  | @@ -122,12 +122,11 @@ public class AsyncServiceImpl implements IAsyncService {
 | 
	
		
			
				|  |  |  				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.setRelatedUser(String.valueOf(userR.getData().getId()));
 | 
	
		
			
				|  |  |  					log.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  |  					log.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  |  					log.setUpdateUser(task.getUpdateUser());
 | 
	
	
		
			
				|  | @@ -142,163 +141,31 @@ public class AsyncServiceImpl implements IAsyncService {
 | 
	
		
			
				|  |  |  							TaskLog taskLog = new TaskLog();
 | 
	
		
			
				|  |  |  							taskLog.setTaskId(task.getId());
 | 
	
		
			
				|  |  |  							taskLog.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
 | 
	
		
			
				|  |  | +							taskLog.setRelatedUser(String.valueOf(userR.getData().getId()));
 | 
	
		
			
				|  |  |  							taskLog.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  |  							taskLog.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  |  							taskLog.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  |  							try {
 | 
	
		
			
				|  |  | -								Thread.sleep(1000);
 | 
	
		
			
				|  |  | +								Thread.sleep(3000);
 | 
	
		
			
				|  |  |  							} catch (InterruptedException e) {
 | 
	
		
			
				|  |  |  								System.out.println("休眠异常:" + e.getMessage());
 | 
	
		
			
				|  |  |  							}
 | 
	
		
			
				|  |  |  							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);
 | 
	
		
			
				|  |  | -						}
 | 
	
		
			
				|  |  | -					}
 | 
	
		
			
				|  |  | -					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(projectId);
 | 
	
		
			
				|  |  | -								auth.setUserId(projectManager);
 | 
	
		
			
				|  |  | -								auths.add(auth);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -								//3.项目组成员
 | 
	
		
			
				|  |  | -								ProjectGroup group = new ProjectGroup();
 | 
	
		
			
				|  |  | -								group.setInviteDept(project.getCompetentUnit());
 | 
	
		
			
				|  |  | -								group.setProjectId(projectId);
 | 
	
		
			
				|  |  | -								group.setStageId(task.getStageId());
 | 
	
		
			
				|  |  | -								group.setBeInvitedDept(orgDeptId);
 | 
	
		
			
				|  |  | -								group.setUserId(projectManager);
 | 
	
		
			
				|  |  | -								groups.add(group);
 | 
	
		
			
				|  |  | -							}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +							ProjectAuth auth = new ProjectAuth();
 | 
	
		
			
				|  |  | +							auth.setTopDept(orgDeptId);
 | 
	
		
			
				|  |  | +							auth.setProjectId(task.getProjectId());
 | 
	
		
			
				|  |  | +							auth.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | +							auth.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | +							auth.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | +							auth.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +							auth.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +							projectAuthService.save(auth);
 | 
	
		
			
				|  |  |  						}
 | 
	
		
			
				|  |  |  					}
 | 
	
		
			
				|  |  | -					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(projectId);
 | 
	
		
			
				|  |  | -									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);
 | 
	
		
			
				|  |  | -						}
 | 
	
		
			
				|  |  | -					}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -					/*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);
 | 
	
		
			
				|  |  | -						}
 | 
	
		
			
				|  |  | -					}*/
 | 
	
		
			
				|  |  |  					taskLogService.saveBatch(logs);
 | 
	
		
			
				|  |  | -					if (!CollectionUtils.isEmpty(auths)) {
 | 
	
		
			
				|  |  | -						projectAuthService.saveBatch(auths);
 | 
	
		
			
				|  |  | -					}
 | 
	
		
			
				|  |  | -					if (!CollectionUtils.isEmpty(groups)) {
 | 
	
		
			
				|  |  | -						projectGroupService.saveBatch(groups);
 | 
	
		
			
				|  |  | -					}
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			// todo 2.任务下发通知
 | 
	
	
		
			
				|  | @@ -315,172 +182,180 @@ public class AsyncServiceImpl implements IAsyncService {
 | 
	
		
			
				|  |  |  			List<ProjectGroup> groups = new ArrayList<>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			Long orgDeptId = task.getOrgDeptId();
 | 
	
		
			
				|  |  | -			switch (type) {
 | 
	
		
			
				|  |  | -				case 1:
 | 
	
		
			
				|  |  | -					R<Dept> dept = sysClient.getDept(orgDeptId);
 | 
	
		
			
				|  |  | -					if (dept.isSuccess()) {
 | 
	
		
			
				|  |  | -						TaskLog log = new TaskLog();
 | 
	
		
			
				|  |  | -						log.setTaskId(task.getId());
 | 
	
		
			
				|  |  | -						log.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
 | 
	
		
			
				|  |  | -						log.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | -						log.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | -						log.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | -						log.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | -						log.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | -						logs.add(log);
 | 
	
		
			
				|  |  | +			if (type == 1) {
 | 
	
		
			
				|  |  | +				R<Dept> dept = sysClient.getDept(orgDeptId);
 | 
	
		
			
				|  |  | +				if (dept.isSuccess()) {
 | 
	
		
			
				|  |  | +					TaskLog log = new TaskLog();
 | 
	
		
			
				|  |  | +					log.setTaskId(task.getId());
 | 
	
		
			
				|  |  | +					log.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
 | 
	
		
			
				|  |  | +					log.setRelatedUser(String.valueOf(userR.getData().getId()));
 | 
	
		
			
				|  |  | +					log.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | +					log.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | +					log.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | +					log.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +					log.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +					logs.add(log);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +					ProjectAuth auth = new ProjectAuth();
 | 
	
		
			
				|  |  | +					auth.setTopDept(orgDeptId);
 | 
	
		
			
				|  |  | +					auth.setProjectId(task.getProjectId());
 | 
	
		
			
				|  |  | +					auths.add(auth);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			} else if (type == 2) {
 | 
	
		
			
				|  |  | +				Long executeDept = task.getExecuteDept();
 | 
	
		
			
				|  |  | +				R<Dept> dept1 = sysClient.getDept(executeDept);
 | 
	
		
			
				|  |  | +				if (dept1.isSuccess()) {
 | 
	
		
			
				|  |  | +					TaskLog log1 = new TaskLog();
 | 
	
		
			
				|  |  | +					log1.setTaskId(task.getId());
 | 
	
		
			
				|  |  | +					log1.setContent(userR.getData().getName() + " 指定了任务执行部门为" + dept1.getData().getDeptName());
 | 
	
		
			
				|  |  | +					log1.setRelatedUser(String.valueOf(userR.getData().getId()));
 | 
	
		
			
				|  |  | +					log1.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | +					log1.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | +					log1.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | +					log1.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +					log1.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +					logs.add(log1);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +					ProjectAuth auth = new ProjectAuth();
 | 
	
		
			
				|  |  | +					auth.setTopDept(orgDeptId);
 | 
	
		
			
				|  |  | +					auth.setUserDept(executeDept);
 | 
	
		
			
				|  |  | +					auth.setProjectId(task.getProjectId());
 | 
	
		
			
				|  |  | +					auths.add(auth);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			} else if (type == 3) {
 | 
	
		
			
				|  |  | +				Long projectManager = task.getProjectManager();
 | 
	
		
			
				|  |  | +				R<User> userR1 = userClient.userInfoById(projectManager);
 | 
	
		
			
				|  |  | +				if (userR1.isSuccess()) {
 | 
	
		
			
				|  |  | +					TaskLog log2 = new TaskLog();
 | 
	
		
			
				|  |  | +					log2.setTaskId(task.getId());
 | 
	
		
			
				|  |  | +					log2.setContent(userR.getData().getName() + " 指定了项目经理为 " + userR1.getData().getName());
 | 
	
		
			
				|  |  | +					List<Long> users = new ArrayList<>();
 | 
	
		
			
				|  |  | +					users.add(userR.getData().getId());
 | 
	
		
			
				|  |  | +					users.add(userR1.getData().getId());
 | 
	
		
			
				|  |  | +					log2.setRelatedUser(Func.join(users));
 | 
	
		
			
				|  |  | +					log2.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | +					log2.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | +					log2.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | +					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 2:
 | 
	
		
			
				|  |  | -					Long executeDept = task.getExecuteDept();
 | 
	
		
			
				|  |  | -					R<Dept> dept1 = sysClient.getDept(executeDept);
 | 
	
		
			
				|  |  | -					if (dept1.isSuccess()) {
 | 
	
		
			
				|  |  | -						TaskLog log1 = new TaskLog();
 | 
	
		
			
				|  |  | -						log1.setTaskId(task.getId());
 | 
	
		
			
				|  |  | -						log1.setContent(userR.getData().getName() + " 指定了任务执行部门为" + dept1.getData().getDeptName());
 | 
	
		
			
				|  |  | -						log1.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | -						log1.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | -						log1.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | -						log1.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | -						log1.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | -						logs.add(log1);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -						ProjectAuth auth = new ProjectAuth();
 | 
	
		
			
				|  |  | -						auth.setTopDept(orgDeptId);
 | 
	
		
			
				|  |  | -						auth.setUserDept(executeDept);
 | 
	
		
			
				|  |  | -						auth.setProjectId(task.getProjectId());
 | 
	
		
			
				|  |  | -						auths.add(auth);
 | 
	
		
			
				|  |  | +						//项目组
 | 
	
		
			
				|  |  | +						ProjectGroup group = new ProjectGroup();
 | 
	
		
			
				|  |  | +						group.setInviteDept(null);
 | 
	
		
			
				|  |  | +						group.setProjectId(task.getProjectId());
 | 
	
		
			
				|  |  | +						group.setStageId(task.getStageId());
 | 
	
		
			
				|  |  | +						group.setBeInvitedDept(orgDeptId);
 | 
	
		
			
				|  |  | +						group.setUserId(projectManager);
 | 
	
		
			
				|  |  | +						groups.add(group);
 | 
	
		
			
				|  |  |  					}
 | 
	
		
			
				|  |  | -					break;
 | 
	
		
			
				|  |  | -				case 3:
 | 
	
		
			
				|  |  | -					Long projectManager = task.getProjectManager();
 | 
	
		
			
				|  |  | -					R<User> userR1 = userClient.userInfoById(projectManager);
 | 
	
		
			
				|  |  | -					if (userR1.isSuccess()) {
 | 
	
		
			
				|  |  | -						TaskLog log2 = new TaskLog();
 | 
	
		
			
				|  |  | -						log2.setTaskId(task.getId());
 | 
	
		
			
				|  |  | -						log2.setContent(userR.getData().getName() + " 指定了项目经理为 " + userR1.getData().getName());
 | 
	
		
			
				|  |  | -						log2.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | -						log2.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | -						log2.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | -						log2.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | -						log2.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | -						logs.add(log2);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -						String deptStr = userR1.getData().getDeptId();
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			} else if (type == 4) {
 | 
	
		
			
				|  |  | +				List<Long> userIds = Func.toLongList(task.getExecuteUser());
 | 
	
		
			
				|  |  | +				List<String> str = new ArrayList<>();
 | 
	
		
			
				|  |  | +				userIds.forEach(id -> {
 | 
	
		
			
				|  |  | +					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(projectManager);
 | 
	
		
			
				|  |  | +							auth.setUserId(id);
 | 
	
		
			
				|  |  |  							auths.add(auth);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -							//项目组
 | 
	
		
			
				|  |  |  							ProjectGroup group = new ProjectGroup();
 | 
	
		
			
				|  |  |  							group.setInviteDept(null);
 | 
	
		
			
				|  |  |  							group.setProjectId(task.getProjectId());
 | 
	
		
			
				|  |  |  							group.setStageId(task.getStageId());
 | 
	
		
			
				|  |  |  							group.setBeInvitedDept(orgDeptId);
 | 
	
		
			
				|  |  | -							group.setUserId(projectManager);
 | 
	
		
			
				|  |  | +							group.setUserId(id);
 | 
	
		
			
				|  |  |  							groups.add(group);
 | 
	
		
			
				|  |  |  						}
 | 
	
		
			
				|  |  |  					}
 | 
	
		
			
				|  |  | -					break;
 | 
	
		
			
				|  |  | -				case 4:
 | 
	
		
			
				|  |  | -					List<Long> userIds = Func.toLongList(task.getExecuteUser());
 | 
	
		
			
				|  |  | -					List<String> str = new ArrayList<>();
 | 
	
		
			
				|  |  | -					userIds.forEach(id -> {
 | 
	
		
			
				|  |  | -						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);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -								ProjectGroup group = new ProjectGroup();
 | 
	
		
			
				|  |  | -								group.setInviteDept(null);
 | 
	
		
			
				|  |  | -								group.setProjectId(task.getProjectId());
 | 
	
		
			
				|  |  | -								group.setStageId(task.getStageId());
 | 
	
		
			
				|  |  | -								group.setBeInvitedDept(orgDeptId);
 | 
	
		
			
				|  |  | -								group.setUserId(id);
 | 
	
		
			
				|  |  | -								groups.add(group);
 | 
	
		
			
				|  |  | -							}
 | 
	
		
			
				|  |  | -						}
 | 
	
		
			
				|  |  | -					});
 | 
	
		
			
				|  |  | -					if (!CollectionUtils.isEmpty(str)) {
 | 
	
		
			
				|  |  | -						TaskLog log3 = new TaskLog();
 | 
	
		
			
				|  |  | -						log3.setTaskId(task.getId());
 | 
	
		
			
				|  |  | -						log3.setContent(userR.getData().getName() + " 指定了任务执行者 " + Func.join(str));
 | 
	
		
			
				|  |  | -						log3.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | -						log3.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | -						log3.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | -						log3.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | -						log3.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | -						logs.add(log3);
 | 
	
		
			
				|  |  | -					}
 | 
	
		
			
				|  |  | -					break;
 | 
	
		
			
				|  |  | -				case 5:
 | 
	
		
			
				|  |  | -					Long first = task.getFirstCheckUser();
 | 
	
		
			
				|  |  | -					Long second = task.getSecondCheckUser();
 | 
	
		
			
				|  |  | -					List<Long> checkUsers = Arrays.asList(first, second);
 | 
	
		
			
				|  |  | -					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);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -								ProjectGroup group = new ProjectGroup();
 | 
	
		
			
				|  |  | -								group.setInviteDept(null);
 | 
	
		
			
				|  |  | -								group.setProjectId(task.getProjectId());
 | 
	
		
			
				|  |  | -								group.setStageId(task.getStageId());
 | 
	
		
			
				|  |  | -								group.setBeInvitedDept(orgDeptId);
 | 
	
		
			
				|  |  | -								group.setUserId(id);
 | 
	
		
			
				|  |  | -								groups.add(group);
 | 
	
		
			
				|  |  | -							}
 | 
	
		
			
				|  |  | +				});
 | 
	
		
			
				|  |  | +				if (!CollectionUtils.isEmpty(str)) {
 | 
	
		
			
				|  |  | +					TaskLog log3 = new TaskLog();
 | 
	
		
			
				|  |  | +					log3.setTaskId(task.getId());
 | 
	
		
			
				|  |  | +					log3.setContent(userR.getData().getName() + " 指定了任务执行者 " + Func.join(str));
 | 
	
		
			
				|  |  | +					List<Long> users = new ArrayList<>();
 | 
	
		
			
				|  |  | +					users.add(userR.getData().getId());
 | 
	
		
			
				|  |  | +					users.addAll(userIds);
 | 
	
		
			
				|  |  | +					log3.setRelatedUser(Func.join(users));
 | 
	
		
			
				|  |  | +					log3.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | +					log3.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | +					log3.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | +					log3.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +					log3.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +					logs.add(log3);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			} else if (type == 5) {
 | 
	
		
			
				|  |  | +				Long first = task.getFirstCheckUser();
 | 
	
		
			
				|  |  | +				Long second = task.getSecondCheckUser();
 | 
	
		
			
				|  |  | +				List<Long> checkUsers = Arrays.asList(first, second);
 | 
	
		
			
				|  |  | +				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);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +							ProjectGroup group = new ProjectGroup();
 | 
	
		
			
				|  |  | +							group.setInviteDept(null);
 | 
	
		
			
				|  |  | +							group.setProjectId(task.getProjectId());
 | 
	
		
			
				|  |  | +							group.setStageId(task.getStageId());
 | 
	
		
			
				|  |  | +							group.setBeInvitedDept(orgDeptId);
 | 
	
		
			
				|  |  | +							group.setUserId(id);
 | 
	
		
			
				|  |  | +							groups.add(group);
 | 
	
		
			
				|  |  |  						}
 | 
	
		
			
				|  |  | -					});
 | 
	
		
			
				|  |  | -					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);
 | 
	
		
			
				|  |  |  					}
 | 
	
		
			
				|  |  | -					break;
 | 
	
		
			
				|  |  | -				case 6:
 | 
	
		
			
				|  |  | -					// todo 提交任务
 | 
	
		
			
				|  |  | -					break;
 | 
	
		
			
				|  |  | -				case 7:
 | 
	
		
			
				|  |  | -					//确认任务
 | 
	
		
			
				|  |  | -					break;
 | 
	
		
			
				|  |  | +				});
 | 
	
		
			
				|  |  | +				if (!CollectionUtils.isEmpty(checks)) {
 | 
	
		
			
				|  |  | +					TaskLog log4 = new TaskLog();
 | 
	
		
			
				|  |  | +					log4.setTaskId(task.getId());
 | 
	
		
			
				|  |  | +					log4.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(checks));
 | 
	
		
			
				|  |  | +					List<Long> users = new ArrayList<>();
 | 
	
		
			
				|  |  | +					users.add(userR.getData().getId());
 | 
	
		
			
				|  |  | +					users.addAll(checkUsers);
 | 
	
		
			
				|  |  | +					log4.setRelatedUser(Func.join(users));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +					log4.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | +					log4.setCreateUser(task.getCreateUser());
 | 
	
		
			
				|  |  | +					log4.setUpdateUser(task.getUpdateUser());
 | 
	
		
			
				|  |  | +					log4.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +					log4.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +					logs.add(log4);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			} else if (type == 6) {
 | 
	
		
			
				|  |  | +				//todo  提交、确认任务
 | 
	
		
			
				|  |  | +			} else if (type == 7) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  			taskLogService.saveBatch(logs);
 | 
	
		
			
				|  |  |  			if (!CollectionUtils.isEmpty(auths)) {
 | 
	
		
			
				|  |  |  				projectAuthService.saveBatch(auths);
 | 
	
	
		
			
				|  | @@ -494,15 +369,17 @@ public class AsyncServiceImpl implements IAsyncService {
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	@Async("asyncPoolTaskExecutor")
 | 
	
		
			
				|  |  |  	public void submitTaskMessage(Long userId, Task task) {
 | 
	
		
			
				|  |  | -		Long createUser = task.getCreateUser();
 | 
	
		
			
				|  |  | +		Long firstCheckUser = task.getFirstCheckUser();
 | 
	
		
			
				|  |  | +		Long secondCheckUser = task.getSecondCheckUser();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  		Long projectId = task.getProjectId();
 | 
	
		
			
				|  |  |  		String title = task.getTitle();
 | 
	
		
			
				|  |  |  		R<User> userR = userClient.userInfoById(userId);
 | 
	
		
			
				|  |  |  		if (userR.isSuccess()) {
 | 
	
		
			
				|  |  | +			List<IndexMessage> list = new ArrayList<>();
 | 
	
		
			
				|  |  |  			IndexMessage message = new IndexMessage();
 | 
	
		
			
				|  |  |  			message.setCategory(1);
 | 
	
		
			
				|  |  | -			//发送给审查人和项目经理
 | 
	
		
			
				|  |  | -			message.setToUser(createUser);
 | 
	
		
			
				|  |  | +			message.setToUser(firstCheckUser);
 | 
	
		
			
				|  |  |  			message.setContent(userR.getData().getName() + "上传了" + title + "任务的文件,请查阅");
 | 
	
		
			
				|  |  |  			message.setOpenUrl("/task");
 | 
	
		
			
				|  |  |  			message.setCreateDept(task.getCreateDept());
 | 
	
	
		
			
				|  | @@ -510,7 +387,21 @@ public class AsyncServiceImpl implements IAsyncService {
 | 
	
		
			
				|  |  |  			message.setUpdateUser(userId);
 | 
	
		
			
				|  |  |  			message.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  |  			message.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | -			indexMessageService.save(message);
 | 
	
		
			
				|  |  | +			list.add(message);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			IndexMessage msg = new IndexMessage();
 | 
	
		
			
				|  |  | +			msg.setCategory(1);
 | 
	
		
			
				|  |  | +			msg.setToUser(secondCheckUser);
 | 
	
		
			
				|  |  | +			msg.setContent(userR.getData().getName() + "上传了" + title + "任务的文件,请查阅");
 | 
	
		
			
				|  |  | +			msg.setOpenUrl("/task");
 | 
	
		
			
				|  |  | +			msg.setCreateDept(task.getCreateDept());
 | 
	
		
			
				|  |  | +			msg.setCreateUser(userId);
 | 
	
		
			
				|  |  | +			msg.setUpdateUser(userId);
 | 
	
		
			
				|  |  | +			msg.setCreateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +			msg.setUpdateTime(DateUtil.now());
 | 
	
		
			
				|  |  | +			list.add(msg);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			indexMessageService.saveBatch(list);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 |