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
3866af04
Commit
3866af04
authored
Feb 22, 2023
by
wujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改车辆管理新需求接口
parent
77924dc6
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
454 additions
and
168 deletions
+454
-168
Car.java
.../main/java/com/yeejoin/equipmanage/common/entity/Car.java
+48
-5
WlCarMileage.java
...a/com/yeejoin/equipmanage/common/entity/WlCarMileage.java
+1
-0
CarTravelDto.java
...m/yeejoin/equipmanage/common/entity/dto/CarTravelDto.java
+2
-2
CarController.java
...ava/com/yeejoin/equipmanage/controller/CarController.java
+7
-0
WlCarMileageController.java
...eejoin/equipmanage/controller/WlCarMileageController.java
+36
-2
CarIotListener.java
...java/com/yeejoin/equipmanage/listener/CarIotListener.java
+136
-79
ICarService.java
...ain/java/com/yeejoin/equipmanage/service/ICarService.java
+2
-0
IWlCarMileageService.java
...com/yeejoin/equipmanage/service/IWlCarMileageService.java
+4
-0
CarServiceImpl.java
.../com/yeejoin/equipmanage/service/impl/CarServiceImpl.java
+33
-3
MqttReceiveServiceImpl.java
...join/equipmanage/service/impl/MqttReceiveServiceImpl.java
+66
-66
WlCarMileageServiceImpl.java
...oin/equipmanage/service/impl/WlCarMileageServiceImpl.java
+100
-10
WlCarMileageMapper.xml
...em-equip/src/main/resources/mapper/WlCarMileageMapper.xml
+19
-1
No files found.
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/Car.java
View file @
3866af04
package
com
.
yeejoin
.
equipmanage
.
common
.
entity
;
package
com
.
yeejoin
.
equipmanage
.
common
.
entity
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.yeejoin.equipmanage.common.entity.publics.BaseEntity
;
import
com.yeejoin.equipmanage.common.entity.publics.BaseEntity
;
import
com.yeejoin.equipmanage.common.entity.vo.EquipmentOnCarAppVO
;
import
com.yeejoin.equipmanage.common.entity.vo.EquipmentOnCarAppVO
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
lombok.experimental.Accessors
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
/**
* 消防车信息
* 消防车信息
*
*
...
@@ -22,7 +28,7 @@ import java.util.List;
...
@@ -22,7 +28,7 @@ import java.util.List;
@Data
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
@EqualsAndHashCode
(
callSuper
=
true
)
@Accessors
(
chain
=
true
)
@Accessors
(
chain
=
true
)
@TableName
(
"wl_car"
)
@TableName
(
value
=
"wl_car"
,
autoResultMap
=
true
)
@ApiModel
(
value
=
"Car对象"
,
description
=
"消防车信息"
)
@ApiModel
(
value
=
"Car对象"
,
description
=
"消防车信息"
)
public
class
Car
extends
BaseEntity
{
public
class
Car
extends
BaseEntity
{
...
@@ -177,11 +183,48 @@ public class Car extends BaseEntity {
...
@@ -177,11 +183,48 @@ public class Car extends BaseEntity {
private
Integer
totalTravel
;
private
Integer
totalTravel
;
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
double
long
t
itude
;
private
double
longitude
;
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
double
latitude
;
private
double
latitude
;
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
Integer
speed
;
private
Integer
speed
;
@ApiModelProperty
(
value
=
"配备方式"
)
private
String
deployment
;
@ApiModelProperty
(
value
=
"配备日期"
)
private
String
deployDate
;
@ApiModelProperty
(
value
=
"配备日期区间"
)
@TableField
(
typeHandler
=
FastjsonTypeHandler
.
class
)
private
List
<
String
>
deployDateRange
;
@ApiModelProperty
(
value
=
"排量"
)
private
String
displacement
;
@ApiModelProperty
(
value
=
"车辆产权单位"
)
private
String
ownership
;
@ApiModelProperty
(
value
=
"编号"
)
private
String
code
;
@ApiModelProperty
(
value
=
"扩展字段1"
)
private
String
extra1
;
@ApiModelProperty
(
value
=
"扩展字段2"
)
private
String
extra2
;
@ApiModelProperty
(
value
=
"扩展字段3"
)
private
String
extra3
;
@ApiModelProperty
(
value
=
"扩展字段4"
)
private
String
extra4
;
@TableField
(
exist
=
false
)
private
String
iotMeasurement
;
@TableField
(
exist
=
false
)
private
String
iotDeviceName
;
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/WlCarMileage.java
View file @
3866af04
...
@@ -83,4 +83,5 @@ public class WlCarMileage extends BaseEntity {
...
@@ -83,4 +83,5 @@ public class WlCarMileage extends BaseEntity {
@TableField
(
exist
=
false
)
@TableField
(
exist
=
false
)
private
long
carId
;
private
long
carId
;
}
}
amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/entity/dto/CarTravelDto.java
View file @
3866af04
...
@@ -2,7 +2,7 @@ package com.yeejoin.equipmanage.common.entity.dto;
...
@@ -2,7 +2,7 @@ package com.yeejoin.equipmanage.common.entity.dto;
import
java.util.List
;
import
java.util.List
;
import
com.yeejoin.equipmanage.common.
entity.WlCarMileage
;
import
com.yeejoin.equipmanage.common.
dto.WlCarMileageDto
;
import
lombok.Data
;
import
lombok.Data
;
@Data
@Data
...
@@ -14,6 +14,6 @@ public class CarTravelDto {
...
@@ -14,6 +14,6 @@ public class CarTravelDto {
Integer
totalTravel
;
Integer
totalTravel
;
List
<
WlCarMileage
>
records
;
List
<
WlCarMileage
Dto
>
records
;
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/CarController.java
View file @
3866af04
...
@@ -1419,4 +1419,11 @@ public class CarController extends AbstractBaseController {
...
@@ -1419,4 +1419,11 @@ public class CarController extends AbstractBaseController {
public
ResponseModel
<
Object
>
getQRCode
(
long
id
)
throws
Exception
{
public
ResponseModel
<
Object
>
getQRCode
(
long
id
)
throws
Exception
{
return
ResponseHelper
.
buildResponse
(
iCarService
.
getQRCode
(
id
));
return
ResponseHelper
.
buildResponse
(
iCarService
.
getQRCode
(
id
));
}
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@RequestMapping
(
value
=
"/location"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"获取二维码图片"
,
notes
=
"获取二维码图片"
)
public
ResponseModel
<
Object
>
location
()
throws
Exception
{
return
ResponseHelper
.
buildResponse
(
iCarService
.
location
());
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/controller/WlCarMileageController.java
View file @
3866af04
package
com
.
yeejoin
.
equipmanage
.
controller
;
package
com
.
yeejoin
.
equipmanage
.
controller
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.yeejoin.equipmanage.common.dto.WlCarMileageDto
;
import
com.yeejoin.equipmanage.common.entity.WlCarMileage
;
import
com.yeejoin.equipmanage.common.entity.WlCarMileage
;
import
com.yeejoin.equipmanage.common.entity.dto.CarTravelDto
;
import
com.yeejoin.equipmanage.common.entity.dto.CarTravelDto
;
import
com.yeejoin.equipmanage.common.utils.NameUtils
;
import
com.yeejoin.equipmanage.common.utils.NameUtils
;
import
com.yeejoin.equipmanage.service.IWlCarMileageService
;
import
com.yeejoin.equipmanage.service.IWlCarMileageService
;
import
com.yeejoin.equipmanage.utils.BeanUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -159,15 +165,24 @@ public class WlCarMileageController {
...
@@ -159,15 +165,24 @@ public class WlCarMileageController {
pageBean
=
new
Page
<>(
pageNum
,
pageSize
);
pageBean
=
new
Page
<>(
pageNum
,
pageSize
);
}
}
Page
<
WlCarMileage
>
page
=
iWlCarMileageService
.
page
(
pageBean
,
wlCarMileage
);
Page
<
WlCarMileage
>
page
=
iWlCarMileageService
.
page
(
pageBean
,
wlCarMileage
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm:ss"
);
CarTravelDto
carTravelDto
=
new
CarTravelDto
();
CarTravelDto
carTravelDto
=
new
CarTravelDto
();
carTravelDto
.
setRecords
(
page
.
getRecords
());
carTravelDto
.
setTotal
(
page
.
getTotal
());
carTravelDto
.
setTotal
(
page
.
getTotal
());
long
totalTime
=
0
;
long
totalTime
=
0
;
int
totalTravel
=
0
;
int
totalTravel
=
0
;
List
<
WlCarMileageDto
>
list
=
new
ArrayList
<
WlCarMileageDto
>();
for
(
WlCarMileage
wl
:
page
.
getRecords
())
{
for
(
WlCarMileage
wl
:
page
.
getRecords
())
{
WlCarMileageDto
wlCarMileageDto
=
new
WlCarMileageDto
();
wl
.
setTime
(
millisToStringShort
(
wl
.
getTakeTime
()));
totalTravel
+=
wl
.
getTravel
();
totalTravel
+=
wl
.
getTravel
();
totalTime
+=
wl
.
getTakeTime
();
totalTime
+=
wl
.
getTakeTime
();
BeanUtil
.
copyPropertiesIgnoreNull
(
wl
,
wlCarMileageDto
);
wlCarMileageDto
.
setStartTime
(
sdf
.
format
(
wl
.
getStartTime
()));
wlCarMileageDto
.
setEndTime
(
sdf
.
format
(
wl
.
getEndTime
()));
list
.
add
(
wlCarMileageDto
);
}
}
carTravelDto
.
setRecords
(
list
);
// // 初始化format格式
// // 初始化format格式
// SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
// SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
// // 设置时区,跳过此步骤会默认设置为"GMT+08:00" 得到的结果会多出来8个小时
// // 设置时区,跳过此步骤会默认设置为"GMT+08:00" 得到的结果会多出来8个小时
...
@@ -190,6 +205,8 @@ public class WlCarMileageController {
...
@@ -190,6 +205,8 @@ public class WlCarMileageController {
strBuilder
.
append
(
0
);
strBuilder
.
append
(
0
);
}
}
strBuilder
.
append
(
temp
/
hper
).
append
(
":"
);
strBuilder
.
append
(
temp
/
hper
).
append
(
":"
);
}
else
{
strBuilder
.
append
(
"00"
).
append
(
":"
);
}
}
temp
=
temp
%
hper
;
temp
=
temp
%
hper
;
if
(
temp
/
mper
>
0
)
{
if
(
temp
/
mper
>
0
)
{
...
@@ -197,6 +214,8 @@ public class WlCarMileageController {
...
@@ -197,6 +214,8 @@ public class WlCarMileageController {
strBuilder
.
append
(
0
);
strBuilder
.
append
(
0
);
}
}
strBuilder
.
append
(
temp
/
mper
).
append
(
":"
);
strBuilder
.
append
(
temp
/
mper
).
append
(
":"
);
}
else
{
strBuilder
.
append
(
"00"
).
append
(
":"
);
}
}
temp
=
temp
%
mper
;
temp
=
temp
%
mper
;
if
(
temp
/
sper
>
0
)
{
if
(
temp
/
sper
>
0
)
{
...
@@ -204,6 +223,8 @@ public class WlCarMileageController {
...
@@ -204,6 +223,8 @@ public class WlCarMileageController {
strBuilder
.
append
(
0
);
strBuilder
.
append
(
0
);
}
}
strBuilder
.
append
(
temp
/
sper
);
strBuilder
.
append
(
temp
/
sper
);
}
else
{
strBuilder
.
append
(
"00"
);
}
}
return
strBuilder
.
toString
();
return
strBuilder
.
toString
();
...
@@ -220,4 +241,17 @@ public class WlCarMileageController {
...
@@ -220,4 +241,17 @@ public class WlCarMileageController {
public
List
<
Coordinate
>
travel
(
long
id
)
{
public
List
<
Coordinate
>
travel
(
long
id
)
{
return
iWlCarMileageService
.
getCoordinateList
(
id
);
return
iWlCarMileageService
.
getCoordinateList
(
id
);
}
}
/**
* 获取日历
*
* @return
*/
@RequestMapping
(
value
=
"/calendar"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"获取日历"
,
notes
=
"获取日历"
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
public
Map
<
String
,
Boolean
>
calendar
(
@RequestParam
(
"id"
)
long
id
,
@DateTimeFormat
(
pattern
=
"yyyy-MM"
)
@RequestParam
(
"date"
)
Date
date
)
{
return
iWlCarMileageService
.
getCalender
(
id
,
date
);
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/listener/CarIotListener.java
View file @
3866af04
...
@@ -5,21 +5,29 @@ import java.io.IOException;
...
@@ -5,21 +5,29 @@ import java.io.IOException;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.eclipse.paho.client.mqttv3.MqttMessage
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.component.emq.EmqxListener
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
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.google.gson.JsonObject
;
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
;
@Component
@Component
...
@@ -29,96 +37,137 @@ public class CarIotListener extends EmqxListener {
...
@@ -29,96 +37,137 @@ public class CarIotListener extends EmqxListener {
private
IWlCarMileageService
iWlCarMileageService
;
private
IWlCarMileageService
iWlCarMileageService
;
@Autowired
@Autowired
private
ICarService
iCarService
;
@Autowired
private
IotFeign
iotFeign
;
private
IotFeign
iotFeign
;
private
final
String
GUIDE_KEY
=
"813684495d9a3981dd2c7694916fe404"
;
private
final
String
GUIDE_KEY
=
"813684495d9a3981dd2c7694916fe404"
;
private
final
String
GUIDE_URL
=
"https://restapi.amap.com/v3/geocode/regeo?"
;
private
final
String
GUIDE_URL
=
"https://restapi.amap.com/v3/geocode/regeo?"
;
@Autowired
private
EmqKeeper
emqkeeper
;
private
static
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
@Override
@Override
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
throws
Exception
{
public
void
processMessage
(
String
topic
,
MqttMessage
message
)
throws
Exception
{
String
measurement
=
topic
.
split
(
"/"
)[
0
];
String
deviceName
=
topic
.
split
(
"/"
)[
1
];
String
iotCode
=
measurement
+
deviceName
;
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
message
.
toString
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
message
.
toString
());
if
(
jsonObject
.
containsKey
(
"startUp"
))
{
if
(
jsonObject
.
containsKey
(
"startUp"
)||
jsonObject
.
containsKey
(
"FireCar_Longitude"
))
if
(
jsonObject
.
getBooleanValue
(
"startUp"
))
{
{
WlCarMileage
wlCarMileage
=
new
WlCarMileage
();
System
.
out
.
println
(
topic
);
wlCarMileage
.
setIotCode
(
iotCode
);
System
.
out
.
println
(
message
);
wlCarMileage
.
setDate
(
new
Date
());
String
measurement
=
topic
.
split
(
"/"
)[
0
];
iWlCarMileageService
.
save
(
wlCarMileage
);
String
deviceName
=
topic
.
split
(
"/"
)[
1
];
}
else
{
String
iotCode
=
measurement
+
deviceName
;
// 获取结束坐标
if
(
jsonObject
.
containsKey
(
"startUp"
))
{
WlCarMileage
last
=
iWlCarMileageService
.
getOne
(
new
LambdaQueryWrapper
<
WlCarMileage
>()
if
(
jsonObject
.
getBooleanValue
(
"startUp"
))
{
.
eq
(
WlCarMileage:
:
getIotCode
,
iotCode
).
isNull
(
WlCarMileage:
:
getEndLongitude
)
WlCarMileage
wlCarMileage
=
new
WlCarMileage
();
.
isNull
(
WlCarMileage:
:
getEndLatitude
).
orderByDesc
(
WlCarMileage:
:
getEndTime
).
last
(
"limit 1"
));
wlCarMileage
.
setIotCode
(
iotCode
);
ResponseModel
<
List
<
Object
>>
result
=
iotFeign
.
getLiveData
(
measurement
,
deviceName
,
last
.
getStartTime
(),
wlCarMileage
.
setDate
(
new
Date
());
new
Date
());
iWlCarMileageService
.
save
(
wlCarMileage
);
List
<
Object
>
list
=
result
.
getResult
();
}
else
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
// 获取结束坐标
//获取最后一个有坐标的数据
WlCarMileage
last
=
iWlCarMileageService
.
getOne
(
new
LambdaQueryWrapper
<
WlCarMileage
>()
JSONObject
lastObj
=
null
;
.
eq
(
WlCarMileage:
:
getIotCode
,
iotCode
).
isNull
(
WlCarMileage:
:
getEndLongitude
)
for
(
int
i
=
list
.
size
()-
1
;
i
>=
0
;
i
--)
.
isNull
(
WlCarMileage:
:
getEndLatitude
).
orderByDesc
(
WlCarMileage:
:
getStartTime
).
last
(
"limit 1"
));
{
ResponseModel
<
List
<
Object
>>
result
=
iotFeign
.
getLiveData
(
measurement
,
deviceName
,
last
.
getStartTime
(),
JSONObject
Obj
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
list
.
get
(
i
)));
new
Date
(
new
Date
().
getTime
()
+
2000
));
if
(
Obj
.
get
(
"FireCar_Longitude"
)!=
null
&&
Obj
.
get
(
"FireCar_Latitude"
)!=
null
)
List
<
Object
>
list
=
result
.
getResult
();
{
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
lastObj
=
Obj
;
// 获取最后一个有坐标的数据
break
;
JSONObject
lastObj
=
null
;
// 过滤空坐标
List
<
Object
>
filterList
=
new
ArrayList
<
Object
>();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
JSONObject
Obj
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
list
.
get
(
i
)));
if
(
Obj
.
get
(
"FireCar_Longitude"
)
!=
null
&&
Obj
.
get
(
"FireCar_Latitude"
)
!=
null
&&
Obj
.
getDoubleValue
(
"FireCar_Longitude"
)
!=
0
&&
Obj
.
getDoubleValue
(
"FireCar_Latitude"
)
!=
0
)
{
filterList
.
add
(
list
.
get
(
i
));
// 获取第一个不为空的坐标
if
(
lastObj
==
null
)
{
lastObj
=
Obj
;
}
}
}
// JSONObject lastObj =
// JSONObject.parseObject(JSONObject.toJSONString(list.get(list.size() - 1)));
if
(
lastObj
==
null
)
{
lastObj
=
new
JSONObject
();
lastObj
.
put
(
"FireCar_Longitude"
,
0.0
);
lastObj
.
put
(
"FireCar_Latitude"
,
0.0
);
lastObj
.
put
(
"time"
,
0
);
lastObj
.
put
(
"FireCar_Speed"
,
0
);
}
double
endLongitude
=
lastObj
.
getDoubleValue
(
"FireCar_Longitude"
);
double
endLatitude
=
lastObj
.
getDoubleValue
(
"FireCar_Latitude"
);
// 230215180624
//Date endTime =UTCToCST(lastObj.getString("time"));
Date
endTime
=
new
Date
(
jsonObject
.
getLong
(
"time"
));
long
takeTime
=
endTime
.
getTime
()
-
last
.
getStartTime
().
getTime
();
last
.
setEndLongitude
(
endLongitude
);
last
.
setEndLatitude
(
endLatitude
);
last
.
setEndTime
(
endTime
);
last
.
setEndName
(
getAddress
(
endLongitude
,
endLatitude
));
last
.
setEndSpeed
(
lastObj
.
getIntValue
(
"FireCar_Speed"
));
last
.
setTakeTime
(
takeTime
);
double
travel
=
0
;
// 获取里程
for
(
int
i
=
0
;
i
<
filterList
.
size
()
-
1
;
i
++)
{
JSONObject
start
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filterList
.
get
(
i
)));
JSONObject
end
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filterList
.
get
(
i
+
1
)));
travel
+=
CoordinateUtil
.
distance
(
start
.
getDoubleValue
(
"FireCar_Longitude"
),
start
.
getDoubleValue
(
"FireCar_Latitude"
),
end
.
getDoubleValue
(
"FireCar_Longitude"
),
end
.
getDoubleValue
(
"FireCar_Latitude"
));
}
}
last
.
setTravel
(
travel
);
iWlCarMileageService
.
updateById
(
last
);
}
}
//JSONObject lastObj = JSONObject.parseObject(JSONObject.toJSONString(list.get(list.size() - 1)));
}
if
(
lastObj
==
null
)
}
else
if
(
jsonObject
.
containsKey
(
"FireCar_Longitude"
))
{
{
WlCarMileage
last
=
iWlCarMileageService
.
getOne
(
new
LambdaQueryWrapper
<
WlCarMileage
>()
lastObj
=
new
JSONObject
();
.
eq
(
WlCarMileage:
:
getIotCode
,
iotCode
).
isNull
(
WlCarMileage:
:
getStartLongitude
)
lastObj
.
put
(
"FireCar_Longitude"
,
0.0
);
.
isNull
(
WlCarMileage:
:
getStartLatitude
).
orderByDesc
(
WlCarMileage:
:
getEndTime
).
last
(
"limit 1"
));
lastObj
.
put
(
"FireCar_Latitude"
,
0.0
);
if
(
jsonObject
.
containsKey
(
"FireCar_Longitude"
)
&&
jsonObject
.
containsKey
(
"FireCar_Latitude"
))
{
lastObj
.
put
(
"currentTime"
,
0
);
// 获取开始坐标
lastObj
.
put
(
"FireCar_Speed"
,
0
);
double
startLongitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
);
double
startLatitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
);
int
direction
=
jsonObject
.
getIntValue
(
"direction"
);
// 保存里程开始节点
if
(
last
!=
null
)
{
// String currentTime = "20"+jsonObject.getString("currentTime");
last
.
setStartLongitude
(
startLongitude
);
last
.
setStartLatitude
(
startLatitude
);
//Date startTime = UTCToCST();
Date
startTime
=
new
Date
(
jsonObject
.
getLong
(
"time"
));
last
.
setStartTime
(
startTime
);
last
.
setStartName
(
getAddress
(
startLongitude
,
startLatitude
));
last
.
setStartSpeed
(
jsonObject
.
getIntValue
(
"FireCar_Speed"
));
iWlCarMileageService
.
updateById
(
last
);
}
}
double
endLongitude
=
lastObj
.
getDoubleValue
(
"FireCar_Longitude"
);
// 地图推送消息
double
endLatitude
=
lastObj
.
getDoubleValue
(
"FireCar_Latitude"
);
Car
car
=
iCarService
.
getOne
(
new
LambdaQueryWrapper
<
Car
>().
eq
(
Car:
:
getIotCode
,
iotCode
));
long
currentTime
=
lastObj
.
getLongValue
(
"currentTime"
);
if
(
car
!=
null
&&
startLongitude
!=
0
&&
startLatitude
!=
0
)
{
long
takeTime
=
currentTime
-
last
.
getStartTime
().
getTime
();
JSONArray
sendArr
=
new
JSONArray
();
last
.
setEndLongitude
(
endLongitude
);
JSONObject
sendObj
=
new
JSONObject
();
last
.
setEndLatitude
(
endLatitude
);
sendObj
.
put
(
"id"
,
String
.
valueOf
(
car
.
getId
()));
last
.
setEndTime
(
new
Date
(
currentTime
));
sendObj
.
put
(
"direction"
,
direction
);
last
.
setEndName
(
getAddress
(
endLongitude
,
endLatitude
));
sendObj
.
put
(
"longitude"
,
String
.
valueOf
(
startLongitude
));
last
.
setEndSpeed
(
lastObj
.
getIntValue
(
"FireCar_Speed"
));
sendObj
.
put
(
"latitude"
,
String
.
valueOf
(
startLatitude
));
last
.
setTakeTime
(
takeTime
);
sendObj
.
put
(
"carNum"
,
car
.
getCarNum
());
double
travel
=
0
;
sendObj
.
put
(
"bizOrgName"
,
car
.
getBizOrgName
());
// 获取里程
sendArr
.
add
(
sendObj
);
for
(
int
i
=
0
;
i
<
list
.
size
()
-
1
;
i
++)
{
MqttMessage
mqttMessage
=
new
MqttMessage
();
JSONObject
start
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
list
.
get
(
i
)));
mqttMessage
.
setPayload
(
sendArr
.
toJSONString
().
getBytes
());
JSONObject
end
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
list
.
get
(
i
+
1
)));
emqkeeper
.
getMqttClient
().
publish
(
"car/location"
,
mqttMessage
);
travel
+=
CoordinateUtil
.
distance
(
start
.
getDoubleValue
(
"FireCar_Longitude"
),
start
.
getDoubleValue
(
"FireCar_Latitude"
),
end
.
getDoubleValue
(
"FireCar_Longitude"
),
end
.
getDoubleValue
(
"FireCar_Latitude"
));
}
}
last
.
setTravel
(
travel
);
iWlCarMileageService
.
updateById
(
last
);
}
}
}
}
}
else
if
(
jsonObject
.
containsKey
(
"FireCar_Longitude"
)){
WlCarMileage
last
=
iWlCarMileageService
.
getOne
(
new
LambdaQueryWrapper
<
WlCarMileage
>()
.
eq
(
WlCarMileage:
:
getIotCode
,
iotCode
).
isNull
(
WlCarMileage:
:
getStartLongitude
)
.
isNull
(
WlCarMileage:
:
getStartLatitude
).
orderByDesc
(
WlCarMileage:
:
getEndTime
).
last
(
"limit 1"
));
if
(
last
!=
null
&&
jsonObject
.
containsKey
(
"FireCar_Longitude"
)
&&
jsonObject
.
containsKey
(
"FireCar_Latitude"
))
{
// 获取开始坐标
double
startLongitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
);
double
startLatitude
=
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
);
long
currentTime
=
jsonObject
.
getLongValue
(
"currentTime"
);
last
.
setStartLongitude
(
startLongitude
);
last
.
setStartLatitude
(
startLatitude
);
last
.
setStartTime
(
new
Date
(
currentTime
));
last
.
setStartName
(
getAddress
(
startLongitude
,
startLatitude
));
last
.
setStartSpeed
(
jsonObject
.
getIntValue
(
"FireCar_Speed"
));
iWlCarMileageService
.
updateById
(
last
);
}
}
}
System
.
out
.
println
(
topic
);
System
.
out
.
println
(
message
);
}
}
public
String
getAddress
(
double
longitude
,
double
lantitude
)
{
public
String
getAddress
(
double
longitude
,
double
lantitude
)
{
...
@@ -143,10 +192,9 @@ public class CarIotListener extends EmqxListener {
...
@@ -143,10 +192,9 @@ public class CarIotListener extends EmqxListener {
System
.
out
.
println
(
object
);
System
.
out
.
println
(
object
);
JSONObject
regeocode
=
object
.
getJSONObject
(
"regeocode"
);
JSONObject
regeocode
=
object
.
getJSONObject
(
"regeocode"
);
String
address
=
regeocode
.
getString
(
"formatted_address"
);
String
address
=
regeocode
.
getString
(
"formatted_address"
);
if
(
"[]"
.
equals
(
address
))
if
(
"[]"
.
equals
(
address
))
{
{
System
.
out
.
println
(
"===============无效坐标:"
+
longitude
+
","
+
lantitude
);
System
.
out
.
println
(
"===============无效坐标:"
+
longitude
+
","
+
lantitude
);
address
=
"无效坐标"
;
address
=
"无效坐标"
;
}
}
res
=
new
StringBuilder
(
address
);
res
=
new
StringBuilder
(
address
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -162,4 +210,13 @@ public class CarIotListener extends EmqxListener {
...
@@ -162,4 +210,13 @@ public class CarIotListener extends EmqxListener {
}
}
return
res
.
toString
();
return
res
.
toString
();
}
}
public
Date
UTCToCST
(
String
UTCStr
)
throws
ParseException
{
Date
date
=
sdf
.
parse
(
UTCStr
);
System
.
out
.
println
(
"UTC时间: "
+
date
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
set
(
Calendar
.
HOUR
,
calendar
.
get
(
Calendar
.
HOUR
)
+
8
);
return
calendar
.
getTime
();
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/ICarService.java
View file @
3866af04
...
@@ -190,4 +190,6 @@ public interface ICarService extends IService<Car> {
...
@@ -190,4 +190,6 @@ public interface ICarService extends IService<Car> {
void
iotrefreshStaData
();
void
iotrefreshStaData
();
IPage
getQRCode
(
Long
id
);
IPage
getQRCode
(
Long
id
);
List
<
Car
>
location
();
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/IWlCarMileageService.java
View file @
3866af04
package
com
.
yeejoin
.
equipmanage
.
service
;
package
com
.
yeejoin
.
equipmanage
.
service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.baomidou.mybatisplus.extension.service.IService
;
...
@@ -20,4 +22,6 @@ public interface IWlCarMileageService extends IService<WlCarMileage> {
...
@@ -20,4 +22,6 @@ public interface IWlCarMileageService extends IService<WlCarMileage> {
Integer
totalMileage
(
String
iotCode
);
Integer
totalMileage
(
String
iotCode
);
List
<
Coordinate
>
getCoordinateList
(
long
id
);
List
<
Coordinate
>
getCoordinateList
(
long
id
);
Map
<
String
,
Boolean
>
getCalender
(
long
id
,
Date
date
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/CarServiceImpl.java
View file @
3866af04
...
@@ -27,6 +27,7 @@ import com.yeejoin.equipmanage.common.entity.dto.CarDto;
...
@@ -27,6 +27,7 @@ import com.yeejoin.equipmanage.common.entity.dto.CarDto;
import
com.yeejoin.equipmanage.common.entity.publics.BaseEntity
;
import
com.yeejoin.equipmanage.common.entity.publics.BaseEntity
;
import
com.yeejoin.equipmanage.common.entity.vo.CarIndexVo
;
import
com.yeejoin.equipmanage.common.entity.vo.CarIndexVo
;
import
com.yeejoin.equipmanage.common.entity.vo.CarPropertyVo
;
import
com.yeejoin.equipmanage.common.entity.vo.CarPropertyVo
;
import
com.yeejoin.equipmanage.common.entity.vo.EquipTypeImgAmountVO
;
import
com.yeejoin.equipmanage.common.entity.vo.EquipmentSpecificVo
;
import
com.yeejoin.equipmanage.common.entity.vo.EquipmentSpecificVo
;
import
com.yeejoin.equipmanage.common.enums.*
;
import
com.yeejoin.equipmanage.common.enums.*
;
import
com.yeejoin.equipmanage.common.exception.CommonException
;
import
com.yeejoin.equipmanage.common.exception.CommonException
;
...
@@ -1348,8 +1349,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
...
@@ -1348,8 +1349,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
equipment
.
setEquipmentCategory
(
equipmentCategoryMapper
.
selectById
(
equipment
.
getCategoryId
()));
equipment
.
setEquipmentCategory
(
equipmentCategoryMapper
.
selectById
(
equipment
.
getCategoryId
()));
}
}
car
.
setEquipment
(
equipment
);
car
.
setEquipment
(
equipment
);
car
.
setCountryName
(
if
(
car
.
getCountry
()!=
null
)
{
iSystemDicService
.
getOne
(
new
QueryWrapper
<
SystemDic
>().
eq
(
"id"
,
car
.
getCountry
())).
getName
());
car
.
setCountryName
(
iSystemDicService
.
getOne
(
new
QueryWrapper
<
SystemDic
>().
eq
(
"id"
,
car
.
getCountry
())).
getName
());
}
if
(!
ObjectUtils
.
isEmpty
(
car
.
getChassisCountry
()))
{
if
(!
ObjectUtils
.
isEmpty
(
car
.
getChassisCountry
()))
{
car
.
setChassisCountryName
(
iSystemDicService
car
.
setChassisCountryName
(
iSystemDicService
.
getOne
(
new
QueryWrapper
<
SystemDic
>().
eq
(
"id"
,
car
.
getChassisCountry
())).
getName
());
.
getOne
(
new
QueryWrapper
<
SystemDic
>().
eq
(
"id"
,
car
.
getChassisCountry
())).
getName
());
...
@@ -1360,7 +1363,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
...
@@ -1360,7 +1363,10 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
List
<
Equipment
>
equipment1
=
iEquipmentService
.
listByCategoryId
(
equipment
.
getCategoryId
());
List
<
Equipment
>
equipment1
=
iEquipmentService
.
listByCategoryId
(
equipment
.
getCategoryId
());
car
.
setUnit
(
equipment1
.
get
(
0
).
getUnit
());
car
.
setUnit
(
equipment1
.
get
(
0
).
getUnit
());
car
.
setCategoryId
(
equipment
.
getCategoryId
());
car
.
setCategoryId
(
equipment
.
getCategoryId
());
car
.
setImportStr
(
car
.
getIsImport
()
?
"进口"
:
"国产"
);
if
(
car
.
getIsImport
()!=
null
)
{
car
.
setImportStr
(
car
.
getIsImport
()
?
"进口"
:
"国产"
);
}
if
(!
ObjectUtils
.
isEmpty
(
car
.
getIotCode
()))
{
if
(!
ObjectUtils
.
isEmpty
(
car
.
getIotCode
()))
{
Integer
totalTravel
=
iWlCarMileageService
.
totalMileage
(
car
.
getIotCode
());
Integer
totalTravel
=
iWlCarMileageService
.
totalMileage
(
car
.
getIotCode
());
car
.
setTotalTravel
(
totalTravel
);
car
.
setTotalTravel
(
totalTravel
);
...
@@ -1368,6 +1374,12 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
...
@@ -1368,6 +1374,12 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
.
getOne
(
new
LambdaQueryWrapper
<
WlCarMileage
>().
eq
(
WlCarMileage:
:
getIotCode
,
car
.
getIotCode
())
.
getOne
(
new
LambdaQueryWrapper
<
WlCarMileage
>().
eq
(
WlCarMileage:
:
getIotCode
,
car
.
getIotCode
())
.
orderByDesc
(
WlCarMileage:
:
getEndTime
).
last
(
"limit 1"
));
.
orderByDesc
(
WlCarMileage:
:
getEndTime
).
last
(
"limit 1"
));
car
.
setSpeed
(
last
!=
null
?
last
.
getEndSpeed
()
:
null
);
car
.
setSpeed
(
last
!=
null
?
last
.
getEndSpeed
()
:
null
);
//产品 和 设备 各8位
if
(
car
.
getIotCode
().
length
()>=
16
)
{
car
.
setIotMeasurement
(
car
.
getIotCode
().
substring
(
0
,
8
));
car
.
setIotDeviceName
(
car
.
getIotCode
().
substring
(
8
,
car
.
getIotCode
().
length
()));
}
}
}
return
car
;
return
car
;
}
}
...
@@ -1710,4 +1722,22 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
...
@@ -1710,4 +1722,22 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
page
.
setRecords
(
list
);
page
.
setRecords
(
list
);
return
page
;
return
page
;
}
}
@Override
public
List
<
Car
>
location
()
{
List
<
Car
>
list
=
this
.
list
();
list
.
forEach
(
x
->
{
if
(!
ObjectUtils
.
isEmpty
(
x
.
getIotCode
()))
{
WlCarMileage
last
=
iWlCarMileageService
.
getOne
(
new
LambdaQueryWrapper
<
WlCarMileage
>().
eq
(
WlCarMileage:
:
getIotCode
,
x
.
getIotCode
())
.
orderByDesc
(
WlCarMileage:
:
getEndTime
).
last
(
"limit 1"
));
if
(
last
!=
null
)
{
x
.
setLongitude
(
last
.
getEndLongitude
());
x
.
setLatitude
(
last
.
getEndLatitude
());
}
}
});
return
list
;
}
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/MqttReceiveServiceImpl.java
View file @
3866af04
...
@@ -254,72 +254,72 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
...
@@ -254,72 +254,72 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
handlerMqttIncrementMessage
(
String
topic
,
String
message
)
{
public
void
handlerMqttIncrementMessage
(
String
topic
,
String
message
)
{
//
TopicEntityVo
topicEntity
=
new
TopicEntityVo
();
//
TopicEntityVo topicEntity = new TopicEntityVo();
topicEntity
.
setTopic
(
topic
);
//
topicEntity.setTopic(topic);
topicEntity
.
setMessage
(
message
);
//
topicEntity.setMessage(message);
int
endIndex
=
topic
.
lastIndexOf
(
"/"
);
//
int endIndex = topic.lastIndexOf("/");
String
iotCode
=
topic
.
substring
(
0
,
endIndex
).
replace
(
"/"
,
""
);
//
String iotCode = topic.substring(0, endIndex).replace("/", "");
topicEntity
.
setIotCode
(
iotCode
);
//
topicEntity.setIotCode(iotCode);
List
<
EquipmentSpecificVo
>
eqIotCodeList
=
iEquipmentSpecificSerivce
.
getEquipAndCarIotcodeByIotcode
(
iotCode
);
//
List<EquipmentSpecificVo> eqIotCodeList = iEquipmentSpecificSerivce.getEquipAndCarIotcodeByIotcode(iotCode);
if
(
eqIotCodeList
.
isEmpty
())
{
//
if (eqIotCodeList.isEmpty()) {
log
.
info
(
"该数据{}不存在!"
,
iotCode
);
//
log.info("该数据{}不存在!", iotCode);
return
;
//
return;
}
//
}
if
(
eqIotCodeList
.
size
()
>
1
)
{
//
if (eqIotCodeList.size() > 1) {
log
.
info
(
"有重复的{}数据!"
,
iotCode
);
//
log.info("有重复的{}数据!", iotCode);
}
//
}
//给 iot服务 推送消息 插数据到 influxdb
//
//给 iot服务 推送消息 插数据到 influxdb
if
(
isSendIot
)
{
//
if (isSendIot) {
mqttSendGateway
.
sendToMqtt
(
"influxdb/"
+
topic
.
substring
(
0
,
endIndex
),
message
);
//
mqttSendGateway.sendToMqtt("influxdb/" + topic.substring(0, endIndex), message);
}
//
}
EquipmentSpecificVo
vo
=
eqIotCodeList
.
get
(
0
);
//
EquipmentSpecificVo vo = eqIotCodeList.get(0);
topicEntity
.
setType
(
vo
.
getType
());
//
topicEntity.setType(vo.getType());
topicEntity
.
setCode
(
vo
.
getCode
());
//
topicEntity.setCode(vo.getCode());
//
JSONObject
json
=
JSONObject
.
parseObject
(
message
);
//
JSONObject json = JSONObject.parseObject(message);
Iterator
it
=
json
.
entrySet
().
iterator
();
//
Iterator it = json.entrySet().iterator();
List
<
IotDataVO
>
iotDatalist
=
new
ArrayList
<>();
//
List<IotDataVO> iotDatalist = new ArrayList<>();
String
traceId
=
""
;
//
String traceId = "";
while
(
it
.
hasNext
())
{
//
while (it.hasNext()) {
IotDataVO
iotDataVO
=
new
IotDataVO
();
//
IotDataVO iotDataVO = new IotDataVO();
Map
.
Entry
<
String
,
Object
>
entry
=
(
Map
.
Entry
<
String
,
Object
>)
it
.
next
();
//
Map.Entry<String, Object> entry = (Map.Entry<String, Object>) it.next();
String
key
=
entry
.
getKey
();
//
String key = entry.getKey();
Object
value
=
entry
.
getValue
();
//
Object value = entry.getValue();
iotDataVO
.
setKey
(
key
);
//
iotDataVO.setKey(key);
iotDataVO
.
setValue
(
value
);
//
iotDataVO.setValue(value);
if
(
"traceId"
.
equalsIgnoreCase
(
key
))
{
//
if ("traceId".equalsIgnoreCase(key)) {
traceId
=
value
.
toString
();
//
traceId = value.toString();
continue
;
//
continue;
}
//
}
iotDatalist
.
add
(
iotDataVO
);
//
iotDatalist.add(iotDataVO);
}
//
}
if
(
ObjectUtils
.
isEmpty
(
iotDatalist
))
{
//
if (ObjectUtils.isEmpty(iotDatalist)) {
return
;
//
return;
}
//
}
log
.
info
(
String
.
format
(
"收到mqtt消息:%s"
,
message
));
//
log.info(String.format("收到mqtt消息:%s", message));
//
// 发送emq消息转kafka
//
// 发送emq消息转kafka
JSONObject
jsonObject
=
new
JSONObject
();
//
JSONObject jsonObject = new JSONObject();
jsonObject
.
put
(
"topic"
,
topic
);
//
jsonObject.put("topic", topic);
jsonObject
.
put
(
"data"
,
message
);
//
jsonObject.put("data",message);
//
try
{
//
try {
emqKeeper
.
getMqttClient
().
publish
(
"emq.iot.created"
,
jsonObject
.
toString
().
getBytes
(),
1
,
false
);
//
emqKeeper.getMqttClient().publish("emq.iot.created",jsonObject.toString().getBytes(),1,false);
}
catch
(
MqttException
e
)
{
//
} catch (MqttException e) {
log
.
info
(
String
.
format
(
"发送eqm转kafka消息失败:%s"
,
e
.
getMessage
()));
//
log.info(String.format("发送eqm转kafka消息失败:%s", e.getMessage()));
}
//
}
//
if
(!
StringUtils
.
isEmpty
(
traceId
))
{
//
if (!StringUtils.isEmpty(traceId)) {
String
finalTraceId
=
traceId
;
//
String finalTraceId = traceId;
List
<
IotDataVO
>
collect
=
iotDatalist
.
stream
().
map
(
x
->
{
//
List<IotDataVO> collect = iotDatalist.stream().map(x -> {
x
.
setTraceId
(
finalTraceId
);
//
x.setTraceId(finalTraceId);
return
x
;
//
return x;
}).
collect
(
Collectors
.
toList
());
//
}).collect(Collectors.toList());
realTimeDateProcessing
(
topicEntity
,
collect
,
vo
);
//
realTimeDateProcessing(topicEntity, collect, vo);
}
else
{
//
} else {
realTimeDateProcessing
(
topicEntity
,
iotDatalist
,
vo
);
//
realTimeDateProcessing(topicEntity, iotDatalist,vo);
}
//
}
}
}
/**
/**
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/WlCarMileageServiceImpl.java
View file @
3866af04
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
package
com
.
yeejoin
.
equipmanage
.
service
.
impl
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
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
;
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.controller.Coordinate
;
import
com.yeejoin.equipmanage.controller.Coordinate
;
import
com.yeejoin.equipmanage.fegin.IotFeign
;
import
com.yeejoin.equipmanage.fegin.IotFeign
;
import
com.yeejoin.equipmanage.mapper.WlCarMileageMapper
;
import
com.yeejoin.equipmanage.mapper.WlCarMileageMapper
;
import
com.yeejoin.equipmanage.service.ICarService
;
import
com.yeejoin.equipmanage.service.IWlCarMileageService
;
import
com.yeejoin.equipmanage.service.IWlCarMileageService
;
/**
/**
...
@@ -30,6 +39,9 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
...
@@ -30,6 +39,9 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
@Autowired
@Autowired
IotFeign
iotFeign
;
IotFeign
iotFeign
;
@Autowired
ICarService
iCarService
;
@Override
@Override
public
Page
<
WlCarMileage
>
page
(
Page
<
WlCarMileage
>
page
,
WlCarMileage
wlCarMileage
)
{
public
Page
<
WlCarMileage
>
page
(
Page
<
WlCarMileage
>
page
,
WlCarMileage
wlCarMileage
)
{
return
this
.
baseMapper
.
page
(
page
,
wlCarMileage
);
return
this
.
baseMapper
.
page
(
page
,
wlCarMileage
);
...
@@ -43,25 +55,103 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
...
@@ -43,25 +55,103 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
@Override
@Override
public
List
<
Coordinate
>
getCoordinateList
(
long
id
)
{
public
List
<
Coordinate
>
getCoordinateList
(
long
id
)
{
WlCarMileage
wlCarMileage
=
this
.
getById
(
id
);
WlCarMileage
wlCarMileage
=
this
.
getById
(
id
);
String
iotCode
=
wlCarMileage
.
getIotCode
();
String
iotCode
=
wlCarMileage
.
getIotCode
();
String
measurement
=
"0THMcLKR"
;
String
measurement
=
"0THMcLKR"
;
String
deviceName
=
iotCode
.
replace
(
measurement
,
""
);
String
deviceName
=
iotCode
.
replace
(
measurement
,
""
);
ResponseModel
<
List
<
Object
>>
result
=
iotFeign
.
getLiveData
(
measurement
,
deviceName
,
// 由于iot存在毫秒故结束时间要+1秒 iot+1秒有bug还是查不到 +2秒
wlCarMileage
.
getStartTime
(),
wlCarMileage
.
getEndTime
());
ResponseModel
<
List
<
Object
>>
result
=
iotFeign
.
getLiveData
(
measurement
,
deviceName
,
wlCarMileage
.
getStartTime
(),
new
Date
(
wlCarMileage
.
getEndTime
().
getTime
()));
List
<
Object
>
list
=
result
.
getResult
();
List
<
Object
>
list
=
result
.
getResult
();
List
<
Coordinate
>
coordinateList
=
new
ArrayList
<
Coordinate
>();
List
<
Coordinate
>
coordinateList
=
new
ArrayList
<
Coordinate
>();
if
(
list
!=
null
)
{
if
(
list
!=
null
)
{
for
(
Object
object
:
list
)
{
for
(
Object
object
:
list
)
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
object
));
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
object
));
Coordinate
coordinate
=
new
Coordinate
();
if
(
jsonObject
.
get
(
"FireCar_Longitude"
)
!=
null
&&
jsonObject
.
get
(
"FireCar_Latitude"
)
!=
null
)
{
List
<
Double
>
lnglat
=
new
ArrayList
<
Double
>();
Coordinate
coordinate
=
new
Coordinate
();
lnglat
.
add
(
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
));
List
<
Double
>
lnglat
=
new
ArrayList
<
Double
>();
lnglat
.
add
(
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
));
lnglat
.
add
(
jsonObject
.
getDoubleValue
(
"FireCar_Longitude"
));
coordinate
.
setLnglat
(
lnglat
);
lnglat
.
add
(
jsonObject
.
getDoubleValue
(
"FireCar_Latitude"
));
coordinate
.
setSpeed
(
jsonObject
.
getIntValue
(
"FireCar_Speed"
));
coordinate
.
setLnglat
(
lnglat
);
coordinateList
.
add
(
coordinate
);
coordinate
.
setSpeed
(
jsonObject
.
getIntValue
(
"FireCar_Speed"
));
coordinateList
.
add
(
coordinate
);
}
}
}
}
}
// 倒序坐标变为正序
Collections
.
reverse
(
list
);
return
coordinateList
;
return
coordinateList
;
}
}
@Override
public
Map
<
String
,
Boolean
>
getCalender
(
long
id
,
Date
date
)
{
List
<
String
>
daylist
=
new
ArrayList
<
String
>();
Map
<
String
,
Boolean
>
map
=
new
HashMap
<>();
Car
car
=
iCarService
.
getById
(
id
);
if
(
car
==
null
||
car
.
getIotCode
()
==
null
||
date
==
null
)
{
return
map
;
}
Calendar
c
=
Calendar
.
getInstance
();
// 获取上一个月
c
.
setTime
(
date
);
c
.
add
(
Calendar
.
MONTH
,
-
1
);
daylist
.
addAll
(
getDayByMonth
(
c
.
getTime
()));
// 获取当月
c
.
setTime
(
date
);
daylist
.
addAll
(
getDayByMonth
(
c
.
getTime
()));
// 获取下一个月
c
.
setTime
(
date
);
c
.
add
(
Calendar
.
MONTH
,
1
);
daylist
.
addAll
(
getDayByMonth
(
c
.
getTime
()));
List
<
Map
<
String
,
Object
>>
hasList
=
this
.
listMaps
(
new
QueryWrapper
<
WlCarMileage
>().
select
(
"COUNT(1) AS count,date"
).
lambda
().
eq
(
WlCarMileage:
:
getIotCode
,
car
.
getIotCode
())
.
between
(
WlCarMileage:
:
getDate
,
daylist
.
get
(
0
),
daylist
.
get
(
daylist
.
size
()
-
1
))
.
groupBy
(
WlCarMileage:
:
getDate
));
Map
<
String
,
Object
>
hasMap
=
new
HashMap
<>();
for
(
Map
<
String
,
Object
>
mapOne
:
hasList
)
{
hasMap
.
put
(
String
.
valueOf
(
mapOne
.
get
(
"date"
)),
mapOne
.
get
(
"count"
));
}
for
(
String
day
:
daylist
)
{
boolean
has
=
false
;
if
(
hasMap
.
containsKey
(
day
))
{
has
=
true
;
}
map
.
put
(
day
,
has
);
}
return
map
;
}
public
static
List
<
String
>
getDayByMonth
(
Date
date
)
{
List
<
String
>
data
=
new
ArrayList
<>();
try
{
Calendar
c
=
Calendar
.
getInstance
();
c
.
setTime
(
date
);
// 获取当前的年份
int
year
=
c
.
get
(
Calendar
.
YEAR
);
// 获取当前的月份(需要加1才是现在的月份)
int
month
=
c
.
get
(
Calendar
.
MONTH
)
+
1
;
// 获取本月的总天数
int
dayCount
=
c
.
getActualMaximum
(
Calendar
.
DAY_OF_MONTH
);
// 定义时间格式
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
// 开始日期为当前年月拼接1号
Date
startDate
=
sdf
.
parse
(
year
+
"-"
+
month
+
"-01"
);
// 结束日期为当前年月拼接该月最大天数
Date
endDate
=
sdf
.
parse
(
year
+
"-"
+
month
+
"-"
+
dayCount
);
// 设置calendar的开始日期
c
.
setTime
(
startDate
);
// 当前时间小于等于设定的结束时间
while
(
c
.
getTime
().
compareTo
(
endDate
)
<=
0
)
{
String
time
=
sdf
.
format
(
c
.
getTime
());
data
.
add
(
time
);
// 当前日期加1
c
.
add
(
Calendar
.
DATE
,
1
);
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
return
data
;
}
}
}
amos-boot-system-equip/src/main/resources/mapper/WlCarMileageMapper.xml
View file @
3866af04
...
@@ -8,7 +8,25 @@
...
@@ -8,7 +8,25 @@
<select
id=
"page"
<select
id=
"page"
resultType=
"com.yeejoin.equipmanage.common.entity.WlCarMileage"
>
resultType=
"com.yeejoin.equipmanage.common.entity.WlCarMileage"
>
SELECT*,date AS name,DATE_FORMAT(from_unixtime(take_time),'%H:%i:%s') AS time FROM wl_car_mileage
SELECT
wl_car_mileage.id,
wl_car_mileage.iot_code,
travel,
date,
start_time,
end_time,
take_time,
start_name,
end_name,
start_longitude,
start_latitude,
end_longitude,
end_latitude,
start_speed,
end_speed,
wl_car_mileage.create_date,
date AS name
FROM wl_car_mileage
LEFT JOIN wl_car ON wl_car.iot_code = wl_car_mileage.iot_code
LEFT JOIN wl_car ON wl_car.iot_code = wl_car_mileage.iot_code
<where>
<where>
<if
test=
"wlCarMileage.carId != null"
>
<if
test=
"wlCarMileage.carId != null"
>
...
...
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