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
19bbf0cc
Commit
19bbf0cc
authored
Aug 22, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
江西电建车辆相关代码调整优化并增加日志
parent
b8d877f3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
15 deletions
+21
-15
CarIotNewListener.java
...a/com/yeejoin/equipmanage/listener/CarIotNewListener.java
+0
-0
ThreadCar.java
...c/main/java/com/yeejoin/equipmanage/thread/ThreadCar.java
+15
-12
ThreadCarMileageTreatment.java
...yeejoin/equipmanage/thread/ThreadCarMileageTreatment.java
+6
-3
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 @
19bbf0cc
This diff is collapsed.
Click to expand it.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/thread/ThreadCar.java
View file @
19bbf0cc
...
@@ -13,6 +13,8 @@ import com.yeejoin.equipmanage.utils.CarUtils;
...
@@ -13,6 +13,8 @@ import com.yeejoin.equipmanage.utils.CarUtils;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.jfree.util.Log
;
import
org.jfree.util.Log
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
...
@@ -23,27 +25,25 @@ import java.util.List;
...
@@ -23,27 +25,25 @@ import java.util.List;
import
java.util.Timer
;
import
java.util.Timer
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
public
class
ThreadCar
extends
Thread
{
public
class
ThreadCar
extends
Thread
{
Logger
logger
=
LoggerFactory
.
getLogger
(
ThreadCar
.
class
);
private
IWlCarMileageService
iWlCarMileageService
;
private
IWlCarMileageService
iWlCarMileageService
;
private
IotFeign
iotFeign
;
private
IotFeign
iotFeign
;
private
String
topic
;
private
String
topic
;
private
Long
clippingTime
;
private
Long
clippingTime
;
ICarService
iCarService
;
ICarService
iCarService
;
private
EmqKeeper
emqkeeper
;
private
JSONObject
jsonObject
;
private
JSONObject
jsonObject
;
public
ThreadCar
(
String
topic
,
JSONObject
jsonObject
,
IWlCarMileageService
iWlCarMileageService
,
IotFeign
iotFeign
,
ICarService
iCarService
,
EmqKeeper
emqkeeper
,
Long
clippingTime
)
{
public
ThreadCar
(
String
topic
,
JSONObject
jsonObject
,
IWlCarMileageService
iWlCarMileageService
,
IotFeign
iotFeign
,
ICarService
iCarService
,
Long
clippingTime
)
{
this
.
topic
=
topic
;
this
.
topic
=
topic
;
this
.
jsonObject
=
jsonObject
;
this
.
jsonObject
=
jsonObject
;
this
.
iWlCarMileageService
=
iWlCarMileageService
;
this
.
iWlCarMileageService
=
iWlCarMileageService
;
this
.
iotFeign
=
iotFeign
;
this
.
iotFeign
=
iotFeign
;
this
.
iCarService
=
iCarService
;
this
.
iCarService
=
iCarService
;
this
.
emqkeeper
=
emqkeeper
;
this
.
clippingTime
=
clippingTime
;
this
.
clippingTime
=
clippingTime
;
}
}
@Override
@Override
public
void
run
()
{
public
void
run
()
{
//toDo
//toDo
...
@@ -51,7 +51,8 @@ public class ThreadCar extends Thread {
...
@@ -51,7 +51,8 @@ public class ThreadCar extends Thread {
JSONObject
lastObj
=
null
;
JSONObject
lastObj
=
null
;
WlCarMileage
last
=
null
;
WlCarMileage
last
=
null
;
try
{
try
{
Log
.
info
(
"-------------------------"
+
this
.
topic
+
"结束坐标开始计时------------------------------"
);
Long
startTime
=
System
.
currentTimeMillis
();
logger
.
info
(
"============================================="
+
topic
+
"结束坐标开始计时======================================="
);
this
.
sleep
(
clippingTime
);
this
.
sleep
(
clippingTime
);
//业务处理
//业务处理
//如果十分钟没有坐标,则需要设置结束标记
//如果十分钟没有坐标,则需要设置结束标记
...
@@ -67,7 +68,6 @@ public class ThreadCar extends Thread {
...
@@ -67,7 +68,6 @@ public class ThreadCar extends Thread {
last
.
getStartTime
(),
new
Date
(
new
Date
().
getTime
()
+
2000
));
last
.
getStartTime
(),
new
Date
(
new
Date
().
getTime
()
+
2000
));
List
<
Object
>
list
=
result
.
getResult
();
List
<
Object
>
list
=
result
.
getResult
();
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
// 过滤空坐标
// 过滤空坐标
List
<
Object
>
filterList
=
new
ArrayList
<
Object
>();
List
<
Object
>
filterList
=
new
ArrayList
<
Object
>();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
...
@@ -82,8 +82,6 @@ public class ThreadCar extends Thread {
...
@@ -82,8 +82,6 @@ public class ThreadCar extends Thread {
}
}
}
}
}
}
// JSONObject lastObj =
// JSONObject.parseObject(JSONObject.toJSONString(list.get(list.size() - 1)));
if
(
lastObj
==
null
)
{
if
(
lastObj
==
null
)
{
lastObj
=
new
JSONObject
();
lastObj
=
new
JSONObject
();
lastObj
.
put
(
"FireCar_Longitude"
,
last
.
getStartLongitude
());
lastObj
.
put
(
"FireCar_Longitude"
,
last
.
getStartLongitude
());
...
@@ -117,13 +115,18 @@ public class ThreadCar extends Thread {
...
@@ -117,13 +115,18 @@ 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
);
Log
.
info
(
"============================================================更新结束坐标成功==========:"
+
topic
);
Long
lastTime
=
System
.
currentTimeMillis
();
this
.
interrupt
();
logger
.
info
(
"--------------"
+
topic
+
"结束坐标成功::花费时间===="
+
String
.
valueOf
((
lastTime
-
startTime
)/
60000
)+
"-------------------------"
);
logger
.
info
(
"============================================================更新结束坐标成功==============================================:"
+
topic
);
}
}
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
if
(
last
!=
null
)
{
if
(
last
!=
null
)
{
logger
.
info
(
"---异常时获取到的获取last信息::"
+
JSONObject
.
toJSONString
(
last
));
iWlCarMileageService
.
updateById
(
last
);
iWlCarMileageService
.
updateById
(
last
);
}
}
}
finally
{
logger
.
info
(
"销毁车辆倒计时线程::topic_"
+
topic
);
this
.
interrupt
();
}
}
}
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/thread/ThreadCarMileageTreatment.java
View file @
19bbf0cc
...
@@ -14,6 +14,8 @@ import com.yeejoin.equipmanage.service.impl.WlCarMileageServiceImpl;
...
@@ -14,6 +14,8 @@ import com.yeejoin.equipmanage.service.impl.WlCarMileageServiceImpl;
import
com.yeejoin.equipmanage.utils.CarUtils
;
import
com.yeejoin.equipmanage.utils.CarUtils
;
import
liquibase.pro.packaged.E
;
import
liquibase.pro.packaged.E
;
import
org.jfree.util.Log
;
import
org.jfree.util.Log
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -28,6 +30,7 @@ import java.util.List;
...
@@ -28,6 +30,7 @@ import java.util.List;
@Component
@Component
public
class
ThreadCarMileageTreatment
extends
Thread
{
public
class
ThreadCarMileageTreatment
extends
Thread
{
Logger
logger
=
LoggerFactory
.
getLogger
(
ThreadCarMileageTreatment
.
class
);
@Autowired
@Autowired
private
WlCarMileageServiceImpl
wlCarMileageServiceImpl
;
private
WlCarMileageServiceImpl
wlCarMileageServiceImpl
;
...
@@ -40,7 +43,7 @@ public class ThreadCarMileageTreatment extends Thread {
...
@@ -40,7 +43,7 @@ public class ThreadCarMileageTreatment extends Thread {
@Override
@Override
public
void
run
()
{
public
void
run
()
{
Log
.
info
(
"----------------------------------------------------开始处理未结束里程---------------------------------"
);
logger
.
info
(
"----------------------------------------------------开始处理未结束里程---------------------------------"
);
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
HashMap
<
String
,
String
>
hashMap
=
new
HashMap
<>();
//toDo
//toDo
WlCarMileage
last
=
null
;
WlCarMileage
last
=
null
;
...
@@ -82,7 +85,7 @@ public class ThreadCarMileageTreatment extends Thread {
...
@@ -82,7 +85,7 @@ public class ThreadCarMileageTreatment extends Thread {
lastObj
=
Obj
;
lastObj
=
Obj
;
}
}
}
}
Log
.
info
(
"----------------------------------------lastobj----------------------"
+
lastObj
.
toJSONString
());
logger
.
info
(
"----------------------------------------lastobj----------------------"
+
lastObj
.
toJSONString
());
if
(
lastObj
==
null
)
{
if
(
lastObj
==
null
)
{
lastObj
=
new
JSONObject
();
lastObj
=
new
JSONObject
();
lastObj
.
put
(
"FireCar_Longitude"
,
last
.
getStartLongitude
());
lastObj
.
put
(
"FireCar_Longitude"
,
last
.
getStartLongitude
());
...
@@ -113,7 +116,7 @@ public class ThreadCarMileageTreatment extends Thread {
...
@@ -113,7 +116,7 @@ public class ThreadCarMileageTreatment extends Thread {
end
.
getDoubleValue
(
"FireCar_Longitude"
));
end
.
getDoubleValue
(
"FireCar_Longitude"
));
}
}
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
());
Log
.
info
(
"----------------------------------------last----------------------"
+
lastObj
.
toJSONString
());
logger
.
info
(
"----------------------------------------last----------------------"
+
lastObj
.
toJSONString
());
// wlCarMileageServiceImpl.updateById(last);
// wlCarMileageServiceImpl.updateById(last);
}
}
}
}
...
...
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