From bc2a040b80daf59224bbe4af65ecb98a6f1a5199 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 15:47:24 +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?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ContractManageApplicationService.java | 90 +++++++++++--------
1 file changed, 54 insertions(+), 36 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 e6cc462bf..b35909df0 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,8 +427,10 @@ public class ContractManageApplicationService {
/**
* 按单据类型取合同结算行上的计费单价(计费策略展开的 isFee 项)。
- *
多条结算明细共用同一计费策略(accounting_strategy_id 相同)时,只展开一次策略参数,
- * 避免前端出现重复的单价列。
+ * 多条结算明细共用同一计费策略(与 {@link #getSubjectAndPrice} 一致:按计费策略 id 先解析 {@link BillingRulesPO},
+ * 再以 {@code billing_rules_id} 取计费参数)时只展开一次,避免前端重复单价列。
+ * 同一策略的参数 JSON 中若存在重复的 isFee 槽位(相同 sort/chargingId),或历史数据多套规则 id 实际等价,
+ * 返回列表会再做一次槽位级去重,避免出现两条「进出仓操作费单价」等同名列。
*/
public List getPrice(String documentTypeCode, String settlementCustomersCode,Long organizationId,Long topOrganizationId) {
List result = new ArrayList<>();
@@ -442,48 +444,64 @@ public class ContractManageApplicationService {
.filter(item -> contractDetailContainsDocumentType(item.getDocumentTypeCode(), documentTypeCode))
.collect(Collectors.toList());
if (contractManageDetailPOs != null && contractManageDetailPOs.size() > 0) {
- Set expandedAccountingStrategyIds = new HashSet<>();
+ Set expandedBillingRulesIds = new HashSet<>();
+ /* 计费规则 + 公式槽位,避免参数 JSON 或多次展开重复同一单价列 */
+ Set addedFeeSlots = new HashSet<>();
for (ContractManageDetailPO contractManageDetailPO : contractManageDetailPOs) {
Long accountingStrategyId = contractManageDetailPO.getAccountingStrategyId();
- if (accountingStrategyId == null || !expandedAccountingStrategyIds.add(accountingStrategyId)) {
+ if (accountingStrategyId == null) {
continue;
}
- List billingParams = contractManageDetailMapper.getBillingParams(accountingStrategyId);
+ 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);
if (billingParams != null && billingParams.size() > 0) {
- //if (billingParams != null && billingParams.size() > 0) {
- BillingParamsPO billingParam = billingParams.get(0);
- String billingParamsJson = billingParam.getBillingParamsJson();
- String preSetRules = billingParam.getPreSetRules();
- Long billingParamsId = billingParam.getBillingParamsId();
- List