Commit 3785f772 zshaohui

1.getToken接口修改

2.url地址修改
1 个父辈 773da1ec
......@@ -157,9 +157,13 @@ public class HttpHelper {
}
public static String postJsonWithAuth(String url, Object params, String auth) throws ApiException {
return postJsonWithAuth(url,params,auth,"application/json;charset=utf-8");
}
public static String postJsonWithAuth(String url, Object params, String auth,String contentType) throws ApiException {
HttpPost httpPost = new HttpPost(url);
httpPost.addHeader("Content-Type", "application/json;charset=utf-8");
httpPost.addHeader("Content-Type", contentType);
if (auth != null && !auth.isEmpty()) {
httpPost.addHeader("Authorization", auth);
}
......
package com.neotel.smfcore.custom.micron20031;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.neotel.smfcore.common.exception.ApiException;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.DateUtil;
......@@ -35,7 +36,7 @@ public class Micron20031Api {
public static String Email_CC="";
private static String apiAddr = "";
private static String url_getToken="https://boapi3testgtwy.micron.com/token";
private static String url_getToken="https://devapigtwy.micron.com/token";
private static String api_CheckUserRights="CheckUserRights";
private static String api_CheckStockAvailable="CheckStockAvailable";
private static String api_TriggerMatReqOrder="TriggerMatReqOrder";
......@@ -200,30 +201,23 @@ public class Micron20031Api {
}
public static String getAuthToken(){
String url = "https://boapi3testgtwy.micron.com/token";
url=url_getToken;
if(ObjectUtil.isEmpty(url_getToken)){
public static String getAuthToken() {
if (ObjectUtil.isEmpty(url_getToken)) {
//直接返回默认的token
return api_AUTH_TOKEN;
// url=url_getToken;
return "";
}
try {
Map<String,Object> dataMap = new HashMap<>();
dataMap.put("grant_type","client_credentials");
String resultStr = HttpHelper.postFormParam(url, dataMap);
final String auth = "Basic c0E1UENNdHhJTFAwZ0VFb1ZyUGFkMnhHTmZNYTp1WmRuSWYxVW1kOG9uNUpHa3NRclZ4RDdtWklh";
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("grant_type", "client_credentials");
String resultStr = HttpHelper.postJsonWithAuth(url_getToken, dataMap, auth, "application/x-www-form-urlencoded");
log.info("get token from MES 返回:" + resultStr);
Map<String, Object> resultMap = JsonUtil.toMap(resultStr);
Object username1 = resultMap.get("Username");
Object Role = resultMap.get("Role");
Object MaterialType = resultMap.get("MaterialType");
Object Message = resultMap.get("Message");
Object Status = resultMap.get("Status");
api_AUTH_TOKEN="Bearer 0f1a4408-7235-3f01-b671-f71491dc6bfa";
// AUTH_TOKEN = "Bearer 03400c52-9b1d-3e10-b40c-a95fbfdcec67";
JSONObject object = JSONObject.parseObject(resultStr);
api_AUTH_TOKEN = object.getString("token_type") + " " + object.getString("access_token");
return api_AUTH_TOKEN;
} catch (ApiException e) {
......
......@@ -2,7 +2,7 @@ server:
port: 8800
micron:
apiAddr: https://testapigtwy.micron.com/t/app.mfg/mmsil/v1/DEVL/SINGAPORE/
apiAddr: https://devapigtwy.micron.com/t/app.mfg/MMSIL/v1/DEVL/SINGAPORE/
api_CheckUserRights: CheckUserRights
api_CheckStockAvailable: CheckStockAvailable
api_TriggerMatReqOrder: TriggerMatReqOrder
......@@ -15,7 +15,7 @@ micron:
api_ChkAuthoriseToDispatch: ChkAuthoriseToDispatch
api_ReturnMaterial: ReturnMaterial
defToken: Bearer 0f1a4408-7235-3f01-b671-f71491dc6bfa
# getTokenUrl: https://boapi3testgtwy.micron.com/token
getTokenUrl: https://devapigtwy.micron.com/token
email:
to:
cc:
......@@ -37,7 +37,7 @@ micron:
api:
name: 20031
inCheckUrl: https://testapigtwy.micron.com/t/app.mfg/mmsil/v1/DEVL/SINGAPORE/ReturnMaterial
inCheckUrl: https://devapigtwy.micron.com/t/app.mfg/MMSIL/v1/DEVL/SINGAPORE/ReturnMaterial
# loginCheckUrl: https://testapigtwy.micron.com/t/app.mfg/mmsil/v1/DEVL/SINGAPORE/CheckUserRights
# 文件存储路径
file:
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!