新增楼宇房屋数据接口 --renpc

This commit is contained in:
Renpc-kilig 2023-11-15 19:44:08 +08:00
parent f2e4f0cbf2
commit 5377f14d86
4 changed files with 216 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.result.SuccessResultList;
import com.cm.population.pojo.dtos.house.BatchHouseDTO;
import com.cm.population.pojo.dtos.house.HouseDTO;
import com.cm.population.pojo.vos.house.HouseVO;
import com.cm.population.service.house.IHouseService;
@ -118,4 +119,16 @@ public class HouseController extends AbstractController {
return houseService.listByPopulationInfoId(populationInfoId);
}
@ApiOperation(value = "获取当前楼栋的所有房屋信息", notes = "获取当前楼栋的所有房屋信息接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "buildingId", value = "楼栋ID", paramType = "path"),
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getAllHouse/{buildingId}")
public BatchHouseDTO getAllHouse(@PathVariable("buildingId") String buildingId) {
Map<String, Object> params = requestParams();
params.put("buildingId", buildingId);
return houseService.getAllHouse(params);
}
}

View File

@ -0,0 +1,121 @@
package com.cm.population.pojo.dtos.house;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* @ClassName: HouseDTO
* @Description: 房院管理
* @Author: CodeFactory
* @Date: 2023-10-25 14:47:44
* @Version: 3.0
**/
@ApiModel
public class BatchHouseDTO {
@ApiModelProperty(name = "floorCount", value = "楼层数")
private String floorCount;
@ApiModelProperty(name = "unitCount", value = "单元数")
private String unitCount;
@ApiModelProperty(name = "unitCount", value = "单元数")
private List<Floor> floors;
public String getFloorCount() {
return floorCount;
}
public void setFloorCount(String floorCount) {
this.floorCount = floorCount;
}
public String getUnitCount() {
return unitCount;
}
public void setUnitCount(String unitCount) {
this.unitCount = unitCount;
}
public List<Floor> getFloors() {
return floors;
}
public void setFloors(List<Floor> floors) {
this.floors = floors;
}
public static class Floor {
@ApiModelProperty(name = "name", value = "所在楼层")
private String name;
@ApiModelProperty(name = "units", value = "单元信息")
private List<Unit> units;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Unit> getUnits() {
return units;
}
public void setUnits(List<Unit> units) {
this.units = units;
}
}
public static class Unit {
@ApiModelProperty(name = "name", value = "所在楼层")
private String name;
@ApiModelProperty(name = "houses", value = "单元信息")
private List<House> houses;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<House> getHouses() {
return houses;
}
public void setHouses(List<House> houses) {
this.houses = houses;
}
}
public static class House {
@ApiModelProperty(name = "houseId", value = "房屋ID")
private String houseId;
@ApiModelProperty(name = "name", value = "房屋编号")
private String name;
public String getHouseId() {
return houseId;
}
public void setHouseId(String houseId) {
this.houseId = houseId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}

View File

@ -3,6 +3,7 @@ package com.cm.population.service.house;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResultList;
import com.cm.population.pojo.bos.house.HouseBO;
import com.cm.population.pojo.dtos.house.BatchHouseDTO;
import com.cm.population.pojo.dtos.house.HouseDTO;
import com.cm.population.pojo.pos.house.HousePO;
import com.cm.population.pojo.vos.house.HouseVO;
@ -186,4 +187,6 @@ public interface IHouseService {
Integer count(Map<String, Object> params);
List<HouseDTO> listByPopulationInfoId(String populationInfoId);
BatchHouseDTO getAllHouse(Map<String, Object> params);
}

View File

@ -4,13 +4,12 @@ import com.cm.common.base.AbstractService;
import com.cm.common.pojo.ListPage;
import com.cm.common.pojo.bos.UserInfoBO;
import com.cm.common.result.SuccessResultList;
import com.cm.common.token.app.AppTokenManager;
import com.cm.common.token.app.entity.AppTokenUser;
import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil;
import com.cm.population.dao.house.IHouseDao;
import com.cm.population.pojo.bos.house.HouseBO;
import com.cm.population.pojo.dtos.building.BuildingDTO;
import com.cm.population.pojo.dtos.house.BatchHouseDTO;
import com.cm.population.pojo.dtos.house.HouseDTO;
import com.cm.population.pojo.dtos.residential.ResidentialDTO;
import com.cm.population.pojo.pos.house.HousePO;
@ -21,12 +20,12 @@ import com.cm.population.service.residential.IResidentialService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @ClassName: HouseServiceImpl
@ -216,4 +215,78 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
return list(params);
}
@Override
public BatchHouseDTO getAllHouse(Map<String, Object> params) {
BatchHouseDTO batchHouseDTO = new BatchHouseDTO();
// 获取楼栋信息
BuildingDTO buildingDTO = buildingService.get(params.get("buildingId").toString());
if (null != buildingDTO) {
Integer floorsNum = buildingDTO.getFloorsNum();
Integer unitNum = buildingDTO.getUnitNum();
batchHouseDTO.setFloorCount(floorsNum.toString());
batchHouseDTO.setUnitCount(unitNum.toString());
// 获取当前楼栋下的所有房屋信息
List<HouseDTO> houseDTOList = houseDao.list(params);
List<BatchHouseDTO.Floor> floorList = new ArrayList<>();
for (int i = 1; i <= floorsNum; i++) {
BatchHouseDTO.Floor floor = new BatchHouseDTO.Floor();
floor.setName(i + "");
List<BatchHouseDTO.Unit> unitList = new ArrayList<>();
for (int j = 1; j <= unitNum; j++) {
BatchHouseDTO.Unit unit = new BatchHouseDTO.Unit();
unit.setName(j + "单元");
List<BatchHouseDTO.House> houseList = new ArrayList<>();
for (HouseDTO houseDTO : houseDTOList) {
BatchHouseDTO.House house = new BatchHouseDTO.House();
if (null != houseDTO.getAffiliationFloors()) {
if (i == houseDTO.getAffiliationFloors()) {
if (null != houseDTO.getAffiliatedUnit()) {
if (j == houseDTO.getAffiliationUnit()) {
house.setHouseId(houseDTO.getHouseId());
house.setName(houseDTO.getHouseNum().toString());
houseList.add(house);
}
}
}
}
}
if (houseList.size() > 0) {
unit.setHouses(houseList);
unitList.add(unit);
} else {
unit.setHouses(new ArrayList<>());
unitList.add(unit);
}
}
floorList.add(floor);
floor.setUnits(unitList);
}
batchHouseDTO.setFloors(floorList);
}
List<BatchHouseDTO.Floor> floors = batchHouseDTO.getFloors();
for (BatchHouseDTO.Floor floor : floors) {
List<BatchHouseDTO.Unit> units = floor.getUnits();
boolean flag = false;
for (BatchHouseDTO.Unit unit : units) {
if (null != unit.getHouses() && unit.getHouses().size() > 0) {
flag = true;
}
}
if (!flag) {
floor.setUnits(new ArrayList<>());
}
}
return batchHouseDTO;
}
}