|
@@ -63,12 +63,18 @@ public class AlarmEventServiceImpl implements AlarmEventService {
|
|
|
@Autowired
|
|
|
private ICentereventTEventtypeService centereventTEventtypeService;
|
|
|
|
|
|
- @Value("${sooka.event.detail.url:}")
|
|
|
+ @Value("${sooka.dahuaservice.detail:}")
|
|
|
private String detailUrl;
|
|
|
|
|
|
+ @Value("${sooka.clientKey:}")
|
|
|
+ private String clientKey;
|
|
|
+
|
|
|
+ @Value("${sooka.clientValue:}")
|
|
|
+ private String clientValue;
|
|
|
+
|
|
|
private static final String HEADER_KEY = "Authorization";
|
|
|
|
|
|
- private static final String HEADER_VALUE = "Bearer ";
|
|
|
+ private static final String HEADER_VALUE = "bearer ";
|
|
|
|
|
|
static final String ERROR_MSG_CHANNEL = "无法匹配相关设备!通道编号为:{}";
|
|
|
|
|
@@ -377,16 +383,22 @@ public class AlarmEventServiceImpl implements AlarmEventService {
|
|
|
if("1".equals(centereventTEventcatalogue.getEventType()) && "forest_event_status_1".equals(centereventTEventcatalogue.getEventStatusValue())){
|
|
|
//按照指定格式拼接路径
|
|
|
String url = "alarmCode=" + RemoteApiUtil.encodeUrl(eventBO.getAlarmCode()) + "&dbType=" + RemoteApiUtil.encodeUrl(eventBO.getDbType()) + "&alarmDate=" + RemoteApiUtil.encodeUrl(eventBO.getAlarmDate());
|
|
|
- //如果请求参数中携带了大华token则使用;如果没有携带,则请求监控中心获取并拼接token
|
|
|
- String token = (null == eventBO.getToken() || "".equals(eventBO.getToken())) ? HEADER_VALUE + RemoteApiUtil.getInstance().getToken() : eventBO.getToken();//3c001989-3ba8-48ff-96f4-c2963455aa6e
|
|
|
//创建请求实体 并 发送请求
|
|
|
- String prBody = new IccHttpHttpRequest(detailUrl + url).header(HEADER_KEY, token).execute();
|
|
|
- //打印响应结果
|
|
|
+ String prBody = new IccHttpHttpRequest(detailUrl + url)
|
|
|
+ //设置token
|
|
|
+ .header(HEADER_KEY, HEADER_VALUE + RemoteApiUtil.getInstance().getToken())
|
|
|
+ //客户端模式,设置请求头
|
|
|
+ .header(clientKey, clientValue)
|
|
|
+ //发送请求
|
|
|
+ .execute();
|
|
|
+ //打印响应结果cd
|
|
|
JSONObject responseData = JSON.parseObject(prBody);
|
|
|
if(responseData.getBoolean("success")){
|
|
|
ArrayList<String> pictures = responseData.getJSONObject("data").getObject("pictures", ArrayList.class);
|
|
|
- //删除旧附件
|
|
|
- remoteDataService.deleteAttchByBusId(eventBO.getLogId());
|
|
|
+ if(pictures.isEmpty()){
|
|
|
+ logger.error("获取的图片集合为空-----请求结果:{}", prBody);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
//添加新附件
|
|
|
List<CenterdataTAttach> attachList = new ArrayList<>();
|
|
|
for (String picture : pictures) {
|
|
@@ -400,9 +412,10 @@ public class AlarmEventServiceImpl implements AlarmEventService {
|
|
|
}
|
|
|
JSONObject requestObj = new JSONObject();
|
|
|
requestObj.put("attachList", attachList);
|
|
|
+ requestObj.put("busId", eventBO.getLogId());
|
|
|
return remoteDataService.insertAttachToArray(requestObj.toJSONString());
|
|
|
}else{
|
|
|
- logger.error("请求结果:{}", prBody);
|
|
|
+ logger.error("请求远端异常-----请求结果:{}", prBody);
|
|
|
return -1;
|
|
|
}
|
|
|
}else{
|