费用计算;

This commit is contained in:
王奎兴
2026-04-03 09:50:17 +08:00
parent b34bb5ce36
commit 9210f49500
@@ -175,8 +175,86 @@ public class ContractManageApplicationService {
}
}
} else {
for (SubjectAndPriceReturn subjectAndPriceReturn : subjectAndPriceReturnList) {
Long billingRulesId = subjectAndPriceReturn.getBillingRulesId();
String name = subjectAndPriceReturn.getName();
BillingRulesPO billingRule = contractManageDetailMapper.getBillingRules(billingRulesId);
List<BillingParamsPO> billingParams = contractManageDetailMapper.getBillingParams(billingRulesId);
if (billingParams != null && billingParams.size() > 0) {
BillingParamsPO billingParam = billingParams.get(0);
String billingParamsJson = billingParam.getBillingParamsJson();
String preSetRules = billingParam.getPreSetRules();
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 (billingParamsList != null && billingParamsList.size() ==2) {
Map<String, Object> targetMap = billingParamsList.stream()
.filter(map -> name.equals(map.get("fieldsName"))) // 关键匹配条件
.findFirst() // 取第一个
.orElse(null); // 没找到返回null
String chargingId = (String) targetMap.get("chargingId");
Integer sort = (Integer) targetMap.get("sort");
Map<String, Object> reles = preSetRulesList.get(0);
String price = (String) reles.get("fields"+sort);
String billingFormula = billingRule.getBillingFormula();
billingFormula = billingFormula.replace(chargingId, price);
//需要判断阶梯类型进行获取各计费标志的取值,拼接公式
List<BillingParamsDetailDTO> billingParamsEntityList = JSON.parseArray(billingParamsJson, BillingParamsDetailDTO.class);
//将计费参数实体分成两组,即:固定参数和条件参数
List<BillingParamsDetailDTO> fixedParamsEntityList = billingParamsEntityList.stream().filter(item -> ObjectUtil.equal(item.getLadderType(),1)).collect(Collectors.toList());
List<BillingParamsDetailDTO> ladderParamsEntityList = billingParamsEntityList.stream().filter(item -> !ObjectUtil.equal(item.getLadderType(),1)).collect(Collectors.toList());
if (fixedParamsEntityList != null && fixedParamsEntityList.size() > 0) {
if (subjectAndPriceReturn.getNum() != null) {
for (BillingParamsDetailDTO ladderParamsEntity : fixedParamsEntityList) {
String chargingId1 = ladderParamsEntity.getChargingId();
if (chargingId1 != chargingId) {
billingFormula = billingFormula.replace(chargingId1, subjectAndPriceReturn.getNum().toEngineeringString());
}
}
}
}
return DynamicCalculationUtil.calculate(billingFormula);
} else {
Map<String, Object> targetMap = billingParamsList.stream()
.filter(map -> name.equals(map.get("fieldsName"))) // 关键匹配条件
.findFirst() // 取第一个
.orElse(null); // 没找到返回null
String chargingId = (String) targetMap.get("chargingId");
Integer sort = (Integer) targetMap.get("sort");
Map<String, Object> reles = preSetRulesList.get(0);
String price = (String) reles.get("fields"+sort);
String billingFormula = billingRule.getBillingFormula();
billingFormula = billingFormula.replace(chargingId, price);
//需要判断阶梯类型进行获取各计费标志的取值,拼接公式
List<BillingParamsDetailDTO> billingParamsEntityList = JSON.parseArray(billingParamsJson, BillingParamsDetailDTO.class);
//将计费参数实体分成两组,即:固定参数和条件参数
List<BillingParamsDetailDTO> fixedParamsEntityList = billingParamsEntityList.stream().filter(item -> ObjectUtil.equal(item.getLadderType(),1)).collect(Collectors.toList());
List<BillingParamsDetailDTO> ladderParamsEntityList = billingParamsEntityList.stream().filter(item -> !ObjectUtil.equal(item.getLadderType(),1)).collect(Collectors.toList());
if (fixedParamsEntityList != null && fixedParamsEntityList.size() > 0) {
if (subjectAndPriceReturn.getNum() != null) {
for (Map<String, Object> ladderParamsEntity : billingParamsList) {
String chargingId1 = (String) ladderParamsEntity.get("chargingId");
String fieldsName = (String) ladderParamsEntity.get("fieldsName");
if ("纸箱贴标单价".equals(name)) {
if ("纸箱数量".equals(fieldsName)) {
billingFormula = billingFormula.replace(chargingId1, subjectAndPriceReturn.getNum().toEngineeringString());
}
} else if ("木箱贴标单价".equals(name)){
if ("木箱数量".equals(fieldsName)) {
billingFormula = billingFormula.replace(chargingId1, subjectAndPriceReturn.getNum().toEngineeringString());
}
}
}
}
}
return DynamicCalculationUtil.calculate(billingFormula);
}
}
}
}
return null;
return BigDecimal.ZERO;
}
public List<SubjectAndPriceReturn> getSubjectAndPrice(SubjectAndPriceDTO contractManageDTO) {