| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- package com.zksy.property.service.impl;
- import cn.hutool.core.bean.BeanUtil;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.zksy.property.domain.AContractInfo;
- import com.zksy.property.domain.AHouseInfoDetail;
- import com.zksy.property.domain.ASimplifiedHouseInfo;
- import com.zksy.property.domain.ATenantInfo;
- import com.zksy.property.domain.bo.*;
- import com.zksy.property.domain.dto.ContractFormDTO;
- import com.zksy.property.factory.ContractFactory;
- import com.zksy.property.mapper.AContractInfoMapper;
- import com.zksy.property.service.*;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.annotation.Lazy;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.math.BigDecimal;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.util.List;
- /**
- * @author Administrator
- * @description 针对表【a_contract_info(合同信息表)】的数据库操作Service实现
- * @createDate 2025-07-14 11:59:44
- */
- @Service
- public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, AContractInfo>
- implements AContractInfoService {
- @Autowired
- @Lazy
- private ASimplifiedHouseInfoService aSimplifiedHouseInfoService;
- @Autowired
- private ATenantInfoService aTenantInfoService;
- @Override
- public Page<AContractInfo> findByPage(long pageNum, long pageSize, String contractNumber, String contractDate, String contractStatus) {
- Page<AContractInfo> page = new Page<>(pageNum, pageSize);
- LambdaQueryWrapper<AContractInfo> queryWrapper = new LambdaQueryWrapper();
- queryWrapper.like(contractNumber != null, AContractInfo::getContractNumber, contractNumber);
- queryWrapper.eq(contractDate != null, AContractInfo::getContractDate, contractDate);
- queryWrapper.like(contractStatus != null, AContractInfo::getContractStatus, contractStatus);
- queryWrapper.orderByDesc(AContractInfo::getUpdateTime);
- Page<AContractInfo> page1 = this.page(page, queryWrapper);
- return page1;
- }
- @Override
- public List<AContractInfo> getAContractInfoList(String contractNumber, String contractDate, String contractStatus) {
- LambdaQueryWrapper<AContractInfo> queryWrapper = new LambdaQueryWrapper();
- queryWrapper.like(contractNumber != null, AContractInfo::getContractNumber, contractNumber);
- queryWrapper.eq(contractDate != null, AContractInfo::getContractDate, contractDate);
- queryWrapper.like(contractStatus != null, AContractInfo::getContractStatus, contractStatus);
- List<AContractInfo> list = this.list(queryWrapper);
- return list;
- }
- @Override
- public AContractInfo getBySimplifiedHouseId(String simplifiedHouseId) {
- LambdaQueryWrapper<AContractInfo> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(AContractInfo::getSimplifiedHouseId, simplifiedHouseId);
- return this.getOne(queryWrapper);
- }
- @Autowired
- private AHouseInfoDetailService aHouseInfoDetailService;
- @Override
- @Transactional
- public String signContract(ContractFormDTO dto) {
- AHouseInfoDetail houseInfoDetail = aHouseInfoDetailService.getBySimplifiedHouseId(dto.getHouseId());
- ASimplifiedHouseInfo aSimplifiedHouseInfo = aSimplifiedHouseInfoService.getById(dto.getHouseId());
- if (!"空闲".equals(aSimplifiedHouseInfo.getStatus())) {
- throw new RuntimeException("此房屋已存在合同");
- }
- Contract baseContract = ContractFactory.createContract(aSimplifiedHouseInfo.getAssetType());
- BeanUtil.copyProperties(dto.getContractData(), baseContract);
- RentalTempBo bo = new RentalTempBo();
- var resPath = "";
- if (baseContract instanceof ContractA) {
- processContractA((ContractA) baseContract, aSimplifiedHouseInfo, houseInfoDetail, bo);
- resPath = fillContractData(bo, aSimplifiedHouseInfo.getAssetType());
- } else if (baseContract instanceof ContractB) {
- processContractB((ContractB) baseContract, aSimplifiedHouseInfo, houseInfoDetail, bo);
- resPath = fillContractData(bo, aSimplifiedHouseInfo.getAssetType());
- } else if (baseContract instanceof ContractC) {
- processContractC((ContractC) baseContract, bo);
- resPath = fillContractData(bo, aSimplifiedHouseInfo.getAssetType());
- }
- aSimplifiedHouseInfo.setStatus("已租");
- aSimplifiedHouseInfoService.updateById(aSimplifiedHouseInfo);
- ATenantInfo aTenantInfo = new ATenantInfo();
- aTenantInfo.setTenantName(dto.getRentalInfo().getRentalName());
- aTenantInfo.setTenantNumber(dto.getRentalInfo().getRentalPhone());
- aTenantInfo.setTenantIdCard(dto.getRentalInfo().getRentalIdCard());
- aTenantInfo.setTenantInDate(LocalDate.parse(dto.getRentalInfo().getRentalTimeStart()));
- aTenantInfo.setTenantTime(dto.getRentalInfo().getRentalTime());
- aTenantInfo.setTenantRent(new BigDecimal(dto.getRentalInfo().getRentalRect()));
- aTenantInfo.setSimplifiedHouseId(dto.getHouseId());
- aTenantInfo.setCreateTime(LocalDateTime.now());
- aTenantInfo.setUpdateTime(LocalDateTime.now());
- aTenantInfoService.save(aTenantInfo);
- return resPath;
- }
- private static void processContractC(ContractC baseContract, RentalTempBo bo) {
- ContractC contractC = baseContract;
- //todo 处理bo
- bo.setC1("");
- bo.setC2("");
- bo.setC3("");
- bo.setC4("");
- bo.setC5("");
- bo.setC6("");
- bo.setC7("");
- bo.setC8("");
- bo.setC9("");
- bo.setC10("");
- bo.setC11("");
- bo.setC12("");
- bo.setC13("");
- bo.setC14("");
- bo.setC15("");
- bo.setC16("");
- bo.setC17("");
- bo.setC18("");
- bo.setC19("");
- bo.setC20("");
- bo.setC21("");
- bo.setC22("");
- bo.setC23("");
- bo.setC24("");
- bo.setC25("");
- bo.setC26("");
- bo.setC27("");
- }
- private static void processContractB(ContractB baseContract, ASimplifiedHouseInfo aSimplifiedHouseInfo, AHouseInfoDetail houseDetailInfo, RentalTempBo bo) {
- ContractB contractB = baseContract;
- //todo 处理bo
- bo.setB1(contractB.getPurpose());
- bo.setB2(contractB.getLandlordName());
- bo.setB3(contractB.getLandlordUniCode());
- bo.setB4(contractB.getLandlordLegalRepresentative());
- bo.setB5(contractB.getLandlordDuty());
- bo.setB6(contractB.getTenantName());
- bo.setB7(contractB.getTenantUniCode());
- bo.setB8(contractB.getTenantLegalRepresentative());
- bo.setB9(contractB.getTenantDuty());
- bo.setB10(contractB.getWho());
- bo.setB11(contractB.getWhatTime());
- bo.setB12(contractB.getTitle());
- bo.setB13(aSimplifiedHouseInfo.getHouseName());
- bo.setB14(aSimplifiedHouseInfo.getFloor());
- bo.setB15(houseDetailInfo.getArea());
- bo.setB16(contractB.getSupportingRoomArea());
- bo.setB17(contractB.getOfficeArea());
- bo.setB18(contractB.getCanteenArea());
- bo.setB19(contractB.getTotalLeasedArea());
- bo.setB20(contractB.getDormTotalRooms());
- bo.setB21(contractB.getDormSmallRooms());
- bo.setB22(contractB.getDormLargeRooms());
- bo.setB23(contractB.getDeliveryDate());
- bo.setB24(contractB.getProductionProject());
- bo.setB25(contractB.getLeaseTermYears());
- bo.setB26(contractB.getLeaseStartDate());
- bo.setB27(contractB.getLeaseEndDate());
- bo.setB28(contractB.getRenewNoticeMonths());
- bo.setB29("");
- bo.setB30("");
- bo.setB31("");
- bo.setB32("");
- bo.setB33("");
- bo.setB34("");
- bo.setB35("");
- bo.setB36("");
- bo.setB37("");
- bo.setB38("");
- bo.setB39("");
- bo.setB40("");
- bo.setB41("");
- bo.setB42("");
- bo.setB43("");
- bo.setB44("");
- bo.setB45("");
- bo.setB46("");
- bo.setB47("");
- bo.setB48("");
- bo.setB49("");
- bo.setB50("");
- bo.setB51("");
- bo.setB52("");
- bo.setB53("");
- bo.setB54("");
- bo.setB55("");
- bo.setB56("");
- }
- private static void processContractA(ContractA baseContract, ASimplifiedHouseInfo aSimplifiedHouseInfo, AHouseInfoDetail houseDetailInfo, RentalTempBo bo) {
- ContractA contractA = baseContract;
- bo.setA1(contractA.getLandlordName());
- bo.setA2(contractA.getTenantName());
- bo.setA3(aSimplifiedHouseInfo.getAddress());
- bo.setA4(contractA.getTenantTime());
- bo.setA5(contractA.getTenantTimeStart());
- bo.setA6(contractA.getTenantTimeEnd());
- bo.setA7(contractA.getTenantRent());
- bo.setA8(contractA.getTenantDeposit());
- bo.setA9(contractA.getTenantDepositAmount());
- }
- @Autowired
- private ARentalContractService aRentalContractService;
- private String fillContractData(RentalTempBo bo, String houseType) {
- var f = 0;
- switch (houseType) {
- case "公租房": {
- f = 1;
- break;
- }
- case "厂房": {
- f = 2;
- break;
- }
- case "创新创业基地": {
- f = 3;
- break;
- }
- }
- return aRentalContractService.generatorRental(String.valueOf(f), bo);
- }
- }
|