优化
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -462,6 +462,22 @@ class UnifiedOrderQueryServiceTest {
|
||||
pageOrders.stream().map(OrderEntity::getId).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
void platformPageKeepsOrderListAvailableWhenColoadSummaryIsUnavailable() {
|
||||
UnifiedOrderQuery query = query("PENDING_REVIEW");
|
||||
OrderEntity order = order(OrderStatus.SUBMITTED);
|
||||
when(orders.unifiedPage(eq(10001L), eq(query), eq(List.of(OrderStatus.SUBMITTED))))
|
||||
.thenReturn(new PageResult<>(List.of(order), 1, 20, 1, 1));
|
||||
when(coloadGroups.batchQuery(eq("internal-token"), any()))
|
||||
.thenThrow(new RuntimeException("firstleg unavailable"));
|
||||
|
||||
assertThat(service.platformPage(10001L, query).records())
|
||||
.singleElement().satisfies(row -> {
|
||||
assertThat(row.orderId()).isEqualTo(order.getId());
|
||||
assertThat(row.coLoadGroup()).isNull();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void platformDetailIncludesColoadBusinessSummary() {
|
||||
OrderEntity order = order(OrderStatus.APPROVED);
|
||||
|
||||
Reference in New Issue
Block a user