快速建房新增逻辑 --renpc
This commit is contained in:
parent
7a63eeb385
commit
9cd88e2b78
@ -19,6 +19,10 @@ public class AutoHouseDTO {
|
|||||||
private String buildingId;
|
private String buildingId;
|
||||||
@ApiModelProperty(name = "floorUnitHouseCount", value = "每单元每层户数")
|
@ApiModelProperty(name = "floorUnitHouseCount", value = "每单元每层户数")
|
||||||
private Integer floorUnitHouseCount;
|
private Integer floorUnitHouseCount;
|
||||||
|
@ApiModelProperty(name = "appointNum", value = "指定单元数")
|
||||||
|
private Integer appointNum;
|
||||||
|
@ApiModelProperty(name = "sortType", value = "排序类型:1:重复排序;2:连续排序")
|
||||||
|
private Integer sortType;
|
||||||
|
|
||||||
public String getBuildingId() {
|
public String getBuildingId() {
|
||||||
return buildingId;
|
return buildingId;
|
||||||
@ -35,4 +39,20 @@ public class AutoHouseDTO {
|
|||||||
public void setFloorUnitHouseCount(Integer floorUnitHouseCount) {
|
public void setFloorUnitHouseCount(Integer floorUnitHouseCount) {
|
||||||
this.floorUnitHouseCount = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -399,6 +399,53 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
|
|||||||
|
|
||||||
String buildingId = autoHouseDTO.getBuildingId();
|
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);
|
BuildingDTO buildingDTO = buildingService.get(buildingId);
|
||||||
if (null != buildingDTO) {
|
if (null != buildingDTO) {
|
||||||
// 楼层数
|
// 楼层数
|
||||||
@ -445,6 +492,53 @@ public class HouseServiceImpl extends AbstractService implements IHouseService {
|
|||||||
|
|
||||||
executorService.shutdown();
|
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 {
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -28,6 +28,19 @@
|
|||||||
<input type="number" id="floorUnitHouseCount" name="floorUnitHouseCount" class="layui-input" value="" step="1" placeholder="请输入每层每单元户数" lay-verify="required|unsignInt">
|
<input type="number" id="floorUnitHouseCount" name="floorUnitHouseCount" class="layui-input" value="" step="1" placeholder="请输入每层每单元户数" lay-verify="required|unsignInt">
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
<div class="layui-form-item layui-layout-admin">
|
<div class="layui-form-item layui-layout-admin">
|
||||||
<div class="layui-input-block">
|
<div class="layui-input-block">
|
||||||
|
Loading…
Reference in New Issue
Block a user