Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 071d6624
由
zshaohui
编写于
2023-08-08 11:28:10 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
镁光新增接口提交
1 个父辈
ddb82a18
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
320 行增加
和
0 行删除
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/MicronApi.java
查看文件 @
071d662
package
com
.
neotel
.
smfcore
.
custom
.
micron1053
.
controller
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.exception.ApiException
;
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.core.device.util.DataCache
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
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
;
...
...
@@ -15,6 +19,7 @@ import org.springframework.stereotype.Controller;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -30,6 +35,13 @@ public class MicronApi extends BaseSmfApiListener {
MicronApi
.
config
=
config
;
}
public
static
DataCache
dataCache
;
@Autowired
public
void
setDataCache
(
DataCache
cache
)
{
MicronApi
.
dataCache
=
cache
;
}
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
...
...
@@ -119,13 +131,252 @@ public class MicronApi extends BaseSmfApiListener {
}
public
static
boolean
Api004
(
String
operationId
){
String
url
=
config
.
getUrl
(
config
.
api_name_004
);
url
=
MessageFormat
.
format
(
url
,
operationId
);
try
{
log
.
info
(
"调用MES接口 API004: url=["
+
url
+
"]"
);
MicronResult
result
=
HttpHelper
.
getMicronJson
(
url
);
}
catch
(
Exception
e
){
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api005
(
String
linePrepOrderId
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_005
);
url
=
MessageFormat
.
format
(
url
,
linePrepOrderId
);
try
{
log
.
info
(
"调用MES接口 API005: url=["
+
url
+
"]"
);
MicronResult
result
=
HttpHelper
.
getMicronJson
(
url
);
}
catch
(
Exception
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api006
(
String
operationId
,
List
<
String
>
pretasks
)
{
/**
* {
* "operationId": <operationId>
* "pretasks":
* [
* <MCL|PCB-PreTaskId-1>,
* <MCL|PCB-PreTaskId-2>,
* <MCL|PCB-PreTaskId-4>
* ]
* }
*/
String
url
=
config
.
getUrl
(
config
.
api_name_006
);
try
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"operationId"
,
operationId
);
paramMap
.
put
(
"pretasks"
,
pretasks
);
String
paramStr
=
JsonUtil
.
toJsonStr
(
paramMap
);
log
.
info
(
"调用MES接口 API006: url=["
+
url
+
"],body=["
+
paramStr
+
"]"
);
MicronResult
micronResult
=
HttpHelper
.
postMicronJson
(
url
,
paramMap
);
}
catch
(
Exception
e
){
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api007
(
String
operationId
,
String
jobId
,
List
<
StoragePos
>
storagePosList
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_007
);
try
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"jobId"
,
jobId
);
paramMap
.
put
(
"operationId"
,
operationId
);
List
<
Map
<
String
,
Object
>>
materialList
=
new
ArrayList
<>();
for
(
StoragePos
storagePos
:
storagePosList
)
{
Map
<
String
,
Object
>
materialsMap
=
new
HashMap
<>();
materialsMap
.
put
(
"location"
,
storagePos
.
getPosName
());
materialsMap
.
put
(
"towerId"
,
storagePos
.
getStorageId
());
materialsMap
.
put
(
"materialStatus"
,
"Available"
);
materialsMap
.
put
(
"material"
,
AMaterialBean
.
toBean
(
storagePos
.
getBarcode
()).
toMap
());
materialList
.
add
(
materialsMap
);
}
paramMap
.
put
(
"dispatchedMaterials"
,
materialList
);
String
paramStr
=
JsonUtil
.
toJsonStr
(
paramMap
);
log
.
info
(
"调用MES接口 API007: url=["
+
url
+
"],body=["
+
paramStr
+
"]"
);
MicronResult
micronResult
=
HttpHelper
.
postMicronJson
(
url
,
paramMap
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api008
(
String
serialNum
,
int
qty
,
int
newQty
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_008
);
url
=
MessageFormat
.
format
(
url
,
serialNum
,
qty
);
try
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"serialNum"
,
serialNum
);
paramMap
.
put
(
"newQty"
,
newQty
);
String
paramStr
=
JsonUtil
.
toJsonStr
(
paramMap
);
log
.
info
(
"调用MES接口 API008: url=["
+
url
+
"],body=["
+
paramStr
+
"]"
);
MicronResult
micronResult
=
HttpHelper
.
postMicronJson
(
url
,
paramMap
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api009
(
List
<
Barcode
>
barcodeList
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_009
);
try
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
List
<
Map
<
String
,
Object
>>
materialList
=
new
ArrayList
<>();
for
(
Barcode
barcode
:
barcodeList
)
{
Map
<
String
,
Object
>
materialMap
=
new
HashMap
<>();
materialMap
.
put
(
"serialNum"
,
barcode
.
getBarcode
());
materialMap
.
put
(
"partNumber"
,
barcode
.
getPartNumber
());
materialList
.
add
(
materialMap
);
}
paramMap
.
put
(
"materials"
,
materialList
);
String
paramStr
=
JsonUtil
.
toJsonStr
(
paramMap
);
log
.
info
(
"调用MES接口 API009: url=["
+
url
+
"],body=["
+
paramStr
+
"]"
);
MicronResult
micronResult
=
HttpHelper
.
postMicronJson
(
url
,
paramMap
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api010
(
String
operationId
,
List
<
Barcode
>
barcodeList
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_010
);
try
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"operationId"
,
operationId
);
List
<
Map
<
String
,
Object
>>
materialList
=
new
ArrayList
<>();
for
(
Barcode
barcode
:
barcodeList
)
{
Map
<
String
,
Object
>
materialMap
=
new
HashMap
<>();
materialMap
.
put
(
"serialNum"
,
barcode
.
getBarcode
());
materialMap
.
put
(
"partNumber"
,
barcode
.
getPartNumber
());
materialList
.
add
(
materialMap
);
}
paramMap
.
put
(
"materials"
,
materialList
);
String
paramStr
=
JsonUtil
.
toJsonStr
(
paramMap
);
log
.
info
(
"调用MES接口 API010: url=["
+
url
+
"],body=["
+
paramStr
+
"]"
);
MicronResult
micronResult
=
HttpHelper
.
postMicronJson
(
url
,
paramMap
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api011
(
String
mode
,
String
userName
,
String
source
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_011
);
url
=
url
+
"?mode="
+
mode
+
"&=username="
+
userName
+
"&source="
+
source
;
try
{
MicronResult
result
=
HttpHelper
.
getMicronJson
(
url
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api101
(
String
id
,
String
operationId
,
String
skipSap
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_101
);
url
=
MessageFormat
.
format
(
url
,
id
,
operationId
,
skipSap
);
try
{
MicronResult
result
=
HttpHelper
.
getMicronJson
(
url
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api102
(
String
id
,
String
operationId
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_102
);
url
=
MessageFormat
.
format
(
url
,
id
,
operationId
);
try
{
MicronResult
result
=
HttpHelper
.
getMicronJson
(
url
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api103
(
String
purchaseOrder
,
String
packagingSlip
,
String
operationId
,
String
skipSap
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_103
);
url
=
MessageFormat
.
format
(
url
,
purchaseOrder
,
packagingSlip
,
operationId
,
skipSap
);
try
{
MicronResult
result
=
HttpHelper
.
getMicronJson
(
url
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api201
(
String
linePrepOrderId
,
String
operationId
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_201
);
url
=
MessageFormat
.
format
(
url
,
linePrepOrderId
,
operationId
);
try
{
MicronResult
result
=
HttpHelper
.
postMicronJson
(
url
,
null
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
public
static
boolean
Api202
(
String
badgeId
)
{
String
url
=
config
.
getUrl
(
config
.
api_name_202
);
url
=
MessageFormat
.
format
(
url
,
badgeId
);
try
{
MicronResult
result
=
HttpHelper
.
getMicronJson
(
url
);
return
true
;
}
catch
(
ApiException
e
)
{
log
.
error
(
url
+
"出错"
,
e
);
}
return
false
;
}
private
static
String
GetSkipSap
(
String
skipSap
)
{
if
(
skipSap
.
toUpperCase
().
toString
().
equals
(
"TRUE"
)||
skipSap
.
toUpperCase
().
toString
().
equals
(
"YES"
)){
...
...
src/main/java/com/neotel/smfcore/custom/micron1053/controller/MicronConfig.java
查看文件 @
071d662
...
...
@@ -65,6 +65,32 @@ public class MicronConfig {
* 获取OperationID ,Get operationId for Loading or Dispatching of material
*/
public
String
api_name_011
=
"operation?mode={Mode}&username={Username}&source={Source}"
;
/**
* Validate if MBR (From Warehouse ) is valid
*/
public
String
api_name_101
=
"operation/validation/mbr?id={Id}&operationId={operationId}&skipSap={SkipSap}"
;
/**
* Validate if REQ (From Outside Shelf) is valid
*/
public
String
api_name_102
=
"operation/validation/req?id={Id}&operationId={operationId}"
;
/**
* Validate if MCL GR is valid
*/
public
String
api_name_103
=
"operation/validation/gr?purchaseOrder={PurchaseOrder}&packagingSlip={PackagingSlip}&operationId={operationId}&skipSap={SkipSap}"
;
/**
* Add material(s) to reservation for the LinePrep specified, so that it can charged the material to the correct PO upon transferOut event
*/
public
String
api_name_201
=
"operation/validate/ctrldispatch?linePrepOrderId={linePrepOrderId}&operationId={operationId}"
;
/**
* Get the emp ID/username and access level
*/
public
String
api_name_202
=
"user/{badgeId}"
;
@Value
(
"${micron.api_name_001:}"
)
public
void
setApi_name_001
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
)){
...
...
@@ -151,6 +177,49 @@ public class MicronConfig {
}
api_name_011
=
api_config
;
}
@Value
(
"${micron.api_name_101:}"
)
public
void
setApi_name_101
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
))
{
return
;
}
api_name_101
=
api_config
;
}
@Value
(
"${micron.api_name_102:}"
)
public
void
setApi_name_102
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
))
{
return
;
}
api_name_102
=
api_config
;
}
@Value
(
"${micron.api_name_103:}"
)
public
void
setApi_name_103
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
))
{
return
;
}
api_name_103
=
api_config
;
}
@Value
(
"${micron.api_name_201:}"
)
public
void
setApi_name_201
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
))
{
return
;
}
api_name_201
=
api_config
;
}
@Value
(
"${micron.api_name_202:}"
)
public
void
setApi_name_202
(
String
api_config
)
{
if
(
ObjectUtil
.
isEmpty
(
api_config
))
{
return
;
}
api_name_202
=
api_config
;
}
@Autowired
private
DataCache
dataCache
;
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论