| | |
| | | package com.ycl.task; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.ycl.common.enums.business.ProcessLogEventTypeEnum; |
| | | import com.ycl.common.enums.business.ProjectProcessTypeEnum; |
| | | import com.ycl.domain.entity.ProcessCoding; |
| | | import com.ycl.domain.entity.ProcessLog; |
| | | import com.ycl.domain.entity.ProjectInfo; |
| | |
| | | |
| | | List<String> taskIds = taskList.stream().map(TaskInfo::getId).collect(Collectors.toList()); |
| | | //查询节点挂起日志 |
| | | Map<String, List<ProcessLog>> hangupLogMap = processLogService.list(new QueryWrapper<ProcessLog>() |
| | | .in("event_type", Arrays.asList(HANGUP, CANCEL_HANGUP)) |
| | | .in("process_ins_id", taskIds)).stream() |
| | | Map<String, List<ProcessLog>> hangupLogMap = new LambdaQueryChainWrapper<>(processLogMapper) |
| | | .in(ProcessLog::getEventType, HANGUP, CANCEL_HANGUP) |
| | | .in(ProcessLog::getProcessInsId, taskIds) |
| | | .list() |
| | | .stream() |
| | | .collect(Collectors.groupingBy(ProcessLog::getTaskId)); |
| | | |
| | | //需要监控的赋码任务 |
| | | List<ProcessCoding> processCodingList = processCodingMapper.selectList(new QueryWrapper<ProcessCoding>().in("task_id", taskIds)); |
| | | List<ProcessCoding> processCodingList = new LambdaQueryChainWrapper<>(processCodingMapper) |
| | | .in(ProcessCoding::getTaskId, taskIds) |
| | | .list(); |
| | | Map<String, ProcessCoding> taskMap = new HashMap<>(); |
| | | Map<String, Date> startTaskMap = new HashMap<>(); |
| | | if (!CollectionUtils.isEmpty(processCodingList)) { |
| | |
| | | map.get(GREEN).add(task.getProcessInstanceId()); |
| | | continue; |
| | | } |
| | | //判断赋码统一用秒作为单位 |
| | | //判断赋码统一用秒作为单位,且只需用红码时间判断超时,通过超时去改变项目的赋码状态,节点本身无赋码状态 |
| | | Date startTime = startTaskMap.get(processCoding.getStartTaskId()); |
| | | try { |
| | | Long redTime = getTime(processCoding.getRedTime()); |
| | | Long yellowTime = getTime(processCoding.getYellowTime()); |
| | | Long overtime = getTime(processCoding.getOvertime()); |
| | | // Long yellowTime = getTime(processCoding.getYellowTime()); |
| | | // Long overtime = getTime(processCoding.getOvertime()); |
| | | if (startTime == null) continue; |
| | | //节点处理时间 |
| | | long durationTime = (now.getTime() - startTime.getTime()) / 1000; |
| | | //TODO:减去项目挂起时长 |
| | | //TODO:减去流程挂起时长 |
| | | |
| | | //减去节点挂起时长 |
| | | durationTime = subNodeHangupTime(hangupLogMap, task, durationTime); |
| | | |
| | | String status = GREEN; // 默认状态为绿色 |
| | | if (redTime != null && redTime != 0 && durationTime >= redTime) { |
| | | status = RED; // 如果超过红色时间阈值,则状态为红色 |
| | | } else if (yellowTime != null && yellowTime != 0 && durationTime >= yellowTime) { |
| | | status = YELLOW; // 否则,如果超过黄色时间阈值,则状态为黄色 |
| | | } |
| | | //处理办理期限 |
| | | String overtimeStatus = NORMAL; |
| | | if (overtime != null && overtime != 0 && durationTime >= overtime) { |
| | | overtimeStatus = OVERTIME; // 如果超过办理期限 |
| | | } else if (overtime != null && overtime != 0 && durationTime >= (overtime - 12 * 60 * 60)) { |
| | | overtimeStatus = WILLOVERTIME; // 如果临期(固定超时前12小时为临期) |
| | | if (redTime != null && redTime != 0 && durationTime >= redTime) { |
| | | status = RED; // 如果超过红色时间阈值,则表明该任务超时 |
| | | overtimeStatus = OVERTIME; |
| | | } |
| | | // else if (yellowTime != null && yellowTime != 0 && durationTime >= yellowTime) { |
| | | // status = YELLOW; // 否则,如果超过黄色时间阈值,则状态为黄色 |
| | | // } |
| | | // //处理办理期限 |
| | | // String overtimeStatus = NORMAL; |
| | | // if (overtime != null && overtime != 0 && durationTime >= overtime) { |
| | | // overtimeStatus = OVERTIME; // 如果超过办理期限 |
| | | // } else if (overtime != null && overtime != 0 && durationTime >= (overtime - 12 * 60 * 60)) { |
| | | // overtimeStatus = WILLOVERTIME; // 如果临期(固定超时前12小时为临期) |
| | | // } |
| | | // else if (overtime != null && overtime != 0 && durationDay >= (overtime - 60)) { |
| | | // overtimeStatus = WILLOVERTIME; // 如果临期(固定超时前12小时为临期) |
| | | // } |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> projectIds = projectProcessMapper.selectList( |
| | | new QueryWrapper<ProjectProcess>() |
| | | .in("process_ins_id", processInstanceIds) |
| | | ).stream() |
| | | List<String> projectIds = new LambdaQueryChainWrapper<>(projectProcessMapper) |
| | | .in(ProjectProcess::getProcessInsId, processInstanceIds) |
| | | .eq(ProjectProcess::getProjectType, ProjectProcessTypeEnum.PROJECT) |
| | | .list() |
| | | .stream() |
| | | .map(ProjectProcess::getProjectId) |
| | | .collect(Collectors.toList()); |
| | | |