zhangnaisong
2024-02-19 779c235959bd1979381b07ffe561242c9cdd9ce2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -18,6 +18,7 @@
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.mapper.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,11 +37,6 @@
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysUserPost;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysUserService;
@@ -77,6 +73,9 @@
    private RedisCache redisCache;
    @Resource
    private ArdAlarmTypeConfigMapper ardAlarmTypeConfigMapper;
    @Resource
    private SysDeptMapper sysDeptMapper;
    /**
     * 项目启动时,初始化参数到缓存
@@ -647,4 +646,25 @@
        queryWrapper.eq("dept_id",deptId).eq("del_flag","0").eq("app_user_type","1");
        return userMapper.selectList(queryWrapper);
    }
    @Override
    public List<SysUser> getAPPSoilderByCommanderId(String userId) {
        SysUser sysUser = userMapper.selectUserById(userId);//获取系统用户
        List<Long> deptIdList = new ArrayList();
        deptIdList.add(sysUser.getDeptId());
        deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//递归查询下属部门主键
        List<SysUser> result = userMapper.getOwnAndChildrenSoilderList(deptIdList);
        return result;
    }
    public List<Long> getOwnAndChildrenDeptIdList(List<Long> deptIdList,List<Long> deptIdListr){
        deptIdListr.addAll(deptIdList);
        List<Long> result = sysDeptMapper.getChildrenDeptIdList(deptIdList);
        if(result.size() != 0){
            deptIdListr.addAll(result);
            result = getOwnAndChildrenDeptIdList(result,deptIdListr);
        }
        deptIdListr = deptIdListr.stream().distinct().collect(Collectors.toList());
        return deptIdListr;
    }
}