Browse Source

[feat]提交:修改部门区域解析逻辑③

pull/7/head
杨威 2 weeks ago
parent
commit
e965a29259
  1. 78
      dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDepartBoundaryServiceImpl.java

78
dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDepartBoundaryServiceImpl.java

@ -257,67 +257,51 @@ public class SysDepartBoundaryServiceImpl extends ServiceImpl<SysDepartBoundaryM
SysDepartBoundary businessDepartBoundary = new SysDepartBoundary(); SysDepartBoundary businessDepartBoundary = new SysDepartBoundary();
businessDepartBoundary.setBoundary(item); businessDepartBoundary.setBoundary(item);
//判断是否存在表中,在表中更新部门区域中的部门id信息
if (ObjectUtil.isNotEmpty(namePathMap.get(divisionName))){
Map<String, Object> objectMap = namePathMap.get(divisionName).get(0);
businessDepartBoundary.setDeptName(objectMap.get("deptName") + "");
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);
} createBoundary(businessDepartBoundary,namePathMap,divisionName,areaType,parentId);
resultList.add(businessDepartBoundary);
}); });
}else { }else {
SysDepartBoundary businessDepartBoundary = new SysDepartBoundary(); SysDepartBoundary businessDepartBoundary = new SysDepartBoundary();
businessDepartBoundary.setBoundary(param.getLandCategories()); businessDepartBoundary.setBoundary(param.getLandCategories());
//判断是否存在表中,在表中更新部门区域中的部门id信息
if (ObjectUtil.isNotEmpty(namePathMap.get(divisionName))){
Map<String, Object> objectMap = namePathMap.get(divisionName).get(0);
businessDepartBoundary.setDeptName(objectMap.get("deptName") + "");
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()); createBoundary(businessDepartBoundary,namePathMap,divisionName,areaType,parentId);
businessDepartBoundary.setDeptName(sysDept.getDeptName()); resultList.add(businessDepartBoundary);
businessDepartBoundary.setDeptId(sysDept.getDeptId());
businessDepartBoundary.setNamePath(deptNamePath.getFirst().get("namePath").toString());
businessDepartBoundary.setAreaType(areaType);
resultList.add(businessDepartBoundary);
}
} }
}); });
return resultList; return resultList;
} }
private void createBoundary(SysDepartBoundary businessDepartBoundary, Map<String, List<Map<String, Object>>> namePathMap, String divisionName, Integer areaType, Long parentId) {
//判断是否存在表中,在表中更新部门区域中的部门id信息
if (ObjectUtil.isNotEmpty(namePathMap.get(divisionName))){
Map<String, Object> objectMap = namePathMap.get(divisionName).get(0);
businessDepartBoundary.setDeptName(objectMap.get("deptName") + "");
businessDepartBoundary.setDeptId(Long.valueOf(objectMap.get("deptId") + ""));
businessDepartBoundary.setNamePath(objectMap.get("namePath") + "");
businessDepartBoundary.setAreaType(areaType);
}else {
//如果不存在在部门表中则添加
SysDeptBo sysDeptBo = new SysDeptBo();
sysDeptBo.setParentId(parentId);
sysDeptBo.setDeptName(divisionName);
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);
}
}
public static List<String> convertStringToList(String str) { public static List<String> convertStringToList(String str) {
// 去除首尾的 "[" 和 "]" // 去除首尾的 "[" 和 "]"
str = str.substring(1, str.length() - 1); str = str.substring(1, str.length() - 1);

Loading…
Cancel
Save