代码格式化样式
This commit is contained in:
+39
-41
@@ -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<LeasePO> 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<Long> leaseIds){
|
||||
public Boolean nullifyByIds(List<Long> 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<LeasePO> leasePOS = queryList(leaseDO);
|
||||
@@ -195,10 +193,10 @@ public class LeaseApplicationService {
|
||||
List<LeasePO> casualRental = leasePOS.stream()
|
||||
.filter(lease -> lease.getLeaseType().equals("散租"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
List<ShipperLeaseDetails> shipperLeaseDetailsList = new ArrayList<>(); //需要保存或更新的数据
|
||||
List<ShipperLeaseDetails> shipperLeaseDetailsToUpdate = new ArrayList<>(); //需要更新的数据
|
||||
|
||||
|
||||
// 查询已存在的货主租赁明细数据(用于判断是新增还是更新)
|
||||
ShipperLeaseDetailsDO queryDO = new ShipperLeaseDetailsDO();
|
||||
queryDO.setBusinessDate(yesterday);
|
||||
@@ -206,18 +204,18 @@ public class LeaseApplicationService {
|
||||
// 构建已存在数据的Map,key为:业务日期+货主ID+仓库ID+租赁类型
|
||||
Map<String, ShipperLeaseDetailsPO> 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<StorageSectionPO> 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());
|
||||
|
||||
Reference in New Issue
Block a user