Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 3785f772
由
zshaohui
编写于
2023-08-02 15:54:11 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1.getToken接口修改
2.url地址修改
1 个父辈
773da1ec
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
21 行增加
和
23 行删除
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
src/main/java/com/neotel/smfcore/custom/micron20031/Micron20031Api.java
src/main/resources/config/application.yml
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
查看文件 @
3785f77
...
@@ -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
);
}
}
...
...
src/main/java/com/neotel/smfcore/custom/micron20031/Micron20031Api.java
查看文件 @
3785f77
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://
boapi3test
gtwy.micron.com/token"
;
private
static
String
url_getToken
=
"https://
devapi
gtwy.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
)
{
...
...
src/main/resources/config/application.yml
查看文件 @
3785f77
...
@@ -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://boapi3test
gtwy.micron.com/token
getTokenUrl
:
https://devapi
gtwy.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!
Cancel
请
注册
或
登录
后发表评论