修改xispeak流程模块,配置文件,配置类以及流程表达式,适配前端选择sdw领导用于后续的审批

This commit is contained in:
wsm
2026-05-19 16:38:41 +08:00
parent 4c1c4ec50c
commit ce4d51345b
3 changed files with 62 additions and 2 deletions
@@ -41,5 +41,6 @@ public class XiSpeakConfig {
private String temImplWorkerKey;
private String temImplLeaderKey;
private String temBgLeaderKey;
private String sdwLeaderListKey;
}
}
@@ -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<String> 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<String> 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<String> 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)}
*/