feat(aihr): read formal position SOP mappings
This commit is contained in:
+52
@@ -174,6 +174,18 @@ public class AihrSopSeedService {
|
||||
public PositionSopResponse positionSop(String requestedPosition, String projectType) {
|
||||
String position = firstNonBlank(requestedPosition, "生活顾问");
|
||||
String effectiveProjectType = firstNonBlank(projectType, "住宅");
|
||||
List<PositionSopTopicResponse> formalTopics = formalPositionSopTopics(position, effectiveProjectType);
|
||||
if (!formalTopics.isEmpty()) {
|
||||
return new PositionSopResponse(
|
||||
position,
|
||||
effectiveProjectType,
|
||||
"formal-applicability",
|
||||
true,
|
||||
"NOT_CONFIGURED",
|
||||
"已按正式岗位/SOP适用范围加载学习主题;上岗资格仍需组织身份和资格规则配置。",
|
||||
formalTopics
|
||||
);
|
||||
}
|
||||
if (!"生活顾问".equals(position)) {
|
||||
return new PositionSopResponse(
|
||||
position,
|
||||
@@ -199,6 +211,46 @@ public class AihrSopSeedService {
|
||||
);
|
||||
}
|
||||
|
||||
private List<PositionSopTopicResponse> formalPositionSopTopics(String position, String projectType) {
|
||||
if (jdbcTemplate == null) {
|
||||
return List.of();
|
||||
}
|
||||
try {
|
||||
return jdbcTemplate.query("""
|
||||
SELECT r.position_code, r.responsibility_text, r.sop_code, r.sop_id
|
||||
FROM aihr_position_responsibility r
|
||||
JOIN aihr_sop_applicability a
|
||||
ON a.tenant_id = r.tenant_id
|
||||
AND ((r.sop_id IS NOT NULL AND r.sop_id = a.sop_id)
|
||||
OR (NULLIF(r.sop_code, '') IS NOT NULL AND r.sop_code = a.sop_code))
|
||||
WHERE r.tenant_id = ?
|
||||
AND r.position_code = ?
|
||||
AND r.enabled = 1
|
||||
AND a.enabled = 1
|
||||
AND (a.project_type IS NULL OR a.project_type = '' OR a.project_type = ?)
|
||||
AND (r.effective_from IS NULL OR r.effective_from <= CURRENT_DATE)
|
||||
AND (r.effective_thru IS NULL OR r.effective_thru >= CURRENT_DATE)
|
||||
AND (a.effective_from IS NULL OR a.effective_from <= CURRENT_DATE)
|
||||
AND (a.effective_thru IS NULL OR a.effective_thru >= CURRENT_DATE)
|
||||
ORDER BY r.id
|
||||
LIMIT 50
|
||||
""", (rs, rowNum) -> {
|
||||
String sopCode = rs.getString("sop_code");
|
||||
Object sopId = rs.getObject("sop_id");
|
||||
String sopReference = firstNonBlank(sopCode, sopId == null ? null : "sop#" + sopId);
|
||||
return new PositionSopTopicResponse(
|
||||
firstNonBlank(rs.getString("position_code"), position),
|
||||
rs.getString("responsibility_text"),
|
||||
firstNonBlank(sopReference, "待绑定SOP"),
|
||||
"正式适用"
|
||||
);
|
||||
}, tenantId(), position, projectType);
|
||||
} catch (DataAccessException ex) {
|
||||
log.debug("formal position SOP mapping unavailable, use pilot seed navigation", ex);
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
public SopReviewResponse reviewSearch(Long id, SopReviewRequest request) {
|
||||
return reviewSearch(id, request, null);
|
||||
}
|
||||
|
||||
+16
@@ -244,6 +244,22 @@ public class AihrSopSeedServiceTest {
|
||||
assertFalse(code.contains("@SaIgnore\n @GetMapping(\"/position-sop\")"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("dev")
|
||||
public void positionSopUsesFormalMappingBeforeSeedFallback() throws Exception {
|
||||
Path source = Path.of("src/main/java/org/dromara/aihr/service/AihrSopSeedService.java");
|
||||
if (!Files.exists(source)) {
|
||||
source = Path.of("ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrSopSeedService.java");
|
||||
}
|
||||
String code = Files.readString(source);
|
||||
|
||||
assertTrue(code.contains("formalPositionSopTopics(position, effectiveProjectType)"));
|
||||
assertTrue(code.contains("FROM aihr_position_responsibility r"));
|
||||
assertTrue(code.contains("JOIN aihr_sop_applicability a"));
|
||||
assertTrue(code.contains("\"formal-applicability\""));
|
||||
assertTrue(code.contains("\"NOT_CONFIGURED\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("dev")
|
||||
public void answerFeedbackReviewUsesAuthenticatedOperatorForAuditTrail() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user