xiangpei
2025-04-07 80662b34fe93b4ede00c7fc03fbd9f01355c94e2
business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
@@ -28,6 +28,7 @@
import com.ycl.domain.entity.ProcessLog;
import com.ycl.domain.entity.ProjectProcess;
import com.ycl.domain.entity.SysForm;
import com.ycl.domain.form.EditFinishedTaskForm;
import com.ycl.domain.json.RejectData;
import com.ycl.domain.query.ProcessLogQuery;
import com.ycl.domain.vo.*;
@@ -190,6 +191,7 @@
        }
        return AjaxResult.success("提交成功");
    }
    /**
     * 容缺补交
@@ -1411,6 +1413,58 @@
    }
    /**
     * 查询当前任务的表单数据
     *
     * @param taskId
     * @return
     * @throws Exception
     */
    @Override
    public AjaxResult currentFlowTaskForm(String taskId) {
        // 流程变量
        List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
                .includeProcessVariables()
                .finished()
                .taskId(taskId)
                .orderByHistoricTaskInstanceStartTime()
                .desc()
                .list();
        if (CollectionUtils.isEmpty(hisTaskList) || Objects.isNull(hisTaskList.get(0))) {
            return AjaxResult.error("未找到该任务信息");
        }
        HistoricTaskInstance historicTaskInstance = hisTaskList.get(0);
        Map<String, Object> parameters = historicTaskInstance.getProcessVariables();
        String processInsId = historicTaskInstance.getProcessInstanceId();
        List<FormDetailVO> beforeNodes = this.getBeforeNodeForm(parameters, historicTaskInstance.getFormKey(), historicTaskInstance.getName(), historicTaskInstance.getProcessDefinitionId(), historicTaskInstance.getTaskDefinitionKey(), Boolean.FALSE);
        // 判断前置任务是不是和当前任务为同一个executeId
        // 判断当前任务是否被挂起中
        String finalProcessInsId = processInsId;
        List<DoFormDetailVO> vos = beforeNodes.stream()
                .filter(FormDetailVO::getCurrent)
                .map(node -> {
                    if (node.getCurrent()) {
                        if (processLogService.taskIsHangup(taskId, finalProcessInsId)) {
                            node.setTaskStatus(TaskStatusEnum.HANGUP);
                        }
                    }
                    // 判断任务是否存在特殊操作(如跳过、转办等),需要在前端展示出来
                    ProcessLogQuery query = new ProcessLogQuery();
                    query.setTaskId(node.getTaskId());
                    query.setProcessInsId(finalProcessInsId);
                    Result result = processLogService.projectProcessLogList(query);
                    List<ProcessLogVO> logList = (List<ProcessLogVO>) result.get("data");
                    DoFormDetailVO vo = new DoFormDetailVO();
                    BeanUtils.copyProperties(node, vo);
                    if (CollectionUtils.isNotEmpty(logList)) {
                        vo.setEvents(logList);
                    }
                    return vo;
        }).collect(Collectors.toList());
        return AjaxResult.success(vos.get(0));
    }
    /**
     * 流程节点表单
     *
     * @param taskId 流程任务编号
@@ -1423,11 +1477,17 @@
        Map<String, Object> parameters = new HashMap<>();
        List<FormDetailVO> beforeNodes = new ArrayList<>();
        String processInsId = "";
        HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().finished().taskId(taskId).singleResult();
        if (Objects.nonNull(historicTaskInstance)) {
            parameters = historicTaskInstance.getProcessVariables();
            processInsId = historicTaskInstance.getProcessInstanceId();
            beforeNodes = this.getBeforeNodeForm(parameters, historicTaskInstance.getFormKey(), historicTaskInstance.getName(), historicTaskInstance.getProcessDefinitionId(), historicTaskInstance.getTaskDefinitionKey(), Boolean.FALSE);
        List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
                .includeProcessVariables()
                .finished()
                .taskId(taskId)
                .orderByHistoricTaskInstanceStartTime()
                .desc()
                .list();
        if (CollectionUtils.isNotEmpty(hisTaskList) && Objects.nonNull(hisTaskList.get(0))) {
            parameters = hisTaskList.get(0).getProcessVariables();
            processInsId = hisTaskList.get(0).getProcessInstanceId();
            beforeNodes = this.getBeforeNodeForm(parameters, hisTaskList.get(0).getFormKey(), hisTaskList.get(0).getName(), hisTaskList.get(0).getProcessDefinitionId(), hisTaskList.get(0).getTaskDefinitionKey(), Boolean.FALSE);
        } else {
            parameters = taskService.getVariables(taskId);
            processInsId = task.getProcessInstanceId();
@@ -1717,6 +1777,7 @@
        return beforeNodes;
    }
    /**
     * 流程节点信息
     *