|
@@ -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);
|
|
|
}
|
|
|
|