代码格式化样式

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