|
|
@@ -438,27 +438,22 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
// 3. 关联账号必须可用 (useStatus == "0") 且可报价 (quoteStatus == "0")
|
|
|
// 过滤后如果某保司没有任何有效协议,会被下面的 removeIf 自动排除
|
|
|
if (CollUtil.isNotEmpty(companyList)) {
|
|
|
- // 1. 收集所有需要校验的归属账号 id(去重)
|
|
|
+ // 1. 收集所有需要校验的归属账号 id
|
|
|
List<String> attributionIds = companyList.stream()
|
|
|
.flatMap(c -> Optional.ofNullable(c.getAgreements()).orElse(Collections.emptyList()).stream())
|
|
|
.map(PtlAgreement::getAttributionId)
|
|
|
.filter(StrUtil::isNotBlank)
|
|
|
- .distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
// 2. 并行批量查询归属账号,构建 id -> 账号信息 索引(避免逐协议串行 RPC)
|
|
|
- Map<String, PtlAgreementAttribution> attributionMap;
|
|
|
+ Map<String, PtlAgreementAttribution> attributionMap = Map.of();
|
|
|
if (CollUtil.isNotEmpty(attributionIds)) {
|
|
|
- attributionMap = attributionIds.parallelStream().collect(HashMap::new, (map, id) -> {
|
|
|
- try {
|
|
|
- HttpResult<PtlAgreementAttribution> res = platformClient.getAgreementAttribution2(id);
|
|
|
- if (res.getCode() == 200 && res.getData() != null) {
|
|
|
- map.put(id, res.getData());
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.warn("批量查询协议归属账号[{}]异常,默认保留", id, e);
|
|
|
+ HttpResult<List<PtlAgreementAttribution>> batchRes = platformClient.getAgreementAttributionByIds(attributionIds);
|
|
|
+ for (PtlAgreementAttribution attr : batchRes.getData()) {
|
|
|
+ if (attr != null && StrUtil.isBlank(attr.getId())) {
|
|
|
+ attributionMap.put(attr.getId(), attr);
|
|
|
}
|
|
|
- }, HashMap::putAll);
|
|
|
+ }
|
|
|
} else {
|
|
|
attributionMap = Collections.emptyMap();
|
|
|
}
|
|
|
@@ -469,6 +464,7 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
if (CollUtil.isEmpty(agreements)) {
|
|
|
continue;
|
|
|
}
|
|
|
+ Map<String, PtlAgreementAttribution> finalAttributionMap = attributionMap;
|
|
|
List<PtlAgreement> validAgreements = agreements.stream()
|
|
|
// 协议自身状态
|
|
|
.filter(a -> a.getIsEnable() != null && a.getIsEnable() == 0)
|
|
|
@@ -479,7 +475,7 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
if (StrUtil.isBlank(attributionId)) {
|
|
|
return true; // 没有关联账号,不做账号校验
|
|
|
}
|
|
|
- PtlAgreementAttribution attr = attributionMap.get(attributionId);
|
|
|
+ PtlAgreementAttribution attr = finalAttributionMap.get(attributionId);
|
|
|
if (attr == null) {
|
|
|
return true; // 查不到账号信息,默认保留
|
|
|
}
|
|
|
@@ -560,8 +556,8 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
dispatchAttrVo.setCompanyId(vo.getCompanyId());
|
|
|
dispatchAttrVo.setSectionGroups(grouped);
|
|
|
dispatchAttrVos.add(dispatchAttrVo);
|
|
|
+ dispatchRuleVos.getDispatchAttrVos().addAll(dispatchAttrVos);
|
|
|
}
|
|
|
- dispatchRuleVos.getDispatchAttrVos().addAll(dispatchAttrVos);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.warn("批量查询协议调度异常", e);
|