Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
项目统一框架
amos-boot-biz
Commits
e89c404f
Commit
e89c404f
authored
Jun 03, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对于收到的消息进行坐标校验,避免大量的无效坐标
parent
6597a33e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
42 deletions
+44
-42
CarIotNewListener.java
...a/com/yeejoin/equipmanage/listener/CarIotNewListener.java
+44
-42
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/listener/CarIotNewListener.java
View file @
e89c404f
...
@@ -65,50 +65,52 @@ public class CarIotNewListener extends EmqxListener {
...
@@ -65,50 +65,52 @@ public class CarIotNewListener extends EmqxListener {
String
deviceName
=
topic
.
split
(
"/"
)[
1
];
String
deviceName
=
topic
.
split
(
"/"
)[
1
];
String
iotCode
=
measurement
+
deviceName
;
String
iotCode
=
measurement
+
deviceName
;
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
message
.
toString
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
message
.
toString
());
//如果map中已经存在该设备或者该设备有但是线程已经执行了
if
(
jsonObject
.
containsKey
(
"FireCar_Longitude"
))
{
if
((!
deviceInfo
.
containsKey
(
topic
))
||
(
deviceInfo
.
containsKey
(
topic
)
&&
deviceInfo
.
get
(
topic
)
==
null
))
{
//如果map中已经存在该设备或者该设备有但是线程已经执行了
ThreadCar
threadCar
=
new
ThreadCar
(
topic
,
jsonObject
,
this
.
iWlCarMileageService
,
this
.
iotFeign
,
this
.
iCarService
,
this
.
emqkeeper
,
clipping_time
);
if
((!
deviceInfo
.
containsKey
(
topic
))
||
(
deviceInfo
.
containsKey
(
topic
)
&&
deviceInfo
.
get
(
topic
)
==
null
))
{
deviceInfo
.
put
(
topic
,
threadCar
);
ThreadCar
threadCar
=
new
ThreadCar
(
topic
,
jsonObject
,
this
.
iWlCarMileageService
,
this
.
iotFeign
,
this
.
iCarService
,
this
.
emqkeeper
,
clipping_time
);
threadCar
.
start
();
deviceInfo
.
put
(
topic
,
threadCar
);
}
threadCar
.
start
();
String
coordinate
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
)
+
String
.
valueOf
(
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
));
}
if
(!
deviceLastInfo
.
containsKey
(
topic
)){
String
coordinate
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
)
+
String
.
valueOf
(
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
));
deviceLastInfo
.
put
(
topic
,
coordinate
);
if
(!
deviceLastInfo
.
containsKey
(
topic
))
{
}
deviceLastInfo
.
put
(
topic
,
coordinate
);
Long
currentTime
=
new
Date
().
getTime
();
}
Long
endTime
=
jsonObject
.
getLong
(
"time"
);
Long
currentTime
=
new
Date
().
getTime
();
Long
endTime
=
jsonObject
.
getLong
(
"time"
);
// if ((startTime - endTime) <= 600000) {
// if ((startTime - endTime) <= 600000) {
if
(((
currentTime
-
endTime
)
<=
clipping_time
)&&(!
deviceLastInfo
.
get
(
topic
).
equals
(
coordinate
)))
{
if
(((
currentTime
-
endTime
)
<=
clipping_time
)
&&
(!
deviceLastInfo
.
get
(
topic
).
equals
(
coordinate
)))
{
try
{
try
{
deviceInfo
.
get
(
topic
).
interrupt
();
deviceInfo
.
get
(
topic
).
interrupt
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
ThreadCar
threadCar
=
new
ThreadCar
(
topic
,
jsonObject
,
this
.
iWlCarMileageService
,
this
.
iotFeign
,
this
.
iCarService
,
this
.
emqkeeper
,
clipping_time
);
deviceInfo
.
put
(
topic
,
threadCar
);
//更新车辆的最新坐标数据
deviceLastInfo
.
put
(
topic
,
coordinate
);
threadCar
.
start
();
}
}
ThreadCar
threadCar
=
new
ThreadCar
(
topic
,
jsonObject
,
this
.
iWlCarMileageService
,
this
.
iotFeign
,
this
.
iCarService
,
this
.
emqkeeper
,
clipping_time
);
if
(
iWlCarMileageService
.
getUncompleteMileagByIotCode
(
iotCode
))
{
deviceInfo
.
put
(
topic
,
threadCar
);
WlCarMileage
wlCarMileage
=
new
WlCarMileage
();
//更新车辆的最新坐标数据
wlCarMileage
.
setIotCode
(
iotCode
);
deviceLastInfo
.
put
(
topic
,
coordinate
);
wlCarMileage
.
setDate
(
new
Date
());
threadCar
.
start
();
// 获取开始坐标
}
double
startLongitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
);
if
(
iWlCarMileageService
.
getUncompleteMileagByIotCode
(
iotCode
))
{
double
startLatitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
);
WlCarMileage
wlCarMileage
=
new
WlCarMileage
();
// String currentTime = "20"+jsonObject.getString("currentTime");
wlCarMileage
.
setIotCode
(
iotCode
);
wlCarMileage
.
setStartLongitude
(
startLongitude
);
wlCarMileage
.
setDate
(
new
Date
());
wlCarMileage
.
setStartLatitude
(
startLatitude
);
// 获取开始坐标
// Date startTime = UTCToCST();
double
startLongitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
);
Date
startTime
=
new
Date
(
jsonObject
.
getLong
(
"time"
));
double
startLatitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
);
wlCarMileage
.
setStartTime
(
startTime
);
// String currentTime = "20"+jsonObject.getString("currentTime");
wlCarMileage
.
setStartName
(
getAddress
(
startLongitude
,
startLatitude
));
wlCarMileage
.
setStartLongitude
(
startLongitude
);
wlCarMileage
.
setStartSpeed
(
jsonObject
.
getIntValue
(
"FireCar_Speed"
));
wlCarMileage
.
setStartLatitude
(
startLatitude
);
try
{
// Date startTime = UTCToCST();
iWlCarMileageService
.
save
(
wlCarMileage
);
Date
startTime
=
new
Date
(
jsonObject
.
getLong
(
"time"
));
}
catch
(
Exception
e
)
{
wlCarMileage
.
setStartTime
(
startTime
);
e
.
printStackTrace
();
wlCarMileage
.
setStartName
(
getAddress
(
startLongitude
,
startLatitude
));
iWlCarMileageService
.
save
(
wlCarMileage
);
wlCarMileage
.
setStartSpeed
(
jsonObject
.
getIntValue
(
"FireCar_Speed"
));
}
try
{
iWlCarMileageService
.
save
(
wlCarMileage
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
iWlCarMileageService
.
save
(
wlCarMileage
);
}
}
}
}
}
}
...
...
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