From e965a29259b66222be0eafde1f306d1d732e7cad Mon Sep 17 00:00:00 2001 From: yangwei <867012372@qq.com> Date: Sat, 7 Jun 2025 17:29:34 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E6=8F=90=E4=BA=A4=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=83=A8=E9=97=A8=E5=8C=BA=E5=9F=9F=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E2=91=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/SysDepartBoundaryServiceImpl.java | 78 ++++++++----------- 1 file changed, 31 insertions(+), 47 deletions(-) diff --git a/dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDepartBoundaryServiceImpl.java b/dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDepartBoundaryServiceImpl.java index 15bd7b1..410c2de 100644 --- a/dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDepartBoundaryServiceImpl.java +++ b/dk-modules/system/src/main/java/org/dromara/system/service/impl/SysDepartBoundaryServiceImpl.java @@ -257,67 +257,51 @@ public class SysDepartBoundaryServiceImpl extends ServiceImpl 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> 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 { SysDepartBoundary businessDepartBoundary = new SysDepartBoundary(); businessDepartBoundary.setBoundary(param.getLandCategories()); - //判断是否存在表中,在表中更新部门区域中的部门id信息 - if (ObjectUtil.isNotEmpty(namePathMap.get(divisionName))){ - Map 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> deptNamePath = deptService.getNamePathList(sysDept.getDeptId()); + createBoundary(businessDepartBoundary,namePathMap,divisionName,areaType,parentId); - businessDepartBoundary.setDeptName(sysDept.getDeptName()); - businessDepartBoundary.setDeptId(sysDept.getDeptId()); - businessDepartBoundary.setNamePath(deptNamePath.getFirst().get("namePath").toString()); - businessDepartBoundary.setAreaType(areaType); - resultList.add(businessDepartBoundary); - - } + resultList.add(businessDepartBoundary); } }); return resultList; } + private void createBoundary(SysDepartBoundary businessDepartBoundary, Map>> namePathMap, String divisionName, Integer areaType, Long parentId) { + //判断是否存在表中,在表中更新部门区域中的部门id信息 + if (ObjectUtil.isNotEmpty(namePathMap.get(divisionName))){ + Map 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> 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 convertStringToList(String str) { // 去除首尾的 "[" 和 "]" str = str.substring(1, str.length() - 1);