Commit 3785f772 zshaohui

1.getToken接口修改

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