补充SuperAgent来源消息未命中日志

This commit is contained in:
andy
2026-07-12 17:22:38 +08:00
parent 8d8fae670a
commit 5d82b29c53

View File

@@ -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 任务结果未匹配 SourceMessagelookupMode=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<SourceMessageInboxSnapshot> candidates =
sourceMessageInboxRepository.findByExternalMessageId(hotelId, externalSourceMessageId);
if (candidates.isEmpty()) {
LOGGER.warn(
"SuperAgent 入口结果未匹配 SourceMessagelookupMode=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 任务结果未匹配 SourceMessagelookupMode=external_message_id, "
+ "hotelId={}, sourceMessageId={}, legacyFallbackAllowed={}",
hotelId,
sourceMessageReference,
allowLegacyInternalFallback);
throw error(HttpStatus.NOT_FOUND, "SOURCE_MESSAGE_NOT_FOUND", "SourceMessage 不存在。");
}
if (candidates.size() > 1) {