|
@@ -1,6 +1,5 @@
|
|
|
package com.sooka.sponest.monitor.dahua.service.impl;
|
|
|
|
|
|
-import com.alibaba.druid.support.json.JSONUtils;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
|
|
import com.dahuatech.hutool.core.codec.Base64;
|
|
@@ -28,6 +27,7 @@ import com.sooka.sponest.monitor.camera.domain.CentermonitorTCameraStateLog;
|
|
|
import com.sooka.sponest.monitor.camera.mapper.CentermonitorTCameraMapper;
|
|
|
import com.sooka.sponest.monitor.camera.service.ICentermonitorTCameraService;
|
|
|
import com.sooka.sponest.monitor.dahua.domain.CenterdataTAttach;
|
|
|
+import com.sooka.sponest.monitor.dahua.domain.DaHuaMp4VO;
|
|
|
import com.sooka.sponest.monitor.dahua.domain.PlayBackProperties;
|
|
|
import com.sooka.sponest.monitor.dahua.service.DahuaService;
|
|
|
import com.sooka.sponest.monitor.dahua.utils.HttpEnum;
|
|
@@ -38,13 +38,16 @@ import com.sooka.sponest.monitor.remoteapi.service.center.event.RemoteEventBaseS
|
|
|
import com.sooka.sponest.monitor.remoteapi.service.center.event.domain.CentereventTDownloads;
|
|
|
import com.sooka.sponest.monitor.remoteapi.service.center.file.RemoteFileBaseService;
|
|
|
import com.sooka.sponest.monitor.util.Mp4ParserUtils;
|
|
|
+import com.sooka.sponest.monitor.util.VideoUrlFetcher;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.crypto.Cipher;
|
|
|
import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.security.KeyFactory;
|
|
|
import java.security.interfaces.RSAPublicKey;
|
|
@@ -53,6 +56,8 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.sooka.sponest.monitor.util.Mp4ParserUtils.convertUrlToMultipartFile;
|
|
|
+
|
|
|
@Service
|
|
|
public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
|
|
@@ -151,6 +156,7 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
redisService.expire("DH_TOKEN", 60 * 60 * 2 - 60);
|
|
|
return token;
|
|
|
} catch (Exception e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
return token;
|
|
|
}
|
|
|
}
|
|
@@ -508,7 +514,6 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 获取执法记录仪token
|
|
|
*/
|
|
@@ -551,9 +556,9 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
}
|
|
|
|
|
|
public AjaxResult getPlaybackByTime(String properties) {
|
|
|
- log.info("**GetPlaybackByTime->"+new Date()+"->start**");
|
|
|
+ log.info("**GetPlaybackByTime->" + new Date() + "->start**");
|
|
|
List<PlayBackProperties> propertiesList = JSON.parseArray(properties, PlayBackProperties.class);
|
|
|
- for (PlayBackProperties property: propertiesList) {
|
|
|
+ for (PlayBackProperties property : propertiesList) {
|
|
|
//下载并上传视频
|
|
|
AjaxResult ajaxResult = getPlaybackByTime(property);
|
|
|
//将视频下载结果保存至事件中心
|
|
@@ -566,7 +571,7 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
downloads.setReason(ajaxResult.get("msg").toString());
|
|
|
eventBaseService.downloads(downloads);
|
|
|
}
|
|
|
- log.info("**GetPlaybackByTime->"+new Date()+"->end**");
|
|
|
+ log.info("**GetPlaybackByTime->" + new Date() + "->end**");
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
@@ -667,10 +672,10 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
//清空文件夹
|
|
|
File folder = new File(dssFileDownloadUrl);
|
|
|
File[] files = folder.listFiles();
|
|
|
- if (files != null){
|
|
|
+ if (files != null) {
|
|
|
for (File f : files) {
|
|
|
boolean b = f.delete();
|
|
|
- if(!b) log.error("getPlaybackByTime => 文件删除失败!");
|
|
|
+ if (!b) log.error("getPlaybackByTime => 文件删除失败!");
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -678,14 +683,13 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
}
|
|
|
return AjaxResult.success("文件下载成功", sysFileR.getData().getUrl());
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
log.error("getPlaybackByTime-查询大华录像-{}, result => {}", "录像回放接口报错", JSONUtil.toJsonStr(QueryRecordsResult));
|
|
|
return AjaxResult.error("录像回放接口报错", QueryRecordsResult.getStr("desc"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
public JSONObject IccHttpHttpRequest(String url, Method method, String param, String token, String action) {
|
|
|
log.info("----开始执行----{}------请求参数:{}", action, JSONUtil.toJsonStr(param));
|
|
|
String prBody;
|
|
@@ -775,11 +779,11 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * 大华联动调转摄像头指向
|
|
|
- *
|
|
|
- * @author 韩福成
|
|
|
- * @date 2025/8/19 上午9:26
|
|
|
- */
|
|
|
+ * 大华联动调转摄像头指向
|
|
|
+ *
|
|
|
+ * @author 韩福成
|
|
|
+ * @date 2025/8/19 上午9:26
|
|
|
+ */
|
|
|
public AjaxResult cameraSteering(Double lng, Double lat, List<String> list) {
|
|
|
List<String> creamList = centermonitorTCameraMapper.getCreamList(list);
|
|
|
if (CollectionUtils.isEmpty(creamList)) {
|
|
@@ -806,4 +810,36 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public AjaxResult reportMp4ToFileService(DaHuaMp4VO mp4VO) throws IOException, ClientException {
|
|
|
+ String token = dahuaService.getToken();
|
|
|
+ String baseUrl = host+"/evo-apigw/evo-gmai/1.4.0/ai/history/task/getAlarmVideo";
|
|
|
+ String downloadUrl = host+"/evo-apigw/evo-oss/";
|
|
|
+ //发送get请求, 获取MP4地址.
|
|
|
+ String videoUrl = downloadUrl + VideoUrlFetcher.getVideoUrl(baseUrl, mp4VO.getChnnaleCode(), mp4VO.getAlarmCode(), token) + "?token="+token;
|
|
|
+ try {
|
|
|
+ //上传到文件服务器
|
|
|
+ R<SysFile> sysFileR = fileBaseService.upload(convertUrlToMultipartFile(videoUrl));
|
|
|
+ if (sysFileR.getCode() == 200) {
|
|
|
+ log.info("getPlaybackByTime => 文件上传成功!{}", sysFileR.getData().getUrl());
|
|
|
+ //保存到数据中心
|
|
|
+ /*CenterdataTAttach attach = new CenterdataTAttach();
|
|
|
+ attach.setBusId(mp4VO.getLogId());
|
|
|
+ attach.setAttachPath(sysFileR.getData().getUrl());
|
|
|
+ attach.setFileName(sysFileR.getData().getName());
|
|
|
+ attach.setBusSource("PC");
|
|
|
+ attach.setFileType("video");
|
|
|
+ dataBaseService.insertAttach(attach);*/
|
|
|
+ } else {
|
|
|
+ log.info("getPlaybackByTime => 文件上传失败!{}", sysFileR.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ return AjaxResult.success("下载成功");
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|