diff --git a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrPracticeDto.java b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrPracticeDto.java index d3053d61..c579742f 100644 --- a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrPracticeDto.java +++ b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrPracticeDto.java @@ -252,7 +252,20 @@ public final class AihrPracticeDto { public record PracticeAlertResponse(String type, String title, String desc, String severity, String extPartyId) { } - public record PracticeAssignmentRequest(String extPartyId, String traineeName, String scenarioId, String scenarioName, String source, String reason) { + public record PracticeAssignmentRequest( + String extPartyId, + String traineeName, + String scenarioId, + String scenarioName, + String source, + String reason, + String taskGoal, + String taskRequirements, + String dueTime + ) { + public PracticeAssignmentRequest(String extPartyId, String traineeName, String scenarioId, String scenarioName, String source, String reason) { + this(extPartyId, traineeName, scenarioId, scenarioName, source, reason, null, null, null); + } } public record PracticeAssignmentResponse( @@ -263,6 +276,9 @@ public final class AihrPracticeDto { String scenarioName, String source, String reason, + String taskGoal, + String taskRequirements, + String dueTime, String status, String createTime, String question, @@ -275,6 +291,29 @@ public final class AihrPracticeDto { String audioUrl, Long audioOssId ) { + public PracticeAssignmentResponse( + Long id, + String extPartyId, + String traineeName, + String scenarioId, + String scenarioName, + String source, + String reason, + String status, + String createTime, + String question, + String referenceAnswer, + String userAnswer, + String feedback, + Boolean correct, + Integer score, + String scoreMode, + String audioUrl, + Long audioOssId + ) { + this(id, extPartyId, traineeName, scenarioId, scenarioName, source, reason, null, null, null, + status, createTime, question, referenceAnswer, userAnswer, feedback, correct, score, scoreMode, audioUrl, audioOssId); + } } public record OnboardTaskResponse( diff --git a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrSopDto.java b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrSopDto.java index f9d70a4a..0615df01 100644 --- a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrSopDto.java +++ b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrSopDto.java @@ -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 fragmentIds, String verdict, String category, String position, String source, Long reviewId) { + public record AnswerFeedbackRequest(String queryText, Long fragmentId, List fragmentIds, String verdict, String category, String position, String source, Long reviewId, List 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) { diff --git a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java index 555549e5..279bcfbb 100644 --- a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java +++ b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java @@ -100,6 +100,7 @@ public class AihrPracticeSeedService { "professional", "表达更专业,突出SOP依据、责任边界、留痕和闭环口径。" ); private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("MM-dd HH:mm"); + private static final DateTimeFormatter ASSIGNMENT_DUE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); // 阶段一只统计“员工收到业主话术后到提交下一轮”的陪练响应时长;正式首响/工单处理时效仍需业务系统数据。 private static final long RESPONSE_FAST_MS = 5_000L; private static final long RESPONSE_ACCEPTABLE_MS = 10_000L; @@ -1108,7 +1109,8 @@ public class AihrPracticeSeedService { : "a.ext_party_id"; String nameExpression = !storeDisplayFields ? "'员工'" : "a.trainee_name"; String sql = """ - SELECT id, %s AS ext_party_id, %s AS trainee_name, scenario_id, scenario_name, source, reason, status, create_time, + SELECT id, %s AS ext_party_id, %s AS trainee_name, scenario_id, scenario_name, source, reason, + task_goal, task_requirements, due_time, status, create_time, answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct, score, score_mode FROM aihr_practice_assignment a %s @@ -2024,7 +2026,8 @@ public class AihrPracticeSeedService { ensureDailyDrills(party); String nameExpression = !storeDisplayFields ? "'员工'" : "trainee_name"; return jdbcTemplate.query(""" - SELECT id, ext_party_id, %s AS trainee_name, scenario_id, scenario_name, source, reason, status, create_time, + SELECT id, ext_party_id, %s AS trainee_name, scenario_id, scenario_name, source, reason, + task_goal, task_requirements, due_time, status, create_time, answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct, score, score_mode FROM aihr_practice_assignment WHERE tenant_id = ? @@ -2190,7 +2193,8 @@ public class AihrPracticeSeedService { : "a.ext_party_id"; String nameExpression = !storeDisplayFields ? "'员工'" : "a.trainee_name"; return jdbcTemplate.query(""" - SELECT id, %s AS ext_party_id, %s AS trainee_name, scenario_id, scenario_name, source, reason, status, create_time, + SELECT id, %s AS ext_party_id, %s AS trainee_name, scenario_id, scenario_name, source, reason, + task_goal, task_requirements, due_time, status, create_time, answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct, score, score_mode FROM aihr_practice_assignment a WHERE a.tenant_id = ? @@ -2314,14 +2318,20 @@ public class AihrPracticeSeedService { // must not turn a manual supervisor assignment into a daily/retry/camp record. String source = "manual"; String reason = firstNonBlank(request == null ? null : request.reason(), "主管派发专项训练"); + String taskGoal = limitedAssignmentText(request == null ? null : request.taskGoal(), 200); + String taskRequirements = limitedAssignmentText(request == null ? null : request.taskRequirements(), 500); + Timestamp dueTime = assignmentDueTimestamp(request == null ? null : request.dueTime()); Timestamp createdAt = Timestamp.valueOf(now); jdbcTemplate.update(""" INSERT INTO aihr_practice_assignment - (tenant_id, ext_party_id, trainee_name, scenario_id, scenario_name, source, reason, status, create_time, update_time) - VALUES (?, ?, ?, ?, ?, ?, ?, '待训练', ?, ?) - """, tenantId(), storedExtPartyId, storedTraineeName, scenario.id(), scenario.name(), source, reason, createdAt, createdAt); + (tenant_id, ext_party_id, trainee_name, scenario_id, scenario_name, source, reason, + task_goal, task_requirements, due_time, status, create_time, update_time) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '待训练', ?, ?) + """, tenantId(), storedExtPartyId, storedTraineeName, scenario.id(), scenario.name(), source, reason, + taskGoal, taskRequirements, dueTime, createdAt, createdAt); List rows = jdbcTemplate.query(""" - SELECT id, ext_party_id, trainee_name, scenario_id, scenario_name, source, reason, status, create_time, + SELECT id, ext_party_id, trainee_name, scenario_id, scenario_name, source, reason, + task_goal, task_requirements, due_time, status, create_time, answer_text, answer_audio_url, answer_audio_oss_id, feedback, correct, score, score_mode FROM aihr_practice_assignment WHERE tenant_id = ? AND ext_party_id = ? AND scenario_id = ? AND source = ? AND reason = ? @@ -2330,14 +2340,45 @@ public class AihrPracticeSeedService { """, this::mapAssignment, tenantId(), storedExtPartyId, scenario.id(), source, reason); if (rows.isEmpty()) { return new PracticeAssignmentResponse(null, extPartyId, storeDisplayFields ? traineeName : "员工", - scenario.id(), scenario.name(), source, reason, "待训练", now.format(TIME_FORMATTER), null, null, null, null, null, null, null, null, null); + scenario.id(), scenario.name(), source, reason, taskGoal, taskRequirements, formatAssignmentDueTime(dueTime), + "待训练", now.format(TIME_FORMATTER), null, null, null, null, null, null, null, null, null); } PracticeAssignmentResponse row = rows.get(0); return new PracticeAssignmentResponse(row.id(), extPartyId, storeDisplayFields ? row.traineeName() : "员工", - row.scenarioId(), row.scenarioName(), row.source(), row.reason(), row.status(), row.createTime(), row.question(), + row.scenarioId(), row.scenarioName(), row.source(), row.reason(), row.taskGoal(), row.taskRequirements(), row.dueTime(), + row.status(), row.createTime(), row.question(), row.referenceAnswer(), row.userAnswer(), row.feedback(), row.correct(), row.score(), row.scoreMode(), row.audioUrl(), row.audioOssId()); } + private String limitedAssignmentText(String value, int maxLength) { + if (value == null || value.isBlank()) { + return null; + } + String normalized = value.trim(); + return normalized.length() <= maxLength ? normalized : normalized.substring(0, maxLength); + } + + private Timestamp assignmentDueTimestamp(String value) { + if (value == null || value.isBlank()) { + return null; + } + String normalized = value.trim().replace('T', ' '); + if (normalized.matches("\\d{4}-\\d{2}-\\d{2}")) { + normalized += " 23:59:59"; + } else if (normalized.matches("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}")) { + normalized += ":00"; + } + try { + return Timestamp.valueOf(LocalDateTime.parse(normalized, ASSIGNMENT_DUE_FORMATTER)); + } catch (RuntimeException error) { + throw new ServiceException("截止时间格式应为 YYYY-MM-DD 或 YYYY-MM-DD HH:mm"); + } + } + + private String formatAssignmentDueTime(Timestamp value) { + return value == null ? "" : value.toLocalDateTime().format(ASSIGNMENT_DUE_FORMATTER); + } + public PracticeAssignmentResponse createAssignment(PracticeAssignmentRequest request, String supervisorExtPartyId) { String extPartyId = request == null ? "" : firstNonBlank(request.extPartyId(), ""); if (!inTeamScope(supervisorExtPartyId, extPartyId)) { @@ -3049,6 +3090,9 @@ public class AihrPracticeSeedService { rs.getString("scenario_name"), source, "daily".equals(source) ? daily.question() : reason, + rs.getString("task_goal"), + rs.getString("task_requirements"), + formatAssignmentDueTime(rs.getTimestamp("due_time")), status, createTime == null ? "" : createTime.toLocalDateTime().format(TIME_FORMATTER), "daily".equals(source) ? daily.question() : null, @@ -4020,6 +4064,9 @@ public class AihrPracticeSeedService { `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 '状态', `answer_text` varchar(1000) DEFAULT NULL COMMENT '每日三题作答', `answer_audio_url` varchar(500) DEFAULT NULL COMMENT '每日三题语音回放地址', @@ -4037,6 +4084,9 @@ public class AihrPracticeSeedService { ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='AI HR 对练派发任务'; """); ensureColumn("aihr_practice_assignment", "answer_text", "ALTER TABLE aihr_practice_assignment ADD COLUMN `answer_text` varchar(1000) DEFAULT NULL COMMENT '每日三题作答' AFTER `status`"); + ensureColumn("aihr_practice_assignment", "task_goal", "ALTER TABLE aihr_practice_assignment ADD COLUMN `task_goal` varchar(200) DEFAULT NULL COMMENT '训练目标' AFTER `reason`"); + ensureColumn("aihr_practice_assignment", "task_requirements", "ALTER TABLE aihr_practice_assignment ADD COLUMN `task_requirements` varchar(500) DEFAULT NULL COMMENT '任务要求' AFTER `task_goal`"); + ensureColumn("aihr_practice_assignment", "due_time", "ALTER TABLE aihr_practice_assignment ADD COLUMN `due_time` datetime DEFAULT NULL COMMENT '截止时间' AFTER `task_requirements`"); ensureColumn("aihr_practice_assignment", "answer_audio_url", "ALTER TABLE aihr_practice_assignment ADD COLUMN `answer_audio_url` varchar(500) DEFAULT NULL COMMENT '每日三题语音回放地址' AFTER `answer_text`"); ensureColumn("aihr_practice_assignment", "answer_audio_oss_id", "ALTER TABLE aihr_practice_assignment ADD COLUMN `answer_audio_oss_id` bigint DEFAULT NULL COMMENT '每日三题语音OSS编号' AFTER `answer_audio_url`"); ensureColumn("aihr_practice_assignment", "feedback", "ALTER TABLE aihr_practice_assignment ADD COLUMN `feedback` varchar(1000) DEFAULT NULL COMMENT '每日三题反馈' AFTER `answer_audio_oss_id`"); diff --git a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrSopSeedService.java b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrSopSeedService.java index fc4e3da2..5bd2855f 100644 --- a/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrSopSeedService.java +++ b/backend/ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrSopSeedService.java @@ -103,6 +103,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 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条可执行步骤,每条以「一、」「二、」「三、」「四、」「五、」开头,包含责任人、动作、时限或留痕要求;" @@ -308,6 +311,14 @@ public class AihrSopSeedService { if (isBlank(verdict)) { throw new ServiceException("反馈类型只支持 up/down"); } + List 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 fragmentIds = feedbackFragmentIds(request); if (fragmentIds.isEmpty()) { throw new ServiceException("缺少片段ID"); @@ -321,11 +332,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), @@ -338,6 +351,8 @@ public class AihrSopSeedService { normalizeFeedbackQuery(AihrSensitiveText.forModel(queryText)), fragmentId, verdict, + feedbackReasonCodes, + feedbackComment, firstNonBlank(request.category(), "sop"), firstNonBlank(request.position(), "生活顾问"), normalizeSearchSource(request.source()), @@ -355,7 +370,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 = ?) @@ -367,6 +382,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"), @@ -2125,6 +2142,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 '来源', @@ -2141,6 +2160,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; @@ -2208,6 +2229,18 @@ public class AihrSopSeedService { return "up".equals(verdict) || "down".equals(verdict) ? verdict : ""; } + private static List normalizeFeedbackReasons(List 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 feedbackFragmentIds(AnswerFeedbackRequest request) { LinkedHashSet ids = new LinkedHashSet<>(); if (request != null && request.fragmentIds() != null) { diff --git a/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrPracticeSeedServiceTest.java b/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrPracticeSeedServiceTest.java index a49906c1..4e5ddd31 100644 --- a/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrPracticeSeedServiceTest.java +++ b/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrPracticeSeedServiceTest.java @@ -113,6 +113,26 @@ public class AihrPracticeSeedServiceTest { assertEquals("缺少员工ID,无法派发专项训练", error.getMessage()); } + @Test + public void assignmentContractPersistsDeadlineGoalAndRequirements() throws Exception { + Path dto = Path.of("src/main/java/org/dromara/aihr/domain/AihrPracticeDto.java"); + Path service = Path.of("src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java"); + if (!Files.exists(dto)) { + dto = Path.of("ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/domain/AihrPracticeDto.java"); + service = Path.of("ruoyi-modules/ruoyi-aihr/src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java"); + } + + String dtoCode = Files.readString(dto); + String serviceCode = Files.readString(service); + + assertTrue(dtoCode.contains("String taskGoal")); + assertTrue(dtoCode.contains("String taskRequirements")); + assertTrue(dtoCode.contains("String dueTime")); + assertTrue(serviceCode.contains("task_goal")); + assertTrue(serviceCode.contains("task_requirements")); + assertTrue(serviceCode.contains("due_time")); + } + @Test public void historyAndReviewDetailUseDisplayFieldPrivacyContract() throws Exception { Path source = Path.of("src/main/java/org/dromara/aihr/service/AihrPracticeSeedService.java"); diff --git a/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrSopSeedServiceTest.java b/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrSopSeedServiceTest.java index d3ac99bc..5c7de2d9 100644 --- a/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrSopSeedServiceTest.java +++ b/backend/ruoyi-modules/ruoyi-aihr/src/test/java/org/dromara/aihr/service/AihrSopSeedServiceTest.java @@ -342,6 +342,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 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 { diff --git a/backend/script/sql/aihr_practice_mysql8.sql b/backend/script/sql/aihr_practice_mysql8.sql index 11c240a4..093dc61e 100644 --- a/backend/script/sql/aihr_practice_mysql8.sql +++ b/backend/script/sql/aihr_practice_mysql8.sql @@ -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 '状态', `answer_text` varchar(1000) DEFAULT NULL COMMENT '每日三题作答', `answer_audio_url` varchar(500) DEFAULT NULL COMMENT '每日三题语音回放地址', diff --git a/backend/script/sql/update/aihr_20260715_knowledge_feedback_mysql8.sql b/backend/script/sql/update/aihr_20260715_knowledge_feedback_mysql8.sql index 715b6fa3..61aaf8e0 100644 --- a/backend/script/sql/update/aihr_20260715_knowledge_feedback_mysql8.sql +++ b/backend/script/sql/update/aihr_20260715_knowledge_feedback_mysql8.sql @@ -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 diff --git a/backend/script/sql/update/aihr_20260717_practice_assignment_contract_mysql8.sql b/backend/script/sql/update/aihr_20260717_practice_assignment_contract_mysql8.sql new file mode 100644 index 00000000..5cd2dcd2 --- /dev/null +++ b/backend/script/sql/update/aihr_20260717_practice_assignment_contract_mysql8.sql @@ -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; diff --git a/docs/BRD_PRODUCTION_MIGRATION_RUNBOOK.md b/docs/BRD_PRODUCTION_MIGRATION_RUNBOOK.md index a6c1d515..e64fac96 100644 --- a/docs/BRD_PRODUCTION_MIGRATION_RUNBOOK.md +++ b/docs/BRD_PRODUCTION_MIGRATION_RUNBOOK.md @@ -35,6 +35,7 @@ mysql --default-character-set=utf8mb4 "$DB_NAME" < backend/script/sql/update/aih mysql --default-character-set=utf8mb4 "$DB_NAME" < backend/script/sql/update/aihr_20260714_case_learning_mysql8.sql mysql --default-character-set=utf8mb4 "$DB_NAME" < backend/script/sql/update/aihr_20260714_practice_five_dimensions_mysql8.sql mysql --default-character-set=utf8mb4 "$DB_NAME" < backend/script/sql/update/aihr_20260715_practice_session_evidence_mysql8.sql +mysql --default-character-set=utf8mb4 "$DB_NAME" < backend/script/sql/update/aihr_20260717_practice_assignment_contract_mysql8.sql mysql --default-character-set=utf8mb4 "$DB_NAME" < backend/script/sql/update/aihr_20260714_daily_drill_score_mode_mysql8.sql mysql --default-character-set=utf8mb4 "$DB_NAME" < backend/script/sql/update/aihr_20260714_sop_requester_identity_mysql8.sql mysql --default-character-set=utf8mb4 "$DB_NAME" < backend/script/sql/update/aihr_20260715_knowledge_feedback_mysql8.sql @@ -68,7 +69,7 @@ WHERE table_schema = DATABASE() AND ( (table_name = 'aihr_case_record' AND column_name IN ('media_oss_id', 'media_url', 'learning_points', 'supervisor_comment')) OR (table_name = 'aihr_practice_session' AND column_name IN ('dim_task_completion', 'dim_response_timeliness', 'response_latency_ms', 'annotations_json', 'review_advice', 'incentive_point', 'satisfaction_score', 'satisfaction_comment')) - OR (table_name = 'aihr_practice_assignment' AND column_name IN ('score', 'score_mode')) + OR (table_name = 'aihr_practice_assignment' AND column_name IN ('score', 'score_mode', 'task_goal', 'task_requirements', 'due_time')) OR (table_name = 'aihr_sop_answer_review' AND column_name IN ('prompt_version', 'requester_ext_party_id')) OR (table_name = 'aihr_org_snapshot' AND column_name = 'hire_date') OR (table_name = 'aihr_candidate_material' AND column_name IN ('reviewer', 'reviewed_time')) diff --git a/frontend/src/api/aihr/sop.ts b/frontend/src/api/aihr/sop.ts index d88c0fb0..03876b9a 100644 --- a/frontend/src/api/aihr/sop.ts +++ b/frontend/src/api/aihr/sop.ts @@ -57,6 +57,8 @@ export type AnswerFeedbackItem = { queryNorm: string; fragmentId: number; verdict: string; + feedbackReasonCodes?: string | null; + feedbackComment?: string | null; category: string; position: string; source: string; diff --git a/frontend/src/views/knowledge/sop.vue b/frontend/src/views/knowledge/sop.vue index 2f3871f1..ec91380d 100644 --- a/frontend/src/views/knowledge/sop.vue +++ b/frontend/src/views/knowledge/sop.vue @@ -113,6 +113,8 @@ {{ row.verdict === 'down' ? '没解决' : row.verdict }} + + diff --git a/mobile-uni/package-lock.json b/mobile-uni/package-lock.json index 4a3da4da..adb7d471 100644 --- a/mobile-uni/package-lock.json +++ b/mobile-uni/package-lock.json @@ -11,6 +11,7 @@ "@dcloudio/uni-app": "3.0.0-alpha-5020120260706001", "@dcloudio/uni-h5": "3.0.0-alpha-5020120260706001", "@dcloudio/uni-ui": "^1.5.12", + "lxgw-wenkai-tc-webfont": "^1.0.0", "vue": "3.5.30" }, "devDependencies": { @@ -5816,6 +5817,12 @@ "yallist": "^3.0.2" } }, + "node_modules/lxgw-wenkai-tc-webfont": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/lxgw-wenkai-tc-webfont/-/lxgw-wenkai-tc-webfont-1.0.0.tgz", + "integrity": "sha512-LOGglSMNw6Nufn+ULaSjliwNwtkCE1cwXuayN09pg+KMDGD5XxxGrAbca1Ap+YdP4NLotdBDKi5wmUXbgqTxHg==", + "license": "MIT" + }, "node_modules/magic-string": { "version": "0.30.11", "resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.30.11.tgz", diff --git a/mobile-uni/package.json b/mobile-uni/package.json index 17f076d5..6f7e475d 100644 --- a/mobile-uni/package.json +++ b/mobile-uni/package.json @@ -15,6 +15,7 @@ "@dcloudio/uni-app": "3.0.0-alpha-5020120260706001", "@dcloudio/uni-h5": "3.0.0-alpha-5020120260706001", "@dcloudio/uni-ui": "^1.5.12", + "lxgw-wenkai-tc-webfont": "^1.0.0", "vue": "3.5.30" }, "devDependencies": { diff --git a/mobile-uni/public/licenses/LXGW-WENKAI-TC-OFL-1.1.txt b/mobile-uni/public/licenses/LXGW-WENKAI-TC-OFL-1.1.txt new file mode 100644 index 00000000..199a917c --- /dev/null +++ b/mobile-uni/public/licenses/LXGW-WENKAI-TC-OFL-1.1.txt @@ -0,0 +1,91 @@ +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/mobile-uni/src/pages/supervisor/assign/index.vue b/mobile-uni/src/pages/supervisor/assign/index.vue index 86277274..d314ad80 100644 --- a/mobile-uni/src/pages/supervisor/assign/index.vue +++ b/mobile-uni/src/pages/supervisor/assign/index.vue @@ -28,7 +28,28 @@