Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
my-kafka-project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AI算法平台
my-kafka-project
Commits
3595f5d4
Commit
3595f5d4
authored
Mar 28, 2024
by
薄玉虎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新版本:修改获取大华平台录像方式
parent
0da81967
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
172 additions
and
25 deletions
+172
-25
pom.xml
pom.xml
+1
-1
src/main/java/com/example/mykafkaproject/server/WarnPushBaseServer.java
...com/example/mykafkaproject/server/WarnPushBaseServer.java
+169
-24
src/main/resources/mapper/WarnPushBaseMapper.xml
src/main/resources/mapper/WarnPushBaseMapper.xml
+2
-0
No files found.
pom.xml
View file @
3595f5d4
...
...
@@ -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>
...
...
src/main/java/com/example/mykafkaproject/server/WarnPushBaseServer.java
View file @
3595f5d4
...
...
@@ -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
=
getVideo
new
(
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,6 +146,146 @@ public class WarnPushBaseServer {
return
"录像错误"
;
}
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
);
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
=
...
...
src/main/resources/mapper/WarnPushBaseMapper.xml
View file @
3595f5d4
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment