From a5f944c2bc0107e5df936937f1c33e5e03eb8fed Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期六, 06 九月 2025 19:15:48 +0800
Subject: [PATCH] 解锁增加解锁原因和展示

---
 blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/execute/TryFlowCompleteService.java |   91 +++++++++++++++++++++++++--------------------
 1 files changed, 50 insertions(+), 41 deletions(-)

diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/execute/TryFlowCompleteService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/execute/TryFlowCompleteService.java
index da3e7e0..3ff7c54 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/execute/TryFlowCompleteService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/service/execute/TryFlowCompleteService.java
@@ -8,13 +8,15 @@
 import org.springblade.core.tool.support.Kv;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringUtil;
+import org.springblade.mdm.basesetting.machine.entity.Machine;
+import org.springblade.mdm.basesetting.machine.service.MachineService;
+import org.springblade.mdm.commons.service.ParamService;
+import org.springblade.mdm.commons.service.UserCommonService;
 import org.springblade.mdm.flow.constants.FlowContants;
+import org.springblade.mdm.flow.constants.FlowVariableContants;
 import org.springblade.mdm.flow.service.FlowCommonService;
 import org.springblade.mdm.flow.service.FlowProgramFileService;
 import org.springblade.mdm.flow.service.FlowProgramProperties;
-import org.springblade.mdm.program.entity.NcNode;
-import org.springblade.mdm.program.service.NcNodeAutoCreateService;
-import org.springblade.mdm.program.service.NcNodeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -28,12 +30,15 @@
 public class TryFlowCompleteService extends AbstractFlowCompleteService {
 	@Autowired
 	private FlowProgramFileService flowProgramFileService;
+
 	@Autowired
-	private NcNodeService ncNodeService;
-	@Autowired
-	private NcNodeAutoCreateService ncNodeAutoCreateService;
+	private ParamService paramService;
 	@Autowired
 	private FlowCommonService flowCommonService;
+	@Autowired
+	private UserCommonService userCommonService;
+	@Autowired
+	private MachineService machineService;
 
 	@Transactional
 	@Override
@@ -41,59 +46,63 @@
 		Task task = currentTask(taskId);
 		String operateResult = this.getApproveResult(variables);
 
-		if(task.getTaskDefinitionKey().equals("programmingTask")) {//缂栧埗鑺傜偣
-			flowProgramFileService.checkProgramFiles(processInstanceId,FlowContants.Y.equals(operateResult));
+		FlowProgramProperties props = flowCommonService.getProgramProperties(processInstanceId);
+		if(!variables.containsKey("assignee")) {
+			throw new ServiceException("璇锋寚瀹氭祦绋嬩笅涓�姝ュ鐞嗕汉");
 		}
-		if (StringUtil.isNoneBlank(processInstanceId, comment)) {
-			taskService.addComment(taskId, processInstanceId, comment);
-		}
+
 		// 闈炵┖鍒ゆ柇
 		if (Func.isEmpty(variables)) {
 			variables = Kv.create();
 		}
-		variables.put(FlowContants.LAST_STEP_USER_NICKNAME, AuthUtil.getNickName());
 
-		if(!variables.containsKey("assignee")) {
-			throw new ServiceException("璇锋寚瀹氭祦绋嬩笅涓�姝ュ鐞嗕汉");
-		}
-		addApproveRecord(taskId,comment,variables);
+		if(task.getTaskDefinitionKey().equals("programmingTask") ) {//缂栧埗鑺傜偣
+			//璁板綍瀹為檯缂栫▼鍛�
+			variables.put(FlowVariableContants.ACT_PROGRAMMER,Func.toStr(AuthUtil.getUserId()));
 
-		//鍦ㄧ紪鍒朵换鍔℃椂锛屽垱寤鸿妭鐐癸紙娌℃湁鑺傜偣鍒欏垱寤猴紝鏈夊氨鐩存帴浣跨敤
-		/*
-		if(task.getTaskDefinitionKey().equals("programmingTask") && FlowContants.Y.equals(operateResult)) {
-			FlowProgramProperties progProperties = flowCommonService.getProgramProperties(processInstanceId);
-			ncNodeAutoCreateService.createNodeTreeWithProgram(progProperties);
-			//鍘熸潵鐗堟鐨勭▼搴忥紝姝ゆ椂搴旇娓呴櫎锛屾槸涓嶆槸瑕佹尓杩囨潵鍛紵鐗堟宸茬粡涓嶅浜�
-			//TODO 鑰佽妭鐐规竻闄ゅ悧
-
-			//璧板埌缂栧埗鑺傜偣锛屽鏋滄槸鏈夊浐鍖栫▼搴忎笖閫氳繃浜嗭紝璇存槑闇�瑕佸崌鐗堬紙閲嶆柊缂栧啓锛夛紝灏嗗浐鍖栫殑鍘熸潵鐨勭▼搴忚缃甽astEdition=0
-			if(FlowContants.Y.equals(progProperties.getHasCuredProgram())) {
-				NcNode curedProgramPackage = ncNodeService.getById(Func.toLong(progProperties.getCuredNodeId()));
-				curedProgramPackage.setIsLastEdition(0);
-				curedProgramPackage.setIsLocked(1);
-				ncNodeService.updateById(curedProgramPackage);
+			if(this.needUploadProgramFile(props.getMachineCode())) {
+				flowProgramFileService.checkProgramFiles(processInstanceId, FlowContants.Y.equals(operateResult));
+			}
+		}else if(task.getTaskDefinitionKey().equals("teamLeaderTask")){
+			if(FlowContants.Y.equals(operateResult)) {
+				runtimeService.setVariable(task.getExecutionId(),FlowContants.PROGRAMMER_NAME,userCommonService.getUserNameById(Func.toLong(variables.get("assignee"))));
 			}
 
-		}*/
-		if(task.getTaskDefinitionKey().equals("approveTask") && FlowContants.Y.equals(operateResult)) {
-			//璇曞垏娴佺▼锛屾垨鑰� 鍋忕娴佺▼ 楂樺笀閫氳繃鐨勬椂鍊欏垱寤鸿妭鐐�
-			//createProgramNodes(processInstanceId);
 		}
+		if (StringUtil.isNoneBlank(processInstanceId, comment)) {
+			taskService.addComment(taskId, processInstanceId, comment);
+		}
+
+		variables.put(FlowContants.LAST_STEP_USER_NICKNAME, AuthUtil.getNickName());
+
+
+		addApproveRecord(taskId,comment,variables);
+
 		variables.remove(FlowContants.PROCESS_EDITION);//涓嶈鍗囩増浜�
-		//if(!"confirmIsUseableTask".equals(task.getTaskDefinitionKey())){
+
 		if("confirmIsUseableTask".equals(task.getTaskDefinitionKey())){
-			//宸ュ簭鐗堟涓嶄竴鑷达紝骞朵笖瀹℃牳閫氳繃锛堝彲鐢級鏄紝鎵嶆洿鏂颁负鏂扮殑versionNumber
-			FlowProgramProperties progProperties = flowCommonService.getProgramProperties(processInstanceId);
 			variables.put(FlowContants.CURE_PROGRAM_USEABLE,operateResult);
 
-			if(FlowContants.Y.equals(operateResult) && FlowContants.N.equals(progProperties.getIsProcessEditionSame())) {
-				//纭绋嬪簭鍙敤 涓� 宸ュ簭鐗堟涓嶄竴鑷达紝杩涘叆鏍″銆傝繖閲岄渶瑕佸崌绾х▼搴忕殑鐗堟湰鍙�
-				Long curedNodeId = progProperties.getCuredNodeId();
-				ncNodeService.upgradeVersionNumber(curedNodeId);
+			if(FlowContants.Y.equals(operateResult)) {
+				//鍒ゅ畾鍙敤锛岃褰曚负瀹為檯缂栫▼鍛�
+				variables.put(FlowVariableContants.ACT_PROGRAMMER,Func.toStr(AuthUtil.getUserId()));
 			}
 		}
 		taskService.complete(taskId, variables);
 	}
 
 
+	/**
+	 * 鏄惁闇�瑕佷笂浼犳枃浠讹紙杞﹀簥涓嶉渶瑕侊級
+	 * @param machineCode 鏈哄簥缂栫爜
+	 * @return 鏄惁闇�瑕佷笂浼�
+	 */
+	boolean needUploadProgramFile(String machineCode){
+		boolean need;
+		Machine machine = machineService.getByCode(machineCode);
+		String turning = paramService.turninngValue();
+		need = !StringUtils.equals(turning,machine.getMachineSpec());
+		return need;
+	}
+
 }

--
Gitblit v1.9.3