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:
@@ -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