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
c8e8de47
Commit
c8e8de47
authored
Jun 03, 2023
by
maoying
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop_dl' of
http://39.98.45.134:8090/moa/amos-boot-biz
into develop_dl
parents
48c973b9
9c47e72a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
10 deletions
+72
-10
CarIotNewListener.java
...a/com/yeejoin/equipmanage/listener/CarIotNewListener.java
+0
-0
IWlCarMileageService.java
...com/yeejoin/equipmanage/service/IWlCarMileageService.java
+2
-1
WlCarMileageServiceImpl.java
...oin/equipmanage/service/impl/WlCarMileageServiceImpl.java
+7
-0
ThreadCar.java
...c/main/java/com/yeejoin/equipmanage/thread/ThreadCar.java
+58
-9
CarUtils.java
...src/main/java/com/yeejoin/equipmanage/utils/CarUtils.java
+5
-0
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 @
c8e8de47
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/service/IWlCarMileageService.java
View file @
c8e8de47
...
@@ -30,6 +30,7 @@ public interface IWlCarMileageService extends IService<WlCarMileage> {
...
@@ -30,6 +30,7 @@ public interface IWlCarMileageService extends IService<WlCarMileage> {
* 里程切分(0点若里程未结束,自动切分设置结束信息,并开始新里程)
* 里程切分(0点若里程未结束,自动切分设置结束信息,并开始新里程)
*/
*/
void
mileageSegmentation
();
void
mileageSegmentation
();
//根据iot编码查询是否有未结束里程
Boolean
getUncompleteMileagByIotCode
(
String
iotCode
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/WlCarMileageServiceImpl.java
View file @
c8e8de47
...
@@ -3,6 +3,7 @@ package com.yeejoin.equipmanage.service.impl;
...
@@ -3,6 +3,7 @@ package com.yeejoin.equipmanage.service.impl;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
...
@@ -384,6 +385,12 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
...
@@ -384,6 +385,12 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
log
.
info
(
"轨迹切分任务执行完成.............."
);
log
.
info
(
"轨迹切分任务执行完成.............."
);
}
}
@Override
public
Boolean
getUncompleteMileagByIotCode
(
String
iotCode
)
{
Integer
integer
=
this
.
count
(
new
QueryWrapper
<
WlCarMileage
>().
select
(
"1"
).
lambda
().
eq
(
WlCarMileage:
:
getIotCode
,
iotCode
).
isNull
(
WlCarMileage:
:
getEndTime
));
return
integer
<=
0
;
}
private
String
getAddress
(
double
longitude
,
double
lantitude
)
{
private
String
getAddress
(
double
longitude
,
double
lantitude
)
{
StringBuilder
api
=
new
StringBuilder
(
GUIDE_ADDRESS_URL
);
StringBuilder
api
=
new
StringBuilder
(
GUIDE_ADDRESS_URL
);
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/thread/ThreadCar.java
View file @
c8e8de47
package
com
.
yeejoin
.
equipmanage
.
thread
;
package
com
.
yeejoin
.
equipmanage
.
thread
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.equipmanage.common.entity.Car
;
import
com.yeejoin.equipmanage.common.entity.WlCarMileage
;
import
com.yeejoin.equipmanage.common.entity.WlCarMileage
;
import
com.yeejoin.equipmanage.common.utils.CoordinateUtil
;
import
com.yeejoin.equipmanage.common.utils.CoordinateUtil
;
import
com.yeejoin.equipmanage.fegin.IotFeign
;
import
com.yeejoin.equipmanage.fegin.IotFeign
;
import
com.yeejoin.equipmanage.service.ICarService
;
import
com.yeejoin.equipmanage.service.IWlCarMileageService
;
import
com.yeejoin.equipmanage.service.IWlCarMileageService
;
import
com.yeejoin.equipmanage.utils.CarUtils
;
import
com.yeejoin.equipmanage.utils.CarUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Timer
;
import
java.util.concurrent.TimeUnit
;
public
class
ThreadCar
extends
Thread
{
public
class
ThreadCar
extends
Thread
{
@Autowired
private
IWlCarMileageService
iWlCarMileageService
;
private
IWlCarMileageService
iWlCarMileageService
;
@Autowired
private
IotFeign
iotFeign
;
private
IotFeign
iotFeign
;
private
String
topic
;
private
String
topic
;
private
Long
clippingTime
;
ICarService
iCarService
;
private
EmqKeeper
emqkeeper
;
private
JSONObject
jsonObject
;
private
JSONObject
jsonObject
;
public
ThreadCar
(
String
topic
,
JSONObject
jsonObject
){
public
ThreadCar
(
String
topic
,
JSONObject
jsonObject
,
IWlCarMileageService
iWlCarMileageService
,
IotFeign
iotFeign
,
ICarService
iCarService
,
EmqKeeper
emqkeeper
,
Long
clippingTime
)
{
this
.
topic
=
topic
;
this
.
topic
=
topic
;
this
.
jsonObject
=
jsonObject
;
this
.
jsonObject
=
jsonObject
;
this
.
iWlCarMileageService
=
iWlCarMileageService
;
this
.
iotFeign
=
iotFeign
;
this
.
iCarService
=
iCarService
;
this
.
emqkeeper
=
emqkeeper
;
this
.
clippingTime
=
clippingTime
;
}
}
@Override
@Override
public
void
run
()
{
public
void
run
()
{
//toDo
//toDo
// 获取最后一个有坐标的数据
// 获取最后一个有坐标的数据
JSONObject
lastObj
=
null
;
JSONObject
lastObj
=
null
;
WlCarMileage
last
=
null
;
WlCarMileage
last
=
null
;
try
{
try
{
T
hread
.
sleep
(
600000
);
T
imeUnit
.
MILLISECONDS
.
sleep
(
Long
.
valueOf
((
long
)
(
clippingTime
))
);
//业务处理
//业务处理
//如果十分钟没有坐标,则需要设置结束标记
//如果十分钟没有坐标,则需要设置结束标记
// 获取结束坐标
// 获取结束坐标
...
@@ -79,7 +94,7 @@ public class ThreadCar extends Thread {
...
@@ -79,7 +94,7 @@ public class ThreadCar extends Thread {
// 230215180624
// 230215180624
// Date endTime =UTCToCST(lastObj.getString("time"));
// Date endTime =UTCToCST(lastObj.getString("time"));
Date
endTime
=
new
Date
(
jsonObject
.
getLong
(
"time"
)
);
Date
endTime
=
new
Date
();
long
takeTime
=
(
endTime
.
getTime
()
/
1000
*
1000
)
-
(
last
.
getStartTime
().
getTime
()
/
1000
*
1000
);
long
takeTime
=
(
endTime
.
getTime
()
/
1000
*
1000
)
-
(
last
.
getStartTime
().
getTime
()
/
1000
*
1000
);
last
.
setEndLongitude
(
endLongitude
);
last
.
setEndLongitude
(
endLongitude
);
last
.
setEndLatitude
(
endLatitude
);
last
.
setEndLatitude
(
endLatitude
);
...
@@ -98,10 +113,44 @@ public class ThreadCar extends Thread {
...
@@ -98,10 +113,44 @@ 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
);
this
.
interrupt
();
this
.
interrupt
();
}
}
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
iWlCarMileageService
.
updateById
(
last
);
}
}
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
);
}
}
}
}
}
}
}
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/utils/CarUtils.java
View file @
c8e8de47
package
com
.
yeejoin
.
equipmanage
.
utils
;
package
com
.
yeejoin
.
equipmanage
.
utils
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.equipmanage.common.entity.Car
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.IOException
;
...
...
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