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>()
|
||||
.lt(HikvisionRequestRetry::getRequestNum, 4));
|
||||
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
|
||||
public interface HikvisionRequestRetryMapper extends BaseMapper<HikvisionRequestRetry> {
|
||||
|
||||
Integer addOne(HikvisionRequestRetry entity);
|
||||
}
|
||||
|
||||
@ -1,4 +1,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">
|
||||
<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>
|
||||
|
||||
@ -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) {
|
||||
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.body:{}", body);
|
||||
String responseStr = null;
|
||||
boolean isException = false;
|
||||
try {
|
||||
Map<String, String> headers = new HashMap();
|
||||
headers.put("Accept", "*/*");
|
||||
@ -51,8 +52,9 @@ public class HikvisionUtil {
|
||||
responseStr = getResponseResult(response);
|
||||
log.info("HikvisionUtil#doPost.getResponseResult:{}", responseStr);
|
||||
} catch (Exception var10) {
|
||||
isException = true;
|
||||
var10.printStackTrace();
|
||||
if (!isRetry) {
|
||||
if (hikvisionRequestRetryId == null) {
|
||||
HikvisionRequestRetry entity = new HikvisionRequestRetry();
|
||||
entity.setUrl(host + path);
|
||||
entity.setHost(host);
|
||||
@ -65,8 +67,15 @@ public class HikvisionUtil {
|
||||
entity.setAppKey(appKey);
|
||||
entity.setAppSecret(appSecret);
|
||||
hikvisionRequestRetryMapper.insert(entity);
|
||||
} else {
|
||||
HikvisionRequestRetry entity = new HikvisionRequestRetry();
|
||||
entity.setId(hikvisionRequestRetryId);
|
||||
hikvisionRequestRetryMapper.addOne(entity);
|
||||
}
|
||||
}
|
||||
if (!isException && hikvisionRequestRetryId != null) {
|
||||
hikvisionRequestRetryMapper.deleteById(hikvisionRequestRetryId);
|
||||
}
|
||||
return responseStr;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user