bug修复
This commit is contained in:
parent
39bdb7c996
commit
d5151f0081
@ -78,7 +78,7 @@ public class HikvisionCall {
|
|||||||
List<HikvisionRequestRetry> hikvisionRequestRetries = hikvisionRequestRetryMapper.selectList(new LambdaQueryWrapper<HikvisionRequestRetry>()
|
List<HikvisionRequestRetry> hikvisionRequestRetries = hikvisionRequestRetryMapper.selectList(new LambdaQueryWrapper<HikvisionRequestRetry>()
|
||||||
.lt(HikvisionRequestRetry::getRequestNum, 4));
|
.lt(HikvisionRequestRetry::getRequestNum, 4));
|
||||||
for (HikvisionRequestRetry retry : hikvisionRequestRetries) {
|
for (HikvisionRequestRetry retry : hikvisionRequestRetries) {
|
||||||
HikvisionUtil.doPost(retry.getHost(), retry.getPath(), retry.getBody(), null, retry.getAppKey(), retry.getAppSecret());
|
HikvisionUtil.doPost(retry.getHost(), retry.getPath(), retry.getBody(), null, retry.getAppKey(), retry.getAppSecret(), retry.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface HikvisionRequestRetryMapper extends BaseMapper<HikvisionRequestRetry> {
|
public interface HikvisionRequestRetryMapper extends BaseMapper<HikvisionRequestRetry> {
|
||||||
|
|
||||||
|
Integer addOne(HikvisionRequestRetry entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.zhgd.xmgl.modules.basicdata.mapper.HikvisionRequestRetryMapper">
|
<mapper namespace="com.zhgd.xmgl.modules.basicdata.mapper.HikvisionRequestRetryMapper">
|
||||||
|
<select id="addOne" resultType="java.lang.Integer">
|
||||||
|
update hikvision_request_retry set request_num
|
||||||
|
= request_num + 1 where id = #{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@ -32,13 +32,14 @@ public class HikvisionUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String doPost(String host, String path, String body, Map<String, String> querys, String appKey, String appSecret) {
|
public static String doPost(String host, String path, String body, Map<String, String> querys, String appKey, String appSecret) {
|
||||||
return doPost(host, path, body, querys, appKey, appSecret, false);
|
return doPost(host, path, body, querys, appKey, appSecret, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String doPost(String host, String path, String body, Map<String, String> querys, String appKey, String appSecret, boolean isRetry) {
|
public static String doPost(String host, String path, String body, Map<String, String> querys, String appKey, String appSecret, Long hikvisionRequestRetryId) {
|
||||||
log.info("HikvisionUtil#doPost.url:{}", host + path);
|
log.info("HikvisionUtil#doPost.url:{}", host + path);
|
||||||
log.info("HikvisionUtil#doPost.body:{}", body);
|
log.info("HikvisionUtil#doPost.body:{}", body);
|
||||||
String responseStr = null;
|
String responseStr = null;
|
||||||
|
boolean isException = false;
|
||||||
try {
|
try {
|
||||||
Map<String, String> headers = new HashMap();
|
Map<String, String> headers = new HashMap();
|
||||||
headers.put("Accept", "*/*");
|
headers.put("Accept", "*/*");
|
||||||
@ -51,8 +52,9 @@ public class HikvisionUtil {
|
|||||||
responseStr = getResponseResult(response);
|
responseStr = getResponseResult(response);
|
||||||
log.info("HikvisionUtil#doPost.getResponseResult:{}", responseStr);
|
log.info("HikvisionUtil#doPost.getResponseResult:{}", responseStr);
|
||||||
} catch (Exception var10) {
|
} catch (Exception var10) {
|
||||||
|
isException = true;
|
||||||
var10.printStackTrace();
|
var10.printStackTrace();
|
||||||
if (!isRetry) {
|
if (hikvisionRequestRetryId == null) {
|
||||||
HikvisionRequestRetry entity = new HikvisionRequestRetry();
|
HikvisionRequestRetry entity = new HikvisionRequestRetry();
|
||||||
entity.setUrl(host + path);
|
entity.setUrl(host + path);
|
||||||
entity.setHost(host);
|
entity.setHost(host);
|
||||||
@ -65,8 +67,15 @@ public class HikvisionUtil {
|
|||||||
entity.setAppKey(appKey);
|
entity.setAppKey(appKey);
|
||||||
entity.setAppSecret(appSecret);
|
entity.setAppSecret(appSecret);
|
||||||
hikvisionRequestRetryMapper.insert(entity);
|
hikvisionRequestRetryMapper.insert(entity);
|
||||||
|
} else {
|
||||||
|
HikvisionRequestRetry entity = new HikvisionRequestRetry();
|
||||||
|
entity.setId(hikvisionRequestRetryId);
|
||||||
|
hikvisionRequestRetryMapper.addOne(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!isException && hikvisionRequestRetryId != null) {
|
||||||
|
hikvisionRequestRetryMapper.deleteById(hikvisionRequestRetryId);
|
||||||
|
}
|
||||||
return responseStr;
|
return responseStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user