From a99b058120879a75442e6bbaebd44c4c183153b6 Mon Sep 17 00:00:00 2001
From: xiejun <xj@2023>
Date: 星期三, 06 十二月 2023 09:56:25 +0800
Subject: [PATCH] 集团码导入功能开发
---
Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java | 62 +++++++++++++++++++++++++++---
1 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java
index f1deaf9..3e48538 100644
--- a/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java
+++ b/Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java
@@ -16,13 +16,20 @@
*/
package com.vci.ubcs.flow.engine.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.vci.ubcs.flow.core.constant.ProcessConstant;
+import com.vci.ubcs.flow.core.dto.FlowTaskDTO;
+import com.vci.ubcs.flow.core.dto.ProcessStageAttrDTO;
import com.vci.ubcs.flow.core.entity.BladeFlow;
+import com.vci.ubcs.flow.core.entity.FlowTaskUser;
+import com.vci.ubcs.flow.core.entity.ProcessStageAttr;
import com.vci.ubcs.flow.core.utils.TaskUtil;
import com.vci.ubcs.flow.engine.entity.*;
import com.vci.ubcs.flow.engine.service.FlowEngineService;
import com.vci.ubcs.flow.engine.service.FlowTaskUserService;
+import com.vci.ubcs.flow.engine.service.ProcessStageAttrService;
import com.vci.ubcs.flow.engine.service.VICFlowService;
+import com.vci.ubcs.starter.web.util.BeanUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -32,7 +39,7 @@
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
-import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.support.Condition;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.support.Kv;
@@ -56,8 +63,11 @@
private final FlowTaskUserService flowTaskUserService;
private final FlowEngineService flowEngineService;
private final HistoryService historyService;
+ private final ProcessStageAttrService processStageAttrService;
private static String MODELKEY = "modelKey";//鍓嶇浼犺繃鏉ョ殑妯″瀷key
+ private static String TASKID = "taskId";//鍓嶇浼犺繃鏉ョ殑妯″瀷key
+ private static String PROCESSINSTANCEID = "processInstanceId";//鍓嶇浼犺繃鏉ョ殑妯″瀷key
@Override
public R<BladeFlow> startProcess(FlowTaskDTO flowTaskUserC){
Map<String, Object> kvv = flowTaskUserC.getVariables();
@@ -148,10 +158,17 @@
String modelKey = processInstance.getProcessDefinitionKey();
List<FlowTaskDTO> mis = flowEngineService.getNodeByFlowableKey(modelKey);
+ Map<String,String> taskMap = new HashMap<>();
+ mis.stream().forEach(e->{
+ String taskId = e.getTaskId();
+ String taskName = e.getTaskName();
+ taskMap.put(taskId,taskName);
+ });
// 杈撳嚭杩炵嚎
List<SequenceFlow> outFlows = flowNode.getOutgoingFlows();
for (SequenceFlow sequenceFlow : outFlows) {
+ String toname = sequenceFlow.getName()==null?"鍚屾剰":sequenceFlow.getName();
//褰撳墠瀹℃壒鑺傜偣
if (NODE_NOW.equals(node)) {
FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement();
@@ -163,9 +180,11 @@
FlowTaskDTO flowTaskUserCi = new FlowTaskDTO();
//flowTaskUserCi.setConditionKey(null);
//flowTaskUserCi.setConditionValue(null);
- flowTaskUserCi.setToName("鍚屾剰");
+ flowTaskUserCi.setToName(toname);
flowTaskUserCi.setToTaskId(targetFlow.getId());
- flowTaskUserCi.setToTaskName(targetFlow.getName());
+ String taskName = taskMap.get(targetFlow.getId());
+ flowTaskUserCi.setToTaskName(taskName);
+ flowTaskUserCi.setTaskName(taskName);
taskList.add(flowTaskUserCi);
}
@@ -179,16 +198,21 @@
flowTaskUserCi.setToTaskName(targetFlow.getName());
taskList.add(flowTaskUserCi);
}
- // 濡傛灉涓嬩釜瀹℃壒鑺傜偣涓烘帓浠栫綉鍏�
- if (targetFlow instanceof ExclusiveGateway) {
+ // 濡傛灉涓嬩釜瀹℃壒鑺傜偣涓虹綉鍏�
+ if (targetFlow instanceof Gateway) {
ExclusiveGateway exclusiveGateway = (ExclusiveGateway) targetFlow;
List<SequenceFlow> exclusiveGatewayOutgoingFlows = exclusiveGateway.getOutgoingFlows();
for (SequenceFlow nexti:exclusiveGatewayOutgoingFlows){
String conditionExpression = nexti.getConditionExpression();//condition
+
String taskId = nexti.getTargetRef();//taskId
String name = nexti.getName();//toName,椹冲洖銆佸悓鎰�
-
+ String taskName = taskMap.get(taskId);
+//ExclusiveGateway
+ if(StringUtils.isEmpty(conditionExpression)){//姝ゆ椂鎺掍粬缃戝叧娌℃湁閰嶇疆娴佽浆鏉′欢
+ continue;
+ }
for (FlowTaskDTO flowTaskUserCi:mis){
if(taskId.equals(flowTaskUserCi.getTaskId())){
flowTaskUserCi.setCondition(conditionExpression);
@@ -209,7 +233,8 @@
}
flowTaskUserCi.setToName(name);
flowTaskUserCi.setToTaskId(taskId);
- flowTaskUserCi.setToTaskName(flowTaskUserCi.getTaskName());
+ flowTaskUserCi.setToTaskName(taskName);
+ flowTaskUserCi.setTaskName(taskName);
taskList.add(flowTaskUserCi);
}
}
@@ -217,10 +242,33 @@
}
}
}
+
+ //娴佺▼甯搁噺
Map<String,Object> variables = runtimeService.getVariables(processInstanceId);
if(!variables.isEmpty()){
flowTaskDTO.setVariables(variables);
}
+
+ //娴佺▼闃舵
+ Map<String, Object> m = new HashMap<>();
+ String templateId = variables.get("templateId").toString();
+ m.put("template_id", templateId);
+ m.put("task_id", crruentActivityId);
+ m.put("model_key", modelKey);
+ QueryWrapper q = Condition.getQueryWrapper(m, ProcessStageAttr.class)
+ .select("attr_id attrId,attr_name attrName,attr_group attrGroup");
+ List<ProcessStageAttr> stageAttrs = processStageAttrService.list(q);
+ List<ProcessStageAttrDTO> stageAttrsDto = new ArrayList<>();
+ stageAttrs.stream().forEach(e->{
+ ProcessStageAttrDTO dto = new ProcessStageAttrDTO();
+ BeanUtil.convert(e,dto);
+ stageAttrsDto.add(dto);
+ });
+ flowTaskDTO.setStageAttrs(stageAttrsDto);
+
+ //鏀惧叆娴佺▼闃舵銆佹祦绋媘odelkey
+ variables.put(TASKID,crruentActivityId);
+ variables.put(PROCESSINSTANCEID,processInstanceId);
return flowTaskDTO;
}
}
--
Gitblit v1.9.3