From 16fd4029758abb79de1e35e0a073cd6a7331deda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Fri, 15 May 2026 14:10:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=85=A5=E5=BA=93=E8=B4=B9=E7=94=A8?= =?UTF-8?q?=E7=99=BB=E8=AE=B0=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mhd/system/api/BmsServiceFeign.java | 9 ++++- .../RemoteBmsFeignFallbackFactory.java | 5 +++ .../ExpenseAccountApplicationService.java | 35 ++++++++++++++++++- .../repository/todo/ExpenseAccountDO.java | 3 ++ .../dto/expenseAccount/ExpenseAccountDTO.java | 7 ++++ .../expenseAccount/ExpenseAccountApi.java | 4 ++- ...SettlementCustomersApplicationService.java | 35 +++++++++++++++++++ .../facadeApi/SettlementCustomersApi.java | 15 ++++++++ 8 files changed, 110 insertions(+), 3 deletions(-) diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java index 055817bad..1866e2a45 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java @@ -18,7 +18,7 @@ import java.util.Set; /** * bms财务结算系统feign调用接口 */ -@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE,url = "http://10.102.192.3:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://127.0.0.1:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface BmsServiceFeign { @@ -35,6 +35,13 @@ public interface BmsServiceFeign { @GetMapping("/settlementCustomersApi/getInfoByCode") public AjaxResult getCustomersInfoByCode(@RequestParam("settlementCustomersCode")String settlementCustomersCode); + /** + * 按结算主体ID(如货主ID,对应 settlement_customers.settlement_entity_id)查询结算对象 + */ + @GetMapping("/settlementCustomersApi/getInfoBySettlementEntityId") + AjaxResult getCustomersInfoBySettlementEntityId(@RequestParam("settlementEntityId") Long settlementEntityId, + @RequestParam(value = "topOrganizationId", required = false) Long topOrganizationId); + /** * 推送同步业务单据 diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteBmsFeignFallbackFactory.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteBmsFeignFallbackFactory.java index f2fb2db79..1ff15b40c 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteBmsFeignFallbackFactory.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/factory/RemoteBmsFeignFallbackFactory.java @@ -42,6 +42,11 @@ public class RemoteBmsFeignFallbackFactory implements FallbackFactory科目范围以合同结算设置为准;若 {@code expenseAccountDO.inOrderDisplay} 或 {@code expenseAccountDO.outOrderDisplay} 非空, * 再按主数据「入库单是否固定显示 / 出库单是否固定显示」(0-否 1-是)与入参相等过滤,二者同时传则同时满足(AND)。

* settlementCustomersCode 不传或为空时使用通用仓储合同。 + *

若 {@code settlementCustomersCode} 为空且 {@code expenseAccountDO.settlementEntityId} 非空,则通过 BMS 按结算主体ID解析结算对象编码后再查合同(编码仍为空则走通用合同)。

*/ public List queryListFromContractWarehouseInOutSettlement(ExpenseAccountDO expenseAccountDO, String settlementCustomersCode) { Long topOrgIdForExpense = expenseAccountDO.getTopOrganizationId(); @@ -66,8 +71,15 @@ public class ExpenseAccountApplicationService { topOrgIdForExpense = lu.getUserPo().getTopOrganizationId(); } } + String effectiveSettlementCode = settlementCustomersCode; + if (StringUtils.isEmpty(effectiveSettlementCode) && expenseAccountDO.getSettlementEntityId() != null) { + effectiveSettlementCode = resolveSettlementCustomersCodeByEntityId( + expenseAccountDO.getSettlementEntityId(), topOrgIdForExpense); + log.info("按结算主体ID解析结算对象编码:settlementEntityId={},解析得到 settlementCustomersCode={}", + expenseAccountDO.getSettlementEntityId(), effectiveSettlementCode); + } List orderedCodes = contractManageApplicationService.listSecondSubjectCodesBySettlementAndDocumentType( - settlementCustomersCode, + effectiveSettlementCode, expenseAccountDO.getOrganizationId(), topOrgIdForExpense, ContractManageApplicationService.DOCUMENT_TYPE_CODE_WAREHOUSE_IN_OUT_ORDER); @@ -92,6 +104,27 @@ public class ExpenseAccountApplicationService { return result; } + /** + * 通过 BMS 按 settlement_entity_id 取结算对象编码,供合同匹配;失败返回 null(走通用合同)。 + */ + private String resolveSettlementCustomersCodeByEntityId(Long settlementEntityId, Long topOrganizationId) { + try { + AjaxResult ajaxResult = bmsServiceFeign.getCustomersInfoBySettlementEntityId(settlementEntityId, topOrganizationId); + if (ajaxResult == null || !"200".equals(String.valueOf(ajaxResult.get("code"))) || ajaxResult.get("data") == null) { + log.warn("按 settlementEntityId 查询结算对象未成功:code={}", ajaxResult != null ? ajaxResult.get("code") : null); + return null; + } + SettlementCustomersPO po = JSON.parseObject(JSON.toJSONString(ajaxResult.get("data")), SettlementCustomersPO.class); + if (po == null || StringUtils.isEmpty(po.getSettlementCustomersCode())) { + return null; + } + return po.getSettlementCustomersCode().trim(); + } catch (Exception e) { + log.warn("按 settlementEntityId 解析结算对象编码异常", e); + return null; + } + } + /** * 合同路径下可选:与主数据 in_order_display / out_order_display 一致才保留(入参为 null 的维度不参与过滤)。 */ diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/expenseAccount/repository/todo/ExpenseAccountDO.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/expenseAccount/repository/todo/ExpenseAccountDO.java index 90ab9e727..cb07d9216 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/expenseAccount/repository/todo/ExpenseAccountDO.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/expenseAccount/repository/todo/ExpenseAccountDO.java @@ -181,4 +181,7 @@ public class ExpenseAccountDO extends BaseVOEntity{ /** 查询参数:结算主体编码(货主编码等) */ private String settlementCustomersCode; + + /** 查询参数:结算主体ID(货主ID等,对应 settlement_customers.settlement_entity_id) */ + private Long settlementEntityId; } \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/expenseAccount/ExpenseAccountDTO.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/expenseAccount/ExpenseAccountDTO.java index 11ba9b86f..d3d6c4b45 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/expenseAccount/ExpenseAccountDTO.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/dto/expenseAccount/ExpenseAccountDTO.java @@ -169,4 +169,11 @@ public class ExpenseAccountDTO extends BaseVOEntity{ @ApiModelProperty("结算主体编码(通常为货主编码);不传则按通用仓储合同的结算设置取科目") private String settlementCustomersCode; + + /** + * 结算主体ID(货主等业务主体ID,与 BMS settlement_customers.settlement_entity_id 一致)。 + * 与 settlementCustomersCode 二选一:编码优先;仅传本字段时在 BMS 解析出结算对象编码后再走合同(有客户合同用客户,无则通用)。 + */ + @ApiModelProperty("结算主体ID(货主ID等,对应 settlement_entity_id);与 settlementCustomersCode 二选一,编码优先") + private Long settlementEntityId; } \ No newline at end of file diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/facade/expenseAccount/ExpenseAccountApi.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/facade/expenseAccount/ExpenseAccountApi.java index dfdec8e29..8810a7c34 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/facade/expenseAccount/ExpenseAccountApi.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/facade/expenseAccount/ExpenseAccountApi.java @@ -53,6 +53,7 @@ public class ExpenseAccountApi extends BaseController{ * *

入库/出库费用登记等场景传 {@code contractSettlementQuery=true}(与单据类型「仓库进出仓单」合同结算行一致), * 科目来源、结算主体为空走通用合同等逻辑入库与出库相同。 + * 可传 {@code settlementCustomersCode},或仅传 {@code settlementEntityId}(货主/结算主体ID,对应 BMS settlement_entity_id)由服务端解析结算编码后再匹配合同(有客户合同用客户,无则通用;编码优先)。 * 先按合同结算行取科目,再关联主数据;若请求中传入 {@code inOrderDisplay} 或 {@code outOrderDisplay}(0-否 1-是), * 则再按主数据「入库单 / 出库单是否固定显示」与入参相等过滤(二者都传则同时满足)。不传则不在此维度过滤。

*/ @@ -70,8 +71,9 @@ public class ExpenseAccountApi extends BaseController{ if (Boolean.TRUE.equals(expenseAccountDTO.getContractSettlementQuery())) { ExpenseAccountDO contractQueryDO = new ExpenseAccountDO(); BeanUtils.copyProperties(expenseAccountDTO, contractQueryDO); - logger.info("按合同结算设置查询费用科目,settlementCustomersCode={},inOrderDisplay={},outOrderDisplay={}", + logger.info("按合同结算设置查询费用科目,settlementCustomersCode={},settlementEntityId={},inOrderDisplay={},outOrderDisplay={}", expenseAccountDTO.getSettlementCustomersCode(), + expenseAccountDTO.getSettlementEntityId(), expenseAccountDTO.getInOrderDisplay(), expenseAccountDTO.getOutOrderDisplay()); List contractList = expenseAccountApplicationService.queryListFromContractWarehouseInOutSettlement( diff --git a/mhd_bms/src/main/java/com/mhd/bms/application/server/settlementCustomers/SettlementCustomersApplicationService.java b/mhd_bms/src/main/java/com/mhd/bms/application/server/settlementCustomers/SettlementCustomersApplicationService.java index 153412f63..1e2608ea1 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/application/server/settlementCustomers/SettlementCustomersApplicationService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/application/server/settlementCustomers/SettlementCustomersApplicationService.java @@ -376,4 +376,39 @@ public class SettlementCustomersApplicationService { } return null; } + + /** + * 按结算主体ID(如货主用户ID,对应 settlement_entity_id)取一条结算对象,用于解析合同上的 settlement_customers_code。 + * 多条时按 settlement_customers_id 升序取第一条。 + * + * @param settlementEntityId 结算主体id,不可为空 + * @param topOrganizationId 一级组织;为空则从当前登录用户取 + */ + public SettlementCustomersPO getFirstBySettlementEntityId(Long settlementEntityId, Long topOrganizationId) { + if (settlementEntityId == null) { + return null; + } + Long topOrg = topOrganizationId; + if (topOrg == null) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + if (loginUser != null && loginUser.getUserPo() != null) { + topOrg = loginUser.getUserPo().getTopOrganizationId(); + } + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper() + .eq(SettlementCustomers::getSettlementEntityId, settlementEntityId) + .eq(SettlementCustomers::getDelFlag, 1) + .orderByAsc(SettlementCustomers::getSettlementCustomersId) + .last("LIMIT 1"); + if (topOrg != null) { + wrapper.eq(SettlementCustomers::getTopOrganizationId, topOrg); + } + SettlementCustomers entity = settlementCustomersMapper.selectOne(wrapper); + if (entity == null) { + return null; + } + SettlementCustomersPO po = new SettlementCustomersPO(); + BeanUtils.copyProperties(entity, po); + return po; + } } \ No newline at end of file diff --git a/mhd_bms/src/main/java/com/mhd/bms/interfaces/facadeApi/SettlementCustomersApi.java b/mhd_bms/src/main/java/com/mhd/bms/interfaces/facadeApi/SettlementCustomersApi.java index 5af14ba96..0b0e45aec 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/interfaces/facadeApi/SettlementCustomersApi.java +++ b/mhd_bms/src/main/java/com/mhd/bms/interfaces/facadeApi/SettlementCustomersApi.java @@ -123,6 +123,21 @@ public class SettlementCustomersApi extends BaseController{ return AjaxResult.success(settlementCustomersApplicationService.getInfoByCode(settlementCustomersCode)); } + /** + * 按结算主体ID(货主等业务主体ID,对应 settlement_entity_id)查询一条结算对象 + */ + @ApiOperation("按结算主体ID查询结算对象") + @GetMapping(value = "/getInfoBySettlementEntityId") + public AjaxResult getInfoBySettlementEntityId( + @RequestParam(value = "settlementEntityId", required = false) Long settlementEntityId, + @RequestParam(value = "topOrganizationId", required = false) Long topOrganizationId) { + if (settlementEntityId == null) { + return AjaxResult.error("缺少必传查询参数 settlementEntityId(货主/结算主体ID,对应 settlement_entity_id)。" + + "GET 请求示例:/settlementCustomersApi/getInfoBySettlementEntityId?settlementEntityId=123456&topOrganizationId=你的租户一级组织ID"); + } + return AjaxResult.success(settlementCustomersApplicationService.getFirstBySettlementEntityId(settlementEntityId, topOrganizationId)); + } + From e85cff8a544bc6928c3d5b52ef014ff3ffec401e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Fri, 15 May 2026 15:22:37 +0800 Subject: [PATCH 2/4] =?UTF-8?q?Feign=E8=B0=83=E7=94=A8=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/mhd/system/api/BmsServiceFeign.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java index 1866e2a45..e18484e8d 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/BmsServiceFeign.java @@ -18,7 +18,7 @@ import java.util.Set; /** * bms财务结算系统feign调用接口 */ -@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://127.0.0.1:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) +@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.3:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class) public interface BmsServiceFeign { From 6d0211d6868d0dcb548d7294c07b7002e08c252b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Sat, 16 May 2026 09:59:11 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=AE=A1=E8=B4=B9=E7=AD=96=E7=95=A5?= =?UTF-8?q?=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, 48 insertions(+), 42 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..8f5866b86 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 @@ -509,52 +509,60 @@ public class ContractManageApplicationService { .eq(ContractManage::getTopOrganizationId, topOrganizationId) .eq(ContractManage::getCommonContractFlag, 2)); if (UserContractManages != null && UserContractManages.size() > 0) { + //用户合同计费策略 + calucateSubjectStrategy(UserContractManages, organizationId, topOrganizationId, sunjectCode, result); }else{ + //通用合同计费策略 List commonContractManages = contractManageMapper.selectList(new LambdaQueryWrapper() .eq(ContractManage::getDelFlag, 1) .eq(ContractManage::getOrganizationId, organizationId) .eq(ContractManage::getTopOrganizationId, topOrganizationId) .eq(ContractManage::getCommonContractFlag, 1)); - if (commonContractManages != null && commonContractManages.size() > 0) { - ContractManage contractManage = commonContractManages.get(0); - Long contractManageId = contractManage.getContractManageId(); - List contractManageDetails = contractManageDetailMapper.selectList(new LambdaQueryWrapper() - .eq(ContractManageDetail::getContractManageId, contractManageId) - .eq(ContractManageDetail::getDelFlag, 1)); - if (contractManageDetails != null && contractManageDetails.size() > 0) { - for (ContractManageDetail contractManageDetail : contractManageDetails) { - String code = contractManageDetail.getFirstSubjectCode(); - if (sunjectCode.equals(code)) { - Long accountingStrategyId = contractManageDetail.getAccountingStrategyId(); - BillingRulesPO billingRule = contractManageDetailMapper.getBillingRules(accountingStrategyId); - if (billingRule != null) { - Long billingRulesId = billingRule.getBillingRulesId(); - List billingParams = contractManageDetailMapper.getBillingParams(billingRulesId); - if (billingParams != null && billingParams.size() > 0) { - BillingParamsPO billingParam = billingParams.get(0); - String billingParamsJson = billingParam.getBillingParamsJson(); - String preSetRules = billingParam.getPreSetRules(); - Long billingParamsId = billingParam.getBillingParamsId(); - List> billingParamsList = JSON.parseObject(billingParamsJson, new TypeReference>>() {}); - 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(isShow)) { - String chargingId = (String) stringObjectMap.get("chargingId"); - String fields = (String) stringObjectMap.get("fields"); - SubjectAndPriceReturn subjectAndPriceReturn = new SubjectAndPriceReturn(); - subjectAndPriceReturn.setName(fieldsName); - subjectAndPriceReturn.setChargingId(chargingId); - subjectAndPriceReturn.setFields(fields); - subjectAndPriceReturn.setBillingRulesId(billingRulesId); - subjectAndPriceReturn.setIsShow(isShow); - subjectAndPriceReturn.setIsFee(isFee); - subjectAndPriceReturn.setIsPush(isPush); - subjectAndPriceReturn.setRulesId(billingParamsId); - result.add(subjectAndPriceReturn); - } + calucateSubjectStrategy(commonContractManages, organizationId, topOrganizationId, sunjectCode, result); + } + return result; + } + + private void calucateSubjectStrategy(List commonContractManages, Long organizationId, Long topOrganizationId, String sunjectCode, List result) { + if (commonContractManages != null && commonContractManages.size() > 0) { + ContractManage contractManage = commonContractManages.get(0); + Long contractManageId = contractManage.getContractManageId(); + List contractManageDetails = contractManageDetailMapper.selectList(new LambdaQueryWrapper() + .eq(ContractManageDetail::getContractManageId, contractManageId) + .eq(ContractManageDetail::getDelFlag, 1)); + if (contractManageDetails != null && contractManageDetails.size() > 0) { + for (ContractManageDetail contractManageDetail : contractManageDetails) { + String code = contractManageDetail.getFirstSubjectCode(); + if (sunjectCode.equals(code)) { + Long accountingStrategyId = contractManageDetail.getAccountingStrategyId(); + BillingRulesPO billingRule = contractManageDetailMapper.getBillingRules(accountingStrategyId); + if (billingRule != null) { + Long billingRulesId = billingRule.getBillingRulesId(); + List billingParams = contractManageDetailMapper.getBillingParams(billingRulesId); + if (billingParams != null && billingParams.size() > 0) { + BillingParamsPO billingParam = billingParams.get(0); + String billingParamsJson = billingParam.getBillingParamsJson(); + String preSetRules = billingParam.getPreSetRules(); + Long billingParamsId = billingParam.getBillingParamsId(); + List> billingParamsList = JSON.parseObject(billingParamsJson, new TypeReference>>() {}); + 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(isShow)) { + String chargingId = (String) stringObjectMap.get("chargingId"); + String fields = (String) stringObjectMap.get("fields"); + SubjectAndPriceReturn subjectAndPriceReturn = new SubjectAndPriceReturn(); + subjectAndPriceReturn.setName(fieldsName); + subjectAndPriceReturn.setChargingId(chargingId); + subjectAndPriceReturn.setFields(fields); + subjectAndPriceReturn.setBillingRulesId(billingRulesId); + subjectAndPriceReturn.setIsShow(isShow); + subjectAndPriceReturn.setIsFee(isFee); + subjectAndPriceReturn.setIsPush(isPush); + subjectAndPriceReturn.setRulesId(billingParamsId); + result.add(subjectAndPriceReturn); } } } @@ -563,10 +571,8 @@ public class ContractManageApplicationService { } } } - return result; } - /** * 新增合同管理 */ From 3b5674b10ccc1830b7453acab4993a460e9f13e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Sat, 16 May 2026 10:43:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=AE=A1=E8=B4=B9=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContractManageApplicationService.java | 113 ++++++++++-------- 1 file changed, 60 insertions(+), 53 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 8f5866b86..0a48641b3 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 @@ -275,64 +275,16 @@ public class ContractManageApplicationService { .eq(ContractManage::getTopOrganizationId, topOrganizationId) .eq(ContractManage::getCommonContractFlag, 2)); if (UserContractManages != null && UserContractManages.size() > 0) { - }else{ + //用户合同计费策略 + calucateSubjectAndPriceStrategy(UserContractManages, organizationId, topOrganizationId, sunjectCode, result); + } else { + //通用合同计费策略 List commonContractManages = contractManageMapper.selectList(new LambdaQueryWrapper() .eq(ContractManage::getDelFlag, 1) .eq(ContractManage::getOrganizationId, organizationId) .eq(ContractManage::getTopOrganizationId, topOrganizationId) .eq(ContractManage::getCommonContractFlag, 1)); - if (commonContractManages != null && commonContractManages.size() > 0) { - ContractManage contractManage = commonContractManages.get(0); - Long contractManageId = contractManage.getContractManageId(); - List contractManageDetails = contractManageDetailMapper.selectList(new LambdaQueryWrapper() - .eq(ContractManageDetail::getContractManageId, contractManageId) - .eq(ContractManageDetail::getDelFlag, 1)); - if (contractManageDetails != null && contractManageDetails.size() > 0) { - for (ContractManageDetail contractManageDetail : contractManageDetails) { - String code = contractManageDetail.getFirstSubjectCode(); - if (sunjectCode.equals(code)) { - Long accountingStrategyId = contractManageDetail.getAccountingStrategyId(); - BillingRulesPO billingRule = contractManageDetailMapper.getBillingRules(accountingStrategyId); - if (billingRule != null) { - Long billingRulesId = billingRule.getBillingRulesId(); - List billingParams = contractManageDetailMapper.getBillingParams(billingRulesId); - 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>>() {}); - 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(billingRulesId); - subjectAndPriceReturn.setIsShow(isShow); - subjectAndPriceReturn.setIsFee(isFee); - subjectAndPriceReturn.setIsPush(isPush); - subjectAndPriceReturn.setRulesId(billingParamsId); - result.add(subjectAndPriceReturn); - } - } - } - } - } - } - } - } + calucateSubjectAndPriceStrategy(commonContractManages, organizationId, topOrganizationId, sunjectCode, result); } return result; } @@ -573,6 +525,61 @@ public class ContractManageApplicationService { } } + private void calucateSubjectAndPriceStrategy(List contractManages, Long organizationId, Long topOrganizationId, String sunjectCode, List result) { + if (contractManages != null && contractManages.size() > 0) { + ContractManage contractManage = contractManages.get(0); + Long contractManageId = contractManage.getContractManageId(); + List contractManageDetails = contractManageDetailMapper.selectList(new LambdaQueryWrapper() + .eq(ContractManageDetail::getContractManageId, contractManageId) + .eq(ContractManageDetail::getDelFlag, 1)); + if (contractManageDetails != null && contractManageDetails.size() > 0) { + for (ContractManageDetail contractManageDetail : contractManageDetails) { + String code = contractManageDetail.getFirstSubjectCode(); + if (sunjectCode.equals(code)) { + Long accountingStrategyId = contractManageDetail.getAccountingStrategyId(); + BillingRulesPO billingRule = contractManageDetailMapper.getBillingRules(accountingStrategyId); + if (billingRule != null) { + Long billingRulesId = billingRule.getBillingRulesId(); + List billingParams = contractManageDetailMapper.getBillingParams(billingRulesId); + 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>>() {}); + 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(billingRulesId); + subjectAndPriceReturn.setIsShow(isShow); + subjectAndPriceReturn.setIsFee(isFee); + subjectAndPriceReturn.setIsPush(isPush); + subjectAndPriceReturn.setRulesId(billingParamsId); + result.add(subjectAndPriceReturn); + } + } + } + } + } + } + } + } + } + /** * 新增合同管理 */