From 80662b34fe93b4ede00c7fc03fbd9f01355c94e2 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 07 四月 2025 13:52:17 +0800
Subject: [PATCH] 修改任务接口

---
 business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java | 1383 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 1,194 insertions(+), 189 deletions(-)

diff --git a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
index 4b71e9a..4ac381a 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
@@ -3,22 +3,24 @@
 
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
 import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
 import com.ycl.common.constant.ProcessConstants;
 import com.ycl.common.constant.ProcessOverTimeConstants;
+import com.ycl.common.core.domain.AjaxResult;
 import com.ycl.common.core.domain.entity.SysDept;
 import com.ycl.common.core.domain.entity.SysDictData;
 import com.ycl.common.core.domain.entity.SysRole;
 import com.ycl.common.core.domain.entity.SysUser;
 import com.ycl.common.enums.business.*;
+import com.ycl.common.utils.DateUtils;
 import com.ycl.common.utils.SecurityUtils;
 import com.ycl.constant.TaskTypeConstant;
 import com.ycl.domain.entity.*;
 import com.ycl.domain.form.*;
 import com.ycl.domain.json.*;
+import com.ycl.domain.query.ProcessLogQuery;
 import com.ycl.domain.vo.*;
 import com.ycl.event.event.TaskLogEvent;
 import com.ycl.mapper.ProjectEngineeringMapper;
@@ -29,6 +31,7 @@
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ycl.domain.query.ProjectProcessQuery;
 import com.ycl.service.common.TaskCommonService;
+import com.ycl.system.domain.base.AbsQuery;
 import com.ycl.system.service.ISysDeptService;
 import com.ycl.system.service.ISysDictTypeService;
 import com.ycl.system.service.ISysRoleService;
@@ -38,6 +41,7 @@
 import org.apache.commons.lang3.StringUtils;
 import org.flowable.bpmn.model.*;
 import org.flowable.bpmn.model.Process;
+import org.flowable.common.engine.impl.persistence.StrongUuidGenerator;
 import org.flowable.common.engine.impl.util.CollectionUtil;
 import org.flowable.engine.*;
 import org.flowable.engine.history.HistoricProcessInstance;
@@ -50,6 +54,8 @@
 import org.flowable.task.api.Task;
 import org.flowable.task.api.TaskQuery;
 import org.flowable.task.api.history.HistoricTaskInstance;
+import org.flowable.task.api.history.HistoricTaskInstanceQuery;
+import org.springframework.beans.BeanUtils;
 import org.springframework.context.ApplicationEventPublisher;
 import org.springframework.stereotype.Service;
 import lombok.RequiredArgsConstructor;
@@ -247,6 +253,7 @@
         variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUserId());
         // 灏嗚椤圭洰鐨勭敵璇蜂汉锛堜笟涓绘柟锛変綔涓烘祦绋嬩腑鏌愪簺鐜妭鐨勫鐞嗕汉
         variables.put(ProcessConstants.DATA_LAUNCH, "dept:" + createBy);
+        variables.put("a", 1);
         ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefId, projectId + "", variables);
         return processInstance.getId();
     }
@@ -302,14 +309,53 @@
         taskStatistics.setTimelyFinishedTaskNum(this.getTimelyTaskNum(projectProcess.getProcessInsId()));
         taskStatistics.setOvertimeTaskNum(this.getOvertimeTaskNum(projectProcess.getProcessInsId()));
         taskStatistics.setWillOvertimeTaskNum(this.getWillOvertimeTaskNum(projectProcess.getProcessInsId()));
-//        taskStatistics.setCurrentTask(this.getCurrentNodeTaskList(projectProcess.getProcessInstanceId()));
+        taskStatistics.setWaitTaskNum(this.getWaitTaskNum(projectProcess.getProcessInsId()));
+        taskStatistics.setJumpTaskNum(this.getJumpTaskNum(projectProcess.getProcessInsId()));
         detail.setStatistics(taskStatistics);
 
         Result result = Result.ok();
 
-        // 浠e姙浠诲姟
-        this.getTodoTaskList(projectProcess.getProjectId(), projectProcess.getProcessInsId(), "", 5, 1, result);
+//        // 浠e姙浠诲姟
+//        this.getTodoTaskList(projectProcess.getProjectId(), projectProcess.getProcessInsId(), "", 5, 1, result);
         return result.data(detail);
+    }
+
+    /**
+     * 瀹圭己浠诲姟璁℃暟
+     * @param processInsId
+     * @return
+     */
+    private Long getWaitTaskNum(String processInsId){
+        // 鏌ュ嚭瀹圭己杩囩殑浠诲姟
+        List<ProcessLog> allWaitTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.WAIT)
+                .orderByDesc(ProcessLog::getGmtCreate)
+                .list();
+        // 鎺掗櫎瀹圭己鍚庡張瀹屾垚鐨勪换鍔�
+        List<ProcessLog> finishedTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .in(ProcessLog::getEventType, ProcessLogEventTypeEnum.FINISHED, ProcessLogEventTypeEnum.REJECT)
+                .list();
+        List<String> finishedTaskIds = finishedTaskList.stream().map(ProcessLog::getTaskId).distinct().collect(Collectors.toList());
+        // 寰楀埌鏈畬鎴愮殑瀹圭己浠诲姟
+        List<String> waitTaskIds = allWaitTaskList.stream().filter(log -> !finishedTaskIds.contains(log.getTaskId())).map(ProcessLog::getTaskId).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(waitTaskIds)) {
+            return 0L;
+        }
+        // 瀹圭己鐨勪换鍔¢兘灞炰簬鍘嗗彶浠诲姟锛屽彧鏄渶瑕佽ˉ琛ㄥ崟鏁版嵁
+        List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
+                .processInstanceId(processInsId)
+                .taskIds(waitTaskIds)
+                .includeIdentityLinks()
+                .orderByHistoricTaskInstanceStartTime()
+                .desc()
+                .list();
+        hisTaskList = this.distinctHisTask(hisTaskList);
+        // 鎺掗櫎杩愯鏃朵换鍔�
+        List<String> runTaskKeys = taskService.createTaskQuery().processInstanceId(processInsId).list().stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+        hisTaskList = hisTaskList.stream().filter(his -> !runTaskKeys.contains(his.getTaskDefinitionKey())).collect(Collectors.toList());
+        return Long.valueOf(hisTaskList.size());
     }
 
     @Override
@@ -331,7 +377,11 @@
                 this.getTodoTaskList(query.getProjectId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getPageSize(), (int) query.getCurrentPage(), ok);
                 ok.data(ok.get("taskList"));
                 break;
-            case TaskTypeConstant.CURRENT:
+            case TaskTypeConstant.WAIT:
+                this.getWaitTask(query.getProjectId(), query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
+                break;
+            case TaskTypeConstant.JUMP:
+                this.getJumpTask(query.getProjectId(), query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
                 break;
             case TaskTypeConstant.REMAINING:
                 this.getRemainingTask(query.getProjectId(), query.getProcessDefId(), projectProcess.getProcessInsId(), query.getTaskName(), (int) query.getCurrentPage(), (int) query.getPageSize(), ok);
@@ -377,7 +427,50 @@
                     .endOr();
         }
         result.total(taskQuery.count());
-        List<Task> taskList = taskQuery.listPage(pageSize * (pageNum - 1), pageSize);
+        List<Task> allTodoList = taskQuery.list();
+        List<TaskOrderVO> orderList = new ArrayList<>();
+        allTodoList.stream().forEach(task -> {
+            TaskOrderVO order = new TaskOrderVO();
+            order.setTaskId(task.getId());
+            // 璁$畻鍔炵悊鏃堕棿锛岃秴鏃剁殑鎺掑墠闈紝娌¤秴鏃剁殑鐢变綆鍒伴珮鎺掑簭锛屾病瓒呮椂鏃堕棿鐨勬帓鏈�鍚�
+            ProcessCoding processCoding = processCodingService.getByTaskId(task.getId(), task.getProcessInstanceId());
+            if (Objects.nonNull(processCoding)) {
+                if (StringUtils.isNotBlank(processCoding.getRedTime())) {
+                    Long overtime = getTime(processCoding.getRedTime());
+                    long durationTime = 0l;
+                    if (Objects.nonNull(processCoding.getStartTaskTime())) {
+                        durationTime = DateUtils.getWorkingSed(processCoding.getStartTaskTime(), new Date());
+                    }
+                    if (overtime > durationTime) {
+                        order.setNum((overtime - durationTime) / 3600);
+                    } else {
+                        order.setNum(-2000000L);
+                    }
+                } else {
+                    order.setNum(2000000L);
+                }
+            } else {
+                order.setNum(2000000L);
+            }
+            orderList.add(order);
+        });
+        // 鍗囧簭鎺掑垪
+        Collections.sort(orderList, Comparator.comparingLong(TaskOrderVO::getNum));
+        int startNum = pageSize * (pageNum - 1);
+        int endNum = startNum + pageSize;
+        if (startNum >= orderList.size()) {
+            result.data(new ArrayList<>()).total(0L);
+            return;
+        }
+        int end = Math.min(endNum, orderList.size());
+        List<String> targetTaskIds = orderList.subList(startNum, end).stream().map(TaskOrderVO::getTaskId).collect(Collectors.toList());
+        List<Task> taskList = targetTaskIds.stream().map(taskId -> {
+            List<Task> list = allTodoList.stream().filter(task -> task.getId().equals(taskId)).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(list)) {
+                return null;
+            }
+            return list.get(0);
+        }).filter(Objects::nonNull).collect(Collectors.toList());
         List<IndexCustomerTaskVO> vos = new ArrayList<>();
         for (Task task : taskList) {
             IndexCustomerTaskVO taskVO = new IndexCustomerTaskVO();
@@ -398,13 +491,28 @@
             taskVO.setTaskDefinitionKey(task.getTaskDefinitionKey());
 
             // 娴佺▼椤圭洰淇℃伅
-            ProjectInfo project = baseMapper.getProjectInfo(task.getProcessInstanceId());
-            if (Objects.nonNull(project)) {
-                taskVO.setProjectId(project.getId());
-                taskVO.setProjectName(project.getProjectName());
-            } else {
-                continue;
+            ProjectProcess projectProcess = new LambdaQueryChainWrapper<>(baseMapper)
+                    .eq(ProjectProcess::getProcessInsId, task.getProcessInstanceId())
+                    .one();
+            String projectId = "";
+            String projectName = "";
+            if (Objects.nonNull(projectProcess)) {
+                if (projectProcess.getProjectType().equals(ProjectProcessTypeEnum.PROJECT)) {
+                    ProjectInfo project = projectInfoMapper.selectById(projectProcess.getProjectId());
+                    if (Objects.nonNull(project)) {
+                        projectId = projectProcess.getProjectId();
+                        projectName = project.getProjectName();
+                    }
+                } else if (projectProcess.getProjectType().equals(ProjectProcessTypeEnum.ENGINEERING)) {
+                    ProjectEngineering engineering = projectEngineeringMapper.selectById(projectProcess.getProjectId());
+                    if (Objects.nonNull(engineering)) {
+                        projectId = projectProcess.getProjectId();
+                        projectName = engineering.getProjectName();
+                    }
+                }
             }
+            taskVO.setProjectId(projectId);
+            taskVO.setProjectName(projectName);
 
             // 娴佺▼鍙戣捣浜轰俊鎭�
             this.setPromoterInfo(taskVO);
@@ -467,15 +575,13 @@
             }
 
             // 璁$畻鍔炵悊鏃堕棿
-            ProcessCoding processCoding = processCodingService.getByTaskId(task.getId());
-            if (processCoding != null) {
-                if (StringUtils.isNotBlank(processCoding.getOvertime())) {
-                    Long overtime = getTime(processCoding.getOvertime());
+            ProcessCoding processCoding = processCodingService.getByTaskId(task.getId(), task.getProcessInstanceId());
+            if (Objects.nonNull(processCoding)) {
+                if (StringUtils.isNotBlank(processCoding.getRedTime())) {
+                    Long overtime = getTime(processCoding.getRedTime());
                     long durationTime = 0l;
                     if (Objects.nonNull(processCoding.getStartTaskTime())) {
                         durationTime = ((new Date()).getTime() - processCoding.getStartTaskTime().getTime()) / 1000;
-                    } else {
-                        taskVO.setRemainingTime("鏈缃姙鐞嗘椂闂�");
                     }
                     if (overtime > durationTime) {
                         taskVO.setRemainingTime((overtime - durationTime) / 3600 + "灏忔椂");
@@ -485,6 +591,8 @@
                 } else {
                     taskVO.setRemainingTime("-");
                 }
+            } else {
+                taskVO.setRemainingTime("-");
             }
             this.distinctVo(taskVO);
             vos.add(taskVO);
@@ -722,7 +830,36 @@
                 }
             }
             // 瀹屾垚浠诲姟
-            flowTaskService.completeSubmitForm(form.getTaskId(), data);
+            flowTaskService.completeSubmitForm(form.getTaskId(), data, Boolean.FALSE);
+        }
+        return Result.ok("鎿嶄綔鎴愬姛");
+    }
+
+    @Override
+    public Result taskWait(TaskWaitForm form) {
+        Task task = taskService.createTaskQuery().taskId(form.getTaskId()).processInstanceId(form.getProcessInsId()).singleResult();
+        if (Objects.nonNull(task)) {
+            // 娣诲姞瀹圭己鏃ュ織
+            publisher.publishEvent(new TaskLogEvent(this,
+                    null,
+                    SecurityUtils.getUserId(),
+                    form.getProjectId(),
+                    form.getProcessInsId(),
+                    task.getId(),
+                    task.getTaskDefinitionKey(),
+                    task.getName(),
+                    ProcessLogEventTypeEnum.WAIT,
+                    new WaitData(form.getDesc())));
+            // 鏌ュ嚭璇ヤ换鍔$粦瀹氱殑琛ㄥ崟
+            Map<String, Object> data = new HashMap<>(1);
+            if (StringUtils.isNotBlank(task.getFormKey())) {
+                SysForm sysForm = formService.selectSysFormById(Long.parseLong(task.getFormKey()));
+                if (Objects.nonNull(sysForm)) {
+                    data.put(ProcessConstants.TASK_FORM_KEY, JSONObject.parseObject(sysForm.getFormContent()));
+                }
+            }
+            // 瀹屾垚浠诲姟
+            flowTaskService.completeSubmitForm(form.getTaskId(), data, Boolean.FALSE);
         }
         return Result.ok("鎿嶄綔鎴愬姛");
     }
@@ -745,7 +882,7 @@
         ProcessLog processLog = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
                 .eq(ProcessLog::getTaskId, form.getTaskId())
                 .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.SUPERVISE)
-                .eq(ProcessLog::getProcessInsId, form.getProcessInsId())
+                .eq(ProcessLog::getProcessInsId, task.getProcessInstanceId())
                 .one();
         List<SuperviseData> dataList;
         if (processLog != null) {
@@ -762,7 +899,7 @@
                 processLog.getId(),
                 processLog.getUserId(),
                 form.getProjectId(),
-                form.getProcessInsId(),
+                task.getProcessInstanceId(),
                 form.getTaskId(),
                 task.getTaskDefinitionKey(),
                 task.getName(),
@@ -878,6 +1015,37 @@
         return Result.ok("鎿嶄綔鎴愬姛");
     }
 
+    @Override
+    public Result getProcessMsg(AbsQuery q) {
+        // 鏌ヨ嚜宸辩殑鏃ュ織
+        ProcessLogQuery query = new ProcessLogQuery();
+        if (! SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
+            query.setUserId(SecurityUtils.getUserId());
+        }
+        query.setEventTypeList(Arrays.asList(ProcessLogEventTypeEnum.DELEGATE.getValue(),
+                ProcessLogEventTypeEnum.REJECT.getValue(),
+                ProcessLogEventTypeEnum.JUMP.getValue(),
+                ProcessLogEventTypeEnum.FINISHED.getValue(),
+                ProcessLogEventTypeEnum.WAIT.getValue()));
+        query.setCurrentPage(q.getCurrentPage());
+        query.setPageSize(q.getPageSize());
+        Result result = processLogService.projectProcessLogPage(query);
+        List<ProcessLogVO> logs = (List<ProcessLogVO>) result.get("data");
+
+        logs.stream().forEach(log -> {
+            if (ProcessLogEventTypeEnum.FINISHED.equals(log.getEventType())) {
+                log.setContent("鎮ㄥ畬鎴愪簡浠诲姟锛�" + log.getTaskName());
+            } else if (ProcessLogEventTypeEnum.REJECT.equals(log.getEventType())) {
+                log.setContent("鎮ㄩ┏鍥炰簡浠诲姟锛�" + log.getTaskName());
+            } else if (ProcessLogEventTypeEnum.WAIT.equals(log.getEventType())) {
+                log.setContent("鎮ㄥ缂轰簡浠诲姟锛�" + log.getTaskName());
+            } else if (ProcessLogEventTypeEnum.JUMP.equals(log.getEventType())) {
+                log.setContent("鎮ㄨ烦杩囦簡浠诲姟锛�" + log.getTaskName());
+            }
+        });
+        return Result.ok().data(logs).total((Long) result.get("total"));
+    }
+
     /**
      * 鏌ヨ寰呭姙浠诲姟
      *
@@ -889,6 +1057,7 @@
      * @param result
      */
     public void getTodoTaskList(String projectId, String processInsId, String taskName, int pageSize, int pageNum, Result result) {
+
         TaskQuery taskQuery = taskService.createTaskQuery()
                 .active()
                 .processInstanceId(processInsId)
@@ -992,11 +1161,11 @@
                         vo.setHandlerType(HandlerTypeEnum.USER);
                         SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userTask.getAssignee()));
                         if (Objects.nonNull(sysUser)) {
-                            handlerIds.add(sysUser.getUserId());
-                            handlerNames.add(this.getUserShowName(sysUser));
+                            vo.getHandlerId().add(sysUser.getUserId());
+                            vo.getHandlerName().add(this.getUserShowName(sysUser));
                             if (Objects.nonNull(sysUser.getDept())) {
-                                handlerUnitIds.add(sysUser.getDept().getDeptId());
-                                handlerUnitNames.add(sysUser.getDept().getDeptName());
+                                vo.getHandlerUnitId().add(sysUser.getDept().getDeptId());
+                                vo.getHandlerUnitName().add(sysUser.getDept().getDeptName());
                             }
                         }
                     } else if (CollectionUtil.isNotEmpty(userTask.getCandidateGroups())) {
@@ -1013,17 +1182,17 @@
                                     // 閮ㄩ棬
                                     SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
                                     if (Objects.nonNull(dept)) {
-                                        handlerUnitIds.add(dept.getDeptId());
-                                        handlerUnitNames.add(dept.getDeptName());
-                                        handlerNames.add(this.getDeptLeaderShowName(dept));
+                                        vo.getHandlerUnitId().add(dept.getDeptId());
+                                        vo.getHandlerUnitName().add(dept.getDeptName());
+                                        vo.getHandlerName().add(this.getDeptLeaderShowName(dept));
                                     }
                                 }
                             } else {
                                 vo.setHandlerType(HandlerTypeEnum.ROLE);
                                 SysRole role = sysRoleService.selectRoleById(Long.parseLong(groupId));
                                 if (Objects.nonNull(role)) {
-                                    handlerUnitIds.add(role.getRoleId());
-                                    handlerUnitNames.add(role.getRoleName());
+                                    vo.getHandlerUnitId().add(role.getRoleId());
+                                    vo.getHandlerUnitName().add(role.getRoleName());
                                 }
                             }
                         }
@@ -1037,18 +1206,19 @@
                     vo.setCreateTime(historicTasks.get(0).getStartTime());
 
                     // 鏌ヨ瀹為檯澶勭悊浜�
-                    long handlerUserId = Long.parseLong(historicTasks.get(0).getAssignee());
-                    SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
-                    if (Objects.nonNull(handlerUser)) {
-                        handlerIds.add(handlerUserId);
-                        handlerNames.add(this.getUserShowName(handlerUser));
-                        if (Objects.nonNull(handlerUser.getDept())) {
-                            handlerUnitNames.add(handlerUser.getDept().getDeptName());
-                            handlerUnitIds.add(handlerUser.getDept().getDeptId());
+                    if (StringUtils.isNotBlank(historicTasks.get(0).getAssignee())) {
+                        long handlerUserId = Long.parseLong(historicTasks.get(0).getAssignee());
+                        SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
+                        if (Objects.nonNull(handlerUser)) {
+                            vo.getHandlerId().add(handlerUserId);
+                            vo.getHandlerName().add(this.getUserShowName(handlerUser));
+                            if (Objects.nonNull(handlerUser.getDept())) {
+                                vo.getHandlerUnitName().add(handlerUser.getDept().getDeptName());
+                                vo.getHandlerUnitId().add(handlerUser.getDept().getDeptId());
+                            }
                         }
                     }
                     vo.setTaskDefinitionKey(historicTasks.get(0).getTaskDefinitionKey());
-                    this.setPromoterAndHandler(vo, historicTasks.get(0).getIdentityLinks());
                 }
             } else {
                 vo.setTaskStatus(TaskStatusEnum.TODO);
@@ -1057,7 +1227,7 @@
                 vo.setCreateTime(task.getCreateTime());
                 vo.setTaskDefinitionKey(task.getTaskDefinitionKey());
 
-                this.setPromoterAndHandler(vo, null);
+                this.setHandler(vo, null);
                 this.setRuntimeTaskInfo(task, vo, projectId);
             }
             this.distinctVo(vo);
@@ -1112,25 +1282,29 @@
                     .orderByHistoricTaskInstanceStartTime()
                     .desc()
                     .list();
-
-            vo.setTaskStatus(TaskStatusEnum.FINISHED);
-            // 濡傛灉鏄凡瀹屾垚鐨勶紝淇℃伅闇�瑕佸崟鐙祴鍊�
-            vo.setTaskId(hisTaskList.get(0).getId());
-            vo.setExecutionId(hisTaskList.get(0).getExecutionId());
-            vo.setCreateTime(hisTaskList.get(0).getStartTime());
-            // 鏌ヨ瀹為檯澶勭悊浜�
-            long handlerUserId = Long.parseLong(hisTaskList.get(0).getAssignee());
-            SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
-            if (Objects.nonNull(handlerUser)) {
-
-                vo.setActualHandlerUserId(hisTaskList.get(0).getAssignee());
-                vo.setActualHandlerUserName(handlerUser.getNickName());
+            // 濡傛灉鏈壘鍒板巻鍙蹭换鍔★紝璇存槑杩欎釜浠诲姟鍙兘澶勪簬鏌愪釜浜掓枼缃戝叧涓嬶紝瀹為檯骞舵湭鎵ц
+            if (CollectionUtils.isEmpty(hisTaskList)) {
+                vo.setTaskStatus(TaskStatusEnum.NOT_START);
+            } else {
+                vo.setTaskStatus(TaskStatusEnum.FINISHED);
+                // 濡傛灉鏄凡瀹屾垚鐨勶紝淇℃伅闇�瑕佸崟鐙祴鍊�
+                vo.setTaskId(hisTaskList.get(0).getId());
+                vo.setExecutionId(hisTaskList.get(0).getExecutionId());
+                vo.setCreateTime(hisTaskList.get(0).getStartTime());
+                // 鏌ヨ瀹為檯澶勭悊浜�
+                if (StringUtils.isNotBlank(hisTaskList.get(0).getAssignee())) {
+                    long handlerUserId = Long.parseLong(hisTaskList.get(0).getAssignee());
+                    SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
+                    if (Objects.nonNull(handlerUser)) {
+                        vo.setActualHandlerUserId(hisTaskList.get(0).getAssignee());
+                        vo.setActualHandlerUserName(handlerUser.getNickName());
+                    }
+                }
+                vo.setTaskDefinitionKey(hisTaskList.get(0).getTaskDefinitionKey());
+                this.setHandler(vo, hisTaskList.get(0).getIdentityLinks());
             }
-            vo.setTaskDefinitionKey(hisTaskList.get(0).getTaskDefinitionKey());
-            this.setPromoterAndHandler(vo, hisTaskList.get(0).getIdentityLinks());
-
             return vo;
-        }).collect(Collectors.toList());
+        }).filter(Objects::nonNull).collect(Collectors.toList());
         return vos;
     }
 
@@ -1199,7 +1373,14 @@
                         taskVO.getHandlerUnitId().add(sysUser.getDept().getDeptId());
                         taskVO.getHandlerUnitName().add(sysUser.getDept().getDeptName());
                         taskVO.getPromoterName().add(this.getUserShowName(sysUser));
-                        taskVO.getPromoterUnitName().add(sysUser.getDept().getDeptName());
+//                        if (sysUser.getDept().getAncestors())
+                        String[] str = sysUser.getDept().getAncestors().split(",");
+                        if (str.length >= 4){
+                            taskVO.getPromoterUnitName().add(sysUser.getDept().getParentName() +"-"+sysUser.getDept().getDeptName());
+                        }else {
+                            taskVO.getPromoterUnitName().add(sysUser.getDept().getDeptName());
+                        }
+
                     }
                 }
                 // 缁戝畾鐨勬槸瑙掕壊鎴栬�呴儴闂�
@@ -1214,7 +1395,7 @@
                             taskVO.getHandlerUnitId().add(dept.getDeptId());
                             taskVO.getHandlerUnitName().add(dept.getDeptName());
                             taskVO.getPromoterName().add(this.getDeptLeaderShowName(dept));
-                            taskVO.getPromoterUnitName().add(dept.getDeptName());
+                            taskVO.getPromoterUnitName().add(this.setDeptNameWithParentName(dept));
                         }
                     }
                 } else {
@@ -1238,16 +1419,30 @@
      */
     private Long getTimelyTaskNum(String processInsId) {
         // 鏌ュ嚭宸插畬鎴愮殑浠诲姟key
-        List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
+        HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery()
                 .processInstanceId(processInsId)
                 .finished()
-                .list();
-        hisTaskList = this.distinctHisTask(hisTaskList);
+                .includeIdentityLinks()
+                .orderByTaskCreateTime()
+                .desc();
+        List<HistoricTaskInstance> hisTaskList = query.list();
         if (CollectionUtils.isEmpty(hisTaskList)) {
             return 0L;
         }
-
+        hisTaskList = this.distinctHisTask(hisTaskList);
+        // 鎺掗櫎璺宠繃銆佸缂虹殑浠诲姟锛屽洜涓鸿繖涓や釜鎿嶄綔閮戒細瀹屾垚浠诲姟鑰屼骇鐢熷巻鍙蹭换鍔�
+        List<String> jumpAndWaitTaskKeys = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .in(ProcessLog::getEventType, ProcessLogEventTypeEnum.JUMP, ProcessLogEventTypeEnum.WAIT) // TODO 濡傛灉杩愯鏃朵换鍔℃濂芥槸琚┏鍥炵殑锛岄渶瑕佹兂鍔炴硶鎺掗櫎璋冭椹冲洖鐨勪换鍔★紝涓嶈兘鐩存帴鍦ㄨ繖鍔� ProcessLogEventTypeEnum.REJECT
+                .list().stream().map(ProcessLog::getTaskDefKey).collect(Collectors.toList());
+        List<String> runtimeTaskKey = taskService.createTaskQuery().processInstanceId(processInsId).list().stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+        jumpAndWaitTaskKeys.addAll(runtimeTaskKey);
+        hisTaskList = hisTaskList.stream().filter(hisTask -> jumpAndWaitTaskKeys.indexOf(hisTask.getTaskDefinitionKey()) == -1).collect(Collectors.toList());
         List<String> hisTaskKeys = hisTaskList.stream().map(HistoricTaskInstance::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+
+        if (CollectionUtils.isEmpty(hisTaskKeys)) {
+            return 0L;
+        }
         Map<String, HistoricTaskInstance> hisTaskMap = hisTaskList.stream().collect(Collectors.toMap(HistoricTaskInstance::getTaskDefinitionKey, his -> his));
         // 鏌ュ嚭鏃堕棿姝e父鐨勪换鍔ey
         List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
@@ -1289,21 +1484,37 @@
         int endNum = startNum + pageSize;
 
         // 鏌ュ嚭宸插畬鎴愮殑浠诲姟key
-        List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
+        HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery()
                 .processInstanceId(processInsId)
                 .finished()
-                .taskNameLike(taskName)
                 .includeIdentityLinks()
                 .orderByTaskCreateTime()
-                .desc()
-                .list();
+                .desc();
+        if (StringUtils.isNotBlank(taskName)) {
+            query.taskNameLike(taskName);
+        }
+        List<HistoricTaskInstance> hisTaskList = query.list();
         if (CollectionUtils.isEmpty(hisTaskList)) {
             result.total(0);
             return new ArrayList<>();
         }
-
+        hisTaskList = this.distinctHisTask(hisTaskList);
+        // 鎺掗櫎璺宠繃銆佸缂虹殑浠诲姟锛屽洜涓鸿繖涓や釜鎿嶄綔閮戒細瀹屾垚浠诲姟鑰屼骇鐢熷巻鍙蹭换鍔�
+        List<String> jumpAndWaitTaskKeys = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .eq(ProcessLog::getProjectId, projectId)
+                .in(ProcessLog::getEventType, ProcessLogEventTypeEnum.JUMP, ProcessLogEventTypeEnum.WAIT)
+                .list().stream().map(ProcessLog::getTaskDefKey).collect(Collectors.toList());
+        List<String> runtimeTaskKey = taskService.createTaskQuery().processInstanceId(processInsId).list().stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+        jumpAndWaitTaskKeys.addAll(runtimeTaskKey);
+        hisTaskList = hisTaskList.stream().filter(hisTask -> jumpAndWaitTaskKeys.indexOf(hisTask.getTaskDefinitionKey()) == -1).collect(Collectors.toList());
         List<String> hisTaskKeys = hisTaskList.stream().map(HistoricTaskInstance::getTaskDefinitionKey).distinct().collect(Collectors.toList());
-        Map<String, HistoricTaskInstance> hisTaskMap = this.distinctHisTask(hisTaskList).stream().collect(Collectors.toMap(HistoricTaskInstance::getTaskDefinitionKey, his -> his));
+
+        if (CollectionUtils.isEmpty(hisTaskKeys)) {
+            result.total(0);
+            return new ArrayList<>();
+        }
+        Map<String, HistoricTaskInstance> hisTaskMap = hisTaskList.stream().collect(Collectors.toMap(HistoricTaskInstance::getTaskDefinitionKey, his -> his));
         // 鏌ュ嚭鏃堕棿姝e父鐨勪换鍔ey
         List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
                 .eq(ProcessCoding::getProcessInsId, processInsId)
@@ -1386,14 +1597,19 @@
                 vo.setCreateTime(hisTask.getStartTime());
 
                 // 鏌ヨ瀹為檯澶勭悊浜�
-                long handlerUserId = Long.parseLong(hisTask.getAssignee());
-                SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
-                if (Objects.nonNull(handlerUser)) {
-                    vo.getHandlerId().add(handlerUserId);
-                    vo.getHandlerName().add(this.getUserShowName(handlerUser));
+                if (StringUtils.isNotBlank(hisTask.getAssignee())) {
+                    long handlerUserId = Long.parseLong(hisTask.getAssignee());
+                    SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
+                    if (Objects.nonNull(handlerUser)) {
+                        vo.getHandlerId().add(handlerUserId);
+                        vo.getHandlerName().add(this.getUserShowName(handlerUser));
+                        if (Objects.nonNull(handlerUser.getDept())) {
+                            vo.getHandlerUnitId().add(handlerUser.getDept().getDeptId());
+                            vo.getHandlerUnitName().add(handlerUser.getDept().getDeptName());
+                        }
+                    }
                 }
                 vo.setTaskDefinitionKey(hisTask.getTaskDefinitionKey());
-                this.setPromoterAndHandler(vo, hisTask.getIdentityLinks());
             }
 
             this.distinctVo(vo);
@@ -1401,6 +1617,81 @@
         }).collect(Collectors.toList());
         result.data(vos);
         return vos;
+    }
+
+    /**
+     * 璁剧疆鍘嗗彶浠诲姟淇℃伅
+     *
+     * @param hisTask
+     * @param vo
+     * @param projectId
+     * @param processInsId
+     */
+    private void setHisTaskInfo(HistoricTaskInstance hisTask, CustomerTaskVO vo, String projectId, String processInsId) {
+        // 鏌ュ嚭娴佺▼
+        ProcessInstance process = runtimeService.createProcessInstanceQuery().processInstanceId(processInsId).singleResult();
+        String deployId = "";
+        String processName = "";
+        String processDefinitionId = "";
+        if (Objects.nonNull(process)) {
+            deployId = process.getDeploymentId();
+            processName = process.getProcessDefinitionName();
+            processDefinitionId = process.getProcessDefinitionId();
+        } else {
+            HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInsId).singleResult();
+            deployId = hisProcess.getDeploymentId();
+            processName = hisProcess.getProcessDefinitionName();
+            processDefinitionId = hisProcess.getProcessDefinitionId();
+        }
+
+        vo.setProcessInsId(processInsId);
+        vo.setProcessDefId(processDefinitionId);
+        vo.setDeployId(deployId);
+        vo.setTaskName(hisTask.getName());
+        vo.setProcessName(processName);
+
+        // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
+        List<Long> handlerIds = new ArrayList<>(2);
+        List<String> handlerNames = new ArrayList<>(2);
+        List<Long> handlerUnitIds = new ArrayList<>(2);
+        List<String> handlerUnitNames = new ArrayList<>(2);
+        List<String> promoterNames = new ArrayList<>(2);
+        List<String> promoterUnitNames = new ArrayList<>(2);
+        vo.setHandlerId(handlerIds);
+        vo.setHandlerName(handlerNames);
+        vo.setHandlerUnitId(handlerUnitIds);
+        vo.setHandlerUnitName(handlerUnitNames);
+        vo.setPromoterName(promoterNames);
+        vo.setPromoterUnitName(promoterUnitNames);
+        List<UserTask> targetUserTasks = this.getAllUserTaskElement(processDefinitionId).stream().filter(userTask -> hisTask.getTaskDefinitionKey().equals(userTask.getId())).collect(Collectors.toList());
+        UserTask userTask = null;
+        if (! CollectionUtils.isEmpty(targetUserTasks)) {
+            userTask = targetUserTasks.get(0);
+        }
+        this.setCandidateInfo(userTask, vo, projectId, processInsId);
+
+
+        vo.setTaskStatus(TaskStatusEnum.FINISHED);
+        // 濡傛灉鏄凡瀹屾垚鐨勶紝淇℃伅闇�瑕佸崟鐙祴鍊�
+        vo.setTaskId(hisTask.getId());
+        vo.setExecutionId(hisTask.getExecutionId());
+        vo.setCreateTime(hisTask.getStartTime());
+
+        // 鏌ヨ瀹為檯澶勭悊浜�
+        if (StringUtils.isNotBlank(hisTask.getAssignee())) {
+            long handlerUserId = Long.parseLong(hisTask.getAssignee());
+            SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
+            if (Objects.nonNull(handlerUser)) {
+                vo.getHandlerId().add(handlerUserId);
+                vo.getHandlerName().add(this.getUserShowName(handlerUser));
+                if (Objects.nonNull(handlerUser.getDept())) {
+                    vo.getHandlerUnitId().add(handlerUser.getDept().getDeptId());
+                    vo.getHandlerUnitName().add(handlerUser.getDept().getDeptName());
+                }
+            }
+        }
+        vo.setTaskDefinitionKey(hisTask.getTaskDefinitionKey());
+        this.distinctVo(vo);
     }
 
     /**
@@ -1452,36 +1743,16 @@
      * @return
      */
     private Long getOvertimeTaskNum(String processInsId) {
-        // 鏌ュ嚭杩愯鍦ㄧ殑浠诲姟key
-        List<Task> taskList = taskService.createTaskQuery().processInstanceId(processInsId).list();
-
-        if (CollectionUtils.isEmpty(taskList)) {
+        // 鏌ュ嚭宸茶秴鏃剁殑浠诲姟id
+        List<ProcessCoding> overtimeRecords = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
+                .eq(ProcessCoding::getProcessInsId, processInsId)
+                .eq(ProcessCoding::getOvertimeStatus, ProcessOverTimeConstants.OVERTIME)
+                .orderByDesc(ProcessCoding::getGmtCreate)
+                .list();
+        if (CollectionUtils.isEmpty(overtimeRecords)) {
             return 0L;
         }
-        List<String> taskKeys = taskList.stream().map(Task::getTaskDefinitionKey).distinct().collect(Collectors.toList());
-        Map<String, Task> taskMap = taskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
-        // 鏌ュ嚭鏁版嵁搴撶殑浠诲姟key
-        List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
-                .eq(ProcessCoding::getProcessInsId, processInsId)
-                .in(ProcessCoding::getTaskDefKey, taskKeys)
-                .list();
-        List<Task> tList = new ArrayList<>();
-        // 鍒ゆ柇
-        for (String key : taskMap.keySet()) {
-            List<ProcessCoding> targetProcessCodings = codeList.stream().filter(code -> key.equals(code.getTaskDefKey())).collect(Collectors.toList());
-            // 濡傛灉宸插畬鎴愮殑浠诲姟娌′粠鏁版嵁搴撴煡鎵惧嚭鏉ワ紝璇存槑璇ヤ换鍔℃病閰嶇疆璧嬬爜绛夋椂闂达紝鐩存帴璁剧疆涓烘寜鏃跺畬鎴�
-            if (CollectionUtils.isEmpty(targetProcessCodings)) {
-                tList.add(taskMap.get(key));
-            } else {
-                // 鎸夌収鏃堕棿闄嶅簭鎺掑垪
-                targetProcessCodings.sort(Comparator.comparing(ProcessCoding::getGmtCreate).reversed());
-                ProcessCoding latestProjectProcess = targetProcessCodings.get(0);
-                if (Objects.nonNull(latestProjectProcess) && ProcessOverTimeConstants.OVERTIME.equals(latestProjectProcess.getOvertimeStatus())) {
-                    tList.add(taskMap.get(key));
-                }
-            }
-        }
-        return Long.valueOf(taskList.size());
+        return Long.valueOf(overtimeRecords.size());
     }
 
     /**
@@ -1500,63 +1771,108 @@
         int startNum = pageSize * (pageNum - 1);
         int endNum = startNum + pageSize;
 
-        // 鏌ュ嚭杩愯鍦ㄧ殑浠诲姟key
-        List<Task> taskList = new ArrayList<>(12);
-        if (StringUtils.isNotBlank(taskName)) {
-            taskList = taskService.createTaskQuery().processInstanceId(processInsId).taskNameLike(taskName).orderByTaskCreateTime().desc().list();
-        } else {
-            taskList = taskService.createTaskQuery().processInstanceId(processInsId).orderByTaskCreateTime().desc().list();
-        }
-        if (CollectionUtils.isEmpty(taskList)) {
+        // 鏌ュ嚭宸茶秴鏃剁殑浠诲姟id
+        List<ProcessCoding> overtimeRecords = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
+                .eq(ProcessCoding::getProcessInsId, processInsId)
+                .eq(ProcessCoding::getOvertimeStatus, ProcessOverTimeConstants.OVERTIME)
+                .orderByDesc(ProcessCoding::getGmtCreate)
+                .list();
+        if (CollectionUtils.isEmpty(overtimeRecords)) {
             result.total(0);
             return new ArrayList<>();
         }
-        List<String> taskKeys = taskList.stream().map(Task::getTaskDefinitionKey).distinct().collect(Collectors.toList());
-        Map<String, Task> taskMap = taskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
-        // 鏌ュ嚭鏁版嵁搴撶殑浠诲姟key
-        List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
-                .eq(ProcessCoding::getProcessInsId, processInsId)
-                .in(ProcessCoding::getTaskDefKey, taskKeys)
-                .list();
-        List<Task> tList = new ArrayList<>();
-        // 鍒ゆ柇
-        for (String key : taskMap.keySet()) {
-            List<ProcessCoding> targetProcessCodings = codeList.stream().filter(code -> key.equals(code.getTaskDefKey())).collect(Collectors.toList());
-            // 濡傛灉宸插畬鎴愮殑浠诲姟娌′粠鏁版嵁搴撴煡鎵惧嚭鏉ワ紝璇存槑璇ヤ换鍔℃病閰嶇疆璧嬬爜绛夋椂闂达紝鐩存帴璁剧疆涓烘寜鏃跺畬鎴�
-            if (CollectionUtils.isEmpty(targetProcessCodings)) {
-                tList.add(taskMap.get(key));
-            } else {
-                // 鎸夌収鏃堕棿闄嶅簭鎺掑垪
-                targetProcessCodings.sort(Comparator.comparing(ProcessCoding::getGmtCreate).reversed());
-                ProcessCoding latestProjectProcess = targetProcessCodings.get(0);
-                if (Objects.nonNull(latestProjectProcess) && ProcessOverTimeConstants.OVERTIME.equals(latestProjectProcess.getOvertimeStatus())) {
-                    tList.add(taskMap.get(key));
-                }
-            }
-        }
-
-        if (startNum >= tList.size()) {
+        if (startNum >= overtimeRecords.size()) {
             // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
             return new ArrayList<>();
         }
-        result.total(tList.size());
-        int end = Math.min(endNum, tList.size());
-        List<Task> pageTaskList = tList.subList(startNum, end);
-        List<String> taskDefs = pageTaskList.stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
-        Map<String, Task> keyMap = pageTaskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
+        result.total(overtimeRecords.size());
+        int end = Math.min(endNum, overtimeRecords.size());
+        List<ProcessCoding> pageOvertimeRecords = overtimeRecords.subList(startNum, end);
 
-        // 寰楀埌鐩爣浠诲姟瀵瑰簲鐨勫畾涔�
-        List<UserTask> finishedUserTaskElement = this.getAllUserTaskElement(processDefinitionId).stream().filter(el -> taskDefs.contains(el.getId())).collect(Collectors.toList());
-
-        // 鏌ヨ浠诲姟鐩稿叧淇℃伅
-        List<CustomerTaskVO> vos = finishedUserTaskElement.stream().map(userTask -> {
-            Task task = keyMap.get(userTask.getId());
+        List<CustomerTaskVO> vos = pageOvertimeRecords.stream().map(record -> {
             CustomerTaskVO vo = new CustomerTaskVO();
-            this.setRuntimeTaskInfo(task, vo, projectId);
-            return vo;
-        }).collect(Collectors.toList());
+            Task task = taskService.createTaskQuery().processInstanceId(processInsId).taskId(record.getTaskId()).singleResult();
+            if (Objects.nonNull(task)) {
+                this.setRuntimeTaskInfo(task, vo, projectId);
+                vo.setTaskStatus(TaskStatusEnum.OVER_TIME);
+                return vo;
+            } else {
+                List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery()
+                        .finished()
+                        .processInstanceId(processInsId)
+                        .taskId(record.getTaskId())
+                        .orderByHistoricTaskInstanceStartTime()
+                        .desc()
+                        .list();
+                if (CollectionUtils.isEmpty(list)) {
+                    return null;
+                }
+                List<HistoricTaskInstance> hisTask = this.distinctHisTask(list);
+                this.setHisTaskInfo(hisTask.get(0), vo, projectId, processInsId);
+                vo.setTaskStatus(TaskStatusEnum.OVER_TIME_FINISHED);
+                return vo;
+            }
+        }).filter(Objects::nonNull).collect(Collectors.toList());
         result.data(vos);
         return vos;
+
+//        // 鏌ュ嚭杩愯鍦ㄧ殑浠诲姟key
+//        List<Task> taskList = new ArrayList<>(12);
+//        if (StringUtils.isNotBlank(taskName)) {
+//            taskList = taskService.createTaskQuery().processInstanceId(processInsId).taskNameLike(taskName).orderByTaskCreateTime().desc().list();
+//        } else {
+//            taskList = taskService.createTaskQuery().processInstanceId(processInsId).orderByTaskCreateTime().desc().list();
+//        }
+//        if (CollectionUtils.isEmpty(taskList)) {
+//            result.total(0);
+//            return new ArrayList<>();
+//        }
+//        List<String> taskKeys = taskList.stream().map(Task::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+//        Map<String, Task> taskMap = taskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
+//        // 鏌ュ嚭鏁版嵁搴撶殑浠诲姟key
+//        List<ProcessCoding> codeList = new LambdaQueryChainWrapper<>(processCodingService.getBaseMapper())
+//                .eq(ProcessCoding::getProcessInsId, processInsId)
+//                .in(ProcessCoding::getTaskDefKey, taskKeys)
+//                .list();
+//        List<Task> tList = new ArrayList<>();
+//        // 鍒ゆ柇
+//        for (String key : taskMap.keySet()) {
+//            List<ProcessCoding> targetProcessCodings = codeList.stream().filter(code -> key.equals(code.getTaskDefKey())).collect(Collectors.toList());
+//            // 濡傛灉宸插畬鎴愮殑浠诲姟娌′粠鏁版嵁搴撴煡鎵惧嚭鏉ワ紝璇存槑璇ヤ换鍔℃病閰嶇疆璧嬬爜绛夋椂闂达紝鐩存帴璁剧疆涓烘寜鏃跺畬鎴�
+//            if (CollectionUtils.isEmpty(targetProcessCodings)) {
+//                tList.add(taskMap.get(key));
+//            } else {
+//                // 鎸夌収鏃堕棿闄嶅簭鎺掑垪
+//                targetProcessCodings.sort(Comparator.comparing(ProcessCoding::getGmtCreate).reversed());
+//                ProcessCoding latestProjectProcess = targetProcessCodings.get(0);
+//                if (Objects.nonNull(latestProjectProcess) && ProcessOverTimeConstants.OVERTIME.equals(latestProjectProcess.getOvertimeStatus())) {
+//                    tList.add(taskMap.get(key));
+//                }
+//            }
+//        }
+//
+//        if (startNum >= tList.size()) {
+//            // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
+//            return new ArrayList<>();
+//        }
+//        result.total(tList.size());
+//        int end = Math.min(endNum, tList.size());
+//        List<Task> pageTaskList = tList.subList(startNum, end);
+//        List<String> taskDefs = pageTaskList.stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+//        Map<String, Task> keyMap = pageTaskList.stream().collect(Collectors.toMap(Task::getTaskDefinitionKey, his -> his));
+//
+//        // 寰楀埌鐩爣浠诲姟瀵瑰簲鐨勫畾涔�
+//        List<UserTask> finishedUserTaskElement = this.getAllUserTaskElement(processDefinitionId).stream().filter(el -> taskDefs.contains(el.getId())).collect(Collectors.toList());
+//
+//        // 鏌ヨ浠诲姟鐩稿叧淇℃伅
+//        List<CustomerTaskVO> vos = finishedUserTaskElement.stream().map(userTask -> {
+//            Task task = keyMap.get(userTask.getId());
+//            CustomerTaskVO vo = new CustomerTaskVO();
+//            this.setRuntimeTaskInfo(task, vo, projectId);
+//            return vo;
+//        }).collect(Collectors.toList());
+//        result.data(vos);
+//        return vos;
     }
 
     /**
@@ -1596,6 +1912,8 @@
         }
         return Long.valueOf(tList.size());
     }
+
+
 
     /**
      * 鏌ヨ鍗冲皢瓒呮椂鐨勪换鍔�
@@ -1672,6 +1990,477 @@
         return vos;
     }
 
+    @Override
+    public void getIndexWaitTask(String s, int pageSize, int pageNum, Result result) {
+        // 鏌ュ嚭瀹圭己杩囩殑浠诲姟
+        List<ProcessLog> allWaitTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.WAIT)
+                .orderByDesc(ProcessLog::getGmtCreate)
+                .list();
+        // 鎺掗櫎瀹圭己鍚庡張瀹屾垚鐨勪换鍔�
+        List<ProcessLog> finishedTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.FINISHED)
+                .list();
+        List<String> finishedTaskIds = finishedTaskList.stream().map(ProcessLog::getTaskId).distinct().collect(Collectors.toList());
+        // 寰楀埌鏈畬鎴愮殑瀹圭己浠诲姟
+        List<String> waitTaskIds = allWaitTaskList.stream().filter(log -> !finishedTaskIds.contains(log.getTaskId())).map(ProcessLog::getTaskId).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(waitTaskIds)) {
+            result.total(0l);
+            result.data(new ArrayList<>());
+            return;
+        }
+        List<HistoricTaskInstance> hisTasks = waitTaskIds.stream().map(waitTaskId -> {
+            List<ProcessLog> logs = allWaitTaskList.stream().filter(item -> item.getTaskId().equals(waitTaskId)).collect(Collectors.toList());
+            HistoricTaskInstance hisTask = null;
+            if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(logs)) {
+                // 瀹圭己鐨勪换鍔¢兘灞炰簬鍘嗗彶浠诲姟锛屽彧鏄渶瑕佽ˉ琛ㄥ崟鏁版嵁
+                HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery()
+                        .processInstanceId(logs.get(0).getProcessInsId())
+                        .taskId(waitTaskId)
+                        .includeIdentityLinks()
+                        .orderByHistoricTaskInstanceStartTime()
+                        .desc();
+                if (!SecurityUtils.getLoginUser().getUser().isAdmin()) {
+                    query
+                            .or()
+                            .taskCandidateGroupIn(taskCommonService.getCurrentUserGroups())
+                            .taskCandidateUser(SecurityUtils.getUserId() + "")
+                            .taskAssignee(SecurityUtils.getUserId() + "")
+                            .endOr();
+                }
+                List<HistoricTaskInstance> hisTaskList = query.list();
+                hisTaskList = this.distinctHisTask(hisTaskList);
+                if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(hisTaskList)) {
+                    hisTask = hisTaskList.get(0);
+                }
+            }
+            return hisTask;
+        }).filter(Objects::nonNull).collect(Collectors.toList());
+
+        if (CollectionUtils.isEmpty(hisTasks)) {
+            result.total(0l);
+            result.data(new ArrayList<>());
+            return;
+        }
+        int startNum = pageSize * (pageNum - 1);
+        int endNum = startNum + pageSize;
+        if (startNum >= hisTasks.size()) {
+            result.total(0l);
+            // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
+            result.data(new ArrayList<>());
+            return;
+        }
+        result.total(hisTasks.size());
+        int end = Math.min(endNum, hisTasks.size());
+        List<HistoricTaskInstance> targetTask = hisTasks.subList(startNum, end);
+
+        // 杞崲鎴怴O
+        List<IndexCustomerTaskVO> vos = targetTask.stream().map(userTask -> {
+            IndexCustomerTaskVO vo = new IndexCustomerTaskVO();
+            vo.setProcessInsId(userTask.getProcessInstanceId());
+            vo.setProcessDefId(userTask.getProcessDefinitionId());
+
+            // 鏌ュ嚭娴佺▼
+            ProcessInstance process = runtimeService.createProcessInstanceQuery().processInstanceId(userTask.getProcessInstanceId()).singleResult();
+            String deployId = "";
+            String processName = "";
+            if (Objects.nonNull(process)) {
+                deployId = process.getDeploymentId();
+                processName = process.getProcessDefinitionName();
+            } else {
+                HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(userTask.getProcessInstanceId()).singleResult();
+                deployId = hisProcess.getDeploymentId();
+                processName = hisProcess.getProcessDefinitionName();
+            }
+
+            String finalDeployId = deployId;
+            String finalProcessName = processName;
+
+            vo.setDeployId(finalDeployId);
+            vo.setTaskName(userTask.getName());
+            vo.setProcessName(finalProcessName);
+
+            // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
+            List<Long> handlerIds = new ArrayList<>(2);
+            List<String> handlerNames = new ArrayList<>(2);
+            List<Long> handlerUnitIds = new ArrayList<>(2);
+            List<String> handlerUnitNames = new ArrayList<>(2);
+            List<String> promoterNames = new ArrayList<>(2);
+            List<String> promoterUnitNames = new ArrayList<>(2);
+            vo.setHandlerId(handlerIds);
+            vo.setHandlerName(handlerNames);
+            vo.setHandlerUnitId(handlerUnitIds);
+            vo.setHandlerUnitName(handlerUnitNames);
+            vo.setPromoterName(promoterNames);
+            vo.setPromoterUnitName(promoterUnitNames);
+
+            ProjectProcess projectProcess = new LambdaQueryChainWrapper<>(baseMapper)
+                    .eq(ProjectProcess::getProcessInsId, userTask.getProcessInstanceId())
+                    .one();
+            if (Objects.isNull(projectProcess)) {
+                throw new RuntimeException("椤圭洰娴佺▼鏈惎鍔�");
+            }
+            String projectId = "";
+            String projectName = "";
+            if (Objects.nonNull(projectProcess)) {
+                if (projectProcess.getProjectType().equals(ProjectProcessTypeEnum.PROJECT)) {
+                    ProjectInfo project = projectInfoMapper.selectById(projectProcess.getProjectId());
+                    if (Objects.nonNull(project)) {
+                        projectId = projectProcess.getProjectId();
+                        projectName = project.getProjectName();
+                    }
+                } else if (projectProcess.getProjectType().equals(ProjectProcessTypeEnum.ENGINEERING)) {
+                    ProjectEngineering engineering = projectEngineeringMapper.selectById(projectProcess.getProjectId());
+                    if (Objects.nonNull(engineering)) {
+                        projectId = projectProcess.getProjectId();
+                        projectName = engineering.getProjectName();
+                    }
+                }
+            }
+            vo.setProjectId(projectId);
+            vo.setProjectName(projectName);
+            List<UserTask> uTaskList = this.getAllUserTaskElement(userTask.getProcessDefinitionId()).stream().filter(item -> item.getId().equals(userTask.getTaskDefinitionKey())).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(uTaskList)) {
+                throw new RuntimeException("鏈壘鍒版祦绋嬩换鍔¤璁�");
+            }
+            this.setCandidateInfo(uTaskList.get(0), vo, projectProcess.getProjectId(), userTask.getProcessInstanceId());
+
+            vo.setTaskStatus(TaskStatusEnum.WAIT);
+            // 濡傛灉鏄凡瀹屾垚鐨勶紝淇℃伅闇�瑕佸崟鐙祴鍊�
+            vo.setTaskId(userTask.getId());
+            vo.setExecutionId(userTask.getExecutionId());
+            vo.setCreateTime(userTask.getStartTime());
+
+            vo.setTaskDefinitionKey(userTask.getTaskDefinitionKey());
+
+            this.distinctVo(vo);
+            return vo;
+        }).collect(Collectors.toList());
+        result.data(vos);
+    }
+
+    /**
+     * 鑾峰彇璺宠繃浠诲姟
+     *
+     * @param processInsId
+     * @return
+     */
+    private Long getJumpTaskNum(String processInsId) {
+        // 鏌ュ嚭璺宠繃鐨勪换鍔�
+        List<ProcessLog> allJumpTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.JUMP)
+                .orderByDesc(ProcessLog::getGmtCreate)
+                .list();
+        // 鎺掗櫎椹冲洖鐨�
+        List<String> rejectTaskIds = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .select(ProcessLog::getTaskId)
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.REJECT)
+                .orderByDesc(ProcessLog::getGmtCreate)
+                .list().stream().map(ProcessLog::getTaskId).collect(Collectors.toList());
+
+        List<String> jumpTaskIds = allJumpTaskList.stream().map(ProcessLog::getTaskId).collect(Collectors.toList());
+        jumpTaskIds.removeAll(rejectTaskIds);
+        if(CollectionUtils.isEmpty(jumpTaskIds)) {
+            return 0L;
+        }
+        List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
+                .processInstanceId(processInsId)
+                .finished()
+                .taskIds(jumpTaskIds)
+                .includeIdentityLinks()
+                .orderByHistoricTaskInstanceStartTime()
+                .desc()
+                .list();
+        hisTaskList = this.distinctHisTask(hisTaskList);
+        // 鎺掗櫎杩愯鏃朵换鍔�
+        List<String> runTaskKeys = taskService.createTaskQuery().processInstanceId(processInsId).list().stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+        hisTaskList = hisTaskList.stream().filter(his -> !runTaskKeys.contains(his.getTaskDefinitionKey())).collect(Collectors.toList());
+        return Long.valueOf(hisTaskList.size());
+    }
+
+    /**
+     * 鑾峰彇璺宠繃浠诲姟
+     *
+     * @param projectId
+     * @param processDefinitionId
+     * @param processInsId
+     * @param taskName
+     * @param pageNum
+     * @param pageSize
+     * @param result
+     * @return
+     */
+    private List<CustomerTaskVO> getJumpTask(String projectId,
+                                             String processDefinitionId,
+                                             String processInsId,
+                                             String taskName,
+                                             Integer pageNum,
+                                             Integer pageSize,
+                                             Result result) {
+        // 鏌ュ嚭璺宠繃鐨勪换鍔�
+        List<ProcessLog> allJumpTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.JUMP)
+                .like(StringUtils.isNotBlank(taskName), ProcessLog::getTaskName, taskName)
+                .orderByDesc(ProcessLog::getGmtCreate)
+                .list();
+        // 鎺掗櫎椹冲洖鐨�
+        List<String> rejectTaskIds = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .select(ProcessLog::getTaskId)
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.REJECT)
+                .like(StringUtils.isNotBlank(taskName), ProcessLog::getTaskName, taskName)
+                .orderByDesc(ProcessLog::getGmtCreate)
+                .list().stream().map(ProcessLog::getTaskId).collect(Collectors.toList());
+
+        List<String> jumpTaskIds = allJumpTaskList.stream().map(ProcessLog::getTaskId).collect(Collectors.toList());
+        jumpTaskIds.removeAll(rejectTaskIds);
+        if(CollectionUtils.isEmpty(jumpTaskIds)) {
+            result.total(0l);
+            return new ArrayList<>();
+        }
+        List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
+                .processInstanceId(processInsId)
+                .finished()
+                .taskIds(jumpTaskIds)
+                .includeIdentityLinks()
+                .orderByHistoricTaskInstanceStartTime()
+                .desc()
+                .list();
+        hisTaskList = this.distinctHisTask(hisTaskList);
+        // 鎺掗櫎杩愯鏃朵换鍔�
+        List<String> runTaskKeys = taskService.createTaskQuery().processInstanceId(processInsId).list().stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+        hisTaskList = hisTaskList.stream().filter(his -> !runTaskKeys.contains(his.getTaskDefinitionKey())).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(hisTaskList)) {
+            result.total(0l);
+            return new ArrayList<>();
+        }
+        int startNum = pageSize * (pageNum - 1);
+        int endNum = startNum + pageSize;
+        if (startNum >= hisTaskList.size()) {
+            result.total(0l);
+            // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
+            return new ArrayList<>();
+        }
+        result.total(hisTaskList.size());
+        int end = Math.min(endNum, hisTaskList.size());
+        List<HistoricTaskInstance> targetTaskList = hisTaskList.subList(startNum, end);
+
+        // 杞崲鎴怴O
+        // 寰楀埌鐩爣浠诲姟瀵瑰簲鐨勫畾涔�
+        List<String> taskDefs = targetTaskList.stream().map(HistoricTaskInstance::getTaskDefinitionKey).collect(Collectors.toList());
+        Map<String, HistoricTaskInstance> keyMap = targetTaskList.stream().collect(Collectors.toMap(HistoricTaskInstance::getTaskDefinitionKey, his -> his));
+        List<UserTask> finishedUserTaskElement = this.getAllUserTaskElement(processDefinitionId).stream().filter(el -> taskDefs.contains(el.getId())).collect(Collectors.toList());
+
+        // 鏌ュ嚭娴佺▼
+        ProcessInstance process = runtimeService.createProcessInstanceQuery().processInstanceId(processInsId).singleResult();
+        String deployId = "";
+        String processName = "";
+        if (Objects.nonNull(process)) {
+            deployId = process.getDeploymentId();
+            processName = process.getProcessDefinitionName();
+        } else {
+            HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInsId).singleResult();
+            deployId = hisProcess.getDeploymentId();
+            processName = hisProcess.getProcessDefinitionName();
+        }
+
+        String finalDeployId = deployId;
+        String finalProcessName = processName;
+        List<CustomerTaskVO> vos = finishedUserTaskElement.stream().map(userTask -> {
+            CustomerTaskVO vo = new CustomerTaskVO();
+            vo.setProcessInsId(processInsId);
+            vo.setProcessDefId(processDefinitionId);
+            vo.setDeployId(finalDeployId);
+            vo.setTaskName(userTask.getName());
+            vo.setProcessName(finalProcessName);
+
+            // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
+            List<Long> handlerIds = new ArrayList<>(2);
+            List<String> handlerNames = new ArrayList<>(2);
+            List<Long> handlerUnitIds = new ArrayList<>(2);
+            List<String> handlerUnitNames = new ArrayList<>(2);
+            List<String> promoterNames = new ArrayList<>(2);
+            List<String> promoterUnitNames = new ArrayList<>(2);
+            vo.setHandlerId(handlerIds);
+            vo.setHandlerName(handlerNames);
+            vo.setHandlerUnitId(handlerUnitIds);
+            vo.setHandlerUnitName(handlerUnitNames);
+            vo.setPromoterName(promoterNames);
+            vo.setPromoterUnitName(promoterUnitNames);
+
+            this.setCandidateInfo(userTask, vo, projectId, processInsId);
+            HistoricTaskInstance hisTask = keyMap.get(userTask.getId());
+            if (Objects.nonNull(hisTask)) {
+                vo.setTaskStatus(TaskStatusEnum.JUMP);
+                // 濡傛灉鏄凡瀹屾垚鐨勶紝淇℃伅闇�瑕佸崟鐙祴鍊�
+                vo.setTaskId(hisTask.getId());
+                vo.setExecutionId(hisTask.getExecutionId());
+                vo.setCreateTime(hisTask.getStartTime());
+
+                // 鏌ヨ瀹為檯澶勭悊浜�
+                if (StringUtils.isNotBlank(hisTask.getAssignee())) {
+                    long handlerUserId = Long.parseLong(hisTask.getAssignee());
+                    SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
+                    if (Objects.nonNull(handlerUser)) {
+                        vo.getHandlerId().add(handlerUserId);
+                        vo.getHandlerName().add(this.getUserShowName(handlerUser));
+                        if (Objects.nonNull(handlerUser.getDept())) {
+                            vo.getHandlerUnitId().add(handlerUser.getDept().getDeptId());
+                            vo.getHandlerUnitName().add(handlerUser.getDept().getDeptName());
+                        }
+                    }
+                }
+                this.setHandler(vo, hisTask.getIdentityLinks());
+                vo.setTaskDefinitionKey(hisTask.getTaskDefinitionKey());
+            }
+            this.distinctVo(vo);
+            return vo;
+        }).collect(Collectors.toList());
+        result.data(vos);
+        return vos;
+    }
+
+    /**
+     * 瀹圭己浠诲姟鍒嗛〉
+     *
+     * @param projectId
+     * @param processDefinitionId
+     * @param processInsId
+     * @param taskName
+     * @param pageNum
+     * @param pageSize
+     * @param result
+     * @return
+     */
+    private List<CustomerTaskVO> getWaitTask(String projectId,
+                                             String processDefinitionId,
+                                             String processInsId,
+                                             String taskName,
+                                             Integer pageNum,
+                                             Integer pageSize,
+                                             Result result) {
+
+        // 鏌ュ嚭瀹圭己杩囩殑浠诲姟
+        List<ProcessLog> allWaitTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.WAIT)
+                .like(StringUtils.isNotBlank(taskName), ProcessLog::getTaskName, taskName)
+                .orderByDesc(ProcessLog::getGmtCreate)
+                .list();
+        // 鎺掗櫎瀹圭己鍚庡張瀹屾垚鐨勪换鍔�
+        List<ProcessLog> finishedTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .in(ProcessLog::getEventType, ProcessLogEventTypeEnum.FINISHED, ProcessLogEventTypeEnum.REJECT)
+                .list();
+        List<String> finishedTaskIds = finishedTaskList.stream().map(ProcessLog::getTaskId).distinct().collect(Collectors.toList());
+        // 寰楀埌鏈畬鎴愮殑瀹圭己浠诲姟
+        List<String> waitTaskIds = allWaitTaskList.stream().filter(log -> !finishedTaskIds.contains(log.getTaskId())).map(ProcessLog::getTaskId).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(waitTaskIds)) {
+            result.total(0l);
+            return new ArrayList<>();
+        }
+        // 瀹圭己鐨勪换鍔¢兘灞炰簬鍘嗗彶浠诲姟锛屽彧鏄渶瑕佽ˉ琛ㄥ崟鏁版嵁
+        List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
+                .processInstanceId(processInsId)
+                .taskIds(waitTaskIds)
+                .includeIdentityLinks()
+                .orderByHistoricTaskInstanceStartTime()
+                .desc()
+                .list();
+        hisTaskList = this.distinctHisTask(hisTaskList);
+        // 鎺掗櫎杩愯鏃朵换鍔�
+        List<String> runTaskKeys = taskService.createTaskQuery().processInstanceId(processInsId).list().stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+        hisTaskList = hisTaskList.stream().filter(his -> !runTaskKeys.contains(his.getTaskDefinitionKey())).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(hisTaskList)) {
+            result.total(0l);
+            return new ArrayList<>();
+        }
+        int startNum = pageSize * (pageNum - 1);
+        int endNum = startNum + pageSize;
+        if (startNum >= hisTaskList.size()) {
+            result.total(0l);
+            // 濡傛灉璧峰绱㈠紩瓒呭嚭浜嗗垪琛ㄧ殑澶у皬锛岃繑鍥炰竴涓┖鍒楄〃
+            return new ArrayList<>();
+        }
+        result.total(hisTaskList.size());
+        int end = Math.min(endNum, hisTaskList.size());
+        List<HistoricTaskInstance> targetTask = hisTaskList.subList(startNum, end);
+
+        // 杞崲鎴怴O
+        // 寰楀埌鐩爣浠诲姟瀵瑰簲鐨勫畾涔�
+        List<String> taskDefs = targetTask.stream().map(HistoricTaskInstance::getTaskDefinitionKey).collect(Collectors.toList());
+        Map<String, HistoricTaskInstance> keyMap = targetTask.stream().collect(Collectors.toMap(HistoricTaskInstance::getTaskDefinitionKey, his -> his));
+        List<UserTask> finishedUserTaskElement = this.getAllUserTaskElement(processDefinitionId).stream().filter(el -> taskDefs.contains(el.getId())).collect(Collectors.toList());
+        // 鏌ュ嚭娴佺▼
+        ProcessInstance process = runtimeService.createProcessInstanceQuery().processInstanceId(processInsId).singleResult();
+        String deployId = "";
+        String processName = "";
+        if (Objects.nonNull(process)) {
+            deployId = process.getDeploymentId();
+            processName = process.getProcessDefinitionName();
+        } else {
+            HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInsId).singleResult();
+            deployId = hisProcess.getDeploymentId();
+            processName = hisProcess.getProcessDefinitionName();
+        }
+
+        String finalDeployId = deployId;
+        String finalProcessName = processName;
+        List<CustomerTaskVO> vos = finishedUserTaskElement.stream().map(userTask -> {
+            CustomerTaskVO vo = new CustomerTaskVO();
+            vo.setProcessInsId(processInsId);
+            vo.setProcessDefId(processDefinitionId);
+            vo.setDeployId(finalDeployId);
+            vo.setTaskName(userTask.getName());
+            vo.setProcessName(finalProcessName);
+
+            // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
+            List<Long> handlerIds = new ArrayList<>(2);
+            List<String> handlerNames = new ArrayList<>(2);
+            List<Long> handlerUnitIds = new ArrayList<>(2);
+            List<String> handlerUnitNames = new ArrayList<>(2);
+            List<String> promoterNames = new ArrayList<>(2);
+            List<String> promoterUnitNames = new ArrayList<>(2);
+            vo.setHandlerId(handlerIds);
+            vo.setHandlerName(handlerNames);
+            vo.setHandlerUnitId(handlerUnitIds);
+            vo.setHandlerUnitName(handlerUnitNames);
+            vo.setPromoterName(promoterNames);
+            vo.setPromoterUnitName(promoterUnitNames);
+
+            this.setCandidateInfo(userTask, vo, projectId, processInsId);
+            HistoricTaskInstance hisTask = keyMap.get(userTask.getId());
+            if (Objects.nonNull(hisTask)) {
+                vo.setTaskStatus(TaskStatusEnum.WAIT);
+                // 濡傛灉鏄凡瀹屾垚鐨勶紝淇℃伅闇�瑕佸崟鐙祴鍊�
+                vo.setTaskId(hisTask.getId());
+                vo.setExecutionId(hisTask.getExecutionId());
+                vo.setCreateTime(hisTask.getStartTime());
+
+                // 鏌ヨ瀹為檯澶勭悊浜�
+                if (StringUtils.isNotBlank(hisTask.getAssignee())) {
+                    long handlerUserId = Long.parseLong(hisTask.getAssignee());
+                    SysUser handlerUser = sysUserService.selectUserById(handlerUserId);
+                    if (Objects.nonNull(handlerUser)) {
+                        vo.getHandlerId().add(handlerUserId);
+                        if (Objects.nonNull(handlerUser.getDept())) {
+                            vo.getHandlerUnitId().add(handlerUser.getDept().getDeptId());
+                        }
+                    }
+                }
+                this.setHandler(vo, hisTask.getIdentityLinks());
+                vo.setTaskDefinitionKey(hisTask.getTaskDefinitionKey());
+            }
+            this.distinctVo(vo);
+            return vo;
+        }).collect(Collectors.toList());
+        result.data(vos);
+        return vos;
+    }
+
     /**
      * 鏌ヨ鍓╀綑浜嬮」锛堟湭寮�濮嬬殑浠诲姟锛�
      *
@@ -1706,8 +2495,14 @@
 
         // 鎺掗櫎杩涜涓殑浠诲姟鍜屽凡瀹屾垚鐨勪换鍔�
         List<String> runTaskKeyList = taskService.createTaskQuery().processInstanceId(processInsId).list().stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
-        List<String> finishedTaskKeyList = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInsId).finished().list().stream().map(HistoricTaskInstance::getTaskDefinitionKey).distinct().collect(Collectors.toList());
-        allUserTaskElement = allUserTaskElement.stream().filter(el -> !runTaskKeyList.contains(el.getId()) && !finishedTaskKeyList.contains(el.getId())).collect(Collectors.toList());
+        List<String> finishedTaskKeyList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .select(ProcessLog::getTaskDefKey)
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .in(ProcessLog::getEventType, ProcessLogEventTypeEnum.FINISHED, ProcessLogEventTypeEnum.JUMP, ProcessLogEventTypeEnum.WAIT)
+                .list().stream().map(ProcessLog::getTaskDefKey).collect(Collectors.toList());
+        finishedTaskKeyList.addAll(runTaskKeyList);
+//        List<String> finishedTaskKeyList = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInsId).finished().list().stream().map(HistoricTaskInstance::getTaskDefinitionKey).distinct().collect(Collectors.toList());
+        allUserTaskElement = allUserTaskElement.stream().filter(el -> finishedTaskKeyList.indexOf(el.getId()) == -1).collect(Collectors.toList());
         // 妯℃嫙妯$硦鏌ヨ
         if (StringUtils.isNotBlank(taskName)) {
             allUserTaskElement = allUserTaskElement.stream().filter(taskEl -> taskEl.getName().contains(taskName)).collect(Collectors.toList());
@@ -1864,14 +2659,18 @@
             // 杩愯鏃舵湭鎵惧埌娴佺▼锛岃鏄庢祦绋嬪凡缁忕粨鏉熶簡
             return 0L;
         }
-        // 鏌ュ嚭宸插畬鎴愮殑浠诲姟锛岀敤鎬讳换鍔℃暟-宸插畬鎴愮殑灏卞緱鍒板墿浣欎簨椤�
-        List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery()
-                .processInstanceId(process.getProcessInstanceId())
-                .finished()
-                .list();
-        long num = list.stream().map(HistoricTaskInstance::getTaskDefinitionKey).distinct().count();
+        List<UserTask> allUserTaskElement = this.getAllUserTaskElement(processDefinitionId);
 
-        return totalNum - num;
+        // 鎺掗櫎杩涜涓殑浠诲姟鍜屽凡瀹屾垚鐨勪换鍔�
+        List<String> runTaskKeyList = taskService.createTaskQuery().processInstanceId(processInsId).list().stream().map(Task::getTaskDefinitionKey).collect(Collectors.toList());
+        List<String> finishedTaskKeyList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                .select(ProcessLog::getTaskDefKey)
+                .eq(ProcessLog::getProcessInsId, processInsId)
+                .in(ProcessLog::getEventType, ProcessLogEventTypeEnum.FINISHED, ProcessLogEventTypeEnum.JUMP, ProcessLogEventTypeEnum.WAIT)
+                .list().stream().map(ProcessLog::getTaskDefKey).collect(Collectors.toList());
+        finishedTaskKeyList.addAll(runTaskKeyList);
+        allUserTaskElement = allUserTaskElement.stream().filter(el -> finishedTaskKeyList.indexOf(el.getId()) == -1).collect(Collectors.toList());
+        return Long.valueOf(allUserTaskElement.size());
     }
 
     /**
@@ -1884,6 +2683,7 @@
      */
     private void setCandidateInfo(UserTask userTask, CustomerTaskVO vo, String projectId, String processInsId) {
         if (StringUtils.isNotBlank(userTask.getAssignee())) {
+            vo.setHandlerType(HandlerTypeEnum.USER);
             SysUser sysUser = sysUserService.selectUserById(Long.parseLong(userTask.getAssignee()));
             if (Objects.nonNull(sysUser)) {
                 if (Objects.nonNull(sysUser.getDept())) {
@@ -1906,7 +2706,7 @@
                         // 閮ㄩ棬
                         SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
                         if (Objects.nonNull(dept)) {
-                            vo.getPromoterUnitName().add(dept.getDeptName());
+                            vo.getPromoterUnitName().add(this.setDeptNameWithParentName(dept));
                             vo.getPromoterName().add(this.getDeptLeaderShowName(dept));
                         }
                     }
@@ -1922,23 +2722,25 @@
     }
 
     /**
+     * 璁剧疆閮ㄩ棬鍚嶇О鏃跺甫涓婁笂绾ч儴闂ㄥ悕绉�
+     * @param dept
+     */
+    private String setDeptNameWithParentName(SysDept dept) {
+        String[] str = dept.getAncestors().split(",");
+        if (str.length >= 4){
+            return dept.getParentName() + "  /  " + dept.getDeptName();
+        }else {
+            return dept.getDeptName();
+        }
+    }
+
+    /**
      * 璁剧疆浠诲姟鐨勫彂璧蜂汉&澶勭悊浜�   鍙湁寰呭姙浠诲姟鍜屽凡瀹屾垚浠诲姟鎵嶄細鎺夎繖涓柟娉�
      *
      * @param taskVO
      * @param identityLinkInfos 濡傛灉鏄凡瀹屾垚鐨勪换鍔★紝鐢ㄨ繖涓幓鍙栧叧鑱旂殑鐢ㄦ埛/鐢ㄦ埛缁�
      */
-    private void setPromoterAndHandler(CustomerTaskVO taskVO, List<? extends IdentityLinkInfo> identityLinkInfos) {
-//        this.setPromoterInfo(taskVO);
-
-        // 涓�涓换鍔″彲鑳芥湁澶氫釜鍊欓�変汉/缁勶紝鎵�浠ラ渶瑕佷娇鐢╨ist
-        List<Long> handlerIds = new ArrayList<>(2);
-        List<String> handlerNames = new ArrayList<>(2);
-        List<Long> handlerUnitIds = new ArrayList<>(2);
-        List<String> handlerUnitNames = new ArrayList<>(2);
-        taskVO.setHandlerId(handlerIds);
-        taskVO.setHandlerName(handlerNames);
-        taskVO.setHandlerUnitId(handlerUnitIds);
-        taskVO.setHandlerUnitName(handlerUnitNames);
+    private void setHandler(CustomerTaskVO taskVO, List<? extends IdentityLinkInfo> identityLinkInfos) {
 
         // 娴佺▼澶勭悊浜轰俊鎭�
         if (TaskStatusEnum.TODO.equals(taskVO.getTaskStatus())) {
@@ -1952,11 +2754,11 @@
                     SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId()));
                     if (Objects.nonNull(sysUser)) {
                         taskVO.setHandlerType(HandlerTypeEnum.USER);
-                        handlerIds.add(sysUser.getUserId());
-                        handlerNames.add(this.getUserShowName(sysUser));
+                        taskVO.getHandlerId().add(sysUser.getUserId());
+                        taskVO.getHandlerName().add(this.getUserShowName(sysUser));
                         if (Objects.nonNull(sysUser.getDept())) {
-                            handlerUnitIds.add(sysUser.getDept().getDeptId());
-                            handlerUnitNames.add(sysUser.getDept().getDeptName());
+                            taskVO.getHandlerUnitId().add(sysUser.getDept().getDeptId());
+                            taskVO.getHandlerUnitName().add(sysUser.getDept().getDeptName());
                         }
                     }
                     // 缁戝畾鐨勬槸瑙掕壊鎴栬�呮槸閮ㄩ棬锛岄渶瑕佹牴鎹甶d鍒ゆ柇
@@ -1968,32 +2770,32 @@
                             // 閮ㄩ棬
                             SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
                             if (Objects.nonNull(dept)) {
-                                handlerUnitIds.add(dept.getDeptId());
-                                handlerUnitNames.add(dept.getDeptName());
+                                taskVO.getHandlerUnitId().add(dept.getDeptId());
+                                taskVO.getHandlerUnitName().add(dept.getDeptName());
                             }
                         }
                     } else {
                         taskVO.setHandlerType(HandlerTypeEnum.ROLE);
                         SysRole role = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId()));
                         if (Objects.nonNull(role)) {
-                            handlerUnitIds.add(role.getRoleId());
-                            handlerUnitNames.add(role.getRoleName());
+                            taskVO.getHandlerUnitId().add(role.getRoleId());
+                            taskVO.getHandlerUnitName().add(role.getRoleName());
                         }
                     }
                 }
             }
-        } else if (TaskStatusEnum.FINISHED.equals(taskVO.getTaskStatus())) {
+        } else if (TaskStatusEnum.FINISHED.equals(taskVO.getTaskStatus()) || TaskStatusEnum.WAIT.equals(taskVO.getTaskStatus())) {
             for (IdentityLinkInfo identityLink : identityLinkInfos) {
                 // 缁戝畾鐨勬槸鐢ㄦ埛锛屾煡鍑虹敤鎴峰鍚嶃�侀儴闂�
                 if (StringUtils.isNotBlank(identityLink.getUserId())) {
                     taskVO.setHandlerType(HandlerTypeEnum.USER);
                     SysUser sysUser = sysUserService.selectUserById(Long.parseLong(identityLink.getUserId()));
                     if (Objects.nonNull(sysUser)) {
-                        handlerIds.add(sysUser.getUserId());
-                        handlerNames.add(this.getUserShowName(sysUser));
+                        taskVO.getHandlerId().add(sysUser.getUserId());
+                        taskVO.getHandlerName().add(this.getUserShowName(sysUser));
                         if (Objects.nonNull(sysUser.getDept())) {
-                            handlerUnitIds.add(sysUser.getDept().getDeptId());
-                            handlerUnitNames.add(sysUser.getDept().getDeptName());
+                            taskVO.getHandlerUnitId().add(sysUser.getDept().getDeptId());
+                            taskVO.getHandlerUnitName().add(sysUser.getDept().getDeptName());
                         }
                     }
                     // 缁戝畾鐨勬槸瑙掕壊锛屾煡鍑鸿鑹插悕绉�
@@ -2005,16 +2807,16 @@
                             // 閮ㄩ棬
                             SysDept dept = sysDeptService.selectDeptById(Long.parseLong(split[1]));
                             if (Objects.nonNull(dept)) {
-                                handlerUnitIds.add(dept.getDeptId());
-                                handlerUnitNames.add(dept.getDeptName());
+                                taskVO.getHandlerUnitId().add(dept.getDeptId());
+                                taskVO.getHandlerUnitName().add(dept.getDeptName());
                             }
                         }
                     } else {
                         taskVO.setHandlerType(HandlerTypeEnum.ROLE);
                         SysRole role = sysRoleService.selectRoleById(Long.parseLong(identityLink.getGroupId()));
                         if (Objects.nonNull(role)) {
-                            handlerUnitIds.add(role.getRoleId());
-                            handlerUnitNames.add(role.getRoleName());
+                            taskVO.getHandlerUnitId().add(role.getRoleId());
+                            taskVO.getHandlerUnitName().add(role.getRoleName());
                         }
                     }
                 }
@@ -2130,4 +2932,207 @@
     private List<Task> getCurrentNodeTaskList(String processInstanceId) {
         return taskService.createTaskQuery().processDefinitionId(processInstanceId).list();
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Result editFinishedTask(EditFinishedTaskForm form) {
+        List<HistoricTaskInstance> hisTasks = historyService.createHistoricTaskInstanceQuery().taskId(form.getTaskId()).orderByHistoricTaskInstanceStartTime().desc().list();
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(hisTasks) || Objects.isNull(hisTasks.get(0))) {
+            return Result.error("浠诲姟涓嶅瓨鍦�");
+        }
+        HistoricTaskInstance task = hisTasks.get(0);
+        ProjectProcess projectProcess = new LambdaQueryChainWrapper<>(projectProcessMapper)
+                .eq(ProjectProcess::getProcessInsId, task.getProcessInstanceId())
+                .eq(ProjectProcess::getProcessDefId, task.getProcessDefinitionId())
+                .one();
+        if (Objects.isNull(projectProcess)) {
+            return Result.error("椤圭洰娴佺▼鏈粦瀹�");
+        }
+        // 鏌ュ嚭瀛楀吀涓渶瑕佹敞鍏ョ殑瀛楁淇℃伅
+        List<String> dictList = dictTypeService.selectDictDataByType("flow_variables").stream().map(SysDictData::getDictValue).collect(Collectors.toList());
+        Map<String, Object> newV = new HashMap<>(2);
+        if (!org.springframework.util.CollectionUtils.isEmpty(form.getVariables())) {
+            for (String key : form.getVariables().keySet()) {
+                newV.put(task.getTaskDefinitionKey() + "&" + key, form.getVariables().get(key));
+                // 瀛楀吀閲屾湁灏变笉鍋氬鐞�
+                if (!org.apache.commons.collections4.CollectionUtils.isEmpty(dictList) && dictList.contains(key)) {
+                    newV.put(key,form.getVariables().get(key));
+                }
+            }
+        }
+        ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
+        Date now = new Date();
+
+        // 1. 琛ㄥ崟鍙橀噺鏇挎崲
+        for (String key : newV.keySet()) {
+            FlowableVarVO var = null;
+            if (Objects.isNull(processInstance)) {
+                // 鏌ヨ鍘嗗彶娴佺▼鍙橀噺
+                var = projectProcessMapper.getHisByteId(projectProcess.getProcessInsId(), key);
+            } else {
+                // 鏌ヨ杩愯鏃舵祦绋嬪彉閲�
+                var = projectProcessMapper.getRuByteId(projectProcess.getProcessInsId(), key);
+            }
+            if (Objects.nonNull(var)) {
+                // 鍏堝垹闄ゅ師鏉ョ殑鍙橀噺锛屽啀鎶婂綋鍓嶇殑淇濆瓨杩涘幓
+                projectProcessMapper.deleteHisFlowableVar(var.getID_());
+                projectProcessMapper.deleteRunFlowableVar(var.getID_());
+                if (StringUtils.isNotBlank(var.getBYTEARRAY_ID_())) {
+                    projectProcessMapper.deleteByteArray(var.getID_());
+                }
+            }
+
+            // 淇濆瓨褰撳墠鐨勮〃鍗曟暟鎹�
+            FlowableVarVO run = new FlowableVarVO();
+            FlowableVarVO v = new FlowableVarVO();
+            v.setNAME_(key);
+            v.setPROC_INST_ID_(task.getProcessInstanceId());
+            v.setEXECUTION_ID_(task.getProcessInstanceId());
+            v.setCREATE_TIME_(now);
+            v.setLAST_UPDATED_TIME_(now);
+            v.setID_(new StrongUuidGenerator().getNextId());
+
+            BeanUtils.copyProperties(v, run);
+            run.setID_(new StrongUuidGenerator().getNextId());
+            if (newV.get(key) instanceof String) {
+                v.setVAR_TYPE_("string");
+                v.setTEXT_((String) newV.get(key));
+                run.setVAR_TYPE_("string");
+                run.setTEXT_((String) newV.get(key));
+            } else if (newV.get(key) instanceof Integer) {
+                v.setVAR_TYPE_("integer");
+                v.setLONG_((Long) newV.get(key));
+                v.setTEXT_((String) newV.get(key));
+                run.setVAR_TYPE_("integer");
+                run.setLONG_((Long) newV.get(key));
+                run.setTEXT_((String) newV.get(key));
+            } else if (newV.get(key) instanceof Long) {
+                v.setVAR_TYPE_("long");
+                v.setLONG_((Long) newV.get(key));
+                v.setTEXT_((String) newV.get(key));
+                run.setVAR_TYPE_("long");
+                run.setLONG_((Long) newV.get(key));
+                run.setTEXT_((String) newV.get(key));
+            } else if (newV.get(key) instanceof Boolean) {
+                v.setVAR_TYPE_("boolean");
+                v.setLONG_((Long) newV.get(key));
+                v.setTEXT_((String) newV.get(key));
+                run.setVAR_TYPE_("boolean");
+                run.setLONG_((Long) newV.get(key));
+                run.setTEXT_((String) newV.get(key));
+            } else {
+                // 鍏跺畠绫诲瀷鐨勮〃鍗曟暟鎹細濡傚浘鐗囥�佹枃浠跺崟鐙瓨琛ㄧ殑銆傚巻鍙层�佽繍琛屼腑鐨勬祦绋嬮渶鍚勫瓨涓�浠�
+                v.setVAR_TYPE_("serializable");
+                v.setBYTEARRAY_ID_(new StrongUuidGenerator().getNextId());
+                projectProcessMapper.insertByteArray(v.getBYTEARRAY_ID_(), 1, "hist.var-" + key, newV.get(key));
+
+                run.setVAR_TYPE_("serializable");
+                run.setBYTEARRAY_ID_(new StrongUuidGenerator().getNextId());
+                projectProcessMapper.insertByteArray(run.getBYTEARRAY_ID_(), 1, "var-" + key, newV.get(key));
+            }
+
+            projectProcessMapper.insertHisFlowableVar(v);
+            projectProcessMapper.insertRunFlowableVar(run);
+
+        }
+        // 2. 浠诲姟鐘舵�佽皟鏁达細浠呮敮鎸� 宸插畬鎴�==銆嬪缂�/璺宠繃   瀹圭己銆�===銆嬭烦杩�
+        if (Objects.nonNull(form.getNowStatus()) && ! Objects.equals(form.getOriginalStatus(), form.getNowStatus())) {
+            if (TaskStatusEnum.FINISHED.equals(form.getOriginalStatus())) {
+                ProcessLog finishedLog = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                        .eq(ProcessLog::getTaskId, form.getTaskId())
+                        .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.FINISHED)
+                        .one();
+                if (Objects.nonNull(finishedLog)) {
+                    if (TaskStatusEnum.JUMP.equals(form.getNowStatus())) {
+                        // 娣诲姞璺宠繃鏃ュ織
+                        publisher.publishEvent(new TaskLogEvent(this, null,
+                                finishedLog.getUserId(),
+                                projectProcess.getProjectId(),
+                                projectProcess.getProcessInsId(),
+                                form.getTaskId(),
+                                task.getTaskDefinitionKey(),
+                                task.getName(),
+                                ProcessLogEventTypeEnum.JUMP,
+                                new JumpData(form.getTaskJumpForm().getDesc())));
+                        // 鍒犻櫎鍘熸潵鐨勫畬鎴愭棩蹇�
+                        processLogService.removeById(finishedLog.getId());
+                    } else if (TaskStatusEnum.WAIT.equals(form.getNowStatus())) {
+                        // 娣诲姞瀹圭己鏃ュ織
+                        publisher.publishEvent(new TaskLogEvent(this, null,
+                                finishedLog.getUserId(),
+                                projectProcess.getProjectId(),
+                                projectProcess.getProcessInsId(),
+                                form.getTaskId(),
+                                task.getTaskDefinitionKey(),
+                                task.getName(),
+                                ProcessLogEventTypeEnum.WAIT,
+                                new WaitData(form.getTaskWaitForm().getDesc())));
+                        // 鍒犻櫎鍘熸潵鐨勫畬鎴愭棩蹇�
+                        processLogService.removeById(finishedLog.getId());
+                    } else {
+                        return Result.error("宸插畬鎴愪换鍔″彧鑳借皟鏁翠负瀹圭己鎴栬烦杩囩姸鎬�");
+                    }
+                }
+            }
+            else if (TaskStatusEnum.WAIT.equals(form.getOriginalStatus())) {
+                ProcessLog waitLog = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                        .eq(ProcessLog::getTaskId, form.getTaskId())
+                        .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.WAIT)
+                        .one();
+                if (Objects.nonNull(waitLog)) {
+                    if (TaskStatusEnum.JUMP.equals(form.getNowStatus())) {
+                        // 娣诲姞璺宠繃鏃ュ織
+                        publisher.publishEvent(new TaskLogEvent(this, null,
+                                waitLog.getUserId(),
+                                projectProcess.getProjectId(),
+                                projectProcess.getProcessInsId(),
+                                form.getTaskId(),
+                                task.getTaskDefinitionKey(),
+                                task.getName(),
+                                ProcessLogEventTypeEnum.JUMP,
+                                new JumpData(form.getTaskJumpForm().getDesc())));
+                        // 鍒犻櫎鍘熸潵鐨勫缂烘棩蹇�
+                        processLogService.removeById(waitLog.getId());
+                    } else {
+                        return Result.error("瀹圭己浠诲姟鍙兘璋冩暣涓鸿烦杩囩姸鎬�");
+                    }
+                }
+            } else if (TaskStatusEnum.JUMP.equals(form.getOriginalStatus())) {
+                ProcessLog jumpLog = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+                        .eq(ProcessLog::getTaskId, form.getTaskId())
+                        .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.JUMP)
+                        .one();
+                if (Objects.nonNull(jumpLog)) {
+                    if (TaskStatusEnum.WAIT.equals(form.getNowStatus())) {
+                        // 娣诲姞瀹圭己鏃ュ織
+                        publisher.publishEvent(new TaskLogEvent(this, null,
+                                jumpLog.getUserId(),
+                                projectProcess.getProjectId(),
+                                projectProcess.getProcessInsId(),
+                                form.getTaskId(),
+                                task.getTaskDefinitionKey(),
+                                task.getName(),
+                                ProcessLogEventTypeEnum.WAIT,
+                                new WaitData(form.getTaskWaitForm().getDesc())));
+                        // 鍒犻櫎鍘熸潵鐨勮烦杩囨棩蹇�
+                        processLogService.removeById(jumpLog.getId());
+                    } else {
+                        return Result.error("璺宠繃浠诲姟鍙兘璋冩暣涓哄缂轰换鍔�");
+                    }
+                }
+            }
+        }
+        // 3. 淇濆瓨淇敼鏃ュ織
+        publisher.publishEvent(new TaskLogEvent(this, null,
+                SecurityUtils.getUserId(),
+                projectProcess.getProjectId(),
+                projectProcess.getProcessInsId(),
+                form.getTaskId(),
+                task.getTaskDefinitionKey(),
+                task.getName(),
+                ProcessLogEventTypeEnum.EDIT,
+                null));
+
+        return Result.ok("淇敼鎴愬姛");
+    }
 }

--
Gitblit v1.8.0