Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit cffc76ca
由
LN
编写于
2022-05-13 17:52:01 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
接口修改
1 个父辈
29e7db1e
全部展开
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
111 行增加
和
39 行删除
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/NLShelfHandler.java
src/main/java/com/neotel/smfcore/hikvision/HikApi.java
src/main/java/com/neotel/smfcore/hikvision/HikApiCache.java
src/main/java/com/neotel/smfcore/hikvision/bean/InOutApiInfo.java
src/main/java/com/neotel/smfcore/hikvision/bean/api/HikApiRequest.java
src/main/java/com/neotel/smfcore/hikvision/util/HttpHelper.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
查看文件 @
cffc76c
...
@@ -672,7 +672,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
...
@@ -672,7 +672,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
boolean
result
=
HikApi
.
scheduleTaskApi
(
task
.
getOperator
(),
taskInfo
);
boolean
result
=
HikApi
.
scheduleTaskApi
(
task
.
getOperator
(),
taskInfo
);
}
else
{
}
else
{
//出库完成,调用 ,7.6出库下架过账接口
//出库完成,调用 ,7.6出库下架过账接口
boolean
result
=
HikApi
.
checkOutApi
(
task
.
getOperator
(),
InOutApiInfo
.
outInfo
(
task
.
getOutType
(),
task
.
getBarcode
(),
task
.
getNum
(),
task
.
getBaseCode
(),
task
.
getLgort
()));
boolean
result
=
HikApi
.
checkOutApi
(
task
.
getOperator
(),
InOutApiInfo
.
outInfo
(
task
.
getOutType
(),
task
.
getBarcode
(),
task
.
getNum
(),
task
.
getBaseCode
(),
task
.
getLgort
()
,
task
.
getSourceName
()
));
}
}
//从队列里面移除操作
//从队列里面移除操作
...
...
src/main/java/com/neotel/smfcore/core/device/handler/impl/NLShelfHandler.java
查看文件 @
cffc76c
...
@@ -282,7 +282,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
...
@@ -282,7 +282,7 @@ public class NLShelfHandler extends BaseDeviceHandler {
taskService
.
addTaskToFinished
(
inPos
,
null
,
loginUser
);
taskService
.
addTaskToFinished
(
inPos
,
null
,
loginUser
);
opPosLight
(
"close"
,
inPos
,
null
);
opPosLight
(
"close"
,
inPos
,
null
);
log
.
info
(
barcode
.
getBarcode
()
+
" 出库完成, 库位["
+
inPos
.
getPosName
()
+
"]灭灯"
);
log
.
info
(
barcode
.
getBarcode
()
+
" 出库完成, 库位["
+
inPos
.
getPosName
()
+
"]灭灯"
);
return
ResultBean
.
new
ErrorResult
(
1
,
"smfcore.shelf.msg.outConfirm"
,
"出库完成, 库位[{0}]灭灯"
,
new
String
[]{
inPos
.
getPosName
()}
);
return
ResultBean
.
new
OkResult
(
"smfcore.shelf.msg.outConfirm"
,
"出库完成, 库位[{0}]灭灯"
,
new
String
[]{
inPos
.
getPosName
()}
);
}
}
}
}
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.shelf.msg.noTask"
,
"操作失败,已在库位[{0}]中,未找到对应的出库任务"
,
new
String
[]{
inPos
.
getPosName
()});
return
ResultBean
.
newErrorResult
(
1
,
"smfcore.shelf.msg.noTask"
,
"操作失败,已在库位[{0}]中,未找到对应的出库任务"
,
new
String
[]{
inPos
.
getPosName
()});
...
...
src/main/java/com/neotel/smfcore/hikvision/HikApi.java
查看文件 @
cffc76c
此文件的差异被折叠,
点击展开。
src/main/java/com/neotel/smfcore/hikvision/HikApiCache.java
查看文件 @
cffc76c
package
com
.
neotel
.
smfcore
.
hikvision
;
package
com
.
neotel
.
smfcore
.
hikvision
;
import
com.neotel.smfcore.common.exception.
Api
Exception
;
import
com.neotel.smfcore.common.exception.
Validate
Exception
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.core.device.util.DataCache
;
import
com.neotel.smfcore.hikvision.bean.api.HikApiRequest
;
import
com.neotel.smfcore.hikvision.bean.api.HikApiRequest
;
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
import
javax.annotation.PostConstruct
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
...
@@ -30,6 +31,22 @@ public class HikApiCache {
...
@@ -30,6 +31,22 @@ public class HikApiCache {
private
static
boolean
isProcessTimer
=
false
;
private
static
boolean
isProcessTimer
=
false
;
@PostConstruct
public
void
Init
(){
initApiRequestMap
();
}
/**
* 加载请求指令信息
*/
private
static
void
initApiRequestMap
()
{
failedRequestMap
=
new
ConcurrentHashMap
<>();
Map
<
String
,
HikApiRequest
>
dbFailedRequestMap
=
dataCache
.
getCache
(
Constants
.
CACHE_failedRequestMap
);
if
(
dbFailedRequestMap
!=
null
)
{
failedRequestMap
.
putAll
(
dbFailedRequestMap
);
log
.
info
(
"共加载到接口异常:"
+
failedRequestMap
.
size
()
+
"条"
);
}
}
/**
/**
* 定时器,每10秒执行一次
* 定时器,每10秒执行一次
*/
*/
...
@@ -37,7 +54,7 @@ public class HikApiCache {
...
@@ -37,7 +54,7 @@ public class HikApiCache {
if
(!
isProcessTimer
)
{
if
(!
isProcessTimer
)
{
isProcessTimer
=
true
;
isProcessTimer
=
true
;
try
{
try
{
sendFailedRequest
();
//
sendFailedRequest();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"发送失败请求定时器执行出错:"
+
e
.
getMessage
());
log
.
error
(
"发送失败请求定时器执行出错:"
+
e
.
getMessage
());
}
finally
{
}
finally
{
...
@@ -46,13 +63,24 @@ public class HikApiCache {
...
@@ -46,13 +63,24 @@ public class HikApiCache {
}
}
}
}
public
static
void
addFailedRequest
(
HikApiRequest
apiRequest
)
{
public
static
List
<
HikApiRequest
>
getAllRequestList
(){
// String mapKey = apiRequest.getParam().getReqCode();
return
new
ArrayList
<>(
failedRequestMap
.
values
());
// if (failedRequestMap.get(mapKey) == null) {
}
// log.info(mapKey + "通知指令发送到Hik失败,加入到缓存");
public
static
HikApiRequest
getRequest
(
String
req
){
// failedRequestMap.put(apiRequest.getParam().getReqCode(), apiRequest);
return
failedRequestMap
.
get
(
req
);
// dataCache.updateCache(Constants.CACHE_failedRequestMap, failedRequestMap);
}
// }
public
static
void
addFailedRequest
(
HikApiRequest
apiRequest
,
ResponseParam
responseParam
)
{
String
mapKey
=
apiRequest
.
getParam
().
getReqCode
();
apiRequest
.
setResponseParam
(
responseParam
);
apiRequest
.
setUpdatetime
(
new
Date
());
if
(
failedRequestMap
.
get
(
mapKey
)
==
null
)
{
log
.
info
(
mapKey
+
"通知指令发送到Hik失败,加入到缓存"
);
}
failedRequestMap
.
put
(
apiRequest
.
getParam
().
getReqCode
(),
apiRequest
);
dataCache
.
updateCache
(
Constants
.
CACHE_failedRequestMap
,
failedRequestMap
);
}
}
public
static
void
removeFailedRequest
(
HikApiRequest
apiRequest
)
{
public
static
void
removeFailedRequest
(
HikApiRequest
apiRequest
)
{
...
@@ -64,26 +92,14 @@ public class HikApiCache {
...
@@ -64,26 +92,14 @@ public class HikApiCache {
}
}
}
}
/**
* 加载请求指令信息
*/
private
static
void
initApiRequestMap
()
{
if
(
failedRequestMap
==
null
)
{
failedRequestMap
=
new
ConcurrentHashMap
<>();
Map
<
String
,
HikApiRequest
>
dbFailedRequestMap
=
dataCache
.
getCache
(
Constants
.
CACHE_failedRequestMap
);
if
(
dbFailedRequestMap
!=
null
)
{
failedRequestMap
.
putAll
(
dbFailedRequestMap
);
log
.
info
(
"当前发送通知失败指令:"
+
failedRequestMap
);
}
}
}
/**
/**
* 获取失败列表,进行定时发送
* 获取失败列表,进行定时发送
*/
*/
p
rivate
static
void
sendFailedRequest
()
throws
ApiException
{
p
ublic
static
void
sendFailedRequest
()
{
if
(
failedRequestMap
==
null
)
{
if
(
failedRequestMap
==
null
)
{
initApiRequestMap
();
initApiRequestMap
();
}
}
...
@@ -97,21 +113,36 @@ public class HikApiCache {
...
@@ -97,21 +113,36 @@ public class HikApiCache {
});
});
for
(
HikApiRequest
apiRequest
:
failedList
)
{
for
(
HikApiRequest
apiRequest
:
failedList
)
{
ResponseParam
responseParam
=
HttpHelper
.
post
(
apiRequest
);
reSendRequest
(
apiRequest
);
}
}
public
static
ResponseParam
reSendRequest
(
HikApiRequest
apiRequest
)
{
ResponseParam
responseParam
=
null
;
try
{
String
interName
=
"Hik 接口"
+
apiRequest
.
getApiType
()
+
" 重发:"
;
responseParam
=
HttpHelper
.
post
(
apiRequest
);
boolean
needResend
=
false
;
boolean
needResend
=
false
;
if
(
responseParam
==
null
||
responseParam
.
getCode
().
equals
(-
1
))
{
if
(
responseParam
==
null
||
responseParam
.
getCode
().
equals
(-
1
))
{
needResend
=
true
;
needResend
=
true
;
log
.
info
(
"Hik 转储单接口 (transferOrderThread): 未收到返回值
,需要重发"
);
log
.
info
(
interName
+
"
,需要重发"
);
}
else
if
(
responseParam
.
getCode
().
equals
(
HikApi
.
CODE_PARAMERROR
)
||
responseParam
.
getCode
().
equals
(
HikApi
.
CODE_REPEAT
))
{
}
else
if
(
responseParam
.
getCode
().
equals
(
HikApi
.
CODE_PARAMERROR
)
||
responseParam
.
getCode
().
equals
(
HikApi
.
CODE_REPEAT
))
{
needResend
=
true
;
needResend
=
true
;
log
.
info
(
"Hik 转储单接口 (transferOrderThread): 返回code="
+
responseParam
.
getCode
()
+
",需要重发,"
+
JsonUtil
.
toJsonStr
(
responseParam
));
log
.
info
(
interName
+
", 返回code="
+
responseParam
.
getCode
()
+
",需要重发,"
+
JsonUtil
.
toJsonStr
(
responseParam
));
}
else
{
if
(
responseParam
.
getCode
().
equals
(
0
))
{
log
.
info
(
interName
+
",发送成功,删除接口异常,返回"
+
JsonUtil
.
toJsonStr
(
responseParam
));
removeFailedRequest
(
apiRequest
);
}
else
{
}
else
{
log
.
info
(
"Hik 转储单接口 (transferOrderThread): 返回"
+
JsonUtil
.
toJsonStr
(
responseParam
));
log
.
info
(
interName
+
",返回"
+
JsonUtil
.
toJsonStr
(
responseParam
));
// Map<String, Object> result = JsonUtil.toMap(responseParam.getData());
// return result;
}
}
}
}
addFailedRequest
(
apiRequest
,
responseParam
);
return
responseParam
;
}
catch
(
Exception
ex
)
{
throw
new
ValidateException
(
"smfcore.error"
,
"出错{0}"
,
new
String
[]{
ex
.
toString
()});
}
}
}
}
}
src/main/java/com/neotel/smfcore/hikvision/bean/InOutApiInfo.java
查看文件 @
cffc76c
...
@@ -21,22 +21,23 @@ public class InOutApiInfo {
...
@@ -21,22 +21,23 @@ public class InOutApiInfo {
// baseCode String 16 是 基地
// baseCode String 16 是 基地
// lgort String 16 是 库位
// lgort String 16 是 库位
// warehousingType Integer 是 出库类型(0普通出库1并盘出库 2湿敏出库)
// warehousingType Integer 是 出库类型(0普通出库1并盘出库 2湿敏出库
3线边仓间转储出库 4预留单出库
)
// trayId String 41 是 料盘ID/唯一码
// trayId String 41 是 料盘ID/唯一码
// docNo String 否 单据号,备注:如果出库类型为3,4则填写预留单号,必填,其他非必填
// qty Integer 是 数量
// qty Integer 是 数量
// baseCode String 16 是 基地
// baseCode String 16 是 基地
// lgort String 16 是 库位
// lgort String 16 是 库位
public
static
InOutApiInfo
inputInfo
(
int
inType
,
String
trayId
,
int
qty
)
public
static
InOutApiInfo
inputInfo
(
int
inType
,
String
trayId
,
int
qty
)
{
{
return
new
InOutApiInfo
(
inType
,
0
,
trayId
,
qty
,
""
,
""
,
""
);
return
new
InOutApiInfo
(
inType
,
0
,
trayId
,
qty
,
""
,
""
,
""
,
""
);
}
}
public
static
InOutApiInfo
inputInfo
(
int
inType
,
String
trayId
,
int
qty
,
String
jobNo
)
public
static
InOutApiInfo
inputInfo
(
int
inType
,
String
trayId
,
int
qty
,
String
jobNo
)
{
{
return
new
InOutApiInfo
(
inType
,
0
,
trayId
,
qty
,
""
,
""
,
jobNo
);
return
new
InOutApiInfo
(
inType
,
0
,
trayId
,
qty
,
""
,
""
,
jobNo
,
""
);
}
}
public
static
InOutApiInfo
outInfo
(
int
outType
,
String
trayId
,
int
qty
,
String
baseCode
,
String
lgort
){
public
static
InOutApiInfo
outInfo
(
int
outType
,
String
trayId
,
int
qty
,
String
baseCode
,
String
lgort
,
String
docNo
){
return
new
InOutApiInfo
(
0
,
outType
,
trayId
,
qty
,
baseCode
,
lgort
,
""
);
return
new
InOutApiInfo
(
0
,
outType
,
trayId
,
qty
,
baseCode
,
lgort
,
""
,
docNo
);
}
}
/**
/**
...
@@ -68,4 +69,8 @@ public class InOutApiInfo {
...
@@ -68,4 +69,8 @@ public class InOutApiInfo {
* 入库类型为退料入库的需要提供工单号
* 入库类型为退料入库的需要提供工单号
*/
*/
private
String
jobNo
;
private
String
jobNo
;
/**
* docNo String 否 单据号,备注:如果出库类型为3,4则填写预留单号,必填,其他非必填
*/
private
String
docNo
;
}
}
src/main/java/com/neotel/smfcore/hikvision/bean/api/HikApiRequest.java
查看文件 @
cffc76c
...
@@ -13,8 +13,23 @@ import java.util.Map;
...
@@ -13,8 +13,23 @@ import java.util.Map;
@NoArgsConstructor
@NoArgsConstructor
public
class
HikApiRequest
implements
Serializable
{
public
class
HikApiRequest
implements
Serializable
{
public
HikApiRequest
(
int
apiType
,
String
url
,
String
key
,
String
secret
,
RequestParam
param
){
this
.
apiType
=
apiType
;
this
.
url
=
url
;
this
.
key
=
key
;
this
.
secret
=
secret
;
this
.
param
=
param
;
this
.
createTime
=
new
Date
();
this
.
updatetime
=
new
Date
();
}
/**
/**
* 消息类型
* 消息类型
* 2=7.2转储单入库过账接口
* 3=7.3排程发料过账接口
* 5=7.5 入库上架过账接口
* 6=7.6 出库下架过账接口
* 11=7.11订单发料完成通知接口
*/
*/
private
int
apiType
=
0
;
private
int
apiType
=
0
;
...
@@ -43,6 +58,17 @@ public class HikApiRequest implements Serializable {
...
@@ -43,6 +58,17 @@ public class HikApiRequest implements Serializable {
*/
*/
private
Date
createTime
;
private
Date
createTime
;
/**
* 最后更新时间
*/
private
Date
updatetime
;
/**
* 最后一次接口返回值
*/
private
ResponseParam
responseParam
;
public
String
getParamJson
(){
public
String
getParamJson
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"reqCode"
,
param
.
getReqCode
());
params
.
put
(
"reqCode"
,
param
.
getReqCode
());
...
@@ -52,4 +78,8 @@ public class HikApiRequest implements Serializable {
...
@@ -52,4 +78,8 @@ public class HikApiRequest implements Serializable {
String
jsonStr
=
JsonUtil
.
toJsonStr
(
params
);
String
jsonStr
=
JsonUtil
.
toJsonStr
(
params
);
return
jsonStr
;
return
jsonStr
;
}
}
public
String
getParamDataStr
(){
return
JsonUtil
.
toJsonStr
(
param
.
getData
());
}
}
}
src/main/java/com/neotel/smfcore/hikvision/util/HttpHelper.java
查看文件 @
cffc76c
...
@@ -72,10 +72,16 @@ public class HttpHelper {
...
@@ -72,10 +72,16 @@ public class HttpHelper {
log
.
info
(
"["
+
url
+
"]["
+
key
+
"]["
+
secret
+
"]发送 "
+
jsonStr
+
",返回值:"
+
result
);
log
.
info
(
"["
+
url
+
"]["
+
key
+
"]["
+
secret
+
"]发送 "
+
jsonStr
+
",返回值:"
+
result
);
}
}
return
responseInfo
;
return
responseInfo
;
}
catch
(
Exception
e
)
{
}
catch
(
ApiException
ex
){
log
.
error
(
"["
+
url
+
"]["
+
key
+
"]["
+
secret
+
"]发送 "
+
jsonStr
+
",出错:"
,
ex
);
return
new
ResponseParam
(
param
.
getReqCode
(),-
1
,
ex
.
getMessage
(),
ex
);
}
catch
(
Exception
e
)
{
log
.
error
(
"["
+
url
+
"]["
+
key
+
"]["
+
secret
+
"]发送 "
+
jsonStr
+
",出错:"
,
e
);
log
.
error
(
"["
+
url
+
"]["
+
key
+
"]["
+
secret
+
"]发送 "
+
jsonStr
+
",出错:"
,
e
);
return
new
ResponseParam
(
param
.
getReqCode
(),-
1
,
e
.
getMessage
(),
e
);
}
}
return
null
;
}
}
public
static
String
postJson
(
String
url
,
Map
<
String
,
Object
>
params
,
String
key
,
String
secret
)
throws
ApiException
{
public
static
String
postJson
(
String
url
,
Map
<
String
,
Object
>
params
,
String
key
,
String
secret
)
throws
ApiException
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论