diff --git a/src/main/java/com/cm/population/controller/api/building/BuildingController.java b/src/main/java/com/cm/population/controller/api/building/BuildingController.java index ec21392..5c6d0d3 100644 --- a/src/main/java/com/cm/population/controller/api/building/BuildingController.java +++ b/src/main/java/com/cm/population/controller/api/building/BuildingController.java @@ -9,6 +9,7 @@ import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.population.pojo.dtos.building.BuildingDTO; +import com.cm.population.pojo.vos.building.BuildingBatchVO; import com.cm.population.pojo.vos.building.BuildingVO; import com.cm.population.service.building.IBuildingService; import io.swagger.annotations.*; @@ -108,4 +109,13 @@ public class BuildingController extends AbstractController { return new SuccessResultData<>(buildingService.count(params)); } + @ApiOperation(value = "新增楼排管理", notes = "新增楼排管理接口") + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("saveBatch") + @CheckRequestBodyAnnotation + public SuccessResult saveBatch(@RequestBody BuildingBatchVO buildingBatchVO) { + buildingService.saveBatch(buildingBatchVO); + return new SuccessResult(); + } + } \ No newline at end of file diff --git a/src/main/java/com/cm/population/controller/app/api/building/BuildingAppController.java b/src/main/java/com/cm/population/controller/app/api/building/BuildingAppController.java index 506e717..abf5e28 100644 --- a/src/main/java/com/cm/population/controller/app/api/building/BuildingAppController.java +++ b/src/main/java/com/cm/population/controller/app/api/building/BuildingAppController.java @@ -9,6 +9,7 @@ import com.cm.common.result.SuccessResult; import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.population.pojo.dtos.building.BuildingDTO; +import com.cm.population.pojo.vos.building.BuildingBatchVO; import com.cm.population.pojo.vos.building.BuildingVO; import com.cm.population.service.building.IBuildingService; import io.swagger.annotations.*; @@ -120,4 +121,16 @@ public class BuildingAppController extends AbstractController { return new SuccessResultData<>(buildingService.count(params)); } + @ApiOperation(value = "新增楼排管理", notes = "新增楼排管理接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "token", value = "token", paramType = "header") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @PostMapping("saveBatch") + @CheckRequestBodyAnnotation + public SuccessResult saveBatch(@RequestHeader("token") String token, @RequestBody BuildingBatchVO buildingBatchVO) { + buildingService.saveBatch(token, buildingBatchVO); + return new SuccessResult(); + } + } \ No newline at end of file diff --git a/src/main/java/com/cm/population/controller/route/building/BuildingRouteController.java b/src/main/java/com/cm/population/controller/route/building/BuildingRouteController.java index 6354e9f..a0ce3dd 100644 --- a/src/main/java/com/cm/population/controller/route/building/BuildingRouteController.java +++ b/src/main/java/com/cm/population/controller/route/building/BuildingRouteController.java @@ -58,6 +58,14 @@ public class BuildingRouteController extends AbstractController { return new ModelAndView("building/list-myself"); } + @GetMapping("save-batch") + public ModelAndView saveBatch() { + ModelAndView mv = new ModelAndView(); + mv.setViewName("building/save-batch"); + setBaiduMapInit(mv); + return mv; + } + private void setBaiduMapInit(ModelAndView modelAndView) { String mapCenter = EnvManager.getInstance().getValue("MAP_CENTER"); if (StringUtils.isBlank(mapCenter)) { diff --git a/src/main/java/com/cm/population/controller/route/house/HouseRouteController.java b/src/main/java/com/cm/population/controller/route/house/HouseRouteController.java index dc0389d..b92ac7d 100644 --- a/src/main/java/com/cm/population/controller/route/house/HouseRouteController.java +++ b/src/main/java/com/cm/population/controller/route/house/HouseRouteController.java @@ -49,10 +49,4 @@ public class HouseRouteController extends AbstractController { public ModelAndView listMyself() { return new ModelAndView("house/list-myself"); } - - @GetMapping("save-batch") - public ModelAndView saveBatch() { - return new ModelAndView("house/save-batch"); - } - } \ No newline at end of file diff --git a/src/main/java/com/cm/population/pojo/vos/building/BuildingBatchVO.java b/src/main/java/com/cm/population/pojo/vos/building/BuildingBatchVO.java new file mode 100644 index 0000000..4384806 --- /dev/null +++ b/src/main/java/com/cm/population/pojo/vos/building/BuildingBatchVO.java @@ -0,0 +1,251 @@ +package com.cm.population.pojo.vos.building; + +import com.cm.common.annotation.CheckNumberAnnotation; +import com.cm.population.pojo.vos.house.HouseVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +/** + * @ClassName: BuildingVO + * @Description: 楼排管理 + * @Author: CodeFactory + * @Date: 2023-10-25 14:44:10 + * @Version: 3.0 + **/ +@ApiModel +public class BuildingBatchVO { + + public BuildingBatchVO() { + } + + @ApiModelProperty(name = "street", value = "街道ID") + private String street; + @ApiModelProperty(name = "streetName", value = "街道名称") + private String streetName; + @ApiModelProperty(name = "community", value = "所在社区") + private String community; + @ApiModelProperty(name = "communityName", value = "所在社区名称") + private String communityName; + @ApiModelProperty(name = "residentialId", value = "所在小区ID") + private String residentialId; + @ApiModelProperty(name = "residentialName", value = "所在小区名称") + private String residentialName; + @ApiModelProperty(name = "name", value = "楼排名称") + private String name; + @ApiModelProperty(name = "buildNum", value = "楼/排号") + @CheckNumberAnnotation(name = "楼/排号") + private Integer buildNum; + @ApiModelProperty(name = "floorsNum", value = "楼层数") + @CheckNumberAnnotation(name = "楼层数") + private Integer floorsNum; + @ApiModelProperty(name = "unitNum", value = "单元/排数") + @CheckNumberAnnotation(name = "单元/排数") + private Integer unitNum; + @ApiModelProperty(name = "address", value = "详细地址") + private String address; + @ApiModelProperty(name = "longitude", value = "经度") + private String longitude; + @ApiModelProperty(name = "latitude", value = "纬度") + private String latitude; + @ApiModelProperty(name = "image", value = "图片") + private String image; + @ApiModelProperty(name = "resultList", value = "批量录入房屋信息") + private List resultList; + + public String getCommunity() { + return community == null ? "" : community.trim(); + } + + public void setCommunity(String community) { + this.community = community; + } + + public String getCommunityName() { + return communityName == null ? "" : communityName.trim(); + } + + public void setCommunityName(String communityName) { + this.communityName = communityName; + } + + public String getResidentialId() { + return residentialId == null ? "" : residentialId.trim(); + } + + public void setResidentialId(String residentialId) { + this.residentialId = residentialId; + } + + public String getResidentialName() { + return residentialName == null ? "" : residentialName.trim(); + } + + public void setResidentialName(String residentialName) { + this.residentialName = residentialName; + } + + public String getName() { + return name == null ? "" : name.trim(); + } + + public void setName(String name) { + this.name = name; + } + + public Integer getBuildNum() { + return buildNum == null ? 0 : buildNum; + } + + public void setBuildNum(Integer buildNum) { + this.buildNum = buildNum; + } + + public Integer getFloorsNum() { + return floorsNum == null ? 0 : floorsNum; + } + + public void setFloorsNum(Integer floorsNum) { + this.floorsNum = floorsNum; + } + + public Integer getUnitNum() { + return unitNum; + } + + public void setUnitNum(Integer unitNum) { + this.unitNum = unitNum; + } + + public String getAddress() { + return address == null ? "" : address.trim(); + } + + public void setAddress(String address) { + this.address = address; + } + + public String getLongitude() { + return longitude == null ? "" : longitude.trim(); + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getLatitude() { + return latitude == null ? "" : latitude.trim(); + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getImage() { + return image == null ? "" : image.trim(); + } + + public void setImage(String image) { + this.image = image; + } + + public String getStreet() { + return street; + } + + public void setStreet(String street) { + this.street = street; + } + + public String getStreetName() { + return streetName; + } + + public void setStreetName(String streetName) { + this.streetName = streetName; + } + + public List getResultList() { + return resultList; + } + + public void setResultList(List resultList) { + this.resultList = resultList; + } + + public static class BatchVO { + + public BatchVO() { + } + + @ApiModelProperty(name = "unitValue", value = "单元信息") + private String unitValue; + @ApiModelProperty(name = "floorList", value = "楼层信息") + private List floorList; + + public String getUnitValue() { + return unitValue; + } + + public void setUnitValue(String unitValue) { + this.unitValue = unitValue; + } + + public List getFloorList() { + return floorList; + } + + public void setFloorList(List floorList) { + this.floorList = floorList; + } + + } + + public static class FloorVO { + + public FloorVO() { + } + + @ApiModelProperty(name = "floorValue", value = "单元信息") + private String floorValue; + @ApiModelProperty(name = "houseList", value = "房屋信息集合") + private List houseList; + + public String getFloorValue() { + return floorValue; + } + + public void setFloorValue(String floorValue) { + this.floorValue = floorValue; + } + + public List getHouseList() { + return houseList; + } + + public void setHouseList(List houseList) { + this.houseList = houseList; + } + + } + + public static class HouseVO { + + public HouseVO() { + } + + @ApiModelProperty(name = "houseValue", value = "房屋信息") + private String houseValue; + + public String getHouseValue() { + return houseValue; + } + + public void setHouseValue(String houseValue) { + this.houseValue = houseValue; + } + } +} + + diff --git a/src/main/java/com/cm/population/pojo/vos/house/HouseVO.java b/src/main/java/com/cm/population/pojo/vos/house/HouseVO.java index 7e2f631..7e4beaa 100644 --- a/src/main/java/com/cm/population/pojo/vos/house/HouseVO.java +++ b/src/main/java/com/cm/population/pojo/vos/house/HouseVO.java @@ -32,10 +32,10 @@ public class HouseVO { private Integer affiliationUnit; @ApiModelProperty(name = "affiliationFloors", value = "所在层/院") @CheckNumberAnnotation(name = "所在层/院") - private Integer affiliationFloors; + private String affiliationFloors; @ApiModelProperty(name = "houseNum", value = "门牌号") @CheckNumberAnnotation(name = "门牌号") - private Integer houseNum; + private String houseNum; @ApiModelProperty(name = "categoryId", value = "房屋类别") private String categoryId; @ApiModelProperty(name = "categoryName", value = "房屋类别名称") @@ -170,19 +170,19 @@ public class HouseVO { this.affiliationUnit = affiliationUnit; } - public Integer getAffiliationFloors() { - return affiliationFloors == null ? 0 : affiliationFloors; + public String getAffiliationFloors() { + return affiliationFloors; } - public void setAffiliationFloors(Integer affiliationFloors) { + public void setAffiliationFloors(String affiliationFloors) { this.affiliationFloors = affiliationFloors; } - public Integer getHouseNum() { - return houseNum == null ? 0 : houseNum; + public String getHouseNum() { + return houseNum; } - public void setHouseNum(Integer houseNum) { + public void setHouseNum(String houseNum) { this.houseNum = houseNum; } diff --git a/src/main/java/com/cm/population/service/building/IBuildingService.java b/src/main/java/com/cm/population/service/building/IBuildingService.java index eef3300..dd2754d 100644 --- a/src/main/java/com/cm/population/service/building/IBuildingService.java +++ b/src/main/java/com/cm/population/service/building/IBuildingService.java @@ -5,6 +5,7 @@ import com.cm.common.result.SuccessResultList; import com.cm.population.pojo.bos.building.BuildingBO; import com.cm.population.pojo.dtos.building.BuildingDTO; import com.cm.population.pojo.pos.building.BuildingPO; +import com.cm.population.pojo.vos.building.BuildingBatchVO; import com.cm.population.pojo.vos.building.BuildingVO; import java.util.List; @@ -185,4 +186,38 @@ public interface IBuildingService { */ Integer count(Map params); + /** + * 批量新增房屋信息 + * + * @param buildingBatchVO + * @return + */ + void saveBatch(BuildingBatchVO buildingBatchVO); + + /** + * 新增楼排管理 + * + * @param token + * @param buildingBatchVO + * @return + */ + void saveBatch(String token, BuildingBatchVO buildingBatchVO); + + /** + * 新增楼排管理 + * + * @param buildingBatchVO + * @return buildingId + */ + String saveBatchReturnId(BuildingBatchVO buildingBatchVO); + + /** + * 新增楼排管理 + * + * @param token + * @param buildingBatchVO + * @return buildingId + */ + String saveBatchReturnId(String token, BuildingBatchVO buildingBatchVO); + } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/building/impl/BuildingServiceImpl.java b/src/main/java/com/cm/population/service/building/impl/BuildingServiceImpl.java index 204a1d8..959dc64 100644 --- a/src/main/java/com/cm/population/service/building/impl/BuildingServiceImpl.java +++ b/src/main/java/com/cm/population/service/building/impl/BuildingServiceImpl.java @@ -13,8 +13,11 @@ import com.cm.population.pojo.bos.building.BuildingBO; import com.cm.population.pojo.dtos.building.BuildingDTO; import com.cm.population.pojo.dtos.residential.ResidentialDTO; import com.cm.population.pojo.pos.building.BuildingPO; +import com.cm.population.pojo.vos.building.BuildingBatchVO; import com.cm.population.pojo.vos.building.BuildingVO; +import com.cm.population.pojo.vos.house.HouseVO; import com.cm.population.service.building.IBuildingService; +import com.cm.population.service.house.IHouseService; import com.cm.population.service.residential.IResidentialService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -38,6 +41,8 @@ public class BuildingServiceImpl extends AbstractService implements IBuildingSer private IBuildingDao buildingDao; @Autowired private IResidentialService residentialService; + @Autowired + private IHouseService houseService; @Override public void save(BuildingVO buildingVO) { @@ -157,14 +162,14 @@ public class BuildingServiceImpl extends AbstractService implements IBuildingSer @Override public List list(Map params) { - if(null != params.get("myself")) { + if (null != params.get("myself")) { UserInfoBO userInfoBO = this.securityComponent.getCurrentUser(); params.put("creator", userInfoBO.getUserId()); } List list = buildingDao.list(params); for (BuildingDTO buildingDTO : list) { ResidentialDTO residentialDTO = residentialService.get(buildingDTO.getResidentialId()); - if(null != residentialDTO) { + if (null != residentialDTO) { buildingDTO.setResidentialName(residentialDTO.getName()); } } @@ -195,4 +200,62 @@ public class BuildingServiceImpl extends AbstractService implements IBuildingSer return count == null ? 0 : count; } + @Override + public void saveBatch(BuildingBatchVO buildingBatchVO) { + saveBatchReturnId(buildingBatchVO); + } + + @Override + public void saveBatch(String token, BuildingBatchVO buildingBatchVO) { + saveBatchReturnId(token, buildingBatchVO); + } + + @Override + public String saveBatchReturnId(BuildingBatchVO buildingBatchVO) { + return saveBatchReturnId(null, buildingBatchVO); + } + + @Override + public String saveBatchReturnId(String token, BuildingBatchVO buildingBatchVO) { + String buildingId = UUIDUtil.getUUID(); + Map params = null; + try { + params = HashMapUtil.beanToMap(buildingBatchVO); + } catch (Exception e) { + e.printStackTrace(); + } + params.put("buildingId", buildingId); + if (StringUtils.isBlank(token)) { + setSaveInfo(params); + } else { + setSaveInfo(token, params); + } + buildingDao.save(params); + + List resultList = buildingBatchVO.getResultList(); + if (null != resultList && resultList.size() > 0) { + for (BuildingBatchVO.BatchVO batchVO : resultList) { + for (BuildingBatchVO.FloorVO floorVO : batchVO.getFloorList()) { + for (BuildingBatchVO.HouseVO houseVO : floorVO.getHouseList()) { + HouseVO insertHouseVO = new HouseVO(); + // 基本信息 + insertHouseVO.setResidentialId(buildingBatchVO.getResidentialId()); + insertHouseVO.setResidentialName(buildingBatchVO.getResidentialName()); + insertHouseVO.setStreet(buildingBatchVO.getStreet()); + insertHouseVO.setStreetName(buildingBatchVO.getStreetName()); + insertHouseVO.setCommunity(buildingBatchVO.getCommunity()); + insertHouseVO.setCommunityName(buildingBatchVO.getCommunityName()); + + insertHouseVO.setBuildingId(buildingId); + insertHouseVO.setAffiliatedUnit(batchVO.getUnitValue()); + insertHouseVO.setAffiliationFloors(floorVO.getFloorValue()); + insertHouseVO.setHouseNum(houseVO.getHouseValue()); + houseService.save(insertHouseVO); + } + } + } + } + return buildingId; + } + } \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/building/building-mapper.xml b/src/main/resources/mybatis/mapper/building/building-mapper.xml index c60bb08..bc75c58 100644 --- a/src/main/resources/mybatis/mapper/building/building-mapper.xml +++ b/src/main/resources/mybatis/mapper/building/building-mapper.xml @@ -327,6 +327,9 @@ AND t1.residential_id = #{residentialId} + + AND t1.residential_name = #{residentialName} + AND t1.street = #{street} diff --git a/src/main/resources/templates/house/save.html b/src/main/resources/templates/house/save.html index 6ae8b19..18748dd 100644 --- a/src/main/resources/templates/house/save.html +++ b/src/main/resources/templates/house/save.html @@ -94,7 +94,7 @@
- +
diff --git a/src/main/resources/templates/house/update.html b/src/main/resources/templates/house/update.html index dd5ca5f..c84a27b 100644 --- a/src/main/resources/templates/house/update.html +++ b/src/main/resources/templates/house/update.html @@ -94,7 +94,7 @@
- +