From c110ab5dcc67005b3479cacad4f380accdeab635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Mon, 23 Feb 2026 14:23:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Lease/LeaseApplicationService.java | 80 +++++++++---------- 1 file changed, 39 insertions(+), 41 deletions(-) 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 0f4938221..2f6355a0e 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 @@ -43,7 +43,7 @@ import java.util.stream.Collectors; /** * 租赁管理ApplicationService - * + * * @author gen * @date 2024-05-07 */ @@ -67,8 +67,9 @@ public class LeaseApplicationService { private StorageSectionApplicationService storageSectionApplicationService; @Autowired - private IShipperLeaseDetailsService shipperLeaseDetailsService; - + private IShipperLeaseDetailsService shipperLeaseDetailsService; + @Autowired + private SystemServiceFeign systemServiceFeign; /** * 分页查询租赁管理列表 @@ -77,23 +78,24 @@ public class LeaseApplicationService { public List queryList(LeaseDO leaseDO) { LoginUser loginUser = SecurityUtils.getLoginUser(); //前端传organizationId = 2827的时候查询所有组织的数据 - Long frontendOrganizationId = leaseDO.getOrganizationId(); - if (frontendOrganizationId != null && frontendOrganizationId == 2827L) { - // 前端传递2827时,查询所有组织的数据,将organizationId设置为null - leaseDO.setOrganizationId(null); - } else { - // 其他情况,只查询当前登录用户所属组织的数据 - if (loginUser != null && loginUser.getUserPo() != null) { - Long userOrganizationId = loginUser.getUserPo().getOrganizationId(); - if (userOrganizationId != null) { - leaseDO.setOrganizationId(userOrganizationId); + if (loginUser != null) { + Long frontendOrganizationId = leaseDO.getOrganizationId(); + if (frontendOrganizationId != null && frontendOrganizationId == 2827L) { + // 前端传递2827时,查询所有组织的数据,将organizationId设置为null + leaseDO.setOrganizationId(null); + } else { + // 其他情况,只查询当前登录用户所属组织的数据 + if (loginUser != null && loginUser.getUserPo() != null) { + Long userOrganizationId = loginUser.getUserPo().getOrganizationId(); + if (userOrganizationId != null) { + leaseDO.setOrganizationId(userOrganizationId); + } } } } return leaseDomainService.queryList(leaseDO); } - /** * 新增租赁管理 */ @@ -113,12 +115,9 @@ public class LeaseApplicationService { return leaseDomainService.insert(leaseDO); } - @Autowired - private SystemServiceFeign systemServiceFeign; - private void setWarehouseInfo(LeaseDO leaseDO) { AjaxResult ajaxResult = systemServiceFeign.getWarehouseInfoByWarehouseId(leaseDO.getWarehouseId()); - if(!"200".equals(String.valueOf(ajaxResult.get("code")))){ + if (!"200".equals(String.valueOf(ajaxResult.get("code")))) { throw new ServiceException("获取仓库信息失败"); } WarehouseFeignPO warehouseFeignPO = com.alibaba.fastjson.JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), WarehouseFeignPO.class); @@ -158,19 +157,18 @@ public class LeaseApplicationService { /** * 获取租赁管理详细信息 */ - public LeasePO getInfo(Long leaseId) - { + public LeasePO getInfo(Long leaseId) { return leaseDomainService.getInfo(leaseId); } /** + * @param leaseIds + * @return Boolean * @description 批量作废租赁 * @author ZhouGY * @date 2024/5/13 9:46 - * @param leaseIds - * @return Boolean */ - public Boolean nullifyByIds(List leaseIds){ + public Boolean nullifyByIds(List leaseIds) { return leaseDomainService.nullifyByIds(leaseIds); } @@ -184,8 +182,8 @@ public class LeaseApplicationService { log.info("开始执行货主租赁明细定时任务"); // 计算前一天的日期,将时间设置为当天的0点0分0秒,只保留日期部分 final Date yesterday = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1)); - - LeaseDO leaseDO = new LeaseDO(); + + LeaseDO leaseDO = new LeaseDO(); leaseDO.setTime(yesterday); //查询有效期内的租赁 List leasePOS = queryList(leaseDO); @@ -195,10 +193,10 @@ public class LeaseApplicationService { List casualRental = leasePOS.stream() .filter(lease -> lease.getLeaseType().equals("散租")) .collect(Collectors.toList()); - + List shipperLeaseDetailsList = new ArrayList<>(); //需要保存或更新的数据 List shipperLeaseDetailsToUpdate = new ArrayList<>(); //需要更新的数据 - + // 查询已存在的货主租赁明细数据(用于判断是新增还是更新) ShipperLeaseDetailsDO queryDO = new ShipperLeaseDetailsDO(); queryDO.setBusinessDate(yesterday); @@ -206,18 +204,18 @@ public class LeaseApplicationService { // 构建已存在数据的Map,key为:业务日期+货主ID+仓库ID+租赁类型 Map existingMap = existingList.stream() .collect(Collectors.toMap( - item -> buildKey(yesterday, item.getShipperId(), item.getWarehouseId(), item.getLeaseType()), - item -> item, - (existing, replacement) -> existing // 如果有重复key,保留第一个 + item -> buildKey(yesterday, item.getShipperId(), item.getWarehouseId(), item.getLeaseType()), + item -> item, + (existing, replacement) -> existing // 如果有重复key,保留第一个 )); - + // 处理整租 for (LeasePO en : entireUnit) { String key = buildKey(yesterday, en.getShipperId(), en.getWarehouseId(), en.getLeaseType()); ShipperLeaseDetails shipperLeaseDetails = new ShipperLeaseDetails(); BeanUtils.copyProperties(en, shipperLeaseDetails); shipperLeaseDetails.setBusinessDate(yesterday); - + // 如果已存在,则更新;否则新增 if (existingMap.containsKey(key)) { ShipperLeaseDetailsPO existing = existingMap.get(key); @@ -227,7 +225,7 @@ public class LeaseApplicationService { shipperLeaseDetailsList.add(shipperLeaseDetails); } } - + // 处理散租:从租赁管理页面维护的面积,效期内的散租客户面积之和 for (LeasePO ca : casualRental) { String key = buildKey(yesterday, ca.getShipperId(), ca.getWarehouseId(), ca.getLeaseType()); @@ -237,7 +235,7 @@ public class LeaseApplicationService { // 散租面积直接使用租赁管理页面维护的面积 shipperLeaseDetails.setLeaseArea(ca.getLeaseArea()); log.info("货主:{},仓库:{},散租面积:{}(来自租赁管理)", ca.getCargoOwnerName(), ca.getWarehouseName(), ca.getLeaseArea()); - + // 如果已存在,则更新;否则新增 if (existingMap.containsKey(key)) { ShipperLeaseDetailsPO existing = existingMap.get(key); @@ -247,22 +245,22 @@ public class LeaseApplicationService { shipperLeaseDetailsList.add(shipperLeaseDetails); } } - + // 批量新增货主租赁明细 if (shipperLeaseDetailsList.size() > 0) { shipperLeaseDetailsService.saveBatch(shipperLeaseDetailsList); log.info("新增货主租赁明细{}条", shipperLeaseDetailsList.size()); } - + // 批量更新货主租赁明细 if (shipperLeaseDetailsToUpdate.size() > 0) { shipperLeaseDetailsService.updateBatchById(shipperLeaseDetailsToUpdate); log.info("更新货主租赁明细{}条", shipperLeaseDetailsToUpdate.size()); } - + log.info("货主租赁明细定时任务执行完成,业务日期:{}", DateUtil.formatDate(yesterday)); } - + /** * 构建唯一key:业务日期+货主ID+仓库ID+租赁类型 */ @@ -293,7 +291,7 @@ public class LeaseApplicationService { ); //获取总面积 BigDecimal totalArea = BigDecimal.ZERO; - StorageSectionDO storageSectionDO = new StorageSectionDO(); + StorageSectionDO storageSectionDO = new StorageSectionDO(); storageSectionDO.setWarehouseId(shipperLeaseDetailsDO.getWarehouseId()); storageSectionDO.setOpeningUp(1); List storageSectionPOS = storageSectionApplicationService.queryList(storageSectionDO); @@ -311,9 +309,9 @@ public class LeaseApplicationService { BigDecimal fractionalLeaseArea = BigDecimal.ZERO; //计算整租和散租 for (ShipperLeaseDetailsPO shipperLeaseDetail : shipperLeaseDetails) { - if (shipperLeaseDetail.getLeaseType().equals("整租")){ + if (shipperLeaseDetail.getLeaseType().equals("整租")) { entireLeaseArea = entireLeaseArea.add(shipperLeaseDetail.getLeaseArea()); - }else { + } else { fractionalLeaseArea = fractionalLeaseArea.add(shipperLeaseDetail.getLeaseArea()); } warehouseOccupancyRate.setWarehouseName(shipperLeaseDetail.getWarehouseName());