|  |  | 
 |  |  | 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.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.*; | 
 |  |  | 
 |  |  |             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) { | 
 |  |  | 
 |  |  |         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()); | 
 |  |  | 
 |  |  |         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); |