فهرست منبع

机关指导处

buzhanyi 1 سال پیش
والد
کامیت
eee899aae4

+ 2 - 1
purchase-system/src/main/java/com/ozs/system/mapper/SysDeptMapper.java

@@ -2,6 +2,7 @@ package com.ozs.system.mapper;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import com.ozs.common.core.domain.entity.SysDept;
 
@@ -10,7 +11,7 @@ import com.ozs.common.core.domain.entity.SysDept;
  *
  * @author ruoyi
  */
-public interface SysDeptMapper {
+public interface SysDeptMapper extends BaseMapper<SysDept> {
     /**
      * 查询部门管理数据
      *

+ 44 - 19
purchase-system/src/main/java/com/ozs/system/service/impl/SysDeptOrganServiceImpl.java

@@ -3,6 +3,7 @@ package com.ozs.system.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ozs.common.core.domain.AjaxResult;
 import com.ozs.common.core.domain.entity.SysDept;
+import com.ozs.common.core.domain.model.LoginUser;
 import com.ozs.common.utils.SecurityUtils;
 import com.ozs.system.domain.SysDeptOrgan;
 import com.ozs.system.mapper.SysDeptMapper;
@@ -12,6 +13,7 @@ import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -44,31 +46,54 @@ public class SysDeptOrganServiceImpl implements SysDeptOrganService {
     @Override
     public AjaxResult selectListMap() {
         HashMap<String, List<SysDeptOrgan>> hashMap = new LinkedHashMap<>();
-        Long deptId = SecurityUtils.getDeptId();
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        Long deptId = loginUser.getDeptId();
         SysDept sysDept = sysDeptMapper.selectDeptById(deptId);
-        //本部门
-        LambdaQueryWrapper<SysDeptOrgan> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(SysDeptOrgan::getDeptId, deptId);
-        List<SysDeptOrgan> organs = deptOrganMapper.selectList(wrapper);
-        String[] ancestors = sysDept.getAncestors().split(",");
-        //上级(除了顶级组织的每一级)
-        if (ancestors.length > 2) {
-            for (int i = 2; i < ancestors.length; i++) {
-                LambdaQueryWrapper<SysDeptOrgan> wrapperT = new LambdaQueryWrapper<>();
-                List<SysDeptOrgan> organsT;
-                if (!ObjectUtils.isEmpty(ancestors[i])) {
-                    String did = ancestors[i];
-                    wrapperT.eq(SysDeptOrgan::getDeptId, did);
-                    organsT = deptOrganMapper.selectList(wrapperT);
-                    SysDept sysDeptTwo = sysDeptMapper.selectDeptById(Long.parseLong(did));
-                    if (ObjectUtils.isEmpty(organsT)) {
-                        hashMap.put(sysDeptTwo.getDeptName() + "(暂无数据)", organsT);
+        List<SysDeptOrgan> organs = new ArrayList<>();
+
+        //admin 账号查每一个单位的机关指导处
+        if (loginUser.getUserId().equals(Long.valueOf("1"))) {
+            LambdaQueryWrapper<SysDept> wrapperDept = new LambdaQueryWrapper<>();
+            List<SysDept> deptList = sysDeptMapper.selectList(wrapperDept);
+            //查询指导处
+            if (!ObjectUtils.isEmpty(deptList)) {
+                for (SysDept dept : deptList) {
+                    LambdaQueryWrapper<SysDeptOrgan> wrapperT = new LambdaQueryWrapper<>();
+                    wrapperT.eq(SysDeptOrgan::getDeptId, dept.getDeptId());
+                    organs = deptOrganMapper.selectList(wrapperT);
+                    if (ObjectUtils.isEmpty(organs)) {
+                        hashMap.put(dept.getDeptName() + "(暂无数据)", organs);
                     } else {
-                        hashMap.put(sysDeptTwo.getDeptName(), organsT);
+                        hashMap.put(dept.getDeptName(), organs);
+                    }
+                }
+            }
+        } else {
+            //本部门
+            LambdaQueryWrapper<SysDeptOrgan> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(SysDeptOrgan::getDeptId, deptId);
+            String[] ancestors = sysDept.getAncestors().split(",");
+            //上级(除了顶级组织的每一级)
+            if (ancestors.length > 2) {
+                for (int i = 2; i < ancestors.length; i++) {
+                    LambdaQueryWrapper<SysDeptOrgan> wrapperT = new LambdaQueryWrapper<>();
+                    List<SysDeptOrgan> organsT;
+                    if (!ObjectUtils.isEmpty(ancestors[i])) {
+                        String did = ancestors[i];
+                        wrapperT.eq(SysDeptOrgan::getDeptId, did);
+                        organsT = deptOrganMapper.selectList(wrapperT);
+                        SysDept sysDeptTwo = sysDeptMapper.selectDeptById(Long.parseLong(did));
+                        if (ObjectUtils.isEmpty(organsT)) {
+                            hashMap.put(sysDeptTwo.getDeptName() + "(暂无数据)", organsT);
+                        } else {
+                            hashMap.put(sysDeptTwo.getDeptName(), organsT);
+                        }
                     }
                 }
             }
         }
+
+
         if (ObjectUtils.isEmpty(sysDept)) {
             hashMap.put(sysDept.getDeptName() + "(暂无数据)", organs);
         } else {