陈昶聿
8 小时以前 cc560edc4af2755297b4b8368e8fb816b35e1ed3
【丽水】ssoGoServiceSubtaskList 调整
已修改3个文件
102 ■■■■ 文件已修改
ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java
@@ -1,6 +1,7 @@
package com.ruoyi.web.controller.sso;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.base.BaseException;
@@ -11,6 +12,7 @@
import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import com.smartor.domain.SSOTokenResponse;
import com.smartor.domain.SSOUserInfo;
@@ -95,6 +97,9 @@
    @Autowired
    private ISysConfigService sysConfigService;
    @Autowired
    private ISysDeptService sysDeptService;
    private final RestTemplate restTemplate;
@@ -189,68 +194,42 @@
    /**
     * ssoGoServiceSubtaskList
     * code 是/mediinfo-lyra-authserver/connect/authorize 由his提供
     * 登录客户端ID是固定的 clientId = 1553588321874087936  clientSecret = suifangxt
     */
    @GetMapping("ssoGoServiceSubtaskList")
    public RedirectView ssoGoServiceSubtaskList(@RequestParam(value = "code", required = false) String code,
                                                @RequestParam(value = "sfzh", required = false) String sfzh) {
    @PostMapping("ssoGoServiceSubtaskList")
    public RedirectView ssoGoServiceSubtaskList(@RequestBody SysUser sysUserVo) {
        // 重定向地址对象(重定向地址
        RedirectView redirectView = new RedirectView();
        log.info("收到ssoGoServiceSubtaskList请求,开始重定向到授权服务器,code = {}, sfzh = {}",code, sfzh);
        String path = sysConfigService.selectConfigByKey("sys.qddz");
        String redirectUri = "https://9.208.2.190:8092/prod-api/sso/ssoLoginLyra";
        String lyraPath = "https://9.0.124.104:13021";
        String clientId = "1553588321874087936";
        String clientSecret = "suifangxt";
        String scope = "openid";
        ServiceSubtaskEntity subtask = new ServiceSubtaskEntity();
        subtask.setSfzh(sfzh);
        subtask.setSort(0);
        List<ServiceSubtask> serviceSubtaskList = serviceSubtaskService.selectServiceSubtaskList(subtask);
        ServiceSubtask serviceSubtask = null;
        if(CollectionUtils.isNotEmpty(serviceSubtaskList)){
            serviceSubtask = serviceSubtaskList.get(0);
        }else {
            redirectView.setUrl(path + "/login?error=sso_failed");
            return redirectView;
        }
//        String authorizeUrl = lyraPath + "/mediinfo-lyra-authserver/connect/authorize";
        String accessTokenUrl = lyraPath + "/mediinfo-lyra-authserver/connect/token";
        String userInfoUrl =  lyraPath + "/mediinfo-lyra-authserver/connect/userinfo";
        String userName = sysUserVo.getUserName();
        String orgid = sysUserVo.getOrgid();
        String campusid = sysUserVo.getCampusid();
        Long deptId = sysUserVo.getDeptId();
        List<String> deptCodes = sysUserVo.getDeptCodes();
        List<String> wardCodes = sysUserVo.getWardCodes();
        try {
            SSOTokenResponse accessToken = getAccessTokenLyra(code, accessTokenUrl, clientId, clientSecret, redirectUri,true);
            log.info("获取到的token:" + accessToken);
            SSOUserInfo userInfo = getUserInfoLyra(accessToken.getAccess_token(), userInfoUrl,true);
            log.info("获取到的用户信息:" + userInfo);
//            createLocalSession(userInfo);
            if (StringUtils.isEmpty(path)) {
                throw new BaseException("请配置前端地址");
            }
            String userName =  userInfo.getZhiGongID();
            String orgid = userInfo.getZuZhiJGID();
            String campusid = "1";
            String deptId = null;
            String token = null;
            log.info("【SSO登录】获取用户Token参数:" + userInfo);
            String loginToken = loginService.ssoLogin(userName, orgid, deptId, campusid, token);
            if (StringUtils.isEmpty(loginToken)) {
                log.error("【SSO登录】登录失败,userName={}, orgid={}", userName, orgid);
                return buildRedirect(path + "/login");
            if(ObjectUtils.isEmpty(deptId)){
                SysDept sysDeptVo = new SysDept();
                sysDeptVo.setOrgid(orgid);
                sysDeptVo.setCampusid(campusid);
                if(CollectionUtils.isNotEmpty(deptCodes)){
                    sysDeptVo.setDeptType("1");
                    sysDeptVo.setDeptCodes(deptCodes);
                }else {
                    sysDeptVo.setDeptType("2");
                    sysDeptVo.setDeptCodes(wardCodes);
                }
                List<SysDept> sysDepts = sysDeptService.selectSysDeptList(sysDeptVo);
                if(CollectionUtils.isNotEmpty(sysDepts)){
                    deptId = sysDepts.get(0).getDeptId();
                }
            }
            String voiceType = (StringUtils.isNotEmpty(serviceSubtask.getType())
                    && serviceSubtask.getType().equals("1")) ? "1" : "0";
            String loginToken  = loginService.loginByUserName(userName + "&" + orgid + "&null" + "&" + campusid);
            String redirectUrl = path + "/loginSSO?token=" + loginToken +
                    "&orgid=" + orgid + "&campusid=" + serviceSubtask.getCampusid() +
                    "&taskid=" + serviceSubtask.getTaskid() + "&patid=" + serviceSubtask.getPatid() +
                    "&id=" + serviceSubtask.getId() + "&voiceType=" + voiceType +
                    "&visitCount=" + serviceSubtask.getVisitCount() + "&sfzh=" + sfzh +
                    "&orgname=null&ZuHuID=null&deptCode=null";
                    "&orgid=" + orgid + "&campusid=" + campusid +
                    "&deptId=" + deptId + "&orgname=null&ZuHuID=null&deptCode=null";
            log.info("【SSO登录】重定向地址:{}", redirectUrl);
            return buildRedirect(redirectUrl);
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java
@@ -23,6 +23,14 @@
    public List<SysDept> selectDeptList(SysDept dept);
    /**
     * 查询部门管理数据
     *
     * @param dept 部门信息
     * @return 部门信息集合
     */
    public List<SysDept> selectSysDeptList(SysDept dept);
    /**
     * 获取所有的部门信息
     * @return
     */
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -53,6 +53,17 @@
        return deptMapper.selectDeptList(dept);
    }
    /**
     * 查询部门管理数据
     *
     * @param dept 部门信息
     * @return 部门信息集合
     */
    @Override
    public List<SysDept> selectSysDeptList(SysDept dept) {
        return deptMapper.selectDeptList(dept);
    }
    @Override
    public Map<String, String> selectDept(String orgid) {
        SysDept sysDept = new SysDept();