xiangpei
2025-03-02 c9e9cd3df7f76aa164e83280680945bca5250451
流程详情、办理时展示任务的特殊操作日志
7个文件已修改
1个文件已添加
165 ■■■■ 已修改文件
business/src/main/java/com/ycl/event/event/TaskLogEvent.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/event/listener/ProcessLogEventListener.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/resources/mapper/HiddenAdminMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/domain/entity/ProcessLog.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/domain/vo/DoFormDetailVO.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/domain/vo/FormDetailVO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/event/event/TaskLogEvent.java
@@ -37,6 +37,12 @@
     * 任务id
     */
    private String taskId;
    /**
     * 任务key
     */
    private String taskDefKey;
    /**
     * 任务名
     */
@@ -62,7 +68,7 @@
     * @param taskId 任务id
     * @param otherData 其它数据
     */
    public TaskLogEvent(Object source,Long id,Long userId, Long projectId, String processInsId, String taskId, String taskName,ProcessLogEventTypeEnum eventType, Object otherData) {
    public TaskLogEvent(Object source,Long id,Long userId, Long projectId, String processInsId, String taskId, String taskDefKey, String taskName,ProcessLogEventTypeEnum eventType, Object otherData) {
        super(source);
        this.id = id;
        this.userId = userId;
@@ -70,6 +76,7 @@
        this.processInsId = processInsId;
        this.eventType = eventType;
        this.taskId = taskId;
        this.taskDefKey = taskDefKey;
        this.taskName = taskName;
        this.otherData = otherData;
    }
business/src/main/java/com/ycl/event/listener/ProcessLogEventListener.java
@@ -34,6 +34,7 @@
        log.setProcessInsId(event.getProcessInsId());
        log.setProjectId(event.getProjectId());
        log.setTaskId(event.getTaskId());
        log.setTaskDefKey(event.getTaskDefKey());
        log.setTaskName(event.getTaskName());
        log.setUserId(SecurityUtils.getUserId());
        if (Objects.nonNull(event.getOtherData())) {
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);
        }
    }
business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
@@ -647,7 +647,7 @@
        jsonData.setAfterHandlerIds(afterHandlerIds);
        jsonData.setAfterHandlerType(form.getPeopleType());
        // 发布转办事件
        publisher.publishEvent(new TaskLogEvent(this, null, SecurityUtils.getUserId(), form.getProjectId(), form.getProcessInsId(), task.getId(), task.getName(), ProcessLogEventTypeEnum.DELEGATE, jsonData));
        publisher.publishEvent(new TaskLogEvent(this, null, SecurityUtils.getUserId(), form.getProjectId(), form.getProcessInsId(), task.getId(), task.getTaskDefinitionKey(), task.getName(), ProcessLogEventTypeEnum.DELEGATE, jsonData));
        return Result.ok("转办成功");
    }
@@ -658,7 +658,7 @@
        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(), form.getTaskId(), task.getName(), ProcessLogEventTypeEnum.JUMP, new JumpData(form.getDesc())));
            publisher.publishEvent(new TaskLogEvent(this, null, SecurityUtils.getUserId(), form.getProjectId(), form.getProcessInsId(), task.getId(), task.getTaskDefinitionKey(), task.getName(), ProcessLogEventTypeEnum.JUMP, new JumpData(form.getDesc())));
            // 查出该任务绑定的表单
            Map<String, Object> data = new HashMap<>(1);
@@ -677,6 +677,9 @@
    @Override
    public Result taskSupervise(TaskSuperviseForm form) {
        Task task = taskService.createTaskQuery().taskId(form.getTaskId()).singleResult();
        if (Objects.isNull(task)) {
            throw new RuntimeException("任务不存在");
        }
        SuperviseData jsonData = new SuperviseData();
        jsonData.setCreateTime(new Date());
        jsonData.setContent(form.getContent());
@@ -685,12 +688,12 @@
        jsonData.setReceiverIds(form.getReceiverIds());
        jsonData.setReceiverType(form.getReceiverType());
        jsonData.setSuperviseType(form.getSuperviseType());
        QueryWrapper<ProcessLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("task_id", form.getTaskId());
        queryWrapper.eq("event_type", ProcessLogEventTypeEnum.SUPERVISE);
        queryWrapper.eq("process_ins_id", form.getProcessInsId());
        //查询督办日志
        ProcessLog processLog = processLogService.getOne(queryWrapper);
        ProcessLog processLog = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
                .eq(ProcessLog::getTaskId, form.getTaskId())
                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.SUPERVISE)
                .eq(ProcessLog::getProcessInsId, form.getProcessInsId())
                .one();
        List<SuperviseData> dataList;
        if (processLog != null) {
            String eventDataJson = processLog.getEventDataJson();
@@ -702,7 +705,16 @@
        }
        dataList.add(jsonData);
        //添加督办日志
        publisher.publishEvent(new TaskLogEvent(this, processLog.getId(), processLog.getUserId(), form.getProjectId(), form.getProcessInsId(), form.getTaskId(), task.getName(), ProcessLogEventTypeEnum.SUPERVISE, dataList));
        publisher.publishEvent(new TaskLogEvent(this,
                processLog.getId(),
                processLog.getUserId(),
                form.getProjectId(),
                form.getProcessInsId(),
                form.getTaskId(),
                task.getTaskDefinitionKey(),
                task.getName(),
                ProcessLogEventTypeEnum.SUPERVISE,
                dataList));
        return Result.ok("操作成功");
    }
@@ -729,6 +741,7 @@
                form.getProjectId(),
                form.getProcessInsId(),
                form.getTaskId(),
                task.getTaskDefinitionKey(),
                task.getName(),
                ProcessLogEventTypeEnum.HANGUP,
                new HangupData(form.getReason())
@@ -758,6 +771,7 @@
                form.getProjectId(),
                form.getProcessInsId(),
                form.getTaskId(),
                task.getTaskDefinitionKey(),
                task.getName(),
                ProcessLogEventTypeEnum.CANCEL_HANGUP,
                new HangupData(form.getReason())
@@ -803,6 +817,7 @@
                form.getProjectId(),
                form.getProcessInsId(),
                form.getTaskId(),
                task.getTaskDefinitionKey(),
                task.getName(),
                ProcessLogEventTypeEnum.TEAM_WORK,
                new TeamWorkData(form.getHandlerType(), form.getHandlerIds(), TeamWorkStatusEnum.NOT_FINISHED)
@@ -876,7 +891,7 @@
        ProcessInstance process = runtimeService.createProcessInstanceQuery().processInstanceId(processInsId).singleResult();
        if (Objects.isNull(process)) {
            // 如果运行时找不到说明是已完成的流程,直接查历史任务
            List<CustomerTaskVO> vos = this.getFinishedProcessTaskInfo(userTasks, processInsId, processDefinitionId);
            List<CustomerTaskVO> vos = this.getFinishedProcessTaskInfo(userTasks, projectId, processInsId, processDefinitionId);
            result.data(vos);
            return vos;
        }
@@ -908,6 +923,7 @@
            vo.setPromoterUnitName(promoterUnitNames);
            this.setCandidateInfo(userTask, vo, projectId, processInsId);
            if (Objects.isNull(task)) {
                // 如果任务在运行时没找到,那么可能为未开始或者已完成,需要从历史任务中再找一下
                List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery()
@@ -1006,7 +1022,7 @@
     * @param processDefId 流程定义id
     * @return
     */
    private List<CustomerTaskVO> getFinishedProcessTaskInfo(List<UserTask> userTasks, String processInsId, String processDefId) {
    private List<CustomerTaskVO> getFinishedProcessTaskInfo(List<UserTask> userTasks, Long projectId, String processInsId, String processDefId) {
        HistoricProcessInstance hisProcess = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInsId).singleResult();
        if (Objects.isNull(hisProcess)) {
            return new ArrayList<>();
@@ -1019,6 +1035,23 @@
            vo.setTaskName(userTask.getName());
            vo.setProcessName(hisProcess.getProcessDefinitionName());
            // 一个任务可能有多个候选人/组,所以需要使用list
            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);
            // 查多个是因为驳回后会查出两条及以上,取最新一条
            List<HistoricTaskInstance> hisTaskList = historyService.createHistoricTaskInstanceQuery()
                    .processInstanceId(hisProcess.getId())
business/src/main/resources/mapper/HiddenAdminMapper.xml
@@ -46,6 +46,8 @@
        WHERE
            THA.deleted = 0
    </select>
    <update id="updateList">
        <foreach collection="list" item="item" index="index" separator=";">
            UPDATE t_hidden_admin THA
@@ -60,6 +62,5 @@
            </set>
            where THA.id = #{item.id}
        </foreach>
    </update>
</mapper>
flowable/src/main/java/com/ycl/domain/entity/ProcessLog.java
@@ -22,6 +22,10 @@
    /** 任务id */
    private String taskId;
    @TableField("task_def_key")
    /** 任务key */
    private String taskDefKey;
    @TableField("task_name")
    /** 任务名 */
    private String taskName;
flowable/src/main/java/com/ycl/domain/vo/DoFormDetailVO.java
New file
@@ -0,0 +1,26 @@
package com.ycl.domain.vo;
import com.ycl.common.enums.business.TaskStatusEnum;
import com.ycl.domain.entity.ProcessLog;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.flowable.bpmn.model.UserTask;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * 处理下一个任务时,回显前置任务的表单(包含本节点的表单)
 *
 * @author:xp
 * @date:2024/12/5 0:35
 */
@Data
public class DoFormDetailVO extends FormDetailVO {
    @ApiModelProperty("任务事件")
    private List<ProcessLog> events = new ArrayList<>();
}
flowable/src/main/java/com/ycl/domain/vo/FormDetailVO.java
@@ -47,7 +47,7 @@
    private TaskStatusEnum taskStatus;
    /**
     * 前置节点定义id
     * 前置节点定义id,即任务key
     *
     */
    private String beforeNodeDefId;