|  |  | 
 |  |  | import com.ruoyi.common.constant.UserConstants; | 
 |  |  | import com.ruoyi.common.core.domain.entity.*; | 
 |  |  | import com.ruoyi.common.exception.ServiceException; | 
 |  |  | import com.ruoyi.common.utils.DtoConversionUtils; | 
 |  |  | import com.ruoyi.common.utils.SecurityUtils; | 
 |  |  | import com.ruoyi.common.utils.StringUtils; | 
 |  |  | import com.ruoyi.common.utils.bean.BeanValidators; | 
 |  |  | 
 |  |  | import com.ruoyi.system.mapper.*; | 
 |  |  | import com.ruoyi.system.service.ISysConfigService; | 
 |  |  | import com.ruoyi.system.service.ISysUserService; | 
 |  |  | import com.smartor.domain.SvyTaskVO; | 
 |  |  | import com.smartor.mapper.SysUserDeptMapper; | 
 |  |  | import org.slf4j.Logger; | 
 |  |  | import org.slf4j.LoggerFactory; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.beans.factory.annotation.Value; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  | import org.springframework.util.CollectionUtils; | 
 |  |  | import org.springframework.util.ObjectUtils; | 
 |  |  |  | 
 |  |  | import javax.validation.Validator; | 
 |  |  | import java.util.*; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     protected Validator validator; | 
 |  |  |  | 
 |  |  |     @Value("${isAdmin}") | 
 |  |  |     private List<Long> isAdmin; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据条件分页查询用户列表 | 
 |  |  | 
 |  |  |         SysUserDept sysUserDept = new SysUserDept(); | 
 |  |  |         sysUserDept.setUserId(sysUser.getUserId()); | 
 |  |  |         sysUserDept.setDeptType(sysUser.getSearchscope()); | 
 |  |  |         sysUserDept.setOrgid(split[1]); | 
 |  |  |         List<SysUserDept> sysUserDeptKSs = null; | 
 |  |  |         List<SysUserDept> sysUserDeptBQs = null; | 
 |  |  |         if (StringUtils.isNotEmpty(sysUser.getSearchscope()) && sysUser.getSearchscope().equals("0")) { | 
 |  |  | 
 |  |  |             sysUserDeptBQs = sysUserDeptMapper.selectSysUserDeptList(sysUserDept); | 
 |  |  |             //如果是admin,需要对sysUserDeptBQs,sysUserDeptBQs去重 | 
 |  |  |             if (StringUtils.isNotEmpty(split[0]) && split[0].equals("admin")) { | 
 |  |  |                 //如果是admin,只能去sys_dept去取数据 | 
 |  |  |                 SysDept dept = new SysDept(); | 
 |  |  |                 dept.setOrgid(split[1]); | 
 |  |  |                 dept.setDeptType("1"); | 
 |  |  |                 sysDepts = sysDeptMapper.selectDeptList(dept); | 
 |  |  |                 sysUserDeptKSs = DtoConversionUtils.sourceToTarget(sysDepts, SysUserDept.class); | 
 |  |  |  | 
 |  |  |                 dept.setDeptType("2"); | 
 |  |  |                 sysDepts = sysDeptMapper.selectDeptList(dept); | 
 |  |  |                 sysUserDeptBQs = DtoConversionUtils.sourceToTarget(sysDepts, SysUserDept.class); | 
 |  |  |  | 
 |  |  |                 List<SysUserDept> distinctUserDepts = new ArrayList<>(); | 
 |  |  |                 Set<String> uniqueDeptCodes = new HashSet<>(); | 
 |  |  |                 for (SysUserDept userDept : sysUserDeptKSs) { | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public void checkUserAllowed(SysUser user) { | 
 |  |  |         if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) { | 
 |  |  |         if (StringUtils.isNotNull(user.getUserId()) && isAdmin.contains(user.getUserId())) { | 
 |  |  |             throw new ServiceException("不允许操作超级管理员用户"); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public void checkUserDataScope(Long userId) { | 
 |  |  |         if (!SysUser.isAdmin(SecurityUtils.getUserId())) { | 
 |  |  |         if (!isAdmin.contains(SecurityUtils.getUserId())) { | 
 |  |  |             SysUser user = new SysUser(); | 
 |  |  |             user.setUserId(userId); | 
 |  |  |             List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user); | 
 |  |  | 
 |  |  |         if (!CollectionUtils.isEmpty(user.getDeptCodes())) { | 
 |  |  |             for (String deptCode : user.getDeptCodes()) { | 
 |  |  |                 SysDept sysDept = sysDeptMapper.selectDeptByCode(deptCode); | 
 |  |  |                 if (ObjectUtils.isEmpty(sysDept)) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 SysUserDept sysUserDept = new SysUserDept(); | 
 |  |  |                 sysUserDept.setUserId(user.getUserId()); | 
 |  |  |                 sysUserDept.setOrgid(user.getOrgid()); | 
 |  |  |                 sysUserDept.setDeptCode(deptCode); | 
 |  |  |                 sysUserDept.setDeptId(sysDept.getDeptId()); | 
 |  |  |                 List<SysUserDept> sysUserDepts = sysUserDeptMapper.selectSysUserDeptList(sysUserDept); | 
 |  |  |                 sysUserDept.setDelFlag(0L); | 
 |  |  |                 sysUserDept.setDeptType("1"); | 
 |  |  | 
 |  |  |         if (!CollectionUtils.isEmpty(user.getWardCodes())) { | 
 |  |  |             for (String wardCode : user.getWardCodes()) { | 
 |  |  |                 SysDept sysDept = sysDeptMapper.selectDeptByCode(wardCode); | 
 |  |  |  | 
 |  |  |                 if (ObjectUtils.isEmpty(sysDept)) { | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 SysUserDept sysUserDept = new SysUserDept(); | 
 |  |  |                 sysUserDept.setUserId(user.getUserId()); | 
 |  |  |                 sysUserDept.setDeptCode(wardCode); | 
 |  |  |                 sysUserDept.setDeptId(sysDept.getDeptId()); | 
 |  |  |                 sysUserDept.setOrgid(user.getOrgid()); | 
 |  |  |                 List<SysUserDept> sysUserDepts = sysUserDeptMapper.selectSysUserDeptList(sysUserDept); | 
 |  |  |                 sysUserDept.setDelFlag(0L); | 
 |  |  |                 sysUserDept.setDeptType("2"); |