|
@@ -1,978 +0,0 @@
|
|
|
-package com.wtkj.service.impl;
|
|
|
-
|
|
|
-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.mapper.ProjectMapper;
|
|
|
-import com.wtkj.service.*;
|
|
|
-import lombok.AllArgsConstructor;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springblade.core.secure.BladeUser;
|
|
|
-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.Func;
|
|
|
-import org.springblade.core.tool.utils.StringUtil;
|
|
|
-import org.springblade.system.entity.Dept;
|
|
|
-import org.springblade.system.entity.Role;
|
|
|
-import org.springblade.system.feign.ISysClient;
|
|
|
-import org.springblade.system.user.entity.User;
|
|
|
-import org.springblade.system.user.feign.IUserClient;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import static com.wtkj.config.MagicValue.ZERO;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author Blizzard
|
|
|
- * @create at 2023-09-13 16:32
|
|
|
- * @describe
|
|
|
- */
|
|
|
-@Service
|
|
|
-@AllArgsConstructor
|
|
|
-@Slf4j
|
|
|
-public class AsyncServiceImpl implements IAsyncService {
|
|
|
-
|
|
|
- private final ITypeAndStageService typeAndStageService;
|
|
|
- private final IProjectStageService stageService;
|
|
|
- private final IProjectAuthService projectAuthService;
|
|
|
- private final ISysClient sysClient;
|
|
|
- private final IUserClient userClient;
|
|
|
- private final ITaskLogService taskLogService;
|
|
|
- private final IProjectGroupService projectGroupService;
|
|
|
- private final ProjectMapper projectMapper;
|
|
|
- private final IIndexMessageService indexMessageService;
|
|
|
-
|
|
|
- @Override
|
|
|
- @Async("asyncPoolTaskExecutor")
|
|
|
- public void createProject(Project project, BladeUser user) {
|
|
|
- //1.项目类型 --> 使用类型对应的模版阶段创建项目阶段
|
|
|
- Long projectType = project.getProjectType();
|
|
|
- List<TemplateTypeAndStage> templateStage = typeAndStageService.getStages(projectType);
|
|
|
- //2.创建项目阶段
|
|
|
- if (!CollectionUtils.isEmpty(templateStage)) {
|
|
|
- List<ProjectStage> stagesList = new ArrayList<>();
|
|
|
- templateStage.forEach(template -> {
|
|
|
- //项目的阶段记录表
|
|
|
- Long id = IdWorker.getId();
|
|
|
- ProjectStage stage = new ProjectStage();
|
|
|
- stage.setId(id);
|
|
|
- stage.setProjectId(project.getId());
|
|
|
- stage.setName(template.getName());
|
|
|
- stage.setSort(template.getSort());
|
|
|
- stage.setCreateUser(project.getCreateUser());
|
|
|
- stage.setCreateDept(project.getCreateDept());
|
|
|
- stage.setCreateTime(DateUtil.now());
|
|
|
- stage.setUpdateTime(DateUtil.now());
|
|
|
- stage.setUpdateUser(project.getUpdateUser());
|
|
|
- //添加默认阶段
|
|
|
- if (template.getSort() == 1) {
|
|
|
- project.setCurrentStage(id);
|
|
|
- projectMapper.updateById(project);
|
|
|
- }
|
|
|
- stagesList.add(stage);
|
|
|
- });
|
|
|
- if (!CollectionUtils.isEmpty(stagesList)) {
|
|
|
- stageService.saveBatch(stagesList);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- @Async("asyncPoolTaskExecutor")
|
|
|
- public void createTask(Task task) {
|
|
|
- Long projectId = task.getProjectId();
|
|
|
- Project project = projectMapper.selectById(projectId);
|
|
|
- if (project != null) {
|
|
|
- //修改项目下任务数量
|
|
|
- project.setTodoTask(project.getTodoTask() + 1);
|
|
|
- projectMapper.updateById(project);
|
|
|
-
|
|
|
- //1.任务日志
|
|
|
- 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) {
|
|
|
- R<User> userR = userClient.userInfoById(createUser);
|
|
|
- if (userR.isSuccess()) {
|
|
|
-
|
|
|
- TaskLog log = new TaskLog();
|
|
|
- log.setId(IdWorker.getId());
|
|
|
- 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());
|
|
|
- Date time = DateUtil.now();
|
|
|
- log.setCreateTime(time);
|
|
|
- log.setUpdateTime(time);
|
|
|
- taskLogService.save(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.setId(IdWorker.getId());
|
|
|
- taskLog.setTaskId(task.getId());
|
|
|
- taskLog.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
|
|
|
- taskLog.setRelatedUser(Func.join(userIds));
|
|
|
- taskLog.setCreateDept(task.getCreateDept());
|
|
|
- taskLog.setCreateUser(task.getCreateUser());
|
|
|
- taskLog.setUpdateUser(task.getUpdateUser());
|
|
|
- taskLog.setCreateTime(DateUtil.now());
|
|
|
- taskLog.setUpdateTime(DateUtil.now());
|
|
|
- taskLogService.save(taskLog);
|
|
|
-
|
|
|
- //项目权限
|
|
|
- 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);
|
|
|
-
|
|
|
- //把创建任务的人加入项目组
|
|
|
- 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);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(auths)) {
|
|
|
- projectAuthService.saveBatch(auths);
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(groups)) {
|
|
|
- projectGroupService.saveBatch(groups);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Async("asyncPoolTaskExecutor")
|
|
|
- public void alterTask(Task afterUpdate, Task beforeUpdate, Long userId) {
|
|
|
- R<User> userR = userClient.userInfoById(userId);
|
|
|
- if (userR.isSuccess()) {
|
|
|
- List<ProjectAuth> auths = new ArrayList<>();
|
|
|
- List<ProjectGroup> groups = new ArrayList<>();
|
|
|
-
|
|
|
- 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);
|
|
|
- if (dept.isSuccess()) {
|
|
|
- TaskLog log = new TaskLog();
|
|
|
- log.setTaskId(afterUpdate.getId());
|
|
|
- log.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
|
|
|
- log.setRelatedUser(String.valueOf(userR.getData().getId()));
|
|
|
- log.setCreateDept(afterUpdate.getCreateDept());
|
|
|
- log.setCreateUser(afterUpdate.getCreateUser());
|
|
|
- log.setUpdateUser(afterUpdate.getUpdateUser());
|
|
|
- log.setCreateTime(DateUtil.now());
|
|
|
- log.setUpdateTime(DateUtil.now());
|
|
|
- taskLogService.save(log);
|
|
|
-
|
|
|
- ProjectAuth auth = new ProjectAuth();
|
|
|
- auth.setTopDept(orgDeptId);
|
|
|
- auth.setProjectId(afterUpdate.getProjectId());
|
|
|
- auths.add(auth);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //2.指定任务执行部门
|
|
|
- if ((beforeUpdate.getExecuteDept() == null || beforeUpdate.getExecuteDept() < 0L) && afterUpdate.getExecuteDept() != null && afterUpdate.getExecuteDept() > 0L) {
|
|
|
- Long executeDept = afterUpdate.getExecuteDept();
|
|
|
- R<Dept> dept1 = sysClient.getDept(executeDept);
|
|
|
- if (dept1.isSuccess()) {
|
|
|
- TaskLog log1 = new TaskLog();
|
|
|
- log1.setTaskId(afterUpdate.getId());
|
|
|
- log1.setContent(userR.getData().getName() + " 指定了任务执行部门为" + dept1.getData().getDeptName());
|
|
|
- log1.setRelatedUser(String.valueOf(userR.getData().getId()));
|
|
|
- log1.setCreateUser(userId);
|
|
|
- log1.setUpdateUser(userId);
|
|
|
- log1.setCreateTime(DateUtil.now());
|
|
|
- log1.setUpdateTime(DateUtil.now());
|
|
|
- taskLogService.save(log1);
|
|
|
-
|
|
|
- ProjectAuth auth = new ProjectAuth();
|
|
|
- auth.setTopDept(orgDeptId);
|
|
|
- auth.setUserDept(executeDept);
|
|
|
- auth.setProjectId(afterUpdate.getProjectId());
|
|
|
- auths.add(auth);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //3.指定项目经理
|
|
|
- if ((beforeUpdate.getProjectManager() == null || beforeUpdate.getProjectManager() < 0L) && afterUpdate.getProjectManager() != null && afterUpdate.getProjectManager() > 0L) {
|
|
|
- Long projectManager = afterUpdate.getProjectManager();
|
|
|
- R<User> userR1 = userClient.userInfoById(projectManager);
|
|
|
- if (userR1.isSuccess()) {
|
|
|
- TaskLog log2 = new TaskLog();
|
|
|
- log2.setTaskId(afterUpdate.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.setCreateUser(userId);
|
|
|
- log2.setUpdateUser(userId);
|
|
|
- log2.setCreateTime(DateUtil.now());
|
|
|
- log2.setUpdateTime(DateUtil.now());
|
|
|
- taskLogService.save(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(afterUpdate.getProjectId());
|
|
|
- auth.setUserId(projectManager);
|
|
|
- auths.add(auth);
|
|
|
-
|
|
|
- //项目组
|
|
|
- ProjectGroup group = new ProjectGroup();
|
|
|
- group.setInviteDept(null);
|
|
|
- group.setProjectId(afterUpdate.getProjectId());
|
|
|
- group.setStageId(afterUpdate.getStageId());
|
|
|
- group.setBeInvitedDept(orgDeptId);
|
|
|
- group.setUserId(projectManager);
|
|
|
- groups.add(group);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //4.指定任务执行者
|
|
|
- if (StringUtil.isBlank(beforeUpdate.getExecuteUser()) && StringUtil.isNotBlank(afterUpdate.getExecuteUser())) {
|
|
|
- List<Long> userIds = Func.toLongList(afterUpdate.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(afterUpdate.getProjectId());
|
|
|
- auth.setUserId(id);
|
|
|
- auths.add(auth);
|
|
|
-
|
|
|
- ProjectGroup group = new ProjectGroup();
|
|
|
- group.setInviteDept(null);
|
|
|
- group.setProjectId(afterUpdate.getProjectId());
|
|
|
- group.setStageId(afterUpdate.getStageId());
|
|
|
- group.setBeInvitedDept(orgDeptId);
|
|
|
- group.setUserId(id);
|
|
|
- groups.add(group);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- if (!CollectionUtils.isEmpty(str)) {
|
|
|
- TaskLog log3 = new TaskLog();
|
|
|
- log3.setTaskId(afterUpdate.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.setCreateUser(userId);
|
|
|
- log3.setUpdateUser(userId);
|
|
|
- log3.setCreateTime(DateUtil.now());
|
|
|
- log3.setUpdateTime(DateUtil.now());
|
|
|
- taskLogService.save(log3);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //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<>();
|
|
|
- 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(afterUpdate.getProjectId());
|
|
|
- auth.setUserId(id);
|
|
|
- auths.add(auth);
|
|
|
-
|
|
|
- ProjectGroup group = new ProjectGroup();
|
|
|
- group.setInviteDept(null);
|
|
|
- group.setProjectId(afterUpdate.getProjectId());
|
|
|
- group.setStageId(afterUpdate.getStageId());
|
|
|
- group.setBeInvitedDept(orgDeptId);
|
|
|
- group.setUserId(id);
|
|
|
- groups.add(group);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- if (!CollectionUtils.isEmpty(checks)) {
|
|
|
- TaskLog log4 = new TaskLog();
|
|
|
- log4.setTaskId(afterUpdate.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.setCreateUser(userId);
|
|
|
- log4.setUpdateUser(userId);
|
|
|
- log4.setCreateTime(DateUtil.now());
|
|
|
- log4.setUpdateTime(DateUtil.now());
|
|
|
- taskLogService.save(log4);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //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());
|
|
|
- taskLogService.save(log);
|
|
|
- }
|
|
|
-
|
|
|
- //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());
|
|
|
- taskLogService.save(log);
|
|
|
- }
|
|
|
-
|
|
|
- //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());
|
|
|
- taskLogService.save(log);
|
|
|
- }
|
|
|
-
|
|
|
- //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());
|
|
|
- taskLogService.save(log);
|
|
|
-
|
|
|
- //项目下待完成的任务减少
|
|
|
- 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());
|
|
|
- taskLogService.save(log);
|
|
|
-
|
|
|
- //项目下待完成的任务减少
|
|
|
- Project project = projectMapper.selectById(projectId);
|
|
|
- if (project != null) {
|
|
|
- project.setTodoTask(Math.max(project.getTodoTask() - 1, 0));
|
|
|
- projectMapper.updateById(project);
|
|
|
- }
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(auths)) {
|
|
|
- projectAuthService.saveBatch(auths);
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(groups)) {
|
|
|
- projectGroupService.saveBatch(groups);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Async("asyncPoolTaskExecutor")
|
|
|
- public void firstCheck(Long userId, Task task) {
|
|
|
- R<User> userR = userClient.userInfoById(userId);
|
|
|
- Long firstCheckUser = task.getFirstCheckUser();
|
|
|
- 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();
|
|
|
- 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);
|
|
|
- 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);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String executeUser = task.getExecuteUser();
|
|
|
- if (!StringUtil.isNotBlank(executeUser)) {
|
|
|
- Date endTime = task.getEndTime();
|
|
|
- String format = DateUtil.format(endTime, "yyyy-MM-dd");
|
|
|
- List<Long> users = Func.toLongList(executeUser);
|
|
|
- if (userR.isSuccess() && project != null) {
|
|
|
- String name = userR.getData().getName();
|
|
|
- users.forEach(user -> {
|
|
|
- R<User> userR1 = userClient.userInfoById(userId);
|
|
|
- if (userR1.isSuccess()) {
|
|
|
- String phone = userR1.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);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-}
|