diff --git a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/SystemServiceFeign.java b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/SystemServiceFeign.java index 1422b6bcf..bc64c9cce 100644 --- a/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/SystemServiceFeign.java +++ b/mhd-api/mhd-api-system/src/main/java/com/mhd/system/api/SystemServiceFeign.java @@ -331,6 +331,11 @@ public interface SystemServiceFeign { @GetMapping("/contractManageApi/getInfoByCode") public AjaxResult getInfoByCode(@RequestParam("contractNumber") String contractNumber); + /** + * 获取通用合同 + */ + @GetMapping("/contractManageApi/getGeneralContract") + public AjaxResult getGeneralContract(); /** * 根据结算主体获取合同信息 */ diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/Lease/LeaseApplicationService.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/Lease/LeaseApplicationService.java index 2aa409f4e..d2fdbd155 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/Lease/LeaseApplicationService.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/application/service/Lease/LeaseApplicationService.java @@ -472,7 +472,7 @@ public class LeaseApplicationService { jsonObject.put("lease_area",leasePO.getLeaseArea());//租赁面积 jsonObject.put("jiecun_cbm",0);//结存体积 businessDataPushDTO.setDocumentFormJson(jsonObject.toJSONString()); - businessDataPushDTO.setDocumentTypeCode("ckzld"); + businessDataPushDTO.setDocumentTypeCode("仓库租赁单"); businessDataPushDTO.setSettlementEntityId(leasePO.getShipperId()); businessDataPushDTO.setSecondSubjectCode(leasePO.getSecondSubjectCode()); businessDataPushDTO.setServiceItemsCode(leasePO.getServiceItemsCode()); @@ -518,10 +518,10 @@ public class LeaseApplicationService { jsonObject.put("lease_area",0);//租赁面积 jsonObject.put("jiecun_cbm",totalVolume);//结存体积 businessDataPushDTO.setDocumentFormJson(jsonObject.toJSONString()); - businessDataPushDTO.setDocumentTypeCode("ckzld"); + businessDataPushDTO.setDocumentTypeCode("仓库租赁单"); businessDataPushDTO.setSettlementEntityId(leasePO.getShipperId()); - businessDataPushDTO.setSecondSubjectCode("26WMS01"); - businessDataPushDTO.setServiceItemsCode("26WMS费用"); + businessDataPushDTO.setSecondSubjectCode(leasePO.getSecondSubjectCode()); + businessDataPushDTO.setServiceItemsCode(leasePO.getServiceItemsCode()); businessDataPushDTO.setDataSources(1); bmsServiceFeign.businessDocumentApiSave(businessDataPushDTO); } 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 1d49d32d8..d88b559f5 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 @@ -478,5 +478,7 @@ public class ContractManageApplicationService { } - + public ContractManagePO getGeneralContract() { + return contractManageDomainService.getGeneralContract(); + } } diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/contractManage/service/ContractManageDomainService.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/contractManage/service/ContractManageDomainService.java index cd98766cb..f0db23e50 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/contractManage/service/ContractManageDomainService.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/domain/contractManage/service/ContractManageDomainService.java @@ -155,13 +155,39 @@ public class ContractManageDomainService { } - - - - - - - - - + public ContractManagePO getGeneralContract() { + ContractManagePO contractManagePO = new ContractManagePO(); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ContractManage::getCommonContractFlag,1); + queryWrapper.eq(ContractManage::getDelFlag,1); + ContractManage contractManage = contractManageService.getOne(queryWrapper); + if(null != contractManage){ + BeanUtils.copyProperties(contractManage,contractManagePO); + //得到合同后,查询合同明细 + List contractManageDetailPOList = contractManageDetailDomainService.queryListByManageId(contractManagePO.getContractManageId()); + List contractManageDetailSaveList = new ArrayList<>(); + if(contractManageDetailPOList != null && contractManageDetailPOList.size()>0){ + //将临时合同中没有,但是通用合同中有的数据过滤出(使用 ObjectUtil.equal 避免 firstSubjectCode/secondSubjectCode 为 null 时 NPE) + contractManageDetailSaveList = contractManageDetailPOList.stream().filter(item -> contractManageDetailPOList.stream().anyMatch(item1 -> ObjectUtil.equal(item1.getFirstSubjectCode(), item.getFirstSubjectCode()) && ObjectUtil.equal(item1.getSecondSubjectCode(), item.getSecondSubjectCode()) && item1.getSubjectType()==1)).collect(Collectors.toList()); + //首先根据结算科目类型将临时合同过滤出 + List tempContractManageDetailPOList = contractManageDetailPOList.stream().filter(item -> item.getSubjectType()==2).collect(Collectors.toList()); + //遍历两个集合,将相同费用科目code的数据,进行比较,如果结算科目类型是临时且合同有效期有效,则使用该条数据,将另一条移除 + for (ContractManageDetailPO manageDetailPO : tempContractManageDetailPOList) { + for (ContractManageDetailPO contractManageDetailPO : contractManageDetailPOList) { + if(ObjectUtil.equal(contractManageDetailPO.getFirstSubjectCode(), manageDetailPO.getFirstSubjectCode()) && ObjectUtil.equal(contractManageDetailPO.getSecondSubjectCode(), manageDetailPO.getSecondSubjectCode())){ + //判断如果是临时合同在有效期内,则将该条数据保存到集合contractManageDetailSaveList + DateTime start = DateUtil.parseDate(DateUtil.format(manageDetailPO.getSubjectEffectiveDate(),"yyyy-MM-dd")); + DateTime end = DateUtil.parseDateTime(DateUtil.format(manageDetailPO.getSubjectEffectiveDate(),"yyyy-MM-dd")); + DateTime now = DateUtil.beginOfDay(DateUtil.date()); + if (now.isAfterOrEquals(start) && now.isBefore(end)) { + contractManageDetailSaveList.add(manageDetailPO); + } + } + } + } + } + contractManagePO.setContractManageDetailPOList(contractManageDetailSaveList); + } + return contractManagePO; + } } diff --git a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/facade/contractManage/ContractManageApi.java b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/facade/contractManage/ContractManageApi.java index 79b1229a2..5f14c644c 100644 --- a/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/facade/contractManage/ContractManageApi.java +++ b/mhd-modules/mhd-system/src/main/java/com/mhd/basic/interfaces/facade/contractManage/ContractManageApi.java @@ -126,6 +126,13 @@ public class ContractManageApi extends BaseController{ return AjaxResult.success(contractManageApplicationService.getInfoByCode(contractNumber)); } + @ApiOperation("查询通用合同") + @GetMapping(value = "/getGeneralContract") + public AjaxResult getGeneralContract() + { + return AjaxResult.success(contractManageApplicationService.getGeneralContract()); + } + @ApiOperation("查询所有合同管理") @GetMapping("/queryList") diff --git a/mhd_bms/src/main/java/com/mhd/bms/application/server/billingRules/CostCalculationApplicationService.java b/mhd_bms/src/main/java/com/mhd/bms/application/server/billingRules/CostCalculationApplicationService.java index c3b488789..276a79478 100644 --- a/mhd_bms/src/main/java/com/mhd/bms/application/server/billingRules/CostCalculationApplicationService.java +++ b/mhd_bms/src/main/java/com/mhd/bms/application/server/billingRules/CostCalculationApplicationService.java @@ -119,15 +119,31 @@ public class CostCalculationApplicationService { private BillingRulesPO chooseBillingParams(CostCalculationDTO costCalculationDTO,TaskFlowRecordsDO taskFlowRecordsDO) { //获取合同信息 AjaxResult ajaxResult = systemServiceFeign.getInfoByCode(costCalculationDTO.getContractNumber()); - if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { - throw new ServiceException("合同信息未找到"); - } - ContractManagePO contractPO = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContractManagePO.class); - if (null == contractPO) { - throw new ServiceException("合同信息未找到"); - } - if(contractPO.getContractManageDetailPOList() == null || contractPO.getContractManageDetailPOList().size() == 0){ - throw new ServiceException("合同详情列表为空,无法进行计算"); + ContractManagePO contractPO = null; + try { + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { + throw new ServiceException("合同信息未找到"); + } + contractPO = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContractManagePO.class); + if (null == contractPO) { + throw new ServiceException("合同信息未找到"); + } + if(contractPO.getContractManageDetailPOList() == null || contractPO.getContractManageDetailPOList().size() == 0){ + throw new ServiceException("合同详情列表为空,无法进行计算"); + } + } catch (ServiceException e) { + //查询通用合同 + AjaxResult generalContract = systemServiceFeign.getGeneralContract(); + if (!"200".equals(String.valueOf(generalContract.get("code")))) { + throw new ServiceException("通用合同信息未找到"); + } + contractPO = JSONObject.parseObject(JSONObject.toJSONString(generalContract.get("data")), ContractManagePO.class); + if (null == contractPO) { + throw new ServiceException("通用合同信息未找到"); + } + if(contractPO.getContractManageDetailPOList() == null || contractPO.getContractManageDetailPOList().size() == 0){ + throw new ServiceException("通用合同详情列表为空,无法进行计算"); + } } //查询单据信息