xiangpei
2025-01-17 e870ae252f020b745bb6eb1b0f6f74ff29fa79bc
事件新增日志
3个文件已修改
3个文件已添加
8 文件已重命名
1个文件已删除
301 ■■■■■ 已修改文件
business/src/main/java/com/ycl/domain/json/DelegateData.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/event/event/TaskLogEvent.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/event/listener/ProcessLogEventListener.java 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/src/main/java/com/ycl/common/enums/business/ProcessLogEventTypeEnum.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/controller/FlowLogController.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/domain/entity/ProcessLog.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/domain/query/ProcessLogQuery.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/domain/vo/ProcessLogVO.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/mapper/FlowLogMapper.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/mapper/ProcessLogMapper.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/service/ProcessLogService.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/service/impl/ProcessLogServiceImpl.java 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/resources/mapper/ProcessLogMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/domain/json/DelegateData.java
File was renamed from business/src/main/java/com/ycl/domain/json/TaskDelegateData.java
@@ -12,7 +12,7 @@
 * @date:2025/1/2 14:39
 */
@Data
public class TaskDelegateData {
public class DelegateData {
    /**
     * 转办前的处理人id
business/src/main/java/com/ycl/event/event/TaskLogEvent.java
New file
@@ -0,0 +1,62 @@
package com.ycl.event.event;
import com.ycl.common.enums.business.ProcessLogEventTypeEnum;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.ApplicationEvent;
/**
 * 转办事件定义
 *
 * @author:xp
 * @date:2025/1/16 15:04
 */
@Getter
@Setter
public class TaskLogEvent extends ApplicationEvent {
    /**
     * 项目id
     */
    private Long projectId;
    /**
     * 流程实例id
     */
    private String processInsId;
    /**
     * 任务id
     */
    private String taskId;
    /**
     * 事件类型
     */
    private ProcessLogEventTypeEnum eventType;
    /**
     * 其它数据
     * @see com.ycl.domain.json
     */
    private Object otherData;
    /**
     * 构造
     *
     * @param source 传this即可
     * @param projectId 项目id
     * @param processInsId 流程实例id
     * @param taskId 任务id
     * @param otherData 其它数据
     */
    public TaskLogEvent(Object source, Long projectId, String processInsId, String taskId, ProcessLogEventTypeEnum eventType, Object otherData) {
        super(source);
        this.projectId = projectId;
        this.processInsId = processInsId;
        this.eventType = eventType;
        this.taskId = taskId;
        this.otherData = otherData;
    }
}
business/src/main/java/com/ycl/event/listener/ProcessLogEventListener.java
New file
@@ -0,0 +1,41 @@
package com.ycl.event.listener;
import com.alibaba.fastjson2.JSON;
import com.ycl.common.enums.business.ProcessLogEventTypeEnum;
import com.ycl.common.utils.SecurityUtils;
import com.ycl.domain.entity.ProcessLog;
import com.ycl.event.event.TaskLogEvent;
import com.ycl.service.ProcessLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
/**
 * @author:xp
 * @date:2025/1/16 15:14
 */
@Component
@RequiredArgsConstructor
public class ProcessLogEventListener {
    private final ProcessLogService processLogService;
    /**
     * 监听流程日志事件
     *
     * @param event 转办的事件内容
     */
    @EventListener(classes = {TaskLogEvent.class})
    public void delegate(TaskLogEvent event) {
        ProcessLog log = new ProcessLog();
        log.setEventType(event.getEventType());
        log.setProcessInsId(event.getProcessInsId());
        log.setProjectId(event.getProjectId());
        log.setTaskId(event.getTaskId());
        log.setUserId(SecurityUtils.getUserId());
        log.setEventDataJson(JSON.toJSONString(event.getOtherData()));
        processLogService.save(log);
    }
}
business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
@@ -1,35 +1,28 @@
package com.ycl.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
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.core.domain.AjaxResult;
import com.ycl.common.core.domain.entity.SysDept;
import com.ycl.common.core.domain.entity.SysRole;
import com.ycl.common.core.domain.entity.SysUser;
import com.ycl.common.enums.FlowComment;
import com.ycl.common.enums.business.FlowLogEventTypeEnum;
import com.ycl.common.enums.business.HandlerTypeEnum;
import com.ycl.common.enums.business.ProcessLogEventTypeEnum;
import com.ycl.common.enums.business.TaskStatusEnum;
import com.ycl.common.utils.SecurityUtils;
import com.ycl.constant.TaskTypeConstant;
import com.ycl.domain.dto.FlowTaskDto;
import com.ycl.domain.entity.FlowLog;
import com.ycl.domain.entity.ProjectInfo;
import com.ycl.domain.entity.ProjectProcess;
import com.ycl.domain.form.RejectTaskForm;
import com.ycl.domain.form.TaskDelegationForm;
import com.ycl.domain.json.TaskDelegateData;
import com.ycl.domain.json.DelegateData;
import com.ycl.domain.vo.CustomerTaskVO;
import com.ycl.domain.vo.IndexCustomerTaskVO;
import com.ycl.domain.vo.ProjectProcessDetailVO;
import com.ycl.event.event.TaskLogEvent;
import com.ycl.mapper.ProjectInfoMapper;
import com.ycl.mapper.ProjectProcessMapper;
import com.ycl.service.FlowLogService;
import com.ycl.service.ProjectProcessService;
import com.ycl.common.base.Result;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -51,18 +44,15 @@
import org.flowable.identitylink.api.IdentityLink;
import org.flowable.identitylink.api.IdentityLinkInfo;
import org.flowable.identitylink.api.IdentityLinkType;
import org.flowable.identitylink.api.history.HistoricIdentityLink;
import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntityImpl;
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.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import com.ycl.framework.utils.PageUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.*;
@@ -89,7 +79,7 @@
    private final ISysRoleService sysRoleService;
    private final ISysDeptService sysDeptService;
    private final TaskCommonService taskCommonService;
    private final FlowLogService flowLogService;
    private final ApplicationEventPublisher publisher;
    /**
     * 分页查询
@@ -521,7 +511,7 @@
                taskService.deleteCandidateGroup(task.getId(), identityLink.getGroupId());
            }
        }
        TaskDelegateData jsonData = new TaskDelegateData();
        DelegateData jsonData = new DelegateData();
        jsonData.setBeforeHandlerIds(beforeHandlerIds);
        jsonData.setBeforeHandlerType(beforeHandlerType);
@@ -566,8 +556,8 @@
        }
        jsonData.setAfterHandlerIds(afterHandlerIds);
        jsonData.setAfterHandlerType(form.getPeopleType());
        // 添加日志
        flowLogService.add(task.getId(), task.getProcessInstanceId(), FlowLogEventTypeEnum.DELEGATE, form.getProjectId(), JSON.toJSONString(jsonData));
        // 发布转办事件
        publisher.publishEvent(new TaskLogEvent(this, form.getProjectId(), form.getProcessInsId(), task.getId(), ProcessLogEventTypeEnum.DELEGATE, jsonData));
        return Result.ok("转办成功");
    }
common/src/main/java/com/ycl/common/enums/business/ProcessLogEventTypeEnum.java
File was renamed from common/src/main/java/com/ycl/common/enums/business/FlowLogEventTypeEnum.java
@@ -11,7 +11,7 @@
 * @date:2024/11/29 11:13
 */
@Getter
public enum FlowLogEventTypeEnum {
public enum ProcessLogEventTypeEnum {
    DELEGATE("DELEGATE", "转办"),
    FINISHED("FINISHED", "完成"),
@@ -26,7 +26,7 @@
    private final String desc;
    FlowLogEventTypeEnum(String value, String desc) {
    ProcessLogEventTypeEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }
flowable/src/main/java/com/ycl/controller/FlowLogController.java
@@ -1,8 +1,8 @@
package com.ycl.controller;
import com.ycl.common.base.Result;
import com.ycl.domain.query.FlowLogQuery;
import com.ycl.service.FlowLogService;
import com.ycl.domain.query.ProcessLogQuery;
import com.ycl.service.ProcessLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
@@ -25,14 +25,14 @@
@RequestMapping("/flow-log")
public class FlowLogController {
    private final FlowLogService flowLogService;
    private final ProcessLogService processLogService;
    @GetMapping("/page")
    @ApiOperation(value = "分页", notes = "分页")
    @PreAuthorize("@ss.hasPermi('flowLog:page')")
    public Result page(FlowLogQuery query) {
        return flowLogService.page(query);
    public Result page(ProcessLogQuery query) {
        return processLogService.page(query);
    }
}
flowable/src/main/java/com/ycl/domain/entity/ProcessLog.java
File was renamed from flowable/src/main/java/com/ycl/domain/entity/FlowLog.java
@@ -2,7 +2,7 @@
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ycl.common.enums.business.FlowLogEventTypeEnum;
import com.ycl.common.enums.business.ProcessLogEventTypeEnum;
import com.ycl.system.domain.base.AbsEntity;
import lombok.Data;
@@ -13,8 +13,8 @@
 * @since 2025-01-02
 */
@Data
@TableName("t_flow_log")
public class FlowLog extends AbsEntity {
@TableName("t_process_log")
public class ProcessLog extends AbsEntity {
    private static final long serialVersionUID = 1L;
@@ -24,15 +24,15 @@
    @TableField("event_type")
    /** 事件日志类型 */
    private FlowLogEventTypeEnum eventType;
    private ProcessLogEventTypeEnum eventType;
    @TableField("project_id")
    /** 项目id */
    private Long projectId;
    @TableField("flow_ins_id")
    @TableField("process_ins_id")
    /** 流程实例id */
    private String flowInsId;
    private String processInsId;
    @TableField("user_id")
    /** 产生日志的人/或其它 */
flowable/src/main/java/com/ycl/domain/query/ProcessLogQuery.java
File was renamed from flowable/src/main/java/com/ycl/domain/query/FlowLogQuery.java
@@ -17,6 +17,6 @@
 */
@Data
@ApiModel(value = "FlowLog查询参数", description = "流程日志查询参数")
public class FlowLogQuery extends AbsQuery {
public class ProcessLogQuery extends AbsQuery {
}
flowable/src/main/java/com/ycl/domain/vo/ProcessLogVO.java
File was renamed from flowable/src/main/java/com/ycl/domain/vo/FlowLogVO.java
@@ -1,14 +1,12 @@
package com.ycl.domain.vo;
import com.ycl.system.domain.base.AbsVo;
import com.ycl.domain.entity.FlowLog;
import java.util.List;
import com.ycl.domain.entity.ProcessLog;
import org.springframework.lang.NonNull;
import org.springframework.beans.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
 * 流程日志展示
@@ -18,7 +16,7 @@
 */
@Data
@ApiModel(value = "流程日志响应数据", description = "流程日志响应数据")
public class FlowLogVO extends AbsVo {
public class ProcessLogVO extends AbsVo {
    /** 任务id */
    @ApiModelProperty("任务id")
@@ -44,9 +42,9 @@
    @ApiModelProperty("事件数据,根据不同的事件可存储对应的扩展数据。如转办事件可存储转办前后的处理人信息")
    private String eventDataJson;
    public static FlowLogVO getVoByEntity(@NonNull FlowLog entity, FlowLogVO vo) {
    public static ProcessLogVO getVoByEntity(@NonNull ProcessLog entity, ProcessLogVO vo) {
        if(vo == null) {
            vo = new FlowLogVO();
            vo = new ProcessLogVO();
        }
        BeanUtils.copyProperties(entity, vo);
        return vo;
flowable/src/main/java/com/ycl/mapper/FlowLogMapper.java
File was deleted
flowable/src/main/java/com/ycl/mapper/ProcessLogMapper.java
New file
@@ -0,0 +1,32 @@
package com.ycl.mapper;
import com.ycl.domain.entity.ProcessLog;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ycl.domain.vo.ProcessLogVO;
import com.ycl.domain.query.ProcessLogQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
 * 流程日志 Mapper 接口
 *
 * @author xp
 * @since 2025-01-02
 */
@Mapper
public interface ProcessLogMapper extends BaseMapper<ProcessLog> {
    /**
     * id查找流程日志
     * @param id
     * @return
     */
    ProcessLogVO getById(Long id);
    /**
    *  分页
    */
    IPage getPage(IPage page, @Param("query") ProcessLogQuery query);
}
flowable/src/main/java/com/ycl/service/ProcessLogService.java
File was renamed from flowable/src/main/java/com/ycl/service/FlowLogService.java
@@ -1,10 +1,10 @@
package com.ycl.service;
import com.ycl.common.enums.business.FlowLogEventTypeEnum;
import com.ycl.domain.entity.FlowLog;
import com.ycl.common.enums.business.ProcessLogEventTypeEnum;
import com.ycl.domain.entity.ProcessLog;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ycl.common.base.Result;
import com.ycl.domain.query.FlowLogQuery;
import com.ycl.domain.query.ProcessLogQuery;
import java.util.List;
/**
@@ -13,7 +13,7 @@
 * @author xp
 * @since 2025-01-02
 */
public interface FlowLogService extends IService<FlowLog> {
public interface ProcessLogService extends IService<ProcessLog> {
    /**
     * 添加
@@ -23,7 +23,7 @@
     * @param projectId 项目id
     * @param eventDataJson json扩展内容
     */
    void add(String taskId, String flowInsId, FlowLogEventTypeEnum eventType, Long projectId, String eventDataJson);
    void add(String taskId, String flowInsId, ProcessLogEventTypeEnum eventType, Long projectId, String eventDataJson);
    /**
     * 批量删除
@@ -44,7 +44,7 @@
     * @param query
     * @return
     */
    Result page(FlowLogQuery query);
    Result page(ProcessLogQuery query);
    /**
     * 根据id查找
flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
@@ -29,7 +29,7 @@
import com.ycl.flow.FindNextNodeUtil;
import com.ycl.flow.FlowableUtils;
import com.ycl.mapper.ProcessCodingMapper;
import com.ycl.service.FlowLogService;
import com.ycl.service.ProcessLogService;
import com.ycl.service.IFlowTaskService;
import com.ycl.service.ISysDeployFormService;
import com.ycl.service.ISysFormService;
@@ -64,7 +64,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
@@ -94,7 +93,7 @@
    private final ISysFormService sysFormService;
    private final TaskCommonService taskCommonService;
    private final ProcessCodingMapper processCodingMapper;
    private final FlowLogService flowLogService;
    private final ProcessLogService processLogService;
    /**
     * 完成审核任务
flowable/src/main/java/com/ycl/service/impl/ProcessLogServiceImpl.java
File was renamed from flowable/src/main/java/com/ycl/service/impl/FlowLogServiceImpl.java
@@ -2,14 +2,14 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.ycl.common.enums.business.FlowLogEventTypeEnum;
import com.ycl.domain.entity.FlowLog;
import com.ycl.mapper.FlowLogMapper;
import com.ycl.service.FlowLogService;
import com.ycl.common.enums.business.ProcessLogEventTypeEnum;
import com.ycl.domain.entity.ProcessLog;
import com.ycl.mapper.ProcessLogMapper;
import com.ycl.service.ProcessLogService;
import com.ycl.common.base.Result;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.domain.vo.FlowLogVO;
import com.ycl.domain.query.FlowLogQuery;
import com.ycl.domain.vo.ProcessLogVO;
import com.ycl.domain.query.ProcessLogQuery;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
@@ -27,9 +27,9 @@
 */
@Service
@RequiredArgsConstructor
public class FlowLogServiceImpl extends ServiceImpl<FlowLogMapper, FlowLog> implements FlowLogService {
public class ProcessLogServiceImpl extends ServiceImpl<ProcessLogMapper, ProcessLog> implements ProcessLogService {
    private final FlowLogMapper flowLogMapper;
    private final ProcessLogMapper processLogMapper;
    /**
     * 添加日志
@@ -40,10 +40,10 @@
     * @param eventDataJson json扩展内容
     */
    @Override
    public void add(String taskId, String flowInsId, FlowLogEventTypeEnum eventType, Long projectId, String eventDataJson) {
        FlowLog log = new FlowLog();
    public void add(String taskId, String flowInsId, ProcessLogEventTypeEnum eventType, Long projectId, String eventDataJson) {
        ProcessLog log = new ProcessLog();
        log.setTaskId(taskId);
        log.setFlowInsId(flowInsId);
        log.setProcessInsId(flowInsId);
        log.setProjectId(projectId);
        log.setEventType(eventType);
        log.setEventDataJson(eventDataJson);
@@ -78,8 +78,8 @@
     * @return
     */
    @Override
    public Result page(FlowLogQuery query) {
        IPage<FlowLogVO> page = PageUtil.getPage(query, FlowLogVO.class);
    public Result page(ProcessLogQuery query) {
        IPage<ProcessLogVO> page = PageUtil.getPage(query, ProcessLogVO.class);
        baseMapper.getPage(page, query);
        return Result.ok().data(page.getRecords()).total(page.getTotal());
    }
@@ -91,7 +91,7 @@
     */
    @Override
    public Result detail(Long id) {
        FlowLogVO vo = baseMapper.getById(id);
        ProcessLogVO vo = baseMapper.getById(id);
        Assert.notNull(vo, "记录不存在");
        return Result.ok().data(vo);
    }
@@ -102,19 +102,19 @@
     */
    @Override
    public Result all() {
        List<FlowLog> entities = baseMapper.selectList(null);
        List<FlowLogVO> vos = entities.stream()
                .map(entity -> FlowLogVO.getVoByEntity(entity, null))
        List<ProcessLog> entities = baseMapper.selectList(null);
        List<ProcessLogVO> vos = entities.stream()
                .map(entity -> ProcessLogVO.getVoByEntity(entity, null))
                .collect(Collectors.toList());
        return Result.ok().data(vos);
    }
    @Override
    public Boolean taskDelegation(String processInstanceId, String taskId) {
        List<FlowLog> list = new LambdaQueryChainWrapper<>(baseMapper)
                .eq(FlowLog::getFlowInsId, processInstanceId)
                .eq(FlowLog::getTaskId, taskId)
                .eq(FlowLog::getEventType, FlowLogEventTypeEnum.DELEGATE)
        List<ProcessLog> list = new LambdaQueryChainWrapper<>(baseMapper)
                .eq(ProcessLog::getProcessInsId, processInstanceId)
                .eq(ProcessLog::getTaskId, taskId)
                .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.DELEGATE)
                .list();
        return CollectionUtils.isNotEmpty(list);
    }
flowable/src/main/resources/mapper/ProcessLogMapper.xml
File was renamed from flowable/src/main/resources/mapper/FlowLogMapper.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ycl.mapper.FlowLogMapper">
<mapper namespace="com.ycl.mapper.ProcessLogMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.domain.vo.FlowLogVO">
    <resultMap id="BaseResultMap" type="com.ycl.domain.vo.ProcessLogVO">
        <result column="task_id" property="taskId" />
        <result column="event_type" property="eventType" />
        <result column="project_id" property="projectId" />
@@ -28,7 +28,7 @@
            TFL.event_data_json,
            TFL.id
        FROM
            t_flow_log TFL
            t_process_log TFL
        WHERE
            TFL.id = #{id} AND TFL.deleted = 0
    </select>
@@ -44,7 +44,7 @@
            TFL.event_data_json,
            TFL.id
        FROM
            t_flow_log TFL
            t_process_log TFL
        WHERE
            TFL.deleted = 0
    </select>