xiangpei
2025-03-02 c9e9cd3df7f76aa164e83280680945bca5250451
business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
@@ -23,9 +23,11 @@
import com.ycl.domain.dto.FlowTaskDto;
import com.ycl.domain.dto.FlowViewerDto;
import com.ycl.domain.entity.ProcessCoding;
import com.ycl.domain.entity.ProcessLog;
import com.ycl.domain.entity.ProjectProcess;
import com.ycl.domain.entity.SysForm;
import com.ycl.domain.json.RejectData;
import com.ycl.domain.vo.DoFormDetailVO;
import com.ycl.domain.vo.FlowQueryVo;
import com.ycl.domain.vo.FlowTaskVo;
import com.ycl.domain.vo.FormDetailVO;
@@ -68,6 +70,7 @@
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 org.springframework.transaction.annotation.Transactional;
@@ -188,6 +191,7 @@
                projectProcess.getProjectId(),
                projectProcess.getProcessInsId(),
                taskId,
                task.getTaskDefinitionKey(),
                task.getName(),
                ProcessLogEventTypeEnum.FINISHED,
                null));
@@ -329,6 +333,7 @@
                projectProcess.getProjectId(),
                projectProcess.getProcessInsId(),
                flowTaskVo.getTaskId(),
                task.getTaskDefinitionKey(),
                task.getName(),
                ProcessLogEventTypeEnum.REJECT,
                new RejectData(flowTaskVo.getComment())));
@@ -1280,14 +1285,26 @@
            HistoricTaskInstance beforeTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(finalProcessInsId).finished().taskDefinitionKey(node.getBeforeNodeDefId()).singleResult();
            return Objects.nonNull(beforeTask);
        }).collect(Collectors.toList());
        beforeNodes.forEach(node -> {
        List<DoFormDetailVO> vos = beforeNodes.stream().map(node -> {
            if (node.getCurrent()) {
                if (processLogService.taskIsHangup(taskId, finalProcessInsId)) {
                    node.setTaskStatus(TaskStatusEnum.HANGUP);
                }
            }
        });
        return AjaxResult.success(beforeNodes);
            // 判断任务是否存在特殊操作(如跳过、转办等),需要在前端展示出来
            List<ProcessLog> logList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
                    .eq(ProcessLog::getTaskDefKey, node.getBeforeNodeDefId())
                    .eq(ProcessLog::getProcessInsId, finalProcessInsId)
                    .orderByDesc(ProcessLog::getGmtCreate)
                    .list();
            DoFormDetailVO vo = new DoFormDetailVO();
            BeanUtils.copyProperties(node, vo);
            if (CollectionUtils.isNotEmpty(logList)) {
                vo.setEvents(logList);
            }
            return vo;
        }).collect(Collectors.toList());
        return AjaxResult.success(vos);
    }
    @Override
@@ -1310,7 +1327,26 @@
                HistoricTaskInstance beforeTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(hisTask.getProcessInstanceId()).finished().taskDefinitionKey(node.getBeforeNodeDefId()).singleResult();
                return Objects.nonNull(beforeTask);
            }).collect(Collectors.toList());
            return AjaxResult.success(dataList);
            List<DoFormDetailVO> vos = dataList.stream().map(node -> {
                if (node.getCurrent()) {
                    if (processLogService.taskIsHangup(taskId, hisTask.getProcessInstanceId())) {
                        node.setTaskStatus(TaskStatusEnum.HANGUP);
                    }
                }
                // 判断任务是否存在特殊操作(如跳过、转办等),需要在前端展示出来
                List<ProcessLog> logList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
                        .eq(ProcessLog::getTaskId, hisTask.getId())
                        .eq(ProcessLog::getProcessInsId, hisTask.getProcessInstanceId())
                        .orderByDesc(ProcessLog::getGmtCreate)
                        .list();
                DoFormDetailVO vo = new DoFormDetailVO();
                BeanUtils.copyProperties(node, vo);
                if (CollectionUtils.isNotEmpty(logList)) {
                    vo.setEvents(logList);
                }
                return vo;
            }).collect(Collectors.toList());
            return AjaxResult.success(vos);
        } else {
            parameters = taskService.getVariables(taskId);
            List<FormDetailVO> beforeNodes = this.getBeforeNodeForm(parameters, task.getFormKey(), task.getName(), task.getProcessDefinitionId(), task.getTaskDefinitionKey(), Boolean.TRUE);
@@ -1321,7 +1357,26 @@
                HistoricTaskInstance beforeTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()).finished().taskDefinitionKey(node.getBeforeNodeDefId()).singleResult();
                return Objects.nonNull(beforeTask);
            }).collect(Collectors.toList());
            return AjaxResult.success(dataList);
            List<DoFormDetailVO> vos = dataList.stream().map(node -> {
                if (node.getCurrent()) {
                    if (processLogService.taskIsHangup(taskId, task.getProcessInstanceId())) {
                        node.setTaskStatus(TaskStatusEnum.HANGUP);
                    }
                }
                // 判断任务是否存在特殊操作(如跳过、转办等),需要在前端展示出来
                List<ProcessLog> logList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
                        .eq(ProcessLog::getTaskId, task.getId())
                        .eq(ProcessLog::getProcessInsId, task.getProcessInstanceId())
                        .orderByDesc(ProcessLog::getGmtCreate)
                        .list();
                DoFormDetailVO vo = new DoFormDetailVO();
                BeanUtils.copyProperties(node, vo);
                if (CollectionUtils.isNotEmpty(logList)) {
                    vo.setEvents(logList);
                }
                return vo;
            }).collect(Collectors.toList());
            return AjaxResult.success(vos);
        }
    }