Blizzard преди 1 година
родител
ревизия
612b34ddee
променени са 18 файла, в които са добавени 813 реда и са изтрити 170 реда
  1. 1 1
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/Project.java
  2. 4 0
      blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/IndexTaskScheduleVO.java
  3. 21 0
      blade-service/wt-okr/pom.xml
  4. 14 0
      blade-service/wt-okr/src/main/java/com/wtkj/config/NacosConfigValue.java
  5. 1 1
      blade-service/wt-okr/src/main/java/com/wtkj/controller/IndexController.java
  6. 1 1
      blade-service/wt-okr/src/main/java/com/wtkj/controller/TaskController.java
  7. 11 1
      blade-service/wt-okr/src/main/java/com/wtkj/handler/Schedule.java
  8. 1 1
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileReadMapper.xml
  9. 1 2
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskFileMapper.xml
  10. 9 14
      blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskMapper.xml
  11. 17 11
      blade-service/wt-okr/src/main/java/com/wtkj/service/IAsyncService.java
  12. 0 1
      blade-service/wt-okr/src/main/java/com/wtkj/service/ITaskService.java
  13. 610 95
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/AsyncServiceImpl.java
  14. 8 0
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/CommonServiceImpl.java
  15. 4 4
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/IndexServiceImpl.java
  16. 20 38
      blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TaskServiceImpl.java
  17. 34 0
      blade-service/wt-okr/src/main/java/com/wtkj/wrapper/IndexTaskScheduleWrapper.java
  18. 56 0
      blade-service/wt-okr/src/main/java/com/wtkj/wrapper/TaskPageWrapper.java

+ 1 - 1
blade-service-api/wt-okr-api/src/main/java/com/wtkj/entity/Project.java

@@ -84,7 +84,7 @@ public class Project extends BaseEntity {
 
 	@TableField("todo_task")
 	@ApiModelProperty(value = "待完成任务数量")
-	private Integer todoTask;
+	private Integer todoTask = 0;
 
 	@TableField("img_id")
 	@ApiModelProperty(value = "项目图片文件ID")

+ 4 - 0
blade-service-api/wt-okr-api/src/main/java/com/wtkj/vo/IndexTaskScheduleVO.java

@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.List;
+
 /**
  * @author Blizzard
  * @create at 2023-09-20 16:31
@@ -21,4 +23,6 @@ public class IndexTaskScheduleVO extends Task {
 
 	@ApiModelProperty(value = "项目经理")
 	private String projectManagerUser;
+
+	private List<String> tagsArray;
 }

+ 21 - 0
blade-service/wt-okr/pom.xml

@@ -30,6 +30,12 @@
             <artifactId>wt-okr-api</artifactId>
             <version>1.0.RELEASE</version>
         </dependency>
+        <dependency>
+            <groupId>com.wtkj</groupId>
+            <artifactId>wutong-base-api</artifactId>
+            <version>2.9.1.RELEASE</version>
+        </dependency>
+
 
         <!--数据导出-->
         <!--        <dependency>-->
@@ -93,6 +99,21 @@
             <groupId>org.springframework.kafka</groupId>
             <artifactId>spring-kafka</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>5.5.7</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.tencentcloudapi</groupId>
+            <artifactId>tencentcloud-sdk-java</artifactId>
+            <!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java and get the latest version. -->
+            <!-- 请到https://search.maven.org/search?q=tencentcloud-sdk-java查询所有版本,最新版本如下 -->
+            <version>3.1.875</version>
+        </dependency>
+
     </dependencies>
 
 

+ 14 - 0
blade-service/wt-okr/src/main/java/com/wtkj/config/NacosConfigValue.java

@@ -21,6 +21,10 @@ public class NacosConfigValue {
 
 	public static String qySecret;
 
+	public static String txSecretId;
+
+	public static String txSecretKey;
+
 	@Value("${qrcode.expireIn}")
 	public void setExpireIn(Long expireIn) {
 		NacosConfigValue.expireIn = expireIn;
@@ -45,4 +49,14 @@ public class NacosConfigValue {
 	public void setCpSecret(String qySecret) {
 		NacosConfigValue.qySecret = qySecret;
 	}
+
+	@Value("${txCloud.secretId}")
+	public void setTxSecretId(String secretId) {
+		NacosConfigValue.txSecretId = secretId;
+	}
+
+	@Value("${txCloud.secretKey}")
+	public void setTxSecretKey(String secretKey) {
+		NacosConfigValue.txSecretKey = secretKey;
+	}
 }

+ 1 - 1
blade-service/wt-okr/src/main/java/com/wtkj/controller/IndexController.java

@@ -90,7 +90,7 @@ public class IndexController {
 	 */
 	@GetMapping("/message-detail")
 	@ApiOperationSupport(order = 6)
-	@ApiOperation(value = "阅读消息", notes = "传入id")
+	@ApiOperation(value = "阅读待办", notes = "传入id")
 	public R messageDetail(@RequestParam Long id) {
 		return R.data(indexService.messageDetail(id));
 	}

+ 1 - 1
blade-service/wt-okr/src/main/java/com/wtkj/controller/TaskController.java

@@ -92,7 +92,7 @@ public class TaskController {
 		query.setCurrent(dto.getCurrent());
 		query.setSize(dto.getSize());
 		IPage<Task> page = taskService.projectTaskPage(dto, Condition.getPage(query));
-		return R.data(TaskWrapper.build().pageVO(page));
+		return R.data(TaskPageWrapper.build().pageVO(page));
 	}
 
 	/**

+ 11 - 1
blade-service/wt-okr/src/main/java/com/wtkj/handler/Schedule.java

@@ -1,6 +1,8 @@
 package com.wtkj.handler;
 
+import com.wtkj.entity.Project;
 import com.wtkj.entity.Task;
+import com.wtkj.service.IProjectService;
 import com.wtkj.service.ITaskService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,16 +25,24 @@ public class Schedule {
 
 	@Autowired
 	private ITaskService taskService;
+	@Autowired
+	private IProjectService projectService;
 
 	@Scheduled(cron = "0 0 3 * * ?")
 	private void task() {
 		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 设置日期格式
 		String now = LocalDate.now().format(formatter);
-		//今天即将过期的任务
+		//今天过期的任务
 		List<Task> tasks = taskService.getTodayToExpire(now);
 		if (!CollectionUtils.isEmpty(tasks)) {
 			tasks.forEach(task -> {
 				task.setTaskStatus(6);
+				Long projectId = task.getProjectId();
+				Project byId = projectService.getById(projectId);
+				if (byId != null) {
+					byId.setTodoTask(Math.max(byId.getTodoTask() - 1, 0));
+					projectService.updateById(byId);
+				}
 			});
 			taskService.updateBatchById(tasks);
 		}

+ 1 - 1
blade-service/wt-okr/src/main/java/com/wtkj/mapper/FileReadMapper.xml

@@ -8,7 +8,7 @@
 
     <select id="selectByFileIds" resultType="com.wtkj.entity.FileRead">
         select * from blade_file_read where is_deleted = 0 and blade_file_id in
-        <foreach collection="param" open="(" separator="," close=")" index="index" item="item">
+        <foreach collection="collection" open="(" separator="," close=")" index="index" item="item">
             #{item}
         </foreach>
     </select>

+ 1 - 2
blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskFileMapper.xml

@@ -3,8 +3,7 @@
 <mapper namespace="com.wtkj.mapper.TaskFileMapper">
 
     <select id="getByBladeFileId" resultType="com.wtkj.entity.TaskFile">
-        select * from blade_task_management_file where is_deleted = 0 and task_id = #{param1} and blade_file_id =
-        #{param2}
+        select * from blade_task_file where is_deleted = 0 and task_id = #{param1} and blade_file_id = #{param2}
 
     </select>
 </mapper>

+ 9 - 14
blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskMapper.xml

@@ -13,12 +13,6 @@
     </select>
 
 
-    <select id="selectTodayTask" resultType="java.lang.Long">
-        select distinct id from blade_task where is_deleted = 0 and execute_user like concat(concat('%',#{param1}),'%')
-        and
-        DATE_FORMAT(end_time,'%Y-%m-%d') = DATE_FORMAT(#{param2},'%Y-%m-%d') and task_status != 4 and task_status != 5
-    </select>
-
     <select id="todayTo" resultType="com.wtkj.entity.Task">
         select * from blade_task where is_deleted = 0 and execute_user like concat(concat('%',#{param1}),'%')
         and
@@ -33,6 +27,13 @@
         order by create_time
     </select>
 
+    <select id="getTodoAndExpireByUserId" resultType="com.wtkj.entity.Task">
+        select * from blade_task where is_deleted = 0 and execute_user like concat(concat('%',#{param1}),'%')
+        and
+        DATE_FORMAT(#{param2},'%Y-%m-%d') >= DATE_FORMAT(end_time,'%Y-%m-%d') and task_status != 4 and task_status != 5
+        order by create_time
+    </select>
+
     <select id="getByDeptAndDate" resultType="com.wtkj.entity.Task">
         select * from blade_task where is_deleted = 0
         <if test="param1 != null">
@@ -45,7 +46,7 @@
             and execute_user like concat(concat('%',#{param3}),'%')
         </if>
         <if test="param4 != null">
-            and DATE_FORMAT(#{param3},'%Y-%m-%d') >= DATE_FORMAT(end_time,'%Y-%m-%d') and task_status != 4 and
+            and DATE_FORMAT(#{param4},'%Y-%m-%d') >= DATE_FORMAT(end_time,'%Y-%m-%d') and task_status != 4 and
             task_status != 5
         </if>
         order by create_time
@@ -61,13 +62,6 @@
         order by create_time
     </select>
 
-    <select id="getTodoAndExpireByUserId" resultType="com.wtkj.entity.Task">
-        select * from blade_task where is_deleted = 0 and execute_user like concat(concat('%',#{param1}),'%')
-        and
-        DATE_FORMAT(#{param2},'%Y-%m-%d') >= DATE_FORMAT(end_time,'%Y-%m-%d') and task_status != 4 and task_status != 5
-        order by create_time
-    </select>
-
     <select id="getTodayTodoByOrgDeptId" resultType="com.wtkj.entity.Task">
         select * from blade_task where is_deleted = 0 and org_dept_id = #{param1} and
         DATE_FORMAT(#{param2},'%Y-%m-%d') = DATE_FORMAT(end_time,'%Y-%m-%d') and task_status != 4 and task_status != 5
@@ -104,6 +98,7 @@
     <select id="getTodayToExpire" resultType="com.wtkj.entity.Task">
         select * from blade_task where is_deleted = 0 and
         DATE_FORMAT(#{param},'%Y-%m-%d') > DATE_FORMAT(end_time,'%Y-%m-%d') and task_status != 4 and task_status != 5
+        and task_status != 6
     </select>
 
 </mapper>

+ 17 - 11
blade-service/wt-okr/src/main/java/com/wtkj/service/IAsyncService.java

@@ -4,8 +4,6 @@ import com.wtkj.entity.Project;
 import com.wtkj.entity.Task;
 import org.springblade.core.secure.BladeUser;
 
-import java.util.List;
-
 /**
  * @author Blizzard
  * @create at 2023-09-13 16:32
@@ -18,17 +16,25 @@ public interface IAsyncService {
 	 */
 	void createProject(Project project, BladeUser user);
 
-	/**
-	 * 异步删除项目  项目阶段 文件夹/文件等
-	 */
-	void removeProject(List<Long> projectIds);
-
 	void createTask(Task task);
 
-	//创建任务日志
-	void submitTaskMessage(Long userId, Task task);
 
 	//指定执行单位日志
-	// type: 1 指定执行单位 2.指定任务执行部门  3.指定项目经理 4.执行任务执行者 5.指定任务审查者 6.提交任务 7.确认任务
-	void updateTask(Integer type, Long userId, Task task);
+	// type: 1 指定执行单位 2.指定任务执行部门  3.指定项目经理 4.执行任务执行者 5.指定任务审查者 6.提交任务 7.审查任务 8.二次审查 8.确认 10.取消
+	void alterTask(Task afterUpdate, Task beforeUpdate, Long userId);
+
+	//第一次审查通知
+	void firstCheck(Long userId, Task task);
+
+	//二次审查通知
+	void secondCheck(Long userId, Task task);
+
+	//下达任务通知
+	void dispatchTask(Long userId, Task task);
+
+	//通知主管
+	void dispatchToDept(Long userId, Task task);
+
+	//通知机构管理员
+	void dispatchToOrg(Long userId, Task task);
 }

+ 0 - 1
blade-service/wt-okr/src/main/java/com/wtkj/service/ITaskService.java

@@ -41,7 +41,6 @@ public interface ITaskService extends BaseService<Task> {
 
 	List<Task> listByUser(Long userId, Integer year, Integer month);
 
-	boolean deleteTask(List<Long> taskIds);
 
 	List<Task> listByStageId(Long stageId);
 

+ 610 - 95
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/AsyncServiceImpl.java

@@ -1,16 +1,26 @@
 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;
@@ -19,8 +29,10 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 import static com.wtkj.config.MagicValue.ZERO;
 
@@ -31,6 +43,7 @@ import static com.wtkj.config.MagicValue.ZERO;
  */
 @Service
 @AllArgsConstructor
+@Slf4j
 public class AsyncServiceImpl implements IAsyncService {
 
 	private final ITypeAndStageService typeAndStageService;
@@ -39,9 +52,9 @@ public class AsyncServiceImpl implements IAsyncService {
 	private final ISysClient sysClient;
 	private final IUserClient userClient;
 	private final ITaskLogService taskLogService;
-	private final IIndexMessageService indexMessageService;
 	private final IProjectGroupService projectGroupService;
 	private final ProjectMapper projectMapper;
+	private final IIndexMessageService indexMessageService;
 
 	@Override
 	@Async("asyncPoolTaskExecutor")
@@ -104,11 +117,6 @@ public class AsyncServiceImpl implements IAsyncService {
 
 	}
 
-	@Async("asyncPoolTaskExecutor")
-	@Override
-	public void removeProject(List<Long> longList) {
-
-	}
 
 	@Override
 	@Async("asyncPoolTaskExecutor")
@@ -116,44 +124,72 @@ public class AsyncServiceImpl implements IAsyncService {
 		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()) {
 					List<TaskLog> logs = new ArrayList<>();
 
 					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());
-					log.setCreateTime(DateUtil.now());
-					log.setUpdateTime(DateUtil.now());
+					Date time = DateUtil.now();
+					log.setCreateTime(time);
+					log.setUpdateTime(time);
 					logs.add(log);
 					Long orgDeptId = null;
 					if (task.getOrgDeptId() != null && task.getOrgDeptId() > 0L) {
 						orgDeptId = task.getOrgDeptId();
 						R<Dept> dept = sysClient.getDept(orgDeptId);
 						if (dept.isSuccess()) {
+							//日志
 							TaskLog taskLog = new TaskLog();
+							taskLog.setId(IdWorker.getId());
 							taskLog.setTaskId(task.getId());
 							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.setCreateUser(task.getCreateUser());
 							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);
 
+							//项目权限
 							ProjectAuth auth = new ProjectAuth();
 							auth.setTopDept(orgDeptId);
 							auth.setProjectId(task.getProjectId());
@@ -163,55 +199,125 @@ public class AsyncServiceImpl implements IAsyncService {
 							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);
+								}
+							});
 						}
 					}
 					taskLogService.saveBatch(logs);
+					if (!CollectionUtils.isEmpty(auths)) {
+						projectAuthService.saveBatch(auths);
+					}
+					if (!CollectionUtils.isEmpty(groups)) {
+						projectGroupService.saveBatch(groups);
+					}
 				}
 			}
-			// todo 2.任务下发通知
 		}
 	}
 
 	@Override
 	@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);
 		if (userR.isSuccess()) {
 			List<TaskLog> logs = new ArrayList<>();
 			List<ProjectAuth> auths = 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);
 				if (dept.isSuccess()) {
 					TaskLog log = new TaskLog();
-					log.setTaskId(task.getId());
+					log.setTaskId(afterUpdate.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.setCreateDept(afterUpdate.getCreateDept());
+					log.setCreateUser(afterUpdate.getCreateUser());
+					log.setUpdateUser(afterUpdate.getUpdateUser());
 					log.setCreateTime(DateUtil.now());
 					log.setUpdateTime(DateUtil.now());
 					logs.add(log);
 
 					ProjectAuth auth = new ProjectAuth();
 					auth.setTopDept(orgDeptId);
-					auth.setProjectId(task.getProjectId());
+					auth.setProjectId(afterUpdate.getProjectId());
 					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);
 				if (dept1.isSuccess()) {
 					TaskLog log1 = new TaskLog();
-					log1.setTaskId(task.getId());
+					log1.setTaskId(afterUpdate.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.setCreateUser(userId);
+					log1.setUpdateUser(userId);
 					log1.setCreateTime(DateUtil.now());
 					log1.setUpdateTime(DateUtil.now());
 					logs.add(log1);
@@ -219,23 +325,25 @@ public class AsyncServiceImpl implements IAsyncService {
 					ProjectAuth auth = new ProjectAuth();
 					auth.setTopDept(orgDeptId);
 					auth.setUserDept(executeDept);
-					auth.setProjectId(task.getProjectId());
+					auth.setProjectId(afterUpdate.getProjectId());
 					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);
 				if (userR1.isSuccess()) {
 					TaskLog log2 = new TaskLog();
-					log2.setTaskId(task.getId());
+					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.setCreateDept(task.getCreateDept());
-					log2.setCreateUser(task.getCreateUser());
-					log2.setUpdateUser(task.getUpdateUser());
+					log2.setCreateUser(userId);
+					log2.setUpdateUser(userId);
 					log2.setCreateTime(DateUtil.now());
 					log2.setUpdateTime(DateUtil.now());
 					logs.add(log2);
@@ -247,22 +355,25 @@ public class AsyncServiceImpl implements IAsyncService {
 						ProjectAuth auth = new ProjectAuth();
 						auth.setTopDept(orgDeptId);
 						auth.setUserDept(deptId);
-						auth.setProjectId(task.getProjectId());
+						auth.setProjectId(afterUpdate.getProjectId());
 						auth.setUserId(projectManager);
 						auths.add(auth);
 
 						//项目组
 						ProjectGroup group = new ProjectGroup();
 						group.setInviteDept(null);
-						group.setProjectId(task.getProjectId());
-						group.setStageId(task.getStageId());
+						group.setProjectId(afterUpdate.getProjectId());
+						group.setStageId(afterUpdate.getStageId());
 						group.setBeInvitedDept(orgDeptId);
 						group.setUserId(projectManager);
 						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<>();
 				userIds.forEach(id -> {
 					R<User> rpc = userClient.userInfoById(id);
@@ -275,14 +386,14 @@ public class AsyncServiceImpl implements IAsyncService {
 							ProjectAuth auth = new ProjectAuth();
 							auth.setTopDept(orgDeptId);
 							auth.setUserDept(deptId);
-							auth.setProjectId(task.getProjectId());
+							auth.setProjectId(afterUpdate.getProjectId());
 							auth.setUserId(id);
 							auths.add(auth);
 
 							ProjectGroup group = new ProjectGroup();
 							group.setInviteDept(null);
-							group.setProjectId(task.getProjectId());
-							group.setStageId(task.getStageId());
+							group.setProjectId(afterUpdate.getProjectId());
+							group.setStageId(afterUpdate.getStageId());
 							group.setBeInvitedDept(orgDeptId);
 							group.setUserId(id);
 							groups.add(group);
@@ -291,23 +402,31 @@ public class AsyncServiceImpl implements IAsyncService {
 				});
 				if (!CollectionUtils.isEmpty(str)) {
 					TaskLog log3 = new TaskLog();
-					log3.setTaskId(task.getId());
+					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.setCreateDept(task.getCreateDept());
-					log3.setCreateUser(task.getCreateUser());
-					log3.setUpdateUser(task.getUpdateUser());
+					log3.setCreateUser(userId);
+					log3.setUpdateUser(userId);
 					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);
+			}
+
+			//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);
@@ -320,14 +439,14 @@ public class AsyncServiceImpl implements IAsyncService {
 							ProjectAuth auth = new ProjectAuth();
 							auth.setTopDept(orgDeptId);
 							auth.setUserDept(deptId);
-							auth.setProjectId(task.getProjectId());
+							auth.setProjectId(afterUpdate.getProjectId());
 							auth.setUserId(id);
 							auths.add(auth);
 
 							ProjectGroup group = new ProjectGroup();
 							group.setInviteDept(null);
-							group.setProjectId(task.getProjectId());
-							group.setStageId(task.getStageId());
+							group.setProjectId(afterUpdate.getProjectId());
+							group.setStageId(afterUpdate.getStageId());
 							group.setBeInvitedDept(orgDeptId);
 							group.setUserId(id);
 							groups.add(group);
@@ -336,24 +455,92 @@ public class AsyncServiceImpl implements IAsyncService {
 				});
 				if (!CollectionUtils.isEmpty(checks)) {
 					TaskLog log4 = new TaskLog();
-					log4.setTaskId(task.getId());
+					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.setCreateDept(task.getCreateDept());
-					log4.setCreateUser(task.getCreateUser());
-					log4.setUpdateUser(task.getUpdateUser());
+					log4.setCreateUser(userId);
+					log4.setUpdateUser(userId);
 					log4.setCreateTime(DateUtil.now());
 					log4.setUpdateTime(DateUtil.now());
 					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);
@@ -368,42 +555,370 @@ public class AsyncServiceImpl implements IAsyncService {
 
 	@Override
 	@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 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();
-		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);
-		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);
+					});
+				}
+			}
+		}
+	}
 
 }

+ 8 - 0
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/CommonServiceImpl.java

@@ -33,6 +33,7 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.core.tool.utils.WebUtil;
 import org.springblade.system.entity.Dept;
 import org.springblade.system.feign.ISysClient;
 import org.springblade.system.user.entity.User;
@@ -63,6 +64,7 @@ public class CommonServiceImpl implements ICommonService {
 	private final RestHighLevelClient client;
 	private final ISysClient sysClient;
 	private final IUserClient userClient;
+	private final IAsyncService asyncService;
 
 
 	@Override
@@ -407,6 +409,12 @@ public class CommonServiceImpl implements ICommonService {
 			if (userR.isSuccess()) {
 				userInfo.setUser(userR.getData());
 			}
+
+			//登录成功通知 仅pc端
+			String platform = WebUtil.getHeader("platform");
+			if (StringUtil.isNotBlank(platform) && platform.equals("pc")) {
+
+			}
 			return userInfo;
 		}
 		return null;

+ 4 - 4
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/IndexServiceImpl.java

@@ -132,7 +132,7 @@ public class IndexServiceImpl implements IIndexService {
 					}
 				}
 			} else if (roleName.contains(STAFF_SECOND_ADMIN)) {
-				List<Task> list = taskService.getByDeptAndDate(null, Long.valueOf(deptId), null, null);
+				List<Task> list = taskService.getByDeptAndDate(null, Func.firstLong(deptId), null, date);
 				if (!CollectionUtils.isEmpty(list)){
 					for (Task task : list) {
 						String executeUser = task.getExecuteUser();
@@ -142,7 +142,7 @@ public class IndexServiceImpl implements IIndexService {
 						}
 					}
 				}
-			} else if (roleName.contains(STAFF_USER)) {
+			} else if (roleName.contains(STAFF_USER) || roleName.contains(STAFF_PROJECT_MANAGER)) {
 				res.add(userId);
 			}
 		}
@@ -152,11 +152,11 @@ public class IndexServiceImpl implements IIndexService {
 				if (rpc.isSuccess()) {
 					ScheduleUserVO vo = new ScheduleUserVO();
 					vo.setUser(rpc.getData());
-					List<Task> tasks = taskService.todayTodo(userId, date);
+					List<Task> tasks = taskService.todayTodo(id, date);
 					if (!CollectionUtils.isEmpty(tasks)) {
 						vo.setTodayTodo(tasks.size());
 					}
-					List<Task> tasks1 = taskService.todayExpire(userId, date);
+					List<Task> tasks1 = taskService.todayExpire(id, date);
 					if (!CollectionUtils.isEmpty(tasks1)) {
 						vo.setTodayExpire(tasks1.size());
 					}

+ 20 - 38
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TaskServiceImpl.java

@@ -71,6 +71,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 	@Override
 	public boolean submit(Task task) {
 		boolean flag = false;
+		Long userId = AuthUtil.getUserId();
 		Long taskId = task.getId();
 		Long projectId = task.getProjectId();
 		Project project = projectMapper.selectById(projectId);
@@ -91,47 +92,34 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 			task.setMonth(month);
 			task.setCompetentUnit(project.getCompetentUnit());
 			flag = this.save(task);
+
 			asyncService.createTask(task);
+			asyncService.dispatchToOrg(userId, task);
+
 		} else {
-			//执行的顶级单位
-			Long userId = AuthUtil.getUserId();
 			Task byId = this.getById(taskId);
 			if (byId != null) {
 				Integer newStatus = task.getTaskStatus();
 				Integer oldStatus = byId.getTaskStatus();
-				//1.指定了执行单位
-				if ((byId.getOrgDeptId() == null || byId.getOrgDeptId() < 0L) && task.getOrgDeptId() != null && task.getOrgDeptId() > 0L) {
-					asyncService.updateTask(1, userId, task);
-				}
-				//2.指定任务执行部门
-				if ((byId.getExecuteDept() == null || byId.getExecuteDept() < 0L) && task.getExecuteDept() != null && task.getExecuteDept() > 0L) {
-					asyncService.updateTask(2, userId, task);
-				}
-				//3.指定项目经理
-				if ((byId.getProjectManager() == null || byId.getProjectManager() < 0L) && task.getProjectManager() != null && task.getProjectManager() > 0L) {
-					asyncService.updateTask(3, userId, task);
-				}
-				//4.指定任务执行者
-				if (StringUtil.isBlank(byId.getExecuteUser()) && StringUtil.isNotBlank(task.getExecuteUser())) {
-					asyncService.updateTask(4, userId, task);
-				}
-				//5.指定任务审查者
-				if (byId.getFirstCheckUser() == null && byId.getSecondCheckUser() == null && task.getFirstCheckUser() != null && task.getSecondCheckUser() != null) {
-					asyncService.updateTask(5, userId, task);
-				}
-				//6.提交了任务
-				if (newStatus != null && oldStatus != null && !oldStatus.equals(3) && newStatus.equals(3)) {
-					//提交了任务
-					asyncService.updateTask(6, userId, task);
-				}
-				//7.确认任务
+				//确认任务
 				if (newStatus != null && oldStatus != null && !oldStatus.equals(4) && newStatus.equals(4)) {
 					task.setConfirmUser(userId);
 					task.setConfirmTime(DateUtil.now());
 					task.setIsConfirmed(1);
-					//确认任务
-					asyncService.updateTask(7, userId, task);
 				}
+				//指定执行部门  ---> 通知主管
+				if (byId.getExecuteDept() == null && task.getExecuteDept() != null) {
+					asyncService.dispatchToDept(userId, task);
+				}
+				// 下发任务 ---> 通知执行者
+				if (StringUtil.isBlank(byId.getExecuteUser()) && StringUtil.isNotBlank(task.getExecuteUser())) {
+					asyncService.dispatchTask(userId, task);
+				}
+				//二次审核 已经变为审核状态(7)的时候通知二次审核
+				if (oldStatus != null && newStatus != null && !oldStatus.equals(7) && newStatus.equals(7)) {
+					asyncService.secondCheck(userId, task);
+				}
+				asyncService.alterTask(task, byId, userId);
 			}
 			flag = this.updateById(task);
 		}
@@ -177,8 +165,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 					files.add(taskFile);
 				}
 			});
-			//提交任务消息
-			asyncService.submitTaskMessage(AuthUtil.getUserId(), this.getById(taskId));
+			asyncService.firstCheck(AuthUtil.getUserId(), this.getById(taskId));
 			flag = taskFileService.saveBatch(files);
 		}
 		return flag;
@@ -332,7 +319,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 					//1.已完成
 					statistics.setCompleted(statistics.getCompleted() + 1);
 				}
-				if (!taskStatus.equals(4) && !taskStatus.equals(5)) {
+				if (!taskStatus.equals(4) && !taskStatus.equals(5) && !taskStatus.equals(6)) {
 					//未完成
 					//6.未完成
 					statistics.setNotCompleted(statistics.getNotCompleted() + 1);
@@ -382,11 +369,6 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 		return this.list(lqw);
 	}
 
-	//todo 删除任务是否需要事务删除任务相关?
-	@Override
-	public boolean deleteTask(List<Long> taskIds) {
-		return false;
-	}
 
 	@Override
 	public List<Task> listByStageId(Long stageId) {

+ 34 - 0
blade-service/wt-okr/src/main/java/com/wtkj/wrapper/IndexTaskScheduleWrapper.java

@@ -7,10 +7,16 @@ import com.wtkj.vo.IndexTaskScheduleVO;
 import org.springblade.core.mp.support.BaseEntityWrapper;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.SpringUtil;
+import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.system.entity.DictBiz;
+import org.springblade.system.feign.IDictBizClient;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -23,9 +29,13 @@ public class IndexTaskScheduleWrapper extends BaseEntityWrapper<Task, IndexTaskS
 	private static IProjectService projectService;
 	private static IUserClient userClient;
 
+	private static IDictBizClient dictBizClient;
+
+
 	public static IndexTaskScheduleWrapper build() {
 		projectService = SpringUtil.getBean(IProjectService.class);
 		userClient = SpringUtil.getBean(IUserClient.class);
+		dictBizClient = SpringUtil.getBean(IDictBizClient.class);
 		return new IndexTaskScheduleWrapper();
 	}
 
@@ -46,6 +56,30 @@ public class IndexTaskScheduleWrapper extends BaseEntityWrapper<Task, IndexTaskS
 				vo.setProjectManagerUser(userR.getData().getName());
 			}
 		}
+		//任务标签的数组
+		String tags = entity.getTags();
+		String category = entity.getCategory();
+		List<String> dictBizs = new ArrayList<>();
+		if (StringUtil.isNotBlank(tags)) {
+			List<Long> intList = Func.toLongList(tags);
+			intList.forEach(f -> {
+				R<DictBiz> byId = dictBizClient.getById(f);
+				if (byId.isSuccess()) {
+					dictBizs.add(byId.getData().getDictValue());
+				}
+			});
+		}
+		if (StringUtil.isNotBlank(category)) {
+			List<Long> intList = Func.toLongList(category);
+			intList.forEach(f -> {
+				R<DictBiz> byId = dictBizClient.getById(f);
+				if (byId.isSuccess()) {
+					dictBizs.add(byId.getData().getDictValue());
+				}
+			});
+		}
+		vo.setTagsArray(dictBizs);
+
 		return vo;
 	}
 }

+ 56 - 0
blade-service/wt-okr/src/main/java/com/wtkj/wrapper/TaskPageWrapper.java

@@ -0,0 +1,56 @@
+package com.wtkj.wrapper;
+
+import com.wtkj.entity.Task;
+import com.wtkj.vo.TaskVO;
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.SpringUtil;
+import org.springblade.system.entity.Dept;
+import org.springblade.system.feign.ISysClient;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
+
+import java.util.Objects;
+
+/**
+ * @author Blizzard
+ * @create at 2023-10-09 15:52
+ * @describe
+ */
+public class TaskPageWrapper extends BaseEntityWrapper<Task, TaskVO> {
+
+	private static ISysClient sysClient;
+	private static IUserClient userClient;
+
+	public static TaskPageWrapper build() {
+		sysClient = SpringUtil.getBean(ISysClient.class);
+		userClient = SpringUtil.getBean(IUserClient.class);
+		return new TaskPageWrapper();
+	}
+
+	@Override
+	public TaskVO entityVO(Task entity) {
+		TaskVO vo = Objects.requireNonNull(BeanUtil.copy(entity, TaskVO.class));
+
+		//协作单位
+		Long orgDeptId = vo.getOrgDeptId();
+		if (orgDeptId != null) {
+			R<Dept> rpc = sysClient.getDept(orgDeptId);
+			if (rpc.isSuccess()) {
+				vo.setDispatchUintName(rpc.getData().getDeptName());
+			}
+		}
+
+		//项目经理
+		Long projectManager = vo.getProjectManager();
+		if (projectManager != null) {
+			R<User> userR = userClient.userInfoById(projectManager);
+			if (userR.isSuccess()) {
+				vo.setProjectManagerUser(userR.getData().getName());
+			}
+		}
+
+		return vo;
+	}
+}