Explorar el Código

Merge branch 'master' into prod

buzhanyi hace 1 año
padre
commit
156a010f38

+ 2 - 0
purchase-common/src/main/java/com/ozs/common/core/domain/entity/SysDept.java

@@ -68,9 +68,11 @@ public class SysDept extends BaseEntity {
     private String delFlag;
 
     /** 父部门名称 */
+    @TableField(exist = false)
     private String parentName;
 
     /** 子部门 */
+    @TableField(exist = false)
     private List<SysDept> children = new ArrayList<SysDept>();
     /**
      * 备注

+ 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> {
     /**
      * 查询部门管理数据
      *

+ 35 - 17
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,19 +46,38 @@ 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])) {
+        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(dept.getDeptName(), organs);
+                    }
+                }
+            }
+        } else {
+            //本部门
+            LambdaQueryWrapper<SysDeptOrgan> wrapper = new LambdaQueryWrapper<>();
+            wrapper.eq(SysDeptOrgan::getDeptId, deptId);
+            String[] ancestors = (sysDept.getAncestors() + "," + deptId).split(",");
+            //上级(除了顶级组织的每一级)
+            if (ancestors.length > 1) {
+                for (int i = 1; i < ancestors.length; i++) {
+                    LambdaQueryWrapper<SysDeptOrgan> wrapperT = new LambdaQueryWrapper<>();
+                    List<SysDeptOrgan> organsT;
                     String did = ancestors[i];
                     wrapperT.eq(SysDeptOrgan::getDeptId, did);
                     organsT = deptOrganMapper.selectList(wrapperT);
@@ -69,11 +90,8 @@ public class SysDeptOrganServiceImpl implements SysDeptOrganService {
                 }
             }
         }
-        if (ObjectUtils.isEmpty(sysDept)) {
-            hashMap.put(sysDept.getDeptName() + "(暂无数据)", organs);
-        } else {
-            hashMap.put(sysDept.getDeptName(), organs);
-        }
+
+
         return AjaxResult.success(hashMap);
     }