chenshudong 4 ヶ月 前
コミット
21eded5810

+ 9 - 0
airport-system/src/main/java/com/sundot/airport/system/service/ISysDeptService.java

@@ -6,6 +6,7 @@ import com.sundot.airport.common.core.domain.TreeSelect;
6 6
 import com.sundot.airport.common.core.domain.DeptUserTreeSelect;
7 7
 import com.sundot.airport.common.core.domain.entity.SysDept;
8 8
 import com.sundot.airport.common.core.domain.entity.SysUser;
9
+import com.sundot.airport.common.dto.DeptInfo;
9 10
 
10 11
 /**
11 12
  * 部门管理 服务层
@@ -179,4 +180,12 @@ public interface ISysDeptService {
179 180
      * @return 指定角色人员
180 181
      */
181 182
     public List<SysUser> deptRole(Long deptId, List<String> roleKeyList);
183
+
184
+    /**
185
+     * 查询指定部门的上级部门信息
186
+     *
187
+     * @param deptId 部门ID
188
+     * @return 上级部门信息
189
+     */
190
+    public DeptInfo getDeptInfoByDeptId(Long deptId);
182 191
 }

+ 33 - 0
airport-system/src/main/java/com/sundot/airport/system/service/impl/SysDeptServiceImpl.java

@@ -7,8 +7,12 @@ import java.util.List;
7 7
 import java.util.stream.Collectors;
8 8
 
9 9
 import cn.hutool.core.collection.CollUtil;
10
+import cn.hutool.core.collection.CollectionUtil;
10 11
 import cn.hutool.core.util.ObjectUtil;
12
+import cn.hutool.core.util.StrUtil;
11 13
 import com.sundot.airport.common.config.LevelConfig;
14
+import com.sundot.airport.common.dto.DeptInfo;
15
+import com.sundot.airport.common.enums.DeptType;
12 16
 import com.sundot.airport.common.enums.DeptTypeEnum;
13 17
 import com.sundot.airport.common.enums.RoleTypeEnum;
14 18
 import org.springframework.beans.factory.annotation.Autowired;
@@ -565,4 +569,33 @@ public class SysDeptServiceImpl implements ISysDeptService {
565 569
         List<SysUser> result = deptMapper.deptRole(deptId, roleKeyList);
566 570
         return result;
567 571
     }
572
+
573
+    /**
574
+     * 查询指定部门的上级部门信息
575
+     *
576
+     * @param deptId 部门ID
577
+     * @return 上级部门信息
578
+     */
579
+    @Override
580
+    public DeptInfo getDeptInfoByDeptId(Long deptId) {
581
+        DeptInfo result = new DeptInfo();
582
+        List<SysDept> deptList = selectAllDept(deptId);
583
+        if (CollectionUtil.isEmpty(deptList)) {
584
+            return result;
585
+        }
586
+        Collections.reverse(deptList);
587
+        SysDept teams = deptList.stream().filter(x -> StrUtil.equals(DeptType.TEAMS.getCode(), x.getDeptType())).findFirst().orElse(new SysDept());
588
+        SysDept department = deptList.stream().filter(x -> StrUtil.equals(DeptType.MANAGER.getCode(), x.getDeptType())).findFirst().orElse(new SysDept());
589
+        SysDept brigade = deptList.stream().filter(x -> StrUtil.equals(DeptType.BRIGADE.getCode(), x.getDeptType())).findFirst().orElse(new SysDept());
590
+        SysDept station = deptList.stream().filter(x -> StrUtil.equals(DeptType.STATION.getCode(), x.getDeptType())).findFirst().orElse(new SysDept());
591
+        result.setTeamId(teams.getDeptId());
592
+        result.setTeamName(teams.getDeptName());
593
+        result.setDepartmentId(department.getDeptId());
594
+        result.setDepartmentName(department.getDeptName());
595
+        result.setBrigadeId(brigade.getDeptId());
596
+        result.setBrigadeName(brigade.getDeptName());
597
+        result.setStationId(station.getDeptId());
598
+        result.setStationName(station.getDeptName());
599
+        return result;
600
+    }
568 601
 }