|
|
@ -8,11 +8,15 @@ import lombok.RequiredArgsConstructor; |
|
|
|
import org.apache.dubbo.config.annotation.DubboReference; |
|
|
|
import org.dromara.system.api.domain.vo.RemoteDeptVo; |
|
|
|
import org.dromara.system.domain.SysDepartBoundary; |
|
|
|
import org.dromara.system.domain.SysDept; |
|
|
|
import org.dromara.system.domain.SysGeospatialVectors; |
|
|
|
import org.dromara.system.domain.SysVectorDict; |
|
|
|
import org.dromara.system.domain.bo.SysDepartBoundaryBo; |
|
|
|
import org.dromara.system.domain.bo.SysDeptBo; |
|
|
|
import org.dromara.system.domain.vo.SysDeptVo; |
|
|
|
import org.dromara.system.mapper.SysDepartBoundaryMapper; |
|
|
|
import org.dromara.system.service.ISysDepartBoundaryService; |
|
|
|
import org.dromara.system.service.ISysDeptService; |
|
|
|
import org.dromara.system.service.ISysVectorDictService; |
|
|
|
import org.dromara.system.utils.BatchProcessorUtil; |
|
|
|
import org.dromara.system.utils.ShpAnalysisUtil; |
|
|
@ -42,8 +46,7 @@ public class SysDepartBoundaryServiceImpl extends ServiceImpl<SysDepartBoundaryM |
|
|
|
|
|
|
|
private final ISysVectorDictService vectorDictService; |
|
|
|
|
|
|
|
@DubboReference |
|
|
|
RemoteDeptService remoteDeptService; |
|
|
|
private final ISysDeptService deptService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public TableDataInfo<SysDepartBoundary> listSysDepartBoundary(PageQuery pageQuery, SysDepartBoundary departBoundary) { |
|
|
@ -65,12 +68,12 @@ public class SysDepartBoundaryServiceImpl extends ServiceImpl<SysDepartBoundaryM |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public boolean uploadShpFile(MultipartFile file,Integer areaType) { |
|
|
|
public boolean uploadShpFile(MultipartFile file,Integer areaType,Long parentId) { |
|
|
|
try { |
|
|
|
List<SysGeospatialVectors> geospatialVectorsList = buildGeospatialVector(file); |
|
|
|
|
|
|
|
//6、生成新的对象集合存储数据表中
|
|
|
|
List<SysDepartBoundary> boundaryList = buildBusinessDepartBoundary(geospatialVectorsList,areaType); |
|
|
|
List<SysDepartBoundary> boundaryList = buildBusinessDepartBoundary(geospatialVectorsList,areaType,parentId); |
|
|
|
|
|
|
|
// 分批处理
|
|
|
|
int startIndex = 0; // 从第 0 条开始
|
|
|
@ -176,20 +179,20 @@ public class SysDepartBoundaryServiceImpl extends ServiceImpl<SysDepartBoundaryM |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<SysDepartBoundaryBo> listJson(SysDepartBoundary departBoundary) { |
|
|
|
if(StringUtils.isBlank(departBoundary.getDeptId())){ |
|
|
|
if(ObjectUtil.isEmpty(departBoundary.getDeptId())){ |
|
|
|
throw new ServiceException("部门【id】不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
SysDepartBoundaryBo child = new SysDepartBoundaryBo(); |
|
|
|
child.setDepartId(String.valueOf(departBoundary.getDeptId())); |
|
|
|
child.setAreaType(SysDepartBoundaryBo.AreaType.DistrictLevel); |
|
|
|
child.setLandCategoriesJson(this.baseMapper.listJson(departBoundary.getDeptId())); |
|
|
|
child.setLandCategoriesJson(this.baseMapper.listJson(String.valueOf(departBoundary.getDeptId()))); |
|
|
|
|
|
|
|
RemoteDeptVo remoteDeptVo = remoteDeptService.getByParentId(departBoundary.getDeptId()); |
|
|
|
SysDeptVo sysDeptVo = deptService.getByParentId(String.valueOf(departBoundary.getDeptId())); |
|
|
|
SysDepartBoundaryBo parent = new SysDepartBoundaryBo(); |
|
|
|
parent.setDepartId(String.valueOf(remoteDeptVo.getDeptId())); |
|
|
|
parent.setDepartId(String.valueOf(sysDeptVo.getDeptId())); |
|
|
|
parent.setAreaType(SysDepartBoundaryBo.AreaType.Municipal); |
|
|
|
parent.setLandCategoriesJson(this.baseMapper.listJson(String.valueOf(remoteDeptVo.getDeptId()))); |
|
|
|
parent.setLandCategoriesJson(this.baseMapper.listJson(String.valueOf(sysDeptVo.getDeptId()))); |
|
|
|
|
|
|
|
return List.of(child,parent); |
|
|
|
} |
|
|
@ -202,6 +205,7 @@ public class SysDepartBoundaryServiceImpl extends ServiceImpl<SysDepartBoundaryM |
|
|
|
throw new ServiceException("实体不存在!"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.baseMapper.deleteById(departBoundary.getId())>0; |
|
|
|
} |
|
|
|
|
|
|
@ -211,12 +215,12 @@ public class SysDepartBoundaryServiceImpl extends ServiceImpl<SysDepartBoundaryM |
|
|
|
* @param geospatialVectorsList |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<SysDepartBoundary> buildBusinessDepartBoundary(List<SysGeospatialVectors> geospatialVectorsList, Integer areaType) { |
|
|
|
private List<SysDepartBoundary> buildBusinessDepartBoundary(List<SysGeospatialVectors> geospatialVectorsList, Integer areaType,Long parentId) { |
|
|
|
List<SysDepartBoundary> resultList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<Map<String,Object>> namePathList = remoteDeptService.getNamePathList(); |
|
|
|
List<Map<String,Object>> namePathList = deptService.getNamePathList(null); |
|
|
|
|
|
|
|
Map<String, List<Map<String, Object>>> namePathMap = namePathList.stream() |
|
|
|
Map<String, List<Map<String, Object>>> namePathMap = namePathList.stream().filter(p-> Long.valueOf(p.get("parentId").toString()).equals(parentId)) |
|
|
|
.collect(Collectors.groupingBy(item -> item.get("deptName").toString())); |
|
|
|
|
|
|
|
geospatialVectorsList.forEach(param->{ |
|
|
@ -225,14 +229,30 @@ public class SysDepartBoundaryServiceImpl extends ServiceImpl<SysDepartBoundaryM |
|
|
|
String divisionName = param.getAdminDivisionName(); |
|
|
|
|
|
|
|
businessDepartBoundary.setBoundary(param.getLandCategories()); |
|
|
|
//判断是否存在表中,在表中更新部门区域中的部门id信息
|
|
|
|
if (ObjectUtil.isNotEmpty(namePathMap.get(divisionName))){ |
|
|
|
Map<String, Object> objectMap = namePathMap.get(divisionName).get(0); |
|
|
|
businessDepartBoundary.setShpNo(ObjectUtil.isEmpty(objectMap.get("shpNo"))?null:(String)objectMap.get("shpNo")); |
|
|
|
businessDepartBoundary.setDeptName(objectMap.get("deptName") + ""); |
|
|
|
businessDepartBoundary.setDeptId(objectMap.get("deptId") + ""); |
|
|
|
businessDepartBoundary.setCommunityName(objectMap.get("namePath") + ""); |
|
|
|
businessDepartBoundary.setDeptId(Long.valueOf(objectMap.get("deptId") + "")); |
|
|
|
businessDepartBoundary.setNamePath(objectMap.get("namePath") + ""); |
|
|
|
businessDepartBoundary.setAreaType(areaType); |
|
|
|
resultList.add(businessDepartBoundary); |
|
|
|
}else { |
|
|
|
//如果不存在在部门表中则添加
|
|
|
|
SysDeptBo sysDeptBo = new SysDeptBo(); |
|
|
|
sysDeptBo.setParentId(parentId); |
|
|
|
sysDeptBo.setDeptName(param.getAdminDivisionName()); |
|
|
|
|
|
|
|
SysDept sysDept = deptService.addBoundaryDept(sysDeptBo); |
|
|
|
|
|
|
|
List<Map<String,Object>> deptNamePath = deptService.getNamePathList(sysDept.getDeptId()); |
|
|
|
|
|
|
|
businessDepartBoundary.setDeptName(sysDept.getDeptName()); |
|
|
|
businessDepartBoundary.setDeptId(sysDept.getDeptId()); |
|
|
|
businessDepartBoundary.setNamePath(deptNamePath.getFirst().get("namePath").toString()); |
|
|
|
businessDepartBoundary.setAreaType(areaType); |
|
|
|
resultList.add(businessDepartBoundary); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
return resultList; |
|
|
|