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
0da81967
Commit
0da81967
authored
Mar 15, 2024
by
薄玉虎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新版本
parent
94894346
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
20 deletions
+78
-20
pom.xml
pom.xml
+2
-2
src/main/java/com/example/mykafkaproject/KafkaConsumerConfig.java
.../java/com/example/mykafkaproject/KafkaConsumerConfig.java
+1
-1
src/main/java/com/example/mykafkaproject/server/WarnPushBaseServer.java
...com/example/mykafkaproject/server/WarnPushBaseServer.java
+75
-17
No files found.
pom.xml
View file @
0da81967
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
<dependency>
<dependency>
<groupId>
com.dahuatech.icc
</groupId>
<groupId>
com.dahuatech.icc
</groupId>
<artifactId>
java-sdk-oauth
</artifactId>
<artifactId>
java-sdk-oauth
</artifactId>
<version>
1.0.
9.1
</version>
<version>
1.0.
12.4
</version>
<exclusions>
<exclusions>
<exclusion>
<exclusion>
<artifactId>
java-sdk-core
</artifactId>
<artifactId>
java-sdk-core
</artifactId>
...
@@ -93,7 +93,7 @@
...
@@ -93,7 +93,7 @@
<dependency>
<dependency>
<groupId>
com.dahuatech.icc
</groupId>
<groupId>
com.dahuatech.icc
</groupId>
<artifactId>
java-sdk-core
</artifactId>
<artifactId>
java-sdk-core
</artifactId>
<version>
1.0.
9.1
</version>
<version>
1.0.
12.4
</version>
</dependency>
</dependency>
<dependency>
<dependency>
...
...
src/main/java/com/example/mykafkaproject/KafkaConsumerConfig.java
View file @
0da81967
...
@@ -25,7 +25,7 @@ import java.util.Map;
...
@@ -25,7 +25,7 @@ import java.util.Map;
@EnableKafka
@EnableKafka
public
class
KafkaConsumerConfig
{
public
class
KafkaConsumerConfig
{
public
final
static
String
BOOTSTRAP_SERVERS
=
"172.16.20.
211
:9092"
;
public
final
static
String
BOOTSTRAP_SERVERS
=
"172.16.20.
33
:9092"
;
// public final static String BOOTSTRAP_SERVERS = "192.168.10.137:9092";
// public final static String BOOTSTRAP_SERVERS = "192.168.10.137:9092";
public
final
static
String
GROUP_ID
=
"test_group"
;
public
final
static
String
GROUP_ID
=
"test_group"
;
...
...
src/main/java/com/example/mykafkaproject/server/WarnPushBaseServer.java
View file @
0da81967
...
@@ -8,8 +8,10 @@ import com.dahuatech.hutool.json.JSONUtil;
...
@@ -8,8 +8,10 @@ import com.dahuatech.hutool.json.JSONUtil;
import
com.dahuatech.icc.exception.ClientException
;
import
com.dahuatech.icc.exception.ClientException
;
import
com.dahuatech.icc.oauth.http.DefaultClient
;
import
com.dahuatech.icc.oauth.http.DefaultClient
;
import
com.dahuatech.icc.oauth.http.IClient
;
import
com.dahuatech.icc.oauth.http.IClient
;
import
com.dahuatech.icc.oauth.http.IccClient
;
import
com.dahuatech.icc.oauth.model.v202010.GeneralRequest
;
import
com.dahuatech.icc.oauth.model.v202010.GeneralRequest
;
import
com.dahuatech.icc.oauth.model.v202010.GeneralResponse
;
import
com.dahuatech.icc.oauth.model.v202010.GeneralResponse
;
import
com.dahuatech.icc.oauth.model.v202010.OauthConfigUserPwdInfo
;
import
com.example.mykafkaproject.bean.WarnPushBase
;
import
com.example.mykafkaproject.bean.WarnPushBase
;
import
com.example.mykafkaproject.mapper.WarnPushBaseMapper
;
import
com.example.mykafkaproject.mapper.WarnPushBaseMapper
;
import
com.example.mykafkaproject.utils.HttpUtils
;
import
com.example.mykafkaproject.utils.HttpUtils
;
...
@@ -42,15 +44,15 @@ public class WarnPushBaseServer {
...
@@ -42,15 +44,15 @@ public class WarnPushBaseServer {
LOGGER
.
info
(
"预警信息:"
+
message
);
LOGGER
.
info
(
"预警信息:"
+
message
);
WarnPushBase
warnPushBase
=
JSON
.
parseObject
(
message
,
WarnPushBase
.
class
);
WarnPushBase
warnPushBase
=
JSON
.
parseObject
(
message
,
WarnPushBase
.
class
);
// if("乌海矿".equals(warnPushBase.getBelong())){
// if("乌海矿".equals(warnPushBase.getBelong())){
//获取视频地址
先不截取布控球的视频
//获取视频地址
String
video
;
String
video
;
if
(!
warnPushBase
.
getAlarmDeviceName
().
contains
(
"布控球"
)){
//
if(!warnPushBase.getAlarmDeviceName().contains("布控球")){
//获取前后五秒时间戳
//获取前后五秒时间戳
Date
alarmTime
=
warnPushBase
.
getAlarmTime
();
Date
alarmTime
=
warnPushBase
.
getAlarmTime
();
video
=
getVideo
(
warnPushBase
.
getChannelId
(),
alarmTime
.
getTime
()
/
1000
-
3
,
alarmTime
.
getTime
()
/
1000
+
3
);
video
=
getVideo
(
warnPushBase
.
getChannelId
(),
alarmTime
.
getTime
()
/
1000
-
3
,
alarmTime
.
getTime
()
/
1000
+
3
,
warnPushBase
);
}
else
{
//
}else{
video
=
"http://172.16.20.211:8080/profile/MP4/1001952$1$0$0_1698988966.mp4"
;
//
video = "http://172.16.20.211:8080/profile/MP4/1001952$1$0$0_1698988966.mp4";
}
//
}
// String video ="F:\\ruoyi\\uploadPath\\MP4";
// String video ="F:\\ruoyi\\uploadPath\\MP4";
warnPushBase
.
setAlarmMsg
(
warnPushBase
.
getGradeType
());
warnPushBase
.
setAlarmMsg
(
warnPushBase
.
getGradeType
());
...
@@ -63,11 +65,17 @@ public class WarnPushBaseServer {
...
@@ -63,11 +65,17 @@ public class WarnPushBaseServer {
// }
// }
}
}
public
String
getVideo
(
String
channelId
,
Long
startTime
,
Long
endTime
)
{
public
String
getVideo
(
String
channelId
,
Long
startTime
,
Long
endTime
,
WarnPushBase
warnPushBase
)
{
try
{
try
{
//获取录像视频流地址
String
url
;
String
url
=
rtsp1
(
channelId
,
startTime
,
endTime
);
//获取录像视频流地址 乌海与海南调用方式不同 需要区分 布控球目前都属于乌海矿
if
(
"乌海矿"
.
equals
(
warnPushBase
.
getBelong
())||
warnPushBase
.
getAlarmDeviceName
().
contains
(
"布控球"
)){
url
=
rtspwh
(
channelId
,
startTime
,
endTime
);
}
else
if
(
"海南矿"
.
equals
(
warnPushBase
.
getBelong
())){
url
=
rtsphn
(
channelId
,
startTime
,
endTime
);
}
else
{
return
"录像错误"
;
}
//录像视频流转mp4文件
//录像视频流转mp4文件
final
Process
[]
process
=
new
Process
[
1
];
final
Process
[]
process
=
new
Process
[
1
];
final
String
fileName
=
channelId
+
"_"
+
startTime
+
".mp4"
;
final
String
fileName
=
channelId
+
"_"
+
startTime
+
".mp4"
;
...
@@ -87,22 +95,28 @@ public class WarnPushBaseServer {
...
@@ -87,22 +95,28 @@ public class WarnPushBaseServer {
return
"http://172.16.20.211:8080/profile/MP4/"
+
fileName
;
return
"http://172.16.20.211:8080/profile/MP4/"
+
fileName
;
}
catch
(
ClientException
e
)
{
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
"录像错误"
;
return
"录像错误"
;
}
}
public
String
rtsp1
(
String
channelId
,
Long
startTime
,
Long
endTime
)
throws
ClientException
{
public
String
rtsphn
(
String
channelId
,
Long
startTime
,
Long
endTime
)
throws
ClientException
{
IClient
iClient
=
new
DefaultClient
();
try
{
GeneralRequest
generalRequest
=
OauthConfigUserPwdInfo
oauthConfigUserPwdInfo
=
new
GeneralRequest
(
"/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"
,
Method
.
POST
);
new
OauthConfigUserPwdInfo
(
"172.16.151.240"
,
"aqpt"
,
"d1571278-0fdf-4866-95f5-a9cd01154527"
,
"system"
,
"Admin123"
);
IccClient
iClient
=
new
IccClient
(
oauthConfigUserPwdInfo
);
GeneralRequest
generalRequest
=
new
GeneralRequest
(
oauthConfigUserPwdInfo
.
getHttpConfigInfo
(),
"/evo-apigw/admin/API/SS/Playback/StartPlaybackByTime"
,
Method
.
POST
);
String
body
=
String
body
=
"{\n"
+
"{\n"
+
" \"data\": {\n"
+
" \"data\": {\n"
+
" \"channelId\": \""
+
channelId
+
"\",\n"
+
" \"channelId\": \""
+
channelId
+
"\",\n"
+
" \"recordSource\": \"
3
\",\n"
+
" \"recordSource\": \"
2
\",\n"
+
" \"startTime\": \""
+
startTime
+
"\",\n"
+
" \"startTime\": \""
+
startTime
+
"\",\n"
+
" \"endTime\": \""
+
endTime
+
"\",\n"
+
" \"endTime\": \""
+
endTime
+
"\",\n"
+
" \"streamType\": \"1\",\n"
+
" \"streamType\": \"1\",\n"
+
...
@@ -112,13 +126,57 @@ public class WarnPushBaseServer {
...
@@ -112,13 +126,57 @@ public class WarnPushBaseServer {
generalRequest
.
body
(
body
);
generalRequest
.
body
(
body
);
GeneralResponse
response
=
iClient
.
doAction
(
generalRequest
,
generalRequest
.
getResponseClass
());
GeneralResponse
response
=
iClient
.
doAction
(
generalRequest
,
generalRequest
.
getResponseClass
());
String
result
=
response
.
getResult
();
String
result
=
response
.
getResult
();
System
.
out
.
println
(
result
);
JSONObject
obj
=
JSONUtil
.
parseObj
(
response
.
getResult
());
JSONObject
obj
=
JSONUtil
.
parseObj
(
response
.
getResult
());
String
url
=
obj
.
getJSONObject
(
"data"
).
getStr
(
"url"
);
String
url
=
obj
.
getJSONObject
(
"data"
).
getStr
(
"url"
);
String
token
=
obj
.
getJSONObject
(
"data"
).
getStr
(
"token"
);
String
token
=
obj
.
getJSONObject
(
"data"
).
getStr
(
"token"
);
String
[]
parts
=
url
.
split
(
"\\|"
);
String
[]
parts
=
url
.
split
(
"\\|"
);
return
parts
[
0
]
+
"?token="
+
token
+
"&trackID=0"
;
return
parts
[
0
]
+
"?token="
+
token
+
"&trackID=0"
;
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
"录像错误"
;
}
}
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
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
"录像错误"
;
}
public
void
iotPush
(
WarnPushBase
warnPushBase
)
{
public
void
iotPush
(
WarnPushBase
warnPushBase
)
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
...
@@ -131,7 +189,7 @@ public class WarnPushBaseServer {
...
@@ -131,7 +189,7 @@ public class WarnPushBaseServer {
bodys
.
put
(
"alarm_device_name"
,
warnPushBase
.
getAlarmDeviceName
());
bodys
.
put
(
"alarm_device_name"
,
warnPushBase
.
getAlarmDeviceName
());
bodys
.
put
(
"grade_name"
,
warnPushBase
.
getGradeName
());
bodys
.
put
(
"grade_name"
,
warnPushBase
.
getGradeName
());
bodys
.
put
(
"grade_type"
,
warnPushBase
.
getGradeType
());
bodys
.
put
(
"grade_type"
,
warnPushBase
.
getGradeType
());
bodys
.
put
(
"grade_type_code"
,
PinYinUtil
.
getPinYinHeadChar
(
warnPushBase
.
getGradeType
()));
bodys
.
put
(
"grade_type_code"
,
PinYinUtil
.
getPinYinHeadChar
(
warnPushBase
.
getGradeType
())
.
replaceAll
(
"、"
,
""
)
);
bodys
.
put
(
"alarm_time"
,
simpleDateFormat
.
format
(
warnPushBase
.
getAlarmTime
()));
bodys
.
put
(
"alarm_time"
,
simpleDateFormat
.
format
(
warnPushBase
.
getAlarmTime
()));
bodys
.
put
(
"alarm_msg"
,
warnPushBase
.
getAlarmMsg
());
bodys
.
put
(
"alarm_msg"
,
warnPushBase
.
getAlarmMsg
());
bodys
.
put
(
"picture"
,
warnPushBase
.
getPicture
());
bodys
.
put
(
"picture"
,
warnPushBase
.
getPicture
());
...
...
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