|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.air.housing.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.air.common.Constant; |
|
|
|
|
import com.air.enums.BlocksOriginStatusEnum; |
|
|
|
|
import com.air.housing.dto.HousingDefine; |
|
|
|
@ -28,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
@ -63,6 +65,11 @@ public class HousingEstatesServiceImpl extends ServiceImpl<HousingEstatesMapper,
|
|
|
|
|
return housingEstatesMapper.getHousingEstatesNamePage(page, name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 添加楼盘信息操作 |
|
|
|
|
* @param housingDefine |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean createFromOrigin(HousingDefine housingDefine) { |
|
|
|
@ -75,6 +82,7 @@ public class HousingEstatesServiceImpl extends ServiceImpl<HousingEstatesMapper,
|
|
|
|
|
if (null == housingDefine.getBlockId()) { |
|
|
|
|
throw new BusinessException("楼栋id不能为空!"); |
|
|
|
|
} |
|
|
|
|
//查询楼栋信息
|
|
|
|
|
BlocksOrigin blocksOrigin = blocksOriginService.getById(housingDefine.getBlockId()); |
|
|
|
|
if (null == blocksOrigin) { |
|
|
|
|
throw new BusinessException("楼栋id不正确!"); |
|
|
|
@ -109,9 +117,9 @@ public class HousingEstatesServiceImpl extends ServiceImpl<HousingEstatesMapper,
|
|
|
|
|
List<AnnoBlocksRel> annoBlocksRelList = new ArrayList<>(landListedIds.size()); |
|
|
|
|
for (int i = 0; i < landListedIds.size(); i++) { |
|
|
|
|
AnnoBlocksRel annoBlocksRel = new AnnoBlocksRel(); |
|
|
|
|
annoBlocksRel.setHousingEstatesId(housingDefine.getHousingEstateId()); |
|
|
|
|
annoBlocksRel.setLandListedId(landListedIds.get(i)); |
|
|
|
|
annoBlocksRel.setStatusCd(Constant.COMMON_STATUS_1000); |
|
|
|
|
annoBlocksRel.setHousingEstatesId(housingDefine.getHousingEstateId());//楼盘
|
|
|
|
|
annoBlocksRel.setLandListedId(landListedIds.get(i)); //地块
|
|
|
|
|
annoBlocksRel.setStatusCd(Constant.COMMON_STATUS_1000); //状态
|
|
|
|
|
//一个条数据为主要地块
|
|
|
|
|
if (i == 0) { |
|
|
|
|
annoBlocksRel.setMainLand(1); |
|
|
|
@ -152,6 +160,12 @@ public class HousingEstatesServiceImpl extends ServiceImpl<HousingEstatesMapper,
|
|
|
|
|
return baseMapper.selectIPage(page.toPage(), query); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 保存楼栋 |
|
|
|
|
* @param blocksOrigin 楼栋信息 |
|
|
|
|
* @param housingDefine 楼栋数据信息 |
|
|
|
|
* @param formatId 业态信息ID |
|
|
|
|
*/ |
|
|
|
|
private void copyBlocksOriginToBlocks(BlocksOrigin blocksOrigin, HousingDefine housingDefine,Long formatId) { |
|
|
|
|
Blocks blocks = new Blocks(); |
|
|
|
|
blocks.setHousingEstateId(housingDefine.getHousingEstateId()); |
|
|
|
@ -160,37 +174,70 @@ public class HousingEstatesServiceImpl extends ServiceImpl<HousingEstatesMapper,
|
|
|
|
|
blocks.setPreSalePermitNo(blocksOrigin.getPreSaleLicenseNo()); |
|
|
|
|
blocks.setStatusCd(Constant.COMMON_STATUS_1000); |
|
|
|
|
blocksService.save(blocks); |
|
|
|
|
copyHousesOriginToHouses(housingDefine.getBlockId(), blocks.getBlockId()); |
|
|
|
|
copyHousesOriginToHouses(housingDefine.getBlockId(), blocks.getBlockId() ,formatId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void copyHousesOriginToHouses(Long originBlockId, Long blockId) { |
|
|
|
|
List<HousesOrigin> origins = housesOriginService.list(Wrappers.<HousesOrigin>query().lambda().eq(HousesOrigin::getBuildingId, originBlockId)); |
|
|
|
|
/** |
|
|
|
|
* 保存房间数据 |
|
|
|
|
* @param originBlockId 楼栋ID |
|
|
|
|
* @param blockId 楼栋楼盘业态ID |
|
|
|
|
*/ |
|
|
|
|
private void copyHousesOriginToHouses(Long originBlockId, Long blockId,Long formatId) { |
|
|
|
|
List<HousesOrigin> origins = housesOriginService.list(Wrappers.<HousesOrigin>query().lambda().eq(HousesOrigin::getBuildingId, originBlockId));//查询和楼栋关联的房间
|
|
|
|
|
if (origins.size() == 0) { |
|
|
|
|
log.info("没有可复制的HousesOrigin,blockId={}", originBlockId); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
List<Houses> housesList = new ArrayList<>(origins.size()); |
|
|
|
|
List<HousesOrigin> housesOriginList = new ArrayList<>(); //
|
|
|
|
|
BigDecimal totalQuantity= new BigDecimal(0);//供给面积
|
|
|
|
|
origins.forEach(housesOrigin -> { |
|
|
|
|
Houses houses = new Houses(); |
|
|
|
|
houses.setBlockId(blockId); |
|
|
|
|
houses.setCoveredArea(housesOrigin.getCoveredArea()); |
|
|
|
|
houses.setCoveredPrice(housesOrigin.getCoveredPrice()); |
|
|
|
|
houses.setHouseNo(housesOrigin.getHouseNo()); |
|
|
|
|
houses.setHouseType(housesOrigin.getHouseType()); |
|
|
|
|
houses.setHouseUsage(housesOrigin.getHouseUsage()); |
|
|
|
|
houses.setNetSignDate(housesOrigin.getNetSignDate()); |
|
|
|
|
houses.setNetSignStatus(housesOrigin.getNetSignStatus()); |
|
|
|
|
houses.setSaleStatus(housesOrigin.getSaleStatus()); |
|
|
|
|
houses.setSaleDate(housesOrigin.getSaleDate()); |
|
|
|
|
houses.setSleeveArea(housesOrigin.getSleeveArea()); |
|
|
|
|
houses.setSleevePrice(housesOrigin.getSleevePrice()); |
|
|
|
|
houses.setHouseNo(housesOrigin.getHouseNo()); |
|
|
|
|
houses.setSubscribeStatus(housesOrigin.getSubscribeStatus()); |
|
|
|
|
houses.setSubscribeDate(housesOrigin.getSubscribeDate()); |
|
|
|
|
houses.setUnitNum(housesOrigin.getUnitNum()); |
|
|
|
|
houses.setStatusCd(Constant.COMMON_STATUS_1000); |
|
|
|
|
housesList.add(houses); |
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(0); |
|
|
|
|
//去除不是房间的数据
|
|
|
|
|
if(housesOrigin.getSleevePrice().compareTo(bigDecimal) > 0){ |
|
|
|
|
Houses houses = new Houses(); |
|
|
|
|
houses.setBlockId(blockId); |
|
|
|
|
houses.setCoveredArea(housesOrigin.getCoveredArea()); |
|
|
|
|
houses.setCoveredPrice(housesOrigin.getCoveredPrice()); |
|
|
|
|
houses.setHouseNo(housesOrigin.getHouseNo()); |
|
|
|
|
houses.setHouseType(housesOrigin.getHouseType()); |
|
|
|
|
houses.setHouseUsage(housesOrigin.getHouseUsage()); |
|
|
|
|
houses.setNetSignDate(housesOrigin.getNetSignDate()); |
|
|
|
|
houses.setNetSignStatus(housesOrigin.getNetSignStatus()); |
|
|
|
|
houses.setSaleStatus(housesOrigin.getSaleStatus()); |
|
|
|
|
houses.setSaleDate(housesOrigin.getSaleDate()); |
|
|
|
|
houses.setSleeveArea(housesOrigin.getSleeveArea()); |
|
|
|
|
houses.setSleevePrice(housesOrigin.getSleevePrice()); |
|
|
|
|
houses.setHouseNo(housesOrigin.getHouseNo()); |
|
|
|
|
houses.setSubscribeStatus(housesOrigin.getSubscribeStatus()); |
|
|
|
|
houses.setSubscribeDate(housesOrigin.getSubscribeDate()); |
|
|
|
|
houses.setUnitNum(housesOrigin.getUnitNum()); |
|
|
|
|
houses.setStatusCd(Constant.COMMON_STATUS_1000); |
|
|
|
|
housesList.add(houses); |
|
|
|
|
//计算成交的数量,面积
|
|
|
|
|
if(StrUtil.isNotBlank(housesOrigin.getSubscribeStatus()) || StrUtil.isNotBlank(housesOrigin.getNetSignStatus()) ) { |
|
|
|
|
housesOriginList.add(housesOrigin); |
|
|
|
|
} |
|
|
|
|
totalQuantity.add(housesOrigin.getCoveredArea()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
//添加对应的房间信息
|
|
|
|
|
housesService.saveBatch(housesList); |
|
|
|
|
|
|
|
|
|
//修改业态的套数
|
|
|
|
|
Format format = new Format(); |
|
|
|
|
format.setFormatId(formatId); |
|
|
|
|
format.setSupplyCount(housesList.size()); //供应总套数
|
|
|
|
|
format.setDealtCount(housesOriginList.size()); //成交套数
|
|
|
|
|
//已售面积
|
|
|
|
|
BigDecimal bigDecimal = new BigDecimal(0); |
|
|
|
|
housesOriginList.forEach( housesOrigin -> { |
|
|
|
|
bigDecimal.add(housesOrigin.getCoveredArea()); |
|
|
|
|
} ); |
|
|
|
|
format.setSupplyArea(totalQuantity);//供给总面积
|
|
|
|
|
format.setDealtArea(bigDecimal);//成交面积
|
|
|
|
|
format.setNarrowSenseStock(totalQuantity.subtract(bigDecimal));//狭义库存
|
|
|
|
|
formatService.updateById(format); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|