Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hzjtpushdateService
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
建金
hzjtpushdateService
Commits
1d1a1f06
Commit
1d1a1f06
authored
Jul 23, 2021
by
yzm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mqtt西复线服务解决id 重复问题
parent
8e42ad9e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
184 deletions
+109
-184
src/main/java/com/hzjt/controller/TraffController.java
src/main/java/com/hzjt/controller/TraffController.java
+100
-178
src/main/java/com/hzjt/redis/Receiver.java
src/main/java/com/hzjt/redis/Receiver.java
+3
-3
src/main/java/com/hzjt/util/DateUtils.java
src/main/java/com/hzjt/util/DateUtils.java
+2
-2
src/main/resources/mapper/Traffalarmrecord.xml
src/main/resources/mapper/Traffalarmrecord.xml
+4
-1
No files found.
src/main/java/com/hzjt/controller/TraffController.java
View file @
1d1a1f06
...
@@ -26,7 +26,6 @@ import sun.net.www.protocol.ftp.FtpURLConnection;
...
@@ -26,7 +26,6 @@ import sun.net.www.protocol.ftp.FtpURLConnection;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.websocket.server.PathParam
;
import
java.io.*
;
import
java.io.*
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
...
@@ -95,7 +94,7 @@ public class TraffController {
...
@@ -95,7 +94,7 @@ public class TraffController {
@Autowired
@Autowired
FLVCacheService
flvCacheService
;
FLVCacheService
flvCacheService
;
Long
eightHour
=
25200000L
;
Long
eightHour
=
25200000L
;
// @Autowired
// @Autowired
// private SimpMessagingTemplate template;
// private SimpMessagingTemplate template;
...
@@ -103,7 +102,7 @@ public class TraffController {
...
@@ -103,7 +102,7 @@ public class TraffController {
@Autowired
@Autowired
MQTTSubsribe
mQTTSubsribe
;
MQTTSubsribe
mQTTSubsribe
;
String
manualStatus
=
"0"
;
String
manualStatus
=
"0"
;
private
static
final
String
TYPE
=
"TRAFFIC_INCIDENT_ALARM"
;
private
static
final
String
TYPE
=
"TRAFFIC_INCIDENT_ALARM"
;
ScheduledExecutorService
schedulepool
=
Executors
.
newScheduledThreadPool
(
5
);
//创
ScheduledExecutorService
schedulepool
=
Executors
.
newScheduledThreadPool
(
5
);
//创
...
@@ -129,13 +128,12 @@ public class TraffController {
...
@@ -129,13 +128,12 @@ public class TraffController {
@PostConstruct
@PostConstruct
public
void
init
()
{
public
void
init
()
{
//查询素有videowbbh
//查询素有videowbbh
List
<
String
>
sbbhlist
=
sbtdspsrMapper
.
selectAllWbbh
();
List
<
String
>
sbbhlist
=
sbtdspsrMapper
.
selectAllWbbh
();
mQTTSubsribe
.
subscribe
(
sbbhlist
);
mQTTSubsribe
.
subscribe
(
sbbhlist
);
}
}
@PostMapping
(
"/alarmevent"
)
@PostMapping
(
"/alarmevent"
)
public
ResultObj
rece
(
@RequestBody
Alarm
trffClientMessage
)
{
public
ResultObj
rece
(
@RequestBody
Alarm
trffClientMessage
)
{
// log.info("alarmevent--------------"+trffClientMessage.toString());
if
(!
TYPE
.
equals
(
trffClientMessage
.
getType
()))
{
if
(!
TYPE
.
equals
(
trffClientMessage
.
getType
()))
{
return
ResultObj
.
error
(
ResponseEnum
.
E_1002
.
getCode
(),
"type类型不正确"
);
return
ResultObj
.
error
(
ResponseEnum
.
E_1002
.
getCode
(),
"type类型不正确"
);
}
}
...
@@ -148,15 +146,12 @@ public class TraffController {
...
@@ -148,15 +146,12 @@ public class TraffController {
return
ResultObj
.
error
(
ResponseEnum
.
E_1004
.
getCode
(),
"incident_type值不能为空"
);
return
ResultObj
.
error
(
ResponseEnum
.
E_1004
.
getCode
(),
"incident_type值不能为空"
);
}
}
//加8个小时兼容算法
//加8个小时兼容算法
log
.
info
(
"trffClientMessage ts===="
+
trffClientMessage
.
getTs
());
Long
current
=
new
Date
().
getTime
()
-
Long
.
valueOf
(
trffClientMessage
.
getTs
());
log
.
info
(
"trffClientMessage nowtime======="
+
new
Date
().
getTime
());
log
.
info
(
"current.longValue()>=eightHour.longValue()======"
+
(
current
.
longValue
()
>=
eightHour
.
longValue
()));
Long
current
=
new
Date
().
getTime
()-
Long
.
valueOf
(
trffClientMessage
.
getTs
());
if
(
current
.
longValue
()
>=
eightHour
.
longValue
())
{
log
.
info
(
"current.longValue()>=eightHour.longValue()======"
+(
current
.
longValue
()>=
eightHour
.
longValue
()));
if
(
current
.
longValue
()>=
eightHour
.
longValue
())
{
//系统时间小于8小时
//系统时间小于8小时
Long
lontime
=
Long
.
valueOf
(
trffClientMessage
.
getTs
())+
28800000L
;
Long
lontime
=
Long
.
valueOf
(
trffClientMessage
.
getTs
())
+
28800000L
;
log
.
info
(
"trffClientMessage lontime====="
+
lontime
);
log
.
info
(
"trffClientMessage lontime====="
+
lontime
);
trffClientMessage
.
setTs
(
String
.
valueOf
(
lontime
));
trffClientMessage
.
setTs
(
String
.
valueOf
(
lontime
));
}
}
...
@@ -166,18 +161,8 @@ public class TraffController {
...
@@ -166,18 +161,8 @@ public class TraffController {
log
.
info
(
"video_id值异常 值为:"
+
videoId
);
log
.
info
(
"video_id值异常 值为:"
+
videoId
);
return
ResultObj
.
error
(
ResponseEnum
.
E_1002
.
getCode
(),
"video_id值异常 值为:"
+
videoId
);
return
ResultObj
.
error
(
ResponseEnum
.
E_1002
.
getCode
(),
"video_id值异常 值为:"
+
videoId
);
}
}
String
sbbh
=
videoId
;
String
sbbh
=
""
;
int
tdbh
=
0
;
int
tdbh
=
0
;
// if( videoId.contains("_") && videoId.split("_").length == 2) {
// String[] sbAndTd = videoId.split("_");
// sbbh = sbAndTd[0];
// tdbh = Integer.valueOf(sbAndTd[1]) + 1;
// }
// else {
sbbh
=
videoId
;
tdbh
=
0
;
// }
List
<
Sbtdspsr
>
sbtdspsrs
=
sbtdspsrMapper
.
selectBySbbh
(
sbbh
,
tdbh
);
List
<
Sbtdspsr
>
sbtdspsrs
=
sbtdspsrMapper
.
selectBySbbh
(
sbbh
,
tdbh
);
if
(
sbtdspsrs
.
isEmpty
())
{
if
(
sbtdspsrs
.
isEmpty
())
{
log
.
info
(
"设备为:"
+
sbbh
+
",通道为:"
+
tdbh
+
"未录入(备案)"
);
log
.
info
(
"设备为:"
+
sbbh
+
",通道为:"
+
tdbh
+
"未录入(备案)"
);
...
@@ -188,41 +173,24 @@ public class TraffController {
...
@@ -188,41 +173,24 @@ public class TraffController {
log
.
info
(
"设备为:"
+
sbbh
+
",通道为:"
+
tdbh
+
"配置的行政区划"
+
xzbh
+
"不合规"
);
log
.
info
(
"设备为:"
+
sbbh
+
",通道为:"
+
tdbh
+
"配置的行政区划"
+
xzbh
+
"不合规"
);
return
ResultObj
.
error
(
ResponseEnum
.
E_1002
.
getCode
(),
"设备为:"
+
sbbh
+
",通道为:"
+
tdbh
+
"配置的行政区划不合规"
);
return
ResultObj
.
error
(
ResponseEnum
.
E_1002
.
getCode
(),
"设备为:"
+
sbbh
+
",通道为:"
+
tdbh
+
"配置的行政区划不合规"
);
}
}
trffClientMessage
.
setDept
(
xzbh
);
trffClientMessage
.
setDept
(
xzbh
);
//判断是否需要手动筛选
manualStatus
=
traffAlarmRecordMapper
.
seletManualStatus
();
log
.
info
(
"是否手动推送 manualStatus"
+
manualStatus
);
if
(
manualStatus
.
equalsIgnoreCase
(
"0"
))
{
log
.
info
(
"send to gaoxin"
);
//手动 推送给高信
webSocket
.
GroupSending
(
JsonUtil
.
beanToString
(
trffClientMessage
));
}
try
{
// 清空redis中的部分旧数据
try
{
// 清空redis中的部分旧数据
// importService.cleanCache();
sendevent
(
trffClientMessage
,
sbtdspsrs
.
get
(
0
).
getWbbh
());
// 将参数result中的部分数据存入redis中,并把格式校验成功的数据发布至对应频道中
// importService.cacheAndPublish(JsonUtil.beanToString(trffClientMessage));
sendevent
(
trffClientMessage
,
sbtdspsrs
.
get
(
0
).
getWbbh
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"MessageController receive putData error:"
+
e
.
toString
());
log
.
error
(
"MessageController receive putData error:"
+
e
.
toString
());
}
}
return
ResultObj
.
ok
(
trffClientMessage
);
return
ResultObj
.
ok
(
trffClientMessage
);
}
}
public
void
sendevent
(
Alarm
trffClientMessage
,
String
wbbh
)
{
public
void
sendevent
(
Alarm
trffClientMessage
,
String
wbbh
)
{
Traffalarmrecord
traffAlarmRecord
=
new
Traffalarmrecord
();
Traffalarmrecord
traffAlarmRecord
=
new
Traffalarmrecord
();
traffAlarmRecord
.
setAreaid
(
Long
.
valueOf
(
trffClientMessage
.
getDept
()));
traffAlarmRecord
.
setAreaid
(
Long
.
valueOf
(
trffClientMessage
.
getDept
()));
traffAlarmRecord
.
setRecordtype
(
trffClientMessage
.
getIncident_type
().
toLowerCase
());
traffAlarmRecord
.
setRecordtype
(
trffClientMessage
.
getIncident_type
().
toLowerCase
());
traffAlarmRecord
.
setRecordtime
(
DateUtils
.
getDateString
(
new
Date
(
Long
.
valueOf
(
trffClientMessage
.
getTs
()))));
traffAlarmRecord
.
setRecordtime
(
DateUtils
.
getDateString
(
new
Date
(
Long
.
valueOf
(
trffClientMessage
.
getTs
()))));
Integer
channelid
=
Integer
.
valueOf
(
0
);
traffAlarmRecord
.
setFdid
(
trffClientMessage
.
getVideo_id
());
traffAlarmRecord
.
setChannelid
(
0
);
traffAlarmRecord
.
setFdid
(
trffClientMessage
.
getVideo_id
());
channelid
=
0
;
traffAlarmRecord
.
setChannelid
(
channelid
);
traffAlarmRecord
.
setVideourlfrom
(
trffClientMessage
.
getVideo_record_url
());
traffAlarmRecord
.
setVideourlfrom
(
trffClientMessage
.
getVideo_record_url
());
traffAlarmRecord
.
setCreatetime
(
DateUtils
.
getDateString
(
new
Date
()));
traffAlarmRecord
.
setCreatetime
(
DateUtils
.
getDateString
(
new
Date
()));
traffAlarmRecord
.
setObjlable
(
trffClientMessage
.
getObjLabel
());
traffAlarmRecord
.
setObjlable
(
trffClientMessage
.
getObjLabel
());
...
@@ -249,30 +217,23 @@ public class TraffController {
...
@@ -249,30 +217,23 @@ public class TraffController {
traffAlarmRecord
.
setCheckstatus
(
9
);
traffAlarmRecord
.
setCheckstatus
(
9
);
}
}
int
recordid
=
traffAlarmRecordMapper
.
selectmax
();
traffAlarmRecord
.
setRecordid
((
long
)
(
recordid
));
//发送给前端
//发送给前端
Map
map
=
new
HashMap
();
Map
map
=
new
HashMap
();
if
(
manualStatus
.
equalsIgnoreCase
(
"1"
))
{
map
.
put
(
"type"
,
"recordalarm"
);
traffAlarmRecord
.
setManualstatus
(
0
);
if
(
manualStatus
.
equalsIgnoreCase
(
"1"
))
{
}
else
{
map
.
put
(
"type"
,
"recordalarm"
);
traffAlarmRecord
.
setManualstatus
(
0
);
}
else
{
map
.
put
(
"type"
,
"alarm"
);
map
.
put
(
"type"
,
"alarm"
);
traffAlarmRecord
.
setManualstatus
(
1
);
traffAlarmRecord
.
setManualstatus
(
1
);
}
}
map
.
put
(
"data"
,
trffClientMessage
);
map
.
put
(
"recordid"
,
recordid
);
webSocket
.
GroupSending
(
JsonUtil
.
beanToString
(
map
));
traffAlarmRecord
.
setProcessstatus
(
"0"
);
traffAlarmRecord
.
setProcessstatus
(
"0"
);
log
.
info
(
traffAlarmRecord
.
getRecordtime
());
log
.
info
(
"JSONUtil.toJsonStr 告警记录数据插入:{}"
,
JSONUtil
.
toJsonStr
(
traffAlarmRecord
));
log
.
info
(
"JSON.toJSONString 告警记录数据插入:{}"
,
JSON
.
toJSONString
(
traffAlarmRecord
));
traffAlarmRecordMapper
.
inserTraffAlarmRecord
(
traffAlarmRecord
);
traffAlarmRecordMapper
.
inserTraffAlarmRecord
(
traffAlarmRecord
);
map
.
put
(
"data"
,
trffClientMessage
);
map
.
put
(
"recordid"
,
traffAlarmRecord
.
getRecordid
());
webSocket
.
GroupSending
(
JsonUtil
.
beanToString
(
map
));
try
{
try
{
String
basepath
=
"gstraff/"
+
traffAlarmRecord
.
getFdid
()
+
(
traffAlarmRecord
.
getChannelid
()
<
10
?
"0"
+
traffAlarmRecord
.
getChannelid
()
:
traffAlarmRecord
.
getChannelid
())
+
"/"
+
DateUtils
.
formatCurrDayNoSign
();
String
basepath
=
"gstraff/"
+
traffAlarmRecord
.
getFdid
()
+
(
traffAlarmRecord
.
getChannelid
()
<
10
?
"0"
+
traffAlarmRecord
.
getChannelid
()
:
traffAlarmRecord
.
getChannelid
())
+
"/"
+
DateUtils
.
formatCurrDayNoSign
();
Map
<
String
,
Object
>
transferRecordMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
transferRecordMap
=
new
HashMap
<>();
...
@@ -289,104 +250,72 @@ public class TraffController {
...
@@ -289,104 +250,72 @@ public class TraffController {
if
(
traffAlarmRecord
!=
null
&&
traffAlarmRecord
.
getRecordid
()
!=
null
)
{
if
(
traffAlarmRecord
!=
null
&&
traffAlarmRecord
.
getRecordid
()
!=
null
)
{
traffAlarmRecordMapper
.
updateTraffAlarmRecordUrl
(
traffAlarmRecord
);
traffAlarmRecordMapper
.
updateTraffAlarmRecordUrl
(
traffAlarmRecord
);
}
}
//如果监控视频为空,延时加载重新获取
//如果监控视频为空,延时加载重新获取
if
(
null
==
recordBak
.
getVideopath
()
||
""
.
equalsIgnoreCase
(
recordBak
.
getVideopath
()))
{
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
(()
->
{
schedulepool
.
schedule
(()
->
{
for
(
String
key
:
transferRecordMap
.
keySet
())
{
final
String
url
=
transferRecordMap
.
get
(
"videopath"
).
toString
();
if
(
key
.
equals
(
"videopath"
))
{
try
{
final
String
url
=
transferRecordMap
.
get
(
key
).
toString
();
HttpURLConnection
connection
=
(
HttpURLConnection
)
new
URL
(
url
).
openConnection
();
try
{
//延迟连接
HttpURLConnection
connection
=
(
HttpURLConnection
)
new
URL
(
url
).
openConnection
();
connection
.
setReadTimeout
(
2000
);
//延迟连接
connection
.
setConnectTimeout
(
3000
);
connection
.
setReadTimeout
(
2000
);
connection
.
setRequestMethod
(
"GET"
);
connection
.
setConnectTimeout
(
3000
);
if
(
connection
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_OK
)
{
connection
.
setRequestMethod
(
"GET"
);
InputStream
inputStream
=
connection
.
getInputStream
();
String
pname
=
DateUtils
.
formatCurrDayNoSign
()
+
"_"
+
recordid
+
"_0000_"
+
key
.
replace
(
"path"
,
""
);
log
.
info
(
"url:"
,
url
);
String
fileName
=
pname
+
".mp4"
;
boolean
r
=
FTPUtil
.
uploadFile
(
ftp
,
basepath
,
fileName
,
inputStream
);
String
ftputl
=
FTPUtil
.
getFtpUrl
(
ftp
)
+
basepath
+
"/"
+
fileName
;
if
(
r
)
{
if
(
connection
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_OK
)
{
log
.
info
(
"video:{} upload success:"
,
ftputl
);
InputStream
inputStream
=
connection
.
getInputStream
();
traffAlarmRecord
.
setVideopath
(
ftputl
);
log
.
info
(
"url:"
,
url
,
" --- "
+
"key:"
,
key
);
if
(
traffAlarmRecord
!=
null
&&
traffAlarmRecord
.
getRecordid
()
!=
null
)
{
boolean
r
=
FTPUtil
.
uploadFile
(
ftp
,
basepath
,
fileName
,
inputStream
);
traffAlarmRecordMapper
.
updateTraffAlarmRecordUrl
(
traffAlarmRecord
);
if
(
r
)
traffAlarmRecord
.
setVideopath
(
ftputl
);
//只更新监控
if
(
traffAlarmRecord
!=
null
&&
traffAlarmRecord
.
getRecordid
()
!=
null
)
{
traffAlarmRecordMapper
.
updateTraffAlarmRecordUrl
(
traffAlarmRecord
);
log
.
info
(
"send to mqtt video is not empty"
);
sendtomqtt
(
trffClientMessage
,
wbbh
,
traffAlarmRecord
);
// //推送给第三方
// if(!manualStatus.equalsIgnoreCase("1")) {
// ResultObj obj = eventWriteService.updateAndAutoSendEvent(traffAlarmRecord);
// log.info("send to guangda:HTTP_OK" + obj.toString());
// }
}
}
else
{
// ResultObj obj = eventWriteService.updateAndAutoSendEvent(traffAlarmRecord);
log
.
info
(
"send to mqtt video is empty"
);
sendtomqtt
(
trffClientMessage
,
wbbh
,
traffAlarmRecord
);
}
}
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
toString
());
log
.
error
(
e
.
toString
());
sendtomqtt
(
trffClientMessage
,
wbbh
,
traffAlarmRecord
);
return
0
;
}
}
}
else
{
log
.
info
(
"video:{} upload fail:"
,
ftputl
);
}
}
sendtomqtt
(
trffClientMessage
,
wbbh
,
traffAlarmRecord
);
}
catch
(
IOException
e
)
{
log
.
error
(
e
.
toString
());
sendtomqtt
(
trffClientMessage
,
wbbh
,
traffAlarmRecord
);
return
0
;
}
}
return
1
;
return
1
;
},
50
,
TimeUnit
.
SECONDS
);
//等待50秒钟执行
},
50
,
TimeUnit
.
SECONDS
);
//等待50秒钟执行
}
else
{
//需要先过滤,过滤结束后推送给第三方
// if(!manualStatus.equalsIgnoreCase("1")) {
// ResultObj obj = eventWriteService.updateAndAutoSendEvent(traffAlarmRecord);
// log.info("send to guangda novideopath --->response message" + obj.toString());
// }
}
}
traffAlarmRecord
.
setPushdesc
(
"推送结束"
);
traffAlarmRecord
.
setPushdesc
(
"推送结束"
);
traffAlarmRecord
.
setPushstatus
(
0
);
traffAlarmRecord
.
setPushstatus
(
0
);
traffAlarmRecordMapper
.
updatePushEvent
(
traffAlarmRecord
);
traffAlarmRecordMapper
.
updatePushEvent
(
traffAlarmRecord
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"alarm
fail
:"
+
e
.
toString
());
log
.
error
(
"alarm
event error
:"
+
e
.
toString
());
}
}
}
}
public
static
void
main
(
String
args
[])
{
long
a
=
1624377806000
l
;
Date
date
=
new
Date
(
a
);
System
.
out
.
println
(
date
);
}
private
void
sendtomqtt
(
Alarm
trffClientMessage
,
String
wbbh
,
Traffalarmrecord
traffAlarmRecord
)
{
private
void
sendtomqtt
(
Alarm
trffClientMessage
,
String
wbbh
,
Traffalarmrecord
traffAlarmRecord
)
{
if
(
null
==
wbbh
||
""
.
equals
(
wbbh
))
if
(
null
==
wbbh
||
""
.
equals
(
wbbh
))
{
{
log
.
info
(
"设备为:"
+
traffAlarmRecord
.
getFdid
()
+
",wbbh"
+
" is empty"
);
log
.
info
(
"设备为:"
+
traffAlarmRecord
.
getFdid
()
+
",wbbh"
+
" is empty"
);
}
}
else
{
//mqtt 推送给第三方
else
{
//mqtt 推送给第三方
MqttAlarm
mqttalarm
=
new
MqttAlarm
();
MqttAlarm
mqttalarm
=
new
MqttAlarm
();
//查询事件类型mqtt 对应的编号
//查询事件类型mqtt 对应的编号
String
mqttbh
=
traffAlarmRecordMapper
.
seletmqttbh
(
trffClientMessage
.
getIncident_type
());
String
mqttbh
=
traffAlarmRecordMapper
.
seletmqttbh
(
trffClientMessage
.
getIncident_type
());
mqttalarm
.
setAlarmTime
(
traffAlarmRecord
.
getRecordtime
());
mqttalarm
.
setAlarmTime
(
traffAlarmRecord
.
getRecordtime
());
mqttalarm
.
setCompanyId
(
"66211"
);
mqttalarm
.
setCompanyId
(
"66211"
);
//设置图片
//设置图片
mqttalarm
.
setImagePath
(
traffAlarmRecord
.
getImg1path
()
==
null
?
""
:
ftpServiceUrl
+
"?location="
+
traffAlarmRecord
.
getImg1path
().
replace
(
"ftp://"
+
ftppath
+
"/"
,
""
));
mqttalarm
.
setImagePath
(
traffAlarmRecord
.
getImg1path
()
==
null
?
""
:
ftpServiceUrl
+
"?location="
+
traffAlarmRecord
.
getImg1path
().
replace
(
"ftp://"
+
ftppath
+
"/"
,
""
));
mqttalarm
.
setVideoPath
(
traffAlarmRecord
.
getVideopath
()
==
null
?
""
:
ftpServiceUrl
+
"?location="
+
traffAlarmRecord
.
getVideopath
().
replace
(
"ftp://"
+
ftppath
+
"/"
,
""
));
mqttalarm
.
setVideoPath
(
traffAlarmRecord
.
getVideopath
()
==
null
?
""
:
ftpServiceUrl
+
"?location="
+
traffAlarmRecord
.
getVideopath
().
replace
(
"ftp://"
+
ftppath
+
"/"
,
""
));
mqttalarm
.
setDeviceId
(
wbbh
);
mqttalarm
.
setDeviceId
(
wbbh
);
if
(
null
!=
trffClientMessage
.
getObj_location
())
{
if
(
null
!=
trffClientMessage
.
getObj_location
())
{
mqttalarm
.
setX
(
trffClientMessage
.
getObj_location
().
get
(
"x"
)
==
null
?
null
:
trffClientMessage
.
getObj_location
().
get
(
"x"
).
toString
());
mqttalarm
.
setX
(
trffClientMessage
.
getObj_location
().
get
(
"x"
)
==
null
?
null
:
trffClientMessage
.
getObj_location
().
get
(
"x"
).
toString
());
...
@@ -395,8 +324,7 @@ public class TraffController {
...
@@ -395,8 +324,7 @@ public class TraffController {
mqttalarm
.
setHeight
(
trffClientMessage
.
getObj_location
().
get
(
"height"
)
==
null
?
null
:
trffClientMessage
.
getObj_location
().
get
(
"height"
).
toString
());
mqttalarm
.
setHeight
(
trffClientMessage
.
getObj_location
().
get
(
"height"
)
==
null
?
null
:
trffClientMessage
.
getObj_location
().
get
(
"height"
).
toString
());
}
}
mqttalarm
.
setEventTypeId
(
mqttbh
);
mqttalarm
.
setEventTypeId
(
mqttbh
);
log
.
info
(
"JSONUtil mqtt data:{}"
,
JSON
.
toJSONString
(
mqttalarm
));
log
.
info
(
"mqtt data:{}"
+
JSON
.
toJSONString
(
mqttalarm
));
log
.
info
(
"mqtt data:{}"
+
JSON
.
toJSONString
(
mqttalarm
));
mQTTSubsribe
.
publishMessage
(
"event/"
+
wbbh
+
"/videoEvent"
,
JSON
.
toJSONString
(
mqttalarm
));
mQTTSubsribe
.
publishMessage
(
"event/"
+
wbbh
+
"/videoEvent"
,
JSON
.
toJSONString
(
mqttalarm
));
}
}
...
@@ -408,7 +336,7 @@ public class TraffController {
...
@@ -408,7 +336,7 @@ public class TraffController {
rateLimiter
=
rateLimiterMap
.
get
(
videoId
);
rateLimiter
=
rateLimiterMap
.
get
(
videoId
);
}
else
{
}
else
{
RateLimiter
value
=
RateLimiter
.
create
(
rate
);
RateLimiter
value
=
RateLimiter
.
create
(
rate
);
rateLimiter
=
rateLimiterMap
.
putIfAbsent
(
videoId
,
value
);
rateLimiter
=
rateLimiterMap
.
putIfAbsent
(
videoId
,
value
);
if
(
rateLimiter
==
null
)
{
if
(
rateLimiter
==
null
)
{
rateLimiter
=
value
;
rateLimiter
=
value
;
}
}
...
@@ -422,15 +350,14 @@ public class TraffController {
...
@@ -422,15 +350,14 @@ public class TraffController {
public
ResultObj
traffflow
(
@RequestBody
Vehicles
vehicles
)
{
public
ResultObj
traffflow
(
@RequestBody
Vehicles
vehicles
)
{
if
(
"TRAFFIC_STATISTICS_VEHICLES"
.
equalsIgnoreCase
(
vehicles
.
getType
()))
{
if
(
"TRAFFIC_STATISTICS_VEHICLES"
.
equalsIgnoreCase
(
vehicles
.
getType
()))
{
String
sbbh
=
""
;
String
sbbh
=
""
;
int
tdbh
=
0
;
int
tdbh
=
0
;
if
(
vehicles
.
getVideo_id
().
contains
(
"_"
)
&&
vehicles
.
getVideo_id
().
split
(
"_"
).
length
==
2
)
{
if
(
vehicles
.
getVideo_id
().
contains
(
"_"
)
&&
vehicles
.
getVideo_id
().
split
(
"_"
).
length
==
2
)
{
String
[]
sbAndTd
=
vehicles
.
getVideo_id
().
split
(
"_"
);
String
[]
sbAndTd
=
vehicles
.
getVideo_id
().
split
(
"_"
);
sbbh
=
sbAndTd
[
0
];
sbbh
=
sbAndTd
[
0
];
tdbh
=
Integer
.
valueOf
(
sbAndTd
[
1
])
+
1
;
tdbh
=
Integer
.
valueOf
(
sbAndTd
[
1
])
+
1
;
}
}
else
{
else
{
sbbh
=
vehicles
.
getVideo_id
();
sbbh
=
vehicles
.
getVideo_id
();
}
}
//重置videoid
//重置videoid
vehicles
.
setVideo_id
(
sbbh
+
"_"
+
tdbh
);
vehicles
.
setVideo_id
(
sbbh
+
"_"
+
tdbh
);
...
@@ -446,8 +373,6 @@ public class TraffController {
...
@@ -446,8 +373,6 @@ public class TraffController {
v
.
setClassification_confidence
(
detail
.
getClassification_confidence
());
v
.
setClassification_confidence
(
detail
.
getClassification_confidence
());
v
.
setVideo_id
(
vehicles
.
getVideo_id
());
v
.
setVideo_id
(
vehicles
.
getVideo_id
());
traffFlowService
.
saveTraffFlowDetail
(
v
);
traffFlowService
.
saveTraffFlowDetail
(
v
);
}
}
//查询近五分钟的车流量,当天车流量websocket 直接推送过去
//查询近五分钟的车流量,当天车流量websocket 直接推送过去
// log.info("fivevehivle");
// log.info("fivevehivle");
...
@@ -469,7 +394,6 @@ public class TraffController {
...
@@ -469,7 +394,6 @@ public class TraffController {
}
}
//获取flv地址
//获取flv地址
@GetMapping
(
"/getflv/{videoid}"
)
@GetMapping
(
"/getflv/{videoid}"
)
public
String
getflv
(
@PathVariable
(
"videoid"
)
String
videoid
)
{
public
String
getflv
(
@PathVariable
(
"videoid"
)
String
videoid
)
{
...
@@ -516,7 +440,7 @@ public class TraffController {
...
@@ -516,7 +440,7 @@ public class TraffController {
v
.
setCreate_time
(
new
Date
(
Long
.
valueOf
(
vehicles
.
getTs
())));
v
.
setCreate_time
(
new
Date
(
Long
.
valueOf
(
vehicles
.
getTs
())));
v
.
setType
(
detail
.
getType
());
v
.
setType
(
detail
.
getType
());
v
.
setDirection
(
detail
.
getDirection
());
v
.
setDirection
(
detail
.
getDirection
());
v
.
setRuleTag
(
detail
.
getDirection
().
longValue
()
<=
ldir
.
longValue
()?
"1"
:
"2"
);
v
.
setRuleTag
(
detail
.
getDirection
().
longValue
()
<=
ldir
.
longValue
()
?
"1"
:
"2"
);
v
.
setClassification_confidence
(
detail
.
getClassification_confidence
());
v
.
setClassification_confidence
(
detail
.
getClassification_confidence
());
v
.
setVideo_id
(
vehicles
.
getVideo_id
());
v
.
setVideo_id
(
vehicles
.
getVideo_id
());
result
=
traffFlowService
.
saveTraffFlowDetail
(
v
);
result
=
traffFlowService
.
saveTraffFlowDetail
(
v
);
...
@@ -531,42 +455,42 @@ public class TraffController {
...
@@ -531,42 +455,42 @@ public class TraffController {
//车流量推送
//车流量推送
@GetMapping
(
"/sendtouser/{recordid}"
)
@GetMapping
(
"/sendtouser/{recordid}"
)
@ResponseBody
@ResponseBody
public
Integer
sendtouser
(
@PathVariable
(
"recordid"
)
String
recordid
)
{
public
Integer
sendtouser
(
@PathVariable
(
"recordid"
)
String
recordid
)
{
//查询该信息
//查询该信息
Traffalarmrecord
traffalarmrecord
=
traffAlarmRecordMapper
.
selectByPrimaryKey
(
recordid
);
Traffalarmrecord
traffalarmrecord
=
traffAlarmRecordMapper
.
selectByPrimaryKey
(
recordid
);
if
(
traffalarmrecord
==
null
)
return
0
;
if
(
traffalarmrecord
==
null
)
return
0
;
Alarm
alarm
=
new
Alarm
();
Alarm
alarm
=
new
Alarm
();
Base64Encoder
base64Encoder
=
new
Base64Encoder
();
Base64Encoder
base64Encoder
=
new
Base64Encoder
();
alarm
.
setTs
(
Long
.
toString
(
traffalarmrecord
.
getRecordtime
()
==
null
?
new
Date
().
getTime
():
DateUtils
.
Parsedate
(
traffalarmrecord
.
getRecordtime
()).
getTime
()));
alarm
.
setTs
(
Long
.
toString
(
traffalarmrecord
.
getRecordtime
()
==
null
?
new
Date
().
getTime
()
:
DateUtils
.
Parsedate
(
traffalarmrecord
.
getRecordtime
()).
getTime
()));
alarm
.
setDept
(
traffalarmrecord
.
getAreaid
()
==
null
?
null
:
Long
.
toString
(
traffalarmrecord
.
getAreaid
()));
alarm
.
setDept
(
traffalarmrecord
.
getAreaid
()
==
null
?
null
:
Long
.
toString
(
traffalarmrecord
.
getAreaid
()));
alarm
.
setVideo_id
(
traffalarmrecord
.
getFdid
()
+
"_"
+
traffalarmrecord
.
getChannelid
());
alarm
.
setVideo_id
(
traffalarmrecord
.
getFdid
()
+
"_"
+
traffalarmrecord
.
getChannelid
());
alarm
.
setIncident_type
(
traffalarmrecord
.
getRecordtype
());
alarm
.
setIncident_type
(
traffalarmrecord
.
getRecordtype
());
List
<
String
>
strImgs
=
new
ArrayList
<>();
List
<
String
>
strImgs
=
new
ArrayList
<>();
if
(
traffalarmrecord
.
getImg1path
()
!=
null
)
{
if
(
traffalarmrecord
.
getImg1path
()
!=
null
)
{
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg1path
());
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg1path
());
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
}
}
if
(
traffalarmrecord
.
getImg2path
()
!=
null
)
{
if
(
traffalarmrecord
.
getImg2path
()
!=
null
)
{
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg2path
());
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg2path
());
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
}
}
if
(
traffalarmrecord
.
getImg3path
()
!=
null
)
{
if
(
traffalarmrecord
.
getImg3path
()
!=
null
)
{
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg3path
());
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg3path
());
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
}
}
if
(
traffalarmrecord
.
getImg4path
()
!=
null
)
{
if
(
traffalarmrecord
.
getImg4path
()
!=
null
)
{
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg4path
());
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg4path
());
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
}
}
if
(
traffalarmrecord
.
getImg5path
()
!=
null
)
{
if
(
traffalarmrecord
.
getImg5path
()
!=
null
)
{
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg5path
());
byte
[]
Img
=
FTPUtil
.
getFtpPicBytes
(
traffalarmrecord
.
getImg5path
());
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
strImgs
.
add
(
Img
!=
null
?
base64Encoder
.
encode
(
Img
)
:
null
);
}
}
alarm
.
setImg_base64
(
strImgs
);
alarm
.
setImg_base64
(
strImgs
);
Map
map
=
new
HashMap
();
Map
map
=
new
HashMap
();
//websocket 推送给客户
//websocket 推送给客户
map
.
put
(
"type"
,
"alarm"
);
map
.
put
(
"type"
,
"alarm"
);
map
.
put
(
"data"
,
alarm
);
map
.
put
(
"data"
,
alarm
);
...
@@ -585,7 +509,7 @@ public class TraffController {
...
@@ -585,7 +509,7 @@ public class TraffController {
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
log
.
info
(
"send to guangda novideopath --->response error"
+
ex
.
toString
());
log
.
info
(
"send to guangda novideopath --->response error"
+
ex
.
toString
());
return
1
;
return
1
;
...
@@ -593,21 +517,19 @@ public class TraffController {
...
@@ -593,21 +517,19 @@ public class TraffController {
}
}
}
}
//车流量推送
//车流量推送
@GetMapping
(
"/test"
)
@GetMapping
(
"/test"
)
@ResponseBody
@ResponseBody
public
void
test
()
{
public
void
test
()
{
String
manualStatus
=
traffAlarmRecordMapper
.
seletManualStatus
();
String
manualStatus
=
traffAlarmRecordMapper
.
seletManualStatus
();
Alarm
alarm
=
new
Alarm
();
Alarm
alarm
=
new
Alarm
();
alarm
.
setVideo_id
(
"33_65_230_156_554_fbXdTkVe98u_ecvs_0"
);
alarm
.
setVideo_id
(
"33_65_230_156_554_fbXdTkVe98u_ecvs_0"
);
alarm
.
setIncident_type
(
"NO_MOTOR_BAN"
);
alarm
.
setIncident_type
(
"NO_MOTOR_BAN"
);
String
str
=
"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAB1UlEQVRIS5WVjTEEQRBG30WACBABGSACLgJEgAicCBABIkAEiIAMkAERUG9remtua2Z3rquuam935nvTPf0zY9y2gENgH/B5Ny3/AL6AV+A5PReVZhV9xS6Bk/RdEUVzE7qXXtwDVyVQCaDoNeC3m/T7qRxkHThPvz9gnrzqlw8Bi3RyTyyoJjzkCTJcO8ApoEed5QAF74CHLDRDofwOShA9PgYOwpMAGPN34A04Grl3T6kZ/5KFJ5vAthEIgC4pLGgsLFMAoWp8pktfCFh6MZG2LQAlPLDpvS3ALDBrNhoutRUQh54LcJNhGYt9ONYKcH1XiAJ80CVTdMpWATwB6wIsEKswALpnupZsLE1dfwsorKl3WAP0hTKgCDcFTeeSWQc5YF+APcaXLSGKSq/1sBzah6h7GCmefNMqgP6SV0nTVsBSmq5SaK2A6AxdFi1V3kSxtQDMNPtal5l5s/Oy7SF2wlo/EmBIvbOS+f4ldQVBfbNzsR3Sj7p3UYG4yZBGKuaQELeLqtVNwGG6xUzwo9PJTGgxwY/p5HpYHDghJN0TrqVxaXXWQAqfpQH1nfrZ0uyuFUw+awUJcGNsVjjC9Ts2u6cqMgowhpH/IwGE2fxK99GH9R91mncY+HKoHAAAAABJRU5ErkJggg=="
;
String
str
=
"iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAB1UlEQVRIS5WVjTEEQRBG30WACBABGSACLgJEgAicCBABIkAEiIAMkAERUG9remtua2Z3rquuam935nvTPf0zY9y2gENgH/B5Ny3/AL6AV+A5PReVZhV9xS6Bk/RdEUVzE7qXXtwDVyVQCaDoNeC3m/T7qRxkHThPvz9gnrzqlw8Bi3RyTyyoJjzkCTJcO8ApoEed5QAF74CHLDRDofwOShA9PgYOwpMAGPN34A04Grl3T6kZ/5KFJ5vAthEIgC4pLGgsLFMAoWp8pktfCFh6MZG2LQAlPLDpvS3ALDBrNhoutRUQh54LcJNhGYt9ONYKcH1XiAJ80CVTdMpWATwB6wIsEKswALpnupZsLE1dfwsorKl3WAP0hTKgCDcFTeeSWQc5YF+APcaXLSGKSq/1sBzah6h7GCmefNMqgP6SV0nTVsBSmq5SaK2A6AxdFi1V3kSxtQDMNPtal5l5s/Oy7SF2wlo/EmBIvbOS+f4ldQVBfbNzsR3Sj7p3UYG4yZBGKuaQELeLqtVNwGG6xUzwo9PJTGgxwY/p5HpYHDghJN0TrqVxaXXWQAqfpQH1nfrZ0uyuFUw+awUJcGNsVjjC9Ts2u6cqMgowhpH/IwGE2fxK99GH9R91mncY+HKoHAAAAABJRU5ErkJggg=="
;
List
arrlist
=
new
ArrayList
();
List
arrlist
=
new
ArrayList
();
arrlist
.
add
(
str
);
arrlist
.
add
(
str
);
arrlist
.
add
(
str
);
arrlist
.
add
(
str
);
arrlist
.
add
(
str
);
arrlist
.
add
(
str
);
...
@@ -616,12 +538,12 @@ public class TraffController {
...
@@ -616,12 +538,12 @@ public class TraffController {
alarm
.
setImg_base64
(
arrlist
);
alarm
.
setImg_base64
(
arrlist
);
alarm
.
setTs
(
"1345677777"
);
alarm
.
setTs
(
"1345677777"
);
alarm
.
setType
(
"TRAFFIC_INCIDENT_ALARM"
);
alarm
.
setType
(
"TRAFFIC_INCIDENT_ALARM"
);
Map
map
=
new
HashMap
();
Map
map
=
new
HashMap
();
map
.
put
(
"type"
,
"alarm"
);
map
.
put
(
"type"
,
"alarm"
);
map
.
put
(
"data"
,
alarm
);
map
.
put
(
"data"
,
alarm
);
map
.
put
(
"recordid"
,
"33448"
);
map
.
put
(
"recordid"
,
"33448"
);
webSocket
.
GroupSending
(
JsonUtil
.
beanToString
(
map
));
webSocket
.
GroupSending
(
JsonUtil
.
beanToString
(
map
));
Traffalarmrecord
traffAlarmRecord
=
new
Traffalarmrecord
();
Traffalarmrecord
traffAlarmRecord
=
new
Traffalarmrecord
();
traffAlarmRecord
.
setRecordid
(
Long
.
parseLong
(
"33448"
));
traffAlarmRecord
.
setRecordid
(
Long
.
parseLong
(
"33448"
));
traffAlarmRecord
.
setChannelid
(
new
Integer
(
1
));
traffAlarmRecord
.
setChannelid
(
new
Integer
(
1
));
traffAlarmRecord
.
setFdid
(
"20200305112042989"
);
traffAlarmRecord
.
setFdid
(
"20200305112042989"
);
...
@@ -631,7 +553,7 @@ public class TraffController {
...
@@ -631,7 +553,7 @@ public class TraffController {
map
.
put
(
"recordid"
,
"33449"
);
map
.
put
(
"recordid"
,
"33449"
);
webSocket
.
GroupSending
(
JsonUtil
.
beanToString
(
map
));
webSocket
.
GroupSending
(
JsonUtil
.
beanToString
(
map
));
Traffalarmrecord
traffAlarmRecord2
=
new
Traffalarmrecord
();
Traffalarmrecord
traffAlarmRecord2
=
new
Traffalarmrecord
();
traffAlarmRecord2
.
setRecordid
(
Long
.
parseLong
(
"33449"
));
traffAlarmRecord2
.
setRecordid
(
Long
.
parseLong
(
"33449"
));
traffAlarmRecord2
.
setChannelid
(
new
Integer
(
1
));
traffAlarmRecord2
.
setChannelid
(
new
Integer
(
1
));
traffAlarmRecord2
.
setFdid
(
"20200305112042989"
);
traffAlarmRecord2
.
setFdid
(
"20200305112042989"
);
...
@@ -644,7 +566,7 @@ public class TraffController {
...
@@ -644,7 +566,7 @@ public class TraffController {
@GetMapping
(
"/testevent"
)
@GetMapping
(
"/testevent"
)
@ResponseBody
@ResponseBody
public
void
testevent
()
{
public
void
testevent
()
{
String
json
=
"{"
+
String
json
=
"{"
+
" \"type\": \"TRAFFIC_INCIDENT_ALARM\","
+
" \"type\": \"TRAFFIC_INCIDENT_ALARM\","
+
" \"id\": \"d9a2b0f0-f0cf-49b9-9b64-3da86a122afa\","
+
" \"id\": \"d9a2b0f0-f0cf-49b9-9b64-3da86a122afa\","
+
" \"video_id\": \"201809180950119121_0\","
+
" \"video_id\": \"201809180950119121_0\","
+
...
@@ -667,7 +589,7 @@ public class TraffController {
...
@@ -667,7 +589,7 @@ public class TraffController {
" \"img_base64\": [\"d0xEMHcFAESwdwaUjWDqB6/1Qw4LapAiSICVTOFWsGT0sgt\"]\n"
+
" \"img_base64\": [\"d0xEMHcFAESwdwaUjWDqB6/1Qw4LapAiSICVTOFWsGT0sgt\"]\n"
+
" }"
;
" }"
;
MqttAlarm
alarm
=
new
MqttAlarm
();
MqttAlarm
alarm
=
new
MqttAlarm
();
alarm
.
setHeight
(
"0.7"
);
alarm
.
setHeight
(
"0.7"
);
alarm
.
setWidth
(
"0.7"
);
alarm
.
setWidth
(
"0.7"
);
...
@@ -679,7 +601,7 @@ public class TraffController {
...
@@ -679,7 +601,7 @@ public class TraffController {
long
startTime
=
System
.
currentTimeMillis
();
long
startTime
=
System
.
currentTimeMillis
();
//ftp://reader:reader@33.50.1.22:21/
//ftp://reader:reader@33.50.1.22:21/
//ftp.host=33.65.219.103:21:hzjt:1qaz2wsx
//ftp.host=33.65.219.103:21:hzjt:1qaz2wsx
String
ftpPath
=
"ftp://"
+
ftppath
+
"/"
+
location
;
String
ftpPath
=
"ftp://"
+
ftppath
+
"/"
+
location
;
FileInputStream
hFile
=
null
;
FileInputStream
hFile
=
null
;
OutputStream
toClient
=
null
;
OutputStream
toClient
=
null
;
InputStream
inputStream
=
null
;
InputStream
inputStream
=
null
;
...
@@ -727,7 +649,7 @@ public class TraffController {
...
@@ -727,7 +649,7 @@ public class TraffController {
PrintWriter
out
=
response
.
getWriter
();
PrintWriter
out
=
response
.
getWriter
();
out
.
write
(
"无法打开图片!"
);
out
.
write
(
"无法打开图片!"
);
out
.
flush
();
out
.
flush
();
log
.
info
(
"ftpagent error "
+
ftpUrl
+
e
.
toString
());
log
.
info
(
"ftpagent error "
+
ftpUrl
+
e
.
toString
());
}
finally
{
}
finally
{
if
(
bis
!=
null
)
{
if
(
bis
!=
null
)
{
bis
.
close
();
bis
.
close
();
...
...
src/main/java/com/hzjt/redis/Receiver.java
View file @
1d1a1f06
...
@@ -95,8 +95,8 @@ public class Receiver {
...
@@ -95,8 +95,8 @@ public class Receiver {
/* 9:免审 */
/* 9:免审 */
traffAlarmRecord
.
setCheckstatus
(
9
);
traffAlarmRecord
.
setCheckstatus
(
9
);
}
}
int
recordid
=
traffAlarmRecordMapper
.
selectmax
();
//
int recordid = traffAlarmRecordMapper.selectmax();
traffAlarmRecord
.
setRecordid
((
long
)(
recordid
+
1
));
//
traffAlarmRecord.setRecordid((long)(recordid+1));
traffAlarmRecord
.
setProcessstatus
(
"0"
);
traffAlarmRecord
.
setProcessstatus
(
"0"
);
traffAlarmRecord
.
setAreaid
(
Long
.
valueOf
(
trffClientMessage
.
getDept
()));
traffAlarmRecord
.
setAreaid
(
Long
.
valueOf
(
trffClientMessage
.
getDept
()));
traffAlarmRecord
.
setRecordtype
(
trffClientMessage
.
getIncident_type
().
toLowerCase
());
traffAlarmRecord
.
setRecordtype
(
trffClientMessage
.
getIncident_type
().
toLowerCase
());
...
@@ -137,7 +137,7 @@ public class Receiver {
...
@@ -137,7 +137,7 @@ public class Receiver {
connection
.
setReadTimeout
(
2000
);
connection
.
setReadTimeout
(
2000
);
connection
.
setConnectTimeout
(
3000
);
connection
.
setConnectTimeout
(
3000
);
connection
.
setRequestMethod
(
"GET"
);
connection
.
setRequestMethod
(
"GET"
);
String
pname
=
DateUtils
.
formatCurrDayNoSign
()
+
"_"
+
recordid
+
"_0000_"
+
key
.
replace
(
"path"
,
""
);
String
pname
=
DateUtils
.
formatCurrDayNoSign
()
+
"_"
+
traffAlarmRecord
.
getFdid
()
+
"_"
+
traffAlarmRecord
.
getRecordid
()
+
key
.
replace
(
"path"
,
""
);
String
fileName
=
pname
+
".mp4"
;
String
fileName
=
pname
+
".mp4"
;
String
ftputl
=
FTPUtil
.
getFtpUrl
(
ftp
)
+
basepath
+
"/"
+
fileName
;
String
ftputl
=
FTPUtil
.
getFtpUrl
(
ftp
)
+
basepath
+
"/"
+
fileName
;
if
(
connection
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_OK
)
{
if
(
connection
.
getResponseCode
()
==
HttpURLConnection
.
HTTP_OK
)
{
...
...
src/main/java/com/hzjt/util/DateUtils.java
View file @
1d1a1f06
...
@@ -14,9 +14,9 @@ public class DateUtils {
...
@@ -14,9 +14,9 @@ public class DateUtils {
public
static
String
getDateString
(
Date
date
)
{
public
static
String
getDateString
(
Date
date
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
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"
));
formatter
.
setTimeZone
(
TimeZone
.
getTimeZone
(
"Asia/Shanghai"
));
log
.
info
(
"date timezone:{}"
,
formatter
.
getTimeZone
())
;
//
log.info("date timezone:{}",formatter.getTimeZone()) ;
String
dateString
=
formatter
.
format
(
date
);
String
dateString
=
formatter
.
format
(
date
);
return
dateString
;
return
dateString
;
}
}
...
...
src/main/resources/mapper/Traffalarmrecord.xml
View file @
1d1a1f06
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
set retrytime= sysdate,
set retrytime= sysdate,
retrycount= retrycount+1
retrycount= retrycount+1
<trim
prefix=
","
suffixOverrides=
","
>
<trim
prefix=
","
suffixOverrides=
","
>
<
if
test=
"img1path!=null"
>
img1path=#{img1path},
</if
>
<
!--<if test="img1path!=null">img1path=#{img1path},</if>--
>
<if
test=
"img2path!=null"
>
img2path=#{img2path},
</if>
<if
test=
"img2path!=null"
>
img2path=#{img2path},
</if>
<if
test=
"img3path!=null"
>
img3path=#{img3path},
</if>
<if
test=
"img3path!=null"
>
img3path=#{img3path},
</if>
<if
test=
"img4path!=null"
>
img4path=#{img4path},
</if>
<if
test=
"img4path!=null"
>
img4path=#{img4path},
</if>
...
@@ -26,6 +26,9 @@
...
@@ -26,6 +26,9 @@
</update>
</update>
<insert
id=
"inserTraffAlarmRecord"
>
<insert
id=
"inserTraffAlarmRecord"
>
<selectKey
keyProperty=
"recordid"
resultType=
"Long"
order=
"BEFORE"
>
select nvl(max(recordid),0)+1 from traffalarmrecord
</selectKey>
insert into traffalarmrecord
insert into traffalarmrecord
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"recordid != null"
>
recordid,
</if>
<if
test=
"recordid != null"
>
recordid,
</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