Bläddra i källkod

修复文章流程发布与变动发版链路

修正文章流程树仅显示启用中的子流程,并恢复流程条件按钮在默认流程/子流程场景下的正确显示。\n发布流程时补充错误日志与前端失败提示,便于直接看到真实报错。\n生成 jpdl 发布文件前兼容旧运行时不支持的结束节点消息字段,并优先沿用上一版已发布流程的 process name,确保 articleRelease 与 articleChange 的新版本可继续部署。\n\nValidation:\n- 本地后台验证 文章 > 流程 > 发布:版本号从 54 升到 55\n- 本地后台验证 文章 > 流程 > 变动:版本号从 8 升到 9\n- 校验发布产物 process name 分别为 1-10004-发布 / 1-10004-变动
非繁 5 månader sedan
förälder
incheckning
1eed5e6d29

+ 2 - 4
WebRoot/main/subassembly/js/flow/flowEdit.js

@@ -504,12 +504,10 @@ space.vue = new Vue({
 				},
 				dataType: 'json',
 				callback: function(data) {
-					if (data.code == 'success') {
-						space.message.success(data.msg);
-					}
+					space.message.auto(data);
 				}
 			})
 			
 		}
 	}
-})
+})

+ 94 - 3
src/space/apps/moudules/basic/services/FlowService.java

@@ -2,6 +2,8 @@ package space.apps.moudules.basic.services;
 
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -76,7 +78,7 @@ public class FlowService extends BaseTransaction {
 		String sql = "select lc.lcid, lc.mkid, lc.lclbid, lc.lclxm, lc.sfmrlc, lc.sjlcid, lc.mc, lc.ms, "
 				+ "lc.`key`, lc.wjml, lc.bbh, lc.plbl, lc.plblmc, lc.lctb, lc.kfzid, lc.jlztm, "
 				+ "lc.lcbh, lc.hslc, lc.xh, lc.cjsj, lc.xgsj "
-				+ "from bpm_lc lc where lc.sjlcid = :sjlcid and lc.mkid = :mkid "
+				+ "from bpm_lc lc where lc.sjlcid = :sjlcid and lc.mkid = :mkid and lc.jlztm = 21 "
 				+ "order by lc.sfmrlc asc, lc.xh asc, lc.lcid asc ";
 		SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
 		sqlCmd.setString("sjlcid", lcid).setString("mkid", mkid);
@@ -135,7 +137,8 @@ public class FlowService extends BaseTransaction {
 			rp.setRequestAttribute("flowName", bpmLcMap.get("lcmc"));
 			rp.setRequestAttribute("mkid", mkid);
 			rp.setRequestAttribute("flowId", flowId);
-			rp.setRequestAttribute("flowConditionAttr", !flag);
+			rp.setRequestAttribute("flowConditionAttr",
+					StringUtil.notNull(bpmLc.getSjlcid()) && !ConstVars.SYF_YES.equals(bpmLc.getSfmrlc()));
 			
 			setResponsePackage(rp);
 			
@@ -399,7 +402,7 @@ public class FlowService extends BaseTransaction {
 			
 			setResponsePackage(getResponseSuccessMsgPackage("发布成功"));
 		} catch (Exception e) {
-			e.printStackTrace();
+			log.error("发布流程版本失败", e);
 			setResponsePackage(getResponseErrorMsgPackage("发布失败:" + e.getMessage()));
 		}
 	}
@@ -418,12 +421,100 @@ public class FlowService extends BaseTransaction {
 	void writeJpdlFile(CoreMk mk, BpmLc bigBpmLc, BpmLc bpmLc, BpmLctfbjl bpmLctfbjl, String jsonFilePath) throws Exception {
 		// 获取 bpm 文件里所有都内容转 list 
 		List<Map<String, List<Map<String, Object>>>> nodeReferDataList = GooFlowUtil.getBpmXmlFileAllContentToList(getBPMXmlFilePath(bigBpmLc.getWjml(), bigBpmLc.getKey()));
+		// 兼容当前运行时的 SpaceCore-1.0.7.5。
+		// 该运行时中的 EndListener 仍不支持结束节点的 messageType / messageServiceName 字段注入,
+		// 如果把新版参考配置直接写进 jpdl,jbpm deploy 会失败,进而导致发布记录事务被回滚。
+		// 因此这里在生成发布版 jpdl 前,先将结束节点的消息配置剔除,保持与当前线上可运行的历史流程结构一致。
+		stripUnsupportedEndNodeMessageConfig(nodeReferDataList);
 		String jpdlXmlContent = JpdlXmlUtil.createJpdlXmlContent(mk, FileUtil.readFile(jsonFilePath), nodeReferDataList, bpmLc.getLcid(), bigBpmLc.getMc(), bigBpmLc.getKey());
+		jpdlXmlContent = alignProcessNameWithReleasedVersion(getGdbaInstance(DBNameVars.BASE), mk.getMkid(), bigBpmLc, bpmLc, jpdlXmlContent);
 		
 		FileUtil.writeFile(jpdlXmlContent, getWebRootPath() + bpmLctfbjl.getJpdlWjlj());
 		FileUtil.copyFile(jsonFilePath, getWebRootPath() + bpmLctfbjl.getJsonWjlj());
 		
 	}
+
+	String alignProcessNameWithReleasedVersion(GeneralDBAccess baseGdba, Long mkid, BpmLc bigBpmLc, BpmLc bpmLc, String jpdlXmlContent) throws Exception {
+		String targetProcessName = getReleasedProcessName(baseGdba, mkid, bpmLc.getLcid());
+		if (StringUtil.isNull(targetProcessName)) {
+			Long lclbid = StringUtil.notNull(bigBpmLc.getLclbid()) ? bigBpmLc.getLclbid() : bpmLc.getLclbid();
+			targetProcessName = mkid + "-" + lclbid + "-" + bpmLc.getMc();
+		}
+		
+		if (StringUtil.isNull(targetProcessName)) {
+			return jpdlXmlContent;
+		}
+		
+		return jpdlXmlContent.replaceFirst("(<process\\s+name=\")[^\"]+(\")",
+				"$1" + Matcher.quoteReplacement(targetProcessName) + "$2");
+	}
+
+	String getReleasedProcessName(GeneralDBAccess baseGdba, Long mkid, Long lcid) throws Exception {
+		String releasedJpdlPath = getLatestReleasedJpdlPath(baseGdba, mkid, lcid);
+		if (StringUtil.isNull(releasedJpdlPath)) {
+			return null;
+		}
+		
+		String resolvedPath = getResolvedFlowFilePath(releasedJpdlPath);
+		if (!FileUtil.fileExist(resolvedPath)) {
+			return null;
+		}
+		
+		String processName = extractProcessName(FileUtil.readFile(resolvedPath));
+		return StringUtil.notNull(processName) ? processName : null;
+	}
+
+	String getLatestReleasedJpdlPath(GeneralDBAccess baseGdba, Long mkid, Long lcid) throws Exception {
+		String sql = "select fbjl.jpdl_wjlj from bpm_lctfbjl fbjl where fbjl.mkid = :mkid and fbjl.lcid = :lcid order by fbjl.bbh desc limit 1 ";
+		SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
+		sqlCmd.setInt("mkid", mkid);
+		sqlCmd.setInt("lcid", lcid);
+		
+		Map<String, Object> releaseMap = baseGdba.selectAsMap(sqlCmd);
+		if (StringUtil.isNull(releaseMap)) {
+			return null;
+		}
+		
+		Object jpdlWjlj = releaseMap.get("jpdl_wjlj");
+		return StringUtil.notNull(jpdlWjlj) ? jpdlWjlj.toString() : null;
+	}
+
+	String extractProcessName(String jpdlXmlContent) {
+		if (StringUtil.isNull(jpdlXmlContent)) {
+			return null;
+		}
+		
+		java.util.regex.Matcher matcher = Pattern.compile("<process\\s+name=\"([^\"]+)\"").matcher(jpdlXmlContent);
+		return matcher.find() ? matcher.group(1) : null;
+	}
+
+	@SuppressWarnings("unchecked")
+	void stripUnsupportedEndNodeMessageConfig(List<Map<String, List<Map<String, Object>>>> nodeReferDataList) {
+		if (StringUtil.isNull(nodeReferDataList) || nodeReferDataList.isEmpty()) {
+			return;
+		}
+		
+		for (Map<String, List<Map<String, Object>>> flowNodeMap : nodeReferDataList) {
+			if (flowNodeMap == null || !flowNodeMap.containsKey("end")) {
+				continue;
+			}
+			
+			List<Map<String, Object>> endNodeList = flowNodeMap.get("end");
+			if (StringUtil.isNull(endNodeList)) {
+				continue;
+			}
+			
+			for (Map<String, Object> endNode : endNodeList) {
+				if (endNode == null) {
+					continue;
+				}
+				endNode.remove("messageType");
+				endNode.remove("messageService_service");
+				endNode.remove("messageService_name");
+				endNode.remove("messageService_destination");
+			}
+		}
+	}
 	
 	/**
 	 * 新增 BPM 流程图发布记录