fuliqi
2025-02-10 ffb1ef9e75bd7b03381496f29d0319c01488997b
办理期限
7个文件已修改
115 ■■■■ 已修改文件
business/src/main/java/com/ycl/listener/flowable/FlowableOverTimeListener.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/task/FlowableTask.java 58 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/common/constant/ProcessOverTimeConstants.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/domain/entity/ProcessCoding.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/domain/form/ProcessCodingForm.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/java/com/ycl/domain/vo/ProcessCodingVO.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
flowable/src/main/resources/mapper/ProcessCodingMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/listener/flowable/FlowableOverTimeListener.java
@@ -41,6 +41,10 @@
     */
    private FixedValue 红码时长;
    /**
     * 办理期限
     */
    private FixedValue 办理期限;
    /**
     * 计时起始节点定义Id
     */
    private FixedValue 开始计时节点;
@@ -75,6 +79,9 @@
        if (红码时长 != null && 红码时长.getValue(delegateTask) != null) {
            processCoding.setRedTime(红码时长.getValue(delegateTask).toString());
        }
        if (办理期限 != null && 办理期限.getValue(delegateTask) != null) {
            processCoding.setOvertime(办理期限.getValue(delegateTask).toString());
        }
        //设置开始节点
        if (开始计时节点 != null && 开始计时节点.getValue(delegateTask) != null) {
            String taskDefKey = 开始计时节点.getValue(delegateTask).toString();
business/src/main/java/com/ycl/task/FlowableTask.java
@@ -67,40 +67,19 @@
            String taskId = task.getId();
            ProcessCoding processCoding = taskMap.get(taskId);
            if (processCoding == null) {
                //不需要监控的任务节点直接改为绿色
                //不需要监控的任务节点项目码直接改为绿色
                List<String> processInsIds = map.get(GREEN);
                processInsIds.add(task.getProcessInstanceId());
                continue;
            }
            //判断是否超时
            //判断赋码统一用秒作为单位
            Date startTime = startTaskMap.get(processCoding.getStartTaskId());
            try {
                Long yellowTime = null;
                Long redTime = null;
                String yellowTimeStr = processCoding.getYellowTime();
                if (StringUtils.isNotBlank(yellowTimeStr)) {
                    String[] yellowTimeArr = yellowTimeStr.split("-");
                    // 解析天数和小时数
                    int days = Integer.parseInt(yellowTimeArr[0]);
                    int hours = 0;
                    // 兼容之前配置的整数天
                    if (yellowTimeArr.length > 1) {
                        hours = Integer.parseInt(yellowTimeArr[1]);
                    }
                    yellowTime = (days * 24L + hours) * 3600L;
                }
                String redTimeStr = processCoding.getRedTime();
                if (StringUtils.isNotBlank(redTimeStr)) {
                    String[] redTimeArr = redTimeStr.split("-");
                    // 解析天数和小时数
                    int days = Integer.parseInt(redTimeArr[0]);
                    int hours = 0;
                    if (redTimeArr.length > 1) {
                        hours = Integer.parseInt(redTimeArr[1]);
                    }
                    redTime = (days * 24L + hours) * 3600L;
                }
                Long redTime = getTime(processCoding.getRedTime());
                Long yellowTime = getTime(processCoding.getYellowTime());
                Long overtime = getTime(processCoding.getOvertime());
                if (startTime == null) continue;
                //节点处理时间
                long durationDay = (now.getTime() - startTime.getTime()) / 1000;
                String status = GREEN; // 默认状态为绿色
                if (redTime != null && redTime !=0 && durationDay >= redTime) {
@@ -108,12 +87,20 @@
                } else if (yellowTime != null && yellowTime !=0 && durationDay >= yellowTime) {
                    status = YELLOW; // 否则,如果超过黄色时间阈值,则状态为黄色
                }
                //处理办理期限
                String overtimeStatus = NORMAL;
                if (overtime != null && overtime !=0 && durationDay >= overtime) {
                    overtimeStatus = OVERTIME; // 如果超过办理期限
                } else if (overtime != null && overtime != 0 && durationDay >= (overtime - 12 * 60 * 60)) {
                    overtimeStatus = WILLOVERTIME; // 如果临期(固定超时前12小时为临期)
                }
                List<String> processInsIds = map.get(status);
                processInsIds.add(task.getProcessInstanceId());
                processCoding.setStatus(status);
                processCoding.setOvertimeStatus(overtimeStatus);
                list.add(processCoding);
            } catch (Exception e) {
                e.printStackTrace();
                log.error(e.getMessage(),"赋码时间格式有误");
            }
        }
@@ -125,6 +112,21 @@
        log.info("结束赋码");
    }
    private Long getTime(String timeStr) {
        Long time = null;
        if (StringUtils.isNotBlank(timeStr)) {
            String[] timeArr = timeStr.split("-");
            // 解析天数和小时数
            int days = Integer.parseInt(timeArr[0]);
            int hours = 0;
            if (timeArr.length > 1) {
                hours = Integer.parseInt(timeArr[1]);
            }
            time = (days * 24L + hours) * 3600L;
        }
        return time;
    }
    private Map<String, Date> getStartTaskList(List<ProcessCoding> processCodingList) {
        //查出任务计时起始节点集合
        List<String> startTaskIds = processCodingList.stream().map(ProcessCoding::getStartTaskId).collect(Collectors.toList());
flowable/src/main/java/com/ycl/common/constant/ProcessOverTimeConstants.java
@@ -15,4 +15,17 @@
     * 黄码
     */
    public static final String YELLOW = "yellow";
    /**
     * 正常
     */
    public static final String NORMAL = "normal";
    /**
     * 临期
     */
    public static final String WILLOVERTIME = "willOvertime";
    /**
     * 超时
     */
    public static final String OVERTIME = "overtime";
}
flowable/src/main/java/com/ycl/domain/entity/ProcessCoding.java
@@ -41,9 +41,15 @@
    /** 变红码的天数 */
    private String redTime;
    @TableField("overtime")
    /** 处理期限 */
    private String overtime;
    @TableField("status")
    /** 任务状态 */
    private String status;
    @TableField("overtime_status")
    /** 任务超时状态 */
    private String overtimeStatus;
}
flowable/src/main/java/com/ycl/domain/form/ProcessCodingForm.java
@@ -41,16 +41,23 @@
    @NotNull(message = "变黄码的天数不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty("变黄码的天数")
    private Integer yellowTime;
    private String yellowTime;
    @NotNull(message = "变红码的天数不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty("变红码的天数")
    private Integer redTime;
    private String redTime;
    @NotNull(message = "处理期限不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty("处理期限")
    private String overtime;
    @NotNull(message = "任务状态", groups = {Add.class, Update.class})
    @ApiModelProperty("任务状态green/yellow/red")
    private String status;
    @NotNull(message = "任务超时状态", groups = {Add.class, Update.class})
    @ApiModelProperty("任务超时状态normal/willOvertime/overtime")
    private String overtimeStatus;
    public static ProcessCoding getEntityByForm(@NonNull ProcessCodingForm form, ProcessCoding entity) {
        if(entity == null) {
          entity = new ProcessCoding();
flowable/src/main/java/com/ycl/domain/vo/ProcessCodingVO.java
@@ -1,5 +1,6 @@
package com.ycl.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ycl.system.domain.base.AbsVo;
import com.ycl.domain.entity.ProcessCoding;
import java.util.List;
@@ -38,16 +39,23 @@
    /** 变黄码的天数 */
    @ApiModelProperty("变黄码的天数")
    private Integer yellowTime;
    private String yellowTime;
    /** 变红码的天数 */
    @ApiModelProperty("变红码的天数")
    private Integer redTime;
    private String redTime;
    @TableField("overtime")
    /** 处理期限 */
    private String overtime;
    /** 任务状态0进行中1结束 */
    @ApiModelProperty("任务状态green/red/yellow")
    private String status;
    /** 任务超时状态 */
    @ApiModelProperty("任务超时状态")
    private String overtimeStatus;
    public static ProcessCodingVO getVoByEntity(@NonNull ProcessCoding entity, ProcessCodingVO vo) {
        if(vo == null) {
            vo = new ProcessCodingVO();
flowable/src/main/resources/mapper/ProcessCodingMapper.xml
@@ -10,7 +10,9 @@
        <result column="process_ins_id" property="processInsId" />
        <result column="yellow_time" property="yellowTime" />
        <result column="red_time" property="redTime" />
        <result column="overtime" property="overtime" />
        <result column="status" property="status" />
        <result column="overtime_status" property="overtimeStatus" />
    </resultMap>
@@ -22,7 +24,9 @@
            TPC.process_ins_id,
            TPC.yellow_time,
            TPC.red_time,
            TPC.overtime,
            TPC.status,
            TPC.overtime_status,
            TPC.id
        FROM
            t_process_coding TPC
@@ -39,7 +43,9 @@
            TPC.process_ins_id,
            TPC.yellow_time,
            TPC.red_time,
            TPC.overtime,
            TPC.status,
            TPC.overtime_status,
            TPC.id
        FROM
            t_process_coding TPC