|
|
@@ -65,13 +65,39 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
|
|
|
List<AgreementRulesVo> rulesVos = baseMapper.queryList(agreementId);
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
if(CollUtil.isNotEmpty(rulesVos)){
|
|
|
+ // 预计算相同parentId下的所有规则ID,用于后续费用汇总查询
|
|
|
+ Map<String, List<String>> parentIdToRuleIds = new LinkedHashMap<>();
|
|
|
+ for (AgreementRulesVo vo : rulesVos) {
|
|
|
+ String parentId = vo.getParentId();
|
|
|
+ if (parentId != null && !parentId.isEmpty()) {
|
|
|
+ parentIdToRuleIds.computeIfAbsent(parentId, k -> new ArrayList<>()).add(vo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 相同parentId的规则合并为一条,ruleDescription以","拼接
|
|
|
+ rulesVos = mergeByParentId(rulesVos);
|
|
|
+ // 查询费用:对合并后的规则,匹配同一parentId下所有规则的费用
|
|
|
for (AgreementRulesVo rulesVo : rulesVos) {
|
|
|
- CostAgreementParam param = new CostAgreementParam();
|
|
|
- param.setPtlAgreementId(agreementId);
|
|
|
- param.setCoverRuleId(rulesVo.getId());
|
|
|
- List<CostListVo> costVos = ptlAgreementCostService.queryByAgreementIdAndCoverRuleId(param);
|
|
|
- if(CollUtil.isNotEmpty(costVos)){
|
|
|
- costVos.forEach(cost-> cost.getPtlAgreementCostVoList().forEach(vo->{
|
|
|
+ List<CostListVo> allCostVos = new ArrayList<>();
|
|
|
+ String parentId = rulesVo.getParentId();
|
|
|
+ if (parentId != null && !parentId.isEmpty() && parentIdToRuleIds.containsKey(parentId)) {
|
|
|
+ // 查询同一parentId下所有规则的费用并汇总
|
|
|
+ for (String ruleId : parentIdToRuleIds.get(parentId)) {
|
|
|
+ CostAgreementParam param = new CostAgreementParam();
|
|
|
+ param.setPtlAgreementId(agreementId);
|
|
|
+ param.setCoverRuleId(ruleId);
|
|
|
+ List<CostListVo> costVos = ptlAgreementCostService.queryByAgreementIdAndCoverRuleId(param);
|
|
|
+ if (CollUtil.isNotEmpty(costVos)) {
|
|
|
+ allCostVos.addAll(costVos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ CostAgreementParam param = new CostAgreementParam();
|
|
|
+ param.setPtlAgreementId(agreementId);
|
|
|
+ param.setCoverRuleId(rulesVo.getId());
|
|
|
+ allCostVos = ptlAgreementCostService.queryByAgreementIdAndCoverRuleId(param);
|
|
|
+ }
|
|
|
+ if (CollUtil.isNotEmpty(allCostVos)) {
|
|
|
+ allCostVos.forEach(cost -> cost.getPtlAgreementCostVoList().forEach(vo -> {
|
|
|
LocalDateTime effectiveTime = vo.getEffectiveTime().toInstant()
|
|
|
.atZone(ZoneId.systemDefault())
|
|
|
.toLocalDateTime();
|
|
|
@@ -85,11 +111,9 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
|
|
|
}
|
|
|
|
|
|
}));
|
|
|
- rulesVo.setCostVoList(costVos);
|
|
|
+ rulesVo.setCostVoList(allCostVos);
|
|
|
}
|
|
|
}
|
|
|
- // 相同parentId的规则合并为一条,ruleDescription以","拼接
|
|
|
- rulesVos = mergeByParentId(rulesVos);
|
|
|
}
|
|
|
return rulesVos;
|
|
|
}
|