From 1519a7c81e6566dd0cbc6acfb1b5e92c3aaba7df Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期日, 02 三月 2025 10:53:57 +0800
Subject: [PATCH] 赋码定时任务只判断超时,且用红码时间判断
---
business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 6 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 268b945..ed9e5f5 100644
--- a/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
+++ b/business/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
@@ -15,6 +15,7 @@
import com.ycl.common.core.domain.entity.SysUser;
import com.ycl.common.enums.FlowComment;
import com.ycl.common.enums.business.ProcessLogEventTypeEnum;
+import com.ycl.common.enums.business.TaskStatusEnum;
import com.ycl.common.exception.CustomException;
import com.ycl.common.utils.SecurityUtils;
import com.ycl.domain.dto.FlowCommentDto;
@@ -73,6 +74,7 @@
import java.io.InputStream;
import java.lang.reflect.Field;
+import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
@@ -149,6 +151,7 @@
if (Objects.isNull(projectProcess)) {
return AjaxResult.error("椤圭洰娴佺▼鏈粦瀹�");
}
+
Map<String, Object> processVariables = new HashMap<>();
//鏌ュ嚭瀛楀吀涓渶瑕佹敞鍏ョ殑瀛楁淇℃伅
List<String> dictList = sysDictDService.selectDictDataByType("flow_variables").stream().map(SysDictData::getDictValue).collect(Collectors.toList());
@@ -158,7 +161,14 @@
newV.put(task.getTaskDefinitionKey() + "&" + key, variables.get(key));
//瀛楀吀閲屾湁灏辨斁鍏ユ祦绋嬪彉閲忎腑
if (!CollectionUtils.isEmpty(dictList) && dictList.contains(key)) {
- processVariables.put(key,variables.get(key));
+ if ("money".equals(key)) {
+ // 涓囧厓杞厓
+ Object w = variables.get(key);
+ BigDecimal y = new BigDecimal(w.toString()).multiply(new BigDecimal(10000));
+ processVariables.put(key, y);
+ } else {
+ processVariables.put(key,variables.get(key));
+ }
}
}
}
@@ -1181,8 +1191,9 @@
.list();
//鎵╁睍 鑾峰彇杩欎釜娴佺▼瀹炰緥鐨勭洃鎺т俊鎭� key:TaskId value:瀹炰綋绫�
- Map<String, ProcessCoding> processCodingMap = processCodingMapper
- .selectList(new QueryWrapper<ProcessCoding>().eq("process_ins_id", procInsId))
+ Map<String, ProcessCoding> processCodingMap = new LambdaQueryChainWrapper<>(processCodingMapper)
+ .eq(ProcessCoding::getProcessInsId, procInsId)
+ .list()
.stream()
.collect(Collectors.toMap(ProcessCoding::getTaskId, Function.identity()));
// 淇濆瓨宸茬粡瀹屾垚鐨勬祦绋嬭妭鐐圭紪鍙�
@@ -1247,13 +1258,35 @@
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
// 娴佺▼鍙橀噺
Map<String, Object> parameters = new HashMap<>();
+ List<FormDetailVO> beforeNodes = new ArrayList<>();
+ String processInsId = "";
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().finished().taskId(taskId).singleResult();
if (Objects.nonNull(historicTaskInstance)) {
parameters = historicTaskInstance.getProcessVariables();
+ processInsId = historicTaskInstance.getProcessInstanceId();
+ beforeNodes = this.getBeforeNodeForm(parameters, historicTaskInstance.getFormKey(), historicTaskInstance.getName(), historicTaskInstance.getProcessDefinitionId(), historicTaskInstance.getTaskDefinitionKey(), Boolean.FALSE);
} else {
parameters = taskService.getVariables(taskId);
+ processInsId = task.getProcessInstanceId();
+ beforeNodes = this.getBeforeNodeForm(parameters, task.getFormKey(), task.getName(), task.getProcessDefinitionId(), task.getTaskDefinitionKey(), Boolean.FALSE);
}
- List<FormDetailVO> beforeNodes = this.getBeforeNodeForm(parameters, task.getFormKey(), task.getName(), task.getProcessDefinitionId(), task.getTaskDefinitionKey(), Boolean.FALSE);
+ // 鍒ゆ柇鍓嶇疆浠诲姟鏄笉鏄拰褰撳墠浠诲姟涓哄悓涓�涓猠xecuteId
+ // 鍒ゆ柇褰撳墠浠诲姟鏄惁琚寕璧蜂腑
+ String finalProcessInsId = processInsId;
+ beforeNodes = beforeNodes.stream().filter(node -> {
+ if (node.getCurrent()) {
+ return Boolean.TRUE;
+ }
+ HistoricTaskInstance beforeTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(finalProcessInsId).finished().taskDefinitionKey(node.getBeforeNodeDefId()).singleResult();
+ return Objects.nonNull(beforeTask);
+ }).collect(Collectors.toList());
+ beforeNodes.forEach(node -> {
+ if (node.getCurrent()) {
+ if (processLogService.taskIsHangup(taskId, finalProcessInsId)) {
+ node.setTaskStatus(TaskStatusEnum.HANGUP);
+ }
+ }
+ });
return AjaxResult.success(beforeNodes);
}
@@ -1270,11 +1303,25 @@
}
parameters = hisTask.getProcessVariables();
List<FormDetailVO> beforeNodes = this.getBeforeNodeForm(parameters, hisTask.getFormKey(), hisTask.getName(), hisTask.getProcessDefinitionId(), hisTask.getTaskDefinitionKey(), Boolean.TRUE);
- return AjaxResult.success(beforeNodes);
+ List<FormDetailVO> dataList = beforeNodes.stream().filter(node -> {
+ if (node.getCurrent()) {
+ return Boolean.TRUE;
+ }
+ HistoricTaskInstance beforeTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(hisTask.getProcessInstanceId()).finished().taskDefinitionKey(node.getBeforeNodeDefId()).singleResult();
+ return Objects.nonNull(beforeTask);
+ }).collect(Collectors.toList());
+ return AjaxResult.success(dataList);
} else {
parameters = taskService.getVariables(taskId);
List<FormDetailVO> beforeNodes = this.getBeforeNodeForm(parameters, task.getFormKey(), task.getName(), task.getProcessDefinitionId(), task.getTaskDefinitionKey(), Boolean.TRUE);
- return AjaxResult.success(beforeNodes);
+ List<FormDetailVO> dataList = beforeNodes.stream().filter(node -> {
+ if (node.getCurrent()) {
+ return Boolean.TRUE;
+ }
+ HistoricTaskInstance beforeTask = historyService.createHistoricTaskInstanceQuery().processInstanceId(task.getProcessInstanceId()).finished().taskDefinitionKey(node.getBeforeNodeDefId()).singleResult();
+ return Objects.nonNull(beforeTask);
+ }).collect(Collectors.toList());
+ return AjaxResult.success(dataList);
}
}
--
Gitblit v1.8.0