From bc4056543fdbef38ac8bf1648df934d5bc8e5bde Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期四, 07 八月 2025 01:31:11 +0800
Subject: [PATCH] 调试固化流程
---
blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/controller/DispatchController.java | 70 +++++++++++++++++++++++++++--------
1 files changed, 54 insertions(+), 16 deletions(-)
diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/controller/DispatchController.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/controller/DispatchController.java
index c07110f..b496b9c 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/controller/DispatchController.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/controller/DispatchController.java
@@ -9,6 +9,7 @@
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
+import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
@@ -21,8 +22,13 @@
import org.springblade.mdm.flow.excution.StartDispatcher;
import org.springblade.mdm.flow.service.ApproveRecordService;
import org.springblade.mdm.flow.service.FlowCommonService;
+import org.springblade.mdm.flow.service.FlowProgramFileService;
+import org.springblade.mdm.flow.service.execute.AbstractFlowCompleteService;
+import org.springblade.mdm.flow.service.execute.DefaultFlowCompleteService;
+import org.springblade.mdm.flow.service.execute.TryFlowCompleteService;
import org.springblade.mdm.flow.vo.TaskAssignVO;
import org.springblade.mdm.program.entity.ProcessProgRef;
+import org.springblade.mdm.program.service.NcNodeAutoCreateService;
import org.springblade.mdm.program.service.ProcessProgRefService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@@ -47,10 +53,14 @@
private final RuntimeService runtimeService;
private final ProcessProgRefService processProgRefService;
- private ApproveRecordService approveRecordService;
- private final FlowCommonService flowCommonService;
+ private final ApproveRecordService approveRecordService;
+ private final FlowProgramFileService flowProgramFileService;
+
+
+ private final TryFlowCompleteService tryFlowCompleteService;
+ private final DefaultFlowCompleteService defaultFlowCompleteService;
/**
- * 鏂板
+ * 鍙戣捣娲惧伐娴佺▼
*/
@PostMapping("/start")
@Operation(summary = "浠诲姟璁″垝(娲惧伐娴佺▼)", description = "鍚姩娲惧伐娴佺▼")
@@ -59,9 +69,32 @@
return R.status(true);
}
+ AbstractFlowCompleteService getActualService(String processInstanceId){
+ ProcessInstance inst = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+ if(inst.getProcessDefinitionKey().equals(FlowContants.TRY_PROCESS_KEY) || inst.getProcessDefinitionKey().equals(FlowContants.CURE_PROCESS_KEY)){
+ return tryFlowCompleteService;
+ }else{
+ return defaultFlowCompleteService;
+ }
+ }
@Operation(summary = "瀹屾垚浠诲姟", description = "娴佸悜涓嬩竴涓妭鐐�")
@PostMapping("completeTask")
public R<Void> completeTask(String taskId, String processInstanceId, String comment,@Parameter(name = "variables", description = "浠诲姟鍙橀噺") @RequestBody Map<String, Object> variables) {
+ try {
+ AbstractFlowCompleteService completeService = getActualService(processInstanceId);
+ completeService.completeTask(taskId, processInstanceId, comment, variables);
+ return R.success("娴佺▼鎻愪氦鎴愬姛");
+ }catch(Exception e){
+ return R.fail(e.getMessage());
+ }
+ /*
+ Task task = taskService.createTaskQuery()
+ .taskId(taskId)
+ .singleResult();
+ String operateResult = variables.get("approve")+"";
+ if(task.getTaskDefinitionKey().equals("programmingTask")) {//缂栧埗鑺傜偣
+ flowProgramFileService.checkProgramFiles(processInstanceId,"Y".equals(operateResult));
+ }
// 澧炲姞璇勮
if (StringUtil.isNoneBlank(processInstanceId, comment)) {
taskService.addComment(taskId, processInstanceId, comment);
@@ -70,21 +103,25 @@
if (Func.isEmpty(variables)) {
variables = Kv.create();
}
- String programIds = null;
- if(variables.containsKey(FlowContants.PROGRAM_IDS_KEY)){
- programIds = variables.get("programIds").toString();
- runtimeService.setVariable(taskId, FlowContants.PROGRAM_IDS_KEY, programIds);
- }
- if(StringUtils.isNotEmpty(programIds)) {
- processProgRefService.addRelations(processInstanceId,Func.toLongList(programIds));
- }
//鍔犲叆瀹℃壒鐢ㄦ埛
- variables.put("approveUserNickName",AuthUtil.getNickName());
+ variables.put(FlowContants.LAST_STEP_USER_NICKNAME,AuthUtil.getNickName());
if(variables.containsKey("assignee")){
+ addApproveRecord(taskId,comment,variables);
- addApproveRecord(taskId,processInstanceId,comment,variables);
+ //鍦ㄧ紪鍒朵换鍔℃椂锛屽垱寤鸿妭鐐癸紙娌℃湁鑺傜偣鍒欏垱寤猴紝鏈夊氨鐩存帴浣跨敤
+ if(task.getTaskDefinitionKey().equals("programmingTask") && "Y".equals(operateResult)) {
+ ncNodeAutoCreateService.createNodeTreeWithProgram(flowCommonService.getProgramProperties(processInstanceId));
+ }
+ if(!"confirmIsUseableTask".equals(task.getTaskDefinitionKey())){
+
+ variables.remove(FlowContants.PROCESS_EDITION);//TODO 涓存椂閿欒鏄紝缁勯暱鎻愪氦鐨勬椂鍊欎細鎻愪氦涓�涓┖涓诧紝娓呯┖浜嗗唴閮ㄦ暟鎹�
+ }else{
+ //鍗囩増
+
+ }
+
//鎸囧畾浜嗕笅涓�姝ユ墽琛屼汉
taskService.complete(taskId, variables);
@@ -92,17 +129,18 @@
}else {
// 瀹屾垚浠诲姟,缁欓粯璁ょ敤鎴�
return R.fail("璇锋寚瀹氭祦绋嬩笅涓�姝ュ鐞嗕汉");
- }
+ }*/
+
}
- void addApproveRecord(String taskId, String processInstanceId, String comment,Map<String, Object> variables){
+ void addApproveRecord(String taskId,String comment,Map<String, Object> variables){
String operateResult = variables.get("approve")+"";
Task task = taskService.createTaskQuery()
.taskId(taskId)
.singleResult();
- approveRecordService.saveApproveRecords(task,processInstanceId,operateResult,comment);
+ approveRecordService.saveApproveRecords(task,operateResult,comment);
}
}
--
Gitblit v1.9.3