src/main/java/org/springblade/modules/category/controller/CategoryController.java
@@ -24,18 +24,20 @@ import javax.validation.Valid; import org.springblade.common.node.TreeIntegerNode; import org.springblade.core.excel.util.ExcelUtil; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.modules.label.vo.LabelVO; import org.springblade.modules.category.excel.CategoryExcel; import org.springblade.modules.category.excel.CategoryImporter; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.core.metadata.IPage; import org.springblade.modules.category.entity.CategoryEntity; import org.springblade.modules.category.vo.CategoryVO; import org.springblade.modules.category.wrapper.CategoryWrapper; import org.springblade.modules.category.service.ICategoryService; import org.springframework.web.multipart.MultipartFile; import java.util.List; /** @@ -143,5 +145,15 @@ return R.data(categoryService.getCategory(category)); } /** * 天地图poi 导入 */ @PostMapping("/import-category") public R importCategory(MultipartFile file, Integer isCovered) { CategoryImporter categoryImporter = new CategoryImporter(categoryService, isCovered == 1); ExcelUtil.save(file, categoryImporter, CategoryExcel.class); return R.success("操作成功"); } } src/main/java/org/springblade/modules/category/excel/CategoryExcel.java
New file @@ -0,0 +1,45 @@ package org.springblade.modules.category.excel; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ContentRowHeight; import com.alibaba.excel.annotation.write.style.HeadRowHeight; import lombok.Data; import java.io.Serializable; /** * CategoryExcel * * @author Chill */ @Data @ColumnWidth(25) @HeadRowHeight(20) @ContentRowHeight(18) public class CategoryExcel implements Serializable { private static final long serialVersionUID = 2L; /** 标签名称 */ @ExcelProperty( "小类") private String categoryName; /** 标签编号 */ @ExcelProperty( "类别代码") private String categoryNo; /** 层级 */ @ExcelProperty( "层级") private Integer level; /** 提示词分类描述 */ @ExcelProperty( "提示词分类描述") private String description; /** 备注 */ @ExcelProperty( "备注") private String remark; } src/main/java/org/springblade/modules/category/excel/CategoryImporter.java
New file @@ -0,0 +1,39 @@ /* * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the dreamlu.net developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: Chill 庄骞 (smallchill@163.com) */ package org.springblade.modules.category.excel; import lombok.RequiredArgsConstructor; import org.springblade.core.excel.support.ExcelImporter; import org.springblade.modules.category.service.ICategoryService; import java.util.List; /** * 场所标签poi数据导入类 * * @author Chill */ @RequiredArgsConstructor public class CategoryImporter implements ExcelImporter<CategoryExcel> { private final ICategoryService categoryService; private final Boolean isCovered; @Override public void save(List<CategoryExcel> data) { categoryService.importCategory(data, isCovered); } } src/main/java/org/springblade/modules/category/service/ICategoryService.java
@@ -21,6 +21,7 @@ import org.springblade.common.node.TreeIntegerNode; import org.springblade.modules.category.dto.CategoryDTO; import org.springblade.modules.category.entity.CategoryEntity; import org.springblade.modules.category.excel.CategoryExcel; import org.springblade.modules.category.vo.CategoryVO; import java.util.List; @@ -56,4 +57,11 @@ List<CategoryDTO> selectCategoryLabelList(CategoryDTO categoryDTO); List<TreeIntegerNode> tree(CategoryVO category); /** * 标签导入 * @param data * @param isCovered */ void importCategory(List<CategoryExcel> data, Boolean isCovered); } src/main/java/org/springblade/modules/category/service/impl/CategoryServiceImpl.java
@@ -16,11 +16,13 @@ */ package org.springblade.modules.category.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springblade.common.node.TreeIntegerNode; import org.springblade.common.utils.NodeTreeUtil; import org.springblade.modules.category.dto.CategoryDTO; import org.springblade.modules.category.entity.CategoryEntity; import org.springblade.modules.category.excel.CategoryExcel; import org.springblade.modules.category.vo.CategoryVO; import org.springblade.modules.category.mapper.CategoryMapper; import org.springblade.modules.category.service.ICategoryService; @@ -77,4 +79,32 @@ node.setChildren(null); } } /** * 标签导入 * @param data * @param isCovered */ @Override public void importCategory(List<CategoryExcel> data, Boolean isCovered) { for (CategoryExcel categoryExcel : data) { // 查询是否已存在 QueryWrapper<CategoryEntity> wrapper = new QueryWrapper<>(); wrapper.eq("category_no",categoryExcel.getCategoryNo()).eq("is_deleted",0); CategoryEntity one = getOne(wrapper); if (null==one){ // 新增 CategoryEntity categoryEntity = new CategoryEntity(); categoryEntity.setCategoryNo(categoryExcel.getCategoryNo()); categoryEntity.setCategoryName(categoryExcel.getCategoryName()); categoryEntity.setLevel(categoryExcel.getLevel()); categoryEntity.setIsDeleted(0); categoryEntity.setParentNo(categoryExcel.getCategoryNo().substring(0,4)); categoryEntity.setDescription(categoryExcel.getDescription()); categoryEntity.setRemark(categoryExcel.getRemark()); // 新增 save(categoryEntity); } } } } src/main/java/org/springblade/modules/doorplateAddress/controller/DoorplateAddressController.java
@@ -212,8 +212,8 @@ * @return */ @GetMapping("/houseDataHandle") public R dataHandle(){ return R.data(doorplateAddressService.houseDataHandle()); public R dataHandle(String townName){ return R.data(doorplateAddressService.houseDataHandle(townName)); } /** src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.java
@@ -163,9 +163,10 @@ @Param("list") List<String> list); /** * 查询所有户室数据 * @param townName * @return */ List<DoorplateAddressEntity> getHouseList(); List<DoorplateAddressEntity> getHouseList(@Param("townName") String townName); /** * 查询商超 @@ -231,4 +232,11 @@ * @return */ List<DoorplateAddressVO> getHouseBuildingCode(String districtId); /** * 查询绑定房屋总数 * @param townName * @return */ Integer getNotHouseListCount(@Param("townName") String townName); } src/main/java/org/springblade/modules/doorplateAddress/mapper/DoorplateAddressMapper.xml
@@ -484,6 +484,10 @@ where 1=1 and jh.house_code is null and doorplate_type = '户室牌' <if test="townName!=null and townName!=''"> and jda.town_street_name like concat('%',#{townName},'%') </if> limit 0,1000 </select> <!--查询商超--> @@ -536,16 +540,18 @@ <!--查询所有的地址表id集合--> <select id="getAoiCodeList" resultType="java.lang.Long"> select max(id) min(id) from jczz_doorplate_address where aoi_code != "" and aoi_name !="" and doorplate_type = '大门牌' GROUP BY aoi_code union all ( select max(id) min(id) from jczz_doorplate_address where aoi_code != "" and sub_aoi != "" and doorplate_type = '大门牌' group by aoi_code ) </select> @@ -676,4 +682,18 @@ and jda.building_code is not null </select> <!--查询所有户室数据--> <select id="getNotHouseListCount" resultType="java.lang.Integer"> select count(*) from jczz_doorplate_address jda left join jczz_house jh on jh.house_code = jda.address_code where 1=1 and jh.house_code is null and doorplate_type = '户室牌' <if test="townName!=null and townName!=''"> and jda.town_street_name like concat('%',#{townName},'%') </if> limit 0,1000 </select> </mapper> src/main/java/org/springblade/modules/doorplateAddress/service/IDoorplateAddressService.java
@@ -97,7 +97,7 @@ * 房屋数据处理 * @return */ Object houseDataHandle(); Object houseDataHandle(String townName); /** * 小区数据处理 src/main/java/org/springblade/modules/doorplateAddress/service/impl/DoorplateAddressServiceImpl.java
@@ -712,9 +712,9 @@ * @return */ @Override public Object houseDataHandle() { public Object houseDataHandle(String townName) { // 处理房屋数据 handleHouseData(); handleHouseData(townName); return null; } @@ -722,41 +722,52 @@ /** * 处理房屋数据 */ private void handleHouseData() { // 查询所有户室数据(未入库的) List<DoorplateAddressEntity> list = baseMapper.getHouseList(); // 需要新增的房屋 list List<HouseEntity> houseList = new ArrayList<>(); // 处理户室数据 for (DoorplateAddressEntity doorplateAddressEntity : list) { // 查询是否已存在,存在就插入,不存在则插入 QueryWrapper<HouseEntity> wrapper = new QueryWrapper<>(); wrapper.eq("house_code", doorplateAddressEntity.getAddressCode()) .eq("is_deleted", 0); HouseEntity one = houseService.getOne(wrapper); if (null == one) { HouseEntity houseEntity = new HouseEntity(); houseEntity.setHouseCode(doorplateAddressEntity.getAddressCode()); houseEntity.setDistrictCode(doorplateAddressEntity.getAoiCode()); houseEntity.setDistrictName(doorplateAddressEntity.getAoiName()); houseEntity.setHouseName(doorplateAddressEntity.getAddressName()); houseEntity.setFloor(doorplateAddressEntity.getFloor()); houseEntity.setBuilding(doorplateAddressEntity.getBuildingName()); houseEntity.setUnit(doorplateAddressEntity.getUnitName()); houseEntity.setRoom(doorplateAddressEntity.getHouseName()); houseEntity.setBuildingNo(doorplateAddressEntity.getBuildingCode()); houseEntity.setCreateUser(AuthUtil.getUserId().toString()); houseEntity.setCreateTime(new Date()); houseEntity.setUpdateUser(AuthUtil.getUserId().toString()); houseEntity.setUpdateTime(new Date()); // 设置来源 1:地址总表 2:国控采集 houseEntity.setSource(1); // 加入集合 houseList.add(houseEntity); private void handleHouseData(String townName) { // 查询总数 Integer count = baseMapper.getNotHouseListCount(townName); if (count>0) { int num = count/1000; for (int i = 0; i <= num+1; i++) { // 查询所有户室数据(未入库的) List<DoorplateAddressEntity> list = baseMapper.getHouseList(townName); // 需要新增的房屋 list List<HouseEntity> houseList = new ArrayList<>(); // 处理户室数据 for (DoorplateAddressEntity doorplateAddressEntity : list) { // 查询是否已存在,存在就插入,不存在则插入 QueryWrapper<HouseEntity> wrapper = new QueryWrapper<>(); wrapper.eq("house_code", doorplateAddressEntity.getAddressCode()) .eq("is_deleted", 0); HouseEntity one = houseService.getOne(wrapper); if (null == one) { HouseEntity houseEntity = new HouseEntity(); houseEntity.setHouseCode(doorplateAddressEntity.getAddressCode()); houseEntity.setDistrictCode(doorplateAddressEntity.getAoiCode()); houseEntity.setDistrictName(doorplateAddressEntity.getAoiName()); houseEntity.setLng(doorplateAddressEntity.getX()); houseEntity.setLat(doorplateAddressEntity.getY()); houseEntity.setHouseName(doorplateAddressEntity.getAddressName()); houseEntity.setAddress(doorplateAddressEntity.getAddressName()); houseEntity.setFloor(doorplateAddressEntity.getFloor()); houseEntity.setBuilding(doorplateAddressEntity.getBuildingName()); houseEntity.setUnit(doorplateAddressEntity.getUnitName()); houseEntity.setRoom(doorplateAddressEntity.getHouseName()); houseEntity.setBuildingNo(doorplateAddressEntity.getBuildingCode()); houseEntity.setCreateUser(AuthUtil.getUserId().toString()); houseEntity.setCreateTime(new Date()); houseEntity.setUpdateUser(AuthUtil.getUserId().toString()); houseEntity.setUpdateTime(new Date()); // 设置来源 1:地址总表 2:国控采集 houseEntity.setSource(1); // 加入集合 houseList.add(houseEntity); } } // 批量插入 houseService.saveBatch(houseList); } } // 批量插入 houseService.saveBatch(houseList); } /** @@ -790,6 +801,16 @@ // 加入集合 districtService.save(districtEntity); // aoiList.add(districtEntity); }else { // 更新 one.setCommunityCode(addressEntity.getNeiCode()); one.setAoiCode(addressEntity.getAoiCode()); one.setName(addressEntity.getAoiName()); one.setAddress(addressEntity.getAddressName()); one.setLng(addressEntity.getX()); one.setLat(addressEntity.getY()); // 加入集合 districtService.updateById(one); } } // 批量插入 @@ -827,6 +848,8 @@ placeEntity.setStatus(1); // 默认为非九小场所 placeEntity.setIsNine(2); // 默认为现场采集 placeEntity.setIsScene(1); // 加入集合 // placeList.add(placeEntity); // 保存 src/main/java/org/springblade/modules/house/controller/HouseController.java
@@ -258,4 +258,24 @@ return R.data(detail); } /** * 房屋网格处理 * @return */ @GetMapping("/houseGridHandle") @ApiOperation(value = "房屋网格处理") public R houseGridHandle() { return R.data(houseService.houseGridHandle()); } /** * 房屋警格处理 * @return */ @GetMapping("/houseJwGridHandle") @ApiOperation(value = "房屋警格处理") public R houseJwGridHandle() { return R.data(houseService.houseJwGridHandle()); } } src/main/java/org/springblade/modules/house/mapper/HouseMapper.java
@@ -103,4 +103,11 @@ @Param("regionChildCodesList") List<String> regionChildCodesList, @Param("isAdministrator") Integer isAdministrator, @Param("streetCode") String streetCode); /** * 查询未绑定网格或警格的数据 * @param type 1:网格 2:警格 * @return */ List<HouseEntity> getNotBindGridOrJwGridList(@Param("type") Integer type); } src/main/java/org/springblade/modules/house/mapper/HouseMapper.xml
@@ -789,5 +789,16 @@ </select> <!--查询未绑定网格或警格的数据--> <select id="getNotBindGridOrJwGridList" resultType="org.springblade.modules.house.entity.HouseEntity"> select lng,lat from jczz_house where is_deleted = 0 and lng != '' <if test="type == 1"> and grid_code is null </if> <if test="type == 2"> and jw_grid_code is null </if> </select> </mapper> src/main/java/org/springblade/modules/house/service/IHouseService.java
@@ -90,4 +90,16 @@ List<Map<String, Object>> labelStatistics(HouseVO house); List<Map<String, Object>> labelCommunityStatistics(HouseVO house); /** * 房屋网格处理 * @return */ Object houseGridHandle(); /** * 房屋警格处理 * @return */ Object houseJwGridHandle(); } src/main/java/org/springblade/modules/house/service/impl/HouseServiceImpl.java
@@ -30,6 +30,7 @@ import org.springblade.core.mp.support.Condition; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.utils.BeanUtil; import org.springblade.modules.grid.entity.GridEntity; import org.springblade.modules.grid.entity.GridRangeEntity; import org.springblade.modules.grid.service.IGridRangeService; import org.springblade.modules.grid.service.IGridService; @@ -48,6 +49,8 @@ import org.springblade.modules.label.entity.LabelEntity; import org.springblade.modules.label.service.ILabelService; import org.springblade.modules.label.vo.LabelVO; import org.springblade.modules.police.entity.PoliceAffairsGridEntity; import org.springblade.modules.police.service.IPoliceAffairsGridService; import org.springblade.modules.system.entity.Region; import org.springblade.modules.system.entity.User; import org.springblade.modules.system.service.IRegionService; @@ -712,4 +715,48 @@ } return list; } /** * 房屋网格处理 * @return */ @Override public Object houseGridHandle() { // 查询未处理的数据 List<HouseEntity> houseEntityList = baseMapper.getNotBindGridOrJwGridList(1); // 遍历 for (HouseEntity houseEntity : houseEntityList) { String point = "'POINT(" + houseEntity.getLng() + " " + houseEntity.getLat() + ")'"; List<GridEntity> gridEntityList = SpringUtils.getBean(IGridService.class).spatialAnalysis(point); if (gridEntityList.size()>0){ houseEntity.setGridCode(gridEntityList.get(0).getGridCode()); houseEntity.setGridId(gridEntityList.get(0).getId()); // 更新 updateById(houseEntity); } } return null; } /** * 房屋警格处理 * @return */ @Override public Object houseJwGridHandle() { // 查询未处理的数据 List<HouseEntity> houseEntityList = baseMapper.getNotBindGridOrJwGridList(2); // 遍历 for (HouseEntity houseEntity : houseEntityList) { String point = "'POINT(" + houseEntity.getLng() + " " + houseEntity.getLat() + ")'"; List<PoliceAffairsGridEntity> policeAffairsGridEntityList = SpringUtils.getBean(IPoliceAffairsGridService.class).spatialAnalysis(point); if (policeAffairsGridEntityList.size()>0){ houseEntity.setJwGridCode(policeAffairsGridEntityList.get(0).getJwGridCode()); // 更新 updateById(houseEntity); } } return null; } }