Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hzjtpushdateService103
Project overview
Project overview
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
建金
hzjtpushdateService103
Commits
5a103c76
Commit
5a103c76
authored
Dec 21, 2021
by
wangjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉延迟50s
parent
a11e7e9c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
58 additions
and
69 deletions
+58
-69
hzjt.iml
hzjt.iml
+0
-1
pom.xml
pom.xml
+0
-6
src/main/java/com/hzjt/controller/TraffController.java
src/main/java/com/hzjt/controller/TraffController.java
+29
-27
src/main/java/com/hzjt/domain/MqttAlarm.java
src/main/java/com/hzjt/domain/MqttAlarm.java
+26
-32
src/main/java/com/hzjt/util/DateUtils.java
src/main/java/com/hzjt/util/DateUtils.java
+2
-2
src/main/resources/application-dev.properties
src/main/resources/application-dev.properties
+1
-1
No files found.
hzjt.iml
View file @
5a103c76
...
...
@@ -102,7 +102,6 @@
<orderEntry
type=
"library"
name=
"Maven: redis.clients:jedis:2.9.0"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.commons:commons-pool2:2.4.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.alibaba:fastjson:1.2.38"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: log4j:log4j:1.2.12"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: commons-httpclient:commons-httpclient:3.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: commons-logging:commons-logging:1.0.4"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: commons-codec:commons-codec:1.10"
level=
"project"
/>
...
...
pom.xml
View file @
5a103c76
...
...
@@ -91,12 +91,6 @@
<artifactId>
fastjson
</artifactId>
<version>
1.2.38
</version>
</dependency>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
<version>
1.2.12
</version>
</dependency>
<dependency>
<groupId>
commons-httpclient
</groupId>
<artifactId>
commons-httpclient
</artifactId>
...
...
src/main/java/com/hzjt/controller/TraffController.java
View file @
5a103c76
...
...
@@ -137,7 +137,6 @@ public class TraffController {
@PostMapping
({
"/alarmevent"
})
public
ResultObj
rece
(
@RequestBody
Alarm
trffClientMessage
)
{
// log.info("trffClientMessage:{}" ,JsonUtil.beanToString(trffClientMessage));
if
(!
TYPE
.
equals
(
trffClientMessage
.
getType
()))
{
return
ResultObj
.
error
(
Integer
.
valueOf
(
ResponseEnum
.
E_1002
.
getCode
()),
"type类型不正确"
);
}
...
...
@@ -200,6 +199,8 @@ public class TraffController {
traffAlarmRecord
.
setCreatetime
(
DateUtils
.
getDateString
(
new
Date
()));
traffAlarmRecord
.
setObjlable
(
trffClientMessage
.
getObjLabel
());
traffAlarmRecord
.
setPushstatus
(
Integer
.
valueOf
(
9
));
traffAlarmRecord
.
setProcessstatus
(
"0"
);
traffAlarmRecord
.
setManualstatus
(
Integer
.
valueOf
(
1
));
traffAlarmRecord
.
setChannelname
(
spr
.
getBz
());
List
<
String
>
imgBase64List
=
trffClientMessage
.
getImg_base64
();
String
imgEnumHead
=
"IMG"
;
...
...
@@ -221,14 +222,15 @@ public class TraffController {
traffAlarmRecord
.
setCheckstatus
(
Integer
.
valueOf
(
9
));
}
Map
<
Object
,
Object
>
map
=
new
HashMap
<>();
if
(
this
.
manualStatus
.
equalsIgnoreCase
(
"1"
))
{
map
.
put
(
"type"
,
"recordalarm"
);
traffAlarmRecord
.
setManualstatus
(
Integer
.
valueOf
(
0
));
}
else
{
// if (this.manualStatus.equalsIgnoreCase("1")) {
// map.put("type", "recordalarm");
// traffAlarmRecord.setManualstatus(Integer.valueOf(0));
// } else {
//
//
// traffAlarmRecord.setManualstatus(Integer.valueOf(1));
// }
map
.
put
(
"type"
,
"alarm"
);
traffAlarmRecord
.
setManualstatus
(
Integer
.
valueOf
(
1
));
}
//为了适配mqtt返回的处理状态,将状态设置为mqtt的事件主键
traffAlarmRecord
.
setEventid
(
"66211"
+
UUIDUtils
.
createuuid
());
this
.
traffAlarmRecordMapper
.
inserTraffAlarmRecord
(
traffAlarmRecord
);
...
...
@@ -245,23 +247,20 @@ public class TraffController {
traffAlarmRecord
.
setImg3path
(
recordBak
.
getImg3path
());
traffAlarmRecord
.
setImg4path
(
recordBak
.
getImg4path
());
traffAlarmRecord
.
setImg5path
(
recordBak
.
getImg5path
());
traffAlarmRecord
.
setVideopath
(
recordBak
.
getVideopath
());
String
pname
=
DateUtils
.
formatCurrDayNoSign
()
+
"_"
+
traffAlarmRecord
.
getRecordid
()
+
"_0000_video"
;
String
fileName
=
pname
+
".mp4"
;
String
ftputl
=
FTPUtil
.
getFtpUrl
(
ftp
)
+
basepath
+
"/"
+
fileName
;
traffAlarmRecord
.
setVideopath
(
ftputl
);
if
(
traffAlarmRecord
!=
null
&&
traffAlarmRecord
.
getRecordid
()
!=
null
)
{
this
.
traffAlarmRecordMapper
.
updateTraffAlarmRecordUrl
(
traffAlarmRecord
);
}
//推送给高信
sendtomqtt
(
trffClientMessage
,
wbbh
,
traffAlarmRecord
);
if
(
null
!=
transferRecordMap
.
get
(
"videopath"
)
&&
!
""
.
equals
(
transferRecordMap
.
get
(
"videopath"
).
toString
())
&&
(
null
==
recordBak
.
getVideopath
()
||
""
.
equalsIgnoreCase
(
recordBak
.
getVideopath
())))
{
String
pname
=
DateUtils
.
formatCurrDayNoSign
()
+
traffAlarmRecord
.
getRecordid
()
+
"_video"
;
String
fileName
=
pname
+
".mp4"
;
String
ftputl
=
FTPUtil
.
getFtpUrl
(
ftp
)
+
basepath
+
"/"
+
fileName
;
log
.
info
(
"send to mqtt video is not empty"
);
schedulepool
.
schedule
(()
->
{
String
url
=
transferRecordMap
.
get
(
"videopath"
).
toString
();
try
{
HttpURLConnection
connection
=
(
HttpURLConnection
)
(
new
URL
(
url
)).
openConnection
();
connection
.
setReadTimeout
(
2000
);
...
...
@@ -273,19 +272,22 @@ public class TraffController {
boolean
r
=
FTPUtil
.
uploadFile
(
ftp
,
basepath
,
fileName
,
inputStream
);
if
(
r
)
{
log
.
info
(
"video:{} upload success:"
,
ftputl
);
traffAlarmRecord
.
setVideopath
(
ftputl
);
if
(
traffAlarmRecord
!=
null
&&
traffAlarmRecord
.
getRecordid
()
!=
null
)
{
this
.
traffAlarmRecordMapper
.
updateTraffAlarmRecordUrl
(
traffAlarmRecord
);
}
//
traffAlarmRecord.setVideopath(ftputl);
//
if (traffAlarmRecord != null && traffAlarmRecord.getRecordid() != null) {
//
this.traffAlarmRecordMapper.updateTraffAlarmRecordUrl(traffAlarmRecord);
//
}
}
}
else
{
log
.
info
(
"video:{} upload fail:"
,
ftputl
);
traffAlarmRecord
.
setVideopath
(
""
);
this
.
traffAlarmRecordMapper
.
updateTraffAlarmRecordUrl
(
traffAlarmRecord
);
}
sendtomqtt
(
trffClientMessage
,
wbbh
,
traffAlarmRecord
);
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
toString
());
sendtomqtt
(
trffClientMessage
,
wbbh
,
traffAlarmRecord
);
traffAlarmRecord
.
setVideopath
(
""
);
this
.
traffAlarmRecordMapper
.
updateTraffAlarmRecordUrl
(
traffAlarmRecord
);
// sendtomqtt(trffClientMessage, wbbh, traffAlarmRecord);
return
Integer
.
valueOf
(
0
);
}
return
Integer
.
valueOf
(
1
);
...
...
@@ -309,13 +311,13 @@ public class TraffController {
String
mqttbh
=
this
.
traffAlarmRecordMapper
.
seletmqttbh
(
trffClientMessage
.
getIncident_type
());
mqttalarm
.
setAlarmTime
(
traffAlarmRecord
.
getRecordtime
());
mqttalarm
.
setCompanyId
(
"66211"
);
mqttalarm
.
setEventid
(
traffAlarmRecord
.
getEventid
());
//
mqttalarm.setEventid(traffAlarmRecord.getEventid());
mqttalarm
.
setImagePath
((
traffAlarmRecord
.
getImg1path
()
==
null
)
?
""
:
(
this
.
ftpServiceUrl
+
"?location="
+
traffAlarmRecord
.
getImg1path
().
replace
(
"ftp://"
+
this
.
ftppath
+
"/"
,
""
)));
mqttalarm
.
setVideoPath
((
traffAlarmRecord
.
getVideopath
()
==
null
)
?
""
:
(
this
.
ftpServiceUrl
+
"?location="
+
traffAlarmRecord
.
getVideopath
().
replace
(
"ftp://"
+
this
.
ftppath
+
"/"
,
""
)));
mqttalarm
.
setDeviceId
(
wbbh
);
log
.
info
(
"mqtt data1:{}"
,
JsonUtil
.
beanToString
(
mqttalarm
));
//查询部门是否包含隧道
mqttalarm
.
setLocation
(
traffAlarmRecord
.
getChannelname
()!=
null
&&
traffAlarmRecord
.
getChannelname
().
contains
(
"隧道"
)?
2
:
1
);
//
mqttalarm.setLocation(traffAlarmRecord.getChannelname()!=null&&traffAlarmRecord.getChannelname().contains("隧道")?2:1);
if
(
null
!=
trffClientMessage
.
getObj_location
())
{
mqttalarm
.
setX
(
trffClientMessage
.
getObj_location
().
get
(
"x"
)
==
null
?
null
:
(
trffClientMessage
.
getObj_location
().
get
(
"x"
)).
toString
());
mqttalarm
.
setY
(
trffClientMessage
.
getObj_location
().
get
(
"y"
)
==
null
?
null
:
(
trffClientMessage
.
getObj_location
().
get
(
"y"
)).
toString
());
...
...
src/main/java/com/hzjt/domain/MqttAlarm.java
View file @
5a103c76
package
com
.
hzjt
.
domain
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.Map
;
public
class
MqttAlarm
{
private
String
deviceId
;
private
String
eventTypeId
;
...
...
@@ -17,9 +11,9 @@ public class MqttAlarm {
private
String
width
;
private
String
imagePath
;
private
String
videoPath
;
private
String
content
;
private
String
eventid
;
private
int
location
;
//
private String content;
//
private String eventid;
//
private int location;
public
String
getDeviceId
()
{
return
deviceId
;
...
...
@@ -101,27 +95,27 @@ public class MqttAlarm {
this
.
videoPath
=
videoPath
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getEventid
()
{
return
eventid
;
}
public
void
setEventid
(
String
eventid
)
{
this
.
eventid
=
eventid
;
}
public
int
getLocation
()
{
return
location
;
}
public
void
setLocation
(
int
location
)
{
this
.
location
=
location
;
}
//
public String getContent() {
//
return content;
//
}
//
//
public void setContent(String content) {
//
this.content = content;
//
}
//
public String getEventid() {
//
return eventid;
//
}
//
//
public void setEventid(String eventid) {
//
this.eventid = eventid;
//
}
//
//
public int getLocation() {
//
return location;
//
}
//
//
public void setLocation(int location) {
//
this.location = location;
//
}
}
src/main/java/com/hzjt/util/DateUtils.java
View file @
5a103c76
...
...
@@ -16,9 +16,9 @@ public class DateUtils {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
DateUtils
.
class
);
public
static
String
getDateString
(
Date
date
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
log
.
info
(
"date timezone:{}"
,
formatter
.
getTimeZone
())
;
//
log.info("date timezone:{}",formatter.getTimeZone()) ;
formatter
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"Asia/Shanghai"
));
log
.
info
(
"date timezone:{}"
,
formatter
.
getTimeZone
())
;
//
log.info("date timezone:{}",formatter.getTimeZone()) ;
String
dateString
=
formatter
.
format
(
date
);
return
dateString
;
}
...
...
src/main/resources/application-dev.properties
View file @
5a103c76
#thymeleaf
server.port
=
808
4
server.port
=
808
9
spring.datasource.username
=
hzjt
spring.datasource.password
=
hzjt
...
...
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