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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
318 additions
and
89 deletions
+318
-89
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
+0
-0
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
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/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