|
@@ -42,12 +42,10 @@ 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;
|
|
@@ -811,35 +809,49 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public AjaxResult reportMp4ToFileService(DaHuaMp4VO mp4VO) throws IOException, ClientException {
|
|
|
+ public AjaxResult reportMp4ToFileService(List<DaHuaMp4VO> mp4VOList) {
|
|
|
+ if(mp4VOList.isEmpty()){
|
|
|
+ return AjaxResult.error("请求参数为空!");
|
|
|
+ }
|
|
|
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());
|
|
|
- }
|
|
|
+ String baseUrl = host + "/evo-apigw/evo-gmai/1.4.0/ai/history/task/getAlarmVideo";
|
|
|
+ String downloadUrl = host + "/evo-apigw/evo-oss/";
|
|
|
|
|
|
- return AjaxResult.success("下载成功");
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return AjaxResult.error(e.getMessage());
|
|
|
- }
|
|
|
- }
|
|
|
+ mp4VOList.forEach(mp4VO -> {
|
|
|
+ //发送get请求, 获取MP4地址.
|
|
|
+ try {
|
|
|
+ String videoUrl = downloadUrl + VideoUrlFetcher.getVideoUrl(baseUrl, mp4VO.getChnnaleCode(), mp4VO.getAlarmCode(), token) + "?token=" + token;
|
|
|
+ //上传到文件服务器
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ //将视频下载结果保存至事件中心
|
|
|
+ CentereventTDownloads downloads = new CentereventTDownloads();
|
|
|
+ downloads.setId(mp4VO.getId());
|
|
|
+ if (sysFileR.getCode() == HttpStatus.SUCCESS) {
|
|
|
+ downloads.setPath(sysFileR.getData().getUrl());
|
|
|
+ }
|
|
|
+ downloads.setFlag(String.valueOf(sysFileR.getCode()));
|
|
|
+ downloads.setReason(sysFileR.getMsg());
|
|
|
+ eventBaseService.downloads(downloads);
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("alarmCode={}, chnnaleCode={}, 下载视频失败,{}", mp4VO.getAlarmCode(), mp4VO.getChnnaleCode(), e.getMessage());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return AjaxResult.success("下载成功");
|
|
|
+ }
|
|
|
|
|
|
}
|