diff --git a/src/main/java/com/cm/population/controller/api/residential/ResidentialController.java b/src/main/java/com/cm/population/controller/api/residential/ResidentialController.java index 79a107d..0e6f3d2 100644 --- a/src/main/java/com/cm/population/controller/api/residential/ResidentialController.java +++ b/src/main/java/com/cm/population/controller/api/residential/ResidentialController.java @@ -18,6 +18,7 @@ import com.cm.common.result.SuccessResultData; import com.cm.common.result.SuccessResultList; import com.cm.population.config.properties.ProjectProperties; import com.cm.population.pojo.dtos.community.CommunityDTO; +import com.cm.population.pojo.dtos.grid.GridDTO; import com.cm.population.pojo.dtos.residential.ResidentialDTO; import com.cm.population.pojo.vos.building.BuildingVO; import com.cm.population.pojo.vos.residential.ReadExcelResidentialModel; @@ -29,6 +30,8 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.client.RestTemplate; @@ -190,7 +193,7 @@ public class ResidentialController extends AbstractController { @ApiOperation(value = "新增小区管理", notes = "新增小区管理接口") @GetMapping("excel") public SuccessResult excel() { - String fileName = "C:\\Users\\29492\\Desktop\\春华社区十分公司建房.xlsx"; + String fileName = "C:\\Users\\29492\\Desktop\\飞地1-3网格.xls"; List list = EasyExcel.read(fileName, ReadExcelResidentialModel.class, new AnalysisEventListener() { @@ -253,4 +256,14 @@ public class ResidentialController extends AbstractController { return new SuccessResult(); } + @ApiOperation(value = "网格数据迁移", notes = "网格数据迁移接口") + @GetMapping("dataRemove") + @Transactional(readOnly = false) + public SuccessResult dataRemove() { + Map params = new HashMap<>(); + List gridDTOList = residentialService.getOldGrid(params); + + return new SuccessResult(); + } + } \ No newline at end of file diff --git a/src/main/java/com/cm/population/dao/residential/IResidentialDao.java b/src/main/java/com/cm/population/dao/residential/IResidentialDao.java index 2a2c31c..fc745f4 100644 --- a/src/main/java/com/cm/population/dao/residential/IResidentialDao.java +++ b/src/main/java/com/cm/population/dao/residential/IResidentialDao.java @@ -5,6 +5,8 @@ import com.cm.common.exception.SaveException; import com.cm.common.exception.SearchException; import com.cm.common.exception.UpdateException; import com.cm.population.pojo.bos.residential.ResidentialBO; +import com.cm.population.pojo.dtos.grid.GridDTO; +import com.cm.population.pojo.dtos.grid.GridPointDTO; import com.cm.population.pojo.dtos.house.HouseDTO; import com.cm.population.pojo.dtos.populationinfo.PopulationInfoBaseDTO; import com.cm.population.pojo.dtos.residential.ResidentialDTO; @@ -128,4 +130,12 @@ public interface IResidentialDao { PopulationInfoBaseDTO getPopu2(Map params); void updateHouse(Map params); + + List getOldGrid(Map params); + + void gridGrid(Map params); + + List getOldPoint(Map params); + + void gridPoint(Map params); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/pojo/dtos/grid/GridDTO.java b/src/main/java/com/cm/population/pojo/dtos/grid/GridDTO.java index 85616c0..340a7d3 100644 --- a/src/main/java/com/cm/population/pojo/dtos/grid/GridDTO.java +++ b/src/main/java/com/cm/population/pojo/dtos/grid/GridDTO.java @@ -59,6 +59,8 @@ public class GridDTO implements Serializable { private List relationIdArray; @ApiModelProperty(name = "pointArray", value = "网格点列表") private List pointArray; + @ApiModelProperty(name = "areaName", value = "网格编码") + private String areaName; public String getGridId() { return gridId == null ? "" : gridId.trim(); @@ -196,6 +198,14 @@ public class GridDTO implements Serializable { this.gmtModified = gmtModified; } + public String getAreaName() { + return areaName; + } + + public void setAreaName(String areaName) { + this.areaName = areaName; + } + public List getRelationIdArray() { if (relationIdArray == null) { return new ArrayList<>(); diff --git a/src/main/java/com/cm/population/service/residential/IResidentialService.java b/src/main/java/com/cm/population/service/residential/IResidentialService.java index e66eca0..c2a8a39 100644 --- a/src/main/java/com/cm/population/service/residential/IResidentialService.java +++ b/src/main/java/com/cm/population/service/residential/IResidentialService.java @@ -3,6 +3,7 @@ package com.cm.population.service.residential; import com.cm.common.pojo.ListPage; import com.cm.common.result.SuccessResultList; import com.cm.population.pojo.bos.residential.ResidentialBO; +import com.cm.population.pojo.dtos.grid.GridDTO; import com.cm.population.pojo.dtos.residential.ResidentialDTO; import com.cm.population.pojo.pos.residential.ResidentialPO; import com.cm.population.pojo.vos.residential.ResidentialVO; @@ -193,4 +194,11 @@ public interface IResidentialService { * 房屋房主信息数据修复 */ void dataCover(); + + /** + * 网格数据迁移 + * @param params + * @return + */ + List getOldGrid(Map params); } \ No newline at end of file diff --git a/src/main/java/com/cm/population/service/residential/impl/ResidentialServiceImpl.java b/src/main/java/com/cm/population/service/residential/impl/ResidentialServiceImpl.java index a4e07cc..99d2d41 100644 --- a/src/main/java/com/cm/population/service/residential/impl/ResidentialServiceImpl.java +++ b/src/main/java/com/cm/population/service/residential/impl/ResidentialServiceImpl.java @@ -6,16 +6,22 @@ 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.DateUtil; import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.UUIDUtil; +import com.cm.population.dao.grid.IGridDao; +import com.cm.population.dao.grid.IGridPointDao; import com.cm.population.dao.house.IHouseDao; import com.cm.population.dao.populationinfo.IPopulationInfoDao; import com.cm.population.dao.residential.IResidentialDao; import com.cm.population.pojo.bos.residential.ResidentialBO; +import com.cm.population.pojo.dtos.grid.GridDTO; +import com.cm.population.pojo.dtos.grid.GridPointDTO; import com.cm.population.pojo.dtos.house.HouseDTO; import com.cm.population.pojo.dtos.populationinfo.PopulationInfoBaseDTO; import com.cm.population.pojo.dtos.residential.ResidentialDTO; import com.cm.population.pojo.pos.residential.ResidentialPO; +import com.cm.population.pojo.vos.grid.GridVO; import com.cm.population.pojo.vos.residential.ResidentialVO; import com.cm.population.service.residential.IResidentialService; import com.github.pagehelper.PageHelper; @@ -44,6 +50,10 @@ public class ResidentialServiceImpl extends AbstractService implements IResident private IHouseDao houseDao; @Autowired private IPopulationInfoDao populationInfoDao; + @Autowired + private IGridDao gridDao; + @Autowired + private IGridPointDao gridPointDao; @Override public void save(ResidentialVO residentialVO) { @@ -398,4 +408,53 @@ public class ResidentialServiceImpl extends AbstractService implements IResident executorService.shutdown(); // 关闭线程池 } + @Override + public List getOldGrid(Map params) { + List gridDTOList = residentialDao.getOldGrid(params); + for (GridDTO gridDTO : gridDTOList) { + String areaName = gridDTO.getAreaName(); + + if(StringUtils.isNotEmpty(areaName)) { + String[] areaNameArr = areaName.split("/"); + if(null != areaNameArr && areaNameArr.length > 1) { + String communityId = this.getCommunityId(areaNameArr[1]); + params.put("communityId", communityId); + params.put("communityName", areaNameArr[1]); + } + if("民馨路街道办事处".equals(areaNameArr[0])) { + areaNameArr[0] = "民馨路街道"; + }else if("稀土路街道办事处".equals(areaNameArr[0])) { + areaNameArr[0] = "稀土路街道"; + } + String streetId = this.getStreetId(areaNameArr[0]); + + params.put("gridCode", gridDTO.getGridCode()); + params.put("gridId", gridDTO.getGridId()); + params.put("gridName", gridDTO.getGridName()); + params.put("gridSummary", gridDTO.getGridSummary()); + params.put("gridGroupId", gridDTO.getGridGroupId()); + params.put("gridDuty", gridDTO.getGridDuty()); + params.put("streetId", streetId); + params.put("streetName", areaNameArr[0]); + params.put("fillColor", gridDTO.getFillColor()); + params.put("creator", 1); + params.put("gmtCreate", DateUtil.getTime()); + params.put("modifier", 1); + params.put("gmtModified", DateUtil.getTime()); + params.put("isDelete", 0); + residentialDao.gridGrid(params); + } + } + + List gridPointDTOList = residentialDao.getOldPoint(params); + params = new HashMap<>(); + for(GridPointDTO gridPointDTO: gridPointDTOList) { + params.put("gridId", gridPointDTO.getGridId()); + params.put("lng", gridPointDTO.getLng()); + params.put("lat", gridPointDTO.getLat()); + residentialDao.gridPoint(params); + } + return gridDTOList; + } + } \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/residential/residential-mapper.xml b/src/main/resources/mybatis/mapper/residential/residential-mapper.xml index 0e3424c..b6afb63 100644 --- a/src/main/resources/mybatis/mapper/residential/residential-mapper.xml +++ b/src/main/resources/mybatis/mapper/residential/residential-mapper.xml @@ -84,6 +84,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO house_residential( @@ -586,4 +614,73 @@ --> + + + + INSERT INTO map_grid( + grid_id, + grid_name, + grid_summary, + grid_group_id, + grid_duty, + grid_code, + grid_square, + street_id, + street_name, + community_id, + community_name, + housing_estate_id, + housing_estate_name, + fill_color, + gmt_create, + creator, + gmt_modified, + modifier, + is_delete + ) VALUES( + #{gridId}, + #{gridName}, + #{gridSummary}, + #{gridGroupId}, + #{gridDuty}, + #{gridCode}, + #{gridSquare}, + #{streetId}, + #{streetName}, + #{communityId}, + #{communityName}, + #{housingEstateId}, + #{housingEstateName}, + #{fillColor}, + #{gmtCreate}, + #{creator}, + #{gmtModified}, + #{modifier}, + #{isDelete} + ) + + + + + + INSERT INTO map_grid_point( + grid_id, + lng, + lat + ) VALUES( + #{gridId}, + #{lng}, + #{lat} + ) + + \ No newline at end of file