From b24fa2cd3ebee17c99e654e5202d24569c40a725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Wed, 13 May 2026 16:24:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BB=B7=E5=88=97=E8=A1=A8=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContractManageApplicationService.java | 90 ++++++++----------- 1 file changed, 36 insertions(+), 54 deletions(-) diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/contractManage/ContractManageApplicationService.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/contractManage/ContractManageApplicationService.java index b35909df0..e6cc462bf 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/contractManage/ContractManageApplicationService.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/contractManage/ContractManageApplicationService.java @@ -427,10 +427,8 @@ public class ContractManageApplicationService { /** * 按单据类型取合同结算行上的计费单价(计费策略展开的 isFee 项)。 - *

多条结算明细共用同一计费策略(与 {@link #getSubjectAndPrice} 一致:按计费策略 id 先解析 {@link BillingRulesPO}, - * 再以 {@code billing_rules_id} 取计费参数)时只展开一次,避免前端重复单价列。

- *

同一策略的参数 JSON 中若存在重复的 isFee 槽位(相同 sort/chargingId),或历史数据多套规则 id 实际等价, - * 返回列表会再做一次槽位级去重,避免出现两条「进出仓操作费单价」等同名列。

+ *

多条结算明细共用同一计费策略(accounting_strategy_id 相同)时,只展开一次策略参数, + * 避免前端出现重复的单价列。

*/ public List getPrice(String documentTypeCode, String settlementCustomersCode,Long organizationId,Long topOrganizationId) { List result = new ArrayList<>(); @@ -444,64 +442,48 @@ public class ContractManageApplicationService { .filter(item -> contractDetailContainsDocumentType(item.getDocumentTypeCode(), documentTypeCode)) .collect(Collectors.toList()); if (contractManageDetailPOs != null && contractManageDetailPOs.size() > 0) { - Set expandedBillingRulesIds = new HashSet<>(); - /* 计费规则 + 公式槽位,避免参数 JSON 或多次展开重复同一单价列 */ - Set addedFeeSlots = new HashSet<>(); + Set expandedAccountingStrategyIds = new HashSet<>(); for (ContractManageDetailPO contractManageDetailPO : contractManageDetailPOs) { Long accountingStrategyId = contractManageDetailPO.getAccountingStrategyId(); - if (accountingStrategyId == null) { + if (accountingStrategyId == null || !expandedAccountingStrategyIds.add(accountingStrategyId)) { continue; } - BillingRulesPO billingRulesPO = contractManageDetailMapper.getBillingRules(accountingStrategyId); - if (billingRulesPO == null || billingRulesPO.getBillingRulesId() == null) { - continue; - } - Long billingRulesId = billingRulesPO.getBillingRulesId(); - if (!expandedBillingRulesIds.add(billingRulesId)) { - continue; - } - List billingParams = contractManageDetailMapper.getBillingParams(billingRulesId); + List billingParams = contractManageDetailMapper.getBillingParams(accountingStrategyId); if (billingParams != null && billingParams.size() > 0) { - BillingParamsPO billingParam = billingParams.get(0); - String billingParamsJson = billingParam.getBillingParamsJson(); - String preSetRules = billingParam.getPreSetRules(); - Long billingParamsId = billingParam.getBillingParamsId(); - List> preSetRulesList = JSON.parseObject(preSetRules, new TypeReference>>() {}); - List> billingParamsList = JSON.parseObject(billingParamsJson, new TypeReference>>() {}); - if (preSetRulesList != null && preSetRulesList.size() > 0 && billingParamsList != null) { - Map stringObjectMap1 = preSetRulesList.get(0); - for (Map stringObjectMap : billingParamsList) { - String fieldsName = (String) stringObjectMap.get("fieldsName"); - String isShow = (String) stringObjectMap.get("isShow"); - String isFee = (String) stringObjectMap.get("isFee"); - String isPush = (String) stringObjectMap.get("isPush"); - if ("1".equals(isFee)) { - Integer sort = (Integer) stringObjectMap.get("sort"); - String chargingId = (String) stringObjectMap.get("chargingId"); - String fields = (String) stringObjectMap.get("fields"); - String feeSlotKey = billingRulesId + "|" + Objects.toString(sort, "") + "|" + Objects.toString(chargingId, ""); - if (!addedFeeSlots.add(feeSlotKey)) { - continue; + //if (billingParams != null && billingParams.size() > 0) { + BillingParamsPO billingParam = billingParams.get(0); + String billingParamsJson = billingParam.getBillingParamsJson(); + String preSetRules = billingParam.getPreSetRules(); + Long billingParamsId = billingParam.getBillingParamsId(); + List> preSetRulesList = JSON.parseObject(preSetRules, new TypeReference>>() {}); + List> billingParamsList = JSON.parseObject(billingParamsJson, new TypeReference>>() {}); + if (preSetRulesList != null && preSetRulesList.size() > 0) { + Map stringObjectMap1 = preSetRulesList.get(0); + for (Map stringObjectMap : billingParamsList) { + String fieldsName = (String) stringObjectMap.get("fieldsName"); + String isShow = (String) stringObjectMap.get("isShow"); + String isFee = (String) stringObjectMap.get("isFee"); + String isPush = (String) stringObjectMap.get("isPush"); + if ("1".equals(isFee)) { + Integer sort = (Integer) stringObjectMap.get("sort"); + String chargingId = (String) stringObjectMap.get("chargingId"); + String fields = (String) stringObjectMap.get("fields"); + String price = (String) stringObjectMap1.get("fields" + sort); + SubjectAndPriceReturn subjectAndPriceReturn = new SubjectAndPriceReturn(); + subjectAndPriceReturn.setName(fieldsName); + subjectAndPriceReturn.setPrice(new BigDecimal(price)); + subjectAndPriceReturn.setChargingId(chargingId); + subjectAndPriceReturn.setFields(fields); + subjectAndPriceReturn.setBillingRulesId(accountingStrategyId); + subjectAndPriceReturn.setIsShow(isShow); + subjectAndPriceReturn.setIsFee(isFee); + subjectAndPriceReturn.setIsPush(isPush); + subjectAndPriceReturn.setRulesId(billingParamsId); + result.add(subjectAndPriceReturn); } - Object rawPrice = stringObjectMap1.get("fields" + sort); - if (rawPrice == null) { - continue; - } - String price = String.valueOf(rawPrice); - SubjectAndPriceReturn subjectAndPriceReturn = new SubjectAndPriceReturn(); - subjectAndPriceReturn.setName(fieldsName); - subjectAndPriceReturn.setPrice(new BigDecimal(price)); - subjectAndPriceReturn.setChargingId(chargingId); - subjectAndPriceReturn.setFields(fields); - subjectAndPriceReturn.setBillingRulesId(billingRulesId); - subjectAndPriceReturn.setIsShow(isShow); - subjectAndPriceReturn.setIsFee(isFee); - subjectAndPriceReturn.setIsPush(isPush); - subjectAndPriceReturn.setRulesId(billingParamsId); - result.add(subjectAndPriceReturn); } } - } + //} } else { throw new ServiceException("计费参数不存在"); }