Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit d0ab9566
由
LN
编写于
2023-08-08 09:36:32 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
接口
1 个父辈
d9427967
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
349 行增加
和
0 行删除
src/main/java/com/neotel/smfcore/custom/micron1053/bean/MicronResult.java
src/main/java/com/neotel/smfcore/custom/micron1053/controller/MicronApi.java
src/main/java/com/neotel/smfcore/custom/micron1053/controller/MicronConfig.java
src/main/java/com/neotel/smfcore/custom/micron1053/controller/api/bean/AMaterialBean.java
src/main/java/com/neotel/smfcore/custom/micron1053/bean/MicronResult.java
查看文件 @
d0ab956
package
com
.
neotel
.
smfcore
.
custom
.
micron1053
.
bean
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.exception.ApiException
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.Serializable
;
import
java.util.Map
;
@Data
@AllArgsConstructor
...
...
@@ -31,4 +34,51 @@ public class MicronResult implements Serializable {
return
false
;
}
public
boolean
isOk
(){
if
(
httpCode
==
200
){
return
true
;
}
return
false
;
}
private
Map
<
String
,
Object
>
resultMap
=
null
;
private
<
T
>
T
getResult
(
String
key
)
throws
ApiException
{
if
(
ObjectUtil
.
isEmpty
(
responseData
))
{
return
null
;
}
if
(
resultMap
==
null
){
resultMap
=
JsonUtil
.
toMap
(
responseData
);
}
Object
resultStatus
=
resultMap
.
get
(
"status"
);
if
(
resultStatus
!=
null
&&
!
resultStatus
.
toString
().
equalsIgnoreCase
(
"PASS"
))
{
Object
msgObj
=
resultMap
.
get
(
"message"
)
;
if
(
ObjectUtil
.
isEmpty
(
msgObj
)){
throw
new
ApiException
(
"smfcore.api.error"
,
"status="
+
resultStatus
);
}
else
{
throw
new
ApiException
(
"smfcore.api.error"
,
msgObj
.
toString
());
}
}
if
(
key
!=
null
&&
!
key
.
isEmpty
())
{
Object
value
=
resultMap
.
get
(
key
);
if
(
value
!=
null
)
{
return
(
T
)
value
;
}
else
{
try
{
char
[]
cs
=
key
.
toCharArray
();
char
c
=
cs
[
0
];
cs
[
0
]
=
Character
.
isUpperCase
(
c
)
?
Character
.
toLowerCase
(
c
)
:
Character
.
toUpperCase
(
c
);
String
newKey
=
String
.
valueOf
(
cs
);
value
=
resultMap
.
get
(
newKey
);
if
(
value
!=
null
)
{
return
(
T
)
value
;
}
}
catch
(
Exception
ex
)
{
}
}
}
return
null
;
}
}
src/main/java/com/neotel/smfcore/custom/micron1053/controller/MicronApi.java
查看文件 @
d0ab956
...
...
@@ -2,9 +2,12 @@ package com.neotel.smfcore.custom.micron1053.controller;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.utils.HttpHelper
;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
com.neotel.smfcore.core.api.listener.BaseSmfApiListener
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.custom.micron1053.bean.MaterialInfo
;
import
com.neotel.smfcore.custom.micron1053.bean.MicronResult
;
import
com.neotel.smfcore.custom.micron1053.controller.api.bean.AMaterialBean
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -35,6 +38,95 @@ public class MicronApi extends BaseSmfApiListener {
}
public
static
boolean
API001
(
String
operationId
,
Barcode
barcode
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_001
);
try
{
// Body=
// {
// "operationId": <operationId>
// "material":
// {
// "serialNum": <SerialNum>,
// "partNumber": <PartNumber>,
// "sapItem": True|False,
// "mfgPartNum": <MfgPartNum>,
// "mfgLotNum": <MfgLotNum>,
// "mfgName": <MfgName>,
// "qty": <Qty>,
// "expirationDateStr": <ExpirationDateStr>,
// "msLevel": <MsLevel>|"NA",
// "containerType": <ContainerType>,
// "arraySize": <ArraySize>|"NA",
// "panelNum": <PanelNum>,|"NA"
// }
//}
Map
<
String
,
Object
>
paramsMap
=
new
HashMap
<>();
AMaterialBean
bean
=
AMaterialBean
.
toBean
(
barcode
);
paramsMap
.
put
(
"operationId"
,
operationId
);
paramsMap
.
put
(
"material"
,
bean
.
toMap
());
String
paramStr
=
JsonUtil
.
toJsonStr
(
paramsMap
);
log
.
info
(
"调用MES接口 API001: url=["
+
url
+
"],body=["
+
paramStr
+
"]"
);
MicronResult
result
=
HttpHelper
.
postMicronJson
(
url
,
paramsMap
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
API002
(
String
operationId
,
Barcode
barcode
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_001
);
try
{
// Body=
// {
// "operationId": <operationId>
// "material":
// {
// "serialNum": <SerialNum>,
// "partNumber": <PartNumber>,
// "sapItem": True|False,
// "mfgPartNum": <MfgPartNum>,
// "mfgLotNum": <MfgLotNum>,
// "mfgName": <MfgName>,
// "qty": <Qty>,
// "expirationDateStr": <ExpirationDateStr>,
// "msLevel": <MsLevel>|"NA",
// "containerType": <ContainerType>,
// "arraySize": <ArraySize>|"NA",
// "panelNum": <PanelNum>,|"NA"
// }
//}
Map
<
String
,
Object
>
paramsMap
=
new
HashMap
<>();
AMaterialBean
bean
=
AMaterialBean
.
toBean
(
barcode
);
paramsMap
.
put
(
"operationId"
,
operationId
);
paramsMap
.
put
(
"material"
,
bean
.
toMap
());
MicronResult
result
=
HttpHelper
.
postMicronJson
(
url
,
paramsMap
);
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
private
static
String
GetSkipSap
(
String
skipSap
)
{
if
(
skipSap
.
toUpperCase
().
toString
().
equals
(
"TRUE"
)||
skipSap
.
toUpperCase
().
toString
().
equals
(
"YES"
)){
return
"YES"
;
...
...
@@ -213,4 +305,9 @@ public class MicronApi extends BaseSmfApiListener {
return
null
;
}
}
src/main/java/com/neotel/smfcore/custom/micron1053/controller/MicronConfig.java
查看文件 @
d0ab956
...
...
@@ -15,6 +15,142 @@ public class MicronConfig {
@Value
(
"${micron.addr:}"
)
public
String
micronAddr
;
/**
* 入库前验证
*Validate the material before loading into the storage bin, and indicate if the material need to go through X-Ray
*/
public
String
api_name_001
=
"material/validation/label"
;
/**
* 入库完成通知MES
*Update material storage location at rod or magazine slot level (One JobID per rod or slot) and Track In process
*/
public
String
api_name_002
=
"material/transfer-in"
;
/**
* 根据API011返回的 operationId,从MES获取出库的Pretask/linePrepOrder
*Get ready Pretask/linePrepOrder list from Auto Kitting System
*/
public
String
api_name_004
=
"operation/dispatchIds?operationId={operationId}"
;
/**
* 出库勾选一个ID(API004返回的ID)后,从MES获取出库的RI
*Get dispatch Material list from Autokitting system to fullfil the LinePrepOrder
*/
public
String
api_name_005
=
"material/lineprep/{LinePrepOrderId}"
;
/**
* 出库勾选多个ID(API004返回的ID)后,从MES获取出库的RI
*Get dispatch Material list from Autokitting system to fullfil the list of provided Ids (MCL/PCB)
*/
public
String
api_name_006
=
"material/pretasks"
;
/**
* 出库完成通知MES
*Update dispatch information by Job Level
*/
public
String
api_name_007
=
"material/transfer-out"
;
/**
* XRay点料完成之后通知MES
*Get Material update status to MAM and AKS. If status failed, material should not move out of Xray station and retry at the KTS is needed.
*/
public
String
api_name_008
=
"material/xray/{serialNum}/{qty}"
;
/**
* 出库勾选物料后,发送唯一码到mes进行验证
*Get material reserved information from AKS, so that KTS only select unreserved material for Adhoc dispatch.
*/
public
String
api_name_009
=
"material/status"
;
/**
* 从mes库存中扣除物料
* Track out the material in micron system successfully, before the material can be dispatch out of the tower.
*/
public
String
api_name_010
=
"material/track-out"
;
/**
* 获取OperationID ,Get operationId for Loading or Dispatching of material
*/
public
String
api_name_011
=
"operation?mode={Mode}&username={Username}&source={Source}"
;
@Value
(
"${micron.api_name_001:}"
)
public
void
setApi_name_001
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_001
=
api_config
;
}
@Value
(
"${micron.api_name_002:}"
)
public
void
setApi_name_002
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_002
=
api_config
;
}
@Value
(
"${micron.api_name_004:}"
)
public
void
setApi_name_004
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_004
=
api_config
;
}
@Value
(
"${micron.api_name_005:}"
)
public
void
setApi_name_005
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_005
=
api_config
;
}
@Value
(
"${micron.api_name_006:}"
)
public
void
setApi_name_006
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_006
=
api_config
;
}
@Value
(
"${micron.api_name_007:}"
)
public
void
setApi_name_007
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_007
=
api_config
;
}
@Value
(
"${micron.api_name_008:}"
)
public
void
setApi_name_008
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_008
=
api_config
;
}
@Value
(
"${micron.api_name_009:}"
)
public
void
setApi_name_009
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_009
=
api_config
;
}
@Value
(
"${micron.api_name_010:}"
)
public
void
setApi_name_010
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_010
=
api_config
;
}
@Value
(
"${micron.api_name_011:}"
)
public
void
setApi_name_011
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
return
;
}
api_name_011
=
api_config
;
}
@Autowired
private
DataCache
dataCache
;
...
...
src/main/java/com/neotel/smfcore/custom/micron1053/controller/api/bean/AMaterialBean.java
0 → 100644
查看文件 @
d0ab956
package
com
.
neotel
.
smfcore
.
custom
.
micron1053
.
controller
.
api
.
bean
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.custom.micron1053.util.MicronDataCache
;
import
lombok.Data
;
import
java.util.HashMap
;
import
java.util.Map
;
@Data
public
class
AMaterialBean
{
private
String
serialNum
;
private
String
partNumber
;
private
boolean
sapItem
=
true
;
private
String
mfgPartNum
;
private
String
mfgLotNum
;
private
String
mfgName
;
private
Integer
qty
;
private
String
expirationDateStr
;
private
String
msLevel
;
private
String
containerType
;
private
String
arraySize
;
private
String
panelNum
;
public
static
AMaterialBean
toBean
(
Barcode
barcode
){
AMaterialBean
bean
=
new
AMaterialBean
();
bean
.
serialNum
=
barcode
.
getBarcode
();
bean
.
partNumber
=
barcode
.
getPartNumber
();
bean
.
sapItem
=
true
;
bean
.
mfgPartNum
=
barcode
.
getMpn
();
bean
.
mfgLotNum
=
barcode
.
getBatch
();
bean
.
mfgName
=
barcode
.
getProvider
();
bean
.
qty
=
barcode
.
getAmount
();
bean
.
expirationDateStr
=
barcode
.
getExpireDateStr
();
bean
.
msLevel
=
barcode
.
getMsl
();
String
reelType
=
MicronDataCache
.
GetReelType
(
barcode
.
getPlateSize
(),
barcode
.
getHeight
());
bean
.
containerType
=
reelType
;
//类型
bean
.
arraySize
=
barcode
.
getQ1Item
();
//1Q
bean
.
panelNum
=
barcode
.
getQItem
();
//Q
return
bean
;
}
public
Map
<
String
,
Object
>
toMap
(){
Map
<
String
,
Object
>
resultMap
=
new
HashMap
<>();
resultMap
.
put
(
"serialNum"
,
serialNum
);
resultMap
.
put
(
"partNumber"
,
panelNum
);
resultMap
.
put
(
"sapItem"
,
sapItem
);
resultMap
.
put
(
"mfgPartNum"
,
mfgPartNum
);
resultMap
.
put
(
"mfgLotNum"
,
mfgLotNum
);
resultMap
.
put
(
"mfgName"
,
mfgName
);
resultMap
.
put
(
"qty"
,
qty
);
resultMap
.
put
(
"expirationDateStr"
,
expirationDateStr
);
resultMap
.
put
(
"msLevel"
,
msLevel
);
resultMap
.
put
(
"containerType"
,
containerType
);
//类型
resultMap
.
put
(
"arraySize"
,
arraySize
);
//1Q
resultMap
.
put
(
"panelNum"
,
panelNum
);
//Q
return
resultMap
;
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论