Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 819ef0ac
由
sunke
编写于
2023-02-03 13:37:32 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
PannaCIM对接
1 个父辈
19888dd5
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
92 行增加
和
75 行删除
src/main/java/com/neotel/smfcore/core/api/listener/BaseSmfApiListener.java
src/main/java/com/neotel/smfcore/core/api/listener/DefaultSmfApiListener.java
src/main/java/com/neotel/smfcore/custom/neotel/NeotelApi.java
src/main/java/com/neotel/smfcore/custom/panacim/PanaApiController.java
src/main/java/com/neotel/smfcore/core/api/listener/BaseSmfApiListener.java
查看文件 @
819ef0a
...
...
@@ -7,8 +7,10 @@ import com.neotel.smfcore.common.utils.HttpHelper;
import
com.neotel.smfcore.common.utils.JsonUtil
;
import
com.neotel.smfcore.core.api.bean.ApiResult
;
import
com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager
;
import
com.neotel.smfcore.core.barcode.service.manager.IComponentManager
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.api.bean.CodeValidateParam
;
import
com.neotel.smfcore.core.barcode.service.po.Component
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.inList.service.manager.IInListManager
;
import
com.neotel.smfcore.core.inList.service.po.InList
;
...
...
@@ -49,6 +51,26 @@ public abstract class BaseSmfApiListener implements ISmfApiListener {
@Autowired
protected
DataCache
dataCache
;
@Autowired
private
IComponentManager
componentManager
;
protected
Component
resolveComponent
(
Barcode
barcode
){
Component
component
=
componentManager
.
findByPartNumberAndProvider
(
barcode
.
getPartNumber
(),
barcode
.
getProvider
());
if
(
component
==
null
){
log
.
info
(
"自动添加["
+
barcode
.
getPartNumber
()+
"]["
+
barcode
.
getProvider
()+
"]的档案信息"
);
component
=
new
Component
();
component
.
setPartNumber
(
barcode
.
getPartNumber
());
component
.
setAmount
(
barcode
.
getAmount
());
int
w
=
barcode
.
getPlateSize
();
int
h
=
barcode
.
getHeight
();
component
.
setPlateSize
(
w
);
component
.
setHeight
(
h
);
component
.
setProvider
(
barcode
.
getProvider
());
component
=
componentManager
.
save
(
component
);
}
return
component
;
}
@Override
public
void
inTaskStatusChange
(
String
inNotifyUrl
,
DataLog
task
){
...
...
src/main/java/com/neotel/smfcore/core/api/listener/DefaultSmfApiListener.java
查看文件 @
819ef0a
...
...
@@ -240,10 +240,4 @@ public class DefaultSmfApiListener extends BaseSmfApiListener {
}
}
public
LiteOrder
fetchOrder
(
String
fetchOrderUrl
,
String
orderNumber
,
String
username
){
return
null
;
}
}
src/main/java/com/neotel/smfcore/custom/neotel/NeotelApi.java
查看文件 @
819ef0a
...
...
@@ -36,12 +36,6 @@ public class NeotelApi extends BaseSmfApiListener {
@Autowired
private
ILiteOrderItemManager
liteOrderItemManager
;
@Autowired
private
CodeResolve
codeResolve
;
@Autowired
private
IComponentManager
componentManager
;
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"neotel"
);
...
...
@@ -218,22 +212,6 @@ public class NeotelApi extends BaseSmfApiListener {
}
private
Component
resolveComponent
(
Barcode
barcode
){
Component
component
=
componentManager
.
findByPartNumberAndProvider
(
barcode
.
getPartNumber
(),
barcode
.
getProvider
());
if
(
component
==
null
){
log
.
info
(
"自动添加["
+
barcode
.
getPartNumber
()+
"]["
+
barcode
.
getProvider
()+
"]的档案信息"
);
component
=
new
Component
();
component
.
setPartNumber
(
barcode
.
getPartNumber
());
component
.
setAmount
(
barcode
.
getAmount
());
int
w
=
barcode
.
getPlateSize
();
int
h
=
barcode
.
getHeight
();
component
.
setPlateSize
(
w
);
component
.
setHeight
(
h
);
component
.
setProvider
(
barcode
.
getProvider
());
component
=
componentManager
.
save
(
component
);
}
return
component
;
}
/**
* 入库判定
...
...
@@ -314,9 +292,4 @@ public class NeotelApi extends BaseSmfApiListener {
public
void
onOrderStatusChange
(
String
orderNotifyUrl
,
LiteOrder
liteOrder
)
{
}
@Override
public
LiteOrder
fetchOrder
(
String
fetchOrderUrl
,
String
orderNumber
,
String
username
)
{
return
null
;
}
}
src/main/java/com/neotel/smfcore/custom/panacim/PanaApiController.java
查看文件 @
819ef0a
...
...
@@ -9,7 +9,10 @@ import com.neotel.smfcore.common.utils.HttpHelper;
import
com.neotel.smfcore.common.utils.StorageConstants
;
import
com.neotel.smfcore.core.api.bean.CodeValidateParam
;
import
com.neotel.smfcore.core.api.listener.BaseSmfApiListener
;
import
com.neotel.smfcore.core.barcode.bean.CodeBean
;
import
com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.device.enums.OP
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
import
com.neotel.smfcore.core.device.util.DataCache
;
...
...
@@ -45,6 +48,10 @@ public class PanaApiController extends BaseSmfApiListener {
protected
static
DataCache
dataCache
;
@Autowired
protected
CodeResolve
codeResolve
;
@Autowired
public
void
setDataCache
(
DataCache
dataCache
)
{
PanaApiController
.
dataCache
=
dataCache
;
...
...
@@ -59,7 +66,6 @@ public class PanaApiController extends BaseSmfApiListener {
private
static
String
PanaCIMPort
=
""
;
private
static
String
TowerID
=
"InoAutoB"
;
private
static
AtomicLong
seq
=
new
AtomicLong
(
0
);
@RequestMapping
(
value
=
"/setConfiguration"
)
...
...
@@ -111,7 +117,8 @@ public class PanaApiController extends BaseSmfApiListener {
return
"OK"
;
}
private
static
String
nextSeq
(){
private
static
String
nextSeq
(
String
TowerID
){
TowerID
=
TowerID
.
replaceAll
(
" "
,
"_"
);
return
"SMDBOX_"
+
TowerID
+
"_"
+
seq
.
incrementAndGet
();
}
...
...
@@ -373,56 +380,77 @@ public class PanaApiController extends BaseSmfApiListener {
return
result
;
}
@Override
public
Barcode
canPutIn
AfterResolve
(
String
inCheckUrl
,
CodeValidateParam
codeParams
,
Barcode
barcode
)
throws
ValidateException
{
public
Barcode
canPutIn
BeforeResolve
(
String
codeResolveUrl
,
CodeValidateParam
codeParams
)
throws
ValidateException
{
String
requestReelUrl
=
getRequestReelUrl
();
try
{
if
(!
Strings
.
isNullOrEmpty
(
requestReelUrl
)){
log
.
info
(
"向 PanaCIM["
+
requestReelUrl
+
"]请求料盘【"
+
barcode
.
getBarcode
()+
"】的信息"
);
//String url = getApiUrl("/api/Storage/requestReel");
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"TransactionID"
,
nextSeq
());
params
.
put
(
"ErrorCode"
,
"0"
);
params
.
put
(
"Reelbarcode"
,
barcode
.
getBarcode
());
String
result
=
HttpHelper
.
postJson
(
requestReelUrl
,
params
);
log
.
info
(
"PanaCIM 返回料盘【"
+
barcode
.
getBarcode
()+
"】的信息:"
+
result
);
if
(!
Strings
.
isNullOrEmpty
(
result
)){
ObjectMapper
mapper
=
new
ObjectMapper
();
HashMap
<
String
,
String
>
jsonMap
=
mapper
.
readValue
(
result
,
HashMap
.
class
);
String
ErrorCode
=
jsonMap
.
get
(
"ErrorCode"
);
if
(
"0"
.
equals
(
ErrorCode
)){
//成功
String
qtyStr
=
jsonMap
.
get
(
"Quantity"
);
if
(!
Strings
.
isNullOrEmpty
(
qtyStr
)){
/**
* Sample json Data: {
* "TransactionID": "101_MAT_1481090400", "ErrorCode": 0,
* "ReelBarcode": "MAT123567",
* "PartNo": "0805",
* "Quantity": 2000, "Msd": True, "Msdlevel": "4", "Location": "0",
* "MsdDetail”:{
* "FloorLifeExpirationTime":"2017-01-23T21:35:45.5403903Z",
* "ShelfLifeExpirationTime":"2018-06-23T21:35:45.5403903Z",
* “FloorTimeRunning”: true
* }
* } }
*/
int
qty
=
Double
.
valueOf
(
qtyStr
).
intValue
();
if
(
qty
>
0
){
barcode
.
setAmount
(
qty
);
log
.
info
(
"向 PanaCIM["
+
requestReelUrl
+
"]请求料盘【"
+
codeParams
.
getCode
()+
"】的信息"
);
Collection
<
CodeBean
>
codeBeans
=
codeResolve
.
resolveCodeStr
(
codeParams
.
getCode
(),
COMPONENT_TYPE
.
COMPONENT
);
String
errorMsg
=
""
;
for
(
CodeBean
codebean
:
codeBeans
)
{
if
(
codebean
.
getReelHeight
()
<=
0
)
{
codebean
.
setReelHeight
(
1
);
}
if
(
codebean
.
getReelWidth
()
<=
0
)
{
codebean
.
setReelWidth
(
1
);
}
Barcode
barcode
=
codebean
.
getBarcode
();
if
(
codebean
.
getBarcode
()
==
null
){
barcode
=
new
Barcode
();
barcode
.
setBarcode
(
codebean
.
getCodeStr
());
}
barcode
.
setPlateSize
(
codebean
.
getReelWidth
());
barcode
.
setHeight
(
codebean
.
getReelHeight
());
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"TransactionID"
,
nextSeq
(
"PANA"
));
params
.
put
(
"ErrorCode"
,
"0"
);
params
.
put
(
"Reelbarcode"
,
barcode
.
getBarcode
());
String
result
=
HttpHelper
.
postJson
(
requestReelUrl
,
params
);
log
.
info
(
"PanaCIM 返回料盘【"
+
codebean
.
getCodeStr
()+
"】的信息:"
+
result
);
if
(!
Strings
.
isNullOrEmpty
(
result
)){
ObjectMapper
mapper
=
new
ObjectMapper
();
HashMap
<
String
,
String
>
jsonMap
=
mapper
.
readValue
(
result
,
HashMap
.
class
);
String
ErrorCode
=
jsonMap
.
get
(
"ErrorCode"
);
if
(
"0"
.
equals
(
ErrorCode
)){
//成功
String
qtyStr
=
jsonMap
.
get
(
"Quantity"
);
if
(!
Strings
.
isNullOrEmpty
(
qtyStr
)){
/**
* Sample json Data: {
* "TransactionID": "101_MAT_1481090400", "ErrorCode": 0,
* "ReelBarcode": "MAT123567",
* "PartNo": "0805",
* "Quantity": 2000, "Msd": True, "Msdlevel": "4", "Location": "0",
* "MsdDetail”:{
* "FloorLifeExpirationTime":"2017-01-23T21:35:45.5403903Z",
* "ShelfLifeExpirationTime":"2018-06-23T21:35:45.5403903Z",
* “FloorTimeRunning”: true
* }
* } }
*/
int
qty
=
Double
.
valueOf
(
qtyStr
).
intValue
();
if
(
qty
>
0
){
barcode
.
setAmount
(
qty
);
}
String
partNo
=
jsonMap
.
get
(
"PartNo"
);
barcode
.
setPartNumber
(
partNo
);
}
resolveComponent
(
barcode
);
barcode
=
barcodeManager
.
saveBarcode
(
barcode
);
return
barcode
;
}
else
{
errorMsg
=
"PanaCIM ["
+
barcode
.
getBarcode
()
+
"] NG:"
+
ErrorCode
;
}
return
barcode
;
}
else
{
throw
new
ValidateException
(
"PanaCIM ["
+
barcode
.
getBarcode
()
+
"] NG:"
+
ErrorCode
,
"PanaCIM验证失败"
);
}
}
throw
new
ValidateException
(
errorMsg
,
"PanaCIM验证失败"
);
}
else
{
log
.
info
(
"没有配置PanaCIM条码检测接口,查找setConfiguration注册的IP 及端口"
);
return
null
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"
向 PanaCIM请求料盘【"
+
barcode
.
getBarcode
()+
"】的信息出错
"
,
e
);
log
.
error
(
"
Request to PanaCIM["
+
codeParams
.
getCode
()+
"] Error
"
,
e
);
}
return
null
;
}
...
...
@@ -461,7 +489,7 @@ public class PanaApiController extends BaseSmfApiListener {
log
.
info
(
"向 PanaCIM["
+
inNotifyApi
+
"] 通知料盘【"
+
task
.
getBarcode
()+
"】的入库信息"
);
//String url = getApiUrl("/api/Storage/checkInNotification");
Map
<
String
,
Object
>
params
=
new
LinkedHashMap
<>();
params
.
put
(
"TransactionID"
,
nextSeq
());
params
.
put
(
"TransactionID"
,
nextSeq
(
task
.
getStorageName
()
));
params
.
put
(
"ReelBarcode"
,
task
.
getBarcode
());
params
.
put
(
"PartNo"
,
task
.
getPartNumber
());
params
.
put
(
"Quantity"
,
task
.
getNum
());
...
...
@@ -491,14 +519,14 @@ public class PanaApiController extends BaseSmfApiListener {
log
.
info
(
"向 PanaCIM["
+
outNotifyApi
+
"] 通知料盘【"
+
task
.
getBarcode
()+
"】的出库信息"
);
//String url = getApiUrl("/api/Storage/deliverNotification");
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"TransactionID"
,
nextSeq
());
params
.
put
(
"TransactionID"
,
nextSeq
(
task
.
getStorageName
()
));
params
.
put
(
"ReelBarcode"
,
task
.
getBarcode
());
params
.
put
(
"PartNO"
,
task
.
getPartNumber
());
params
.
put
(
"Quantity"
,
task
.
getNum
());
SimpleDateFormat
dataformat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
params
.
put
(
"Timestamp"
,
dataformat
.
format
(
new
Date
()));
params
.
put
(
"TowerID"
,
task
.
getStorageName
());
params
.
put
(
"JobID"
,
""
);
params
.
put
(
"JobID"
,
task
.
getSourceId
()
);
params
.
put
(
"Msd"
,
false
);
params
.
put
(
"MsdLevel"
,
"1"
);
params
.
put
(
"Location"
,
"0"
);
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论