Преглед изворни кода

fix: select by task status

Blizzard пре 1 година
родитељ
комит
984794444d

+ 40 - 0
blade-service/wt-okr/src/main/java/com/wtkj/handler/Schedule.java

@@ -0,0 +1,40 @@
+package com.wtkj.handler;
+
+import com.wtkj.entity.Task;
+import com.wtkj.service.ITaskService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.util.CollectionUtils;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+
+/**
+ * @author Blizzard
+ * @create at 2023-10-05 11:47
+ * @describe 定时任务扫描任务状态
+ */
+@Configuration
+@Slf4j
+public class Schedule {
+
+	@Autowired
+	private ITaskService taskService;
+
+	@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);
+			});
+			taskService.updateBatchById(tasks);
+		}
+	}
+}

+ 8 - 0
blade-service/wt-okr/src/main/java/com/wtkj/mapper/TaskMapper.java

@@ -29,4 +29,12 @@ public interface TaskMapper extends BaseMapper<Task> {
 	List<Task> getTodayTodoByOrgDeptId(Long topDept, String date);
 
 	List<Task> getTodoByYear(Set<Long> projectIds, Integer year);
+
+	List<Task> selectLeftByDateAndStage(Long stageId, String date);
+
+	List<Task> selectByDateAndStageAndStatus(Long stageId, String formatDate, Integer taskStatus);
+
+	List<Task> selectCurrentDateCompleteByStageAndDate(Long stageId, String formatDate, Integer taskStatus);
+
+	List<Task> getTodayToExpire(String date);
 }

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

@@ -20,25 +20,28 @@
     <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 is_confirmed = 0
+        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
-        DATE_FORMAT(end_time,'%Y-%m-%d') = DATE_FORMAT(#{param2},'%Y-%m-%d') and is_confirmed = 0 order by create_time
+        DATE_FORMAT(end_time,'%Y-%m-%d') = DATE_FORMAT(#{param2},'%Y-%m-%d') and task_status != 4 and task_status != 5
+        order by create_time
     </select>
 
     <select id="todayExpire" 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 is_confirmed = 0 order by create_time
+        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="getByOrgDeptId" resultType="com.wtkj.entity.Task">
         select * from blade_task where is_deleted = 0 and org_dept_id = #{param1}
         <if test="param2 != null">
-            and DATE_FORMAT(#{param2},'%Y-%m-%d') >= DATE_FORMAT(end_time,'%Y-%m-%d') and is_confirmed = 0
+            and DATE_FORMAT(#{param2},'%Y-%m-%d') >= DATE_FORMAT(end_time,'%Y-%m-%d') and task_status != 4 and
+            task_status != 5
         </if>
         order by create_time
     </select>
@@ -46,18 +49,44 @@
     <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 is_confirmed = 0 order by create_time
+        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 is_confirmed = 0 order by create_time
+        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="getTodoByYear" resultType="com.wtkj.entity.Task">
-        select * from blade_task where is_deleted = 0 and year = #{param2} and is_confirmed = 0 and project_id in
+        select * from blade_task where is_deleted = 0 and year = #{param2} and task_status != 4 and task_status != 5 and
+        project_id in
         <foreach collection="param1" index="index" item="item" open="(" separator="," close=")">
             #{item}
         </foreach>
     </select>
+
+    <select id="selectLeftByDateAndStage" resultType="com.wtkj.entity.Task">
+        select * from blade_task where is_deleted = 0 and stage_id = #{param1} and
+        DATE_FORMAT(#{param2},'%Y-%m-%d') = DATE_FORMAT(end_time,'%Y-%m-%d') and task_status != 4 and task_status != 5
+    </select>
+
+    <select id="selectByDateAndStageAndStatus" resultType="com.wtkj.entity.Task">
+        select * from blade_task where is_deleted = 0 and stage_id = #{param1} and
+        DATE_FORMAT(#{param2},'%Y-%m-%d') = DATE_FORMAT(end_time,'%Y-%m-%d') and task_status = #{param3}
+    </select>
+
+    <select id="selectCurrentDateCompleteByStageAndDate" resultType="com.wtkj.entity.Task">
+        select * from blade_task where is_deleted = 0 and stage_id = #{param1} and
+        DATE_FORMAT(#{param2},'%Y-%m-%d') = DATE_FORMAT(confirm_time,'%Y-%m-%d')
+        <if test="param3 != null">
+            and task_status = #{param3}
+        </if>
+    </select>
+
+    <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
+    </select>
 </mapper>

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

@@ -29,6 +29,6 @@ public interface IAsyncService {
 	void submitTaskMessage(Long userId, Task task);
 
 	//指定执行单位日志
-	// type: 1 指定执行单位 2.指定任务执行部门  3.指定项目经理 4.执行任务执行者
+	// type: 1 指定执行单位 2.指定任务执行部门  3.指定项目经理 4.执行任务执行者 5.指定任务审查者 6.提交任务 7.确认任务
 	void updateTask(Integer type, Long userId, Task task);
 }

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

@@ -87,4 +87,6 @@ public interface ITaskService extends BaseService<Task> {
 	LineChartDataSet projectTaskSituation(Long stageId);
 
 	LineChartDataSet projectTaskBurnout(Long stageId);
+
+	List<Task> getTodayToExpire(String date);
 }

+ 167 - 156
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/AsyncServiceImpl.java

@@ -112,187 +112,191 @@ public class AsyncServiceImpl implements IAsyncService {
 	@Override
 	@Async("asyncPoolTaskExecutor")
 	public void createTask(Task task) {
-		//1.任务日志
-		Long createUser = task.getCreateUser();
-		if (createUser != null) {
-			R<User> userR = userClient.userInfoById(createUser);
-			if (userR.isSuccess()) {
-				List<TaskLog> logs = new ArrayList<>();
-				List<ProjectAuth> auths = new ArrayList<>();
-				List<ProjectGroup> groups = new ArrayList<>();
+		Long projectId = task.getProjectId();
+		Project project = projectMapper.selectById(projectId);
+		if (project != null) {
+			//1.任务日志
+			Long createUser = task.getCreateUser();
+			if (createUser != null) {
+				R<User> userR = userClient.userInfoById(createUser);
+				if (userR.isSuccess()) {
+					List<TaskLog> logs = new ArrayList<>();
+					List<ProjectAuth> auths = new ArrayList<>();
+					List<ProjectGroup> groups = new ArrayList<>();
 
-				TaskLog log = new TaskLog();
-				log.setTaskId(task.getId());
-				log.setContent(userR.getData().getName() + " 创建了任务");
-				log.setCreateDept(task.getCreateDept());
-				log.setCreateUser(task.getCreateUser());
-				log.setUpdateUser(task.getUpdateUser());
-				log.setCreateTime(DateUtil.now());
-				log.setUpdateTime(DateUtil.now());
-				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.setTaskId(task.getId());
-						taskLog.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
-						taskLog.setCreateDept(task.getCreateDept());
-						taskLog.setCreateUser(task.getCreateUser());
-						taskLog.setUpdateUser(task.getUpdateUser());
-						taskLog.setCreateTime(DateUtil.now());
-						taskLog.setUpdateTime(DateUtil.now());
-						logs.add(taskLog);
-					}
-				}
-				if (task.getExecuteDept() != null && task.getExecuteDept() > 0L) {
-					Long executeDept = task.getExecuteDept();
-					R<Dept> dept = sysClient.getDept(executeDept);
-					if (dept.isSuccess()) {
-						TaskLog taskLog = new TaskLog();
-						taskLog.setTaskId(task.getId());
-						taskLog.setContent(userR.getData().getName() + " 指定了任务执行部门为" + dept.getData().getDeptName());
-						taskLog.setCreateDept(task.getCreateDept());
-						taskLog.setCreateUser(task.getCreateUser());
-						taskLog.setUpdateUser(task.getUpdateUser());
-						taskLog.setCreateTime(DateUtil.now());
-						taskLog.setUpdateTime(DateUtil.now());
-						logs.add(taskLog);
+					TaskLog log = new TaskLog();
+					log.setTaskId(task.getId());
+					log.setContent(userR.getData().getName() + " 创建了任务");
+					log.setCreateDept(task.getCreateDept());
+					log.setCreateUser(task.getCreateUser());
+					log.setUpdateUser(task.getUpdateUser());
+					log.setCreateTime(DateUtil.now());
+					log.setUpdateTime(DateUtil.now());
+					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.setTaskId(task.getId());
+							taskLog.setContent(userR.getData().getName() + " 指定了执行单位为" + dept.getData().getDeptName());
+							taskLog.setCreateDept(task.getCreateDept());
+							taskLog.setCreateUser(task.getCreateUser());
+							taskLog.setUpdateUser(task.getUpdateUser());
+							taskLog.setCreateTime(DateUtil.now());
+							taskLog.setUpdateTime(DateUtil.now());
+							logs.add(taskLog);
+						}
 					}
-				}
-				if (task.getProjectManager() != null && task.getProjectManager() > 0L) {
-					Long projectManager = task.getProjectManager();
-					//1.任务动态
-					R<User> userR1 = userClient.userInfoById(projectManager);
-					if (userR1.isSuccess()) {
-						TaskLog taskLog = new TaskLog();
-						taskLog.setTaskId(task.getId());
-						taskLog.setContent(userR.getData().getName() + " 指定了项目经理为 " + userR1.getData().getName());
-						taskLog.setCreateDept(task.getCreateDept());
-						taskLog.setCreateUser(task.getCreateUser());
-						taskLog.setUpdateUser(task.getUpdateUser());
-						taskLog.setCreateTime(DateUtil.now());
-						taskLog.setUpdateTime(DateUtil.now());
-						logs.add(taskLog);
-
-						String deptStr = userR1.getData().getDeptId();
-						if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
-							//2.项目权限
-							Long deptId = Func.firstLong(deptStr);
-							ProjectAuth auth = new ProjectAuth();
-							auth.setTopDept(orgDeptId);
-							auth.setUserDept(deptId);
-							auth.setProjectId(task.getProjectId());
-							auth.setUserId(projectManager);
-							auths.add(auth);
-
-							//3.项目组成员
-							ProjectGroup group = new ProjectGroup();
-							group.setInviteDept(null);
-							group.setProjectId(task.getProjectId());
-							group.setStageId(task.getStageId());
-							group.setBeInvitedDept(orgDeptId);
-							group.setUserId(projectManager);
-							groups.add(group);
+					if (task.getExecuteDept() != null && task.getExecuteDept() > 0L) {
+						Long executeDept = task.getExecuteDept();
+						R<Dept> dept = sysClient.getDept(executeDept);
+						if (dept.isSuccess()) {
+							TaskLog taskLog = new TaskLog();
+							taskLog.setTaskId(task.getId());
+							taskLog.setContent(userR.getData().getName() + " 指定了任务执行部门为" + dept.getData().getDeptName());
+							taskLog.setCreateDept(task.getCreateDept());
+							taskLog.setCreateUser(task.getCreateUser());
+							taskLog.setUpdateUser(task.getUpdateUser());
+							taskLog.setCreateTime(DateUtil.now());
+							taskLog.setUpdateTime(DateUtil.now());
+							logs.add(taskLog);
 						}
-
 					}
-				}
-				if (StringUtil.isNotBlank(task.getExecuteUser())) {
-					List<Long> userIds = Func.toLongList(task.getExecuteUser());
-					List<String> str = new ArrayList<>();
-					Long finalOrgDeptId = orgDeptId;
-					userIds.forEach(userId -> {
-						R<User> rpc = userClient.userInfoById(userId);
-						if (rpc.isSuccess()) {
-							str.add(rpc.getData().getName());
+					if (task.getProjectManager() != null && task.getProjectManager() > 0L) {
+						Long projectManager = task.getProjectManager();
+						//1.任务动态
+						R<User> userR1 = userClient.userInfoById(projectManager);
+						if (userR1.isSuccess()) {
+							TaskLog taskLog = new TaskLog();
+							taskLog.setTaskId(task.getId());
+							taskLog.setContent(userR.getData().getName() + " 指定了项目经理为 " + userR1.getData().getName());
+							taskLog.setCreateDept(task.getCreateDept());
+							taskLog.setCreateUser(task.getCreateUser());
+							taskLog.setUpdateUser(task.getUpdateUser());
+							taskLog.setCreateTime(DateUtil.now());
+							taskLog.setUpdateTime(DateUtil.now());
+							logs.add(taskLog);
 
-							String deptStr = rpc.getData().getDeptId();
-							if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId != null) {
+							String deptStr = userR1.getData().getDeptId();
+							if (StringUtil.isNotBlank(deptStr) && orgDeptId != null) {
+								//2.项目权限
 								Long deptId = Func.firstLong(deptStr);
 								ProjectAuth auth = new ProjectAuth();
-								auth.setTopDept(finalOrgDeptId);
+								auth.setTopDept(orgDeptId);
 								auth.setUserDept(deptId);
-								auth.setProjectId(task.getProjectId());
-								auth.setUserId(userId);
+								auth.setProjectId(projectId);
+								auth.setUserId(projectManager);
 								auths.add(auth);
 
-								//项目组成员
+								//3.项目组成员
 								ProjectGroup group = new ProjectGroup();
-								group.setInviteDept(null);
-								group.setProjectId(task.getProjectId());
+								group.setInviteDept(project.getCompetentUnit());
+								group.setProjectId(projectId);
 								group.setStageId(task.getStageId());
-								group.setBeInvitedDept(finalOrgDeptId);
-								group.setUserId(userId);
+								group.setBeInvitedDept(orgDeptId);
+								group.setUserId(projectManager);
 								groups.add(group);
 							}
+
 						}
-					});
-					if (!CollectionUtils.isEmpty(str)) {
-						TaskLog taskLog = new TaskLog();
-						taskLog.setTaskId(task.getId());
-						taskLog.setContent(userR.getData().getName() + " 指定了任务执行者 " + Func.join(str));
-						taskLog.setCreateDept(task.getCreateDept());
-						taskLog.setCreateUser(task.getCreateUser());
-						taskLog.setUpdateUser(task.getUpdateUser());
-						taskLog.setCreateTime(DateUtil.now());
-						taskLog.setUpdateTime(DateUtil.now());
-						logs.add(taskLog);
 					}
-				}
+					if (StringUtil.isNotBlank(task.getExecuteUser())) {
+						List<Long> userIds = Func.toLongList(task.getExecuteUser());
+						List<String> str = new ArrayList<>();
+						Long finalOrgDeptId = orgDeptId;
+						userIds.forEach(userId -> {
+							R<User> rpc = userClient.userInfoById(userId);
+							if (rpc.isSuccess()) {
+								str.add(rpc.getData().getName());
 
-				if (StringUtil.isNotBlank(task.getCheckUser())) {
-					List<Long> userIds = Func.toLongList(task.getCheckUser());
-					List<String> str = new ArrayList<>();
-					Long finalOrgDeptId1 = orgDeptId;
-					userIds.forEach(userId -> {
-						R<User> rpc = userClient.userInfoById(userId);
-						if (rpc.isSuccess()) {
-							str.add(rpc.getData().getName());
+								String deptStr = rpc.getData().getDeptId();
+								if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId != null) {
+									Long deptId = Func.firstLong(deptStr);
+									ProjectAuth auth = new ProjectAuth();
+									auth.setTopDept(finalOrgDeptId);
+									auth.setUserDept(deptId);
+									auth.setProjectId(projectId);
+									auth.setUserId(userId);
+									auths.add(auth);
 
-							String deptStr = rpc.getData().getDeptId();
-							if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId1 != null) {
-								Long deptId = Func.firstLong(deptStr);
-								ProjectAuth auth = new ProjectAuth();
-								auth.setTopDept(finalOrgDeptId1);
-								auth.setUserDept(deptId);
-								auth.setProjectId(task.getProjectId());
-								auth.setUserId(userId);
-								auths.add(auth);
+									//项目组成员
+									ProjectGroup group = new ProjectGroup();
+									group.setInviteDept(project.getCompetentUnit());
+									group.setProjectId(projectId);
+									group.setStageId(task.getStageId());
+									group.setBeInvitedDept(finalOrgDeptId);
+									group.setUserId(userId);
+									groups.add(group);
+								}
+							}
+						});
+						if (!CollectionUtils.isEmpty(str)) {
+							TaskLog taskLog = new TaskLog();
+							taskLog.setTaskId(task.getId());
+							taskLog.setContent(userR.getData().getName() + " 指定了任务执行者 " + Func.join(str));
+							taskLog.setCreateDept(task.getCreateDept());
+							taskLog.setCreateUser(task.getCreateUser());
+							taskLog.setUpdateUser(task.getUpdateUser());
+							taskLog.setCreateTime(DateUtil.now());
+							taskLog.setUpdateTime(DateUtil.now());
+							logs.add(taskLog);
+						}
+					}
 
-								ProjectGroup group = new ProjectGroup();
-								group.setInviteDept(null);
-								group.setProjectId(task.getProjectId());
-								group.setStageId(task.getStageId());
-								group.setBeInvitedDept(finalOrgDeptId1);
-								group.setUserId(userId);
-								groups.add(group);
+					if (StringUtil.isNotBlank(task.getCheckUser())) {
+						List<Long> userIds = Func.toLongList(task.getCheckUser());
+						List<String> str = new ArrayList<>();
+						Long finalOrgDeptId1 = orgDeptId;
+						userIds.forEach(userId -> {
+							R<User> rpc = userClient.userInfoById(userId);
+							if (rpc.isSuccess()) {
+								str.add(rpc.getData().getName());
+
+								String deptStr = rpc.getData().getDeptId();
+								if (StringUtil.isNotBlank(deptStr) && finalOrgDeptId1 != null) {
+									Long deptId = Func.firstLong(deptStr);
+									ProjectAuth auth = new ProjectAuth();
+									auth.setTopDept(finalOrgDeptId1);
+									auth.setUserDept(deptId);
+									auth.setProjectId(projectId);
+									auth.setUserId(userId);
+									auths.add(auth);
+
+									ProjectGroup group = new ProjectGroup();
+									group.setInviteDept(project.getCompetentUnit());
+									group.setProjectId(projectId);
+									group.setStageId(task.getStageId());
+									group.setBeInvitedDept(finalOrgDeptId1);
+									group.setUserId(userId);
+									groups.add(group);
+								}
 							}
+						});
+						if (!CollectionUtils.isEmpty(str)) {
+							TaskLog taskLog = new TaskLog();
+							taskLog.setTaskId(task.getId());
+							taskLog.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(str));
+							taskLog.setCreateDept(task.getCreateDept());
+							taskLog.setCreateUser(task.getCreateUser());
+							taskLog.setUpdateUser(task.getUpdateUser());
+							taskLog.setCreateTime(DateUtil.now());
+							taskLog.setUpdateTime(DateUtil.now());
+							logs.add(taskLog);
 						}
-					});
-					if (!CollectionUtils.isEmpty(str)) {
-						TaskLog taskLog = new TaskLog();
-						taskLog.setTaskId(task.getId());
-						taskLog.setContent(userR.getData().getName() + " 指定了任务审查者 " + Func.join(str));
-						taskLog.setCreateDept(task.getCreateDept());
-						taskLog.setCreateUser(task.getCreateUser());
-						taskLog.setUpdateUser(task.getUpdateUser());
-						taskLog.setCreateTime(DateUtil.now());
-						taskLog.setUpdateTime(DateUtil.now());
-						logs.add(taskLog);
 					}
-				}
-				taskLogService.saveBatch(logs);
-				if (!CollectionUtils.isEmpty(auths)) {
-					projectAuthService.saveBatch(auths);
-				}
-				if (!CollectionUtils.isEmpty(groups)) {
-					projectGroupService.saveBatch(groups);
+					taskLogService.saveBatch(logs);
+					if (!CollectionUtils.isEmpty(auths)) {
+						projectAuthService.saveBatch(auths);
+					}
+					if (!CollectionUtils.isEmpty(groups)) {
+						projectGroupService.saveBatch(groups);
+					}
 				}
 			}
+			// todo 2.任务下发通知
 		}
-		// todo 2.任务下发通知
 	}
 
 	@Override
@@ -450,6 +454,13 @@ public class AsyncServiceImpl implements IAsyncService {
 						log4.setUpdateTime(DateUtil.now());
 						logs.add(log4);
 					}
+					break;
+				case 6:
+					// todo 提交任务
+					break;
+				case 7:
+					//确认任务
+					break;
 			}
 			taskLogService.saveBatch(logs);
 			if (!CollectionUtils.isEmpty(auths)) {

+ 128 - 10
blade-service/wt-okr/src/main/java/com/wtkj/service/impl/TaskServiceImpl.java

@@ -70,6 +70,8 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 			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);
@@ -90,6 +92,19 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 				if (StringUtil.isBlank(byId.getCheckUser()) && StringUtil.isNotBlank(task.getCheckUser())) {
 					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);
+				}
 			}
 			flag = this.updateById(task);
 		}
@@ -288,6 +303,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 	public List<Task> listByStageId(Long stageId) {
 		LambdaQueryWrapper<Task> lqw = new LambdaQueryWrapper<>();
 		lqw.eq(Task::getStageId, stageId);
+		lqw.ne(Task::getTaskStatus, 5);
 		lqw.orderByAsc(Task::getEndTime);
 		return this.list(lqw);
 	}
@@ -387,31 +403,133 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 		//1.阶段周期
 		List<LocalDate> dateList = redis.get("dateList::" + stageId);
 		if (!CollectionUtils.isEmpty(dateList)) {
-			LineChartData line = new LineChartData();
-			line.setType("line");
-			line.setName("leftTask");
-			List<Map<String, Object>> data = new ArrayList<>();
+			LineChartData leftLine = new LineChartData();
+			leftLine.setType("line");
+			leftLine.setName("leftTask");
+			LineChartData completeLine = new LineChartData();
+			completeLine.setType("line");
+			completeLine.setName("completeTask");
+			LineChartData expireLine = new LineChartData();
+			expireLine.setType("line");
+			expireLine.setName("expireTask");
+			List<Map<String, Object>> leftData = new ArrayList<>();
+			List<Map<String, Object>> completeData = new ArrayList<>();
+			List<Map<String, Object>> expireData = new ArrayList<>();
 			dateList.forEach(date -> {
-				DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 设置日期格
+				DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 设置日期格
 				String formatDate = date.format(formatter);
-				Map<String, Object> map = new HashMap<>();
-				map.put(formatDate, null);
+				Map<String, Object> leftMap = new HashMap<>();
+				// 日期为date时的任务剩余量 完成量 过期量
+				//1.剩余量 未完成和已取消的除外
+				List<Task> leftTasks = this.getLeftByDateAndStage(stageId, formatDate);
+				int leftAmount = 0;
+				if (!CollectionUtils.isEmpty(leftTasks)) {
+					leftAmount = leftTasks.size();
+				}
+				leftMap.put(formatDate, leftAmount);
+				leftData.add(leftMap);
+
+				//2.完成量 task_status = 4 的数量
+				Map<String, Object> completeMap = new HashMap<>();
+				List<Task> completeTasks = this.getListByDateAndStageAndStatus(stageId, formatDate, 4);
+				int completeAmount = 0;
+				if (!CollectionUtils.isEmpty(completeTasks)) {
+					completeAmount = completeTasks.size();
+				}
+				completeMap.put(formatDate, completeAmount);
+				completeData.add(completeMap);
+
+				//3.过期量 task_status = 6
+				Map<String, Object> expireMap = new HashMap<>();
+				List<Task> expireTasks = this.getListByDateAndStageAndStatus(stageId, formatDate, 6);
+				int expireAmount = 0;
+				if (!CollectionUtils.isEmpty(expireTasks)) {
+					expireAmount = expireTasks.size();
+				}
+				expireMap.put(formatDate, expireAmount);
+				expireData.add(expireMap);
 			});
-			line.setData(data);
-
+			leftLine.setData(leftData);
+			completeLine.setData(completeData);
+			expireLine.setData(expireData);
 
-			list.add(line);
+			list.add(leftLine);
+			list.add(completeLine);
+			list.add(expireLine);
 		}
 		set.setLineChartDataList(list);
 		return set;
 
 	}
 
+
 	@Override
 	public LineChartDataSet projectTaskBurnout(Long stageId) {
 		LineChartDataSet set = new LineChartDataSet();
 		List<LineChartData> list = new ArrayList<>();
+
+		//1.阶段周期
+		List<LocalDate> dateList = redis.get("dateList::" + stageId);
+		if (!CollectionUtils.isEmpty(dateList)) {
+			int size = dateList.size();
+			float avg = 0f;
+			// 当前阶段下所有的任务
+			List<Task> tasks = this.listByStageId(stageId);
+			if (!CollectionUtils.isEmpty(tasks)) {
+				int taskAmount = tasks.size();
+				//任务每天平均燃尽量
+				avg = (float) taskAmount / size;
+			}
+			LineChartData actualLine = new LineChartData();
+			actualLine.setType("line");
+			actualLine.setName("actual");
+			LineChartData avgLine = new LineChartData();
+			avgLine.setType("line");
+			avgLine.setName("avg");
+			List<Map<String, Object>> actualData = new ArrayList<>();
+			List<Map<String, Object>> avgData = new ArrayList<>();
+			float finalAvg = avg;
+			dateList.forEach(date -> {
+				DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); // 设置日期格式
+				String formatDate = date.format(formatter);
+				// 日期为date时的当日完成数 理想完成数
+				//1.date 当日完成数
+				Map<String, Object> actualMap = new HashMap<>();
+				List<Task> actualTasks = this.getCurrentDateCompleteByStageAndDate(stageId, formatDate, null);
+				int actualAmount = 0;
+				if (!CollectionUtils.isEmpty(actualTasks)) {
+					actualAmount = actualTasks.size();
+				}
+				actualMap.put(formatDate, actualAmount);
+				actualData.add(actualMap);
+
+				Map<String, Object> avgMap = new HashMap<>();
+				avgMap.put(formatDate, finalAvg);
+				avgData.add(avgMap);
+			});
+			actualLine.setData(actualData);
+			avgLine.setData(avgData);
+			list.add(actualLine);
+			list.add(avgLine);
+		}
 		set.setLineChartDataList(list);
 		return set;
 	}
+
+	@Override
+	public List<Task> getTodayToExpire(String date) {
+		return baseMapper.getTodayToExpire(date);
+	}
+
+	private List<Task> getListByDateAndStageAndStatus(Long stageId, String formatDate, Integer taskStatus) {
+		return baseMapper.selectByDateAndStageAndStatus(stageId, formatDate, taskStatus);
+	}
+
+	private List<Task> getLeftByDateAndStage(Long stageId, String date) {
+		return baseMapper.selectLeftByDateAndStage(stageId, date);
+	}
+
+	private List<Task> getCurrentDateCompleteByStageAndDate(Long stageId, String formatDate, Integer taskStatus) {
+		return baseMapper.selectCurrentDateCompleteByStageAndDate(stageId, formatDate, taskStatus);
+	}
 }