From 1698792d4299a0b81b9695d8a56e3d3088c7a7ee Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期一, 31 三月 2025 11:39:50 +0800 Subject: [PATCH] 超时计算排除节假日,超时统计调整 --- business/src/main/java/com/ycl/task/FlowableTask.java | 75 ++++++++++++++++++++++++------------- 1 files changed, 49 insertions(+), 26 deletions(-) diff --git a/business/src/main/java/com/ycl/task/FlowableTask.java b/business/src/main/java/com/ycl/task/FlowableTask.java index e5cefa7..9055d47 100644 --- a/business/src/main/java/com/ycl/task/FlowableTask.java +++ b/business/src/main/java/com/ycl/task/FlowableTask.java @@ -1,14 +1,18 @@ 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.common.utils.DateUtils; import com.ycl.domain.entity.ProcessCoding; import com.ycl.domain.entity.ProcessLog; import com.ycl.domain.entity.ProjectInfo; import com.ycl.domain.entity.ProjectProcess; import com.ycl.factory.FlowServiceFactory; import com.ycl.mapper.ProcessCodingMapper; +import com.ycl.mapper.ProcessLogMapper; import com.ycl.mapper.ProjectInfoMapper; import com.ycl.mapper.ProjectProcessMapper; import com.ycl.service.ProcessCodingService; @@ -41,6 +45,9 @@ private ProcessCodingMapper processCodingMapper; @Autowired private ProcessLogService processLogService; + @Autowired + private ProcessLogMapper processLogMapper; + /** * 璧嬬爜浠诲姟 * 涓や釜閫昏緫 鏀归」鐩爜銆佹敼鑺傜偣棰滆壊 @@ -50,6 +57,11 @@ //褰撳墠姝e湪杩愯鐨勬墍鏈変换鍔¤妭鐐� List<Task> taskList = taskService.createTaskQuery().active().list(); if (CollectionUtils.isEmpty(taskList)) return; + //鎺掗櫎鎺夎妭鐐规寕璧风殑浠诲姟 + List<String> allHangupTask = processLogMapper.getAllHangup(); + taskList = taskList.stream() + .filter(task -> !allHangupTask.contains(task.getId())) + .collect(Collectors.toList()); //TODO锛氱瓫閫夊嚭娴佺▼瀹炰緥id锛岀敤浣滈」鐩寕璧� Set<String> proInsIds = taskList.stream() .map(TaskInfo::getProcessInstanceId) @@ -58,12 +70,17 @@ 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)) { @@ -88,43 +105,48 @@ 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锛氬噺鍘婚」鐩寕璧锋椂闀� + + //鑺傜偣澶勭悊鏃堕棿锛岄渶鎺掗櫎鑺傚亣鏃� + long durationTime = DateUtils.getWorkingSed(startTime, now); + + //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; // 濡傛灉瓒呰繃鍔炵悊鏈熼檺 + if (redTime != null && redTime != 0 && durationTime >= redTime) { + status = RED; // 濡傛灉瓒呰繃绾㈣壊鏃堕棿闃堝�硷紝鍒欒〃鏄庤浠诲姟瓒呮椂 + overtimeStatus = OVERTIME; } - else if (overtime != null && overtime != 0 && durationTime >= (overtime - 12 * 60 * 60)) { - overtimeStatus = WILLOVERTIME; // 濡傛灉涓存湡(鍥哄畾瓒呮椂鍓�12灏忔椂涓轰复鏈�) - } +// 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灏忔椂涓轰复鏈�) // } map.get(status).add(task.getProcessInstanceId()); processCoding.setStatus(status); processCoding.setOvertimeStatus(overtimeStatus); + processCoding.setStartTaskTime(task.getCreateTime()); list.add(processCoding); } catch (Exception e) { - log.error(e.getMessage(),"璧嬬爜鏃堕棿鏍煎紡鏈夎"); + log.error(e.getMessage(), "璧嬬爜鏃堕棿鏍煎紡鏈夎"); } } //鏇存柊椤圭洰鐮� @@ -196,10 +218,11 @@ 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()); -- Gitblit v1.8.0