Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit edd8a5ff
由
LN
编写于
2023-06-22 16:39:42 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加接口地址配置
1 个父辈
cd8a0ac9
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
207 行增加
和
23 行删除
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
src/main/java/com/neotel/smfcore/core/api/SmfApi.java
src/main/java/com/neotel/smfcore/custom/micron20031/Micron20031Api.java
src/main/java/com/neotel/smfcore/custom/micron20031/MicronSpApiListener.java
src/main/java/com/neotel/smfcore/custom/micron20031/MicronSpLoadController.java
src/main/java/com/neotel/smfcore/common/utils/HttpHelper.java
查看文件 @
edd8a5f
...
...
@@ -144,7 +144,10 @@ public class HttpHelper {
if
(
params
==
null
||
params
.
isEmpty
())
{
params
=
null
;
}
return
postJsonWithAuth
(
url
,
params
,
null
);
String
result
=
postJsonWithAuth
(
url
,
params
,
null
);
log
.
info
(
" postJson url=["
+
url
+
"],return=["
+
result
+
"]"
);
return
result
;
}
public
static
String
postJsonWithAuth
(
String
url
,
Object
params
,
String
auth
)
throws
ApiException
{
...
...
@@ -172,6 +175,8 @@ public class HttpHelper {
String
responseContent
=
EntityUtils
.
toString
(
entity
,
CONTENT_CHARSET
);
response
.
close
();
httpClient
.
close
();
log
.
info
(
"postJsonWithAuth url=["
+
url
+
"] return= ["
+
responseContent
+
"]"
);
return
responseContent
;
}
catch
(
Exception
e
)
{
throw
new
ApiException
(
"Request to ["
+
url
+
"] failed:"
+
e
.
getMessage
());
...
...
src/main/java/com/neotel/smfcore/core/api/SmfApi.java
查看文件 @
edd8a5f
...
...
@@ -225,7 +225,7 @@ public class SmfApi {
return
null
;
}
public
boolean
canLogin
(
String
username
,
String
pwd
)
throws
ValidateException
{
if
(
ObjectUtil
.
isNotEmpty
(
username
)
&&
ObjectUtil
.
isNotEmpty
(
pwd
)
)
{
if
(
ObjectUtil
.
isNotEmpty
(
username
)
)
{
if
(
isUrlExist
(
loginCheckUrl
))
{
for
(
ISmfApiListener
apiListener
:
apiListenerList
)
{
...
...
src/main/java/com/neotel/smfcore/custom/micron20031/Micron20031Api.java
查看文件 @
edd8a5f
...
...
@@ -2,6 +2,7 @@ package com.neotel.smfcore.custom.micron20031;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.exception.ApiException
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.DateUtil
;
import
com.neotel.smfcore.common.utils.HttpHelper
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
...
...
@@ -21,6 +22,7 @@ import java.util.*;
@Slf4j
@Service
public
class
Micron20031Api
{
// https://testapigtwy.micron.com/t/app.mfg/mmsil/v1/DEVL/SINGAPORE/CheckUserRights
public
static
String
MODE_DISABLE_SAP
=
"DISABLE_SAP"
;
public
static
String
MODE_DISABLE_MAM
=
"DISABLE_MAM"
;
public
static
String
MODE_DISABLE_MAM_AND_SAP
=
"DISABLE_MAM_AND_SAP"
;
...
...
@@ -33,6 +35,116 @@ 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
api_CheckUserRights
=
"CheckUserRights"
;
private
static
String
api_CheckStockAvailable
=
"CheckStockAvailable"
;
private
static
String
api_TriggerMatReqOrder
=
"TriggerMatReqOrder"
;
private
static
String
api_GetMatReqDetail
=
"GetMatReqDetail"
;
private
static
String
api_DepositCreateMA
=
"DepositCreateMA"
;
private
static
String
api_SendEmail
=
"SendEmail"
;
private
static
String
api_MATrackOut
=
"MATrackOut"
;
private
static
String
api_GetEquipIDList
=
"GetEquipIDList"
;
private
static
String
api_GetMicronPN
=
"GetMicronPN"
;
private
static
String
api_ChkAuthoriseToDispatch
=
"ChkAuthoriseToDispatch"
;
private
static
String
api_ReturnMaterial
=
"ReturnMaterial"
;
@Value
(
"${micron.api_CheckUserRights:}"
)
public
void
setApi_CheckUserRights
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_CheckUserRights
=
api_config
;
}
@Value
(
"${micron.api_CheckStockAvailable:}"
)
public
void
setApi_CheckStockAvailable
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_CheckStockAvailable
=
api_config
;
}
@Value
(
"${micron.api_TriggerMatReqOrder:}"
)
public
void
setApi_TriggerMatReqOrder
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_TriggerMatReqOrder
=
api_config
;
}
@Value
(
"${micron.api_GetMatReqDetail:}"
)
public
void
setApi_GetMatReqDetail
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_GetMatReqDetail
=
api_config
;
}
@Value
(
"${micron.api_DepositCreateMA:}"
)
public
void
setApi_DepositCreateMA
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_DepositCreateMA
=
api_config
;
}
@Value
(
"${micron.api_SendEmail:}"
)
public
void
setApi_SendEmail
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_SendEmail
=
api_config
;
}
@Value
(
"${micron.api_MATrackOut:}"
)
public
void
setApi_MATrackOut
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_MATrackOut
=
api_config
;
}
@Value
(
"${micron.api_GetEquipIDList:}"
)
public
void
setApi_GetEquipIDList
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_GetEquipIDList
=
api_config
;
}
@Value
(
"${micron.api_GetMicronPN:}"
)
public
void
setApi_GetMicronPN
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_GetMicronPN
=
api_config
;
}
@Value
(
"${micron.email.api_ChkAuthoriseToDispatch:}"
)
public
void
setApi_ChkAuthoriseToDispatch
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_ChkAuthoriseToDispatch
=
api_config
;
}
@Value
(
"${micron.email.api_ReturnMaterial:}"
)
public
void
setApi_ReturnMaterial
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
Micron20031Api
.
api_ReturnMaterial
=
api_config
;
}
@Value
(
"${micron.email.to:}"
)
public
void
setEmaillTo
(
String
to
)
{
Micron20031Api
.
Email_TO
=
to
;
...
...
@@ -44,8 +156,16 @@ public class Micron20031Api {
@Value
(
"${micron.apiAddr:}"
)
public
void
setApiaddr
(
String
apiAddr
)
{
Micron20031Api
.
apiAddr
=
apiAddr
;
}
@Value
(
"${micron.getTokenUrl:}"
)
public
void
seturl_GetToken
(
String
url_getToken
)
{
Micron20031Api
.
url_getToken
=
url_getToken
;
}
private
static
String
AUTH_TOKEN
=
""
;
private
static
String
MATERIAL_TYPE
=
"SOLDER_PASTE"
;
...
...
@@ -57,9 +177,25 @@ public class Micron20031Api {
return
true
;
}
public
static
String
getUrl
(
String
methodName
){
if
(
isEnable
()){
//如果配置是完整的地址,不需要拼接
if
(
methodName
.
startsWith
(
"http"
)){
return
methodName
;
}
return
apiAddr
+
methodName
;
}
return
""
;
}
public
static
String
getAuthToken
(){
String
url
=
"https://boapi3testgtwy.micron.com/token"
;
if
(
ObjectUtil
.
isNotEmpty
(
url_getToken
)){
url
=
url_getToken
;
}
try
{
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"grant_type"
,
"client_credentials"
);
...
...
@@ -93,15 +229,27 @@ public class Micron20031Api {
* //Output: Username, Role, MaterialType, Message, Status
* @param username
*/
public
static
void
checkUserRights
(
String
username
)
throws
ApiException
{
String
checkUserRightsUrl
=
""
;
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"Username"
,
username
);
dataMap
.
put
(
"MaterialType"
,
"SOLDER_PASTE"
);
log
.
info
(
"调用MES接口 checkUserRights,参数:"
+
JsonUtil
.
toJsonStr
(
dataMap
));
public
static
boolean
checkUserRights
(
String
username
)
throws
ApiException
{
String
checkUserRightsUrl
=
getUrl
(
api_CheckUserRights
)
;
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"Username"
,
username
);
dataMap
.
put
(
"MaterialType"
,
"SOLDER_PASTE"
);
log
.
info
(
"调用MES接口 checkUserRights,参数:"
+
JsonUtil
.
toJsonStr
(
dataMap
));
String
resultStr
=
HttpHelper
.
postJson
(
checkUserRightsUrl
,
dataMap
);
//如果包含userName
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
resultStr
);
if
(
map
.
containsKey
(
"Username"
))
{
return
true
;
}
log
.
info
(
"调用MES接口 checkUserRights 返回:"
+
resultStr
);
getResult
(
resultStr
,
""
);
String
returnData
=
getResult
(
resultStr
,
"Username"
);
if
(
ObjectUtil
.
isNotEmpty
(
returnData
))
{
return
true
;
}
else
{
throw
new
ValidateException
(
"smfcore.mesApi.loginCheck.ng"
,
"NG: "
+
resultStr
);
}
}
/**
...
...
@@ -126,7 +274,7 @@ public class Micron20031Api {
*/
public
static
List
<
MatOrderBean
>
checkStockAvailable
(
Map
<
String
,
Integer
>
pnMap
)
throws
ApiException
{
//pnMap的key为pn, value为库存数量
String
checkStockAvailableUrl
=
""
;
String
checkStockAvailableUrl
=
getUrl
(
api_CheckStockAvailable
)
;
String
auth
=
getAuthToken
();
List
<
Map
<
String
,
String
>>
paramList
=
new
ArrayList
<>();
for
(
String
pn
:
pnMap
.
keySet
())
{
...
...
@@ -161,7 +309,7 @@ public class Micron20031Api {
*/
public
static
MatOrderBean
triggerMatReqOrder
(
MatOrderBean
orderBean
)
throws
ApiException
{
//pnMap的key为pn, value为库存数量
String
checkStockAvailableUrl
=
""
;
String
checkStockAvailableUrl
=
getUrl
(
api_TriggerMatReqOrder
)
;
String
auth
=
getAuthToken
();
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"MicronPN"
,
orderBean
.
getMicronPN
());
...
...
@@ -189,7 +337,7 @@ public class Micron20031Api {
*/
public
static
List
<
DepositMatReqBean
>
getMatReqDetail
(
String
matReqNo
)
throws
ApiException
{
//pnMap的key为pn, value为库存数量
String
getMatReqDetailUrl
=
""
;
String
getMatReqDetailUrl
=
getUrl
(
api_GetMatReqDetail
);
;
String
auth
=
getAuthToken
();
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"MatReqNo"
,
matReqNo
);
...
...
@@ -223,7 +371,7 @@ public class Micron20031Api {
*/
public
static
Barcode
depositCreateMA
(
Barcode
barcode
,
String
username
)
throws
ApiException
{
//pnMap的key为pn, value为库存数量
String
depositCreateMAUrl
=
""
;
String
depositCreateMAUrl
=
getUrl
(
api_DepositCreateMA
)
;
String
auth
=
getAuthToken
();
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
dataMap
.
put
(
"MicronPN"
,
barcode
.
getPartNumber
());
...
...
@@ -269,7 +417,7 @@ public class Micron20031Api {
* //Output: To, From, CC, BCC, Subject, Text, Status, Message
*/
public
static
void
sendEmail
(
String
to
,
String
cc
,
String
subject
,
String
conent
){
String
url
=
""
;
String
url
=
getUrl
(
api_SendEmail
)
;
String
auth
=
getAuthToken
();
try
{
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
...
...
@@ -301,7 +449,7 @@ public class Micron20031Api {
* //Output: Lot No, Username, SystemID, MaterialType, Message, Status
*/
public
static
void
mATrackOut
(
Barcode
barcode
){
String
url
=
""
;
String
url
=
getUrl
(
api_MATrackOut
)
;
String
auth
=
getAuthToken
();
try
{
Map
<
String
,
Object
>
dataMap
=
new
HashMap
<>();
...
...
@@ -374,7 +522,7 @@ public class Micron20031Api {
*/
public
static
List
<
String
>
getEquipIDList
()
throws
ApiException
{
List
<
String
>
equipIdList
=
new
ArrayList
<>();
String
checkStockAvailableUrl
=
""
;
String
checkStockAvailableUrl
=
getUrl
(
api_GetEquipIDList
)
;
if
(
ObjectUtil
.
isEmpty
(
checkStockAvailableUrl
))
{
List
<
String
>
result
=
new
ArrayList
<
String
>();
result
.
add
(
"test1"
);
...
...
@@ -411,7 +559,7 @@ public class Micron20031Api {
* //Output: Equip ID, Micron LotID, Micron Part Number, Status, MaterialType
*/
public
static
String
getMicronPN
(
String
micronLotId
,
String
equipId
)
throws
ApiException
{
String
checkStockAvailableUrl
=
""
;
String
checkStockAvailableUrl
=
getUrl
(
api_GetMicronPN
)
;
if
(
ObjectUtil
.
isEmpty
(
checkStockAvailableUrl
)){
return
"2K.K2275.010"
;
}
...
...
@@ -443,7 +591,7 @@ public class Micron20031Api {
* //Output: MicronPN, LotNo, BatchNo, SpoolStatus, Quantity, Username, Mode, MaterialType, MaterialDocumentNo, Message, Status
*/
public
static
void
chkAuthoriseToDispatch
(
Barcode
barcode
,
String
mode
,
String
username
)
throws
ApiException
{
String
checkStockAvailableUrl
=
""
;
String
checkStockAvailableUrl
=
getUrl
(
api_ChkAuthoriseToDispatch
)
;
if
(
ObjectUtil
.
isEmpty
(
checkStockAvailableUrl
)){
return
;
}
...
...
@@ -467,6 +615,9 @@ public class Micron20031Api {
private
static
<
T
>
T
getResult
(
String
resultJson
,
String
key
)
throws
ApiException
{
if
(
ObjectUtil
.
isEmpty
(
resultJson
)){
return
null
;
}
Map
<
String
,
Object
>
resultMap
=
JsonUtil
.
toMap
(
resultJson
);
Object
resultStatus
=
resultMap
.
get
(
"Status"
);
if
(
resultStatus
!=
null
&&
!
resultStatus
.
toString
().
equalsIgnoreCase
(
"PASS"
)){
...
...
@@ -500,7 +651,7 @@ public class Micron20031Api {
* //Output: TypeofReturn, MicronPN, LotNo, BatchNo, Location, RemainingQuantity, Mode, Username, SystemId, MaterialType, Message, Status, ExpiredDate
*/
public
static
Barcode
returnMaterial
(
Barcode
barcode
,
String
typeOfReturn
,
String
username
)
throws
ApiException
{
String
checkStockAvailableUrl
=
""
;
String
checkStockAvailableUrl
=
getUrl
(
api_ReturnMaterial
)
;
if
(
ObjectUtil
.
isEmpty
(
checkStockAvailableUrl
)){
return
barcode
;
}
...
...
src/main/java/com/neotel/smfcore/custom/micron20031/MicronSpApiListener.java
查看文件 @
edd8a5f
...
...
@@ -12,8 +12,9 @@ import com.neotel.smfcore.core.inList.util.InListCache;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.swing.text.html.InlineView
;
@Service
@Slf4j
public
class
MicronSpApiListener
extends
BaseSmfApiListener
{
...
...
@@ -21,7 +22,11 @@ public class MicronSpApiListener extends BaseSmfApiListener {
private
InListCache
inListCache
;
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
return
Micron20031Api
.
isEnable
();
if
(
Micron20031Api
.
isEnable
())
{
return
true
;
}
// return apiName != null && apiName.equalsIgnoreCase("20031");
return
false
;
}
@Override
public
Barcode
canPutInAfterResolve
(
String
inCheckUrl
,
CodeValidateParam
params
,
Barcode
barcode
)
throws
ValidateException
{
...
...
@@ -58,4 +63,19 @@ public class MicronSpApiListener extends BaseSmfApiListener {
}
return
null
;
}
@Override
public
boolean
canLogin
(
String
loginCheckUrl
,
String
userName
,
String
pwd
)
throws
ValidateException
{
try
{
return
Micron20031Api
.
checkUserRights
(
userName
);
}
catch
(
ValidateException
e
){
throw
e
;
}
catch
(
Exception
e
)
{
log
.
error
(
"登陆验证接口出错:"
+
e
.
getMessage
());
throw
new
ValidateException
(
"smfcore.mesApi.loginCheck.error"
,
"MES Login Error:"
+
e
.
getMessage
());
}
}
}
src/main/java/com/neotel/smfcore/custom/micron20031/MicronSpLoadController.java
查看文件 @
edd8a5f
...
...
@@ -13,6 +13,7 @@ import com.neotel.smfcore.core.inList.util.InListCache;
import
com.neotel.smfcore.core.storage.enums.DeviceType
;
import
com.neotel.smfcore.core.storage.service.manager.IStorageManager
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.custom.micron20031.bean.DepositMatReqBean
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -105,9 +106,12 @@ public class MicronSpLoadController {
inListCache
.
addInListToMap
(
inList
);
storage
.
setInListName
(
matReqNo
);
log
.
info
(
"设置料仓["
+
storage
.
getName
()
+
"]的入库单为:["
+
matReqNo
+
"],同时更新入库单开始时间"
);
log
.
info
(
"设置料仓["
+
storage
.
getName
()
+
"]的入库单为:["
+
matReqNo
+
"],同时更新入库单开始时间
,同时发送 closeInLock=doit
"
);
storageManager
.
save
(
storage
);
dataCache
.
reloadStorage
(
storage
,
""
);
//设置开始入库
DevicesStatusUtil
.
appendOp
(
storage
.
getCid
(),
"closeInLock"
,
"doit"
);
return
ResultBean
.
newOkResult
(
matReqNo
);
}
...
...
@@ -122,9 +126,13 @@ public class MicronSpLoadController {
return
ResultBean
.
newErrorResult
(-
1
,
"smfcore.micron.operationFailure"
,
"操作失败"
);
}
storage
.
setInListName
(
""
);
log
.
info
(
"设置料仓["
+
storage
.
getName
()
+
"]开始 return "
);
log
.
info
(
"设置料仓["
+
storage
.
getName
()
+
"]开始 return
,同时发送 closeInLock=doit
"
);
storageManager
.
save
(
storage
);
dataCache
.
reloadStorage
(
storage
,
""
);
//设置开始入库
DevicesStatusUtil
.
appendOp
(
storage
.
getCid
(),
"closeInLock"
,
"doit"
);
return
ResultBean
.
newOkResult
(
""
);
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论