From 34c289586add69e361ce476a32bc59d3a08ca993 Mon Sep 17 00:00:00 2001
From: fujunling <2984387807@qq.com>
Date: 星期二, 20 六月 2023 16:37:02 +0800
Subject: [PATCH] config文件代理

---
 Source/UBCS/ubcs-ops/ubcs-flow/src/main/java/com/vci/ubcs/flow/engine/service/impl/VCIFlowserviceImpl.java |   75 ++++++++++++++++++++++++++-----------
 1 files changed, 53 insertions(+), 22 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 9012c4b..1221fa3 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
@@ -31,7 +31,6 @@
 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.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.support.Kv;
@@ -57,7 +56,7 @@
 	private final HistoryService historyService;
 
 	@Override
-	public R<BladeFlow> startProcess(FlowTaskUserC flowTaskUserC){
+	public R<BladeFlow> startProcess(FlowTaskDTO flowTaskUserC){
 		String modelKey = flowTaskUserC.getModelKey();
 		String templateId = flowTaskUserC.getTemplateId();
 
@@ -81,16 +80,16 @@
 		}
 
 		//瀵规瘮閰嶇疆鐨勫鏍镐汉鍛樺拰娴佺▼涓妭鐐规槸鍚︿竴鑷达紝鍙兘瀛樺湪娴佺▼鑺傜偣鍙樻洿浜嗭紝澶氫簡鎴栬�呭皯浜嗚妭鐐癸紝浣嗘槸閰嶇疆瀹℃牳浜哄憳鐨勮妭鐐规病鏈夊彉
-		List<Map<String,String>> processTasks = flowEngineService.getNodeByFlowableKey(modelKey);
-		for (Map<String,String> mi:processTasks){
-			String taskId = mi.get(flowEngineService.getTaskIdString());
-			if(!taskIdSet.contains(taskId)){
-				throw new ServiceException("娴佺▼宸查噸鏂伴儴缃诧紝鑺傜偣宸叉敼鍙橈紝璇疯缃鏍镐汉鍛橈紒");
-			}
-		}
-		if(taskIdSet.size()!=processTasks.size()){
-			throw new ServiceException("娴佺▼宸查噸鏂伴儴缃诧紝鑺傜偣宸叉敼鍙橈紝璇疯缃鏍镐汉鍛橈紒");
-		}
+//		List<Map<String,String>> processTasks = flowEngineService.getNodeByFlowableKey(modelKey);
+//		for (Map<String,String> mi:processTasks){
+//			String taskId = mi.get(flowEngineService.getTaskIdString());
+//			if(!taskIdSet.contains(taskId)){
+//				throw new ServiceException("娴佺▼宸查噸鏂伴儴缃诧紝鑺傜偣宸叉敼鍙橈紝璇疯缃鏍镐汉鍛橈紒");
+//			}
+//		}
+//		if(taskIdSet.size()!=processTasks.size()){
+//			throw new ServiceException("娴佺▼宸查噸鏂伴儴缃诧紝鑺傜偣宸叉敼鍙橈紝璇疯缃鏍镐汉鍛橈紒");
+//		}
 
 		//娴佺▼涓枃浠躲�佸彉閲忕瓑
 		//do..
@@ -100,46 +99,78 @@
 		BladeFlow flow = new BladeFlow();
 		flow.setProcessInstanceId(processInstance.getId());
 
-		nextFlowNode("next","039ac1d8-0c1e-11ee-bebb-5c3a4570456d");
 		return R.data(flow);
 	}
 
+	public static String NODE_NOW = "now";
+	public static String NODE_NEXT = "next";
 	/**
 	 * 鑾峰彇浠诲姟鑺傜偣
 	 *
 	 * @param node   鏌ヨ鑺傜偣閫夋嫨
 	 * @param processInstanceId 娴佺▼瀹炰緥id
 	 */
-	public void nextFlowNode(String node, String processInstanceId) {
+	public FlowTaskDTO nextFlowNode(String node, String processInstanceId) {
+		FlowTaskDTO flowTaskDTO = new FlowTaskDTO();
+		List<FlowTaskDTO> taskList = new ArrayList<>();//鑺傜偣鎸夐挳
+		flowTaskDTO.setToTasks(taskList);
 
 		Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).active().singleResult();
-
 		ExecutionEntity ee = (ExecutionEntity) runtimeService.createExecutionQuery()
 			.executionId(task.getExecutionId()).singleResult();
 		// 褰撳墠瀹℃壒鑺傜偣
 		String crruentActivityId = ee.getActivityId();
 		BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
 		FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(crruentActivityId);
+
+		//杩欎釜瀹炰緥鐨勬墍鏈夎妭鐐�
+		ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+		Map<String, Object> processVariables = processInstance.getProcessVariables();//鎵�鏈夊弬鏁�
+		flowTaskDTO.setVars(processVariables);
+
+		String modelKey = processInstance.getProcessDefinitionKey();
+		List<FlowTaskDTO> mis = flowEngineService.getNodeByFlowableKey(modelKey);
+
 		// 杈撳嚭杩炵嚎
 		List<SequenceFlow> outFlows = flowNode.getOutgoingFlows();
 		for (SequenceFlow sequenceFlow : outFlows) {
 			//褰撳墠瀹℃壒鑺傜偣
-			if ("now".equals(node)) {
+			if (NODE_NOW.equals(node)) {
 				FlowElement sourceFlowElement = sequenceFlow.getSourceFlowElement();
 				System.out.println("褰撳墠鑺傜偣: id=" + sourceFlowElement.getId() + ",name=" + sourceFlowElement.getName());
-			} else if ("next".equals(node)) {
+			} else if (NODE_NEXT.equals(node)) {
 				// 涓嬩竴涓鎵硅妭鐐�
 				FlowElement targetFlow = sequenceFlow.getTargetFlowElement();
 				if (targetFlow instanceof UserTask) {
 					System.out.println("涓嬩竴鑺傜偣: id=" + targetFlow.getId() + ",name=" + targetFlow.getName());
 				}
-				// 濡傛灉涓嬩釜瀹℃壒鑺傜偣涓虹粨鏉熻妭鐐�
-				if (targetFlow instanceof EndEvent) {
-					System.out.println("涓嬩竴鑺傜偣涓虹粨鏉熻妭鐐癸細id=" + targetFlow.getId() + ",name=" + targetFlow.getName());
+				// 濡傛灉涓嬩釜瀹℃壒鑺傜偣涓烘帓浠栫綉鍏�
+				if (targetFlow instanceof ExclusiveGateway) {
+
+					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,椹冲洖銆佸悓鎰�
+
+						for (FlowTaskDTO flowTaskUserCi:mis){
+							if(taskId.equals(flowTaskUserCi.getTaskId())){
+								flowTaskUserCi.setCondition(conditionExpression);
+								if(conditionExpression.split("=").length>1) {
+									flowTaskUserCi.setConditionKey(conditionExpression.split("=")[0]);
+									flowTaskUserCi.setConditionValue(conditionExpression.split("=")[1]);
+								}
+								flowTaskUserCi.setToName(name);
+								flowTaskUserCi.setToTaskId(taskId);
+								flowTaskUserCi.setToTaskName(flowTaskUserCi.getTaskName());
+								taskList.add(flowTaskUserCi);
+							}
+						}
+					}
 				}
 			}
-
-
 		}
+		return flowTaskDTO;
 	}
 }

--
Gitblit v1.9.3