|
|
@@ -414,6 +414,8 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
|
|
|
|
|
|
Map<String, String> userName2Name = sysUserJzgInfoService.queryUserInfoUserName2Name(baseController.getSystemCode());
|
|
|
Page<CostManagementVo> costManagementVoPage = baseMapper.pageList(costParam.getPage(), costParam);
|
|
|
+ // 按承保规则属性 sort 正序,重新排列 cost_rules 各段描述
|
|
|
+ reorderCostRules(costManagementVoPage.getRecords());
|
|
|
costManagementVoPage.getRecords().forEach(item->{
|
|
|
if(item.getCostRules() != null && !item.getCostRules().isEmpty()){
|
|
|
item.setCostRules(item.getCostRules().substring(0,item.getCostRules().length()-1));
|
|
|
@@ -428,6 +430,67 @@ public class PtlAgreementCostServiceImpl extends ServiceImpl<PtlAgreementCostMap
|
|
|
return HttpResult.ok(costManagementVoPage);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 重新排序费用规则描述(cost_rules)
|
|
|
+ * 流程:
|
|
|
+ * 1. 查询所有 ptl_agreement_undwrt_rules_attr,按 sort 正序排列
|
|
|
+ * 2. 将 cost_rules 按 ";\t\t" 分段
|
|
|
+ * 3. 用 contains 判断每段包含哪个属性名(attr_name),按 sort 顺序重新排列各段
|
|
|
+ * 4. 重新拼接并赋值 cost_rules
|
|
|
+ *
|
|
|
+ * @param records 费用管理分页记录
|
|
|
+ */
|
|
|
+ private void reorderCostRules(List<CostManagementVo> records) {
|
|
|
+ if (CollectionUtils.isEmpty(records)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 查询所有承保规则属性,按 sort 正序排列
|
|
|
+ List<PtlAgreementUndwrtRulesAttr> sortedAttrs = agreementUndwrtRulesAttrService.getUndwrtRulesAttrList().stream()
|
|
|
+ .filter(attr -> StrUtil.isNotEmpty(attr.getAttrName()))
|
|
|
+ .sorted(Comparator.comparing(PtlAgreementUndwrtRulesAttr::getSort, Comparator.nullsLast(Integer::compareTo)))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (sortedAttrs.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // cost_rules 各段以 ";\t\t" 分隔
|
|
|
+ String separator = ";\t\t";
|
|
|
+ for (CostManagementVo item : records) {
|
|
|
+ String costRules = item.getCostRules();
|
|
|
+ if (StrUtil.isEmpty(costRules)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 按 separator 分段,过滤空段
|
|
|
+ List<String> segList = Arrays.stream(costRules.split(separator))
|
|
|
+ .filter(s -> !s.isEmpty())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (segList.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 为每段确定排序值:用 contains 判断包含哪个属性名,取对应 sort
|
|
|
+ List<Map.Entry<String, Integer>> segWithSort = new ArrayList<>();
|
|
|
+ for (String seg : segList) {
|
|
|
+ Integer sortVal = null;
|
|
|
+ for (PtlAgreementUndwrtRulesAttr attr : sortedAttrs) {
|
|
|
+ if (seg.contains(attr.getAttrName())) {
|
|
|
+ sortVal = attr.getSort();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ segWithSort.add(new AbstractMap.SimpleEntry<>(seg, sortVal));
|
|
|
+ }
|
|
|
+ // 按 sort 正序排列(未匹配到的段置后,保持原顺序)
|
|
|
+ segWithSort.sort(Comparator.comparing(e -> e.getValue() == null ? Integer.MAX_VALUE : e.getValue()));
|
|
|
+ // 重新拼接并赋值 cost_rules
|
|
|
+ String newCostRules = segWithSort.stream()
|
|
|
+ .map(Map.Entry::getKey)
|
|
|
+ .collect(Collectors.joining(separator));
|
|
|
+ if (StrUtil.isNotBlank(newCostRules)) {
|
|
|
+ newCostRules = newCostRules + separator;
|
|
|
+ }
|
|
|
+ item.setCostRules(newCostRules);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@GlobalTransactional
|
|
|
@Override
|
|
|
public HttpResult costCopy(PtlAgreementCostCopyParam costCopyParam) {
|