P4前置: 闭环 flowable-service projectRoleType 候选人解析 + 长尾收敛
侦察老系统语义(以代码为准):projectRoleType 在 com.dsasp.server.wf CandidateUsersHandler 单独分派(非 organize 的 AssignmentHandlerImpl), 调客户私有 ProjectRoleUser.getUserByProjectRole(projectId, "八大员位枚举"); framework 无该实现(项目定制 OSGi 扩展点)。解析链经客户库数据模型反推 + 真实流程任务实证锁定:content 位序(1-based)即 pm_project_user.role。 实现: - OrgDirectoryJdbc.getUsersByProjectRole 去 WARN 降级,参数化直查 pm_project_user(pm_projectid + role IN(true 位序) + isactive=1), 保留 ProjectRoleResolver 钩子作客户私有覆盖位; - 顺带闭环长尾: initiatorDepartManager(view_sys_user.masterdepart 子查询 →sys_depart.leader)、fixedDimension(view_sys_dimensiondepart 维度树 向上回溯)、sameToTask(historyService 取前序 userTask assignee); - CandidateController 加 GET /project-role 对账端点。 验证(8089 起本地 eip4flow + 客户库只读):5 个真实 projectRoleType 任务 REST==手工 SQL(含数据漂移空例);initiatorDepartManager/fixedDimension 真实数据对账一致;P3 position/user 回归不破;新增 7 单测(原 26→33), 全反应堆 mvn test + ArchUnit 绿。 缺口:降级类型 5 类→1 类(仅 scriptUser 26 处),覆盖率 91%→99.46%。 scriptUser 需活的 ExecutionEntity + 反序列化变量,超独立服务边界,留方案。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,8 +5,12 @@ import java.util.List;
|
||||
|
||||
import org.codehaus.jackson.JsonNode;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.ProcessEngine;
|
||||
import org.flowable.engine.ProcessEngines;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.history.HistoricActivityInstance;
|
||||
import org.flowable.engine.history.HistoricActivityInstanceQuery;
|
||||
|
||||
import com.dsasp.server.wf.bean.BasePropertiesConverter;
|
||||
import com.dsasp.server.wf.bean.UserProperty;
|
||||
@@ -59,15 +63,24 @@ public class CandidateUsersHandler {
|
||||
if(userProperties != null){
|
||||
for(UserProperty userProperty : userProperties){
|
||||
List<String> users = null;
|
||||
if(WfTypes.SAMETOTASK.equals(userProperty.getType())
|
||||
|| WfTypes.BEFORETASKLEADER.equals(userProperty.getType())
|
||||
|| WfTypes.BEFORETASKDEPARTMANAGER.equals(userProperty.getType())){
|
||||
// 原版经 processCoreService.getSpecialActivityProcessor(前一活动处理者)解析;
|
||||
// 该解析依赖历史活动栈遍历(framework ProcessCoreServiceImpl),
|
||||
// 独立服务暂不接入(WARN 降级),报告登记。占比小(sameToTask 5 处)。
|
||||
System.out.println("[WARN] candidateUsersHandler: 类型 " + userProperty.getType()
|
||||
+ " 依赖前序活动处理者解析,独立服务暂未接入,跳过该项");
|
||||
if(WfTypes.SAMETOTASK.equals(userProperty.getType())){
|
||||
// 原版:processCoreService.getSpecialActivityProcessor(piId, content) 取前序 userTask 处理者。
|
||||
// P4 闭环:经 historyService 历史活动栈直查(content 为指定活动 id,空则取最近一个)。
|
||||
String user = getSpecialActivityProcessor(processInstanceId, userProperty.getContent());
|
||||
users = new ArrayList<String>();
|
||||
if(user != null){
|
||||
users.add(user);
|
||||
}
|
||||
}else if(WfTypes.BEFORETASKLEADER.equals(userProperty.getType())
|
||||
|| WfTypes.BEFORETASKDEPARTMANAGER.equals(userProperty.getType())){
|
||||
// 原版:先取前一活动处理者(getSpecialActivityProcessor(piId, null)),再经
|
||||
// assignmentUser(type, content, null, null, beforeUser) 求其直接领导/部门负责人。
|
||||
// P4 闭环:前序处理者经 historyService 取;领导/部门负责人经 OrgDirectory 直查
|
||||
// (beforeUser 作 initiatorId 入参,对齐原版第 5 形参的语义复用)。
|
||||
String beforeUser = getSpecialActivityProcessor(processInstanceId, null);
|
||||
String t = WfTypes.BEFORETASKLEADER.equals(userProperty.getType())
|
||||
? WfTypes.INITIATORLEADER : WfTypes.INITIATORDEPARTMANAGER;
|
||||
users = directory.assignmentUser(t, userProperty.getContent(), beforeUser, null);
|
||||
}else if(WfTypes.SCRIPTUSER.equals(userProperty.getType())){
|
||||
// 原版经 ScriptingEngines.evaluate(content,"juel",execution) 求值;
|
||||
// 独立服务不内置服务流脚本引擎(精简边界),WARN 降级,报告登记。
|
||||
@@ -135,6 +148,49 @@ public class CandidateUsersHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/** 取默认引擎的 HistoryService;无默认引擎(如单测)时返回 null。 */
|
||||
protected HistoryService resolveHistoryService() {
|
||||
try {
|
||||
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
|
||||
return engine != null ? engine.getHistoryService() : null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取前序活动处理者(sameToTask/beforeTask* 用)。
|
||||
*
|
||||
* <p>逐条对齐 framework {@code ProcessCoreServiceImpl.getSpecialActivityProcessor}:
|
||||
* 取流程实例下已结束 userTask 活动、按结束时间倒序的第一条的 assignee;
|
||||
* 指定 activityId(content)时只在该活动内取。framework 的 UserSession 兜底
|
||||
* (取当前登录人)在独立服务无会话上下文,省略(返回 null,候选项为空)。</p>
|
||||
*/
|
||||
protected String getSpecialActivityProcessor(String processInstanceId, String activityId) {
|
||||
HistoryService historyService = resolveHistoryService();
|
||||
if (historyService == null || processInstanceId == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
|
||||
.activityType("userTask")
|
||||
.processInstanceId(processInstanceId)
|
||||
.finished()
|
||||
.orderByHistoricActivityInstanceEndTime().desc();
|
||||
if (!isEmpty(activityId)) {
|
||||
query.activityId(activityId);
|
||||
}
|
||||
List<HistoricActivityInstance> list = query.list();
|
||||
if (list != null && !list.isEmpty()) {
|
||||
return list.get(0).getAssignee();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 历史服务异常不阻断候选人解析(与原版 null 兜底同口径)
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Object getVariable(RuntimeService runtimeService, String processInstanceId, String name) {
|
||||
if (runtimeService == null || processInstanceId == null) {
|
||||
return null;
|
||||
|
||||
@@ -68,6 +68,12 @@ public class CandidateController {
|
||||
return org != null ? ResponseEntity.ok(org) : ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
@GetMapping("/project-role")
|
||||
@Operation(summary = "projectRoleType 解析", description = "projectId+八大员位枚举 content → 用户 id 列表(直查 pm_project_user),P4 对账用")
|
||||
public List<String> projectRole(String projectId, String content) {
|
||||
return orgDirectory.getUsersByProjectRole(projectId, content);
|
||||
}
|
||||
|
||||
@GetMapping("/task-context")
|
||||
@Operation(summary = "任务上下文", description = "给定 taskId,回显其流程实例的发起人/部门/项目变量,辅助候选人对账")
|
||||
public Map<String, Object> taskContext(String taskId) {
|
||||
|
||||
@@ -28,12 +28,22 @@ import com.dsasp.server.wf.support.WfTypes;
|
||||
*
|
||||
* <p><b>实测分布(本地客户库副本)</b>:position 1949 / user 1683 / formSpecifiedDimension 601
|
||||
* / projectRoleType 528 / scriptUser 26 / initiatorDepartManager 24 / depart 14
|
||||
* / fixedDimension 12 / sameToTask 5 / initiator 3。占主导类型全部覆盖。</p>
|
||||
* / fixedDimension 12 / sameToTask 5 / initiator 3。</p>
|
||||
*
|
||||
* <p><b>未覆盖类型(报告登记)</b>:initiatorDepartManager/initiatorLeader/initiatorSubordinate/
|
||||
* initiatorDepart/fixedDimension 依赖 SYS_USER.MASTERDEPART/MASTERPOSITION 等
|
||||
* <b>元数据虚拟列</b>(客户库 sys_user 无该物理列,引擎经元数据映射),纯直查 SQL 无法复现,
|
||||
* 需保真层元数据层;本实现对这些类型返回空并由调用侧 WARN。</p>
|
||||
* <p><b>P4 闭环新增(原 P3 降级,现直查闭环)</b>:</p>
|
||||
* <ul>
|
||||
* <li>{@code projectRoleType}(528):content 是「八大员」true/false 位枚举,
|
||||
* true 的位序(1-based)即 {@code PM_PROJECT_USER.ROLE},按 PROJECTID 直查项目角色用户表;</li>
|
||||
* <li>{@code initiatorDepartManager}(24):MASTERDEPART 虚拟列经
|
||||
* {@code view_sys_user.masterdepart} 子查询(sys_positionuser.ismaster=1 → sys_position.parentdepartid)落地,
|
||||
* 再取 {@code sys_depart.leader} 得部门负责人;</li>
|
||||
* <li>{@code fixedDimension}(12):经 {@code view_sys_dimensiondepart}(维度树,PARENTDEPARTIDS 链)
|
||||
* 本部门命中岗位类别岗位则返回,否则按维度链向上回溯(direction=0)。</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p><b>仍降级类型(报告登记)</b>:{@code scriptUser}(26,JUEL 脚本求值需活的 ExecutionEntity
|
||||
* + 反序列化变量,超独立服务精简边界,handler 侧 WARN)、{@code sameToTask}(5,前序活动栈,
|
||||
* 已在 handler 侧经 historyService 闭环,不经本类)。</p>
|
||||
*/
|
||||
public class OrgDirectoryJdbc implements OrgDirectory {
|
||||
|
||||
@@ -80,20 +90,75 @@ public class OrgDirectoryJdbc implements OrgDirectory {
|
||||
} else if (WfTypes.FORMSPECIFIEDDIMENSION.equals(type)) {
|
||||
// framework: findUsersByDepartPositionTypes(curDepart, contents)
|
||||
return findUsersByDepartPositionTypes(initiatorDepart, contents);
|
||||
} else if (WfTypes.INITIATORDEPARTMANAGER.equals(type)) {
|
||||
// framework AssignmentHandlerImpl:getMainDepart(author) → findDepartManager(mainDepart)
|
||||
// MASTERDEPART 经 view_sys_user.masterdepart 子查询落地(P4 闭环)
|
||||
String mainDepart = getMainDepart(initiatorId);
|
||||
if (mainDepart == null) {
|
||||
return rtn;
|
||||
}
|
||||
return findDepartManager(mainDepart);
|
||||
} else if (WfTypes.FIXEDDIMENSION.equals(type)) {
|
||||
// framework AssignmentHandlerImpl:content=维度,岗位类别1,岗位类别2...
|
||||
// → findUsersByDimenDepartPositionTypes(curDepart, dimension, positionTypes, 0)
|
||||
if (contents.size() < 2) {
|
||||
return rtn;
|
||||
}
|
||||
String dimension = contents.get(0);
|
||||
List<String> positionTypes = new ArrayList<String>(contents.subList(1, contents.size()));
|
||||
return findUsersByDimenDepartPositionTypes(initiatorDepart, dimension, positionTypes);
|
||||
}
|
||||
// initiatorDepartManager/beforeTask*/fixedDimension:依赖 MASTERDEPART 等元数据虚拟列
|
||||
// 或前序活动栈,纯直查无法复现,返回空(报告登记)。
|
||||
// beforeTask*/sameToTask:依赖前序活动处理者栈(historyService),已在 handler 侧闭环,不经本类。
|
||||
return rtn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsersByProjectRole(String projectId, String roleContent) {
|
||||
// 客户私有化注入了自有 ProjectRoleUser 实现时,优先委托(完全对齐其语义);
|
||||
// 否则走 P4 闭环的 pm_project_user 直查(逐条对齐 framework projectRoleUser 契约)。
|
||||
if (projectRoleResolver != null) {
|
||||
return projectRoleResolver.getUserByProjectRole(projectId, roleContent);
|
||||
}
|
||||
System.out.println("[WARN] projectRoleType 候选人:framework 无通用 ProjectRoleUser 实现(项目定制扩展),"
|
||||
+ "未注入 ProjectRoleResolver,返回空。projectId=" + projectId);
|
||||
return new ArrayList<String>();
|
||||
List<Integer> roles = parseProjectRoles(roleContent);
|
||||
if (projectId == null || projectId.trim().isEmpty() || roles.isEmpty()) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
// framework ProjectRoleUser.getUserByProjectRole(projectId, "true,false,...") 契约:
|
||||
// content 是「八大员」按枚举顺序的 true/false 串,true 的位序(1-based)即角色编号 role,
|
||||
// 取该项目下这些角色的在用用户(PM_PROJECT_USER.ROLE,isactive=1)。
|
||||
String sql = "SELECT distinct userid FROM pm_project_user WHERE pm_projectid = ? AND isactive = 1 "
|
||||
+ "AND role IN (" + placeholders(roles.size()) + ")";
|
||||
Object[] args = new Object[roles.size() + 1];
|
||||
args[0] = projectId;
|
||||
for (int i = 0; i < roles.size(); i++) {
|
||||
args[i + 1] = roles.get(i);
|
||||
}
|
||||
List<String> rows = bizJdbc.query(sql, (rs, n) -> rs.getString("userid"), args);
|
||||
Set<String> userIds = new LinkedHashSet<String>();
|
||||
for (String u : rows) {
|
||||
if (u != null && !u.trim().isEmpty()) {
|
||||
userIds.add(u.trim());
|
||||
}
|
||||
}
|
||||
return new ArrayList<String>(userIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析「八大员」true/false 位枚举 content 为角色编号(1-based)列表。
|
||||
* 例:{@code "true,false,true"} → {@code [1, 3]};空/全 false → 空。
|
||||
*/
|
||||
static List<Integer> parseProjectRoles(String roleContent) {
|
||||
List<Integer> roles = new ArrayList<Integer>();
|
||||
if (roleContent == null || roleContent.trim().isEmpty()) {
|
||||
return roles;
|
||||
}
|
||||
String[] flags = roleContent.split(",");
|
||||
for (int i = 0; i < flags.length; i++) {
|
||||
if ("true".equalsIgnoreCase(flags[i].trim())) {
|
||||
roles.add(i + 1);
|
||||
}
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,6 +282,106 @@ public class OrgDirectoryJdbc implements OrgDirectory {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* OrganizationServiceImpl.getMainDepart:取用户主部门。
|
||||
*
|
||||
* <p>framework 经元数据虚拟列 {@code SYS_USER.MASTERDEPART} 取得;客户库 sys_user 无该物理列,
|
||||
* 由数据库视图 {@code view_sys_user.masterdepart} 落地(等价 SQL:主岗位 ismaster=1 的
|
||||
* sys_position.parentdepartid)。此处直查该计算逻辑,避免依赖保真层元数据引擎。</p>
|
||||
*/
|
||||
String getMainDepart(String userId) {
|
||||
if (userId == null || userId.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
List<String> rows = bizJdbc.query(
|
||||
"SELECT s2.parentdepartid FROM sys_positionuser s1 "
|
||||
+ "LEFT JOIN sys_position s2 ON s1.positionid = s2.sys_position_id "
|
||||
+ "WHERE s1.ismaster = 1 AND s1.userid = ?",
|
||||
(rs, n) -> rs.getString(1), userId);
|
||||
for (String d : rows) {
|
||||
if (d != null && !d.trim().isEmpty()) {
|
||||
return d.trim();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* UserFindServiceImpl.findDepartManager:部门负责人 = {@code SYS_DEPART.LEADER}。
|
||||
* framework 经 {@code loadPOJO(departId, SYS_DEPART).get_Value("LEADER")} 取,此处直查列。
|
||||
*/
|
||||
List<String> findDepartManager(String departId) {
|
||||
List<String> userIds = new ArrayList<String>();
|
||||
if (departId == null || departId.trim().isEmpty()) {
|
||||
return userIds;
|
||||
}
|
||||
List<String> rows = bizJdbc.query(
|
||||
"SELECT leader FROM sys_depart WHERE sys_depart_id = ?",
|
||||
(rs, n) -> rs.getString("leader"), departId);
|
||||
for (String u : rows) {
|
||||
if (u != null && !u.trim().isEmpty()) {
|
||||
userIds.add(u.trim());
|
||||
}
|
||||
}
|
||||
return userIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* UserFindServiceImpl.findUsersByDimenDepartPositionTypes(curDepart, dimension, positionTypes, 0):
|
||||
* 维度内按部门找岗位类别岗位人员,本部门无则按维度树向上回溯。
|
||||
*
|
||||
* <p>framework 经 {@code VIEW_SYS_DIMENSIONDEPART}(维度部门树,PARENTDEPARTIDS 为祖先链 CSV)
|
||||
* 落地;此处直查该视图。direction 固定 0(向上找,framework 全部调用点即 0,向下分支原版未实现)。</p>
|
||||
*/
|
||||
List<String> findUsersByDimenDepartPositionTypes(String curDepartId, String dimension, List<String> positionTypes) {
|
||||
if (curDepartId == null || curDepartId.trim().isEmpty()
|
||||
|| dimension == null || dimension.trim().isEmpty()
|
||||
|| positionTypes == null || positionTypes.isEmpty()) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
// 1、定位当前维度下的当前部门,取其祖先链 PARENTDEPARTIDS
|
||||
List<String> parentChains = bizJdbc.query(
|
||||
"SELECT parentdepartids FROM view_sys_dimensiondepart WHERE departid = ? AND dimensionid = ?",
|
||||
(rs, n) -> rs.getString("parentdepartids"), curDepartId, dimension);
|
||||
if (parentChains.size() != 1) {
|
||||
// framework:list.size()==1 才继续(维度内该部门唯一),否则返回空
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
// 2、本部门下有该岗位类别岗位则直接返回
|
||||
String posSql = "SELECT sys_position_id FROM sys_position WHERE parentdepartid = ? AND positiontype IN (" + placeholders(positionTypes.size()) + ")";
|
||||
List<String> positionIds = bizJdbc.query(posSql, (rs, n) -> rs.getString("sys_position_id"),
|
||||
prependArg(curDepartId, positionTypes));
|
||||
if (!positionIds.isEmpty()) {
|
||||
return findUsersByPositions(positionIds);
|
||||
}
|
||||
// 3、向上回溯祖先部门链(从近到远),命中岗位类别岗位即返回
|
||||
String chain = parentChains.get(0);
|
||||
if (chain != null && !chain.trim().isEmpty()) {
|
||||
List<String> parents = Arrays.asList(chain.split(","));
|
||||
for (int i = parents.size() - 1; i >= 0; i--) {
|
||||
String parent = parents.get(i);
|
||||
if (parent == null || parent.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
List<String> parentPositionIds = bizJdbc.query(posSql, (rs, n) -> rs.getString("sys_position_id"),
|
||||
prependArg(parent.trim(), positionTypes));
|
||||
if (!parentPositionIds.isEmpty()) {
|
||||
return findUsersByPositions(parentPositionIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
private static Object[] prependArg(String first, List<String> rest) {
|
||||
Object[] args = new Object[rest.size() + 1];
|
||||
args[0] = first;
|
||||
for (int i = 0; i < rest.size(); i++) {
|
||||
args[i + 1] = rest.get(i);
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
private static String placeholders(int n) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
||||
@@ -92,6 +92,37 @@ class CandidateUsersHandlerTest {
|
||||
assertThat(dir.dispatched).contains("projectRoleType:true,false");
|
||||
}
|
||||
|
||||
@Test
|
||||
void sameToTask经前序活动处理者解析() {
|
||||
// sameToTask:content 为指定活动 id,经 getSpecialActivityProcessor(历史活动栈)取处理者。
|
||||
// 单测以子类桩注入前序处理者,验证其进候选人列表(独立服务无引擎时该方法本应取历史)。
|
||||
String expr = "【\"items\":["
|
||||
+ "【\"type\":\"sameToTask\",\"content\":\"sid-PRIOR-ACTIVITY\",\"isCandidate\":true,\"isSendMail\":false,\"isSendPhone\":false】"
|
||||
+ "]】";
|
||||
CandidateUsersHandler handler = new CandidateUsersHandler() {
|
||||
@Override
|
||||
protected String getSpecialActivityProcessor(String processInstanceId, String activityId) {
|
||||
// 模拟历史活动栈返回前序 userTask 的 assignee
|
||||
return "sid-PRIOR-ACTIVITY".equals(activityId) ? "prev-user-7" : null;
|
||||
}
|
||||
};
|
||||
List<String> users = handler.getCandidateUsers((Object) null, expr);
|
||||
assertThat(users).containsExactly("prev-user-7");
|
||||
// sameToTask 不经 OrgDirectory.assignmentUser 分派
|
||||
assertThat(dir.dispatched).noneMatch(s -> s.startsWith("sameToTask"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sameToTask无前序处理者时返回空不抛异常() {
|
||||
String expr = "【\"items\":["
|
||||
+ "【\"type\":\"sameToTask\",\"content\":\"sid-X\",\"isCandidate\":true,\"isSendMail\":false,\"isSendPhone\":false】"
|
||||
+ "]】";
|
||||
// 默认 handler:无引擎 → getSpecialActivityProcessor 返回 null → 候选人空
|
||||
CandidateUsersHandler handler = new CandidateUsersHandler();
|
||||
List<String> users = handler.getCandidateUsers((Object) null, expr);
|
||||
assertThat(users).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void scriptUser分支降级返回空不抛异常() {
|
||||
String expr = "【\"items\":["
|
||||
|
||||
@@ -111,21 +111,76 @@ class OrgDirectoryJdbcTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void 元数据虚拟列依赖类型返回空_initiatorDepartManager() {
|
||||
// initiatorDepartManager 依赖 MASTERDEPART 元数据虚拟列,纯直查不可复现,返回空(报告登记)
|
||||
void initiatorDepartManager经主部门查部门负责人() {
|
||||
// P4 闭环:getMainDepart(经 view_sys_user.masterdepart 子查询)→ findDepartManager(sys_depart.leader)
|
||||
stubQuerySequence(
|
||||
List.of("dep-main"), // getMainDepart:主岗位 parentdepartid
|
||||
List.of("leader-9 ")); // findDepartManager:sys_depart.leader(带 padding)
|
||||
OrgDirectoryJdbc d = directory();
|
||||
assertThat(d.assignmentUser("initiatorDepartManager", null, "u1", "dep1"))
|
||||
.containsExactly("leader-9"); // 去 padding
|
||||
}
|
||||
|
||||
@Test
|
||||
void initiatorDepartManager无主部门返回空() {
|
||||
stubQuery(List.of()); // getMainDepart 返回空
|
||||
OrgDirectoryJdbc d = directory();
|
||||
assertThat(d.assignmentUser("initiatorDepartManager", null, "u1", "dep1")).isEmpty();
|
||||
assertThat(d.assignmentUser("fixedDimension", "dim1,typeA", "u1", "dep1")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectRoleType无解析器时返回空() {
|
||||
void fixedDimension本部门命中岗位类别岗位则返回不回溯() {
|
||||
// 维度内本部门唯一(parentdepartids 链命中 1 条)→ 本部门岗位命中 → 取人员
|
||||
stubQuerySequence(
|
||||
List.of("a,b,c"), // view_sys_dimensiondepart.parentdepartids(1 条)
|
||||
List.of("posDim"), // 本部门岗位类别岗位
|
||||
List.of("dim-user")); // findUsersByPositions
|
||||
OrgDirectoryJdbc d = directory();
|
||||
assertThat(d.getUsersByProjectRole("proj1", "true,false")).isEmpty();
|
||||
assertThat(d.assignmentUser("fixedDimension", "administrative,typeA", "u1", "dep1"))
|
||||
.containsExactly("dim-user");
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectRoleType有解析器时委托() {
|
||||
void fixedDimension内容不足两段返回空() {
|
||||
OrgDirectoryJdbc d = directory();
|
||||
assertThat(d.assignmentUser("fixedDimension", "onlyDimension", "u1", "dep1")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectRoleType解析八大员位枚举查pm_project_user() {
|
||||
// content "true,false,true" → 角色 1,3 → 查 pm_project_user
|
||||
stubQuery(List.of("pu-1 ", "pu-2 ", "pu-1 "));
|
||||
OrgDirectoryJdbc d = directory();
|
||||
List<String> users = d.getUsersByProjectRole("proj1", "true,false,true");
|
||||
// 去 padding + 去重
|
||||
assertThat(users).containsExactly("pu-1", "pu-2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectRoleType全false或空content返回空不查库() {
|
||||
OrgDirectoryJdbc d = directory();
|
||||
assertThat(d.getUsersByProjectRole("proj1", "false,false,false")).isEmpty();
|
||||
assertThat(d.getUsersByProjectRole("proj1", "")).isEmpty();
|
||||
assertThat(d.getUsersByProjectRole(null, "true")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectRoleType位枚举解析为1based角色编号() {
|
||||
// 单元验证位序解析:true 的位置(1-based)即角色编号
|
||||
assertThat(OrgDirectoryJdbc.parseProjectRoles("true,false,false,false,false,false,false,false"))
|
||||
.containsExactly(1);
|
||||
assertThat(OrgDirectoryJdbc.parseProjectRoles("false,true,false")).containsExactly(2);
|
||||
assertThat(OrgDirectoryJdbc.parseProjectRoles("true,false,true")).containsExactly(1, 3);
|
||||
// 变长(新版流程加了角色位)
|
||||
assertThat(OrgDirectoryJdbc.parseProjectRoles("false,false,false,false,false,false,false,false,false,false,true"))
|
||||
.containsExactly(11);
|
||||
assertThat(OrgDirectoryJdbc.parseProjectRoles("")).isEmpty();
|
||||
assertThat(OrgDirectoryJdbc.parseProjectRoles(null)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void projectRoleType有客户私有解析器时优先委托() {
|
||||
// 客户私有化注入自有 ProjectRoleUser 时,优先委托,不走 pm_project_user 直查
|
||||
OrgDirectoryJdbc d = new OrgDirectoryJdbc(bizJdbc,
|
||||
(projectId, roleContent) -> List.of("pr-user-1"));
|
||||
assertThat(d.getUsersByProjectRole("proj1", "true")).containsExactly("pr-user-1");
|
||||
|
||||
Reference in New Issue
Block a user