Merge branch 'codex/brd-release-20260715' into codex/multi-tenant-knowledge-platform
# Conflicts: # AGENTS.md # README.md # backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrPracticeDto.java # backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrOrgSyncService.java # backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java # backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrUploadQueueService.java # backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrOrgSyncServiceTest.java # backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrPracticeSeedServiceTest.java # backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrUploadQueueServiceTest.java # docs/20260708/uni-app用户侧前端重建计划.md # docs/API_INTEGRATION.md # docs/BRD_IMPLEMENTATION_AUDIT.md # docs/BRD_PRODUCTION_MIGRATION_RUNBOOK.md # docs/DEMO_ACCEPTANCE.md # docs/DEV_SETUP.md # docs/FIGMA_IMPLEMENTATION_MATRIX.md # docs/README.md # frontend/src/views/knowledge/processing.vue # mobile-uni/src/pages/supervisor/assign/index.vue # mobile-uni/src/pages/supervisor/index/index.vue # mobile-uni/src/pages/supervisor/profile/index.vue # mobile-uni/src/pages/supervisor/review/index.vue # mobile-uni/src/pages/supervisor/reviews/index.vue # mobile-uni/src/pages/supervisor/team/index.vue # mobile-uni/src/pages/user/cases/index.vue # mobile-uni/src/pages/user/practice/index.vue # mobile-uni/src/pages/user/profile/index.vue # mobile-uni/src/pages/user/sop/index.vue # mobile-uni/src/pages/user/today/index.vue # mobile-uni/src/types/api.ts # scripts/tests/aihr-schema-migrations.test.sh
This commit is contained in:
+2
-2
@@ -38,13 +38,13 @@ public final class AihrSopDto {
|
||||
public record SopReviewResponse(Long id, Boolean usable, String status, String reviewedAt, String promptVersion) {
|
||||
}
|
||||
|
||||
public record AnswerFeedbackRequest(String queryText, Long fragmentId, List<Long> fragmentIds, String verdict, String category, String position, String source, Long reviewId) {
|
||||
public record AnswerFeedbackRequest(String queryText, Long fragmentId, List<Long> fragmentIds, String verdict, String category, String position, String source, Long reviewId, List<String> reasonCodes, String comment) {
|
||||
}
|
||||
|
||||
public record AnswerFeedbackResponse(Integer saved, String verdict, String reviewStatus) {
|
||||
}
|
||||
|
||||
public record AnswerFeedbackItemResponse(Long id, String queryText, String queryNorm, Long fragmentId, String verdict, String category, String position, String source, Long reviewId, String reviewStatus, String reviewer, String reviewedTime, String createTime, String updateTime) {
|
||||
public record AnswerFeedbackItemResponse(Long id, String queryText, String queryNorm, Long fragmentId, String verdict, String feedbackReasonCodes, String feedbackComment, String category, String position, String source, Long reviewId, String reviewStatus, String reviewer, String reviewedTime, String createTime, String updateTime) {
|
||||
}
|
||||
|
||||
public record AnswerFeedbackReviewResponse(Long id, String reviewStatus, String reviewer, String reviewedTime) {
|
||||
|
||||
+63
-9
@@ -72,11 +72,15 @@ public class AihrOrgSyncService {
|
||||
@Value("${aihr.org-sync.store-display-fields:${AIHR_ORG_SYNC_STORE_DISPLAY_FIELDS:false}}")
|
||||
private boolean storeDisplayFields;
|
||||
|
||||
@Value("${aihr.org-sync.position-map-json:${AIHR_ORG_POSITION_MAP_JSON:}}")
|
||||
private String configuredPositionMapJson;
|
||||
|
||||
public SyncResponse sync(SyncRequest request) {
|
||||
SyncRequest req = request == null ? new SyncRequest(null, null, null, null, null, null, null, null) : request;
|
||||
if (req.dryRun() == null) {
|
||||
throw new IllegalArgumentException("组织同步必须明确传 dryRun=true 预检或 dryRun=false 写入");
|
||||
}
|
||||
Map<String, PositionMapping> positionMappings = positionMappings();
|
||||
String baseUrl = normalizeBaseUrl(configuredBaseUrl);
|
||||
if (baseUrl.isBlank()) {
|
||||
throw new IllegalArgumentException("请先配置 AIHR_ORG_SYNC_BASE_URL,值为外部开放平台 /api/open/v1 前缀");
|
||||
@@ -108,7 +112,7 @@ public class AihrOrgSyncService {
|
||||
int maskedPhone = 0;
|
||||
int phoneLinked = 0;
|
||||
for (JsonNode employee : employeeItems) {
|
||||
List<OrgRow> employeeRows = orgRows(employee, companies, departments, projects, assignmentGroups);
|
||||
List<OrgRow> employeeRows = orgRows(employee, companies, departments, projects, assignmentGroups, positionMappings);
|
||||
if (employeeRows.isEmpty()) {
|
||||
skipped++;
|
||||
} else {
|
||||
@@ -124,6 +128,13 @@ public class AihrOrgSyncService {
|
||||
int suspectText = (int) rows.stream().filter(OrgRow::suspectText).count();
|
||||
int duplicateMemberships = countDuplicateMemberships(rows);
|
||||
int mappedEmployees = employeeItems.size() - skipped;
|
||||
if (!positionMappings.isEmpty()) {
|
||||
int mappedPositions = (int) rows.stream().filter(OrgRow::positionMapped).count();
|
||||
int supervisors = (int) rows.stream()
|
||||
.filter(row -> "主管".equals(row.positionLevel()) || "项目经理".equals(row.positionLevel()))
|
||||
.count();
|
||||
warnings.add("HR 岗位映射命中 " + mappedPositions + " 人,解析主管/项目经理 " + supervisors + " 人,请核对后再写入");
|
||||
}
|
||||
if (mappedEmployees > 0 && phoneLinked < mappedEmployees) {
|
||||
warnings.add("外部员工快照手机号覆盖 " + phoneLinked + "/" + mappedEmployees + ",移动端正式登录仅可映射已带手机号人员");
|
||||
}
|
||||
@@ -394,7 +405,8 @@ public class AihrOrgSyncService {
|
||||
}
|
||||
|
||||
private OrgRow orgRow(JsonNode employee, Map<String, CompanyInfo> companies, Map<String, DepartmentInfo> departments,
|
||||
Map<String, ProjectInfo> projects, Map<String, AssignmentInfo> assignments) {
|
||||
Map<String, ProjectInfo> projects, Map<String, AssignmentInfo> assignments,
|
||||
Map<String, PositionMapping> positionMappings) {
|
||||
String employeeNumber = firstNonBlank(text(employee, "employee_number", "employeeNumber", "employeeNo"));
|
||||
String employeeId = firstNonBlank(text(employee, "employee_id", "employeeId", "id", "user_id", "userId"));
|
||||
String extPartyId = firstNonBlank(employeeNumber, employeeId);
|
||||
@@ -447,13 +459,18 @@ public class AihrOrgSyncService {
|
||||
"组织架构"
|
||||
);
|
||||
String personName = firstNonBlank(text(employee, "name", "person_name", "personName", "employee_name", "employeeName"), "-");
|
||||
String positionName = firstNonBlank(
|
||||
assignment == null ? "" : assignment.positionName(),
|
||||
text(employee, "project_position_name", "projectPositionName", "position_name", "positionName", "job_title", "jobTitle",
|
||||
"post_name", "postName", "job_name", "jobName", "role_name", "roleName", "position", "title"), "员工");
|
||||
String assignmentPositionName = assignment == null ? "" : assignment.positionName();
|
||||
String externalPositionName = text(employee, "project_position_name", "projectPositionName", "position_name", "positionName",
|
||||
"job_title", "jobTitle", "post_name", "postName", "job_name", "jobName", "role_name", "roleName", "position", "title");
|
||||
PositionMapping mappedPosition = positionMappings.get(firstNonBlank(
|
||||
text(employee, "position_id", "positionId", "job_id", "jobId", "post_id", "postId")));
|
||||
boolean positionMapped = assignmentPositionName.isBlank() && externalPositionName.isBlank() && mappedPosition != null;
|
||||
String positionName = firstNonBlank(assignmentPositionName, externalPositionName,
|
||||
mappedPosition == null ? "" : mappedPosition.name(), "员工");
|
||||
String positionLevel = firstNonBlank(
|
||||
assignment == null ? "" : assignment.positionLevel(),
|
||||
text(employee, "project_position_level", "projectPositionLevel", "position_level", "positionLevel", "job_level", "jobLevel"),
|
||||
positionMapped ? mappedPosition.level() : "",
|
||||
level(positionName)
|
||||
);
|
||||
LocalDate hireDate = parseDate(firstNonBlank(
|
||||
@@ -471,6 +488,7 @@ public class AihrOrgSyncService {
|
||||
storeDisplayFields ? personName : "",
|
||||
positionName,
|
||||
positionLevel(positionLevel, positionName),
|
||||
positionMapped,
|
||||
status(text(employee, "status", "employment_status", "employmentStatus")),
|
||||
hireDate,
|
||||
LocalDate.now(),
|
||||
@@ -480,7 +498,8 @@ public class AihrOrgSyncService {
|
||||
|
||||
private List<OrgRow> orgRows(JsonNode employee, Map<String, CompanyInfo> companies,
|
||||
Map<String, DepartmentInfo> departments, Map<String, ProjectInfo> projects,
|
||||
Map<String, List<AssignmentInfo>> assignmentGroups) {
|
||||
Map<String, List<AssignmentInfo>> assignmentGroups,
|
||||
Map<String, PositionMapping> positionMappings) {
|
||||
String employeeNumber = firstNonBlank(text(employee, "employee_number", "employeeNumber", "employeeNo"));
|
||||
String employeeId = firstNonBlank(text(employee, "employee_id", "employeeId", "id", "user_id", "userId"));
|
||||
String extPartyId = firstNonBlank(employeeNumber, employeeId);
|
||||
@@ -489,7 +508,7 @@ public class AihrOrgSyncService {
|
||||
}
|
||||
List<AssignmentInfo> assignments = assignmentList(assignmentGroups, employeeId, employeeNumber, extPartyId);
|
||||
if (assignments.isEmpty()) {
|
||||
OrgRow row = orgRow(employee, companies, departments, projects, Map.of());
|
||||
OrgRow row = orgRow(employee, companies, departments, projects, Map.of(), positionMappings);
|
||||
return row == null ? List.of() : List.of(row);
|
||||
}
|
||||
List<OrgRow> rows = new ArrayList<>();
|
||||
@@ -498,7 +517,7 @@ public class AihrOrgSyncService {
|
||||
putAssignment(selected, employeeId, assignment);
|
||||
putAssignment(selected, employeeNumber, assignment);
|
||||
putAssignment(selected, extPartyId, assignment);
|
||||
OrgRow row = orgRow(employee, companies, departments, projects, selected);
|
||||
OrgRow row = orgRow(employee, companies, departments, projects, selected, positionMappings);
|
||||
if (row != null) {
|
||||
rows.add(row);
|
||||
}
|
||||
@@ -822,6 +841,37 @@ public class AihrOrgSyncService {
|
||||
return level;
|
||||
}
|
||||
|
||||
private Map<String, PositionMapping> positionMappings() {
|
||||
String json = clean(configuredPositionMapJson);
|
||||
if (json.isBlank()) {
|
||||
return Map.of();
|
||||
}
|
||||
try {
|
||||
JsonNode root = objectMapper.readTree(json);
|
||||
if (!root.isObject()) {
|
||||
throw new IllegalArgumentException("岗位映射必须是 JSON 对象");
|
||||
}
|
||||
Map<String, PositionMapping> mappings = new TreeMap<>();
|
||||
var fields = root.fields();
|
||||
while (fields.hasNext()) {
|
||||
var entry = fields.next();
|
||||
String positionId = clean(entry.getKey());
|
||||
String name = text(entry.getValue(), "name", "positionName", "position_name");
|
||||
String level = text(entry.getValue(), "level", "positionLevel", "position_level");
|
||||
if (positionId.isBlank() || name.isBlank() || name.length() > 100
|
||||
|| !("一线".equals(level) || "主管".equals(level) || "项目经理".equals(level))) {
|
||||
throw new IllegalArgumentException("岗位映射必须包含 position_id、岗位名称及合法层级(一线/主管/项目经理)");
|
||||
}
|
||||
mappings.put(positionId, new PositionMapping(name, level));
|
||||
}
|
||||
return Map.copyOf(mappings);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("岗位映射 JSON 配置无效", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String phone(JsonNode employee) {
|
||||
for (String field : PHONE_FIELDS) {
|
||||
String normalized = normalizeMobilePhone(text(employee, field));
|
||||
@@ -1003,6 +1053,9 @@ public class AihrOrgSyncService {
|
||||
) {
|
||||
}
|
||||
|
||||
private record PositionMapping(String name, String level) {
|
||||
}
|
||||
|
||||
private record OrgRow(
|
||||
String projectCode,
|
||||
String projectName,
|
||||
@@ -1012,6 +1065,7 @@ public class AihrOrgSyncService {
|
||||
String personName,
|
||||
String positionName,
|
||||
String positionLevel,
|
||||
boolean positionMapped,
|
||||
String employmentStatus,
|
||||
LocalDate hireDate,
|
||||
LocalDate snapshotDate,
|
||||
|
||||
+36
-3
@@ -111,6 +111,9 @@ public class AihrSopSeedService {
|
||||
private static final int LOCAL_EMBEDDING_DIMENSION = 1536;
|
||||
private static final int MAX_EVIDENCE_SNIPPETS = 3;
|
||||
private static final String NO_CLEAR_SOP_EVIDENCE = "未在已入库 SOP 中找到明确依据";
|
||||
private static final Set<String> FEEDBACK_REASON_CODES = Set.of(
|
||||
"no_answer", "not_specific", "wrong_reference", "outdated", "not_applicable"
|
||||
);
|
||||
private static final String SOP_ANSWER_PROMPT_VERSION = "builtin-sop_answer-v1";
|
||||
private static final String SOP_ANSWER_SYSTEM_PROMPT = "你是物业一线员工的SOP助手。只返回 JSON,不要 markdown。字段固定为 answer, keyPoints, cautions。"
|
||||
+ "answer 必须结论先行,60字内直接告诉员工现在怎么做;keyPoints 必须是3到5条可执行步骤,每条以「一、」「二、」「三、」「四、」「五、」开头,包含责任人、动作、时限或留痕要求;"
|
||||
@@ -353,6 +356,14 @@ public class AihrSopSeedService {
|
||||
if (isBlank(verdict)) {
|
||||
throw new ServiceException("反馈类型只支持 up/down");
|
||||
}
|
||||
List<String> reasonCodes = normalizeFeedbackReasons(request == null ? null : request.reasonCodes());
|
||||
if ("down".equals(verdict) && reasonCodes.isEmpty()) {
|
||||
throw new ServiceException("请选择未解决原因");
|
||||
}
|
||||
String feedbackReasonCodes = "down".equals(verdict) ? String.join(",", reasonCodes) : "";
|
||||
String feedbackComment = "down".equals(verdict)
|
||||
? truncate(AihrSensitiveText.forModel(request.comment()), 500)
|
||||
: "";
|
||||
List<Long> fragmentIds = feedbackFragmentIds(request);
|
||||
if (fragmentIds.isEmpty()) {
|
||||
throw new ServiceException("缺少片段ID");
|
||||
@@ -366,11 +377,13 @@ public class AihrSopSeedService {
|
||||
for (Long fragmentId : fragmentIds) {
|
||||
saved += jdbcTemplate.update("""
|
||||
INSERT INTO aihr_knowledge_answer_feedback
|
||||
(tenant_id, query_text, query_norm, fragment_id, verdict, category, position, source, review_id, review_status, create_time, update_time)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
(tenant_id, query_text, query_norm, fragment_id, verdict, feedback_reason_codes, feedback_comment, category, position, source, review_id, review_status, create_time, update_time)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
query_text = VALUES(query_text),
|
||||
verdict = VALUES(verdict),
|
||||
feedback_reason_codes = VALUES(feedback_reason_codes),
|
||||
feedback_comment = VALUES(feedback_comment),
|
||||
category = VALUES(category),
|
||||
position = VALUES(position),
|
||||
source = VALUES(source),
|
||||
@@ -383,6 +396,8 @@ public class AihrSopSeedService {
|
||||
normalizeFeedbackQuery(AihrSensitiveText.forModel(queryText)),
|
||||
fragmentId,
|
||||
verdict,
|
||||
feedbackReasonCodes,
|
||||
feedbackComment,
|
||||
firstNonBlank(request.category(), "sop"),
|
||||
firstNonBlank(request.position(), "生活顾问"),
|
||||
normalizeSearchSource(request.source()),
|
||||
@@ -400,7 +415,7 @@ public class AihrSopSeedService {
|
||||
String reviewStatus = firstNonBlank(status, "待复核");
|
||||
int limitValue = Math.max(1, Math.min(limit, 200));
|
||||
return jdbcTemplate.query("""
|
||||
SELECT id, query_text, query_norm, fragment_id, verdict, category, position, source, review_id, review_status, reviewer, reviewed_time, create_time, update_time
|
||||
SELECT id, query_text, query_norm, fragment_id, verdict, feedback_reason_codes, feedback_comment, category, position, source, review_id, review_status, reviewer, reviewed_time, create_time, update_time
|
||||
FROM aihr_knowledge_answer_feedback
|
||||
WHERE tenant_id = ?
|
||||
AND (? = '' OR review_status = ?)
|
||||
@@ -412,6 +427,8 @@ public class AihrSopSeedService {
|
||||
rs.getString("query_norm"),
|
||||
rs.getLong("fragment_id"),
|
||||
rs.getString("verdict"),
|
||||
rs.getString("feedback_reason_codes"),
|
||||
rs.getString("feedback_comment"),
|
||||
rs.getString("category"),
|
||||
rs.getString("position"),
|
||||
rs.getString("source"),
|
||||
@@ -2570,6 +2587,8 @@ public class AihrSopSeedService {
|
||||
`query_norm` varchar(500) NOT NULL COMMENT '规范化问题',
|
||||
`fragment_id` bigint NOT NULL COMMENT '知识片段ID',
|
||||
`verdict` varchar(10) NOT NULL COMMENT '反馈: up/down',
|
||||
`feedback_reason_codes` varchar(255) DEFAULT NULL COMMENT '未解决原因代码',
|
||||
`feedback_comment` varchar(500) DEFAULT NULL COMMENT '未解决补充说明',
|
||||
`category` varchar(100) DEFAULT NULL COMMENT '知识分类',
|
||||
`position` varchar(80) DEFAULT NULL COMMENT '岗位',
|
||||
`source` varchar(50) DEFAULT 'knowledge_search' COMMENT '来源',
|
||||
@@ -2586,6 +2605,8 @@ public class AihrSopSeedService {
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='AI HR 知识答案反馈';
|
||||
""");
|
||||
ensureColumn("aihr_knowledge_answer_feedback", "review_id", "ALTER TABLE aihr_knowledge_answer_feedback ADD COLUMN `review_id` bigint DEFAULT NULL COMMENT '对应SOP问答评审ID' AFTER `source`");
|
||||
ensureColumn("aihr_knowledge_answer_feedback", "feedback_reason_codes", "ALTER TABLE aihr_knowledge_answer_feedback ADD COLUMN `feedback_reason_codes` varchar(255) DEFAULT NULL COMMENT '未解决原因代码' AFTER `verdict`");
|
||||
ensureColumn("aihr_knowledge_answer_feedback", "feedback_comment", "ALTER TABLE aihr_knowledge_answer_feedback ADD COLUMN `feedback_comment` varchar(500) DEFAULT NULL COMMENT '未解决补充说明' AFTER `feedback_reason_codes`");
|
||||
ensureColumn("aihr_knowledge_answer_feedback", "reviewer", "ALTER TABLE aihr_knowledge_answer_feedback ADD COLUMN `reviewer` varchar(100) DEFAULT NULL COMMENT '复核人' AFTER `review_status`");
|
||||
ensureColumn("aihr_knowledge_answer_feedback", "reviewed_time", "ALTER TABLE aihr_knowledge_answer_feedback ADD COLUMN `reviewed_time` datetime DEFAULT NULL COMMENT '复核时间' AFTER `reviewer`");
|
||||
answerFeedbackTableReady = true;
|
||||
@@ -2653,6 +2674,18 @@ public class AihrSopSeedService {
|
||||
return "up".equals(verdict) || "down".equals(verdict) ? verdict : "";
|
||||
}
|
||||
|
||||
private static List<String> normalizeFeedbackReasons(List<String> values) {
|
||||
if (values == null) {
|
||||
return List.of();
|
||||
}
|
||||
return values.stream()
|
||||
.map(value -> Optional.ofNullable(value).orElse("").trim().toLowerCase(Locale.ROOT))
|
||||
.filter(FEEDBACK_REASON_CODES::contains)
|
||||
.distinct()
|
||||
.limit(FEEDBACK_REASON_CODES.size())
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static List<Long> feedbackFragmentIds(AnswerFeedbackRequest request) {
|
||||
LinkedHashSet<Long> ids = new LinkedHashSet<>();
|
||||
if (request != null && request.fragmentIds() != null) {
|
||||
|
||||
+32
-6
@@ -79,13 +79,13 @@ public class AihrOrgSyncServiceTest {
|
||||
""");
|
||||
|
||||
ReflectionTestUtils.setField(service, "storeDisplayFields", false);
|
||||
Object masked = ReflectionTestUtils.invokeMethod(service, "orgRow", employee, Map.of(), Map.of(), Map.of(), Map.of());
|
||||
Object masked = ReflectionTestUtils.invokeMethod(service, "orgRow", employee, Map.of(), Map.of(), Map.of(), Map.of(), Map.of());
|
||||
assertEquals("", ReflectionTestUtils.getField(masked, "personName"));
|
||||
assertEquals("", ReflectionTestUtils.getField(masked, "deptName"));
|
||||
assertEquals(LocalDate.of(2026, 7, 1), ReflectionTestUtils.getField(masked, "hireDate"));
|
||||
|
||||
ReflectionTestUtils.setField(service, "storeDisplayFields", true);
|
||||
Object demo = ReflectionTestUtils.invokeMethod(service, "orgRow", employee, Map.of(), Map.of(), Map.of(), Map.of());
|
||||
Object demo = ReflectionTestUtils.invokeMethod(service, "orgRow", employee, Map.of(), Map.of(), Map.of(), Map.of(), Map.of());
|
||||
assertEquals("测试员工", ReflectionTestUtils.getField(demo, "personName"));
|
||||
assertEquals("项目管理", ReflectionTestUtils.getField(demo, "deptName"));
|
||||
assertEquals(LocalDate.of(2026, 7, 1), ReflectionTestUtils.getField(demo, "hireDate"));
|
||||
@@ -112,7 +112,7 @@ public class AihrOrgSyncServiceTest {
|
||||
Object row = ReflectionTestUtils.invokeMethod(service, "orgRow", employee, Map.of(),
|
||||
ReflectionTestUtils.invokeMethod(service, "departmentMap", departments),
|
||||
ReflectionTestUtils.invokeMethod(service, "projectMap", projects),
|
||||
ReflectionTestUtils.invokeMethod(service, "assignmentMap", assignments));
|
||||
ReflectionTestUtils.invokeMethod(service, "assignmentMap", assignments), Map.of());
|
||||
|
||||
assertEquals("FW001", ReflectionTestUtils.getField(row, "projectCode"));
|
||||
assertEquals("翡翠湾", ReflectionTestUtils.getField(row, "projectName"));
|
||||
@@ -143,7 +143,7 @@ public class AihrOrgSyncServiceTest {
|
||||
|
||||
Object groups = ReflectionTestUtils.invokeMethod(service, "assignmentGroups", assignments);
|
||||
List<?> rows = ReflectionTestUtils.invokeMethod(service, "orgRows", employee,
|
||||
Map.of(), Map.of(), Map.of(), groups);
|
||||
Map.of(), Map.of(), Map.of(), groups, Map.of());
|
||||
|
||||
assertEquals(2, rows.size());
|
||||
assertEquals(List.of("FW001", "YSF001"), rows.stream()
|
||||
@@ -159,11 +159,37 @@ public class AihrOrgSyncServiceTest {
|
||||
{"id":"EMP-1","project_name":"翡翠湾","position_name":"项目经理","position_level":2,"phone":"13900001111"}
|
||||
""");
|
||||
|
||||
Object row = ReflectionTestUtils.invokeMethod(service, "orgRow", employee, Map.of(), Map.of(), Map.of(), Map.of());
|
||||
Object row = ReflectionTestUtils.invokeMethod(service, "orgRow", employee, Map.of(), Map.of(), Map.of(), Map.of(), Map.of());
|
||||
|
||||
assertEquals("项目经理", ReflectionTestUtils.getField(row, "positionLevel"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configuredPositionMappingFillsMissingPositionWithoutOverridingAssignments() throws Exception {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
AihrOrgSyncService service = new AihrOrgSyncService(mapper, mock(JdbcTemplate.class), mock(TransactionTemplate.class));
|
||||
ReflectionTestUtils.setField(service, "configuredPositionMapJson",
|
||||
"{\"POS-1\":{\"name\":\"项目经理\",\"level\":\"项目经理\"}}");
|
||||
Object mappings = ReflectionTestUtils.invokeMethod(service, "positionMappings");
|
||||
Object row = ReflectionTestUtils.invokeMethod(service, "orgRow",
|
||||
mapper.readTree("{\"id\":\"EMP-1\",\"position_id\":\"POS-1\"}"),
|
||||
Map.of(), Map.of(), Map.of(), Map.of(), mappings);
|
||||
|
||||
assertEquals("项目经理", ReflectionTestUtils.getField(row, "positionName"));
|
||||
assertEquals("项目经理", ReflectionTestUtils.getField(row, "positionLevel"));
|
||||
assertEquals(true, ReflectionTestUtils.getField(row, "positionMapped"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configuredPositionMappingRejectsPrivilegeLevelsOutsideTheContract() {
|
||||
AihrOrgSyncService service = new AihrOrgSyncService(new ObjectMapper(), mock(JdbcTemplate.class), mock(TransactionTemplate.class));
|
||||
ReflectionTestUtils.setField(service, "configuredPositionMapJson",
|
||||
"{\"POS-1\":{\"name\":\"项目经理\",\"level\":\"超级管理员\"}}");
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> ReflectionTestUtils.invokeMethod(service, "positionMappings"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void suspectTextIsCheckedBeforeDisplayFieldsAreMasked() throws Exception {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
@@ -173,7 +199,7 @@ public class AihrOrgSyncServiceTest {
|
||||
""");
|
||||
|
||||
ReflectionTestUtils.setField(service, "storeDisplayFields", false);
|
||||
Object masked = ReflectionTestUtils.invokeMethod(service, "orgRow", employee, Map.of(), Map.of(), Map.of(), Map.of());
|
||||
Object masked = ReflectionTestUtils.invokeMethod(service, "orgRow", employee, Map.of(), Map.of(), Map.of(), Map.of(), Map.of());
|
||||
|
||||
assertEquals("", ReflectionTestUtils.getField(masked, "personName"));
|
||||
assertEquals("", ReflectionTestUtils.getField(masked, "deptName"));
|
||||
|
||||
+18
@@ -369,6 +369,24 @@ public class AihrSopSeedServiceTest {
|
||||
assertTrue(code.contains("WHERE tenant_id = ? AND id = ? AND query_text = ?"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("dev")
|
||||
public void answerFeedbackPersistsStructuredNegativeReasons() throws Exception {
|
||||
Path dto = Path.of("src/main/java/org/dromara/aihr/domain/AihrSopDto.java");
|
||||
Path service = Path.of("src/main/java/org/dromara/aihr/service/AihrSopSeedService.java");
|
||||
if (!Files.exists(dto)) {
|
||||
dto = Path.of("ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrSopDto.java");
|
||||
service = Path.of("ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrSopSeedService.java");
|
||||
}
|
||||
String dtoCode = Files.readString(dto);
|
||||
String serviceCode = Files.readString(service);
|
||||
|
||||
assertTrue(dtoCode.contains("List<String> reasonCodes, String comment"));
|
||||
assertTrue(serviceCode.contains("feedback_reason_codes"));
|
||||
assertTrue(serviceCode.contains("feedback_comment"));
|
||||
assertTrue(serviceCode.contains("normalizeFeedbackReasons(request == null ? null : request.reasonCodes())"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Tag("dev")
|
||||
public void ossMetadataQueriesKeepTenantScope() throws Exception {
|
||||
|
||||
@@ -118,6 +118,9 @@ CREATE TABLE IF NOT EXISTS `aihr_practice_assignment` (
|
||||
`scenario_name` varchar(100) DEFAULT NULL COMMENT '场景名称',
|
||||
`source` varchar(30) NOT NULL DEFAULT 'manual' COMMENT '来源 daily/camp/retry/manual',
|
||||
`reason` varchar(500) DEFAULT NULL COMMENT '派发原因',
|
||||
`task_goal` varchar(200) DEFAULT NULL COMMENT '训练目标',
|
||||
`task_requirements` varchar(500) DEFAULT NULL COMMENT '任务要求',
|
||||
`due_time` datetime DEFAULT NULL COMMENT '截止时间',
|
||||
`status` varchar(30) NOT NULL DEFAULT '待训练' COMMENT '状态',
|
||||
`due_date` date DEFAULT NULL COMMENT '训练截止日期',
|
||||
`request_key` varchar(100) DEFAULT NULL COMMENT '客户端幂等请求ID',
|
||||
|
||||
@@ -21,6 +21,8 @@ CREATE TABLE IF NOT EXISTS `aihr_knowledge_answer_feedback` (
|
||||
`query_norm` varchar(500) NOT NULL COMMENT '规范化问题',
|
||||
`fragment_id` bigint NOT NULL COMMENT '知识片段ID',
|
||||
`verdict` varchar(10) NOT NULL COMMENT '反馈: up/down',
|
||||
`feedback_reason_codes` varchar(255) DEFAULT NULL COMMENT '未解决原因代码',
|
||||
`feedback_comment` varchar(500) DEFAULT NULL COMMENT '未解决补充说明',
|
||||
`category` varchar(100) DEFAULT NULL COMMENT '知识分类',
|
||||
`position` varchar(80) DEFAULT NULL COMMENT '岗位',
|
||||
`source` varchar(50) DEFAULT 'knowledge_search' COMMENT '来源',
|
||||
@@ -59,6 +61,38 @@ PREPARE aihr_feedback_review_id_stmt FROM @aihr_feedback_review_id_ddl;
|
||||
EXECUTE aihr_feedback_review_id_stmt;
|
||||
DEALLOCATE PREPARE aihr_feedback_review_id_stmt;
|
||||
|
||||
SET @aihr_feedback_reason_codes_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_knowledge_answer_feedback'
|
||||
AND COLUMN_NAME = 'feedback_reason_codes'
|
||||
);
|
||||
SET @aihr_feedback_reason_codes_ddl := IF(
|
||||
@aihr_feedback_table_exists = 1 AND @aihr_feedback_reason_codes_exists = 0,
|
||||
'ALTER TABLE aihr_knowledge_answer_feedback ADD COLUMN `feedback_reason_codes` varchar(255) DEFAULT NULL COMMENT ''未解决原因代码'' AFTER `verdict`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_feedback_reason_codes_stmt FROM @aihr_feedback_reason_codes_ddl;
|
||||
EXECUTE aihr_feedback_reason_codes_stmt;
|
||||
DEALLOCATE PREPARE aihr_feedback_reason_codes_stmt;
|
||||
|
||||
SET @aihr_feedback_comment_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_knowledge_answer_feedback'
|
||||
AND COLUMN_NAME = 'feedback_comment'
|
||||
);
|
||||
SET @aihr_feedback_comment_ddl := IF(
|
||||
@aihr_feedback_table_exists = 1 AND @aihr_feedback_comment_exists = 0,
|
||||
'ALTER TABLE aihr_knowledge_answer_feedback ADD COLUMN `feedback_comment` varchar(500) DEFAULT NULL COMMENT ''未解决补充说明'' AFTER `feedback_reason_codes`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_feedback_comment_stmt FROM @aihr_feedback_comment_ddl;
|
||||
EXECUTE aihr_feedback_comment_stmt;
|
||||
DEALLOCATE PREPARE aihr_feedback_comment_stmt;
|
||||
|
||||
SET @aihr_feedback_reviewer_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
-- AIHR 主管训练指派字段契约(MySQL 8.x)
|
||||
-- 补齐训练目标、任务要求和截止时间;不写入业务数据,可重复执行。
|
||||
|
||||
SET @aihr_assignment_table_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.TABLES
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_assignment'
|
||||
);
|
||||
|
||||
SET @aihr_assignment_goal_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_assignment'
|
||||
AND COLUMN_NAME = 'task_goal'
|
||||
);
|
||||
SET @aihr_assignment_goal_ddl := IF(
|
||||
@aihr_assignment_table_exists = 1 AND @aihr_assignment_goal_exists = 0,
|
||||
'ALTER TABLE aihr_practice_assignment ADD COLUMN `task_goal` varchar(200) DEFAULT NULL COMMENT ''训练目标'' AFTER `reason`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_assignment_goal_stmt FROM @aihr_assignment_goal_ddl;
|
||||
EXECUTE aihr_assignment_goal_stmt;
|
||||
DEALLOCATE PREPARE aihr_assignment_goal_stmt;
|
||||
|
||||
SET @aihr_assignment_requirements_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_assignment'
|
||||
AND COLUMN_NAME = 'task_requirements'
|
||||
);
|
||||
SET @aihr_assignment_requirements_ddl := IF(
|
||||
@aihr_assignment_table_exists = 1 AND @aihr_assignment_requirements_exists = 0,
|
||||
'ALTER TABLE aihr_practice_assignment ADD COLUMN `task_requirements` varchar(500) DEFAULT NULL COMMENT ''任务要求'' AFTER `task_goal`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_assignment_requirements_stmt FROM @aihr_assignment_requirements_ddl;
|
||||
EXECUTE aihr_assignment_requirements_stmt;
|
||||
DEALLOCATE PREPARE aihr_assignment_requirements_stmt;
|
||||
|
||||
SET @aihr_assignment_due_exists := (
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'aihr_practice_assignment'
|
||||
AND COLUMN_NAME = 'due_time'
|
||||
);
|
||||
SET @aihr_assignment_due_ddl := IF(
|
||||
@aihr_assignment_table_exists = 1 AND @aihr_assignment_due_exists = 0,
|
||||
'ALTER TABLE aihr_practice_assignment ADD COLUMN `due_time` datetime DEFAULT NULL COMMENT ''截止时间'' AFTER `task_requirements`',
|
||||
'SELECT 1'
|
||||
);
|
||||
PREPARE aihr_assignment_due_stmt FROM @aihr_assignment_due_ddl;
|
||||
EXECUTE aihr_assignment_due_stmt;
|
||||
DEALLOCATE PREPARE aihr_assignment_due_stmt;
|
||||
Reference in New Issue
Block a user