Commit 3595f5d4 authored by 薄玉虎's avatar 薄玉虎

更新版本:修改获取大华平台录像方式

parent 0da81967
......@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>my-kafka-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
<name>my-kafka-project</name>
<description>my-kafka-project</description>
<properties>
......
......@@ -23,6 +23,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
......@@ -49,7 +54,7 @@ public class WarnPushBaseServer {
// if(!warnPushBase.getAlarmDeviceName().contains("布控球")){
//获取前后五秒时间戳
Date alarmTime = warnPushBase.getAlarmTime();
video = getVideo(warnPushBase.getChannelId(), alarmTime.getTime() / 1000 - 3, alarmTime.getTime() / 1000 + 3,warnPushBase);
video = getVideonew(warnPushBase.getChannelId(), alarmTime.getTime() - 4000, alarmTime.getTime() + 4000,warnPushBase);
// }else{
// video = "http://172.16.20.211:8080/profile/MP4/1001952$1$0$0_1698988966.mp4";
// }
......@@ -141,34 +146,174 @@ public class WarnPushBaseServer {
return "录像错误";
}
public String rtspwh(String channelId, Long startTime, Long endTime) throws ClientException {
public String getVideonew(String channelId, Long startTime, Long endTime,WarnPushBase warnPushBase) {
try {
String fileName;
//获取录像视频流地址 乌海与海南调用方式不同 需要区分 布控球目前都属于乌海矿
if("乌海矿".equals(warnPushBase.getBelong())||warnPushBase.getAlarmDeviceName().contains("布控球")){
fileName = rtspwhnew(channelId, startTime, endTime);
}else if("海南矿".equals(warnPushBase.getBelong())){
fileName = rtsphnnew(channelId, startTime, endTime);
}else{
return "录像错误";
}
//录像视频流转mp4文件
/*final Process[] process = new Process[1];
final String fileName = channelId + "_" + startTime + ".mp4";
new Thread(new Runnable() {
@Override
public void run() {
process[0] = rtspToMP4.StartRecord("F:\\ffmpeg\\ffmpeg-2023-10-29-git-2532e832d2-full_build\\bin\\ffmpeg.exe"
, url, "F:\\ruoyi\\uploadPath\\MP4\\" + fileName);
}
}).start();*/
/*Thread.sleep(6 * 1000);
rtspToMP4.stopRecord(process[0]);*/
return "http://172.16.20.211:8080/profile/MP4/" + fileName;
} catch (ClientException e) {
e.printStackTrace();
}
return "录像错误";
}
public String rtspwhnew(String channelId, Long startTime, Long endTime) throws ClientException {
FileOutputStream outputStream = null;
InputStream inputStream = null;
String fileName=null;
try {
OauthConfigUserPwdInfo oauthConfigUserPwdInfo =
new OauthConfigUserPwdInfo("172.16.51.4","aqpt",
"2faa3446-7e32-4fff-b661-a54d2c4cec7f","system",
"Admin@123");
IccClient iClient = new IccClient(oauthConfigUserPwdInfo);
GeneralRequest generalRequest = new GeneralRequest(oauthConfigUserPwdInfo.getHttpConfigInfo(),
"/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime", Method.POST);
String body =
"{\n" +
" \"data\": {\n" +
" \"channelId\": \"" + channelId + "\",\n" +
" \"recordSource\": \"3\",\n" +
" \"startTime\": \"" + startTime + "\",\n" +
" \"endTime\": \"" + endTime + "\",\n" +
" \"streamType\": \"1\",\n" +
" \"recordType\": \"1\"\n" +
" }\n" +
"}";
generalRequest.body(body);
GeneralResponse response = iClient.doAction(generalRequest, generalRequest.getResponseClass());
String result = response.getResult();
JSONObject obj = JSONUtil.parseObj(response.getResult());
String url = obj.getJSONObject("data").getStr("url");
String token = obj.getJSONObject("data").getStr("token");
String[] parts = url.split("\\|");
return parts[0] + "?token=" + token + "&trackID=0";
IccClient iClient = new IccClient(oauthConfigUserPwdInfo);
String access_token = iClient.getAccessToken().getAccess_token();
Date sdate = new Date(startTime);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
String sdatetime = sdf.format(sdate);
Date edate = new Date(endTime);
String edatetime = sdf.format(edate);
String replace = channelId.replace("$1$0$","%24");
URL url = new URL("http://172.16.51.4:83/evo-apigw/evo-httpnode/vod/cam/download.mp4" +
"?vcuid="+replace+"&subtype=1&starttime="+sdatetime+"&endtime="+edatetime+"&videoType=3" +
"&token="+access_token+"&recordType=1");
URLConnection connection = url.openConnection();
inputStream = connection.getInputStream();
fileName = channelId + "_" + startTime + ".mp4";
outputStream = new FileOutputStream("F:\\ruoyi\\uploadPath\\MP4\\" + fileName);
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, length);
}
} catch (ClientException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}finally {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
inputStream.close();
return fileName;
} catch (IOException e) {
e.printStackTrace();
}
}
return "0";
}
public String rtsphnnew(String channelId, Long startTime, Long endTime) throws ClientException {
FileOutputStream outputStream = null;
InputStream inputStream = null;
String fileName=null;
try {
OauthConfigUserPwdInfo oauthConfigUserPwdInfo =
new OauthConfigUserPwdInfo("172.16.151.240","aqpt",
"d1571278-0fdf-4866-95f5-a9cd01154527","system",
"Admin123");
IccClient iClient = new IccClient(oauthConfigUserPwdInfo);
String access_token = iClient.getAccessToken().getAccess_token();
Date sdate = new Date(startTime);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
String sdatetime = sdf.format(sdate);
Date edate = new Date(endTime);
String edatetime = sdf.format(edate);
String replace = channelId.replace("$1$0$","%24");
URL url = new URL("http://172.16.151.240:83/evo-apigw/evo-httpnode/vod/cam/download.mp4" +
"?vcuid="+replace+"&subtype=1&starttime="+sdatetime+"&endtime="+edatetime+"&videoType=2" +
"&token="+access_token+"&recordType=1");
URLConnection connection = url.openConnection();
inputStream = connection.getInputStream();
fileName = channelId + "_" + startTime + ".mp4";
outputStream = new FileOutputStream("F:\\ruoyi\\uploadPath\\MP4\\" + fileName);
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, length);
}
} catch (ClientException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}finally {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
inputStream.close();
return fileName;
} catch (IOException e) {
e.printStackTrace();
}
}
return "0";
}
public String rtspwh(String channelId, Long startTime, Long endTime) throws ClientException {
try {
OauthConfigUserPwdInfo oauthConfigUserPwdInfo =
new OauthConfigUserPwdInfo("172.16.51.4","aqpt",
"2faa3446-7e32-4fff-b661-a54d2c4cec7f","system",
"Admin@123");
IccClient iClient = new IccClient(oauthConfigUserPwdInfo);
GeneralRequest generalRequest = new GeneralRequest(oauthConfigUserPwdInfo.getHttpConfigInfo(),
"/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime", Method.POST);
String body =
"{\n" +
" \"data\": {\n" +
" \"channelId\": \"" + channelId + "\",\n" +
" \"recordSource\": \"3\",\n" +
" \"startTime\": \"" + startTime + "\",\n" +
" \"endTime\": \"" + endTime + "\",\n" +
" \"streamType\": \"1\",\n" +
" \"recordType\": \"1\"\n" +
" }\n" +
"}";
generalRequest.body(body);
GeneralResponse response = iClient.doAction(generalRequest, generalRequest.getResponseClass());
String result = response.getResult();
JSONObject obj = JSONUtil.parseObj(response.getResult());
String url = obj.getJSONObject("data").getStr("url");
String token = obj.getJSONObject("data").getStr("token");
String[] parts = url.split("\\|");
return parts[0] + "?token=" + token + "&trackID=0";
} catch (ClientException e) {
e.printStackTrace();
}
......
......@@ -9,6 +9,7 @@
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderName != null and orderName != ''">order_name,</if>
<if test="alarmDeviceName != null and alarmDeviceName != ''">alarm_device_name,</if>
<if test="channelId != null and channelId != ''">alarm_id,</if>
<if test="gradeName != null and gradeName != ''">grade_name,</if>
<if test="gradeType != null and gradeType != ''">grade_type,</if>
<if test="alarmTime != null ">alarm_time,</if>
......@@ -24,6 +25,7 @@
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderName != null and orderName != ''">#{orderName},</if>
<if test="alarmDeviceName != null and alarmDeviceName != ''">#{alarmDeviceName},</if>
<if test="channelId != null and channelId != ''">#{channelId},</if>
<if test="gradeName != null and gradeName != ''">#{gradeName},</if>
<if test="gradeType != null and gradeType != ''">#{gradeType},</if>
<if test="alarmTime != null ">#{alarmTime},</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment