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 deba0d3f3..a3f88d184 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 @@ -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 billingParams = contractManageDetailMapper.getBillingParams(billingRulesId); + if (billingParams != null && billingParams.size() > 0) { + BillingParamsPO billingParam = billingParams.get(0); + String billingParamsJson = billingParam.getBillingParamsJson(); + String preSetRules = billingParam.getPreSetRules(); + List> preSetRulesList = JSON.parseObject(preSetRules, new TypeReference>>() { + }); + List> billingParamsList = JSON.parseObject(billingParamsJson, new TypeReference>>() { + }); + if (billingParamsList != null && billingParamsList.size() ==2) { + Map 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 reles = preSetRulesList.get(0); + String price = (String) reles.get("fields"+sort); + String billingFormula = billingRule.getBillingFormula(); + billingFormula = billingFormula.replace(chargingId, price); + //需要判断阶梯类型进行获取各计费标志的取值,拼接公式 + List billingParamsEntityList = JSON.parseArray(billingParamsJson, BillingParamsDetailDTO.class); + //将计费参数实体分成两组,即:固定参数和条件参数 + List fixedParamsEntityList = billingParamsEntityList.stream().filter(item -> ObjectUtil.equal(item.getLadderType(),1)).collect(Collectors.toList()); + List 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 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 reles = preSetRulesList.get(0); + String price = (String) reles.get("fields"+sort); + String billingFormula = billingRule.getBillingFormula(); + billingFormula = billingFormula.replace(chargingId, price); + //需要判断阶梯类型进行获取各计费标志的取值,拼接公式 + List billingParamsEntityList = JSON.parseArray(billingParamsJson, BillingParamsDetailDTO.class); + //将计费参数实体分成两组,即:固定参数和条件参数 + List fixedParamsEntityList = billingParamsEntityList.stream().filter(item -> ObjectUtil.equal(item.getLadderType(),1)).collect(Collectors.toList()); + List 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 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 getSubjectAndPrice(SubjectAndPriceDTO contractManageDTO) {