快速建房新增逻辑 --renpc

This commit is contained in:
Renpc-kilig 2023-11-22 21:55:05 +08:00
parent 7a63eeb385
commit 9cd88e2b78
3 changed files with 145 additions and 0 deletions

View File

@ -19,6 +19,10 @@ public class AutoHouseDTO {
private String buildingId;
@ApiModelProperty(name = "floorUnitHouseCount", value = "每单元每层户数")
private Integer floorUnitHouseCount;
@ApiModelProperty(name = "appointNum", value = "指定单元数")
private Integer appointNum;
@ApiModelProperty(name = "sortType", value = "排序类型1重复排序2连续排序")
private Integer sortType;
public String getBuildingId() {
return buildingId;
@ -35,4 +39,20 @@ public class AutoHouseDTO {
public void setFloorUnitHouseCount(Integer floorUnitHouseCount) {
this.floorUnitHouseCount = floorUnitHouseCount;
}
public Integer getAppointNum() {
return appointNum;
}
public void setAppointNum(Integer appointNum) {
this.appointNum = appointNum;
}
public Integer getSortType() {
return sortType;
}
public void setSortType(Integer sortType) {
this.sortType = sortType;
}
}

View File

@ -399,6 +399,53 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
String buildingId = autoHouseDTO.getBuildingId();
BuildingDTO buildingDTO = buildingService.get(buildingId);
if (null != buildingDTO) {
// 楼层数
int floorsNum = Integer.valueOf(buildingDTO.getFloorsNum());
// 单元数
int unitNum = Integer.valueOf(buildingDTO.getUnitNum());
// 每层户数
int houseCount = autoHouseDTO.getFloorUnitHouseCount();
// 指定单元数
Integer appointNum = autoHouseDTO.getAppointNum();
// 排序类型
int sortType = autoHouseDTO.getSortType();
if (null != appointNum) {
hasUnit(sortType, appointNum, floorsNum, houseCount,
buildingDTO, appointNum, houseVOList);
} else {
hasUnit(sortType, 1, floorsNum, houseCount,
buildingDTO, unitNum, houseVOList);
}
int size = houseVOList.size();
int numThreads = size / 5 + (size % 5 == 0 ? 0 : 1); // 计算需要的线程数
ExecutorService executorService = Executors.newFixedThreadPool(numThreads);
for (int i = 0; i < size; i += 5) {
int end = Math.min(i + 5, size);
List<HouseVO> subList = houseVOList.subList(i, end);
executorService.submit(new saveHouse(subList, userInfoBO));
}
executorService.shutdown();
}
}
// saveAuto备份
/*public void saveAuto(String token, AutoHouseDTO autoHouseDTO) {
UserInfoBO userInfoBO = this.securityComponent.getCurrentUser();
List<HouseVO> houseVOList = new ArrayList<>();
String buildingId = autoHouseDTO.getBuildingId();
BuildingDTO buildingDTO = buildingService.get(buildingId);
if (null != buildingDTO) {
// 楼层数
@ -445,6 +492,53 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
executorService.shutdown();
}
}*/
/**
* 指定单元专用方法
*
* @param floorsNum
* @param houseCount
* @param buildingDTO
* @param unitNum
* @param houseVOList
*/
private void hasUnit(int sortType, int forNum, int floorsNum, int houseCount,
BuildingDTO buildingDTO, int unitNum, List<HouseVO> houseVOList) {
String houseNum = "";
for (int floor = 1; floor <= floorsNum; floor++) {
int flagNum = 0;
for (int unit = forNum; unit <= unitNum; unit++) {
for (int house = 1; house <= houseCount; house++) {
if (1 == sortType) {
flagNum = house;
} else if (2 == sortType) {
flagNum += 1;
}
houseNum = floor + "0" + flagNum;
HouseVO houseVO = new HouseVO();
// 基本信息街道社区小区楼栋
houseVO.setStreet(buildingDTO.getStreet());
houseVO.setStreetName(buildingDTO.getStreetName());
houseVO.setCommunity(buildingDTO.getCommunity());
houseVO.setCommunityName(buildingDTO.getCommunityName());
houseVO.setResidentialId(buildingDTO.getResidentialId());
houseVO.setResidentialName(buildingDTO.getResidentialName());
houseVO.setBuildingId(buildingDTO.getBuildingId());
houseVO.setBuildingName(buildingDTO.getName());
// 房屋信息单元楼层房号
houseVO.setAffiliationUnit("" + unit);
houseVO.setAffiliationFloors(String.valueOf(floor));
houseVO.setHouseNum(houseNum);
houseVOList.add(houseVO);
}
}
}
}
public class saveHouse implements Runnable {
@ -486,4 +580,22 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
}
}
public static void main(String[] args) {
int unit = 3;
int floor = 5;
int house = 3;
for (int i = 1; i < unit; i++) {
int num = 0;
for (int i1 = 1; i1 < floor; i1++) {
for (int i2 = 1; i2 < house; i2++) {
num++;
System.out.println(num);
}
if (num == house) {
num = house;
}
}
}
}
}

View File

@ -28,6 +28,19 @@
<input type="number" id="floorUnitHouseCount" name="floorUnitHouseCount" class="layui-input" value="" step="1" placeholder="请输入每层每单元户数" lay-verify="required|unsignInt">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="width: 140px;">指定单元数</label>
<div class="layui-input-block" style="margin-left: 140px;">
<input type="number" id="appointNum" name="appointNum" class="layui-input" value="" step="1" placeholder="请输入指定单元数">
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label" style="width: 140px;">排序类型</label>
<div class="layui-input-block">
<input type="radio" name="sortType" lay-filter="sortType" value="1" title="重复排序" checked>
<input type="radio" name="sortType" lay-filter="sortType" value="2" title="连续排序">
</div>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">