单价列表重复修改
This commit is contained in:
+36
-54
@@ -427,10 +427,8 @@ public class ContractManageApplicationService {
|
||||
|
||||
/**
|
||||
* 按单据类型取合同结算行上的计费单价(计费策略展开的 isFee 项)。
|
||||
* <p>多条结算明细共用同一计费策略(与 {@link #getSubjectAndPrice} 一致:按计费策略 id 先解析 {@link BillingRulesPO},
|
||||
* 再以 {@code billing_rules_id} 取计费参数)时只展开一次,避免前端重复单价列。</p>
|
||||
* <p>同一策略的参数 JSON 中若存在重复的 isFee 槽位(相同 sort/chargingId),或历史数据多套规则 id 实际等价,
|
||||
* 返回列表会再做一次槽位级去重,避免出现两条「进出仓操作费单价」等同名列。</p>
|
||||
* <p>多条结算明细共用同一计费策略(accounting_strategy_id 相同)时,只展开一次策略参数,
|
||||
* 避免前端出现重复的单价列。</p>
|
||||
*/
|
||||
public List<SubjectAndPriceReturn> getPrice(String documentTypeCode, String settlementCustomersCode,Long organizationId,Long topOrganizationId) {
|
||||
List<SubjectAndPriceReturn> 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<Long> expandedBillingRulesIds = new HashSet<>();
|
||||
/* 计费规则 + 公式槽位,避免参数 JSON 或多次展开重复同一单价列 */
|
||||
Set<String> addedFeeSlots = new HashSet<>();
|
||||
Set<Long> 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<BillingParamsPO> billingParams = contractManageDetailMapper.getBillingParams(billingRulesId);
|
||||
List<BillingParamsPO> 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<Map<String, Object>> preSetRulesList = JSON.parseObject(preSetRules, new TypeReference<List<Map<String, Object>>>() {});
|
||||
List<Map<String, Object>> billingParamsList = JSON.parseObject(billingParamsJson, new TypeReference<List<Map<String, Object>>>() {});
|
||||
if (preSetRulesList != null && preSetRulesList.size() > 0 && billingParamsList != null) {
|
||||
Map<String, Object> stringObjectMap1 = preSetRulesList.get(0);
|
||||
for (Map<String, Object> 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<Map<String, Object>> preSetRulesList = JSON.parseObject(preSetRules, new TypeReference<List<Map<String, Object>>>() {});
|
||||
List<Map<String, Object>> billingParamsList = JSON.parseObject(billingParamsJson, new TypeReference<List<Map<String, Object>>>() {});
|
||||
if (preSetRulesList != null && preSetRulesList.size() > 0) {
|
||||
Map<String, Object> stringObjectMap1 = preSetRulesList.get(0);
|
||||
for (Map<String, Object> 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("计费参数不存在");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user