From 26b18b6170b54d4da3cb7f19fac1e0a0627d17f8 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 15 一月 2026 14:04:40 +0800
Subject: [PATCH] 【景宁】SSO单点登录接口
---
smartor/src/main/java/com/smartor/domain/SSOUserInfo.java | 52 +++++++++++++----
ruoyi-admin/src/main/java/com/ruoyi/web/controller/sso/SSOController.java | 57 +++++++++++++++---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java | 30 ++++++++++
3 files changed, 117 insertions(+), 22 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java
index f0c91d1..08f9db6 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/PatMedInhospController.java
@@ -11,6 +11,7 @@
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.system.service.ISysConfigService;
import com.smartor.domain.PatMedInhosp;
import com.smartor.domain.PatMedInhospVO;
import com.smartor.domain.PatMedReq;
@@ -42,6 +43,19 @@
@Autowired
private IPatMedOuthospService iPatMedOuthospService;
+
+ @Autowired
+ private IPatMedInhospService iPatMedInhospService;
+
+ @Autowired
+ private ISysConfigService configService;
+
+ @Value("${server.port}")
+ private String port;
+
+
+ @Value("${spring.profiles.active}")
+ private String active;
/**
* 鏌ヨ鎮h�呬綇闄㈣褰曞垪琛�
@@ -215,4 +229,20 @@
// }
// }
+ /**
+ * 澶勭悊鎮h�呬俊鎭紝杩涘叆瀛愪换鍔¤〃
+ */
+ @ApiOperation("dealOutHospInfo")
+ @PostMapping("/dealOutHospInfo")
+ public void dealOutHospInfo() {
+ String config = configService.selectConfigByKey("visit.early.day");
+ if (port.equals("8095")) {
+ //鍑洪櫌琛�
+ iPatMedInhospService.dealOutHospInfo(config);
+ //闂ㄨ瘖琛�(鏂板崕鐨勬殏鏃朵笉鍋氶棬璇婇殢璁�)
+ if (!active.equals("xh")) {
+ iPatMedOuthospService.dealOutpatientInfo();
+ }
+ }
+ }
}
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 78296c7..e174e25 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
@@ -3,10 +3,12 @@
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.HttpUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysUserService;
import com.smartor.domain.SSOTokenResponse;
import com.smartor.domain.SSOUserInfo;
@@ -22,6 +24,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
+import org.springframework.web.servlet.view.RedirectView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -80,6 +83,9 @@
@Autowired
private TokenService tokenService;
+ @Autowired
+ private ISysConfigService sysConfigService;
+
private final RestTemplate restTemplate;
public SSOController() {
@@ -94,14 +100,24 @@
* SSO鐧诲綍鍏ュ彛 - 淇¢�氶櫌浼氳皟鐢ㄨ繖涓湴鍧�
* 璁块棶璺緞锛歨ttp://鍩熷悕:8095/sso/login
*/
- @GetMapping("")
- public void ssoLogin() {
+ @GetMapping("ssoLogin")
+ public RedirectView ssoLogin() {
log.info("鏀跺埌SSO鐧诲綍璇锋眰锛屽紑濮嬮噸瀹氬悜鍒版巿鏉冩湇鍔″櫒");
+ String id = clientId;
+ String redirectUri = internalRedirectUri;
+ String scope = "openid";
+ id = "1553548571532333056";
+ redirectUri = URLEncoder.encode(internalRedirectUri);
+ // 閲嶅畾鍚戝湴鍧�瀵硅薄(閲嶅畾鍚戝湴鍧�
+ RedirectView redirectView = new RedirectView();
// Authorize閴存潈鎺ュ彛
- String param = "client_id=" + clientId + "&redirect_uri=" + internalRedirectUri + "&response_type=code" + "&state=" + state + "&scope=" + scope;
+ String param = "client_id=" + id + "&redirect_uri=" + redirectUri + "&response_type=code" +
+ "&state=" + state + "&scope=" + scope;
log.info("銆怉uthorize閴存潈鎺ュ彛銆戝叆鍙備负锛歿}", param);
- String s = HttpUtils.sendGet(internalAuthorizeUrl, param);
+ String url = "https://9.208.39.29:13021" + "/mediinfo-lyra-authserver/connect/authorize";
+// String url = internalAuthorizeUrl;
+ String s = HttpUtils.sendGet(url, param);
Map<String, String> result = getResult(s);
String code = result.get("code");
try {
@@ -110,9 +126,22 @@
createLocalSession(userInfo);
+ String path = sysConfigService.selectConfigByKey("sys.qddz");
+ if (StringUtils.isEmpty(path)) {
+ throw new BaseException("璇烽厤缃墠绔湴鍧�");
+ }
+ String reviewUrl = path + "/loginSSO?token=" + accessToken.getAccess_token() + "&orgid=" +
+ userInfo.getZuZhiJGID() + "&orgname=" + userInfo.getZuZhiJGMC() +
+ "&ZuHuID="+ userInfo.getYongHuID() +"&deptCode=null";
+ log.info("鍗曠偣鐧婚檰閲嶅畾鍚戝湴鍧�涓猴細{}", reviewUrl);
+ redirectView.setUrl(reviewUrl);
+ redirectView.setStatusCode(HttpStatus.MOVED_PERMANENTLY);
} catch (Exception e) {
e.printStackTrace();
+ return new RedirectView();
}
+
+ return redirectView;
}
private Map<String, String> getResult(String param) {
@@ -143,15 +172,22 @@
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
- params.add("client_id", clientId);
- params.add("client_secret", clientSecret);
+ String id = clientId;
+ String secret = clientSecret;
+ String url = getTokenUrl(isInternal);
+ String redirectUri = getRedirectUri(isInternal);
+ id = "1553548571532333056";
+ secret = "suifangxt";
+ url = "https://9.208.39.29:13021" + "/mediinfo-lyra-authserver/connect/token";
+ params.add("client_id", id);
+ params.add("client_secret", secret);
params.add("code", code);
params.add("grant_type", "authorization_code");
- params.add("redirect_uri", getRedirectUri(isInternal));
+ params.add("redirect_uri", redirectUri);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers);
- ResponseEntity<String> response = restTemplate.exchange(getTokenUrl(isInternal), HttpMethod.POST, request, String.class);
+ ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, request, String.class);
log.info("Token鍝嶅簲: {}", response.getBody());
@@ -176,8 +212,9 @@
headers.set("Authorization", "Bearer " + accessToken);
HttpEntity<String> entity = new HttpEntity<>(headers);
-
- ResponseEntity<String> response = restTemplate.exchange(getUserinfoUrl(isInternal), HttpMethod.GET, entity, String.class);
+ String url = getUserinfoUrl(isInternal);
+ url = "https://9.208.39.29:13021" + "/mediinfo-lyra-authserver/connect/userinfo";
+ ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
log.info("鐢ㄦ埛淇℃伅鍝嶅簲: {}", response.getBody());
diff --git a/smartor/src/main/java/com/smartor/domain/SSOUserInfo.java b/smartor/src/main/java/com/smartor/domain/SSOUserInfo.java
index 88574e3..10cdec5 100644
--- a/smartor/src/main/java/com/smartor/domain/SSOUserInfo.java
+++ b/smartor/src/main/java/com/smartor/domain/SSOUserInfo.java
@@ -1,19 +1,47 @@
package com.smartor.domain;
+import lombok.Data;
+
+@Data
public class SSOUserInfo {
- private String sub; // 鐢ㄦ埛ID
- private String name; // 鐢ㄦ埛鍚�/宸ュ彿
+
+ /**
+ *韬唤鎻愪緵鑰�
+ */
+ private String idp;
+ /**
+ *涓婚
+ */
+ private String sub;
+ /**
+ *缁勭粐鏈烘瀯id
+ */
+ private String zuZhiJGID;
+ /**
+ *缁勭粐鏈烘瀯鍚嶇О
+ */
+ private String zuZhiJGMC;
+ /**
+ *鍞竴鍚嶇О
+ */
+ private String unique_name;
+ /**
+ *鐢ㄦ埛id
+ */
+ private String yongHuID;
+ /**
+ *鍚嶇О
+ */
+ private String name;
private String nickname; // 鏄剧ず鍚�
-
- // getter鍜宻etter鏂规硶
- public String getSub() { return sub; }
- public void setSub(String sub) { this.sub = sub; }
-
- public String getName() { return name; }
- public void setName(String name) { this.name = name; }
-
- public String getNickname() { return nickname; }
- public void setNickname(String nickname) { this.nickname = nickname; }
+ /**
+ *韬唤璇�
+ */
+ private String id_card;
+ /**
+ *鎵嬫満鍙�
+ */
+ private String phone;
@Override
public String toString() {
--
Gitblit v1.9.3