Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 221db772
由
LN
编写于
2022-05-17 17:04:22 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
异常接口发送成功后自动删除。
1 个父辈
4045ca25
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
9 行删除
src/main/java/com/neotel/smfcore/core/hik/rest/InterfaceExceptionController.java
src/main/java/com/neotel/smfcore/hikvision/HikApiCache.java
src/main/java/com/neotel/smfcore/core/hik/rest/InterfaceExceptionController.java
查看文件 @
221db77
...
@@ -117,6 +117,14 @@ public class InterfaceExceptionController {
...
@@ -117,6 +117,14 @@ public class InterfaceExceptionController {
if
(
request
==
null
)
{
if
(
request
==
null
)
{
throw
new
ValidateException
(
"smfcore.error.interfaceEx.invalid"
,
"未找到异常接口{0}"
,
new
String
[]{
reqCode
});
throw
new
ValidateException
(
"smfcore.error.interfaceEx.invalid"
,
"未找到异常接口{0}"
,
new
String
[]{
reqCode
});
}
}
//如果上次返回成功,直接删除
if
(
request
.
getResponseParam
().
getCode
().
equals
(
0
)){
log
.
info
(
"重发接口["
+
reqCode
+
"]时发现上次返回值为0,删除接口异常"
);
HikApiCache
.
removeFailedRequest
(
request
);
throw
new
ValidateException
(
"smfcore.error.interfaceEx.invalid"
,
"此接口已返回成功,不需要重发"
,
new
String
[]{
reqCode
});
}
ResponseParam
responseParam
=
HikApiCache
.
reSendRequest
(
request
);
ResponseParam
responseParam
=
HikApiCache
.
reSendRequest
(
request
);
if
(
responseParam
.
getCode
().
equals
(
0
))
{
if
(
responseParam
.
getCode
().
equals
(
0
))
{
...
...
src/main/java/com/neotel/smfcore/hikvision/HikApiCache.java
查看文件 @
221db77
...
@@ -21,18 +21,18 @@ public class HikApiCache {
...
@@ -21,18 +21,18 @@ public class HikApiCache {
private
static
DataCache
dataCache
;
private
static
DataCache
dataCache
;
@Autowired
@Autowired
public
void
setDataCache
(
DataCache
dataCache
){
public
void
setDataCache
(
DataCache
dataCache
)
{
HikApiCache
.
dataCache
=
dataCache
;
HikApiCache
.
dataCache
=
dataCache
;
}
}
/**
/**
* 需要重发的指令列表
* 需要重发的指令列表
*/
*/
private
static
Map
<
String
,
HikApiRequest
>
failedRequestMap
=
new
HashMap
<>();
private
static
Map
<
String
,
HikApiRequest
>
failedRequestMap
=
new
HashMap
<>();
private
static
boolean
isProcessTimer
=
false
;
private
static
boolean
isProcessTimer
=
false
;
@PostConstruct
@PostConstruct
public
void
Init
(){
public
void
Init
()
{
initApiRequestMap
();
initApiRequestMap
();
}
}
/**
/**
...
@@ -63,10 +63,10 @@ public class HikApiCache {
...
@@ -63,10 +63,10 @@ public class HikApiCache {
}
}
}
}
public
static
List
<
HikApiRequest
>
getAllRequestList
(){
public
static
List
<
HikApiRequest
>
getAllRequestList
()
{
return
new
ArrayList
<>(
failedRequestMap
.
values
());
return
new
ArrayList
<>(
failedRequestMap
.
values
());
}
}
public
static
HikApiRequest
getRequest
(
String
req
){
public
static
HikApiRequest
getRequest
(
String
req
)
{
return
failedRequestMap
.
get
(
req
);
return
failedRequestMap
.
get
(
req
);
}
}
...
@@ -93,11 +93,10 @@ public class HikApiCache {
...
@@ -93,11 +93,10 @@ public class HikApiCache {
}
}
/**
/**
* 获取失败列表,进行定时发送
* 获取失败列表,进行定时发送
*/
*/
public
static
void
sendFailedRequest
()
{
public
static
void
sendFailedRequest
()
{
if
(
failedRequestMap
==
null
)
{
if
(
failedRequestMap
==
null
)
{
initApiRequestMap
();
initApiRequestMap
();
...
@@ -118,7 +117,7 @@ public class HikApiCache {
...
@@ -118,7 +117,7 @@ public class HikApiCache {
}
}
public
static
ResponseParam
reSendRequest
(
HikApiRequest
apiRequest
)
{
public
static
ResponseParam
reSendRequest
(
HikApiRequest
apiRequest
)
{
ResponseParam
responseParam
=
null
;
ResponseParam
responseParam
=
null
;
try
{
try
{
String
interName
=
"Hik 接口"
+
apiRequest
.
getApiType
()
+
" 重发:"
;
String
interName
=
"Hik 接口"
+
apiRequest
.
getApiType
()
+
" 重发:"
;
responseParam
=
HttpHelper
.
post
(
apiRequest
);
responseParam
=
HttpHelper
.
post
(
apiRequest
);
...
@@ -134,6 +133,7 @@ public class HikApiCache {
...
@@ -134,6 +133,7 @@ public class HikApiCache {
if
(
responseParam
.
getCode
().
equals
(
0
))
{
if
(
responseParam
.
getCode
().
equals
(
0
))
{
log
.
info
(
interName
+
",发送成功,删除接口异常,返回"
+
JsonUtil
.
toJsonStr
(
responseParam
));
log
.
info
(
interName
+
",发送成功,删除接口异常,返回"
+
JsonUtil
.
toJsonStr
(
responseParam
));
removeFailedRequest
(
apiRequest
);
removeFailedRequest
(
apiRequest
);
return
responseParam
;
}
else
{
}
else
{
log
.
info
(
interName
+
",返回"
+
JsonUtil
.
toJsonStr
(
responseParam
));
log
.
info
(
interName
+
",返回"
+
JsonUtil
.
toJsonStr
(
responseParam
));
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论