diff --git a/jeecg-boot-module/jeecg-module-flow/src/main/java/org/jeecg/xispeak/XiSpeakConfig.java b/jeecg-boot-module/jeecg-module-flow/src/main/java/org/jeecg/xispeak/XiSpeakConfig.java index e6c7a3d..c69c064 100644 --- a/jeecg-boot-module/jeecg-module-flow/src/main/java/org/jeecg/xispeak/XiSpeakConfig.java +++ b/jeecg-boot-module/jeecg-module-flow/src/main/java/org/jeecg/xispeak/XiSpeakConfig.java @@ -41,5 +41,6 @@ public class XiSpeakConfig { private String temImplWorkerKey; private String temImplLeaderKey; private String temBgLeaderKey; + private String sdwLeaderListKey; } } diff --git a/jeecg-boot-module/jeecg-module-flow/src/main/java/org/jeecg/xispeak/XiSpeakFlow.java b/jeecg-boot-module/jeecg-module-flow/src/main/java/org/jeecg/xispeak/XiSpeakFlow.java index 5f282d1..d0f9857 100644 --- a/jeecg-boot-module/jeecg-module-flow/src/main/java/org/jeecg/xispeak/XiSpeakFlow.java +++ b/jeecg-boot-module/jeecg-module-flow/src/main/java/org/jeecg/xispeak/XiSpeakFlow.java @@ -61,8 +61,8 @@ public class XiSpeakFlow { return userList; } - public int getSDWLeaderLength() { - return this.getSDWLeader().size(); + public int getSDWLeaderLength(Object jsonData) { + return this.getSdwLeaderList(jsonData).size(); } //流程表达式内用法 ${xiSpeakFlow.getBgDeptLdUserIdListLength()} @@ -108,6 +108,53 @@ public class XiSpeakFlow { } } + private List getListCodeValueFromData(Object jsonData, String codeName, String logLabel) { + // 1. 基础校验:如果入参为空或配置的 Key 为空,直接返回空列表 + if (jsonData == null || org.apache.commons.lang.StringUtils.isBlank(codeName)) { + return Collections.emptyList(); + } + + try { + JSONObject data; + // 2. 统一转换为 JSONObject + if (jsonData instanceof JSONObject) { + data = (JSONObject) jsonData; + } else if (jsonData instanceof String) { + String jsonStr = (String) jsonData; + if (org.apache.commons.lang.StringUtils.isBlank(jsonStr)) { + return Collections.emptyList(); + } + data = JSONObject.parseObject(jsonStr); + } else { + // 处理普通 POJO 对象 + data = JSONObject.parseObject(JSONObject.toJSONString(jsonData)); + } + + // 3. 提取目标字段的字符串值 + String rawValue = data.getString(codeName); + + // 4. 转换逗号分隔的字符串为 List + List resultList; + if (org.apache.commons.lang.StringUtils.isBlank(rawValue)) { + resultList = Collections.emptyList(); + } else { + // 使用逗号分割,并过滤掉每个元素前后的空格 + resultList = Arrays.stream(rawValue.split(",")) + .map(String::trim) + .filter(org.apache.commons.lang.StringUtils::isNotBlank) // 过滤掉因连续逗号产生的空元素 + .collect(Collectors.toList()); + } + + log.info("{} 业务解析结果: {}", logLabel, resultList); + return resultList; + + } catch (Exception e) { + log.warn("JSON解析失败: 业务={}, codeKey={}, 数据={}", logLabel, codeName, jsonData, e); + // 异常情况下返回空列表,确保调用方不崩溃 + return Collections.emptyList(); + } + } + // --- 调用处 --- //流程表达式内用法${xiSpeakFlow.getNeedSdwApproval(jsonData)} @@ -122,6 +169,17 @@ public class XiSpeakFlow { return getCodeValueFromData(jsonData, codeName, "立即反馈"); } + //流程表达式内用法${xiSpeakFlow.getSdwLeaderList(json_data)} + public List getSdwLeaderList(Object jsonData) { + String codeName = xiSpeakConfig.getXiSpeak().getSdwLeaderListKey(); + return getListCodeValueFromData(jsonData, codeName, "立即反馈"); + } + + //流程表达式内用法${xiSpeakFlow.getSdwLeaderListLength(json_data)} + public int getSdwLeaderListLength(Object jsonData) { + return this.getSdwLeaderList(jsonData).size(); + } + /** * 流程表达式内用法: ${xiSpeakFlow.getTemImplWorkerList(execution)} */ diff --git a/jeecg-boot-module/jeecg-module-flow/src/main/resources/application-flow.yml b/jeecg-boot-module/jeecg-module-flow/src/main/resources/application-flow.yml index 8ef4c06..3430518 100644 --- a/jeecg-boot-module/jeecg-module-flow/src/main/resources/application-flow.yml +++ b/jeecg-boot-module/jeecg-module-flow/src/main/resources/application-flow.yml @@ -16,6 +16,7 @@ flow-biz: tem-impl-worker-key: "tem_impl_worker" tem-impl-leader-key: "tem_impl_leader" tem-bg-leader-key: "tem_bg_leader" + sdw-leader-list-key: "sdwLeaderList" xi-speak-fb: dept-id: "x" business-id: "business_id"