AContractInfoServiceImpl.java 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. package com.zksy.property.service.impl;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6. import com.zksy.property.domain.AContractInfo;
  7. import com.zksy.property.domain.AHouseInfoDetail;
  8. import com.zksy.property.domain.ASimplifiedHouseInfo;
  9. import com.zksy.property.domain.ATenantInfo;
  10. import com.zksy.property.domain.bo.*;
  11. import com.zksy.property.domain.dto.ContractFormDTO;
  12. import com.zksy.property.factory.ContractFactory;
  13. import com.zksy.property.mapper.AContractInfoMapper;
  14. import com.zksy.property.service.*;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.context.annotation.Lazy;
  17. import org.springframework.stereotype.Service;
  18. import org.springframework.transaction.annotation.Transactional;
  19. import java.math.BigDecimal;
  20. import java.time.LocalDate;
  21. import java.time.LocalDateTime;
  22. import java.util.List;
  23. /**
  24. * @author Administrator
  25. * @description 针对表【a_contract_info(合同信息表)】的数据库操作Service实现
  26. * @createDate 2025-07-14 11:59:44
  27. */
  28. @Service
  29. public class AContractInfoServiceImpl extends ServiceImpl<AContractInfoMapper, AContractInfo>
  30. implements AContractInfoService {
  31. @Autowired
  32. @Lazy
  33. private ASimplifiedHouseInfoService aSimplifiedHouseInfoService;
  34. @Autowired
  35. private ATenantInfoService aTenantInfoService;
  36. @Override
  37. public Page<AContractInfo> findByPage(long pageNum, long pageSize, String contractNumber, String contractDate, String contractStatus) {
  38. Page<AContractInfo> page = new Page<>(pageNum, pageSize);
  39. LambdaQueryWrapper<AContractInfo> queryWrapper = new LambdaQueryWrapper();
  40. queryWrapper.like(contractNumber != null, AContractInfo::getContractNumber, contractNumber);
  41. queryWrapper.eq(contractDate != null, AContractInfo::getContractDate, contractDate);
  42. queryWrapper.like(contractStatus != null, AContractInfo::getContractStatus, contractStatus);
  43. queryWrapper.orderByDesc(AContractInfo::getUpdateTime);
  44. Page<AContractInfo> page1 = this.page(page, queryWrapper);
  45. return page1;
  46. }
  47. @Override
  48. public List<AContractInfo> getAContractInfoList(String contractNumber, String contractDate, String contractStatus) {
  49. LambdaQueryWrapper<AContractInfo> queryWrapper = new LambdaQueryWrapper();
  50. queryWrapper.like(contractNumber != null, AContractInfo::getContractNumber, contractNumber);
  51. queryWrapper.eq(contractDate != null, AContractInfo::getContractDate, contractDate);
  52. queryWrapper.like(contractStatus != null, AContractInfo::getContractStatus, contractStatus);
  53. List<AContractInfo> list = this.list(queryWrapper);
  54. return list;
  55. }
  56. @Override
  57. public AContractInfo getBySimplifiedHouseId(String simplifiedHouseId) {
  58. LambdaQueryWrapper<AContractInfo> queryWrapper = new LambdaQueryWrapper<>();
  59. queryWrapper.eq(AContractInfo::getSimplifiedHouseId, simplifiedHouseId);
  60. return this.getOne(queryWrapper);
  61. }
  62. @Autowired
  63. private AHouseInfoDetailService aHouseInfoDetailService;
  64. @Override
  65. @Transactional
  66. public String signContract(ContractFormDTO dto) {
  67. AHouseInfoDetail houseInfoDetail = aHouseInfoDetailService.getBySimplifiedHouseId(dto.getHouseId());
  68. ASimplifiedHouseInfo aSimplifiedHouseInfo = aSimplifiedHouseInfoService.getById(dto.getHouseId());
  69. if (!"空闲".equals(aSimplifiedHouseInfo.getStatus())) {
  70. throw new RuntimeException("此房屋已存在合同");
  71. }
  72. Contract baseContract = ContractFactory.createContract(aSimplifiedHouseInfo.getAssetType());
  73. BeanUtil.copyProperties(dto.getContractData(), baseContract);
  74. RentalTempBo bo = new RentalTempBo();
  75. var resPath = "";
  76. if (baseContract instanceof ContractA) {
  77. processContractA((ContractA) baseContract, aSimplifiedHouseInfo, houseInfoDetail, bo);
  78. resPath = fillContractData(bo, aSimplifiedHouseInfo.getAssetType());
  79. } else if (baseContract instanceof ContractB) {
  80. processContractB((ContractB) baseContract, aSimplifiedHouseInfo, houseInfoDetail, bo);
  81. resPath = fillContractData(bo, aSimplifiedHouseInfo.getAssetType());
  82. } else if (baseContract instanceof ContractC) {
  83. processContractC((ContractC) baseContract, bo);
  84. resPath = fillContractData(bo, aSimplifiedHouseInfo.getAssetType());
  85. }
  86. aSimplifiedHouseInfo.setStatus("已租");
  87. aSimplifiedHouseInfoService.updateById(aSimplifiedHouseInfo);
  88. ATenantInfo aTenantInfo = new ATenantInfo();
  89. aTenantInfo.setTenantName(dto.getRentalInfo().getRentalName());
  90. aTenantInfo.setTenantNumber(dto.getRentalInfo().getRentalPhone());
  91. aTenantInfo.setTenantIdCard(dto.getRentalInfo().getRentalIdCard());
  92. aTenantInfo.setTenantInDate(LocalDate.parse(dto.getRentalInfo().getRentalTimeStart()));
  93. aTenantInfo.setTenantTime(dto.getRentalInfo().getRentalTime());
  94. aTenantInfo.setTenantRent(new BigDecimal(dto.getRentalInfo().getRentalRect()));
  95. aTenantInfo.setSimplifiedHouseId(dto.getHouseId());
  96. aTenantInfo.setCreateTime(LocalDateTime.now());
  97. aTenantInfo.setUpdateTime(LocalDateTime.now());
  98. aTenantInfoService.save(aTenantInfo);
  99. return resPath;
  100. }
  101. private static void processContractC(ContractC baseContract, RentalTempBo bo) {
  102. ContractC contractC = baseContract;
  103. //todo 处理bo
  104. bo.setC1("");
  105. bo.setC2("");
  106. bo.setC3("");
  107. bo.setC4("");
  108. bo.setC5("");
  109. bo.setC6("");
  110. bo.setC7("");
  111. bo.setC8("");
  112. bo.setC9("");
  113. bo.setC10("");
  114. bo.setC11("");
  115. bo.setC12("");
  116. bo.setC13("");
  117. bo.setC14("");
  118. bo.setC15("");
  119. bo.setC16("");
  120. bo.setC17("");
  121. bo.setC18("");
  122. bo.setC19("");
  123. bo.setC20("");
  124. bo.setC21("");
  125. bo.setC22("");
  126. bo.setC23("");
  127. bo.setC24("");
  128. bo.setC25("");
  129. bo.setC26("");
  130. bo.setC27("");
  131. }
  132. private static void processContractB(ContractB baseContract, ASimplifiedHouseInfo aSimplifiedHouseInfo, AHouseInfoDetail houseDetailInfo, RentalTempBo bo) {
  133. ContractB contractB = baseContract;
  134. //todo 处理bo
  135. bo.setB1(contractB.getPurpose());
  136. bo.setB2(contractB.getLandlordName());
  137. bo.setB3(contractB.getLandlordUniCode());
  138. bo.setB4(contractB.getLandlordLegalRepresentative());
  139. bo.setB5(contractB.getLandlordDuty());
  140. bo.setB6(contractB.getTenantName());
  141. bo.setB7(contractB.getTenantUniCode());
  142. bo.setB8(contractB.getTenantLegalRepresentative());
  143. bo.setB9(contractB.getTenantDuty());
  144. bo.setB10(contractB.getWho());
  145. bo.setB11(contractB.getWhatTime());
  146. bo.setB12(contractB.getTitle());
  147. bo.setB13(aSimplifiedHouseInfo.getHouseName());
  148. bo.setB14(aSimplifiedHouseInfo.getFloor());
  149. bo.setB15(houseDetailInfo.getArea());
  150. bo.setB16(contractB.getSupportingRoomArea());
  151. bo.setB17(contractB.getOfficeArea());
  152. bo.setB18(contractB.getCanteenArea());
  153. bo.setB19(contractB.getTotalLeasedArea());
  154. bo.setB20(contractB.getDormTotalRooms());
  155. bo.setB21(contractB.getDormSmallRooms());
  156. bo.setB22(contractB.getDormLargeRooms());
  157. bo.setB23(contractB.getDeliveryDate());
  158. bo.setB24(contractB.getProductionProject());
  159. bo.setB25(contractB.getLeaseTermYears());
  160. bo.setB26(contractB.getLeaseStartDate());
  161. bo.setB27(contractB.getLeaseEndDate());
  162. bo.setB28(contractB.getRenewNoticeMonths());
  163. bo.setB29("");
  164. bo.setB30("");
  165. bo.setB31("");
  166. bo.setB32("");
  167. bo.setB33("");
  168. bo.setB34("");
  169. bo.setB35("");
  170. bo.setB36("");
  171. bo.setB37("");
  172. bo.setB38("");
  173. bo.setB39("");
  174. bo.setB40("");
  175. bo.setB41("");
  176. bo.setB42("");
  177. bo.setB43("");
  178. bo.setB44("");
  179. bo.setB45("");
  180. bo.setB46("");
  181. bo.setB47("");
  182. bo.setB48("");
  183. bo.setB49("");
  184. bo.setB50("");
  185. bo.setB51("");
  186. bo.setB52("");
  187. bo.setB53("");
  188. bo.setB54("");
  189. bo.setB55("");
  190. bo.setB56("");
  191. }
  192. private static void processContractA(ContractA baseContract, ASimplifiedHouseInfo aSimplifiedHouseInfo, AHouseInfoDetail houseDetailInfo, RentalTempBo bo) {
  193. ContractA contractA = baseContract;
  194. bo.setA1(contractA.getLandlordName());
  195. bo.setA2(contractA.getTenantName());
  196. bo.setA3(aSimplifiedHouseInfo.getAddress());
  197. bo.setA4(contractA.getTenantTime());
  198. bo.setA5(contractA.getTenantTimeStart());
  199. bo.setA6(contractA.getTenantTimeEnd());
  200. bo.setA7(contractA.getTenantRent());
  201. bo.setA8(contractA.getTenantDeposit());
  202. bo.setA9(contractA.getTenantDepositAmount());
  203. }
  204. @Autowired
  205. private ARentalContractService aRentalContractService;
  206. private String fillContractData(RentalTempBo bo, String houseType) {
  207. var f = 0;
  208. switch (houseType) {
  209. case "公租房": {
  210. f = 1;
  211. break;
  212. }
  213. case "厂房": {
  214. f = 2;
  215. break;
  216. }
  217. case "创新创业基地": {
  218. f = 3;
  219. break;
  220. }
  221. }
  222. return aRentalContractService.generatorRental(String.valueOf(f), bo);
  223. }
  224. }