Explorar el Código

机构树查询上级调试

jiawuxian hace 2 años
padre
commit
ea03995cd8

+ 6 - 5
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysOrgServiceImpl.java

@@ -454,19 +454,20 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
         Long curOrgId = SecurityUtils.getLoginUser().getOrgId();
         Long queryOrgId = req.getOrgId();
         Map<Long, String> idPathMap = lambdaQuery().in(SysOrg::getId, Arrays.asList(curOrgId, queryOrgId))
-                .select(SysOrg::getId, SysOrg::getPath).list().stream().collect(Collectors.toMap(SysOrg::getId, SysOrg::getPath));
+                .select(SysOrg::getId, SysOrg::getPath).list().stream()
+                .collect(Collectors.toMap(SysOrg::getId, SysOrg::getPath));
         String curOrgPath = idPathMap.get(curOrgId);
         String queryOrgPath = idPathMap.get(queryOrgId);
         if (req.getCheckSub()) {
             //1.如果当前机构是查询机构的上级机构,那么应查询当前机构到 查询机构之间的所有机构id,与当前机构的所有下级
-            if (curOrgPath.startsWith(queryOrgPath)){
-                List<Long> list = Arrays.stream(queryOrgPath.split("-")).map(Long::valueOf).collect(Collectors.toList());
+            if (curOrgPath.startsWith(queryOrgPath) && ObjectUtil.notEqual(curOrgPath,queryOrgPath)){
+                List<Long> list = Arrays.stream(curOrgPath.split("-")).map(Long::valueOf).collect(Collectors.toList());
                 //移除当前机构id,当前机构的数据以path字段查询
                 list.remove(curOrgId);
                 resp.setOrgIdList(list);
-                resp.setOrgPath(queryOrgPath);
-            }else {
                 resp.setOrgPath(curOrgPath);
+            }else {
+                resp.setOrgPath(queryOrgPath);
             }
             return resp;
         }