From 89144af315cdd0ce9ad75f4aead298aebd278df7 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期一, 24 三月 2025 11:45:35 +0800
Subject: [PATCH] 容缺计数
---
business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 107 insertions(+), 1 deletions(-)
diff --git a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
index 0c283e6..0ed7ebe 100644
--- a/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/ProjectProcessServiceImpl.java
@@ -18,6 +18,7 @@
import com.ycl.domain.entity.*;
import com.ycl.domain.form.*;
import com.ycl.domain.json.*;
+import com.ycl.domain.query.ProcessLogQuery;
import com.ycl.domain.vo.*;
import com.ycl.event.event.TaskLogEvent;
import com.ycl.mapper.ProjectEngineeringMapper;
@@ -28,6 +29,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.domain.query.ProjectProcessQuery;
import com.ycl.service.common.TaskCommonService;
+import com.ycl.system.domain.base.AbsQuery;
import com.ycl.system.service.ISysDeptService;
import com.ycl.system.service.ISysDictTypeService;
import com.ycl.system.service.ISysRoleService;
@@ -302,6 +304,7 @@
taskStatistics.setTimelyFinishedTaskNum(this.getTimelyTaskNum(projectProcess.getProcessInsId()));
taskStatistics.setOvertimeTaskNum(this.getOvertimeTaskNum(projectProcess.getProcessInsId()));
taskStatistics.setWillOvertimeTaskNum(this.getWillOvertimeTaskNum(projectProcess.getProcessInsId()));
+ taskStatistics.setToleranceNum(this.getToleranceTask(projectProcess.getProcessInsId()));
// taskStatistics.setCurrentTask(this.getCurrentNodeTaskList(projectProcess.getProcessInstanceId()));
detail.setStatistics(taskStatistics);
@@ -310,6 +313,32 @@
// 浠e姙浠诲姟
this.getTodoTaskList(projectProcess.getProjectId(), projectProcess.getProcessInsId(), "", 5, 1, result);
return result.data(detail);
+ }
+
+ /**
+ * 瀹圭己浠诲姟璁℃暟
+ * @param processInsId
+ * @return
+ */
+ private Long getToleranceTask(String processInsId){
+ // 鏌ュ嚭瀹圭己杩囩殑浠诲姟
+ List<ProcessLog> allWaitTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+ .eq(ProcessLog::getProcessInsId, processInsId)
+ .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.WAIT)
+ .orderByDesc(ProcessLog::getGmtCreate)
+ .list();
+ // 鎺掗櫎瀹圭己鍚庡張瀹屾垚鐨勪换鍔�
+ List<ProcessLog> finishedTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
+ .eq(ProcessLog::getProcessInsId, processInsId)
+ .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.FINISHED)
+ .list();
+ List<String> finishedTaskIds = finishedTaskList.stream().map(ProcessLog::getTaskId).distinct().collect(Collectors.toList());
+ // 寰楀埌鏈畬鎴愮殑瀹圭己浠诲姟
+ List<String> waitTaskIds = allWaitTaskList.stream().filter(log -> !finishedTaskIds.contains(log.getTaskId())).map(ProcessLog::getTaskId).collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(waitTaskIds)) {
+ return 0L;
+ }
+ return Long.valueOf(waitTaskIds.size());
}
@Override
@@ -378,7 +407,50 @@
.endOr();
}
result.total(taskQuery.count());
- List<Task> taskList = taskQuery.listPage(pageSize * (pageNum - 1), pageSize);
+ List<Task> allTodoList = taskQuery.list();
+ List<TaskOrderVO> orderList = new ArrayList<>();
+ allTodoList.stream().forEach(task -> {
+ TaskOrderVO order = new TaskOrderVO();
+ order.setTaskId(task.getId());
+ // 璁$畻鍔炵悊鏃堕棿锛岃秴鏃剁殑鎺掑墠闈紝娌¤秴鏃剁殑鐢变綆鍒伴珮鎺掑簭锛屾病瓒呮椂鏃堕棿鐨勬帓鏈�鍚�
+ ProcessCoding processCoding = processCodingService.getByTaskId(task.getId(), task.getProcessInstanceId());
+ if (Objects.nonNull(processCoding)) {
+ if (StringUtils.isNotBlank(processCoding.getRedTime())) {
+ Long overtime = getTime(processCoding.getRedTime());
+ long durationTime = 0l;
+ if (Objects.nonNull(processCoding.getStartTaskTime())) {
+ durationTime = ((new Date()).getTime() - processCoding.getStartTaskTime().getTime()) / 1000;
+ }
+ if (overtime > durationTime) {
+ order.setNum((overtime - durationTime) / 3600);
+ } else {
+ order.setNum(-2000000L);
+ }
+ } else {
+ order.setNum(2000000L);
+ }
+ } else {
+ order.setNum(2000000L);
+ }
+ orderList.add(order);
+ });
+ // 鍗囧簭鎺掑垪
+ Collections.sort(orderList, Comparator.comparingLong(TaskOrderVO::getNum));
+ int startNum = pageSize * (pageNum - 1);
+ int endNum = startNum + pageSize;
+ if (startNum >= orderList.size()) {
+ result.data(new ArrayList<>()).total(0L);
+ return;
+ }
+ int end = Math.min(endNum, orderList.size());
+ List<String> targetTaskIds = orderList.subList(startNum, end).stream().map(TaskOrderVO::getTaskId).collect(Collectors.toList());
+ List<Task> taskList = targetTaskIds.stream().map(taskId -> {
+ List<Task> list = allTodoList.stream().filter(task -> task.getId().equals(taskId)).collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(list)) {
+ return null;
+ }
+ return list.get(0);
+ }).filter(Objects::nonNull).collect(Collectors.toList());
List<IndexCustomerTaskVO> vos = new ArrayList<>();
for (Task task : taskList) {
IndexCustomerTaskVO taskVO = new IndexCustomerTaskVO();
@@ -921,6 +993,37 @@
new TeamWorkData(form.getHandlerType(), form.getHandlerIds(), TeamWorkStatusEnum.NOT_FINISHED)
));
return Result.ok("鎿嶄綔鎴愬姛");
+ }
+
+ @Override
+ public Result getProcessMsg(AbsQuery q) {
+ // 鏌ヨ嚜宸辩殑鏃ュ織
+ ProcessLogQuery query = new ProcessLogQuery();
+ if (! SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
+ query.setUserId(SecurityUtils.getUserId());
+ }
+ query.setEventTypeList(Arrays.asList(ProcessLogEventTypeEnum.DELEGATE.getValue(),
+ ProcessLogEventTypeEnum.REJECT.getValue(),
+ ProcessLogEventTypeEnum.JUMP.getValue(),
+ ProcessLogEventTypeEnum.FINISHED.getValue(),
+ ProcessLogEventTypeEnum.WAIT.getValue()));
+ query.setCurrentPage(q.getCurrentPage());
+ query.setPageSize(q.getPageSize());
+ Result result = processLogService.projectProcessLogPage(query);
+ List<ProcessLogVO> logs = (List<ProcessLogVO>) result.get("data");
+
+ logs.stream().forEach(log -> {
+ if (ProcessLogEventTypeEnum.FINISHED.equals(log.getEventType())) {
+ log.setContent("鎮ㄥ畬鎴愪簡浠诲姟锛�" + log.getTaskName());
+ } else if (ProcessLogEventTypeEnum.REJECT.equals(log.getEventType())) {
+ log.setContent("鎮ㄩ┏鍥炰簡浠诲姟锛�" + log.getTaskName());
+ } else if (ProcessLogEventTypeEnum.WAIT.equals(log.getEventType())) {
+ log.setContent("鎮ㄥ缂轰簡浠诲姟锛�" + log.getTaskName());
+ } else if (ProcessLogEventTypeEnum.JUMP.equals(log.getEventType())) {
+ log.setContent("鎮ㄨ烦杩囦簡浠诲姟锛�" + log.getTaskName());
+ }
+ });
+ return Result.ok().data(logs).total((Long) result.get("total"));
}
/**
@@ -1660,6 +1763,8 @@
return Long.valueOf(tList.size());
}
+
+
/**
* 鏌ヨ鍗冲皢瓒呮椂鐨勪换鍔�
*
@@ -1742,6 +1847,7 @@
Integer pageNum,
Integer pageSize,
Result result) {
+
// 鏌ュ嚭瀹圭己杩囩殑浠诲姟
List<ProcessLog> allWaitTaskList = new LambdaQueryChainWrapper<>(processLogService.getBaseMapper())
.eq(ProcessLog::getProcessInsId, processInsId)
--
Gitblit v1.8.0