This commit is contained in:
2026-09-23 09:59:39 +08:00
parent c26b68c53a
commit 52fad8505b
2 changed files with 31 additions and 4 deletions
@@ -18,6 +18,8 @@ import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -36,6 +38,7 @@ import java.util.stream.Collectors;
/** Product-level read façade. Existing Order and Firstleg state machines stay unchanged. */
@Service
public class UnifiedOrderQueryService {
private static final Logger LOGGER = LoggerFactory.getLogger(UnifiedOrderQueryService.class);
private static final Set<String> MAIN_STATUSES = Set.of(
"PENDING_REVIEW", "WAIT_MEASURE", "WAIT_PALLETIZE", "INBOUNDED", "WAIT_SPLIT",
"LOADING", "LOADED", "DELIVERED", "COMPLETED");
@@ -251,10 +254,18 @@ public class UnifiedOrderQueryService {
private Map<Long, UnifiedOrderResponse.CoLoadGroupSummary> coLoadGroups(
List<Long> orderIds, boolean includeCoLoadGroups) {
if (!includeCoLoadGroups || orderIds.isEmpty()) return Map.of();
List<FirstlegColoadGroupClient.OrderGroupInfo> data = require(
call(() -> coloadGroups.batchQuery(internalToken,
new FirstlegColoadGroupClient.BatchQueryRequest(orderIds.stream().distinct().toList()))),
"同柜组摘要响应无效");
List<FirstlegColoadGroupClient.OrderGroupInfo> data;
try {
data = require(
call(() -> coloadGroups.batchQuery(internalToken,
new FirstlegColoadGroupClient.BatchQueryRequest(orderIds.stream().distinct().toList()))),
"同柜组摘要响应无效");
} catch (BizException exception) {
// Co-load data is a supplementary list decoration. A temporary Firstleg/token/schema
// failure must not make the authoritative Order list unavailable.
LOGGER.warn("读取同柜组摘要失败,继续返回订单列表: orderCount={}", orderIds.size(), exception);
return Map.of();
}
List<Long> memberOrderIds = data.stream().filter(Objects::nonNull)
.map(FirstlegColoadGroupClient.OrderGroupInfo::group).filter(Objects::nonNull)
.flatMap(group -> safeMembers(group).stream())