Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
9cc64cd648
|
@ -83,4 +83,15 @@ public class AuthService {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void logout(String eoss_ip,String session_id){
|
||||
String url = String.format("%s/sso2/authCenter/logout", eoss_ip);
|
||||
// 构建 URL,添加查询参数
|
||||
String urlWithParams = UriComponentsBuilder.fromHttpUrl(url)
|
||||
.queryParam("sessionId", session_id)
|
||||
.toUriString(); // 生成带参数的完整 URL
|
||||
|
||||
ResponseEntity<String> response = restTemplate.exchange(urlWithParams, HttpMethod.GET,null, String.class);
|
||||
logger.info(String.format("logout→返回结果:%s",response.getBody()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,18 @@ package shkd.sys.sys.eoss;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.cache.CacheFactory;
|
||||
import kd.bos.cache.DistributeSessionlessCache;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.login.thirdauth.ThirdSSOAuthHandler;
|
||||
import kd.bos.login.thirdauth.UserAuthResult;
|
||||
import kd.bos.login.thirdauth.UserProperType;
|
||||
import kd.bos.servicehelper.user.UserServiceHelper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -34,14 +40,25 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
|
|||
public void callTrdSSOLogin(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, String s) {
|
||||
//认证中心的登录地址
|
||||
logger.info(String.format("eoss_ip:%s,client_id:%s,client_secret:%s,重定向地址:%s",EOSS_IP,CLIENT_ID,CLIENT_SECRET,s));
|
||||
|
||||
try {
|
||||
//重定向的统一认证的地址
|
||||
/**
|
||||
* 获取授权码
|
||||
*/
|
||||
String ssourl=String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&authType=0&redirect_uri=%s",
|
||||
EOSS_IP,CLIENT_ID,s);
|
||||
logger.info(String.format("重定向地址→sendRedirect:%s",ssourl));
|
||||
String ssourl= EOSS_IP+"/service/SGE-project-sctz-master/pc/dist/login.html";
|
||||
if (httpServletRequest.getRequestURI().contains("/auth/logout.do")){
|
||||
String userName = UserServiceHelper.getCurrentUser("name").getString("name");
|
||||
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
|
||||
String userKey = "user_sessionId_" + userName; // 构造一个唯一的键
|
||||
String sessionId = cache.get(userKey);
|
||||
if (sessionId != null) {
|
||||
AuthService.logout(EOSS_IP, sessionId);
|
||||
}
|
||||
}else{
|
||||
/**
|
||||
*重定向的统一认证的地址 获取授权码
|
||||
*/
|
||||
ssourl=String.format("%s/sso2/authCenter/authorize?client_id=%s&response_type=code&authType=0&redirect_uri=%s",
|
||||
EOSS_IP,CLIENT_ID,s);
|
||||
logger.info(String.format("重定向地址→sendRedirect:%s",ssourl));
|
||||
}
|
||||
httpServletResponse.sendRedirect(ssourl);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -61,9 +78,11 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
|
|||
UserAuthResult result=new UserAuthResult();
|
||||
//获取返回的授权码
|
||||
String code = httpServletRequest.getParameter("code");
|
||||
logger.info(String.format("getTrdSSOAuth→code:%s",code));
|
||||
//获取返回的 sessionId
|
||||
String sessionId = httpServletRequest.getParameter("sessionId");
|
||||
logger.info(String.format("getTrdSSOAuth→授权码code:%s",code));
|
||||
if (StringUtils.isEmpty(code)){
|
||||
logger.error("getTrdSSOAuth→code为空");
|
||||
logger.error("getTrdSSOAuth→授权码code为空");
|
||||
result.setSucess(false);
|
||||
}else {
|
||||
try {
|
||||
|
@ -81,6 +100,11 @@ public class SSOPluginLogin implements ThirdSSOAuthHandler {
|
|||
result.setUser(user);
|
||||
result.setSucess(true);
|
||||
logger.info("SSO用户登录成功,进入苍穹系统");
|
||||
|
||||
String userKey = "user_sessionId_" + user; // 构造一个唯一的键
|
||||
DistributeSessionlessCache cache = CacheFactory.getCommonCacheFactory().getDistributeSessionlessCache("customRegion");
|
||||
cache.put(userKey,sessionId);//将自定义参数加入缓存
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.openapi.api.plugin.ApiSavePlugin;
|
||||
import kd.bos.openapi.api.plugin.ApiSerializerPlugin;
|
||||
import kd.bos.openapi.api.plugin.SerializerResult;
|
||||
|
@ -24,13 +26,14 @@ import java.util.Map;
|
|||
* @Date 2024/11/7
|
||||
*/
|
||||
public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin {
|
||||
private static final Log logger = LogFactory.getLog(PayBillApiSavePlugin.class);
|
||||
private static final long serialVersionUID = 7055073356277386444L;
|
||||
private String shkd_businessid;
|
||||
private String shkd_businessnumber;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) {
|
||||
|
||||
logger.info("接口调用接口参数:{}", reqData);
|
||||
//付款处理 → 收款人ID payee → 付款银行.编码 payerbank_number payeetype 收款人类型 → payeenumber 收款人编码
|
||||
//payeracctbank_number 付款银行账号.number
|
||||
|
||||
|
@ -51,6 +54,7 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
Object payeetype = map.get("payeetype");//如果是收款人类型 则为付款处理保存接口
|
||||
Object payertype = map.get("payertype");//如果是付款人类型 则为收款处理保存接口
|
||||
if (payeetype != null) {
|
||||
logger.info("进入付款处理单API");
|
||||
objectType = payeetype.toString();
|
||||
objectNumber = map.get("payeenumber").toString();
|
||||
fieldName1 = "payee";
|
||||
|
@ -58,12 +62,14 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
bankNumber = map.get("payeracctbank_number").toString();
|
||||
fieldName2 = "payerbank_number";
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(objectType, "id", new QFilter("billno", QCP.equals, objectNumber).toArray());
|
||||
logger.info("objectType:{},objectNumber:{}", objectType, objectNumber);
|
||||
DynamicObject amAccountbank = BusinessDataServiceHelper.loadSingle("am_accountbank", "id,bank,bank.number", new QFilter("number", QCP.equals, bankNumber).toArray());
|
||||
logger.info("amAccountbank:{}", amAccountbank);
|
||||
map.put(fieldName1, dynamicObject.getString("id"));
|
||||
map.put(fieldName2, amAccountbank.getDynamicObject("bank").getString("number"));
|
||||
}
|
||||
|
||||
if (payertype != null){
|
||||
if (payertype != null) {
|
||||
objectType = payertype.toString();
|
||||
objectNumber = map.get("payernumber").toString();
|
||||
fieldName1 = "payer";
|
||||
|
@ -71,7 +77,9 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
bankNumber = map.get("accountbank_number").toString();
|
||||
fieldName2 = "payeebank_number";
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(objectType, "id", new QFilter("billno", QCP.equals, objectNumber).toArray());
|
||||
logger.info("objectType:{},objectNumber:{}", objectType, objectNumber);
|
||||
DynamicObject amAccountbank = BusinessDataServiceHelper.loadSingle("am_accountbank", "id,bank,bank.number", new QFilter("number", QCP.equals, bankNumber).toArray());
|
||||
logger.info("amAccountbank:{}", amAccountbank);
|
||||
map.put(fieldName1, dynamicObject.getString("id"));
|
||||
map.put(fieldName2, amAccountbank.getDynamicObject("bank").getString("number"));
|
||||
}
|
||||
|
@ -80,14 +88,17 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
// shkd_businessid
|
||||
// shkd_businessnumber
|
||||
// shkd_businessname
|
||||
logger.info("最终处理 → 调用接口参数:{}", reqData);
|
||||
}
|
||||
return reqData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult serialize(Object response, String accept, String contentType) {
|
||||
logger.info("进入serialize方法");
|
||||
try {
|
||||
if (contentType.contains(MediaType.APPLICATION_JSON)) {
|
||||
logger.info("进入if");
|
||||
//返回text文本
|
||||
String responseStr = new ObjectMapper().writeValueAsString(response);
|
||||
JSONObject jsonObject = JSON.parseObject(responseStr);
|
||||
|
@ -100,13 +111,15 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
result.getJSONObject(0).put("shkd_businessnumber", shkd_businessnumber);
|
||||
return new SerializerResult(MediaType.TEXT_PLAIN, jsonObject.toJSONString());
|
||||
} else {
|
||||
logger.info("进入else");
|
||||
//其他类型的出参序列化
|
||||
return null;
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.info("catch");
|
||||
//处理异常时严禁抛出异常,可以定义自己的错误返回信息
|
||||
String result="...";
|
||||
return new SerializerResult(MediaType.TEXT_PLAIN,result);
|
||||
String result = "...";
|
||||
return new SerializerResult(MediaType.TEXT_PLAIN, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue