fix(aihr): close Figma UI regression gaps
This commit is contained in:
+40
-1
@@ -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(
|
||||
|
||||
+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) {
|
||||
|
||||
+59
-9
@@ -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<PracticeAssignmentResponse> 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`");
|
||||
|
||||
+36
-3
@@ -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<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条可执行步骤,每条以「一、」「二、」「三、」「四、」「五、」开头,包含责任人、动作、时限或留痕要求;"
|
||||
@@ -308,6 +311,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");
|
||||
@@ -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<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) {
|
||||
|
||||
+20
@@ -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");
|
||||
|
||||
+18
@@ -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<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 '状态',
|
||||
`answer_text` varchar(1000) DEFAULT NULL COMMENT '每日三题作答',
|
||||
`answer_audio_url` varchar(500) DEFAULT NULL COMMENT '每日三题语音回放地址',
|
||||
|
||||
@@ -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