Browse Source

楼盘管理

feature/v.2.0.0
caoyizhong 3 years ago
parent
commit
65e6c12136
  1. 97
      air/src/main/java/com/air/housing/service/impl/HousingEstatesServiceImpl.java
  2. 5
      air/src/main/java/com/air/origin/controller/BlocksOriginController.java
  3. 2
      air/src/main/java/com/air/origin/dto/BlocksOriginQuery.java
  4. 2
      air/src/main/resources/mapper/BlocksOriginMapper.xml

97
air/src/main/java/com/air/housing/service/impl/HousingEstatesServiceImpl.java

@ -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);
}
}

5
air/src/main/java/com/air/origin/controller/BlocksOriginController.java

@ -11,6 +11,7 @@ import com.cinderella.framework.common.data.mybatis.QueryPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -26,6 +27,7 @@ import java.util.List;
@AllArgsConstructor
@RequestMapping("/blocks_origin")
@Api(value = "blocks_origin", tags = "楼栋信息管理")
@Slf4j
public class BlocksOriginController {
private final BlocksOriginService blocksOriginService;
@ -38,7 +40,8 @@ public class BlocksOriginController {
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page")
public R<Page<BlocksOrigin>> getBlocksOriginPage(QueryPage queryPage, BlocksOriginQuery blocksOriginQuery) {
public R<Page<BlocksOrigin>> getBlocksOriginPage(QueryPage queryPage, BlocksOriginQuery blocksOriginQuery,String city) {
log.info("===================={}===={}",blocksOriginQuery,city);
Page<BlocksOrigin> page = queryPage.toPage();
List<BlocksOrigin> blocksOrigins = blocksOriginService.pageSer(page, blocksOriginQuery);
return R.ok(page.setRecords(blocksOrigins),"查询成功");

2
air/src/main/java/com/air/origin/dto/BlocksOriginQuery.java

@ -21,7 +21,7 @@ import java.util.Date;
@Data
@EqualsAndHashCode
@ApiModel(value = "楼栋信息查询条件")
public class BlocksOriginQuery {
public class BlocksOriginQuery {
@ApiModelProperty(value = "楼盘id")
private String itemId;
@ApiModelProperty(value = "315楼盘名称(爬虫获取的)")

2
air/src/main/resources/mapper/BlocksOriginMapper.xml

@ -31,6 +31,8 @@
<if test="query.statusCd != null and query.statusCd != ''">and status_cd = #{query.statusCd}</if>
<if test="query.createDate != null and query.createDate != ''">and date_format(create_date, '%Y-%m-%d') = #{query.createDate}</if>
<if test="query.name != null and query.name != ''">and name like concat('%',#{query.name} ,'%') </if>
<if test="query.netName != null and query.netName != ''">and net_name like concat('%',#{query.netName} ,'%') </if>
<if test="query.preSaleLicenseNo != null and query.preSaleLicenseNo != ''">and pre_sale_license_no like concat('%',#{query.preSaleLicenseNo} ,'%') </if>
</where>
</select>
</mapper>

Loading…
Cancel
Save