BIP单据与获取token公用方法编写

This commit is contained in:
yuqh 2024-05-31 16:59:12 +08:00
parent aa1b93d053
commit cbbb2bdc35
1 changed files with 12 additions and 9 deletions

View File

@ -20,7 +20,7 @@ import java.util.Map;
@Service(value = "BipSsoServiceImpl")
public class BipSsoServiceImpl extends BaseService<BipTokenVo, String> implements IBipSsoService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final String BASEURL = "http://hzya.ufyct.com:9955/seeyon/thirdpartyController.do?ticket=";
private final String BASEURL = "http://192.168.2.237:8099/seeyon/thirdpartyController.do?ticket=";
private final String ESBURL = "http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface";
/**
*
@ -31,13 +31,13 @@ public class BipSsoServiceImpl extends BaseService<BipTokenVo, String> implement
*/
@Override
public String erpSso(String ticket)throws Exception {
public String erpSso(String userCode)throws Exception {
String result = "";
boolean flag = true;
logger.info("接收到致远OA认证参数的ticket{}",ticket);
// logger.info("接收到致远OA认证参数的ticket{}",ticket);
//通过ticket获取OA用户信息
// String usetCode = HttpUtil.get(BASEURL+ticket);
String userCode = "yonyou";
// String userCode = HttpUtil.get(BASEURL+ticket);
// String userCode = "yonyou";
logger.info("获取到的OA用户信息{}",userCode);
String dsname = "YonBIPV3";
String client_id = "OAREST";//第三方系统id
@ -46,7 +46,8 @@ public class BipSsoServiceImpl extends BaseService<BipTokenVo, String> implement
try {
String security = genKey(userCode,userCode + (System.currentTimeMillis() + "").substring(0, 6));
sb.append("type=type_security&dsname="+dsname+"&usercode="+userCode+"&client_id="+client_id+"&security="+security);
String baseUrl = "http://127.0.0.1:8888/service/genThirdPartyAccessToken?"+sb.toString();
String baseUrl = "http://192.168.2.85:8888/service/genThirdPartyAccessToken?"+sb.toString();
// logger.info("请求BIPtokenbaseUrl{}",baseUrl);
result = result = HttpRequest.post(baseUrl)
.header("Content-Type", "application/x-www-form-urlencoded")//头信息多个头信息多次调用此方法即可
.header("Content-Length", "10000")//头信息多个头信息多次调用此方法即可
@ -54,16 +55,18 @@ public class BipSsoServiceImpl extends BaseService<BipTokenVo, String> implement
.body("{}")//表单内容
.timeout(20000)//超时毫秒
.execute().body();
logger.info("获取到的BIPtoken信息{}",result);
// logger.info("获取到的BIPtoken信息{}",result);
} catch (HttpException e) {
flag=false;
e.printStackTrace();
}
}
if(flag){
return "http://127.0.0.1:8888nccloud/resources/uap/rbac/thirdpartylogin/main/index.html?accesstoken="+result+"&redirect_uri=http://127.0.0.1:8888nccloud/resources/workbench/public/common/main/index.html#";
String indexUR = "http://192.168.2.85:8888/nccloud/resources/uap/rbac/thirdpartylogin/main/index.html?accesstoken="+result+"&redirect_uri=http://192.168.2.85:8888/nccloud/resources/workbench/public/common/main/index.html#";
logger.info(indexUR);
return indexUR;
}else{
return "http://127.0.0.1:8888nccloud/resources/uap/rbac/login/main/index.html";
return "http://192.168.2.85:8888/nccloud/resources/uap/rbac/login/main/index.html";
}
}