|
|
@@ -414,6 +414,14 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
|
|
|
/**
|
|
|
* 规则过滤保险公司
|
|
|
+ * <p>
|
|
|
+ * 主流程编排方法,按以下步骤执行:
|
|
|
+ * Step1: 根据权限获取所有保司
|
|
|
+ * Step2: 协议和账号状态过滤
|
|
|
+ * Step3: 业务员归属权限过滤
|
|
|
+ * Step4: 方案匹配 + 费用规则校验 + 过滤不匹配方案的保司
|
|
|
+ * Step5: 构建保司结果 VO + 调度规则校验
|
|
|
+ * Step6: 国任车主与投保人不一致时,返回车主约定T0028特约
|
|
|
*
|
|
|
* @param schemeRuleFilterVo 过滤保险公司的条件
|
|
|
* @return List<PtlAgreementInsCompanyVo> 满足报价要求的保险公司以及其下的协议
|
|
|
@@ -425,18 +433,83 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
String userSystemCode = baseController.getUserSystemCode();
|
|
|
String systemCode = baseController.getSystemCode();
|
|
|
log.info("租户匹配保司以及保司下的协议等信息。 schemeRuleFilterVo=[{}],userSystemCode=[{}],systemCode=[{}]", JSONUtil.toJsonStr(schemeRuleFilterVo), userSystemCode, systemCode);
|
|
|
+
|
|
|
+ long totalStart = System.currentTimeMillis();
|
|
|
+
|
|
|
+ // Step1: 根据权限获取所有保司
|
|
|
+ long step1Start = System.currentTimeMillis();
|
|
|
+ log.info("【性能监控】Step1: 根据权限获取所有保司 - 开始");
|
|
|
+ List<EsmInsCompany> companyList = getAuthorizedInsCompanies(systemCode);
|
|
|
+ log.info("【性能监控】Step1: 根据权限获取所有保司 - 结束,耗时[{}]ms", System.currentTimeMillis() - step1Start);
|
|
|
+
|
|
|
+ // Step2: 协议和账号状态过滤
|
|
|
+ long step2Start = System.currentTimeMillis();
|
|
|
+ log.info("【性能监控】Step2: 协议和账号状态过滤 - 开始");
|
|
|
+ filterByAgreementAndAccountStatus(companyList);
|
|
|
+ log.info("【性能监控】Step2: 协议和账号状态过滤 - 结束,耗时[{}]ms", System.currentTimeMillis() - step2Start);
|
|
|
+ log.info("协议/账号状态过滤完成,开始后续业务匹配");
|
|
|
+
|
|
|
+ // Step3: 业务员的归属权限是可选参数,不选的话不进行过滤
|
|
|
+ long step3Start = System.currentTimeMillis();
|
|
|
+ log.info("【性能监控】Step3: 业务员归属权限过滤 - 开始");
|
|
|
+ companyList = salespersonFilterCompanyList(schemeRuleFilterVo, companyList);
|
|
|
+ log.info("【性能监控】Step3: 业务员归属权限过滤 - 结束,耗时[{}]ms", System.currentTimeMillis() - step3Start);
|
|
|
+
|
|
|
+ log.info("根据权限获取到的保司个数是[{}].systemCode=[{}]", CollUtil.size(companyList), systemCode);
|
|
|
+ if (CollUtil.isEmpty(companyList)) {
|
|
|
+ log.info("租户[{}]没有可报价的保险公司,请到平台系统的【租户管理】-【功能配置】页面进行配置并且查看对应公司的协议,费用是否维护好", systemCode);
|
|
|
+ AssertionUtils.isFail(companyList.isEmpty(), "没有可报价的保险公司");
|
|
|
+ }
|
|
|
+
|
|
|
+ // Step4: 根据基本规则匹配方案 + 费用规则校验 + 过滤不匹配方案的保司
|
|
|
+ long step4Start = System.currentTimeMillis();
|
|
|
+ log.info("【性能监控】Step4: 方案匹配+费用规则校验+保司过滤 - 开始");
|
|
|
+ ValidateSchemeRuleVo validateSchemeRuleVo = matchSchemeAndFilterCompany(schemeRuleFilterVo, companyList);
|
|
|
+ log.info("【性能监控】Step4: 方案匹配+费用规则校验+保司过滤 - 结束,耗时[{}]ms", System.currentTimeMillis() - step4Start);
|
|
|
+
|
|
|
+ // Step5: 构建保司结果 VO + 调度规则校验
|
|
|
+ long step5Start = System.currentTimeMillis();
|
|
|
+ log.info("【性能监控】Step5: 构建保司结果VO+调度规则校验 - 开始");
|
|
|
+ List<PtlAgreementInsCompanyVo> resVo = buildResultVoAndApplyDispatch(companyList, validateSchemeRuleVo);
|
|
|
+ log.info("【性能监控】Step5: 构建保司结果VO+调度规则校验 - 结束,耗时[{}]ms", System.currentTimeMillis() - step5Start);
|
|
|
+
|
|
|
+ // Step6: 国任车主与投保人不一致时,返回车主约定T0028特约
|
|
|
+ long step6Start = System.currentTimeMillis();
|
|
|
+ log.info("【性能监控】Step6: 国任T0028特约处理 - 开始");
|
|
|
+ applyOwnerClauseForXDCX(resVo, schemeRuleFilterVo);
|
|
|
+ log.info("【性能监控】Step6: 国任T0028特约处理 - 结束,耗时[{}]ms", System.currentTimeMillis() - step6Start);
|
|
|
+
|
|
|
+ log.info("【性能监控】ruleFilterCompany 全流程结束,总耗时[{}]ms", System.currentTimeMillis() - totalStart);
|
|
|
+ return resVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Step1: 根据权限获取所有保司
|
|
|
+ *
|
|
|
+ * @param systemCode 系统编码
|
|
|
+ * @return 有权限的保司列表
|
|
|
+ */
|
|
|
+ private List<EsmInsCompany> getAuthorizedInsCompanies(String systemCode) {
|
|
|
//根据权限获取所有保司
|
|
|
HttpResult<List<EsmInsCompany>> companyListResult = esmInsCompanyClient.getUserCompany(systemCode);
|
|
|
log.info("租户[{}]有权限的保司有[{}]个", systemCode, CollUtil.size(companyListResult.getData()));
|
|
|
AssertionUtils.isFail(companyListResult.getCode() != 200, companyListResult.getMsg());
|
|
|
- List<EsmInsCompany> companyList = companyListResult.getData();
|
|
|
+ return companyListResult.getData();
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * Step2: 协议和账号状态过滤
|
|
|
+ * <p>
|
|
|
+ * 过滤条件:
|
|
|
+ * 1. 协议必须启用 (isEnable == 0)
|
|
|
+ * 2. 协议必须生效中 (validStatus == "0")
|
|
|
+ * 3. 关联账号必须可用 (useStatus == "0") 且可报价 (quoteStatus == "0")
|
|
|
+ * 过滤后如果某保司没有任何有效协议,会被后续 removeIf 自动排除
|
|
|
+ *
|
|
|
+ * @param companyList 保司列表(原地修改)
|
|
|
+ */
|
|
|
+ private void filterByAgreementAndAccountStatus(List<EsmInsCompany> companyList) {
|
|
|
// ========================= 协议和账号状态过滤 =========================
|
|
|
- // 过滤条件:
|
|
|
- // 1. 协议必须启用 (isEnable == 0)
|
|
|
- // 2. 协议必须生效中 (validStatus == "0")
|
|
|
- // 3. 关联账号必须可用 (useStatus == "0") 且可报价 (quoteStatus == "0")
|
|
|
- // 过滤后如果某保司没有任何有效协议,会被下面的 removeIf 自动排除
|
|
|
if (CollUtil.isNotEmpty(companyList)) {
|
|
|
// 1. 收集所有需要校验的归属账号 id
|
|
|
List<String> attributionIds = companyList.stream()
|
|
|
@@ -485,18 +558,17 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
company.setAgreements(validAgreements);
|
|
|
}
|
|
|
}
|
|
|
- log.info("协议/账号状态过滤完成,开始后续业务匹配");
|
|
|
// ====================================================================
|
|
|
+ }
|
|
|
|
|
|
- // 业务员的归属权限是可选参数,不选的话不进行过滤
|
|
|
- companyList = salespersonFilterCompanyList(schemeRuleFilterVo, companyList);
|
|
|
-
|
|
|
- log.info("根据权限获取到的保司个数是[{}].systemCode=[{}]", CollUtil.size(companyList), systemCode);
|
|
|
- if (CollUtil.isEmpty(companyList)) {
|
|
|
- log.info("租户[{}]没有可报价的保险公司,请到平台系统的【租户管理】-【功能配置】页面进行配置并且查看对应公司的协议,费用是否维护好", systemCode);
|
|
|
- AssertionUtils.isFail(companyList.isEmpty(), "没有可报价的保险公司");
|
|
|
- }
|
|
|
-
|
|
|
+ /**
|
|
|
+ * Step4: 根据基本规则匹配方案 + 费用规则校验 + 过滤不匹配方案的保司
|
|
|
+ *
|
|
|
+ * @param schemeRuleFilterVo 过滤条件
|
|
|
+ * @param companyList 保司列表(原地修改,移除不匹配方案的保司及空协议保司)
|
|
|
+ * @return 方案规则校验 VO(含 quoteVo,供调度规则校验使用)
|
|
|
+ */
|
|
|
+ private ValidateSchemeRuleVo matchSchemeAndFilterCompany(SchemeRuleFilterVo schemeRuleFilterVo, List<EsmInsCompany> companyList) {
|
|
|
//根据基本规则 能源、车辆类型、使用性质获取方案
|
|
|
List<PtlScheme> ptlSchemes = ptlSchemeMapper.selectList(new LambdaQueryWrapper<PtlScheme>()
|
|
|
.eq(PtlScheme::getEnergyType, schemeRuleFilterVo.getCarInfo().getEnergyTypeCode().equals("0") ? "0" : "1")
|
|
|
@@ -529,6 +601,17 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
Set<String> companyIdSet = ptlSchemes.stream().map(PtlScheme::getCompanyId).collect(Collectors.toSet());
|
|
|
// 移除不匹配方案的保司,以及空协议的保司
|
|
|
companyList.removeIf(company -> !companyIdSet.contains(company.getId()) || CollUtil.isEmpty(company.getAgreements()));
|
|
|
+ return validateSchemeRuleVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Step5: 构建保司结果 VO + 调度规则校验
|
|
|
+ *
|
|
|
+ * @param companyList 过滤后的保司列表
|
|
|
+ * @param validateSchemeRuleVo 方案规则校验 VO(提供 quoteVo)
|
|
|
+ * @return 保司结果 VO 列表
|
|
|
+ */
|
|
|
+ private List<PtlAgreementInsCompanyVo> buildResultVoAndApplyDispatch(List<EsmInsCompany> companyList, ValidateSchemeRuleVo validateSchemeRuleVo) {
|
|
|
List<PtlAgreementInsCompanyVo> resVo = new ArrayList<>();
|
|
|
companyList.forEach(company -> {
|
|
|
PtlAgreementInsCompanyVo vo = new PtlAgreementInsCompanyVo();
|
|
|
@@ -540,12 +623,11 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
|
|
|
ValidateDispatchRuleVo dispatchRuleVos = new ValidateDispatchRuleVo();
|
|
|
dispatchRuleVos.setQuoteVo(validateSchemeRuleVo.getQuoteVo());
|
|
|
- //2.协议调度规则数据拼接(一次批量查询所有保司,避免逐保司重复的全表/字典查询与串行 RPC)
|
|
|
+ //2.协议调度规则数据拼接(同项目内直接走 Service 调用,避免 Feign 自调用的 HTTP 往返与序列化开销)
|
|
|
List<String> allCompanyIds = companyList.stream().map(EsmInsCompany::getId).collect(Collectors.toList());
|
|
|
try {
|
|
|
- HttpResult agreementDispatch = orgClient.getAgreementDispatchByCompanyIds(allCompanyIds);
|
|
|
- if (agreementDispatch != null && agreementDispatch.getCode() == 200 && agreementDispatch.getData() != null) {
|
|
|
- PtlAgreementDispatchVo dispatchVoResult = new ObjectMapper().convertValue(agreementDispatch.getData(), PtlAgreementDispatchVo.class);
|
|
|
+ PtlAgreementDispatchVo dispatchVoResult = ptlAgreementDispatchService.getAgreementDispatchByCompanyIds(allCompanyIds);
|
|
|
+ if (dispatchVoResult != null && CollUtil.isNotEmpty(dispatchVoResult.getDispatchVos())) {
|
|
|
List<ValidateDispatchRuleVo.DispatchAttrVo> dispatchAttrVos = new ArrayList<>();
|
|
|
for (PtlAgreementDispatchVo.DispatchVo vo : dispatchVoResult.getDispatchVos()) {
|
|
|
List<PtlAgreementDispatchRulesAttrLink> attrLinks = vo.getAttrLinks();
|
|
|
@@ -556,8 +638,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);
|
|
|
@@ -599,6 +681,16 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ return resVo;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Step6: 国任车主与投保人不一致时,返回车主约定T0028特约
|
|
|
+ *
|
|
|
+ * @param resVo 保司结果 VO 列表
|
|
|
+ * @param schemeRuleFilterVo 过滤条件(含车主、投保人信息)
|
|
|
+ */
|
|
|
+ private void applyOwnerClauseForXDCX(List<PtlAgreementInsCompanyVo> resVo, SchemeRuleFilterVo schemeRuleFilterVo) {
|
|
|
// 国任车主与投保人不一致时,返回车主约定T0028特约
|
|
|
for (PtlAgreementInsCompanyVo company : resVo) {
|
|
|
if ("XDCX".equals(company.getCode())) {
|
|
|
@@ -624,7 +716,6 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- return resVo;
|
|
|
}
|
|
|
/**
|
|
|
* 报价公司过滤入参统一校验
|