From c37ea09c23b76f2da7f075292ff273a5fb579935 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 03 四月 2026 14:49:13 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/2.0.1' into 2.0.1
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwRoomServiceImpl.java | 105 ++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 77 insertions(+), 28 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwRoomServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwRoomServiceImpl.java
index af4bcbc..65e696b 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwRoomServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwRoomServiceImpl.java
@@ -25,10 +25,7 @@
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -70,6 +67,7 @@
model.setStatus(Constants.ZERO);
model.setEditDate(model.getCreateDate());
model.setEditor(model.getCreator());
+ model.setLeaseNowStatus(Constants.ZERO);
ywRoomMapper.insert(model);
return model.getId();
}
@@ -141,6 +139,10 @@
queryWrapper.selectAll(YwRoom.class )
.selectAs(YwProject::getName,YwRoom::getProjectName)
.selectAs(YwFloor::getName,YwRoom::getFloorName)
+// .select(" ifnull( ( select case when y1.status = 3 then now() BETWEEN y1.START_DATE and y1.BT_DATE else now() BETWEEN y1.START_DATE and y1.END_DATE END " +
+// "from yw_contract y1 left join yw_contract_room y2 on y1.id = y2.CONTRACT_ID and y2.TYPE = 0 " +
+// "where y1.`STATUS` <> 4 and y2.room_id = t.id order by y1.create_date desc limit 1 ) ,0) ",YwRoom::getLeaseStatus)
+ .select(" ifnull( ( case when t.IS_INVESTMENT = 0 then 2 else t.LEASE_NOW_STATUS end ) ,0) ",YwRoom::getLeaseStatus)
.selectAs(YwBuilding::getName,YwRoom::getBuildingName)
.leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
.leftJoin(YwBuilding.class,YwBuilding::getId,YwRoom::getBuildingId)
@@ -173,9 +175,10 @@
.selectAs(YwProject::getName,YwRoom::getProjectName)
.selectAs(YwFloor::getName,YwRoom::getFloorName)
.selectAs(YwBuilding::getName,YwRoom::getBuildingName)
- .select(" ifnull( ( select case when y1.status = 3 then now() BETWEEN y1.START_DATE and y1.BT_DATE else now() BETWEEN y1.START_DATE and y1.END_DATE END " +
- "from yw_contract y1 left join yw_contract_room y2 on y1.id = y2.CONTRACT_ID and y2.TYPE = 0 " +
- "where y1.`STATUS` <> 4 and y2.room_id = t.id order by y1.create_date desc limit 1 ) ,0) ",YwRoom::getLeaseStatus)
+// .select(" ifnull( ( select case when y1.status = 3 then now() BETWEEN y1.START_DATE and y1.BT_DATE else now() BETWEEN y1.START_DATE and y1.END_DATE END " +
+// "from yw_contract y1 left join yw_contract_room y2 on y1.id = y2.CONTRACT_ID and y2.TYPE = 0 " +
+// "where y1.`STATUS` <> 4 and y2.room_id = t.id order by y1.create_date desc limit 1 ) ,0) ",YwRoom::getLeaseStatus)
+ .select(" ifnull( ( case when t.IS_INVESTMENT = 0 then 2 else t.LEASE_NOW_STATUS end ) ,0) ",YwRoom::getLeaseStatus)
.leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
.leftJoin(YwBuilding.class,YwBuilding::getId,YwRoom::getBuildingId)
.leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor);
@@ -245,11 +248,11 @@
}
queryWrapper.orderByAsc(YwRoom::getRoomNum);
IPage<YwRoom> iPage = ywRoomMapper.selectJoinPage(page,YwRoom.class, queryWrapper);
- for (YwRoom ywRoom:iPage.getRecords()) {
- if(Constants.equalsInteger(ywRoom.getIsInvestment(),Constants.ZERO)){
- ywRoom.setLeaseStatus(Constants.TWO);
- }
- }
+// for (YwRoom ywRoom:iPage.getRecords()) {
+// if(Constants.equalsInteger(ywRoom.getIsInvestment(),Constants.ZERO)){
+// ywRoom.setLeaseStatus(Constants.TWO);
+// }
+// }
return PageData.from(iPage);
}
@@ -288,7 +291,7 @@
YwRoomStatusDataVO roomStatusDataVO = new YwRoomStatusDataVO();
roomStatusDataVO.setFloorId(ywRoom.getFloor());
roomStatusDataVO.setRoomId(ywRoom.getId());
- roomStatusDataVO.setRoomCode(ywRoom.getCode());
+ roomStatusDataVO.setRoomCode(ywRoom.getRoomNum());
roomStatusDataVO.setRoomRentArea(ywRoom.getRentArea());
List<YwContract> roomContractList = ywContractMapper.selectJoinList(YwContract.class,new MPJLambdaWrapper<YwContract>()
@@ -297,15 +300,39 @@
.leftJoin(YwContractRoom.class,YwContractRoom::getContractId,YwContract::getId)
.leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
.eq(YwContract::getIsdeleted,Constants.ZERO)
- .ge(YwContract::getStartDate, DateUtil.getCurrDateTime())
+ .le(YwContract::getStartDate, DateUtil.getCurrDateTime())
+ .ge(YwContract::getEndDate, DateUtil.getCurrDateTime())
.eq(YwContractRoom::getType,Constants.ZERO)
.eq(YwContractRoom::getRoomId,ywRoom.getId())
- .ne(YwContract::getBillStatus,Constants.THREE)
.orderByDesc(YwContract::getStartDate)
+ .orderByDesc(YwContract::getId)
);
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(roomContractList)){
roomStatusDataVO.setRoomStatus(Constants.ZERO);
- roomStatusDataVO.setFreeDayAmount(Constants.ZERO);
+ //鏌ヨ鏄惁鏈夊凡閫�绉熷悎鍚�
+ List<YwContract> roomRentContractList = ywContractMapper.selectJoinList(YwContract.class,new MPJLambdaWrapper<YwContract>()
+ .selectAll(YwContract.class)
+ .selectAs(YwCustomer::getName,YwContract::getRenterName)
+ .leftJoin(YwContractRoom.class,YwContractRoom::getContractId,YwContract::getId)
+ .leftJoin(YwCustomer.class,YwCustomer::getId,YwContract::getRenterId)
+ .eq(YwContract::getIsdeleted,Constants.ZERO)
+ .eq(YwContract::getStatus,Constants.FOUR)
+ .eq(YwContractRoom::getType,Constants.ZERO)
+ .eq(YwContractRoom::getRoomId,ywRoom.getId())
+ .orderByDesc(YwContract::getStartDate)
+ .orderByDesc(YwContract::getId)
+ );
+ if(CollectionUtils.isEmpty(roomRentContractList)){
+ roomStatusDataVO.setFreeDayAmount(Constants.ZERO);
+ }else{
+ YwContract ywContract = roomRentContractList.get(Constants.ZERO);
+ //鏌ヨ閫�绉熸棩鏈熷拰褰撳墠鏃ユ湡鐩稿樊澶╂暟
+ Integer btDays = DateUtil.daysBetweenDates(new Date(),ywContract.getBtDate());
+ if(btDays>=Constants.ZERO){
+ roomStatusDataVO.setFreeDayAmount(btDays);
+ }
+ }
+
}else{
YwContract ywContract = roomContractList.get(Constants.ZERO);
//鍚堝悓鐘舵�� 0寰呮墽琛� 1鎵ц涓� 2宸插埌鏈� 3閫�绉熶腑 4宸查��绉�
@@ -320,9 +347,24 @@
roomStatusDataVO.setOverData(ywContract.getBtDate());
}
}else{
- if(Objects.nonNull(ywContract.getEndDate()) && DateUtil.getBetweenDays(DateUtil.getFomartDate(ywContract.getEndDate(),"yyyy-MM-dd"),DateUtil.getFomartDate(new Date(),"yyyy-MM-dd"))<=90){
+ System.out.println(DateUtil.daysBetweenDates(ywContract.getEndDate(),new Date()));
+ if(Objects.nonNull(ywContract.getEndDate())
+ &&
+ DateUtil.daysBetweenDates(ywContract.getEndDate(),new Date())<=90){
roomStatusDataVO.setRoomStatus(Constants.TWO);
roomStatusDataVO.setOverData(ywContract.getEndDate());
+ }else{
+ roomStatusDataVO.setOverData(ywContract.getEndDate());
+ }
+ }
+ }else{
+ roomStatusDataVO.setRoomStatus(Constants.ZERO);
+ //宸查��绉� 璁$畻閫�绉熸椂闂�
+ if(Objects.nonNull(ywContract.getBtDate())){
+ //鏌ヨ閫�绉熸棩鏈熷拰褰撳墠鏃ユ湡鐩稿樊澶╂暟
+ Integer btDays = DateUtil.daysBetweenDates(new Date(),ywContract.getBtDate());
+ if(btDays>=Constants.ZERO){
+ roomStatusDataVO.setFreeDayAmount(btDays);
}
}
}
@@ -332,12 +374,15 @@
}
for (YwFloor ywFloor:ywFloorList) {
YwFloorStatusDataVO ywFloorStatusDataVO = new YwFloorStatusDataVO();
- ywFloorStatusDataVO.setFloor(ywFloor.getFloor());
+ ywFloorStatusDataVO.setFloorName(ywFloor.getName());
ywFloorStatusDataVO.setFloorId(ywFloor.getId());
- ywFloorStatusDataVO.setFloorArea(ywFloor.getArea());
+ ywFloorStatusDataVO.setFloorArea(BigDecimal.ZERO);
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(roomStatusDataList)){
List<YwRoomStatusDataVO> floorRoomList = roomStatusDataList.stream().filter(i->Objects.nonNull(i.getFloorId())&&Constants.equalsInteger(i.getFloorId(),ywFloor.getId())).collect(Collectors.toList());
ywFloorStatusDataVO.setYwRoomStatusDataVOList(floorRoomList);
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(floorRoomList)){
+ ywFloorStatusDataVO.setFloorArea(floorRoomList.stream().filter(i->Objects.nonNull(i.getRoomRentArea())).map(i->i.getRoomRentArea()).reduce(BigDecimal.ZERO,BigDecimal::add));
+ }
}
ywFloorStatusDataVOList.add(ywFloorStatusDataVO);
}
@@ -358,6 +403,7 @@
ywRoomContractDataVO.setLeasePrice(BigDecimal.ZERO);
ywRoomContractDataVO.setLeaseArea(BigDecimal.ZERO);
ywRoomContractDataVO.setLeaseRoomAmount(Constants.ZERO);
+ ywRoomContractDataVO.setLeaseDayPrice(BigDecimal.ZERO);
List<YwRoom> ywRoomList = ywRoomMapper.selectList(new QueryWrapper<YwRoom>().lambda()
.eq(YwRoom::getIsdeleted,Constants.ZERO)
@@ -376,15 +422,13 @@
List<YwContract> roomContractList = ywContractMapper.selectJoinList(YwContract.class,new MPJLambdaWrapper<YwContract>()
.selectAll(YwContract.class)
.select(" ( select ifnull(sum(yr.RENT_AREA),0) from yw_contract_room y left join yw_room yr on y.room_id = yr.id where y.type = 0 and y.CONTRACT_ID = t.id ) " , YwContract::getTotalArea)
- .select(" ( select ifnull(sum(y.TOTLE_FEE),0) from yw_contract_bill y where y.CONTRACT_ID = t.id and y.type = 0 ) " , YwContract::getTotalFee)
+ .select(" ( select ifnull(sum(y.TOTLE_FEE),0) from yw_contract_bill y where y.CONTRACT_ID = t.id and y.type = 0 and y.COST_TYPE=0 and y.BILL_TYPE = 0 ) " , YwContract::getTotalFee)
.eq(YwContract::getIsdeleted,Constants.ZERO)
- .in(YwContract::getStatus,Constants.ONE,Constants.TWO,Constants.THREE)
- .ne(YwContract::getBillStatus,Constants.THREE)
+ .in(YwContract::getStatus,Constants.ZERO,Constants.ONE,Constants.TWO,Constants.THREE)
.apply(Objects.nonNull(model.getBuildingId()),
" t.id in ( select y.CONTRACT_ID from yw_contract_room y left join yw_room yr on y.room_id = yr.id where y.type = 0 and yr.BUILDING_ID = "+model.getBuildingId()+" ) ")
.apply(Objects.nonNull(model.getProjectId()),
" t.id in ( select y.CONTRACT_ID from yw_contract_room y left join yw_room yr on y.room_id = yr.id where y.type = 0 and yr.PROJECT_ID = "+model.getProjectId()+" ) ")
- .apply(Objects.nonNull(model.getProjectId())," ")
.orderByDesc(YwContract::getStartDate)
);
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(roomContractList)){
@@ -392,17 +436,21 @@
}
//澶勭悊绉熻祦鍗曚环 鏍规嵁 鍚堝悓绉熻祦鎬婚 / 锛堢璧佹椂闀� * 绉熻祦闈㈢Н锛�
for (YwContract ywContract:roomContractList) {
- long contractDayAmount = DateUtil.getBetweenDays(DateUtil.getFomartDate(ywContract.getEndDate(),"yyyy-MM-dd"),DateUtil.getFomartDate(ywContract.getStartDate(),"yyyy-MM-dd"));
+ long contractDayAmount = DateUtil.daysBetweenDates(ywContract.getEndDate()
+ ,ywContract.getStartDate());
if(Objects.nonNull(contractDayAmount) && Objects.nonNull(ywContract.getTotalArea()) && Objects.nonNull(ywContract.getTotalFee())){
- ywRoomContractDataVO.setLeasePrice(
- ywRoomContractDataVO.getLeasePrice().add(
+ ywRoomContractDataVO.setLeaseDayPrice(
+ ywRoomContractDataVO.getLeaseDayPrice().add(
ywContract.getTotalFee().divide((ywContract.getTotalArea().multiply(new BigDecimal(Long.toString(contractDayAmount)))),2,BigDecimal.ROUND_HALF_UP)
)
);
}
}
-
ywRoomContractDataVO.setLeaseContractAmount(roomContractList.size());
+ if(Objects.nonNull(ywRoomContractDataVO.getLeaseDayPrice())&&ywRoomContractDataVO.getLeaseDayPrice().compareTo(BigDecimal.ZERO)>Constants.ZERO){
+ ywRoomContractDataVO.setLeasePrice(
+ ywRoomContractDataVO.getLeaseDayPrice().divide(new BigDecimal(Integer.toString(ywRoomContractDataVO.getLeaseContractAmount())),2,BigDecimal.ROUND_HALF_UP));
+ }
List<Integer> contractId = roomContractList.stream().map(i->i.getId()).collect(Collectors.toList());
List<YwRoom> ywLeaseRoomList = ywRoomMapper.selectJoinList(YwRoom.class,new MPJLambdaWrapper<YwRoom>()
.selectAll(YwRoom.class)
@@ -413,7 +461,8 @@
.eq(Objects.nonNull(model.getBuildingId()),YwRoom::getBuildingId,model.getBuildingId())
.eq(Objects.nonNull(model.getProjectId()),YwRoom::getProjectId,model.getProjectId())
.in(YwContractRoom::getContractId,contractId)
- .orderByAsc(YwRoom::getSortnum)
+ .last(" group by t.id " +
+ "ORDER BY t.sortnum ASC ")
);
if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywLeaseRoomList)){
ywRoomContractDataVO.setLeaseArea(
--
Gitblit v1.9.3