!36 feat(inspectcloseout): 新增 getJWSJUser 纪委书记用户查询方法,完善空值与多用户校验

* feat(inspectcloseout): 新增 getJWSJUser 纪委书记用户查询方法,完善空值与多用户校验
* feat(inspectcloseout): 新增 InspectCloseoutConstant 常量文件,补全 InspectClose…
* fix(inspectimprove): 修复 getMeasureResLeader 方法体为正确返回措施责任领导,新增 AfterMea…
* fix(dqinspecttask): DqInspectProgress 逻辑删除字段 delFlag 添加默认值 0
This commit is contained in:
new_new_new
2026-06-09 00:25:44 +00:00
parent 751254e7ac
commit 16c0342dcd
5 changed files with 168 additions and 4 deletions
@@ -0,0 +1,10 @@
package org.jeecg.inspectcloseout;
public class InspectCloseoutConstant {
public static final String JJ_DEPT_ID = "2054466800692432898";
public static final String JJ_DEPT_LEADER_ROLE_ID = "2044680793306591234";
public static final String JJ_DEPT_WORKER_ROLE_ID = "2047511967494213633";
public static final String SLD_DEPT_ID = "2044677562460508161";
public static final String SLD_JWSJ_ROLE_ID = "2063902766943363073";
public static final int ZERO_INDEX = 0;
}
@@ -1,12 +1,16 @@
package org.jeecg.inspectcloseout;
import com.alibaba.fastjson.JSONObject;
import com.jeecg.weibo.exception.BusinessException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.system.api.ISysBaseAPI;
import org.jeecg.inspectimprove.InspectImproveConfig;
import org.jeecg.modules.extbpm.process.common.expression.FlowNodeExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
@@ -18,6 +22,7 @@ public class InspectCloseoutFlow {
private final InspectCloseoutConfig inspectCloseoutConfig;
private final FlowNodeExpression flowNodeExpression;
private final ISysBaseAPI iSysBaseAPI;
// ===================================================================
// 通用工具方法
@@ -47,8 +52,77 @@ public class InspectCloseoutFlow {
}
}
//流程表达式内用法 ${inspectImproveFlow.getJJDeptLdUserIdList()}
public List<String> getJJDeptLdUserIdList() {
log.info("【巡视整改销号-流程表达式】查询部门角色用户列表, deptId: {}, roleId: {}", InspectCloseoutConstant.JJ_DEPT_ID, InspectCloseoutConstant.JJ_DEPT_LEADER_ROLE_ID);
List<String> userList = iSysBaseAPI.getUsersListByDeptIdAndRoleIdLocalApi(
InspectCloseoutConstant.JJ_DEPT_ID,
InspectCloseoutConstant.JJ_DEPT_LEADER_ROLE_ID
);
log.info("【巡视整改销号-流程表达式】查询到用户列表, userList: {}", userList);
return userList;
}
//流程表达式内用法 ${inspectCloseoutFlow.getJJDeptLdUserIdListLength()}
public int getJJDeptLdUserIdListLength() {
List<String> jjDeptLdUserIdList = this.getJJDeptLdUserIdList();
if (jjDeptLdUserIdList != null && !jjDeptLdUserIdList.isEmpty()) {
return jjDeptLdUserIdList.size();
}
log.error("【巡视整改销号-流程表达式】JJ部门LD角色没有对应用户");
return 0;
}
//流程表达式内用法 ${inspectCloseoutFlow.getJJDeptLdWorkerIdList()}
public List<String> getJJDeptLdWorkerIdList() {
log.info("【巡视整改销号-流程表达式】查询部门角色用户列表, deptId: {}, roleId: {}", InspectCloseoutConstant.JJ_DEPT_ID, InspectCloseoutConstant.JJ_DEPT_LEADER_ROLE_ID);
List<String> userList = iSysBaseAPI.getUsersListByDeptIdAndRoleIdLocalApi(
InspectCloseoutConstant.JJ_DEPT_ID,
InspectCloseoutConstant.JJ_DEPT_WORKER_ROLE_ID
);
log.info("【巡视整改销号-流程表达式】查询到用户列表, userList: {}", userList);
return userList;
}
//流程表达式内用法 ${inspectCloseoutFlow.getJWSJUser()}
public String getJWSJUser() {
String deptId = InspectCloseoutConstant.SLD_DEPT_ID;
String roleId = InspectCloseoutConstant.SLD_JWSJ_ROLE_ID;
log.info("【巡视整改销号-流程表达式】查询纪委书记用户, deptId: {}, roleId: {}", deptId, roleId);
List<String> userList = iSysBaseAPI.getUsersListByDeptIdAndRoleIdLocalApi(deptId, roleId);
if (CollectionUtils.isEmpty(userList)) {
log.error("【巡视整改销号-流程表达式】未查询到纪委书记用户, deptId: {}, roleId: {}", deptId, roleId);
throw new BusinessException("流程流转失败:未配置纪委书记用户,请联系管理员!");
}
if (userList.size() > 1) {
log.error("【巡视整改销号-流程表达式】查询到多个纪委书记用户, 数量: {}, 用户列表: {}", userList.size(), userList);
throw new BusinessException("流程流转失败:存在多个纪委书记用户,数据不唯一,请检查角色配置!");
}
String targetUser = userList.get(InspectCloseoutConstant.ZERO_INDEX);
log.info("【巡视整改销号-流程表达式】匹配到纪委书记用户: {}", targetUser);
return targetUser;
}
//流程表达式内用法 ${inspectCloseoutFlow.getJJDeptLdWorkerIdListLength()}
public int getJJDeptLdWorkerIdListLength() {
List<String> jjDeptLdUserIdList = this.getJJDeptLdUserIdList();
if (jjDeptLdUserIdList != null && !jjDeptLdUserIdList.isEmpty()) {
return jjDeptLdUserIdList.size();
}
log.error("【巡视整改销号-流程表达式】JJ部门WORKER角色没有对应用户");
return 0;
}
private List<String> getListFromData(Object jsonData, String codeName, String logLabel) {
if (jsonData == null || StringUtils.isBlank(codeName)) {
log.warn("【巡视整改销号-流程表达式】{}解析参数为空, codeName: {}", logLabel, codeName);
return Collections.emptyList();
}
try {
@@ -57,23 +131,27 @@ public class InspectCloseoutFlow {
data = (JSONObject) jsonData;
} else if (jsonData instanceof String) {
String jsonStr = (String) jsonData;
if (StringUtils.isBlank(jsonStr)) return Collections.emptyList();
if (StringUtils.isBlank(jsonStr)) {
log.warn("【巡视整改销号-流程表达式】{}JSON字符串为空", logLabel);
return Collections.emptyList();
}
data = JSONObject.parseObject(jsonStr);
} else {
data = JSONObject.parseObject(JSONObject.toJSONString(jsonData));
}
String rawValue = data.getString(codeName);
if (StringUtils.isBlank(rawValue)) {
log.warn("【巡视整改销号-流程表达式】{}字段值为空, codeName: {}", logLabel, codeName);
return Collections.emptyList();
}
List<String> result = Arrays.stream(rawValue.split(","))
.map(String::trim)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toList());
log.info("{} 解析结果: {}", logLabel, result);
log.info("【巡视整改销号-流程表达式】{}解析结果: {}", logLabel, result);
return result;
} catch (Exception e) {
log.warn("JSON解析失败: label={}, key={}", logLabel, codeName, e);
log.error("【巡视整改销号-流程表达式】{}JSON解析失败, codeName: {}", logLabel, codeName, e);
return Collections.emptyList();
}
}
@@ -111,6 +111,26 @@ public class InspectImproveFlow {
return InspectConstant.NEED_APPROVE_STR;
}
// 流程表达式内用法 ${inspectImproveFlow.getMeasureResLeader(execution)}
public String getMeasureResLeader(DelegateExecution execution) {
DqInspectTask temDqInspectTask = this.getDqInspectTask(execution);
if (temDqInspectTask == null) {
log.error("【巡视整改-流程表达式】获取措施责任领导时未找到业务表单数据, processInstanceId: {}", execution.getProcessInstanceId());
throw new IllegalStateException("无法获取措施责任领导:未找到对应的业务表单数据,流程暂停。");
}
String measureResLeader = temDqInspectTask.getMeasureResLeader();
if (StringUtils.isBlank(measureResLeader)) {
log.warn("【巡视整改-流程表达式】措施责任领导为空, businessKey: {}, processInstanceId: {}",
temDqInspectTask.getId(), execution.getProcessInstanceId());
return null;
}
log.info("【巡视整改-流程表达式】获取到措施责任领导: {}, businessKey: {}", measureResLeader, temDqInspectTask.getId());
return measureResLeader;
}
// 流程表达式内用法:${inspectImproveFlow.getImplDeptLeaderList(execution)}
public List<String> getImplDeptLeaderList(DelegateExecution execution) {
@@ -0,0 +1,56 @@
package org.jeecg.inspectimprove.listener;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;
import org.jeecg.inspectimprove.InspectImproveConfig;
import org.jeecg.modules.demo.dqinspecttask.entity.DqInspectTask;
import org.jeecg.modules.demo.dqinspecttask.service.IDqInspectTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 巡视整改-措施责任领导监听器:任务完成后将当前审批人写入 DqInspectTask.measureResLeader
*/
@Slf4j
@Component("AfterMeasureResLeaderStoreListener")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class AfterMeasureResLeaderStoreListener implements TaskListener {
private static final long serialVersionUID = 1L;
private final InspectImproveConfig inspectImproveConfig;
private final IDqInspectTaskService dqInspectTaskService;
@Override
public void notify(DelegateTask delegateTask) {
String assignee = delegateTask.getAssignee();
String taskId = delegateTask.getId();
if (StringUtils.isEmpty(assignee)) {
log.error("【巡视整改-措施责任领导存储监听器】未获取到审批人, taskId: {}", taskId);
return;
}
Object businessKeyObj = delegateTask.getVariable(inspectImproveConfig.getInspectImprove().getBusinessKey());
if (businessKeyObj == null || StringUtils.isBlank(businessKeyObj.toString())) {
log.error("【巡视整改-措施责任领导存储监听器】未获取到业务表单ID, taskId: {}", taskId);
return;
}
String businessKey = businessKeyObj.toString();
DqInspectTask task = dqInspectTaskService.getById(businessKey);
if (task == null) {
log.error("【巡视整改-措施责任领导存储监听器】未查询到业务表单记录, businessKey: {}", businessKey);
return;
}
task.setMeasureResLeader(assignee);
dqInspectTaskService.updateById(task);
log.info("【巡视整改-措施责任领导存储监听器】已将审批人 {} 写入 DqInspectTask.measureResLeader, businessKey: {}, taskId: {}",
assignee, businessKey, taskId);
}
}
@@ -84,7 +84,7 @@ public class DqInspectProgress implements Serializable {
@Excel(name = "删除标识", width = 15)
@Schema(description = "删除标识")
@TableLogic
private java.lang.String delFlag;
private java.lang.String delFlag = "0";
/**整改措施任务ID*/
@Schema(description = "整改措施任务ID")
private java.lang.String mainId;