性能优化:N+1查询改批量、串行远程调用并发化、紫鸟索引巡检批量回写
Build Backend JAR / build (push) Has been cancelled

This commit is contained in:
2026-08-25 19:42:43 +08:00
parent 338493ecaa
commit 5f519f9cd5
14 changed files with 425 additions and 53 deletions
@@ -136,9 +136,12 @@ public class QueryAsinResolveService {
if (ordered.isEmpty()) {
throw new BusinessException("shop_names 无有效店铺名");
}
List<QueryAsinEntity> allAsins = queryAsinMapper.selectList(
new LambdaQueryWrapper<QueryAsinEntity>().orderByAsc(QueryAsinEntity::getId));
List<QueryAsinCountryAsinsDto> preloadedQueryAsins = toCountryAsins(allAsins);
ProductRiskMatchShopsVo vo = new ProductRiskMatchShopsVo();
for (String shopName : ordered) {
vo.getItems().add(matchOneShop(request.getUserId(), shopName));
vo.getItems().add(matchOneShop(shopName, preloadedQueryAsins));
}
return vo;
}
@@ -161,7 +164,8 @@ public class QueryAsinResolveService {
return count == null ? 0L : count;
}
private ProductRiskShopQueueItemVo matchOneShop(Long userId, String shopName) {
private ProductRiskShopQueueItemVo matchOneShop(String shopName,
List<QueryAsinCountryAsinsDto> preloadedQueryAsins) {
ProductRiskShopQueueItemVo item = new ProductRiskShopQueueItemVo();
item.setShopName(shopName);
try {
@@ -180,7 +184,7 @@ public class QueryAsinResolveService {
item.setMatchStatus(matched.getMatchStatus());
item.setMatchMessage(matched.getMatchMessage());
item.setOpenStoreUrl(matched.getOpenStoreUrl());
item.setQueryAsins(loadQueryAsinsForShop(userId, shopName));
item.setQueryAsins(preloadedQueryAsins);
if (item.isMatched() && item.getQueryAsins().isEmpty()) {
item.setMatchMessage("紫鸟已匹配,但后台查询 ASIN 表暂无数据");
}