Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 06d99ddb
由
LN
编写于
2024-05-22 17:46:40 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
韩华接口修改
1 个父辈
a258290f
全部展开
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
241 行增加
和
40 行删除
src/main/java/com/neotel/smfcore/custom/hanwha/handler/HanwhaApiHandler.java
src/main/java/com/neotel/smfcore/custom/hanwha/handler/TMSApis.java
src/main/java/com/neotel/smfcore/custom/hanwha/handler/TMSCommunicator.java
src/main/java/com/neotel/smfcore/custom/hanwha/handler/bean/TMSPartReelStatus.java
src/main/java/com/neotel/smfcore/custom/hanwha/handler/bean/TMSPos.java
src/main/java/com/neotel/smfcore/custom/hanwha/handler/bean/TMSRackStatus.java
src/main/java/com/neotel/smfcore/custom/hanwha/handler/HanwhaApiHandler.java
查看文件 @
06d99dd
...
@@ -7,37 +7,54 @@ import com.neotel.smfcore.core.api.bean.CodeValidateParam;
...
@@ -7,37 +7,54 @@ import com.neotel.smfcore.core.api.bean.CodeValidateParam;
import
com.neotel.smfcore.core.api.listener.BaseSmfApiListener
;
import
com.neotel.smfcore.core.api.listener.BaseSmfApiListener
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.barcode.service.po.Barcode
;
import
com.neotel.smfcore.core.device.bean.StatusBean
;
import
com.neotel.smfcore.core.device.bean.StatusBean
;
import
com.neotel.smfcore.core.order.service.po.LiteOrder
;
import
com.neotel.smfcore.core.storage.service.manager.IStoragePosManager
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.Storage
;
import
com.neotel.smfcore.core.storage.service.po.StoragePos
;
import
com.neotel.smfcore.core.system.service.manager.IDataLogManager
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.service.po.DataLog
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.core.system.util.DevicesStatusUtil
;
import
com.neotel.smfcore.custom.hanwha.handler.bean.TMSPart
;
import
com.neotel.smfcore.custom.hanwha.handler.bean.TMSPart
;
import
com.neotel.smfcore.custom.hanwha.handler.bean.TMSPartReelPos
;
import
com.neotel.smfcore.custom.hanwha.handler.bean.TMSPartReelPos
;
import
com.neotel.smfcore.custom.hanwha.handler.bean.TMSRackStatus
;
import
com.neotel.smfcore.custom.hanwha.handler.bean.TMSReserve
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
@Service
@Service
@Slf4j
@Slf4j
public
class
HanwhaApiHandler
extends
BaseSmfApiListener
{
public
class
HanwhaApiHandler
extends
BaseSmfApiListener
{
//配置說明
//配置說明
// api:
// api:
// name: hanwha
// name: hanwha
// inCheckUrl:
webservice/RequestGetPartInfo
// inCheckUrl:
// outNotifyUrl: webservice/RequestSyncPartReelPosInfo
// outNotifyUrl: webservice/RequestSyncPartReelPosInfo
// inNotifyUrl: webservice/RequestSyncPartReelPosInfo
// inNotifyUrl: webservice/RequestSyncPartReelPosInfo
// deviceStatusUrl: webservice/RequestUpdateStorageConnectionInfo
// deviceStatusUrl: webservice/RequestUpdateStorageConnectionInfo
//
// codeResolveUrl: webservice/RequestGetPartInfo
// orderNotifyUrl: webservice/ResponseUpdateDeliveryReserveState
//
// hanwha:
// hanwha:
// host: 127.0.0.1
// host: 3.39.76.183
// webPort: 18189
// webPort: 1337
// apiPort: 8374
// apiPort: 8082
@Autowired
private
IStoragePosManager
storagePosManager
;
@Autowired
private
TMSCommunicator
tmsCommunicator
;
@Override
@Override
public
boolean
isForThisApi
(
String
apiName
)
{
public
boolean
isForThisApi
(
String
apiName
)
{
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"hanwha"
)&&
TMSCommunicator
.
isEnable
();
return
apiName
!=
null
&&
apiName
.
equalsIgnoreCase
(
"hanwha"
)
&&
TMSCommunicator
.
isEnable
();
}
}
...
@@ -45,6 +62,71 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
...
@@ -45,6 +62,71 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
private
TMSApis
tmsApis
;
private
TMSApis
tmsApis
;
@Override
@Override
public
Barcode
canPutInBeforeResolve
(
String
codeResolveUrl
,
CodeValidateParam
params
)
throws
ValidateException
{
log
.
info
(
"barcode["
+
params
.
getCode
()
+
"] 解析条码,调用 RequestGetPartInfo"
);
List
<
TMSPart
>
result
=
tmsApis
.
RequestGetPartInfo
(
0
,
params
.
getCode
());
if
(
result
.
size
()
>
0
)
{
String
pn
=
result
.
get
(
0
).
getPartName
();
String
code
=
result
.
get
(
0
).
getReelCode
();
int
count
=
result
.
get
(
0
).
getResponseCount
();
boolean
needS
=
false
;
if
(
ObjectUtil
.
isEmpty
(
pn
))
{
log
.
info
(
"barcode["
+
params
.
getCode
()
+
"] RequestGetPartInfo ,PN为空"
);
return
null
;
}
if
(
ObjectUtil
.
isEmpty
(
code
))
{
log
.
info
(
"barcode["
+
params
.
getCode
()
+
"] RequestGetPartInfo ,唯一码为空"
);
return
null
;
}
if
(
count
<=
0
)
{
count
=
0
;
}
int
width
=
7
;
int
height
=
8
;
Barcode
barcode
=
new
Barcode
();
barcode
.
setFullCode
(
params
.
getCode
());
barcode
.
setAmount
(
count
);
barcode
.
setPartNumber
(
pn
);
barcode
.
setBarcode
(
code
);
barcode
.
setHeight
(
height
);
barcode
.
setPlateSize
(
width
);
barcode
=
barcodeManager
.
saveBarcode
(
barcode
);
log
.
info
(
"barcode["
+
params
.
getCode
()
+
"] RequestGetPartInfo ,PN=["
+
pn
+
"],code=["
+
code
+
"],count=["
+
count
+
"]新增条码准备入库"
);
return
barcode
;
}
return
null
;
}
@Override
public
Barcode
canPutInAfterResolve
(
String
inCheckUrl
,
CodeValidateParam
params
,
Barcode
barcode
)
throws
ValidateException
{
log
.
info
(
"barcode["
+
barcode
.
getBarcode
()
+
"] 准备入库,调用 RequestGetPartInfo"
);
List
<
TMSPart
>
result
=
tmsApis
.
RequestGetPartInfo
(
0
,
barcode
.
getFullCode
());
if
(
result
.
size
()
>
0
)
{
String
pn
=
result
.
get
(
0
).
getPartName
();
String
code
=
result
.
get
(
0
).
getReelCode
();
boolean
needS
=
false
;
if
(
ObjectUtil
.
isNotEmpty
(
pn
))
{
barcode
.
setPartNumber
(
pn
);
needS
=
true
;
}
if
(
ObjectUtil
.
isNotEmpty
(
code
))
{
barcode
.
setBarcode
(
code
);
needS
=
true
;
}
int
count
=
result
.
get
(
0
).
getResponseCount
();
if
(
count
>
0
)
{
barcode
.
setAmount
(
count
);
needS
=
true
;
}
if
(
needS
)
{
log
.
info
(
"barcode["
+
barcode
.
getBarcode
()
+
"] 准备入库,调用 RequestGetPartInfo ,更改pn=["
+
barcode
.
getPartNumber
()
+
"],code=["
+
barcode
.
getBarcode
()
+
"],count=["
+
barcode
.
getAmount
()
+
"]"
);
barcodeManager
.
saveBarcode
(
barcode
);
}
}
return
barcode
;
}
@Override
public
void
inTaskStatusChange
(
String
inNotifyUrl
,
DataLog
task
)
{
public
void
inTaskStatusChange
(
String
inNotifyUrl
,
DataLog
task
)
{
if
(!
task
.
isPutInTask
())
{
if
(!
task
.
isPutInTask
())
{
return
;
return
;
...
@@ -79,40 +161,87 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
...
@@ -79,40 +161,87 @@ public class HanwhaApiHandler extends BaseSmfApiListener {
}
}
@Override
@Override
public
Barcode
canPutInAfterResolve
(
String
inCheckUrl
,
CodeValidateParam
params
,
Barcode
barcode
)
throws
ValidateException
{
public
void
onOrderStatusChange
(
String
orderNotifyUrl
,
LiteOrder
liteOrder
)
{
log
.
info
(
"barcode["
+
barcode
.
getBarcode
()
+
"] 准备入库,调用 RequestGetPartInfo"
);
//ResponseUpdateDeliveryReserveState-all work order
List
<
TMSPart
>
result
=
tmsApis
.
RequestGetPartInfo
(
0
,
barcode
.
getFullCode
());
if
(
result
.
size
()
>
0
)
{
if
(
liteOrder
.
isClosed
())
{
String
pn
=
result
.
get
(
0
).
getPartName
();
String
code
=
result
.
get
(
0
).
getReelCode
();
TMSReserve
tmsReserve
=
tmsCommunicator
.
GetOrderInfo
(
liteOrder
);
boolean
needS
=
false
;
List
<
TMSReserve
>
list
=
new
ArrayList
<>();
if
(
ObjectUtil
.
isNotEmpty
(
pn
))
{
list
.
add
(
tmsReserve
);
barcode
.
setPartNumber
(
pn
);
tmsCommunicator
.
ResponseUpdateDeliveryReserveState
(
0
,
list
,
0
);
needS
=
true
;
}
}
if
(
ObjectUtil
.
isNotEmpty
(
code
))
{
barcode
.
setBarcode
(
code
);
needS
=
true
;
}
}
int
count
=
result
.
get
(
0
).
getResponseCount
();
if
(
count
>
0
)
{
@Override
barcode
.
setAmount
(
count
);
public
boolean
deviceStatusChanges
(
String
deviceStatusUrl
,
String
[]
cids
,
Integer
[]
statusList
)
{
needS
=
true
;
log
.
info
(
"deviceStatusChanges ,设备状态变化["
+
JsonUtil
.
toJsonStr
(
cids
)
+
"],["
+
JsonUtil
.
toJsonStr
(
statusList
)
+
"],通知TMS"
);
// UpdateStorageConnectionInfo(cids,statusList);
RequestSyncRackStatusInfo
(
cids
,
statusList
);
return
true
;
}
}
if
(
needS
)
{
log
.
info
(
"barcode["
+
barcode
.
getBarcode
()
+
"] 准备入库,调用 RequestGetPartInfo ,更改pn=["
+
barcode
.
getPartNumber
()
+
"],code=["
+
barcode
.
getBarcode
()
+
"],count=["
+
barcode
.
getAmount
()
+
"]"
);
public
void
RequestSyncRackStatusInfo
(
String
[]
cids
,
Integer
[]
statusList
)
{
barcodeManager
.
saveBarcode
(
barcode
);
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
dateString
=
formatter
.
format
(
new
Date
());
if
(!
TMSCommunicator
.
isEnable
())
{
return
;
}
}
List
<
TMSRackStatus
>
SyncRackStatusDatas
=
new
ArrayList
<>();
List
<
String
>
storageIds
=
new
ArrayList
<>();
int
i
=
0
;
for
(
String
cid
:
cids
)
{
Storage
storage
=
dataCache
.
getStorage
(
cid
);
if
(
storage
==
null
)
{
continue
;
}
}
return
barcode
;
String
type
=
"Storage"
;
if
(
storage
.
isNLShelf
()
||
storage
.
isNLPShelf
()
||
storage
.
isNLMShelf
()
||
storage
.
isShelf
())
{
type
=
"Rack"
;
}
}
@Override
int
status
=
-
1
;
public
boolean
deviceStatusChanges
(
String
deviceStatusUrl
,
String
[]
cids
,
Integer
[]
statusList
)
{
if
(
statusList
!=
null
&&
statusList
.
length
>
i
)
{
log
.
info
(
"deviceStatusChanges ,设备状态变化["
+
JsonUtil
.
toJsonStr
(
cids
)
+
"],["
+
JsonUtil
.
toJsonStr
(
statusList
)
+
"],通知TMS"
);
status
=
statusList
[
i
];
UpdateStorageConnectionInfo
(
cids
,
statusList
);
}
else
{
return
true
;
StatusBean
bean
=
DevicesStatusUtil
.
getStatusBean
(
storage
.
getCid
());
if
(
bean
==
null
||
bean
.
timeOut
())
{
status
=
-
1
;
}
else
{
status
=
bean
.
getStatus
();
}
}
int
flag
=
0
;
if
(
status
>=
1
)
{
flag
=
2
;
}
List
<
StoragePos
>
allStorage
=
storagePosManager
.
findByStorage
(
storage
.
getId
());
for
(
StoragePos
pos
:
allStorage
)
{
TMSRackStatus
st
=
new
TMSRackStatus
();
st
.
setPosName
(
pos
.
getPosName
());
st
.
setRackID
(
storage
.
getCid
());
st
.
setFlag
(
flag
);
st
.
setOutdate
(
""
);
st
.
setIndate
(
""
);
if
(
flag
==
2
)
{
st
.
setIndate
(
dateString
);
}
else
{
st
.
setOutdate
(
dateString
);
}
}
public
void
UpdateStorageConnectionInfo
(
String
[]
cids
,
Integer
[]
statusList
)
{
SyncRackStatusDatas
.
add
(
st
);
}
}
if
(
storageIds
.
size
()
>
0
)
{
tmsApis
.
RequestSyncRackStatusInfo
(
0
,
SyncRackStatusDatas
);
}
}
public
void
UpdateStorageConnectionInfo
(
String
[]
cids
,
Integer
[]
statusList
)
{
if
(!
TMSCommunicator
.
isEnable
())
{
if
(!
TMSCommunicator
.
isEnable
())
{
return
;
return
;
}
}
...
...
src/main/java/com/neotel/smfcore/custom/hanwha/handler/TMSApis.java
查看文件 @
06d99dd
...
@@ -117,7 +117,9 @@ public class TMSApis {
...
@@ -117,7 +117,9 @@ public class TMSApis {
}
}
/**
/**
* 3.18 RequestSyncRackStatusInfo
* 3.18 RequestSyncRackStatusInfo 不需要
* 3.19 不需要
*
* When Rack’ Status change, send to TMS about Rack’s Status.
* When Rack’ Status change, send to TMS about Rack’s Status.
* @param RequestID
* @param RequestID
* @param SyncRackStatusDatas
* @param SyncRackStatusDatas
...
@@ -162,8 +164,10 @@ public class TMSApis {
...
@@ -162,8 +164,10 @@ public class TMSApis {
}
}
return
result
;
return
result
;
}
}
////3.20 设备离线上线所有的库位信息上传
/**
/**
*3.2
1
RequestUpdateStorageConnectionInfo
*3.2
3
RequestUpdateStorageConnectionInfo
* When Rack’s Connection Status changed, send to TMS about Rack Connection
* When Rack’s Connection Status changed, send to TMS about Rack Connection
* Status.
* Status.
* @param RequestID
* @param RequestID
...
...
src/main/java/com/neotel/smfcore/custom/hanwha/handler/TMSCommunicator.java
查看文件 @
06d99dd
此文件的差异被折叠,
点击展开。
src/main/java/com/neotel/smfcore/custom/hanwha/handler/bean/TMSPartReelStatus.java
查看文件 @
06d99dd
...
@@ -7,8 +7,18 @@ import java.util.HashMap;
...
@@ -7,8 +7,18 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
@Data
@Data
public
class
TMSPartReelStatus
extends
TMSPart
implements
Serializable
{
public
class
TMSPartReelStatus
extends
TMSPart
implements
Serializable
{
/**
* String ResultCode Result code (Refer 5. ResultCode)
* When the request (In : 0 / Out : 1)
* When the response (ok : 0 / ng : 1)
*/
private
String
ReserveCode
=
""
;
private
String
ReserveCode
=
""
;
/**
* Bool TowerLamp Tower Lamp Status (true : on / false : off)
* When the request, (current tower lamp status)
* When the response, (tower lamp status to be changed)
*/
private
boolean
TowerLamp
=
false
;
private
boolean
TowerLamp
=
false
;
@Override
@Override
...
...
src/main/java/com/neotel/smfcore/custom/hanwha/handler/bean/TMSPos.java
查看文件 @
06d99dd
...
@@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@Data
@Data
@Slf4j
@Slf4j
...
@@ -28,9 +30,9 @@ public class TMSPos implements Serializable {
...
@@ -28,9 +30,9 @@ public class TMSPos implements Serializable {
public
String
getPosName
(){
public
String
getPosName
(){
return
getRowID
()+
"_"
+
getColID
();
return
getRowID
()+
"_"
+
getColID
();
}
}
public
void
setPosName
(
String
posName
){
public
void
setPosName
(
String
posName
)
{
if
(
ObjectUtil
.
isEmpty
(
posName
))
{
if
(
ObjectUtil
.
isEmpty
(
posName
))
{
setColID
(
""
);
setColID
(
""
);
setRowID
(
""
);
setRowID
(
""
);
return
;
return
;
...
@@ -43,14 +45,55 @@ public class TMSPos implements Serializable {
...
@@ -43,14 +45,55 @@ public class TMSPos implements Serializable {
// setColID(posName.substring(index+1,posName.length()-1));
// setColID(posName.substring(index+1,posName.length()-1));
// }
// }
String
[]
posArray
=
posName
.
split
(
"_"
);
String
spit
=
"_"
;
String
[]
posArray
=
posName
.
split
(
spit
);
if
(
posArray
.
length
>=
2
)
{
if
(
posArray
.
length
>=
2
)
{
}
else
{
spit
=
"-"
;
}
try
{
try
{
setColID
(
posArray
[
posArray
.
length
-
1
]);
String
rowId
=
proStr
(
posName
)
;
setRowID
(
posArray
[
posArray
.
length
-
2
]);
String
colId
=
""
;
int
index
=
posName
.
lastIndexOf
(
spit
);
if
(
index
>
0
)
{
rowId
=
posName
.
substring
(
0
,
index
);
colId
=
posName
.
substring
(
index
+
1
,
posName
.
length
());
}
else
{
String
nPosName
=
proStr
(
posName
);
if
(
nPosName
.
length
()>
2
){
index
=
posName
.
length
()
-
2
;
rowId
=
posName
.
substring
(
0
,
index
);
colId
=
posName
.
substring
(
index
,
posName
.
length
());
}
}
setRowID
(
proStr
(
rowId
));
setColID
(
proStr
(
colId
));
// setColID(posArray[posArray.length - 1]);
// setRowID(posArray[posArray.length - 2]);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
log
.
error
(
"解析位置的行列失败 "
+
posName
+
","
+
ex
.
toString
());
log
.
error
(
"解析位置的行列失败 "
+
posName
+
","
+
ex
.
toString
());
}
}
}
private
String
proStr
(
String
input
)
{
// 使用正则表达式匹配数字
String
regex
=
"\\d+"
;
Pattern
pattern
=
Pattern
.
compile
(
regex
);
Matcher
matcher
=
pattern
.
matcher
(
input
);
// 拼接匹配到的数字
StringBuilder
builder
=
new
StringBuilder
();
while
(
matcher
.
find
())
{
builder
.
append
(
matcher
.
group
());
}
}
// 输出结果
String
result
=
builder
.
toString
();
return
result
;
}
}
}
}
src/main/java/com/neotel/smfcore/custom/hanwha/handler/bean/TMSRackStatus.java
查看文件 @
06d99dd
...
@@ -8,10 +8,25 @@ import java.util.Map;
...
@@ -8,10 +8,25 @@ import java.util.Map;
@Data
@Data
public
class
TMSRackStatus
extends
TMSPos
implements
Serializable
{
public
class
TMSRackStatus
extends
TMSPos
implements
Serializable
{
/**
* 0: Unconnected Rack(shelf ) / not available
* 1: Booting (not available)
* 2: Connected Rack(shelf) / ready ( available )
*/
private
int
Flag
=
0
;
private
int
Flag
=
0
;
/**
* Connected to the Rack(shelf)
* Format : “yyyy-MM-dd HH:mm:ss”
* Ex) April 5, 2019 PM 12:30:59 → “2019-04-05 12:30:59”
*/
private
String
Indate
;
private
String
Indate
;
/**
* Unconnected to the Rack(shelf)
* Format : “yyyy-MM-dd HH:mm:ss”
* Ex) April 5, 2019 PM 12:30:59 → “2019-04-05 12:30:59”
*/
private
String
Outdate
;
private
String
Outdate
;
public
TMSRackStatus
()
{
public
TMSRackStatus
()
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论