bug修复
This commit is contained in:
parent
989c13a614
commit
78f235d6db
@ -14,7 +14,6 @@ import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.base.*;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.HikvisionRequestRetry;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.HikvisionRequestRetryMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.impl.NoticeServiceImpl;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarCamera;
|
||||
import com.zhgd.xmgl.modules.car.entity.CarInfo;
|
||||
@ -94,9 +93,6 @@ public class HikvisionCall {
|
||||
private CarPassRecordMapper carPassRecordMapper;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private HikvisionRequestRetryMapper hikvisionRequestRetryMapper;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private CarTypeMapper carTypeMapper;
|
||||
@Autowired
|
||||
@Lazy
|
||||
@ -268,19 +264,6 @@ public class HikvisionCall {
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 海康请求失败重试定时
|
||||
*/
|
||||
@Scheduled(cron = "4 0 0 * * ?")
|
||||
@PostMapping(value = "/failRetry")
|
||||
public void failRetry() {
|
||||
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(), retry.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "按事件类型订阅事件", notes = "按事件类型订阅事件", httpMethod = "POST")
|
||||
@PostMapping(value = "/subscribeEvent")
|
||||
public Result subscribeEvent(@ApiIgnore @RequestBody SubscribeEventQo qo) {
|
||||
@ -1374,7 +1357,11 @@ public class HikvisionCall {
|
||||
return;
|
||||
}
|
||||
HikvisionOrganization hikvisionOrganization = getHikvisionOrganization(enterpriseInfo);
|
||||
editOrgFromHttp(project, hikvisionOrganization);
|
||||
if (existOrg(project, String.valueOf(enterpriseInfo.getId()))) {
|
||||
editOrgFromHttp(project, hikvisionOrganization);
|
||||
} else {
|
||||
addOrgFromHttp(project, hikvisionOrganization);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1434,7 +1421,11 @@ public class HikvisionCall {
|
||||
return;
|
||||
}
|
||||
HikvisionOrganization hikvisionOrganization = getHikvisionOrganization(teamInfo);
|
||||
editOrgFromHttp(project, hikvisionOrganization);
|
||||
if (existOrg(project, String.valueOf(teamInfo.getId()))) {
|
||||
editOrgFromHttp(project, hikvisionOrganization);
|
||||
} else {
|
||||
addOrgFromHttp(project, hikvisionOrganization);
|
||||
}
|
||||
}
|
||||
|
||||
private void editOrgFromHttp(Project project, HikvisionOrganization hikvisionOrganization) {
|
||||
@ -1512,7 +1503,12 @@ public class HikvisionCall {
|
||||
return;
|
||||
}
|
||||
HikvisionOrganization hikvisionOrganization = getHikvisionOrganization(departmentInfo);
|
||||
editOrgFromHttp(project, hikvisionOrganization);
|
||||
if (existOrg(project, String.valueOf(departmentInfo.getId()))) {
|
||||
editOrgFromHttp(project, hikvisionOrganization);
|
||||
} else {
|
||||
addOrgFromHttp(project, hikvisionOrganization);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1560,6 +1556,44 @@ public class HikvisionCall {
|
||||
HikvisionUtil.doPost(host, path, body, null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取组织列表v2
|
||||
*
|
||||
* @param project
|
||||
* @param orgIndex
|
||||
*/
|
||||
public String getOrgV2(Project project, String orgIndex) {
|
||||
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
||||
return null;
|
||||
}
|
||||
final String ARTEMIS_PATH = "/artemis";
|
||||
final String path = ARTEMIS_PATH + "/api/resource/v2/org/advance/orgList";
|
||||
String host = "https://" + project.getArtemisConfigHost();
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("pageNo", 1);
|
||||
jo.put("pageSize", 100);
|
||||
jo.put("orgIndexCodes", orgIndex);
|
||||
String body = jo.toJSONString();
|
||||
String rs = HikvisionUtil.doPost(host, path, body, null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
||||
if (StringUtils.isBlank(rs)) {
|
||||
throw new OpenAlertException("海康网络超时");
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织存在?
|
||||
*
|
||||
* @param project
|
||||
* @param orgIndex
|
||||
* @return
|
||||
*/
|
||||
public boolean existOrg(Project project, String orgIndex) {
|
||||
String rs = getOrgV2(project, orgIndex);
|
||||
JSONObject jo = HikvisionUtil.getJSONObjectData(rs);
|
||||
return jo.getJSONArray("list").size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取停车库列表
|
||||
*
|
||||
|
||||
@ -20,7 +20,6 @@ import java.io.Serializable;
|
||||
@Data
|
||||
@TableName("dictionaries_record")
|
||||
@ApiModel(value = "DictionariesRecord实体类", description = "DictionariesRecord")
|
||||
@Deprecated
|
||||
public class DictionariesRecord implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@ -10,7 +10,6 @@ import com.hikvision.artemis.sdk.Response;
|
||||
import com.hikvision.artemis.sdk.constant.Constants;
|
||||
import com.hikvision.artemis.sdk.enums.Method;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.HikvisionRequestRetry;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.HikvisionRequestRetryMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -26,13 +25,6 @@ import java.util.Objects;
|
||||
@Component
|
||||
public class HikvisionUtil {
|
||||
|
||||
private static HikvisionRequestRetryMapper hikvisionRequestRetryMapper;
|
||||
|
||||
@Autowired
|
||||
public void setHikvisionRequestRetryMapper(HikvisionRequestRetryMapper hikvisionRequestRetryMapper) {
|
||||
HikvisionUtil.hikvisionRequestRetryMapper = hikvisionRequestRetryMapper;
|
||||
}
|
||||
|
||||
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, null);
|
||||
}
|
||||
@ -57,27 +49,6 @@ public class HikvisionUtil {
|
||||
} catch (Exception var10) {
|
||||
isException = true;
|
||||
log.error("HikvisionUtil#doPost.error:{}", var10.getMessage(), var10);
|
||||
if (hikvisionRequestRetryId == null) {
|
||||
HikvisionRequestRetry entity = new HikvisionRequestRetry();
|
||||
entity.setUrl(host + path);
|
||||
entity.setHost(host);
|
||||
entity.setPath(path);
|
||||
entity.setMethod(2);
|
||||
entity.setParam(JSON.toJSONString(querys));
|
||||
entity.setBody(body);
|
||||
entity.setLastResult(null);
|
||||
entity.setRequestNum(1);
|
||||
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;
|
||||
}
|
||||
@ -86,7 +57,6 @@ public class HikvisionUtil {
|
||||
String responseStr = null;
|
||||
int statusCode = response.getStatusCode();
|
||||
if (!String.valueOf(statusCode).startsWith("2") && !String.valueOf(statusCode).startsWith("3")) {
|
||||
//String msg = response.getErrorMessage();
|
||||
responseStr = response.getBody();
|
||||
} else {
|
||||
responseStr = response.getBody();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user