|
|
@@ -62,6 +62,12 @@ public class AIChatController {
|
|
|
@Resource
|
|
|
private com.etotem.cfc.service.PortraitService portraitService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private com.etotem.cfc.mapper.FiveDimensionSelfCheckMapper selfCheckMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private com.fasterxml.jackson.databind.ObjectMapper objectMapper;
|
|
|
+
|
|
|
@Operation(summary = "发送聊天消息(支持传入reportId以解读报告)")
|
|
|
@PostMapping("/chat/send")
|
|
|
public Result<Map<String, Object>> sendMessage(
|
|
|
@@ -71,6 +77,7 @@ public class AIChatController {
|
|
|
String conversationId = params.get("conversationId");
|
|
|
String reportIdStr = params.get("reportId");
|
|
|
String surveyIdStr = params.get("surveyId");
|
|
|
+ String selfCheckIdStr = params.get("selfCheckId");
|
|
|
|
|
|
if (query == null || query.trim().isEmpty()) {
|
|
|
return Result.error("消息不能为空");
|
|
|
@@ -121,6 +128,19 @@ public class AIChatController {
|
|
|
inputs.put("portrait_prompt", chatPortrait);
|
|
|
}
|
|
|
|
|
|
+ // 注入自检上下文(P1-2)
|
|
|
+ if (selfCheckIdStr != null && !selfCheckIdStr.trim().isEmpty()) {
|
|
|
+ try {
|
|
|
+ Long selfCheckId = Long.valueOf(selfCheckIdStr);
|
|
|
+ com.etotem.cfc.entity.FiveDimensionSelfCheck selfCheck = selfCheckMapper.selectById(selfCheckId);
|
|
|
+ if (selfCheck != null) {
|
|
|
+ inputs.put("self_check_result", objectMapper.writeValueAsString(selfCheck));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("注入自检上下文失败: {}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// AI记忆层注入(会话摘要+关键事实)
|
|
|
inputs = aiService.enrichInputsWithMemory(userId, conversationId, inputs);
|
|
|
|