From 0573252c6de638563ec000af56848dde15bbb25b Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 17 九月 2026 14:47:07 +0800
Subject: [PATCH] 【丽水】ssoGoServiceSubtaskList 调整
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java | 106 ++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 84 insertions(+), 22 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java
index 80f4e66..8f7c845 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java
+++ b/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;
@@ -8,23 +9,29 @@
import com.ruoyi.common.utils.OkHttpExample;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
+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;
+import com.smartor.domain.ServiceSubtask;
+import com.smartor.domain.VO.ServiceSubtaskVO;
+import com.smartor.domain.entity.ServiceSubtaskEntity;
+import com.smartor.service.IServiceSubtaskService;
+import com.smartor.service.impl.ServiceSubtaskServiceImpl;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
+
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.ObjectUtils;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.view.RedirectView;
import org.springframework.web.util.UriComponentsBuilder;
@@ -33,9 +40,7 @@
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.*;
/**
* SSO鍗曠偣鐧诲綍鎺у埗鍣�
@@ -88,9 +93,18 @@
private TokenService tokenService;
@Autowired
+ private SysLoginService loginService;
+
+ @Autowired
private ISysConfigService sysConfigService;
+ @Autowired
+ private ISysDeptService sysDeptService;
+
private final RestTemplate restTemplate;
+
+ @Autowired
+ private IServiceSubtaskService serviceSubtaskService;
public SSOController() {
// 閰嶇疆RestTemplate瓒呮椂
@@ -145,35 +159,83 @@
// 閲嶅畾鍚戝湴鍧�瀵硅薄(閲嶅畾鍚戝湴鍧�
RedirectView redirectView = new RedirectView();
try {
- SSOTokenResponse accessToken = getAccessTokenLyra(code, accessTokenUrl, clientId, redirectUri, clientSecret,true);
+ 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);
+// createLocalSession(userInfo);
if (StringUtils.isEmpty(path)) {
throw new BaseException("璇烽厤缃墠绔湴鍧�");
}
- String reviewUrl = "";
- reviewUrl = UriComponentsBuilder.fromHttpUrl(path)
- .path("/loginSSO")
- .queryParam("token", accessToken.getAccess_token())
- .queryParam("orgid", userInfo.getZuZhiJGID())
- .queryParam("orgname", userInfo.getZuZhiJGMC())
- .queryParam("ZuHuID", userInfo.getYongHuID())
- .queryParam("deptCode", "null")
- .build()
- .toUriString();
- log.info("鍗曠偣鐧婚檰閲嶅畾鍚戝湴鍧�涓猴細{}", reviewUrl);
- redirectView.setUrl(reviewUrl);
- redirectView.setStatusCode(HttpStatus.FOUND);
+ String userName = userInfo.getZhiGongID();
+ String orgid = userInfo.getZuZhiJGID();
+ String campusid = "1";
+ String deptId = null;
+ String token = null;
+ log.info("銆怱SO鐧诲綍銆戣幏鍙栫敤鎴稵oken鍙傛暟锛�" + userInfo);
+ String loginToken = loginService.ssoLogin(userName, orgid, deptId, campusid, token);
+ if (StringUtils.isEmpty(loginToken)) {
+ log.error("銆怱SO鐧诲綍銆戠櫥褰曞け璐ワ紝userName={}, orgid={}", userName, orgid);
+ return buildRedirect(path + "/login");
+ }
+
+ String redirectUrl = path + "/loginSSO?token=" + loginToken + "&orgid=" + orgid + "&orgname=null&ZuHuID=null&deptCode=null";
+ log.info("銆怱SO鐧诲綍銆戦噸瀹氬悜鍦板潃锛歿}", redirectUrl);
+ return buildRedirect(redirectUrl);
+
} catch (Exception e) {
log.error("SSO鐧诲綍澶辫触", e);
redirectView.setUrl(path + "/login?error=sso_failed");
return redirectView;
}
+ }
+ /**
+ * ssoGoServiceSubtaskList
+ */
+ @PostMapping("ssoGoServiceSubtaskList")
+ public RedirectView ssoGoServiceSubtaskList(@RequestBody SSOUserInfo ssoUserInfo) {
+ // 閲嶅畾鍚戝湴鍧�瀵硅薄(閲嶅畾鍚戝湴鍧�
+ RedirectView redirectView = new RedirectView();
+ String path = sysConfigService.selectConfigByKey("sys.qddz");
+ String userName = ssoUserInfo.getUsername();
+ String orgid = ssoUserInfo.getOrgid();
+ String campusid = ssoUserInfo.getCampusid();
+ String searchCondition = "";
+ String deptCode = ssoUserInfo.getDeptCode();
+ String wardCode = ssoUserInfo.getWardCode();
+ try {
+ if (StringUtils.isEmpty(path)) {
+ throw new BaseException("璇烽厤缃墠绔湴鍧�");
+ }
+ if(StringUtils.isNotEmpty(deptCode)){
+ searchCondition = "&followUpDeptCode=" + deptCode;
+ }else if(StringUtils.isNotEmpty(wardCode)){
+ searchCondition = "&followUpWardCode=" + deptCode;
+ }
+ String loginToken = loginService.loginByUserName(userName + "&" + orgid + "&null" + "&" + campusid);
+ String redirectUrl = path + "/loginSSO?token=" + loginToken +
+ "&orgid=" + orgid + "&campusid=" + campusid +
+ searchCondition + "&orgname=null&ZuHuID=null&deptCode=null";
+ log.info("銆怱SO鐧诲綍銆戦噸瀹氬悜鍦板潃锛歿}", redirectUrl);
+ return buildRedirect(redirectUrl);
+
+ } catch (Exception e) {
+ log.error("SSO鐧诲綍澶辫触", e);
+ redirectView.setUrl(path + "/login?error=sso_failed");
+ return redirectView;
+
+ }
+ }
+ /**
+ * 鏋勫缓閲嶅畾鍚戣鍥�
+ */
+ private RedirectView buildRedirect(String url) {
+ RedirectView redirectView = new RedirectView();
+ redirectView.setUrl(url);
+ redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
return redirectView;
}
--
Gitblit v1.9.3