包头下一个节点设置责任单位bug修复

This commit is contained in:
guoshengxiong 2025-05-10 18:46:03 +08:00
parent 3b19203df3
commit 02ca1f9808
2 changed files with 50 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package com.zhgd.xmgl.modules.baotou.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -151,6 +152,11 @@ public class CivilizeConstructionServiceImpl extends ServiceImpl<CivilizeConstru
@Override
public void addFromFlow(Map<String, Object> map) {
String instanceId = FlowUtil.getString(map, "instanceId");
int count = this.count(new LambdaQueryWrapper<CivilizeConstruction>()
.eq(CivilizeConstruction::getInstanceId, instanceId));
if (count > 0) {
return;
}
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(instanceId).singleResult();
Map<String, Object> formData = processService.getInstanceProgress(null, instanceId).getFormData();
ProcessProgressVo.ProgressNode node = flowSeviceUtil.getNextTodoApproval(instanceId, FlowUtil.getString(map, "dfNodeId"));

View File

@ -167,17 +167,45 @@ public class FlowSeviceUtil {
if (StrUtil.isNotBlank(dfNodeId)) {
nodeMap = nodeCatchService.reloadProcessByStr(modelHistory.getProcess());
}
List<ProcessProgressVo.ProgressNode> progressNodeList = this.getFutureTask(instance, owner.getOwnerDeptId(), vars, nodeMap, modelHistory.getTenantId());
progressNodeList = progressNodeList.stream().filter(o -> o.getNodeType().equals(NodeTypeEnum.APPROVAL)).collect(Collectors.toList());
if (CollUtil.isEmpty(progressNodeList)) {
ProcessNode nextValue = getNextValue(nodeMap, dfNodeId);
ApprovalProps props = (ApprovalProps) nextValue.getProps();
List<String> users = processTaskService.getApprovalUsers(instance.getId(), nextValue.getId(), props, modelHistory.getTenantId());
Map<String, OrgUser> userMaps = userDeptOrLeaderService.getUserMapByIds(users);
// List<ProcessProgressVo.ProgressNode> progressNodeList = this.getCurFutureTask(instance, owner.getOwnerDeptId(), vars, nodeMap, modelHistory.getTenantId());
// progressNodeList = progressNodeList.stream().filter(o -> o.getNodeType().equals(NodeTypeEnum.APPROVAL)).collect(Collectors.toList());
if (CollUtil.isEmpty(users)) {
log.warn("获取下一个待处理的审批节点超时失败instanceId=" + instanceId + "nodeId=" + dfNodeId);
return null;
} else {
return progressNodeList.get(0);
return ProcessProgressVo.ProgressNode.builder()
.nodeId(nextValue.getId())
.name(nextValue.getName())
.user(userMaps.getOrDefault(users.get(0), UNKNOW_USER))
.nodeType(nextValue.getType())
.comment(Collections.emptyList())
.approvalMode(props.getMode())
// .startTime(createTime)
.build();
}
}
/**
* 获取下一个节点
*
* @param map
* @param key
* @return
*/
public ProcessNode getNextValue(Map<String, ProcessNode<?>> map, String key) {
List<Map.Entry<String, ProcessNode<?>>> entries = new ArrayList<>(map.entrySet());
for (int i = 0; i < entries.size(); i++) {
if (entries.get(i).getKey().equals(key) && i < entries.size() - 1) {
return entries.get(i + 1).getValue();
}
}
return null;
}
private boolean isProcessDone(String process, String curNodeId, String dfNodeId) {
JSONObject rootJo = JSON.parseObject(process);
int i = 0;
@ -274,7 +302,17 @@ public class FlowSeviceUtil {
return ccUsers;
}
private List<ProcessProgressVo.ProgressNode> getFutureTask(HistoricProcessInstance instance, String
/**
* 获取当前和未来的节点
*
* @param instance
* @param startDept
* @param context
* @param nodes
* @param tenantId
* @return
*/
private List<ProcessProgressVo.ProgressNode> getCurFutureTask(HistoricProcessInstance instance, String
startDept, Map<String, Object> context, Map<String, ProcessNode<?>> nodes, String tenantId) {
//根据流程遍历后续节点期间要穿越后续包含并行网关和条件网关的节点先找到所有激活的任务节点开始递归
//节点如果处于并行/包容分支内可能会有多个活动的节点