|
@@ -1,13 +1,18 @@
|
|
|
package com.sooka.sponest.event.centereventteventcatalogue.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.dahuatech.icc.exception.ClientException;
|
|
|
+import com.dahuatech.icc.oauth.http.IccHttpHttpRequest;
|
|
|
import com.ruoyi.common.core.utils.DateUtils;
|
|
|
import com.ruoyi.common.core.utils.SpringUtils;
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
import com.ruoyi.common.core.utils.uuid.IdUtils;
|
|
|
+import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
import com.sooka.sponest.event.centereventtdeptevent.domain.CentereventDeptEvent;
|
|
|
import com.sooka.sponest.event.centereventtdeptevent.service.ICentereventDeptEventService;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.CentereventTEventcatalogue;
|
|
|
+import com.sooka.sponest.event.centereventteventcatalogue.domain.DaHuaEventBO;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.dahua.DaHuaFireEventVO;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.dahua.DaHuaOtherEventVO;
|
|
|
import com.sooka.sponest.event.centereventteventcatalogue.domain.dahua.PictureVO;
|
|
@@ -22,17 +27,18 @@ import com.sooka.sponest.event.centereventtfirelog.domain.CentereventTFireLog;
|
|
|
import com.sooka.sponest.event.centereventtfirelog.service.ICentereventTFireLogService;
|
|
|
import com.sooka.sponest.event.remoteapi.RemoteDataService;
|
|
|
import com.sooka.sponest.event.remoteapi.domain.CenterdataTAttach;
|
|
|
+import com.sooka.sponest.event.utils.RemoteApiUtil;
|
|
|
import com.sooka.sponest.monitor.api.RemoteMonitorService;
|
|
|
import com.sooka.sponest.monitor.api.domain.CenterdataTAidevicedept;
|
|
|
import com.sooka.sponest.monitor.api.domain.CenterdataTCamera;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static com.ruoyi.common.core.utils.DateUtils.YYYY_MM_DD_HH_MM_SS;
|
|
|
import static com.sooka.sponest.event.utils.EventConstants.*;
|
|
@@ -57,6 +63,13 @@ public class AlarmEventServiceImpl implements AlarmEventService {
|
|
|
@Autowired
|
|
|
private ICentereventTEventtypeService centereventTEventtypeService;
|
|
|
|
|
|
+ @Value("${sooka.event.detail.url:}")
|
|
|
+ private String detailUrl;
|
|
|
+
|
|
|
+ private static final String HEADER_KEY = "Authorization";
|
|
|
+
|
|
|
+ private static final String HEADER_VALUE = "Bearer ";
|
|
|
+
|
|
|
static final String ERROR_MSG_CHANNEL = "无法匹配相关设备!通道编号为:{}";
|
|
|
|
|
|
static final String ERROR_MSG_DEPT = "无法匹配相关部门!摄像头编号为:{}";
|
|
@@ -253,6 +266,12 @@ public class AlarmEventServiceImpl implements AlarmEventService {
|
|
|
String logId = this.insertEventLog(centereventTEventcatalogue);
|
|
|
if (StringUtils.isNotBlank(daHuaFireEventVO.getInfo().getPicture())) {
|
|
|
String[] pictures = daHuaFireEventVO.getInfo().getPicture().split(",");
|
|
|
+ //图片结合中应由热感和高清两张图片
|
|
|
+ if (pictures.length != 2) {
|
|
|
+ //延迟获取图片
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
for (String picture : pictures) {
|
|
|
CenterdataTAttach tAttach = new CenterdataTAttach();
|
|
|
tAttach.setBusId(logId);
|
|
@@ -348,4 +367,46 @@ public class AlarmEventServiceImpl implements AlarmEventService {
|
|
|
}
|
|
|
return centereventTEventcatalogue.getEventCode() + "_" + eventtype.getEventTypeName();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updateFireEventImage(DaHuaEventBO eventBO) throws ClientException {
|
|
|
+ //通过eventCode查询详情
|
|
|
+ CentereventTEventcatalogue centereventTEventcatalogue = centereventTEventcatalogueService.selectCentereventTEventcatalogueByEventCode(eventBO.getEventCode());
|
|
|
+ //确认为 火情事件 并且 状态为上报
|
|
|
+ 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
|
|
|
+ String token = RemoteApiUtil.getInstance().getToken();//3c001989-3ba8-48ff-96f4-c2963455aa6e
|
|
|
+ //创建请求实体 并 发送请求
|
|
|
+ String prBody = new IccHttpHttpRequest(detailUrl + url).header(HEADER_KEY, HEADER_VALUE + token).execute();
|
|
|
+ //打印响应结果
|
|
|
+ JSONObject responseData = JSON.parseObject(prBody);
|
|
|
+ if(responseData.getBoolean("success")){
|
|
|
+ ArrayList<String> pictures = responseData.getJSONObject("data").getObject("pictures", ArrayList.class);
|
|
|
+ //删除旧附件
|
|
|
+ remoteDataService.deleteAttchByBusId(eventBO.getLogId());
|
|
|
+ //添加新附件
|
|
|
+ List<CenterdataTAttach> attachList = new ArrayList<>();
|
|
|
+ for (String picture : pictures) {
|
|
|
+ CenterdataTAttach tAttach = new CenterdataTAttach();
|
|
|
+ tAttach.setBusId(eventBO.getLogId());
|
|
|
+ tAttach.setAttachPath(picture);
|
|
|
+ tAttach.setBusIndx(BUS_INDEX_1);
|
|
|
+ tAttach.setBusSource("DH_1");
|
|
|
+ tAttach.setFileType(FILE_TYPE_1);
|
|
|
+ attachList.add(tAttach);
|
|
|
+ }
|
|
|
+ JSONObject requestObj = new JSONObject();
|
|
|
+ requestObj.put("attachList", attachList);
|
|
|
+ return remoteDataService.insertAttachToArray(requestObj.toJSONString());
|
|
|
+ }else{
|
|
|
+ logger.error("请求结果:{}", prBody);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|