From 1b9936ba920d65df09ab8dba79c6252568ee26e4 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 26 三月 2025 12:16:02 +0800
Subject: [PATCH] 任务统计bug
---
business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java | 76 +++++++++++++++++++++++++++----------
1 files changed, 55 insertions(+), 21 deletions(-)
diff --git a/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java b/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
index fdf46b4..af1da78 100644
--- a/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
@@ -6,6 +6,7 @@
import com.alibaba.fastjson2.TypeReference;
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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ycl.common.base.Result;
import com.ycl.common.constant.ProcessConstants;
@@ -24,6 +25,7 @@
import com.ycl.domain.dto.FlowTaskDto;
import com.ycl.domain.dto.FlowViewerDto;
import com.ycl.domain.entity.ProcessCoding;
+import com.ycl.domain.entity.ProcessLog;
import com.ycl.domain.entity.ProjectProcess;
import com.ycl.domain.entity.SysForm;
import com.ycl.domain.json.RejectData;
@@ -71,7 +73,6 @@
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -329,8 +330,18 @@
if (taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult().isSuspended()) {
throw new CustomException("浠诲姟澶勪簬鎸傝捣鐘舵��!");
}
+
// 褰撳墠浠诲姟 task
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
+
+ ProjectProcess projectProcess = new LambdaQueryChainWrapper<>(projectProcessMapper)
+ .eq(ProjectProcess::getProcessInsId, task.getProcessInstanceId())
+ .eq(ProjectProcess::getProcessDefId, task.getProcessDefinitionId())
+ .one();
+ if (Objects.isNull(projectProcess)) {
+ throw new CustomException("椤圭洰娴佺▼鏈粦瀹�");
+ }
+
// 鑾峰彇娴佺▼瀹氫箟淇℃伅
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
// 鑾峰彇鎵�鏈夎妭鐐逛俊鎭�
@@ -423,6 +434,21 @@
try {
// 濡傛灉鐖剁骇浠诲姟澶氫簬 1 涓紝璇存槑褰撳墠鑺傜偣涓嶆槸骞惰鑺傜偣锛屽師鍥犱负涓嶈�冭檻澶氬澶氭儏鍐�
if (targetIds.size() > 1) {
+ // 鍒犻櫎琚┏鍥炰换鍔$殑鎵�鏈夋棩蹇�
+ for (String targetId : targetIds) {
+ List<HistoricTaskInstance> rejectHisTaskList = historyService.createHistoricTaskInstanceQuery()
+ .taskDefinitionKey(targetId)
+ .processInstanceId(projectProcess.getProcessInsId())
+ .orderByHistoricTaskInstanceStartTime()
+ .desc()
+ .list();
+ if (CollectionUtils.isNotEmpty(rejectHisTaskList)) {
+ new LambdaUpdateChainWrapper<>(processLogService.getBaseMapper())
+ .eq(ProcessLog::getTaskId, rejectHisTaskList.get(0).getId())
+ .eq(ProcessLog::getProcessInsId, projectProcess.getProcessInsId())
+ .remove();
+ }
+ }
// 1 瀵� 澶氫换鍔¤烦杞紝currentIds 褰撳墠鑺傜偣(1)锛宼argetIds 璺宠浆鍒扮殑鑺傜偣(澶�)
runtimeService.createChangeActivityStateBuilder()
.processInstanceId(task.getProcessInstanceId()).
@@ -430,22 +456,30 @@
}
// 濡傛灉鐖剁骇浠诲姟鍙湁涓�涓紝鍥犳褰撳墠浠诲姟鍙兘涓虹綉鍏充腑鐨勪换鍔�
if (targetIds.size() == 1) {
+ // 鍒犻櫎琚┏鍥炰换鍔$殑鎵�鏈夋棩蹇�
+ List<HistoricTaskInstance> rejectHisTaskList = historyService.createHistoricTaskInstanceQuery()
+ .taskDefinitionKey(targetIds.get(0))
+ .processInstanceId(projectProcess.getProcessInsId())
+ .orderByHistoricTaskInstanceStartTime()
+ .desc()
+ .list();
+ if (CollectionUtils.isNotEmpty(rejectHisTaskList)) {
+ new LambdaUpdateChainWrapper<>(processLogService.getBaseMapper())
+ .eq(ProcessLog::getTaskId, rejectHisTaskList.get(0).getId())
+ .eq(ProcessLog::getProcessInsId, projectProcess.getProcessInsId())
+ .remove();
+ }
+
// 1 瀵� 1 鎴� 澶� 瀵� 1 鎯呭喌锛宑urrentIds 褰撳墠瑕佽烦杞殑鑺傜偣鍒楄〃(1鎴栧)锛宼argetIds.get(0) 璺宠浆鍒扮殑鑺傜偣(1)
runtimeService.createChangeActivityStateBuilder()
.processInstanceId(task.getProcessInstanceId())
.moveActivityIdsToSingleActivityId(currentIds, targetIds.get(0)).changeState();
}
+ historyService.deleteHistoricTaskInstance(flowTaskVo.getTaskId());
} catch (FlowableObjectNotFoundException e) {
throw new CustomException("鏈壘鍒版祦绋嬪疄渚嬶紝娴佺▼鍙兘宸插彂鐢熷彉鍖�");
} catch (FlowableException e) {
throw new CustomException("鏃犳硶鍙栨秷鎴栧紑濮嬫椿鍔�");
- }
- ProjectProcess projectProcess = new LambdaQueryChainWrapper<>(projectProcessMapper)
- .eq(ProjectProcess::getProcessInsId, task.getProcessInstanceId())
- .eq(ProjectProcess::getProcessDefId, task.getProcessDefinitionId())
- .one();
- if (Objects.isNull(projectProcess)) {
- throw new CustomException("椤圭洰娴佺▼鏈粦瀹�");
}
// 淇濆瓨鏃ュ織
publisher.publishEvent(new TaskLogEvent(this, null,
@@ -978,17 +1012,17 @@
public AjaxResult flowRecord(String procInsId) {
Map<String, Object> map = new HashMap<String, Object>();
if (StringUtils.isNotBlank(procInsId)) {
- List<HistoricActivityInstance> list = historyService
- .createHistoricActivityInstanceQuery()
+ List<HistoricTaskInstance> list = historyService
+ .createHistoricTaskInstanceQuery()
.processInstanceId(procInsId)
- .orderByHistoricActivityInstanceStartTime()
+ .orderByHistoricTaskInstanceStartTime()
.desc().list();
//鎵╁睍 鑾峰彇杩欎釜娴佺▼瀹炰緥鐨勭洃鎺т俊鎭� key:TaskId value:瀹炰綋绫�
Map<String, ProcessCoding> processCodingMap = processCodingMapper.selectList(new QueryWrapper<ProcessCoding>().eq("process_ins_id", procInsId))
.stream()
.collect(Collectors.toMap(ProcessCoding::getTaskId, Function.identity()));
List<FlowTaskDto> hisFlowList = new ArrayList<>();
- for (HistoricActivityInstance histIns : list) {
+ for (HistoricTaskInstance histIns : list) {
// 灞曠ず寮�濮嬭妭鐐�
// if ("startEvent".equals(histIns.getActivityType())) {
// FlowTaskDto flowTask = new FlowTaskDto();
@@ -1006,10 +1040,10 @@
// flowTask.setFinishTime(histIns.getEndTime());
// hisFlowList.add(flowTask);
// } else
- if (StringUtils.isNotBlank(histIns.getTaskId())) {
+ if (StringUtils.isNotBlank(histIns.getId())) {
FlowTaskDto flowTask = new FlowTaskDto();
- flowTask.setTaskId(histIns.getTaskId());
- flowTask.setTaskName(histIns.getActivityName());
+ flowTask.setTaskId(histIns.getId());
+ flowTask.setTaskName(histIns.getName());
flowTask.setCreateTime(histIns.getStartTime());
flowTask.setFinishTime(histIns.getEndTime());
if (StringUtils.isNotBlank(histIns.getAssignee())) {
@@ -1019,7 +1053,7 @@
flowTask.setDeptName(Objects.nonNull(sysUser.getDept()) ? sysUser.getDept().getDeptName() : "");
}
// 灞曠ず瀹℃壒浜哄憳
- List<HistoricIdentityLink> linksForTask = historyService.getHistoricIdentityLinksForTask(histIns.getTaskId());
+ List<HistoricIdentityLink> linksForTask = historyService.getHistoricIdentityLinksForTask(histIns.getId());
StringBuilder stringBuilder = new StringBuilder();
for (HistoricIdentityLink identityLink : linksForTask) {
// 鑾烽�変汉,鍊欓�夌粍/瑙掕壊(澶氫釜)
@@ -1046,7 +1080,7 @@
flowTask.setDuration(histIns.getDurationInMillis() == null || histIns.getDurationInMillis() == 0 ? null : getDate(histIns.getDurationInMillis()));
//鎵╁睍 鍒ゆ柇鏄惁瓒呮椂
- ProcessCoding processCoding = processCodingMap.get(histIns.getTaskId());
+ ProcessCoding processCoding = processCodingMap.get(histIns.getId());
if (processCoding != null) {
//閫氳繃鑰楁椂鍒ゆ柇鏄惁鏄唬鍔炶妭鐐�
//濡傛灉浠诲姟鏄唬鍔炶妭鐐�
@@ -1065,7 +1099,7 @@
// 鑾峰彇鎰忚璇勮鍐呭
List<Comment> commentList = taskService.getProcessInstanceComments(histIns.getProcessInstanceId());
commentList.forEach(comment -> {
- if (histIns.getTaskId().equals(comment.getTaskId())) {
+ if (histIns.getId().equals(comment.getTaskId())) {
flowTask.setComment(FlowCommentDto.builder().type(comment.getType()).comment(comment.getFullMessage()).build());
}
});
@@ -1443,7 +1477,7 @@
ProcessLogQuery query = new ProcessLogQuery();
query.setTaskId(node.getTaskId());
query.setProcessInsId(finalProcessInsId);
- Result result = processLogService.projectProcessLogPage(query);
+ Result result = processLogService.projectProcessLogList(query);
List<ProcessLogVO> logList = (List<ProcessLogVO>) result.get("data");
DoFormDetailVO vo = new DoFormDetailVO();
BeanUtils.copyProperties(node, vo);
@@ -1522,7 +1556,7 @@
ProcessLogQuery query = new ProcessLogQuery();
query.setTaskId(node.getTaskId());
query.setProcessInsId(hisTask.getProcessInstanceId());
- Result result = processLogService.projectProcessLogPage(query);
+ Result result = processLogService.projectProcessLogList(query);
List<ProcessLogVO> logList = (List<ProcessLogVO>) result.get("data");
DoFormDetailVO vo = new DoFormDetailVO();
BeanUtils.copyProperties(node, vo);
@@ -1593,7 +1627,7 @@
ProcessLogQuery query = new ProcessLogQuery();
query.setTaskId(node.getTaskId());
query.setProcessInsId(processInsId);
- Result result = processLogService.projectProcessLogPage(query);
+ Result result = processLogService.projectProcessLogList(query);
List<ProcessLogVO> logList = (List<ProcessLogVO>) result.get("data");
DoFormDetailVO vo = new DoFormDetailVO();
BeanUtils.copyProperties(node, vo);
--
Gitblit v1.8.0