|
@@ -1,16 +1,26 @@
|
|
package com.wtkj.service.impl;
|
|
package com.wtkj.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
|
+import com.tencentcloudapi.common.Credential;
|
|
|
|
+import com.tencentcloudapi.common.profile.ClientProfile;
|
|
|
|
+import com.tencentcloudapi.common.profile.HttpProfile;
|
|
|
|
+import com.tencentcloudapi.sms.v20190711.SmsClient;
|
|
|
|
+import com.tencentcloudapi.sms.v20190711.models.SendSmsRequest;
|
|
|
|
+import com.tencentcloudapi.sms.v20190711.models.SendSmsResponse;
|
|
|
|
+import com.wtkj.config.NacosConfigValue;
|
|
import com.wtkj.entity.*;
|
|
import com.wtkj.entity.*;
|
|
import com.wtkj.mapper.ProjectMapper;
|
|
import com.wtkj.mapper.ProjectMapper;
|
|
import com.wtkj.service.*;
|
|
import com.wtkj.service.*;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.springblade.core.secure.BladeUser;
|
|
import org.springblade.core.secure.BladeUser;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
|
|
+import org.springblade.core.tool.utils.CollectionUtil;
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.Func;
|
|
import org.springblade.core.tool.utils.StringUtil;
|
|
import org.springblade.core.tool.utils.StringUtil;
|
|
import org.springblade.system.entity.Dept;
|
|
import org.springblade.system.entity.Dept;
|
|
|
|
+import org.springblade.system.entity.Role;
|
|
import org.springblade.system.feign.ISysClient;
|
|
import org.springblade.system.feign.ISysClient;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.entity.User;
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
@@ -19,8 +29,10 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
-import java.util.Arrays;
|
|
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.wtkj.config.MagicValue.ZERO;
|
|
import static com.wtkj.config.MagicValue.ZERO;
|
|
|
|
|
|
@@ -31,6 +43,7 @@ import static com.wtkj.config.MagicValue.ZERO;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
|
+@Slf4j
|
|
public class AsyncServiceImpl implements IAsyncService {
|
|
public class AsyncServiceImpl implements IAsyncService {
|
|
|
|
|
|
private final ITypeAndStageService typeAndStageService;
|
|
private final ITypeAndStageService typeAndStageService;
|
|
@@ -39,9 +52,9 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
private final ISysClient sysClient;
|
|
private final ISysClient sysClient;
|
|
private final IUserClient userClient;
|
|
private final IUserClient userClient;
|
|
private final ITaskLogService taskLogService;
|
|
private final ITaskLogService taskLogService;
|
|
- private final IIndexMessageService indexMessageService;
|
|
|
|
private final IProjectGroupService projectGroupService;
|
|
private final IProjectGroupService projectGroupService;
|
|
private final ProjectMapper projectMapper;
|
|
private final ProjectMapper projectMapper;
|
|
|
|
+ private final IIndexMessageService indexMessageService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Async("asyncPoolTaskExecutor")
|
|
@Async("asyncPoolTaskExecutor")
|
|
@@ -104,11 +117,6 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- @Async("asyncPoolTaskExecutor")
|
|
|
|
- @Override
|
|
|
|
- public void removeProject(List<Long> longList) {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Async("asyncPoolTaskExecutor")
|
|
@Async("asyncPoolTaskExecutor")
|
|
@@ -116,44 +124,72 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
Long projectId = task.getProjectId();
|
|
Long projectId = task.getProjectId();
|
|
Project project = projectMapper.selectById(projectId);
|
|
Project project = projectMapper.selectById(projectId);
|
|
if (project != null) {
|
|
if (project != null) {
|
|
|
|
+ //修改项目下任务数量
|
|
|
|
+ project.setTodoTask(project.getTodoTask() + 1);
|
|
|
|
+ projectMapper.updateById(project);
|
|
|
|
+
|
|
//1.任务日志
|
|
//1.任务日志
|
|
Long createUser = task.getCreateUser();
|
|
Long createUser = task.getCreateUser();
|
|
|
|
+ Long projectManager = task.getProjectManager();
|
|
|
|
+ Long firstCheckUser = task.getFirstCheckUser();
|
|
|
|
+ Long secondCheckUser = task.getSecondCheckUser();
|
|
|
|
+ String executeUser = task.getExecuteUser();
|
|
|
|
+
|
|
|
|
+ List<ProjectAuth> auths = new ArrayList<>();
|
|
|
|
+ List<ProjectGroup> groups = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
|
+ userIds.add(createUser);
|
|
|
|
+ if (projectManager != null) {
|
|
|
|
+ userIds.add(projectManager);
|
|
|
|
+ }
|
|
|
|
+ if (firstCheckUser != null) {
|
|
|
|
+ userIds.add(firstCheckUser);
|
|
|
|
+ }
|
|
|
|
+ if (secondCheckUser != null) {
|
|
|
|
+ userIds.add(secondCheckUser);
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isNotBlank(executeUser)) {
|
|
|
|
+ userIds.addAll(Func.toLongList(executeUser));
|
|
|
|
+ }
|
|
|
|
+
|
|
if (createUser != null) {
|
|
if (createUser != null) {
|
|
R<User> userR = userClient.userInfoById(createUser);
|
|
R<User> userR = userClient.userInfoById(createUser);
|
|
if (userR.isSuccess()) {
|
|
if (userR.isSuccess()) {
|
|
List<TaskLog> logs = new ArrayList<>();
|
|
List<TaskLog> logs = new ArrayList<>();
|
|
|
|
|
|
TaskLog log = new TaskLog();
|
|
TaskLog log = new TaskLog();
|
|
|
|
+ log.setId(IdWorker.getId());
|
|
log.setTaskId(task.getId());
|
|
log.setTaskId(task.getId());
|
|
log.setContent(userR.getData().getName() + " 创建了任务");
|
|
log.setContent(userR.getData().getName() + " 创建了任务");
|
|
log.setRelatedUser(String.valueOf(userR.getData().getId()));
|
|
log.setRelatedUser(String.valueOf(userR.getData().getId()));
|
|
log.setCreateDept(task.getCreateDept());
|
|
log.setCreateDept(task.getCreateDept());
|
|
log.setCreateUser(task.getCreateUser());
|
|
log.setCreateUser(task.getCreateUser());
|
|
log.setUpdateUser(task.getUpdateUser());
|
|
log.setUpdateUser(task.getUpdateUser());
|
|
- log.setCreateTime(DateUtil.now());
|
|
|
|
- log.setUpdateTime(DateUtil.now());
|
|
|
|
|
|
+ Date time = DateUtil.now();
|
|
|
|
+ log.setCreateTime(time);
|
|
|
|
+ log.setUpdateTime(time);
|
|
logs.add(log);
|
|
logs.add(log);
|
|
Long orgDeptId = null;
|
|
Long orgDeptId = null;
|
|
if (task.getOrgDeptId() != null && task.getOrgDeptId() > 0L) {
|
|
if (task.getOrgDeptId() != null && task.getOrgDeptId() > 0L) {
|
|
orgDeptId = task.getOrgDeptId();
|
|
orgDeptId = task.getOrgDeptId();
|
|
R<Dept> dept = sysClient.getDept(orgDeptId);
|
|
R<Dept> dept = sysClient.getDept(orgDeptId);
|
|
if (dept.isSuccess()) {
|
|
if (dept.isSuccess()) {
|
|
|
|
+ //日志
|
|
TaskLog taskLog = new TaskLog();
|
|
TaskLog taskLog = new TaskLog();
|
|
|
|
+ taskLog.setId(IdWorker.getId());
|
|
taskLog.setTaskId(task.getId());
|
|
taskLog.setTaskId(task.getId());
|
|
taskLog.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
|
|
taskLog.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
|
|
- taskLog.setRelatedUser(String.valueOf(userR.getData().getId()));
|
|
|
|
|
|
+ taskLog.setRelatedUser(Func.join(userIds));
|
|
taskLog.setCreateDept(task.getCreateDept());
|
|
taskLog.setCreateDept(task.getCreateDept());
|
|
taskLog.setCreateUser(task.getCreateUser());
|
|
taskLog.setCreateUser(task.getCreateUser());
|
|
taskLog.setUpdateUser(task.getUpdateUser());
|
|
taskLog.setUpdateUser(task.getUpdateUser());
|
|
- try {
|
|
|
|
- Thread.sleep(3000);
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
- System.out.println("休眠异常:" + e.getMessage());
|
|
|
|
- }
|
|
|
|
- taskLog.setCreateTime(DateUtil.now());
|
|
|
|
- taskLog.setUpdateTime(DateUtil.now());
|
|
|
|
|
|
+ time.setTime(time.getTime() + 1000);
|
|
|
|
+ taskLog.setCreateTime(time);
|
|
|
|
+ taskLog.setUpdateTime(time);
|
|
logs.add(taskLog);
|
|
logs.add(taskLog);
|
|
|
|
|
|
|
|
+ //项目权限
|
|
ProjectAuth auth = new ProjectAuth();
|
|
ProjectAuth auth = new ProjectAuth();
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setProjectId(task.getProjectId());
|
|
auth.setProjectId(task.getProjectId());
|
|
@@ -163,55 +199,125 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
auth.setCreateTime(DateUtil.now());
|
|
auth.setCreateTime(DateUtil.now());
|
|
auth.setUpdateTime(DateUtil.now());
|
|
auth.setUpdateTime(DateUtil.now());
|
|
projectAuthService.save(auth);
|
|
projectAuthService.save(auth);
|
|
|
|
+
|
|
|
|
+ //把创建任务的人加入项目组
|
|
|
|
+ Long deptId = null;
|
|
|
|
+ String deptStr = userR.getData().getDeptId();
|
|
|
|
+ R<Dept> rpc = sysClient.getDept(Long.valueOf(deptStr));
|
|
|
|
+ if (rpc.isSuccess()) {
|
|
|
|
+ String ancestors = rpc.getData().getAncestors();
|
|
|
|
+ // ancestors 0,1689540492698267649
|
|
|
|
+ if (ancestors != null && ancestors.contains(String.valueOf(ZERO))) {
|
|
|
|
+ List<Long> longList = Func.toLongList(ancestors);
|
|
|
|
+ if (!CollectionUtils.isEmpty(longList)) {
|
|
|
|
+ if (longList.size() > 1) {
|
|
|
|
+ deptId = longList.get(1);
|
|
|
|
+ } else {
|
|
|
|
+ deptId = Long.valueOf(deptStr);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ProjectGroup group = new ProjectGroup();
|
|
|
|
+ group.setStageId(task.getStageId());
|
|
|
|
+ group.setProjectId(projectId);
|
|
|
|
+ group.setBeInvitedDept(deptId);
|
|
|
|
+ group.setUserId(createUser);
|
|
|
|
+ groups.add(group);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 项目创建人、项目经理 、任务审查人、执行人
|
|
|
|
+ userIds.remove(createUser);
|
|
|
|
+ Long finalOrgDeptId = orgDeptId;
|
|
|
|
+ if (!CollectionUtils.isEmpty(userIds)) {
|
|
|
|
+ userIds.forEach(userId -> {
|
|
|
|
+ R<User> rpc = userClient.userInfoById(userId);
|
|
|
|
+ if (rpc.isSuccess()) {
|
|
|
|
+ //项目权限
|
|
|
|
+ ProjectAuth auth = new ProjectAuth();
|
|
|
|
+ auth.setTopDept(finalOrgDeptId);
|
|
|
|
+ auth.setProjectId(task.getProjectId());
|
|
|
|
+ auth.setUserId(userId);
|
|
|
|
+ auth.setUserDept(Long.valueOf(rpc.getData().getDeptId()));
|
|
|
|
+ auth.setCreateDept(task.getCreateDept());
|
|
|
|
+ auth.setCreateUser(task.getCreateUser());
|
|
|
|
+ auth.setUpdateUser(task.getUpdateUser());
|
|
|
|
+ auth.setCreateTime(DateUtil.now());
|
|
|
|
+ auth.setUpdateTime(DateUtil.now());
|
|
|
|
+ auths.add(auth);
|
|
|
|
+
|
|
|
|
+ //项目组
|
|
|
|
+ ProjectGroup group = new ProjectGroup();
|
|
|
|
+ group.setUserId(userId);
|
|
|
|
+ group.setBeInvitedDept(finalOrgDeptId);
|
|
|
|
+ group.setStageId(task.getStageId());
|
|
|
|
+ group.setProjectId(task.getProjectId());
|
|
|
|
+ groups.add(group);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
taskLogService.saveBatch(logs);
|
|
taskLogService.saveBatch(logs);
|
|
|
|
+ if (!CollectionUtils.isEmpty(auths)) {
|
|
|
|
+ projectAuthService.saveBatch(auths);
|
|
|
|
+ }
|
|
|
|
+ if (!CollectionUtils.isEmpty(groups)) {
|
|
|
|
+ projectGroupService.saveBatch(groups);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // todo 2.任务下发通知
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Async("asyncPoolTaskExecutor")
|
|
@Async("asyncPoolTaskExecutor")
|
|
- public void updateTask(Integer type, Long userId, Task task) {
|
|
|
|
|
|
+ public void alterTask(Task afterUpdate, Task beforeUpdate, Long userId) {
|
|
R<User> userR = userClient.userInfoById(userId);
|
|
R<User> userR = userClient.userInfoById(userId);
|
|
if (userR.isSuccess()) {
|
|
if (userR.isSuccess()) {
|
|
List<TaskLog> logs = new ArrayList<>();
|
|
List<TaskLog> logs = new ArrayList<>();
|
|
List<ProjectAuth> auths = new ArrayList<>();
|
|
List<ProjectAuth> auths = new ArrayList<>();
|
|
List<ProjectGroup> groups = new ArrayList<>();
|
|
List<ProjectGroup> groups = new ArrayList<>();
|
|
|
|
|
|
- Long orgDeptId = task.getOrgDeptId();
|
|
|
|
- if (type == 1) {
|
|
|
|
|
|
+ Long orgDeptId = afterUpdate.getOrgDeptId();
|
|
|
|
+
|
|
|
|
+ Integer newStatus = afterUpdate.getTaskStatus();
|
|
|
|
+ Integer oldStatus = beforeUpdate.getTaskStatus();
|
|
|
|
+
|
|
|
|
+ Long projectId = afterUpdate.getProjectId();
|
|
|
|
+
|
|
|
|
+ //1.指定了执行单位
|
|
|
|
+ if ((beforeUpdate.getOrgDeptId() == null || beforeUpdate.getOrgDeptId() < 0L) && afterUpdate.getOrgDeptId() != null && afterUpdate.getOrgDeptId() > 0L) {
|
|
R<Dept> dept = sysClient.getDept(orgDeptId);
|
|
R<Dept> dept = sysClient.getDept(orgDeptId);
|
|
if (dept.isSuccess()) {
|
|
if (dept.isSuccess()) {
|
|
TaskLog log = new TaskLog();
|
|
TaskLog log = new TaskLog();
|
|
- log.setTaskId(task.getId());
|
|
|
|
|
|
+ log.setTaskId(afterUpdate.getId());
|
|
log.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
|
|
log.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
|
|
log.setRelatedUser(String.valueOf(userR.getData().getId()));
|
|
log.setRelatedUser(String.valueOf(userR.getData().getId()));
|
|
- log.setCreateDept(task.getCreateDept());
|
|
|
|
- log.setCreateUser(task.getCreateUser());
|
|
|
|
- log.setUpdateUser(task.getUpdateUser());
|
|
|
|
|
|
+ log.setCreateDept(afterUpdate.getCreateDept());
|
|
|
|
+ log.setCreateUser(afterUpdate.getCreateUser());
|
|
|
|
+ log.setUpdateUser(afterUpdate.getUpdateUser());
|
|
log.setCreateTime(DateUtil.now());
|
|
log.setCreateTime(DateUtil.now());
|
|
log.setUpdateTime(DateUtil.now());
|
|
log.setUpdateTime(DateUtil.now());
|
|
logs.add(log);
|
|
logs.add(log);
|
|
|
|
|
|
ProjectAuth auth = new ProjectAuth();
|
|
ProjectAuth auth = new ProjectAuth();
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setTopDept(orgDeptId);
|
|
- auth.setProjectId(task.getProjectId());
|
|
|
|
|
|
+ auth.setProjectId(afterUpdate.getProjectId());
|
|
auths.add(auth);
|
|
auths.add(auth);
|
|
}
|
|
}
|
|
- } else if (type == 2) {
|
|
|
|
- Long executeDept = task.getExecuteDept();
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //2.指定任务执行部门
|
|
|
|
+ if ((beforeUpdate.getExecuteDept() == null || beforeUpdate.getExecuteDept() < 0L) && afterUpdate.getExecuteDept() != null && afterUpdate.getExecuteDept() > 0L) {
|
|
|
|
+ Long executeDept = afterUpdate.getExecuteDept();
|
|
R<Dept> dept1 = sysClient.getDept(executeDept);
|
|
R<Dept> dept1 = sysClient.getDept(executeDept);
|
|
if (dept1.isSuccess()) {
|
|
if (dept1.isSuccess()) {
|
|
TaskLog log1 = new TaskLog();
|
|
TaskLog log1 = new TaskLog();
|
|
- log1.setTaskId(task.getId());
|
|
|
|
|
|
+ log1.setTaskId(afterUpdate.getId());
|
|
log1.setContent(userR.getData().getName() + " 指定了任务执行部门为" + dept1.getData().getDeptName());
|
|
log1.setContent(userR.getData().getName() + " 指定了任务执行部门为" + dept1.getData().getDeptName());
|
|
log1.setRelatedUser(String.valueOf(userR.getData().getId()));
|
|
log1.setRelatedUser(String.valueOf(userR.getData().getId()));
|
|
- log1.setCreateDept(task.getCreateDept());
|
|
|
|
- log1.setCreateUser(task.getCreateUser());
|
|
|
|
- log1.setUpdateUser(task.getUpdateUser());
|
|
|
|
|
|
+ log1.setCreateUser(userId);
|
|
|
|
+ log1.setUpdateUser(userId);
|
|
log1.setCreateTime(DateUtil.now());
|
|
log1.setCreateTime(DateUtil.now());
|
|
log1.setUpdateTime(DateUtil.now());
|
|
log1.setUpdateTime(DateUtil.now());
|
|
logs.add(log1);
|
|
logs.add(log1);
|
|
@@ -219,23 +325,25 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
ProjectAuth auth = new ProjectAuth();
|
|
ProjectAuth auth = new ProjectAuth();
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setUserDept(executeDept);
|
|
auth.setUserDept(executeDept);
|
|
- auth.setProjectId(task.getProjectId());
|
|
|
|
|
|
+ auth.setProjectId(afterUpdate.getProjectId());
|
|
auths.add(auth);
|
|
auths.add(auth);
|
|
}
|
|
}
|
|
- } else if (type == 3) {
|
|
|
|
- Long projectManager = task.getProjectManager();
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //3.指定项目经理
|
|
|
|
+ if ((beforeUpdate.getProjectManager() == null || beforeUpdate.getProjectManager() < 0L) && afterUpdate.getProjectManager() != null && afterUpdate.getProjectManager() > 0L) {
|
|
|
|
+ Long projectManager = afterUpdate.getProjectManager();
|
|
R<User> userR1 = userClient.userInfoById(projectManager);
|
|
R<User> userR1 = userClient.userInfoById(projectManager);
|
|
if (userR1.isSuccess()) {
|
|
if (userR1.isSuccess()) {
|
|
TaskLog log2 = new TaskLog();
|
|
TaskLog log2 = new TaskLog();
|
|
- log2.setTaskId(task.getId());
|
|
|
|
|
|
+ log2.setTaskId(afterUpdate.getId());
|
|
log2.setContent(userR.getData().getName() + " 指定了项目经理为 " + userR1.getData().getName());
|
|
log2.setContent(userR.getData().getName() + " 指定了项目经理为 " + userR1.getData().getName());
|
|
List<Long> users = new ArrayList<>();
|
|
List<Long> users = new ArrayList<>();
|
|
users.add(userR.getData().getId());
|
|
users.add(userR.getData().getId());
|
|
users.add(userR1.getData().getId());
|
|
users.add(userR1.getData().getId());
|
|
log2.setRelatedUser(Func.join(users));
|
|
log2.setRelatedUser(Func.join(users));
|
|
- log2.setCreateDept(task.getCreateDept());
|
|
|
|
- log2.setCreateUser(task.getCreateUser());
|
|
|
|
- log2.setUpdateUser(task.getUpdateUser());
|
|
|
|
|
|
+ log2.setCreateUser(userId);
|
|
|
|
+ log2.setUpdateUser(userId);
|
|
log2.setCreateTime(DateUtil.now());
|
|
log2.setCreateTime(DateUtil.now());
|
|
log2.setUpdateTime(DateUtil.now());
|
|
log2.setUpdateTime(DateUtil.now());
|
|
logs.add(log2);
|
|
logs.add(log2);
|
|
@@ -247,22 +355,25 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
ProjectAuth auth = new ProjectAuth();
|
|
ProjectAuth auth = new ProjectAuth();
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setUserDept(deptId);
|
|
auth.setUserDept(deptId);
|
|
- auth.setProjectId(task.getProjectId());
|
|
|
|
|
|
+ auth.setProjectId(afterUpdate.getProjectId());
|
|
auth.setUserId(projectManager);
|
|
auth.setUserId(projectManager);
|
|
auths.add(auth);
|
|
auths.add(auth);
|
|
|
|
|
|
//项目组
|
|
//项目组
|
|
ProjectGroup group = new ProjectGroup();
|
|
ProjectGroup group = new ProjectGroup();
|
|
group.setInviteDept(null);
|
|
group.setInviteDept(null);
|
|
- group.setProjectId(task.getProjectId());
|
|
|
|
- group.setStageId(task.getStageId());
|
|
|
|
|
|
+ group.setProjectId(afterUpdate.getProjectId());
|
|
|
|
+ group.setStageId(afterUpdate.getStageId());
|
|
group.setBeInvitedDept(orgDeptId);
|
|
group.setBeInvitedDept(orgDeptId);
|
|
group.setUserId(projectManager);
|
|
group.setUserId(projectManager);
|
|
groups.add(group);
|
|
groups.add(group);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else if (type == 4) {
|
|
|
|
- List<Long> userIds = Func.toLongList(task.getExecuteUser());
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //4.指定任务执行者
|
|
|
|
+ if (StringUtil.isBlank(beforeUpdate.getExecuteUser()) && StringUtil.isNotBlank(afterUpdate.getExecuteUser())) {
|
|
|
|
+ List<Long> userIds = Func.toLongList(afterUpdate.getExecuteUser());
|
|
List<String> str = new ArrayList<>();
|
|
List<String> str = new ArrayList<>();
|
|
userIds.forEach(id -> {
|
|
userIds.forEach(id -> {
|
|
R<User> rpc = userClient.userInfoById(id);
|
|
R<User> rpc = userClient.userInfoById(id);
|
|
@@ -275,14 +386,14 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
ProjectAuth auth = new ProjectAuth();
|
|
ProjectAuth auth = new ProjectAuth();
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setUserDept(deptId);
|
|
auth.setUserDept(deptId);
|
|
- auth.setProjectId(task.getProjectId());
|
|
|
|
|
|
+ auth.setProjectId(afterUpdate.getProjectId());
|
|
auth.setUserId(id);
|
|
auth.setUserId(id);
|
|
auths.add(auth);
|
|
auths.add(auth);
|
|
|
|
|
|
ProjectGroup group = new ProjectGroup();
|
|
ProjectGroup group = new ProjectGroup();
|
|
group.setInviteDept(null);
|
|
group.setInviteDept(null);
|
|
- group.setProjectId(task.getProjectId());
|
|
|
|
- group.setStageId(task.getStageId());
|
|
|
|
|
|
+ group.setProjectId(afterUpdate.getProjectId());
|
|
|
|
+ group.setStageId(afterUpdate.getStageId());
|
|
group.setBeInvitedDept(orgDeptId);
|
|
group.setBeInvitedDept(orgDeptId);
|
|
group.setUserId(id);
|
|
group.setUserId(id);
|
|
groups.add(group);
|
|
groups.add(group);
|
|
@@ -291,23 +402,31 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
});
|
|
});
|
|
if (!CollectionUtils.isEmpty(str)) {
|
|
if (!CollectionUtils.isEmpty(str)) {
|
|
TaskLog log3 = new TaskLog();
|
|
TaskLog log3 = new TaskLog();
|
|
- log3.setTaskId(task.getId());
|
|
|
|
|
|
+ log3.setTaskId(afterUpdate.getId());
|
|
log3.setContent(userR.getData().getName() + " 指定了任务执行者 " + Func.join(str));
|
|
log3.setContent(userR.getData().getName() + " 指定了任务执行者 " + Func.join(str));
|
|
List<Long> users = new ArrayList<>();
|
|
List<Long> users = new ArrayList<>();
|
|
users.add(userR.getData().getId());
|
|
users.add(userR.getData().getId());
|
|
users.addAll(userIds);
|
|
users.addAll(userIds);
|
|
log3.setRelatedUser(Func.join(users));
|
|
log3.setRelatedUser(Func.join(users));
|
|
- log3.setCreateDept(task.getCreateDept());
|
|
|
|
- log3.setCreateUser(task.getCreateUser());
|
|
|
|
- log3.setUpdateUser(task.getUpdateUser());
|
|
|
|
|
|
+ log3.setCreateUser(userId);
|
|
|
|
+ log3.setUpdateUser(userId);
|
|
log3.setCreateTime(DateUtil.now());
|
|
log3.setCreateTime(DateUtil.now());
|
|
log3.setUpdateTime(DateUtil.now());
|
|
log3.setUpdateTime(DateUtil.now());
|
|
logs.add(log3);
|
|
logs.add(log3);
|
|
}
|
|
}
|
|
- } else if (type == 5) {
|
|
|
|
- Long first = task.getFirstCheckUser();
|
|
|
|
- Long second = task.getSecondCheckUser();
|
|
|
|
- List<Long> checkUsers = Arrays.asList(first, second);
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //5.指定任务审查者
|
|
|
|
+ if ((beforeUpdate.getFirstCheckUser() == null && afterUpdate.getFirstCheckUser() != null) || (beforeUpdate.getSecondCheckUser() == null && afterUpdate.getSecondCheckUser() != null)) {
|
|
|
|
+ Long first = afterUpdate.getFirstCheckUser();
|
|
|
|
+ Long second = afterUpdate.getSecondCheckUser();
|
|
|
|
+ List<Long> checkUsers = new ArrayList<>();
|
|
|
|
+ if (first != null) {
|
|
|
|
+ checkUsers.add(first);
|
|
|
|
+ }
|
|
|
|
+ if (second != null) {
|
|
|
|
+ checkUsers.add(second);
|
|
|
|
+ }
|
|
List<String> checks = new ArrayList<>();
|
|
List<String> checks = new ArrayList<>();
|
|
checkUsers.forEach(id -> {
|
|
checkUsers.forEach(id -> {
|
|
R<User> rpc = userClient.userInfoById(id);
|
|
R<User> rpc = userClient.userInfoById(id);
|
|
@@ -320,14 +439,14 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
ProjectAuth auth = new ProjectAuth();
|
|
ProjectAuth auth = new ProjectAuth();
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setTopDept(orgDeptId);
|
|
auth.setUserDept(deptId);
|
|
auth.setUserDept(deptId);
|
|
- auth.setProjectId(task.getProjectId());
|
|
|
|
|
|
+ auth.setProjectId(afterUpdate.getProjectId());
|
|
auth.setUserId(id);
|
|
auth.setUserId(id);
|
|
auths.add(auth);
|
|
auths.add(auth);
|
|
|
|
|
|
ProjectGroup group = new ProjectGroup();
|
|
ProjectGroup group = new ProjectGroup();
|
|
group.setInviteDept(null);
|
|
group.setInviteDept(null);
|
|
- group.setProjectId(task.getProjectId());
|
|
|
|
- group.setStageId(task.getStageId());
|
|
|
|
|
|
+ group.setProjectId(afterUpdate.getProjectId());
|
|
|
|
+ group.setStageId(afterUpdate.getStageId());
|
|
group.setBeInvitedDept(orgDeptId);
|
|
group.setBeInvitedDept(orgDeptId);
|
|
group.setUserId(id);
|
|
group.setUserId(id);
|
|
groups.add(group);
|
|
groups.add(group);
|
|
@@ -336,24 +455,92 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
});
|
|
});
|
|
if (!CollectionUtils.isEmpty(checks)) {
|
|
if (!CollectionUtils.isEmpty(checks)) {
|
|
TaskLog log4 = new TaskLog();
|
|
TaskLog log4 = new TaskLog();
|
|
- log4.setTaskId(task.getId());
|
|
|
|
|
|
+ log4.setTaskId(afterUpdate.getId());
|
|
log4.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(checks));
|
|
log4.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(checks));
|
|
List<Long> users = new ArrayList<>();
|
|
List<Long> users = new ArrayList<>();
|
|
users.add(userR.getData().getId());
|
|
users.add(userR.getData().getId());
|
|
users.addAll(checkUsers);
|
|
users.addAll(checkUsers);
|
|
log4.setRelatedUser(Func.join(users));
|
|
log4.setRelatedUser(Func.join(users));
|
|
|
|
|
|
- log4.setCreateDept(task.getCreateDept());
|
|
|
|
- log4.setCreateUser(task.getCreateUser());
|
|
|
|
- log4.setUpdateUser(task.getUpdateUser());
|
|
|
|
|
|
+ log4.setCreateUser(userId);
|
|
|
|
+ log4.setUpdateUser(userId);
|
|
log4.setCreateTime(DateUtil.now());
|
|
log4.setCreateTime(DateUtil.now());
|
|
log4.setUpdateTime(DateUtil.now());
|
|
log4.setUpdateTime(DateUtil.now());
|
|
logs.add(log4);
|
|
logs.add(log4);
|
|
}
|
|
}
|
|
- } else if (type == 6) {
|
|
|
|
- //todo 提交、确认任务
|
|
|
|
- } else if (type == 7) {
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //6.提交了任务
|
|
|
|
+ if (newStatus != null && oldStatus != null && !oldStatus.equals(3) && newStatus.equals(3)) {
|
|
|
|
+ //提交成果文件
|
|
|
|
+ TaskLog log = new TaskLog();
|
|
|
|
+ log.setTaskId(afterUpdate.getId());
|
|
|
|
+ log.setContent(userR.getData().getName() + " 提交了成果文件");
|
|
|
|
+ log.setCreateUser(userId);
|
|
|
|
+ log.setUpdateUser(userId);
|
|
|
|
+ log.setCreateTime(DateUtil.now());
|
|
|
|
+ log.setUpdateTime(DateUtil.now());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //7.审查任务
|
|
|
|
+ if (newStatus != null && oldStatus != null && !oldStatus.equals(7) && newStatus.equals(7)) {
|
|
|
|
+ //审查任务
|
|
|
|
+ TaskLog log = new TaskLog();
|
|
|
|
+ log.setTaskId(afterUpdate.getId());
|
|
|
|
+ log.setContent(userR.getData().getName() + " 审查了成果文件");
|
|
|
|
+ log.setCreateUser(userId);
|
|
|
|
+ log.setUpdateUser(userId);
|
|
|
|
+ log.setCreateTime(DateUtil.now());
|
|
|
|
+ log.setUpdateTime(DateUtil.now());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //8.二次审查任务
|
|
|
|
+ if (newStatus != null && oldStatus != null && !oldStatus.equals(8) && newStatus.equals(8)) {
|
|
|
|
+ //二次审查任务
|
|
|
|
+ TaskLog log = new TaskLog();
|
|
|
|
+ log.setTaskId(afterUpdate.getId());
|
|
|
|
+ log.setContent(userR.getData().getName() + " 二次审查了成果文件");
|
|
|
|
+ log.setCreateUser(userId);
|
|
|
|
+ log.setUpdateUser(userId);
|
|
|
|
+ log.setCreateTime(DateUtil.now());
|
|
|
|
+ log.setUpdateTime(DateUtil.now());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //9.确认任务
|
|
|
|
+ if (newStatus != null && oldStatus != null && !oldStatus.equals(4) && newStatus.equals(4)) {
|
|
|
|
+ //确认任务
|
|
|
|
+ TaskLog log = new TaskLog();
|
|
|
|
+ log.setTaskId(afterUpdate.getId());
|
|
|
|
+ log.setContent(userR.getData().getName() + " 确认任务已完成");
|
|
|
|
+ log.setCreateUser(userId);
|
|
|
|
+ log.setUpdateUser(userId);
|
|
|
|
+ log.setCreateTime(DateUtil.now());
|
|
|
|
+ log.setUpdateTime(DateUtil.now());
|
|
|
|
+
|
|
|
|
+ //项目下待完成的任务减少
|
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
|
+ if (project != null) {
|
|
|
|
+ project.setTodoTask(Math.max(project.getTodoTask() - 1, 0));
|
|
|
|
+ projectMapper.updateById(project);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ //10.取消任务
|
|
|
|
+ if (newStatus != null && oldStatus != null && !oldStatus.equals(5) && newStatus.equals(5)) {
|
|
|
|
+ TaskLog log = new TaskLog();
|
|
|
|
+ log.setTaskId(afterUpdate.getId());
|
|
|
|
+ log.setContent(userR.getData().getName() + " 取消了任务");
|
|
|
|
+ log.setCreateUser(userId);
|
|
|
|
+ log.setUpdateUser(userId);
|
|
|
|
+ log.setCreateTime(DateUtil.now());
|
|
|
|
+ log.setUpdateTime(DateUtil.now());
|
|
|
|
+
|
|
|
|
+ //项目下待完成的任务减少
|
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
|
+ if (project != null) {
|
|
|
|
+ project.setTodoTask(Math.max(project.getTodoTask() - 1, 0));
|
|
|
|
+ projectMapper.updateById(project);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
taskLogService.saveBatch(logs);
|
|
taskLogService.saveBatch(logs);
|
|
@@ -368,42 +555,370 @@ public class AsyncServiceImpl implements IAsyncService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Async("asyncPoolTaskExecutor")
|
|
@Async("asyncPoolTaskExecutor")
|
|
- public void submitTaskMessage(Long userId, Task task) {
|
|
|
|
|
|
+ public void firstCheck(Long userId, Task task) {
|
|
|
|
+ R<User> userR = userClient.userInfoById(userId);
|
|
Long firstCheckUser = task.getFirstCheckUser();
|
|
Long firstCheckUser = task.getFirstCheckUser();
|
|
- Long secondCheckUser = task.getSecondCheckUser();
|
|
|
|
|
|
+ Long projectId = task.getProjectId();
|
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
|
+ R<User> checkR = userClient.userInfoById(firstCheckUser);
|
|
|
|
+ if (userR.isSuccess() && checkR.isSuccess() && project != null) {
|
|
|
|
+ String name = userR.getData().getName();
|
|
|
|
+ String phone = checkR.getData().getPhone();
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isNotBlank(name) && StringUtil.isNotBlank(phone)) {
|
|
|
|
+ try {
|
|
|
|
+ //发送短信
|
|
|
|
+ // 1.创建一个认真对象
|
|
|
|
+ Credential cred = new Credential(NacosConfigValue.txSecretId, NacosConfigValue.txSecretKey);
|
|
|
|
+ //2.实例化一个http选项
|
|
|
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
|
+ httpProfile.setReqMethod("POST");
|
|
|
|
+ httpProfile.setConnTimeout(60);
|
|
|
|
+ httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
|
|
|
+ //3实例化一个客户端配置对象
|
|
|
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
|
+ clientProfile.setSignMethod("HmacSHA256");
|
|
|
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
|
+ SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
|
|
|
+
|
|
|
|
+ //4.实例化请求对象
|
|
|
|
+ SendSmsRequest req = new SendSmsRequest();
|
|
|
|
+ String sdkAppId = "1400785942";
|
|
|
|
+ req.setSmsSdkAppid(sdkAppId);
|
|
|
|
+
|
|
|
|
+ String signName = "梧桐树网";
|
|
|
|
+ req.setSign(signName);
|
|
|
|
+
|
|
|
|
+ String templateId = "1948441";
|
|
|
|
+ req.setTemplateID(templateId);
|
|
|
|
+
|
|
|
|
+ /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
|
|
|
|
+ String[] templateParamSet = {name};
|
|
|
|
+ req.setTemplateParamSet(templateParamSet);
|
|
|
|
+
|
|
|
|
+ String[] phoneNumberSet = {"+86" + phone};
|
|
|
|
+ req.setPhoneNumberSet(phoneNumberSet);
|
|
|
|
+
|
|
|
|
+ SendSmsResponse res = client.SendSms(req);
|
|
|
|
+ log.info(SendSmsResponse.toJsonString(res));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("发送短信失败" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ //发送消息到首页
|
|
|
|
+ IndexMessage msg = new IndexMessage();
|
|
|
|
+ msg.setToUser(firstCheckUser);
|
|
|
|
+ msg.setContent(name + "已经完成了" + project.getName() + task.getTitle() + "的任务,请及时审核");
|
|
|
|
+ msg.setCategory(1);
|
|
|
|
+ msg.setOpenUrl("/task");
|
|
|
|
+ msg.setCreateUser(userId);
|
|
|
|
+ msg.setUpdateUser(userId);
|
|
|
|
+ indexMessageService.save(msg);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Async("asyncPoolTaskExecutor")
|
|
|
|
+ public void secondCheck(Long userId, Task task) {
|
|
|
|
+ R<User> userR = userClient.userInfoById(userId);
|
|
|
|
+ Long secondCheckUser = task.getSecondCheckUser();
|
|
Long projectId = task.getProjectId();
|
|
Long projectId = task.getProjectId();
|
|
- String title = task.getTitle();
|
|
|
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
|
+ R<User> checkR = userClient.userInfoById(secondCheckUser);
|
|
|
|
+
|
|
|
|
+ if (userR.isSuccess() && checkR.isSuccess() && project != null) {
|
|
|
|
+ String name = userR.getData().getName();
|
|
|
|
+ String phone = checkR.getData().getPhone();
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isNotBlank(name) && StringUtil.isNotBlank(phone)) {
|
|
|
|
+ try {
|
|
|
|
+ //发送短信
|
|
|
|
+ // 1.创建一个认证对象
|
|
|
|
+ Credential cred = new Credential(NacosConfigValue.txSecretId, NacosConfigValue.txSecretKey);
|
|
|
|
+ //2.实例化一个http选项
|
|
|
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
|
+ httpProfile.setReqMethod("POST");
|
|
|
|
+ httpProfile.setConnTimeout(60);
|
|
|
|
+ httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
|
|
|
+ //3实例化一个客户端配置对象
|
|
|
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
|
+ clientProfile.setSignMethod("HmacSHA256");
|
|
|
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
|
+ SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
|
|
|
+
|
|
|
|
+ //4.实例化请求对象
|
|
|
|
+ SendSmsRequest req = new SendSmsRequest();
|
|
|
|
+ String sdkAppId = "1400785942";
|
|
|
|
+ req.setSmsSdkAppid(sdkAppId);
|
|
|
|
+
|
|
|
|
+ String signName = "梧桐树网";
|
|
|
|
+ req.setSign(signName);
|
|
|
|
+
|
|
|
|
+ String templateId = "1948455";
|
|
|
|
+ req.setTemplateID(templateId);
|
|
|
|
+
|
|
|
|
+ /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
|
|
|
|
+ String[] templateParamSet = {name};
|
|
|
|
+ req.setTemplateParamSet(templateParamSet);
|
|
|
|
+
|
|
|
|
+ String[] phoneNumberSet = {"+86" + phone};
|
|
|
|
+ req.setPhoneNumberSet(phoneNumberSet);
|
|
|
|
+
|
|
|
|
+ SendSmsResponse res = client.SendSms(req);
|
|
|
|
+ log.info(SendSmsResponse.toJsonString(res));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("发送短信失败" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //发送消息到首页
|
|
|
|
+ IndexMessage msg = new IndexMessage();
|
|
|
|
+ msg.setToUser(secondCheckUser);
|
|
|
|
+ msg.setContent(name + "已经完成了" + project.getName() + task.getTitle() + "的任务一次审核,请及时二次审核");
|
|
|
|
+ msg.setCategory(1);
|
|
|
|
+ msg.setOpenUrl("/task");
|
|
|
|
+ msg.setCreateUser(userId);
|
|
|
|
+ msg.setUpdateUser(userId);
|
|
|
|
+ indexMessageService.save(msg);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Async("asyncPoolTaskExecutor")
|
|
|
|
+ public void dispatchTask(Long userId, Task task) {
|
|
R<User> userR = userClient.userInfoById(userId);
|
|
R<User> userR = userClient.userInfoById(userId);
|
|
- if (userR.isSuccess()) {
|
|
|
|
- List<IndexMessage> list = new ArrayList<>();
|
|
|
|
- IndexMessage message = new IndexMessage();
|
|
|
|
- message.setCategory(1);
|
|
|
|
- message.setToUser(firstCheckUser);
|
|
|
|
- message.setContent(userR.getData().getName() + "上传了" + title + "任务的文件,请查阅");
|
|
|
|
- message.setOpenUrl("/task");
|
|
|
|
- message.setCreateDept(task.getCreateDept());
|
|
|
|
- message.setCreateUser(userId);
|
|
|
|
- message.setUpdateUser(userId);
|
|
|
|
- message.setCreateTime(DateUtil.now());
|
|
|
|
- message.setUpdateTime(DateUtil.now());
|
|
|
|
- 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);
|
|
|
|
|
|
+ String executeUser = task.getExecuteUser();
|
|
|
|
+ List<Long> users = Func.toLongList(executeUser);
|
|
|
|
+ Long projectId = task.getProjectId();
|
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
|
+ Date endTime = task.getEndTime();
|
|
|
|
+ String format = DateUtil.format(endTime, "yyyy-MM-dd");
|
|
|
|
+
|
|
|
|
+ if (userR.isSuccess() && project != null) {
|
|
|
|
+ String name = userR.getData().getName();
|
|
|
|
+ users.forEach(user -> {
|
|
|
|
+ R<User> rpc = userClient.userInfoById(userId);
|
|
|
|
+ if (rpc.isSuccess()) {
|
|
|
|
+ String phone = rpc.getData().getPhone();
|
|
|
|
+ if (StringUtil.isNotBlank(name) && StringUtil.isNotBlank(phone)) {
|
|
|
|
+ try {
|
|
|
|
+ //发送短信
|
|
|
|
+ // 1.创建一个认证对象
|
|
|
|
+ Credential cred = new Credential(NacosConfigValue.txSecretId, NacosConfigValue.txSecretKey);
|
|
|
|
+ //2.实例化一个http选项
|
|
|
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
|
+ httpProfile.setReqMethod("POST");
|
|
|
|
+ httpProfile.setConnTimeout(60);
|
|
|
|
+ httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
|
|
|
+ //3实例化一个客户端配置对象
|
|
|
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
|
+ clientProfile.setSignMethod("HmacSHA256");
|
|
|
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
|
+ SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
|
|
|
+
|
|
|
|
+ //4.实例化请求对象
|
|
|
|
+ SendSmsRequest req = new SendSmsRequest();
|
|
|
|
+ String sdkAppId = "1400785942";
|
|
|
|
+ req.setSmsSdkAppid(sdkAppId);
|
|
|
|
+
|
|
|
|
+ String signName = "梧桐树网";
|
|
|
|
+ req.setSign(signName);
|
|
|
|
+
|
|
|
|
+ //任务下发通知模版id
|
|
|
|
+ String templateId = "1948622";
|
|
|
|
+ req.setTemplateID(templateId);
|
|
|
|
+
|
|
|
|
+ /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
|
|
|
|
+ String[] templateParamSet = {name, format};
|
|
|
|
+ req.setTemplateParamSet(templateParamSet);
|
|
|
|
+
|
|
|
|
+ String[] phoneNumberSet = {"+86" + phone};
|
|
|
|
+ req.setPhoneNumberSet(phoneNumberSet);
|
|
|
|
+
|
|
|
|
+ SendSmsResponse res = client.SendSms(req);
|
|
|
|
+ log.info(SendSmsResponse.toJsonString(res));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("发送短信失败" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //发送消息到首页
|
|
|
|
+ List<IndexMessage> messages = new ArrayList<>();
|
|
|
|
+ IndexMessage msg = new IndexMessage();
|
|
|
|
+ msg.setToUser(user);
|
|
|
|
+ msg.setContent(name + "指派" + project.getName() + task.getTitle() + "的任务,请及时完成");
|
|
|
|
+ msg.setCategory(1);
|
|
|
|
+ msg.setOpenUrl("/task");
|
|
|
|
+ msg.setCreateUser(userId);
|
|
|
|
+ msg.setUpdateUser(userId);
|
|
|
|
+ messages.add(msg);
|
|
|
|
+
|
|
|
|
+ IndexMessage message = new IndexMessage();
|
|
|
|
+ message.setToUser(user);
|
|
|
|
+ message.setContent(project.getName() + task.getTitle() + "的任务截至时间为" + format + ",请及时完成");
|
|
|
|
+ message.setCategory(1);
|
|
|
|
+ message.setOpenUrl("/task");
|
|
|
|
+ message.setCreateUser(userId);
|
|
|
|
+ message.setUpdateUser(userId);
|
|
|
|
+ messages.add(message);
|
|
|
|
+ indexMessageService.saveBatch(messages);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Async("asyncPoolTaskExecutor")
|
|
|
|
+ public void dispatchToDept(Long userId, Task task) {
|
|
|
|
+ Long createUser = task.getCreateUser();
|
|
|
|
+ R<User> userR = userClient.userInfoById(createUser);
|
|
|
|
+
|
|
|
|
+ Long charge = task.getFirstCheckUser();
|
|
|
|
+ R<User> chargeR = userClient.userInfoById(charge);
|
|
|
|
+
|
|
|
|
+ Long projectId = task.getProjectId();
|
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
|
+
|
|
|
|
+ if (userR.isSuccess() && chargeR.isSuccess() && project != null) {
|
|
|
|
+ String name = userR.getData().getName();
|
|
|
|
+ String title = task.getTitle();
|
|
|
|
+ String phone = chargeR.getData().getPhone();
|
|
|
|
+
|
|
|
|
+ if (StringUtil.isNotBlank(name) && StringUtil.isNotBlank(phone)) {
|
|
|
|
+ try {
|
|
|
|
+ //发送短信
|
|
|
|
+ // 1.创建一个认证对象
|
|
|
|
+ Credential cred = new Credential(NacosConfigValue.txSecretId, NacosConfigValue.txSecretKey);
|
|
|
|
+ //2.实例化一个http选项
|
|
|
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
|
+ httpProfile.setReqMethod("POST");
|
|
|
|
+ httpProfile.setConnTimeout(60);
|
|
|
|
+ httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
|
|
|
+ //3实例化一个客户端配置对象
|
|
|
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
|
+ clientProfile.setSignMethod("HmacSHA256");
|
|
|
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
|
+ SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
|
|
|
+
|
|
|
|
+ //4.实例化请求对象
|
|
|
|
+ SendSmsRequest req = new SendSmsRequest();
|
|
|
|
+ String sdkAppId = "1400785942";
|
|
|
|
+ req.setSmsSdkAppid(sdkAppId);
|
|
|
|
+
|
|
|
|
+ String signName = "梧桐树网";
|
|
|
|
+ req.setSign(signName);
|
|
|
|
+
|
|
|
|
+ //分配任务通知
|
|
|
|
+ String templateId = "1948437";
|
|
|
|
+ req.setTemplateID(templateId);
|
|
|
|
+
|
|
|
|
+ /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
|
|
|
|
+ String[] templateParamSet = {name, title};
|
|
|
|
+ req.setTemplateParamSet(templateParamSet);
|
|
|
|
+
|
|
|
|
+ String[] phoneNumberSet = {"+86" + phone};
|
|
|
|
+ req.setPhoneNumberSet(phoneNumberSet);
|
|
|
|
+
|
|
|
|
+ SendSmsResponse res = client.SendSms(req);
|
|
|
|
+ log.info(SendSmsResponse.toJsonString(res));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("发送短信失败" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //发送消息到首页
|
|
|
|
+ IndexMessage msg = new IndexMessage();
|
|
|
|
+ msg.setToUser(charge);
|
|
|
|
+ msg.setContent(name + "创建了" + project.getName() + task.getTitle() + "的任务,请及时跟进任务分配");
|
|
|
|
+ msg.setCategory(1);
|
|
|
|
+ msg.setOpenUrl("/task");
|
|
|
|
+ msg.setCreateUser(userId);
|
|
|
|
+ msg.setUpdateUser(userId);
|
|
|
|
+ indexMessageService.save(msg);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ @Async("asyncPoolTaskExecutor")
|
|
|
|
+ public void dispatchToOrg(Long userId, Task task) {
|
|
|
|
+
|
|
|
|
+ Long createUser = task.getCreateUser();
|
|
|
|
+ R<User> userR = userClient.userInfoById(createUser);
|
|
|
|
+
|
|
|
|
+ Long projectId = task.getProjectId();
|
|
|
|
+ Project project = projectMapper.selectById(projectId);
|
|
|
|
+
|
|
|
|
+ Long orgDeptId = task.getOrgDeptId();
|
|
|
|
+
|
|
|
|
+ //1.此dept下的所有用户 2.用户的角色是管理员角色的
|
|
|
|
+ R<List<User>> rpc = userClient.getUserByDeptId(String.valueOf(orgDeptId));
|
|
|
|
+ if (rpc.isSuccess()) {
|
|
|
|
+ List<User> data = rpc.getData();
|
|
|
|
+ //次级机构管理员
|
|
|
|
+ R<Role> roleR = sysClient.getRoleByRoleAlias("staff_admin");
|
|
|
|
+ if (roleR.isSuccess()) {
|
|
|
|
+ Set<User> users = data.stream().filter(f -> f.getRoleId() != null && f.getRoleId().contains(String.valueOf(roleR.getData().getId()))).collect(Collectors.toSet());
|
|
|
|
+ if (!CollectionUtil.isEmpty(users) && userR.isSuccess() && project != null) {
|
|
|
|
+ String name = userR.getData().getName();
|
|
|
|
+ String title = task.getTitle();
|
|
|
|
+ users.forEach(user -> {
|
|
|
|
+ String phone = user.getPhone();
|
|
|
|
+ try {
|
|
|
|
+ //发送短信
|
|
|
|
+ // 1.创建一个认证对象
|
|
|
|
+ Credential cred = new Credential(NacosConfigValue.txSecretId, NacosConfigValue.txSecretKey);
|
|
|
|
+ //2.实例化一个http选项
|
|
|
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
|
+ httpProfile.setReqMethod("POST");
|
|
|
|
+ httpProfile.setConnTimeout(60);
|
|
|
|
+ httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
|
|
|
+ //3实例化一个客户端配置对象
|
|
|
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
|
+ clientProfile.setSignMethod("HmacSHA256");
|
|
|
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
|
+ SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
|
|
|
+
|
|
|
|
+ //4.实例化请求对象
|
|
|
|
+ SendSmsRequest req = new SendSmsRequest();
|
|
|
|
+ String sdkAppId = "1400785942";
|
|
|
|
+ req.setSmsSdkAppid(sdkAppId);
|
|
|
|
+
|
|
|
|
+ String signName = "梧桐树网";
|
|
|
|
+ req.setSign(signName);
|
|
|
|
+
|
|
|
|
+ //分配任务通知
|
|
|
|
+ String templateId = "1948437";
|
|
|
|
+ req.setTemplateID(templateId);
|
|
|
|
+
|
|
|
|
+ /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
|
|
|
|
+ String[] templateParamSet = {name, title};
|
|
|
|
+ req.setTemplateParamSet(templateParamSet);
|
|
|
|
+
|
|
|
|
+ String[] phoneNumberSet = {"+86" + phone};
|
|
|
|
+ req.setPhoneNumberSet(phoneNumberSet);
|
|
|
|
+
|
|
|
|
+ SendSmsResponse res = client.SendSms(req);
|
|
|
|
+ log.info(SendSmsResponse.toJsonString(res));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("发送短信失败" + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //发送消息到首页
|
|
|
|
+ IndexMessage msg = new IndexMessage();
|
|
|
|
+ msg.setToUser(user.getId());
|
|
|
|
+ msg.setContent(userR.getData().getName() + "创建了" + project.getName() + task.getTitle() + "的任务,请及时跟进任务分配");
|
|
|
|
+ msg.setCategory(1);
|
|
|
|
+ msg.setOpenUrl("/task");
|
|
|
|
+ msg.setCreateUser(userId);
|
|
|
|
+ msg.setUpdateUser(userId);
|
|
|
|
+ indexMessageService.save(msg);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|