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
472648e2
Commit
472648e2
authored
Jun 05, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
收到的坐标未能及时更新到地图问题修改
parent
7b8f0c87
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
43 deletions
+43
-43
CarIotNewListener.java
...a/com/yeejoin/equipmanage/listener/CarIotNewListener.java
+43
-10
ThreadCar.java
...c/main/java/com/yeejoin/equipmanage/thread/ThreadCar.java
+0
-33
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 @
472648e2
...
@@ -66,28 +66,29 @@ public class CarIotNewListener extends EmqxListener {
...
@@ -66,28 +66,29 @@ public class CarIotNewListener extends EmqxListener {
String
iotCode
=
measurement
+
deviceName
;
String
iotCode
=
measurement
+
deviceName
;
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
message
.
toString
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
message
.
toString
());
if
(
jsonObject
.
containsKey
(
"FireCar_Longitude"
))
{
if
(
jsonObject
.
containsKey
(
"FireCar_Longitude"
))
{
this
.
updateCarLocation
(
jsonObject
,
iotCode
);
//如果map中已经存在该设备或者该设备有但是线程已经执行了
//如果map中已经存在该设备或者该设备有但是线程已经执行了
if
((!
deviceInfo
.
containsKey
(
topic
))
||
(
deviceInfo
.
containsKey
(
topic
)
&&
deviceInfo
.
get
(
topic
)
==
null
))
{
if
((!
deviceInfo
.
containsKey
(
iotCode
))
||
(
deviceInfo
.
containsKey
(
iotCode
)
&&
deviceInfo
.
get
(
iotCode
)
==
null
))
{
ThreadCar
threadCar
=
new
ThreadCar
(
topic
,
jsonObject
,
this
.
iWlCarMileageService
,
this
.
iotFeign
,
this
.
iCarService
,
this
.
emqkeeper
,
clipping_time
);
ThreadCar
threadCar
=
new
ThreadCar
(
iotCode
,
jsonObject
,
this
.
iWlCarMileageService
,
this
.
iotFeign
,
this
.
iCarService
,
this
.
emqkeeper
,
clipping_time
);
deviceInfo
.
put
(
topic
,
threadCar
);
deviceInfo
.
put
(
iotCode
,
threadCar
);
threadCar
.
start
();
threadCar
.
start
();
}
}
String
coordinate
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
)
+
String
.
valueOf
(
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
));
String
coordinate
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
)
+
String
.
valueOf
(
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
));
if
(!
deviceLastInfo
.
containsKey
(
topic
))
{
if
(!
deviceLastInfo
.
containsKey
(
iotCode
))
{
deviceLastInfo
.
put
(
topic
,
coordinate
);
deviceLastInfo
.
put
(
iotCode
,
coordinate
);
}
}
Long
currentTime
=
new
Date
().
getTime
();
Long
currentTime
=
new
Date
().
getTime
();
Long
endTime
=
jsonObject
.
getLong
(
"time"
);
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
(
iotCode
).
equals
(
coordinate
)))
{
try
{
try
{
deviceInfo
.
get
(
topic
).
interrupt
();
deviceInfo
.
get
(
iotCode
).
interrupt
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
}
}
ThreadCar
threadCar
=
new
ThreadCar
(
topic
,
jsonObject
,
this
.
iWlCarMileageService
,
this
.
iotFeign
,
this
.
iCarService
,
this
.
emqkeeper
,
clipping_time
);
ThreadCar
threadCar
=
new
ThreadCar
(
iotCode
,
jsonObject
,
this
.
iWlCarMileageService
,
this
.
iotFeign
,
this
.
iCarService
,
this
.
emqkeeper
,
clipping_time
);
deviceInfo
.
put
(
topic
,
threadCar
);
deviceInfo
.
put
(
iotCode
,
threadCar
);
//更新车辆的最新坐标数据
//更新车辆的最新坐标数据
deviceLastInfo
.
put
(
topic
,
coordinate
);
deviceLastInfo
.
put
(
iotCode
,
coordinate
);
threadCar
.
start
();
threadCar
.
start
();
}
}
if
(
iWlCarMileageService
.
getUncompleteMileagByIotCode
(
iotCode
))
{
if
(
iWlCarMileageService
.
getUncompleteMileagByIotCode
(
iotCode
))
{
...
@@ -162,5 +163,37 @@ public class CarIotNewListener extends EmqxListener {
...
@@ -162,5 +163,37 @@ public class CarIotNewListener extends EmqxListener {
calendar
.
set
(
Calendar
.
HOUR
,
calendar
.
get
(
Calendar
.
HOUR
)
+
8
);
calendar
.
set
(
Calendar
.
HOUR
,
calendar
.
get
(
Calendar
.
HOUR
)
+
8
);
return
calendar
.
getTime
();
return
calendar
.
getTime
();
}
}
public
void
updateCarLocation
(
JSONObject
jsonObject
,
String
iotCode
)
{
if
(
jsonObject
.
containsKey
(
"FireCar_Longitude"
)
&&
jsonObject
.
containsKey
(
"FireCar_Latitude"
))
{
// 获取开始坐标
double
startLongitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
);
double
startLatitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
);
int
direction
=
jsonObject
.
getIntValue
(
"direction"
);
// 地图推送消息
Car
car
=
iCarService
.
getOne
(
new
LambdaQueryWrapper
<
Car
>().
eq
(
Car:
:
getIotCode
,
iotCode
));
if
(
car
!=
null
&&
startLongitude
!=
0
&&
startLatitude
!=
0
)
{
JSONArray
sendArr
=
new
JSONArray
();
JSONObject
sendObj
=
new
JSONObject
();
sendObj
.
put
(
"id"
,
String
.
valueOf
(
car
.
getId
()));
sendObj
.
put
(
"direction"
,
direction
);
sendObj
.
put
(
"longitude"
,
String
.
valueOf
(
startLongitude
));
sendObj
.
put
(
"latitude"
,
String
.
valueOf
(
startLatitude
));
sendObj
.
put
(
"carNum"
,
car
.
getCarNum
());
sendObj
.
put
(
"bizOrgName"
,
car
.
getBizOrgName
());
sendArr
.
add
(
sendObj
);
MqttMessage
mqttMessage
=
new
MqttMessage
();
mqttMessage
.
setPayload
(
sendArr
.
toJSONString
().
getBytes
());
car
.
setLongitude
(
startLongitude
);
car
.
setLatitude
(
startLatitude
);
iCarService
.
updateById
(
car
);
System
.
out
.
println
(
"-----------推送车辆位置消息到到地图成功--------"
);
try
{
emqkeeper
.
getMqttClient
().
publish
(
"car/location"
,
mqttMessage
);
}
catch
(
MqttException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/thread/ThreadCar.java
View file @
472648e2
...
@@ -113,7 +113,6 @@ public class ThreadCar extends Thread {
...
@@ -113,7 +113,6 @@ public class ThreadCar extends Thread {
}
}
last
.
setTravel
(
new
BigDecimal
(
travel
/
1000
).
setScale
(
1
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
());
last
.
setTravel
(
new
BigDecimal
(
travel
/
1000
).
setScale
(
1
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
());
iWlCarMileageService
.
updateById
(
last
);
iWlCarMileageService
.
updateById
(
last
);
this
.
pushCarInfoToMap
(
jsonObject
,
topic
);
System
.
out
.
println
(
"============================================================更新结束坐标成功==========:"
+
topic
);
System
.
out
.
println
(
"============================================================更新结束坐标成功==========:"
+
topic
);
this
.
interrupt
();
this
.
interrupt
();
}
}
...
@@ -124,37 +123,5 @@ public class ThreadCar extends Thread {
...
@@ -124,37 +123,5 @@ public class ThreadCar extends Thread {
}
}
}
}
public
void
pushCarInfoToMap
(
JSONObject
jsonObject
,
String
iotCode
)
{
if
(
jsonObject
.
containsKey
(
"FireCar_Longitude"
)
&&
jsonObject
.
containsKey
(
"FireCar_Latitude"
))
{
// 获取开始坐标
double
startLongitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
);
double
startLatitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
);
int
direction
=
jsonObject
.
getIntValue
(
"direction"
);
// 地图推送消息
Car
car
=
iCarService
.
getOne
(
new
LambdaQueryWrapper
<
Car
>().
eq
(
Car:
:
getIotCode
,
iotCode
));
if
(
car
!=
null
&&
startLongitude
!=
0
&&
startLatitude
!=
0
)
{
JSONArray
sendArr
=
new
JSONArray
();
JSONObject
sendObj
=
new
JSONObject
();
sendObj
.
put
(
"id"
,
String
.
valueOf
(
car
.
getId
()));
sendObj
.
put
(
"direction"
,
direction
);
sendObj
.
put
(
"longitude"
,
String
.
valueOf
(
startLongitude
));
sendObj
.
put
(
"latitude"
,
String
.
valueOf
(
startLatitude
));
sendObj
.
put
(
"carNum"
,
car
.
getCarNum
());
sendObj
.
put
(
"bizOrgName"
,
car
.
getBizOrgName
());
sendArr
.
add
(
sendObj
);
MqttMessage
mqttMessage
=
new
MqttMessage
();
mqttMessage
.
setPayload
(
sendArr
.
toJSONString
().
getBytes
());
car
.
setLongitude
(
startLongitude
);
car
.
setLatitude
(
startLatitude
);
iCarService
.
updateById
(
car
);
try
{
emqkeeper
.
getMqttClient
().
publish
(
"car/location"
,
mqttMessage
);
}
catch
(
MqttException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
}
}
}
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