|
|
@ -1,6 +1,7 @@ |
|
|
|
package org.dromara.business.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
@ -12,6 +13,7 @@ import org.dromara.business.domain.BusinessVectorDict; |
|
|
|
import org.dromara.business.mapper.BusinessDepartBoundaryMapper; |
|
|
|
import org.dromara.business.service.IBusinessDepartBoundaryService; |
|
|
|
import org.dromara.business.service.IBusinessVectorDictService; |
|
|
|
import org.dromara.business.utils.BatchProcessorUtil; |
|
|
|
import org.dromara.business.utils.ShpAnalysisUtil; |
|
|
|
import org.dromara.common.core.exception.ServiceException; |
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery; |
|
|
@ -58,8 +60,8 @@ public class BusinessDepartBoundaryServiceImpl extends ServiceImpl<BusinessDepar |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<BusinessDepartBoundary> listSysDepartBoundaryGeomFromText(BusinessDepartBoundary sysDepartBoundary) { |
|
|
|
return baseMapper.listSysDepartBoundaryGeomFromText(sysDepartBoundary); |
|
|
|
public List<BusinessDepartBoundary> listSysDepartBoundaryGeomFromText(BusinessDepartBoundary departBoundary) { |
|
|
|
return baseMapper.listSysDepartBoundaryGeomFromText(departBoundary); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -69,7 +71,7 @@ public class BusinessDepartBoundaryServiceImpl extends ServiceImpl<BusinessDepar |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void uploadShpFile(MultipartFile file) { |
|
|
|
public boolean uploadShpFile(MultipartFile file) { |
|
|
|
List<BusinessGeospatialVectors> geospatialVectorsList = new ArrayList<>(); |
|
|
|
try { |
|
|
|
//1、首先调用解析工具拿到解析的字段集合
|
|
|
@ -135,10 +137,22 @@ public class BusinessDepartBoundaryServiceImpl extends ServiceImpl<BusinessDepar |
|
|
|
//6、生成新的对象集合存储数据表中
|
|
|
|
List<BusinessDepartBoundary> boundaryList = buildBusinessDepartBoundary(geospatialVectorsList); |
|
|
|
|
|
|
|
//批量新增部门区域数据
|
|
|
|
this.saveBatch(boundaryList); |
|
|
|
// 分批处理
|
|
|
|
int startIndex = 0; // 从第 0 条开始
|
|
|
|
int batchSize = 2000; // 每批处理 2000 条
|
|
|
|
boolean flag = BatchProcessorUtil.processBatches(boundaryList, batchSize, startIndex, batch -> { |
|
|
|
//批量新增部门区域数据
|
|
|
|
this.baseMapper.saveBatchBoundary(batch); |
|
|
|
}); |
|
|
|
|
|
|
|
if (flag) { |
|
|
|
System.out.println("所有数据处理完成!"); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -151,6 +165,11 @@ public class BusinessDepartBoundaryServiceImpl extends ServiceImpl<BusinessDepar |
|
|
|
return this.updateById(departBoundary); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean addDepartBoundary(BusinessDepartBoundary departBoundary) { |
|
|
|
return this.saveOrUpdate(departBoundary); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean deleteDepartBoundary(String id) { |
|
|
|
BusinessDepartBoundary departBoundary = this.baseMapper.selectById(id); |
|
|
@ -171,16 +190,20 @@ public class BusinessDepartBoundaryServiceImpl extends ServiceImpl<BusinessDepar |
|
|
|
private List<BusinessDepartBoundary> buildBusinessDepartBoundary(List<BusinessGeospatialVectors> geospatialVectorsList) { |
|
|
|
List<BusinessDepartBoundary> resultList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<Map<String,String>> namePathList = remoteDeptService.getNamePathList(); |
|
|
|
Map<String, List<Map<String, String>>> namePathMap = namePathList.stream().collect(Collectors.groupingBy(item -> item.get("shpNo"))); |
|
|
|
List<Map<String,Object>> namePathList = remoteDeptService.getNamePathList(); |
|
|
|
|
|
|
|
Map<String, List<Map<String, Object>>> namePathMap = namePathList.stream() |
|
|
|
.filter(item -> item.containsKey("shpNo")) |
|
|
|
.collect(Collectors.groupingBy(item -> item.get("shpNo").toString())); |
|
|
|
|
|
|
|
geospatialVectorsList.forEach(param->{ |
|
|
|
BusinessDepartBoundary businessDepartBoundary = new BusinessDepartBoundary(); |
|
|
|
businessDepartBoundary.setBoundary(param.getLandCategories()); |
|
|
|
businessDepartBoundary.setDeptName(param.getLandUnitName()); |
|
|
|
businessDepartBoundary.setShpNo(param.getLandUnitCode()); |
|
|
|
if (ObjectUtil.isNotEmpty(namePathMap.get(param.getLandUnitCode()))){ |
|
|
|
businessDepartBoundary.setDeptId(namePathMap.get(param.getLandUnitCode()).get(0).get("deptId")); |
|
|
|
businessDepartBoundary.setCommunityName(namePathMap.get(param.getLandUnitCode()).get(0).get("namePath")); |
|
|
|
businessDepartBoundary.setDeptName(namePathMap.get(param.getLandUnitCode()).get(0).get("deptName") + ""); |
|
|
|
businessDepartBoundary.setDeptId(namePathMap.get(param.getLandUnitCode()).get(0).get("deptId") + ""); |
|
|
|
businessDepartBoundary.setCommunityName(namePathMap.get(param.getLandUnitCode()).get(0).get("namePath") + ""); |
|
|
|
|
|
|
|
resultList.add(businessDepartBoundary); |
|
|
|
} |
|
|
|