From a5f40b4c2590a3d61592f1918d689d4932545248 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期三, 22 一月 2025 15:06:38 +0800
Subject: [PATCH] ll
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwRoomServiceImpl.java | 187 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 183 insertions(+), 4 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 fc67f80..af4bcbc 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
@@ -6,12 +6,13 @@
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
+import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.Utils;
-import com.doumee.dao.business.YwBuildingMapper;
-import com.doumee.dao.business.YwContractRoomMapper;
-import com.doumee.dao.business.YwRoomMapper;
-import com.doumee.dao.business.YwWorkorderMapper;
+import com.doumee.dao.business.*;
import com.doumee.dao.business.model.*;
+import com.doumee.dao.business.vo.YwFloorStatusDataVO;
+import com.doumee.dao.business.vo.YwRoomContractDataVO;
+import com.doumee.dao.business.vo.YwRoomStatusDataVO;
import com.doumee.service.business.YwRoomService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -23,8 +24,12 @@
import org.springframework.stereotype.Service;
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.stream.Collectors;
/**
* 杩愮淮鎴挎簮淇℃伅琛⊿ervice瀹炵幇
@@ -41,7 +46,13 @@
@Autowired
private YwContractRoomMapper ywContractRoomMapper;
@Autowired
+ private YwContractMapper ywContractMapper;
+
+ @Autowired
private YwWorkorderMapper ywWorkorderMapper;
+ @Autowired
+ private YwFloorMapper ywFloorMapper;
+
@Override
public Integer create(YwRoom model) {
@@ -247,4 +258,172 @@
QueryWrapper<YwRoom> wrapper = new QueryWrapper<>(ywRoom);
return ywRoomMapper.selectCount(wrapper);
}
+
+
+
+ @Override
+ public List<YwFloorStatusDataVO> getRoomStatusList(YwRoom model){
+ if(Objects.isNull(model)
+ || (Objects.isNull(model.getBuildingId()) && Objects.isNull(model.getFloor()))){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ List<YwFloorStatusDataVO> ywFloorStatusDataVOList = new ArrayList<>();
+ List<YwFloor> ywFloorList = ywFloorMapper.selectList(new QueryWrapper<YwFloor>().lambda()
+ .eq(YwFloor::getIsdeleted,Constants.ZERO)
+ .eq(Objects.nonNull(model.getBuildingId()),YwFloor::getBuildingId,model.getBuildingId())
+ .eq(Objects.nonNull(model.getFloor()),YwFloor::getId,model.getFloor())
+ .orderByAsc(YwFloor::getFloor)
+ );
+ List<YwRoom> ywRoomList = ywRoomMapper.selectList(new QueryWrapper<YwRoom>().lambda()
+ .eq(YwRoom::getIsdeleted,Constants.ZERO)
+ .eq(YwRoom::getIsInvestment,Constants.ONE)
+ .eq(YwRoom::getStatus,Constants.ZERO)
+ .eq(Objects.nonNull(model.getBuildingId()),YwRoom::getBuildingId,model.getBuildingId())
+ .eq(Objects.nonNull(model.getFloor()),YwRoom::getFloor,model.getFloor())
+ .orderByAsc(YwRoom::getSortnum)
+ );
+ List<YwRoomStatusDataVO> roomStatusDataList = new ArrayList<>();
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywRoomList)){
+ for (YwRoom ywRoom:ywRoomList) {
+ YwRoomStatusDataVO roomStatusDataVO = new YwRoomStatusDataVO();
+ roomStatusDataVO.setFloorId(ywRoom.getFloor());
+ roomStatusDataVO.setRoomId(ywRoom.getId());
+ roomStatusDataVO.setRoomCode(ywRoom.getCode());
+ roomStatusDataVO.setRoomRentArea(ywRoom.getRentArea());
+
+ List<YwContract> roomContractList = 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)
+ .ge(YwContract::getStartDate, DateUtil.getCurrDateTime())
+ .eq(YwContractRoom::getType,Constants.ZERO)
+ .eq(YwContractRoom::getRoomId,ywRoom.getId())
+ .ne(YwContract::getBillStatus,Constants.THREE)
+ .orderByDesc(YwContract::getStartDate)
+ );
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(roomContractList)){
+ roomStatusDataVO.setRoomStatus(Constants.ZERO);
+ roomStatusDataVO.setFreeDayAmount(Constants.ZERO);
+ }else{
+ YwContract ywContract = roomContractList.get(Constants.ZERO);
+ //鍚堝悓鐘舵�� 0寰呮墽琛� 1鎵ц涓� 2宸插埌鏈� 3閫�绉熶腑 4宸查��绉�
+ //寰呮墽琛�/鎵ц涓�/閫�绉熶腑 鍧囧睘浜庡凡鍑虹 鏍规嵁鍏蜂綋鍒版湡鏃堕棿鍒ゆ柇鏄惁澶勪簬鍗冲皢鍒版湡 90澶�
+ if(Constants.equalsInteger(ywContract.getStatus(),Constants.ZERO)||Constants.equalsInteger(ywContract.getStatus(),Constants.ONE)||
+ Constants.equalsInteger(ywContract.getStatus(),Constants.THREE)){
+ roomStatusDataVO.setRoomStatus(Constants.ONE);
+ roomStatusDataVO.setCustomerName(ywContract.getRenterName());
+ if(Constants.equalsInteger(ywContract.getStatus(),Constants.THREE)){
+ if(Objects.nonNull(ywContract.getBtDate()) && DateUtil.getBetweenDays(DateUtil.getFomartDate(ywContract.getBtDate(),"yyyy-MM-dd"),DateUtil.getFomartDate(new Date(),"yyyy-MM-dd"))<=90){
+ roomStatusDataVO.setRoomStatus(Constants.TWO);
+ 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){
+ roomStatusDataVO.setRoomStatus(Constants.TWO);
+ roomStatusDataVO.setOverData(ywContract.getEndDate());
+ }
+ }
+ }
+ }
+ roomStatusDataList.add(roomStatusDataVO);
+ }
+ }
+ for (YwFloor ywFloor:ywFloorList) {
+ YwFloorStatusDataVO ywFloorStatusDataVO = new YwFloorStatusDataVO();
+ ywFloorStatusDataVO.setFloor(ywFloor.getFloor());
+ ywFloorStatusDataVO.setFloorId(ywFloor.getId());
+ ywFloorStatusDataVO.setFloorArea(ywFloor.getArea());
+ 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);
+ }
+ ywFloorStatusDataVOList.add(ywFloorStatusDataVO);
+ }
+ return ywFloorStatusDataVOList;
+ }
+
+
+ @Override
+ public YwRoomContractDataVO getRoomContract(YwRoom model){
+ if(Objects.isNull(model)
+ || (Objects.isNull(model.getBuildingId()) && Objects.isNull(model.getProjectId()))){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ YwRoomContractDataVO ywRoomContractDataVO = new YwRoomContractDataVO();
+ ywRoomContractDataVO.setInvestmentRoomAmount(Constants.ZERO);
+ ywRoomContractDataVO.setInvestmentArea(BigDecimal.ZERO);
+ ywRoomContractDataVO.setLeaseContractAmount(Constants.ZERO);
+ ywRoomContractDataVO.setLeasePrice(BigDecimal.ZERO);
+ ywRoomContractDataVO.setLeaseArea(BigDecimal.ZERO);
+ ywRoomContractDataVO.setLeaseRoomAmount(Constants.ZERO);
+
+ List<YwRoom> ywRoomList = ywRoomMapper.selectList(new QueryWrapper<YwRoom>().lambda()
+ .eq(YwRoom::getIsdeleted,Constants.ZERO)
+ .eq(YwRoom::getStatus,Constants.ZERO)
+ .eq(YwRoom::getIsInvestment,Constants.ONE)
+ .eq(Objects.nonNull(model.getBuildingId()),YwRoom::getBuildingId,model.getBuildingId())
+ .eq(Objects.nonNull(model.getProjectId()),YwRoom::getProjectId,model.getProjectId())
+ .orderByAsc(YwRoom::getSortnum)
+ );
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isEmpty(ywRoomList)){
+ return ywRoomContractDataVO;
+ }
+ ywRoomContractDataVO.setInvestmentRoomAmount(ywRoomList.size());
+ ywRoomContractDataVO.setInvestmentArea(ywRoomList.stream().filter(i->Objects.nonNull(i.getRentArea())).map(i->i.getRentArea()).reduce(BigDecimal.ZERO,BigDecimal::add));
+
+ 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)
+ .eq(YwContract::getIsdeleted,Constants.ZERO)
+ .in(YwContract::getStatus,Constants.ONE,Constants.TWO,Constants.THREE)
+ .ne(YwContract::getBillStatus,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)){
+ return ywRoomContractDataVO;
+ }
+ //澶勭悊绉熻祦鍗曚环 鏍规嵁 鍚堝悓绉熻祦鎬婚 / 锛堢璧佹椂闀� * 绉熻祦闈㈢Н锛�
+ for (YwContract ywContract:roomContractList) {
+ long contractDayAmount = DateUtil.getBetweenDays(DateUtil.getFomartDate(ywContract.getEndDate(),"yyyy-MM-dd"),DateUtil.getFomartDate(ywContract.getStartDate(),"yyyy-MM-dd"));
+ if(Objects.nonNull(contractDayAmount) && Objects.nonNull(ywContract.getTotalArea()) && Objects.nonNull(ywContract.getTotalFee())){
+ ywRoomContractDataVO.setLeasePrice(
+ ywRoomContractDataVO.getLeasePrice().add(
+ ywContract.getTotalFee().divide((ywContract.getTotalArea().multiply(new BigDecimal(Long.toString(contractDayAmount)))),2,BigDecimal.ROUND_HALF_UP)
+ )
+ );
+ }
+ }
+
+ ywRoomContractDataVO.setLeaseContractAmount(roomContractList.size());
+ 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)
+ .leftJoin(YwContractRoom.class,YwContractRoom::getRoomId,YwRoom::getId)
+ .eq(YwRoom::getIsdeleted,Constants.ZERO)
+ .eq(YwRoom::getIsInvestment,Constants.ONE)
+ .eq(YwRoom::getStatus,Constants.ZERO)
+ .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)
+ );
+ if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywLeaseRoomList)){
+ ywRoomContractDataVO.setLeaseArea(
+ ywLeaseRoomList.stream().filter(i->Objects.nonNull(i.getRentArea())).map(i->i.getRentArea()).reduce(BigDecimal.ZERO,BigDecimal::add)
+ );
+ ywRoomContractDataVO.setLeaseRoomAmount(ywLeaseRoomList.size());
+ }
+ return ywRoomContractDataVO;
+ }
+
+
+
}
--
Gitblit v1.9.3