| | |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.entity.*; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.common.core.service.IUserExtInfoService; |
| | | import com.ruoyi.common.core.service.ISatisfactionCategoryService; |
| | | import com.ruoyi.system.mapper.SysUserDeptMapper; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | import javax.validation.Validator; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.Executor; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Value("${isAdmin}") |
| | | private List<Long> isAdmin; |
| | | |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | | |
| | | /** |
| | | * 根据条件分页查询用户列表 |
| | |
| | | SysUserDept sysUserDept = new SysUserDept(); |
| | | sysUserDept.setUserId(sysUser.getUserId()); |
| | | sysUserDept.setDeptType(sysUser.getSearchscope()); |
| | | sysUserDept.setOrgid(sysUser.getOrgid()); |
| | | List<SysUserDept> sysUserDeptKSs = null; |
| | | List<SysUserDept> sysUserDeptBQs = null; |
| | | if (StringUtils.isNotEmpty(sysUser.getSearchscope()) && sysUser.getSearchscope().equals("0")) { |
| | |
| | | String[] split = userName.split("&"); |
| | | SysUser sysUser = userMapper.selectUserByUserNameByCondition(split[0], split[1], null); |
| | | if (Objects.isNull(sysUser)) return sysUser; |
| | | //这里只卡用户类型为“患者”的 |
| | | if (sysUser.getUserType().equals("患者") && StringUtils.isNotEmpty(split[3]) && !split[3].equals("null") && !sysUser.getUserType().equals(split[3].trim())) |
| | | throw new BaseException("当前用户类型与登录用户类型不一致"); |
| | | |
| | | boolean isAdmin = StringUtils.isNotEmpty(split[0]) && "admin".equals(split[0]); |
| | | IUserExtInfoService userExtInfoService = SpringUtils.getBean(IUserExtInfoService.class); |
| | | java.util.concurrent.Executor executor = SpringUtils.getBean("threadPoolTaskExecutor"); |
| | | Executor executor = SpringUtils.getBean("threadPoolTaskExecutor"); |
| | | |
| | | // === 并行查询: 用户机构信息 + 部门列表 === |
| | | CompletableFuture<Map<String, String>> orgInfoFuture = CompletableFuture.supplyAsync(() -> |
| | | userExtInfoService.getUserOrgInfo(sysUser.getUserId().toString(), split[1], split[2]), executor); |
| | | CompletableFuture<Map<String, String>> orgInfoFuture = CompletableFuture.supplyAsync(() -> userExtInfoService.getUserOrgInfo(sysUser.getUserId().toString(), split[1], split[2]), executor); |
| | | |
| | | CompletableFuture<List<SysDept>> deptsFuture; |
| | | if (isAdmin) { |
| | |
| | | } |
| | | sysUser.setBelongDepts(list); |
| | | // 设置满意度分类(走缓存) |
| | | sysUser.setSatisfactionCategories(userExtInfoService.getSatisfactionCategories(sysUser.getOrgid())); |
| | | // 满意度模块化后:不再经由 smartor 的 IUserExtInfoService, |
| | | // 改为按 ruoyi-common 的 ISatisfactionCategoryService 接口查找实现 |
| | | // (实现在 ruoyi-satisfaction,由常驻门面保证"模块关闭/缺失时返回空 Map") |
| | | sysUser.setSatisfactionCategories(loadSatisfactionCategories(sysUser.getOrgid())); |
| | | } |
| | | return sysUser; |
| | | } |
| | | |
| | | /** |
| | | * 安全地获取满意度分类。 |
| | | * <p> |
| | | * 满意度模块可以被配置关闭({@code sys_config} 参数 {@code satisfaction.enabled=false}),也可以整体不在依赖里; |
| | | * 这两种情况下都必须<b>不影响登录主流程</b>,因此这里: |
| | | * <ul> |
| | | * <li>容器里没有 {@code ISatisfactionCategoryService} 实现时返回空 Map;</li> |
| | | * <li>调用过程中抛任何异常也只记日志并返回空 Map。</li> |
| | | * </ul> |
| | | * |
| | | * @param orgid 机构ID |
| | | * @return 满意度分类;不可用时返回空 Map(不会返回 null) |
| | | */ |
| | | private Map<String, Object> loadSatisfactionCategories(String orgid) { |
| | | try { |
| | | ISatisfactionCategoryService satisfactionCategoryService = |
| | | SpringUtils.getBean(ISatisfactionCategoryService.class); |
| | | if (satisfactionCategoryService == null) { |
| | | return Collections.emptyMap(); |
| | | } |
| | | Map<String, Object> categories = satisfactionCategoryService.getSatisfactionCategories(orgid); |
| | | return categories == null ? Collections.emptyMap() : categories; |
| | | } catch (Exception e) { |
| | | log.warn("获取满意度分类失败,已降级为空结果(不影响登录)。orgid={}", orgid, e); |
| | | return Collections.emptyMap(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public SysUser selectUserByUserNameAndDeptId(String userName) { |
| | | String[] split = userName.split("&"); |
| | | if (split[2].contains("null")) { |
| | | //南华附一也不验证dept_id了 |
| | | if (split[2].contains("null") || active.equals("nhfy")) { |
| | | split[2] = null; |
| | | } |
| | | SysUser sysUser = userMapper.selectUserByUserNameByCondition(split[0], split[1], split[2]); |
| | | |
| | | //获取当前登陆人的机构和院�? |
| | | IUserExtInfoService userExtInfoService2 = SpringUtils.getBean(IUserExtInfoService.class); |
| | | Map<String, String> userOrgInfo2 = userExtInfoService2.getUserOrgInfo( |
| | | sysUser.getUserId().toString(), |
| | | split[1], |
| | | split[3]); |
| | | Map<String, String> userOrgInfo2 = userExtInfoService2.getUserOrgInfo(sysUser.getUserId().toString(), split[1], split[3]); |
| | | if (!userOrgInfo2.isEmpty()) { |
| | | sysUser.setOrgid(userOrgInfo2.get("orgid")); |
| | | sysUser.setCampusid(userOrgInfo2.get("campusid")); |
| | |
| | | // sysUserDeptMapper.insertSysUserDept(sysUserDep); |
| | | // } |
| | | // } |
| | | //删除原有关系 |
| | | SysUserDept delSysUserDept = new SysUserDept(); |
| | | delSysUserDept.setUserId(user.getUserId()); |
| | | delSysUserDept.setOrgid(user.getOrgid()); |
| | | sysUserDeptMapper.deleteSysUserDeptByUserId(delSysUserDept); |
| | | |
| | | if (!CollectionUtils.isEmpty(user.getDeptCodes())) { |
| | | for (String deptCode : user.getDeptCodes()) { |
| | | SysDept sysDept = sysDeptMapper.selectDeptByCode("1", user.getOrgid(), deptCode); |
| | |
| | | sysUserDept.setOrgid(user.getOrgid()); |
| | | sysUserDept.setDeptCode(deptCode); |
| | | sysUserDept.setDeptId(sysDept.getDeptId()); |
| | | List<SysUserDept> sysUserDepts = sysUserDeptMapper.selectSysUserDeptList(sysUserDept); |
| | | sysUserDept.setDelFlag(0L); |
| | | sysUserDept.setDeptType("1"); |
| | | sysUserDept.setDeptName(sysDept.getDeptName()); |
| | | sysUserDept.setUpdateTime(new Date()); |
| | | if (!CollectionUtils.isEmpty(sysUserDepts)) { |
| | | sysUserDept.setId(sysUserDepts.get(0).getId()); |
| | | sysUserDeptMapper.updateSysUserDept(sysUserDept); |
| | | continue; |
| | | } |
| | | sysUserDept.setCreateTime(new Date()); |
| | | sysUserDeptMapper.insertSysUserDept(sysUserDept); |
| | | } |
| | | } |
| | | |
| | | if (!CollectionUtils.isEmpty(user.getWardCodes())) { |
| | | for (String wardCode : user.getWardCodes()) { |
| | | SysDept sysDept = sysDeptMapper.selectDeptByCode("2", user.getOrgid(), wardCode); |
| | |
| | | sysUserDept.setDeptCode(wardCode); |
| | | sysUserDept.setDeptId(sysDept.getDeptId()); |
| | | sysUserDept.setOrgid(user.getOrgid()); |
| | | List<SysUserDept> sysUserDepts = sysUserDeptMapper.selectSysUserDeptList(sysUserDept); |
| | | sysUserDept.setDelFlag(0L); |
| | | sysUserDept.setDeptType("2"); |
| | | sysUserDept.setOrgid(user.getOrgid()); |
| | | sysUserDept.setDeptName(sysDept.getDeptName()); |
| | | sysUserDept.setUpdateTime(new Date()); |
| | | if (!CollectionUtils.isEmpty(sysUserDepts)) { |
| | | sysUserDeptMapper.updateSysUserDept(sysUserDept); |
| | | continue; |
| | | } |
| | | sysUserDept.setCreateTime(new Date()); |
| | | sysUserDeptMapper.insertSysUserDept(sysUserDept); |
| | | } |