From 5d82b29c53dde47999e19467f11beca8b070a6aa Mon Sep 17 00:00:00 2001 From: andy Date: Sun, 12 Jul 2026 17:22:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85SuperAgent=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=9C=AA=E5=91=BD=E4=B8=AD=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReservationAiTaskIntakeServiceImpl.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/cn/nianxx/thhotel/workflows/reservation/service/impl/ReservationAiTaskIntakeServiceImpl.java b/server/src/main/java/cn/nianxx/thhotel/workflows/reservation/service/impl/ReservationAiTaskIntakeServiceImpl.java index fd979c1..5cd75a0 100644 --- a/server/src/main/java/cn/nianxx/thhotel/workflows/reservation/service/impl/ReservationAiTaskIntakeServiceImpl.java +++ b/server/src/main/java/cn/nianxx/thhotel/workflows/reservation/service/impl/ReservationAiTaskIntakeServiceImpl.java @@ -39,6 +39,8 @@ import java.util.HexFormat; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.dao.DuplicateKeyException; import org.springframework.http.HttpStatus; @@ -51,6 +53,8 @@ import org.springframework.transaction.annotation.Transactional; @Service public class ReservationAiTaskIntakeServiceImpl implements ReservationAiTaskIntakeService { + private static final Logger LOGGER = LoggerFactory.getLogger(ReservationAiTaskIntakeServiceImpl.class); + private static final String FIELD_CONTRACT_VERSION = "20260711-p0"; private static final String BATCH_KEY_PREFIX = "superagent-task-result-batch:v1"; private static final String ITEM_KEY_PREFIX = "superagent-task-result-item:v1"; @@ -1658,7 +1662,15 @@ public class ReservationAiTaskIntakeServiceImpl implements ReservationAiTaskInta throw error(HttpStatus.BAD_REQUEST, "HOTEL_ID_REQUIRED", "使用外部 source_message_id 时 hotel_id 不能为空。"); } SourceMessageInboxSnapshot sourceMessage = sourceMessageInboxRepository.findById(sourceMessageId) - .orElseThrow(() -> error(HttpStatus.NOT_FOUND, "SOURCE_MESSAGE_NOT_FOUND", "SourceMessage 不存在。")); + .orElse(null); + if (sourceMessage == null) { + LOGGER.warn( + "SuperAgent 任务结果未匹配 SourceMessage:lookupMode=legacy_internal_id, " + + "sourceMessageId={}, expectedHotelId={}", + rawId, + expectedHotelId); + throw error(HttpStatus.NOT_FOUND, "SOURCE_MESSAGE_NOT_FOUND", "SourceMessage 不存在。"); + } if (expectedHotelId != null && !expectedHotelId.equals(sourceMessage.hotelId())) { throw error(HttpStatus.BAD_REQUEST, "HOTEL_ID_MISMATCH", "SourceMessage 所属酒店与系统酒店不一致。"); } @@ -1675,6 +1687,11 @@ public class ReservationAiTaskIntakeServiceImpl implements ReservationAiTaskInta List candidates = sourceMessageInboxRepository.findByExternalMessageId(hotelId, externalSourceMessageId); if (candidates.isEmpty()) { + LOGGER.warn( + "SuperAgent 入口结果未匹配 SourceMessage:lookupMode=external_message_id, " + + "hotelId={}, sourceMessageId={}", + hotelId, + externalSourceMessageId); throw error(HttpStatus.NOT_FOUND, "SOURCE_MESSAGE_NOT_FOUND", "SourceMessage 不存在。"); } if (candidates.size() > 1) { @@ -1696,6 +1713,12 @@ public class ReservationAiTaskIntakeServiceImpl implements ReservationAiTaskInta if (allowLegacyInternalFallback && isLongText(sourceMessageReference)) { return resolveLegacyInternalSourceMessage(sourceMessageReference, hotelId); } + LOGGER.warn( + "SuperAgent 任务结果未匹配 SourceMessage:lookupMode=external_message_id, " + + "hotelId={}, sourceMessageId={}, legacyFallbackAllowed={}", + hotelId, + sourceMessageReference, + allowLegacyInternalFallback); throw error(HttpStatus.NOT_FOUND, "SOURCE_MESSAGE_NOT_FOUND", "SourceMessage 不存在。"); } if (candidates.size() > 1) {