diff --git a/src/main/java/com/cm/population/pojo/dtos/house/AutoHouseDTO.java b/src/main/java/com/cm/population/pojo/dtos/house/AutoHouseDTO.java index 118b194..fc47bf8 100644 --- a/src/main/java/com/cm/population/pojo/dtos/house/AutoHouseDTO.java +++ b/src/main/java/com/cm/population/pojo/dtos/house/AutoHouseDTO.java @@ -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; + } } diff --git a/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java b/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java index bab565c..ac6ee18 100644 --- a/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java +++ b/src/main/java/com/cm/population/service/house/impl/HouseServiceImpl.java @@ -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 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 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 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; + } + } + } + } + } \ No newline at end of file diff --git a/src/main/resources/templates/house/save-quick.html b/src/main/resources/templates/house/save-quick.html index 07aefaa..c3a4e2c 100644 --- a/src/main/resources/templates/house/save-quick.html +++ b/src/main/resources/templates/house/save-quick.html @@ -28,6 +28,19 @@ +
+ +
+ +
+
+
+ +
+ + +
+