Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 6b8d2f0b
authored
Jun 25, 2024
by
谢海旭
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'develop' into 'master'
Develop See merge request
!2
2 parents
a580d061
6913e50a
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1255 additions
and
9 deletions
src/main/java/cn/com/glsx/admin/modules/controller/DeviceController.java
src/main/java/cn/com/glsx/admin/modules/controller/RiskAssessmentController.java
src/main/java/cn/com/glsx/admin/modules/entity/DeviceJourneyOverview.java
src/main/java/cn/com/glsx/admin/modules/mapper/AlarmWarnAnalyseMapper.java
src/main/java/cn/com/glsx/admin/modules/mapper/DeviceJourneyMapper.java
src/main/java/cn/com/glsx/admin/modules/mapper/DeviceJourneyOverviewMapper.java
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleDeviceMapper.java
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
src/main/java/cn/com/glsx/admin/modules/model/dto/BasicInformationDTO.java
src/main/java/cn/com/glsx/admin/modules/model/vo/AlarmTimeLinePointVo.java
src/main/java/cn/com/glsx/admin/modules/model/vo/AlarmTimeLineVo.java
src/main/java/cn/com/glsx/admin/modules/model/vo/BasicInformationVO.java
src/main/java/cn/com/glsx/admin/modules/model/vo/DeviceInformationVO.java
src/main/java/cn/com/glsx/admin/modules/model/vo/VehicleUsageAnalysisPointVO.java
src/main/java/cn/com/glsx/admin/modules/model/vo/VehicleUsageAnalysisVO.java
src/main/java/cn/com/glsx/admin/modules/remote/RemoteAlarmService.java
src/main/java/cn/com/glsx/admin/modules/remote/RemoteStuJudgeAlarmService.java
src/main/java/cn/com/glsx/admin/modules/service/DeviceService.java
src/main/java/cn/com/glsx/admin/modules/service/RiskAssessmentService.java
src/main/java/cn/com/glsx/admin/modules/utils/DateUtil.java
src/main/resources/mapper/AlarmWarnAnalyseMapper.xml
src/main/resources/mapper/DeviceJourneyMapper.xml
src/main/resources/mapper/DeviceJourneyOverviewMapper.xml
src/main/resources/mapper/VehicleDeviceMapper.xml
src/main/resources/mapper/VehicleMapper.xml
src/main/java/cn/com/glsx/admin/modules/controller/DeviceController.java
View file @
6b8d2f0
package
cn
.
com
.
glsx
.
admin
.
modules
.
controller
;
package
cn
.
com
.
glsx
.
admin
.
modules
.
controller
;
import
cn.com.glsx.admin.modules.model.DropOptions
;
import
cn.com.glsx.admin.modules.model.DropOptions
;
import
cn.com.glsx.admin.modules.model.vo.DeviceInformationVO
;
import
cn.com.glsx.admin.modules.service.DeviceService
;
import
cn.com.glsx.stdinterface.enums.DeviceComposeEnum
;
import
cn.com.glsx.stdinterface.enums.DeviceComposeEnum
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.List
;
...
@@ -19,6 +23,9 @@ import java.util.List;
...
@@ -19,6 +23,9 @@ import java.util.List;
@Api
(
value
=
"设备管理"
,
tags
=
{
"设备管理"
})
@Api
(
value
=
"设备管理"
,
tags
=
{
"设备管理"
})
public
class
DeviceController
{
public
class
DeviceController
{
@Autowired
private
DeviceService
deviceService
;
@ApiOperation
(
value
=
"设备组合"
)
@ApiOperation
(
value
=
"设备组合"
)
@GetMapping
(
"/compose"
)
@GetMapping
(
"/compose"
)
public
R
compose
()
{
public
R
compose
()
{
...
@@ -35,4 +42,11 @@ public class DeviceController {
...
@@ -35,4 +42,11 @@ public class DeviceController {
return
R
.
ok
().
data
(
options
);
return
R
.
ok
().
data
(
options
);
}
}
@ApiOperation
(
value
=
"通过车辆id查找绑定的设备列表信息"
)
@GetMapping
(
"/getByVehicleId"
)
public
R
getByVehicleId
(
@RequestParam
(
"vehicleId"
)
Long
vehicleId
)
{
List
<
DeviceInformationVO
>
devices
=
deviceService
.
getByVehicleId
(
vehicleId
);
return
R
.
ok
().
data
(
devices
);
}
}
}
src/main/java/cn/com/glsx/admin/modules/controller/RiskAssessmentController.java
View file @
6b8d2f0
...
@@ -9,10 +9,13 @@ import io.swagger.annotations.ApiResponse;
...
@@ -9,10 +9,13 @@ import io.swagger.annotations.ApiResponse;
import
io.swagger.annotations.ApiResponses
;
import
io.swagger.annotations.ApiResponses
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
/**
/**
* 风险评估 controller
* 风险评估 controller
...
@@ -82,4 +85,27 @@ public class RiskAssessmentController extends AbstractController {
...
@@ -82,4 +85,27 @@ public class RiskAssessmentController extends AbstractController {
UserBehaviorInformationVO
userBehaviorInformation
=
riskAssessmentService
.
getUserBehaviorInformation
(
vehicleId
);
UserBehaviorInformationVO
userBehaviorInformation
=
riskAssessmentService
.
getUserBehaviorInformation
(
vehicleId
);
return
R
.
ok
().
data
(
userBehaviorInformation
);
return
R
.
ok
().
data
(
userBehaviorInformation
);
}
}
/**
* 查询车辆警情时间轴信息
*/
@ApiOperation
(
value
=
"查询车辆警情时间轴信息"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
AlarmTimeLinePointVo
.
class
)})
@GetMapping
(
value
=
"/getAlarmTimeLine"
)
public
R
<
List
<
AlarmTimeLinePointVo
>>
getAlarmTimeLine
(
@RequestParam
(
"vehicleId"
)
Long
vehicleId
)
{
log
.
info
(
"查询车辆警情时间轴信息 vehicleId:{}"
,
vehicleId
);
List
<
AlarmTimeLinePointVo
>
alarmTimeLinePointVos
=
riskAssessmentService
.
getAlarmTimeLine
(
vehicleId
);
return
R
.
ok
().
data
(
alarmTimeLinePointVos
);
}
/**
* 车辆用量分析
*/
@ApiOperation
(
value
=
"车辆用量分析"
)
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
VehicleUsageAnalysisVO
.
class
)})
@GetMapping
(
value
=
"/usageAnalysis"
)
public
R
<
VehicleUsageAnalysisVO
>
usageAnalysis
(
@RequestParam
(
"vehicleId"
)
Long
vehicleId
)
{
VehicleUsageAnalysisVO
vehicleUsageAnalysisVO
=
riskAssessmentService
.
usageAnalysis
(
vehicleId
);
return
R
.
ok
().
data
(
vehicleUsageAnalysisVO
);
}
}
}
src/main/java/cn/com/glsx/admin/modules/entity/DeviceJourneyOverview.java
0 → 100644
View file @
6b8d2f0
package
cn
.
com
.
glsx
.
admin
.
modules
.
entity
;
import
com.glsx.plat.mybatis.base.BaseEntity
;
import
javax.persistence.Column
;
import
javax.persistence.Table
;
import
java.util.Date
;
@Table
(
name
=
"t_device_journey_overview"
)
public
class
DeviceJourneyOverview
extends
BaseEntity
{
/**
* 设备序列号
*/
private
String
sn
;
/**
* 车辆、设备关系id
*/
@Column
(
name
=
"vd_id"
)
private
Integer
vdId
;
/**
* 总行驶次数
*/
@Column
(
name
=
"total_journey_count"
)
private
Integer
totalJourneyCount
;
/**
* 总里程m
*/
private
Integer
distance
;
/**
* 创建时间|入库时间
*/
@Column
(
name
=
"created_date"
)
private
Date
createdDate
;
/**
* 更新时间
*/
@Column
(
name
=
"updated_date"
)
private
Date
updatedDate
;
/**
* 更新人用户id
*/
@Column
(
name
=
"updated_by"
)
private
Integer
updatedBy
;
private
static
final
long
serialVersionUID
=
1L
;
/**
* 获取设备序列号
*
* @return sn - 设备序列号
*/
public
String
getSn
()
{
return
sn
;
}
/**
* 设置设备序列号
*
* @param sn 设备序列号
*/
public
void
setSn
(
String
sn
)
{
this
.
sn
=
sn
==
null
?
null
:
sn
.
trim
();
}
/**
* 获取车辆、设备关系id
*
* @return vd_id - 车辆、设备关系id
*/
public
Integer
getVdId
()
{
return
vdId
;
}
/**
* 设置车辆、设备关系id
*
* @param vdId 车辆、设备关系id
*/
public
void
setVdId
(
Integer
vdId
)
{
this
.
vdId
=
vdId
;
}
/**
* 获取总行驶次数
*
* @return total_journey_count - 总行驶次数
*/
public
Integer
getTotalJourneyCount
()
{
return
totalJourneyCount
;
}
/**
* 设置总行驶次数
*
* @param totalJourneyCount 总行驶次数
*/
public
void
setTotalJourneyCount
(
Integer
totalJourneyCount
)
{
this
.
totalJourneyCount
=
totalJourneyCount
;
}
/**
* 获取总里程m
*
* @return distance - 总里程m
*/
public
Integer
getDistance
()
{
return
distance
;
}
/**
* 设置总里程m
*
* @param distance 总里程m
*/
public
void
setDistance
(
Integer
distance
)
{
this
.
distance
=
distance
;
}
/**
* 获取创建时间|入库时间
*
* @return created_date - 创建时间|入库时间
*/
public
Date
getCreatedDate
()
{
return
createdDate
;
}
/**
* 获取更新时间
*
* @return updated_date - 更新时间
*/
public
Date
getUpdatedDate
()
{
return
updatedDate
;
}
/**
* 设置更新人用户id
*
* @param updatedBy 更新人用户id
*/
public
void
setUpdatedBy
(
Integer
updatedBy
)
{
this
.
updatedBy
=
updatedBy
;
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
getClass
().
getSimpleName
());
sb
.
append
(
" ["
);
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", sn="
).
append
(
sn
);
sb
.
append
(
", vdId="
).
append
(
vdId
);
sb
.
append
(
", totalJourneyCount="
).
append
(
totalJourneyCount
);
sb
.
append
(
", distance="
).
append
(
distance
);
sb
.
append
(
", delFlag="
).
append
(
getDelFlag
());
sb
.
append
(
", createdDate="
).
append
(
createdDate
);
sb
.
append
(
", createdBy="
).
append
(
getCreatedBy
());
sb
.
append
(
", updatedDate="
).
append
(
updatedDate
);
sb
.
append
(
", updatedBy="
).
append
(
updatedBy
);
sb
.
append
(
", serialVersionUID="
).
append
(
serialVersionUID
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/mapper/AlarmWarnAnalyseMapper.java
View file @
6b8d2f0
...
@@ -16,4 +16,6 @@ import java.util.List;
...
@@ -16,4 +16,6 @@ import java.util.List;
public
interface
AlarmWarnAnalyseMapper
extends
CommonBaseMapper
<
AlarmWarnAnalyse
>
{
public
interface
AlarmWarnAnalyseMapper
extends
CommonBaseMapper
<
AlarmWarnAnalyse
>
{
List
<
AlarmWarnAnalyse
>
selectByVehicleId
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
List
<
AlarmWarnAnalyse
>
selectByVehicleId
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
List
<
AlarmWarnAnalyse
>
selectLatestAlarmOfEachType
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/mapper/DeviceJourneyMapper.java
View file @
6b8d2f0
...
@@ -3,7 +3,7 @@ package cn.com.glsx.admin.modules.mapper;
...
@@ -3,7 +3,7 @@ package cn.com.glsx.admin.modules.mapper;
import
cn.com.glsx.admin.modules.entity.DeviceJourney
;
import
cn.com.glsx.admin.modules.entity.DeviceJourney
;
import
cn.com.glsx.admin.modules.model.dto.UserBehaviorDayDTO
;
import
cn.com.glsx.admin.modules.model.dto.UserBehaviorDayDTO
;
import
cn.com.glsx.admin.modules.model.dto.UserBehaviorWeekDTO
;
import
cn.com.glsx.admin.modules.model.dto.UserBehaviorWeekDTO
;
import
cn.com.glsx.admin.modules.model.vo.
UserBehaviorInformation
VO
;
import
cn.com.glsx.admin.modules.model.vo.
VehicleUsageAnalysisPoint
VO
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -54,4 +54,20 @@ public interface DeviceJourneyMapper extends CommonBaseMapper<DeviceJourney> {
...
@@ -54,4 +54,20 @@ public interface DeviceJourneyMapper extends CommonBaseMapper<DeviceJourney> {
* @return 行程按照天统计信息
* @return 行程按照天统计信息
*/
*/
List
<
UserBehaviorDayDTO
>
statisticsDeviceJourneyWithDay
(
@Param
(
"sn"
)
String
sn
);
List
<
UserBehaviorDayDTO
>
statisticsDeviceJourneyWithDay
(
@Param
(
"sn"
)
String
sn
);
/**
* 通过设备的里程记录来统计车辆每周的使用天数
*
* @param sn
* @return
*/
List
<
VehicleUsageAnalysisPointVO
>
statisUsageBySnGroupByWeek
(
@Param
(
"sn"
)
String
sn
);
/**
* 统计设备每日的里程
*
* @param sn
* @return
*/
List
<
VehicleUsageAnalysisPointVO
>
statisMileageBySnGroupByDate
(
@Param
(
"sn"
)
String
sn
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/mapper/DeviceJourneyOverviewMapper.java
0 → 100644
View file @
6b8d2f0
package
cn
.
com
.
glsx
.
admin
.
modules
.
mapper
;
import
cn.com.glsx.admin.modules.entity.DeviceJourneyOverview
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
DeviceJourneyOverviewMapper
extends
CommonBaseMapper
<
DeviceJourneyOverview
>
{
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleDeviceMapper.java
View file @
6b8d2f0
...
@@ -10,13 +10,12 @@ import cn.com.glsx.admin.modules.model.param.ReportDeviceSearch;
...
@@ -10,13 +10,12 @@ import cn.com.glsx.admin.modules.model.param.ReportDeviceSearch;
import
cn.com.glsx.admin.modules.model.stat.StatActivatedVehicleDevice
;
import
cn.com.glsx.admin.modules.model.stat.StatActivatedVehicleDevice
;
import
cn.com.glsx.admin.modules.model.stat.StatCountModel
;
import
cn.com.glsx.admin.modules.model.stat.StatCountModel
;
import
cn.com.glsx.admin.modules.model.stat.StatSearch
;
import
cn.com.glsx.admin.modules.model.stat.StatSearch
;
import
cn.com.glsx.admin.modules.model.vo.DeviceInformationVO
;
import
com.glsx.plat.common.annotation.DataPerm
;
import
com.glsx.plat.common.annotation.DataPerm
;
import
com.glsx.plat.common.annotation.DataPermShare
;
import
com.glsx.plat.common.annotation.DataPermShare
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.ResultMap
;
import
org.apache.ibatis.annotations.Select
;
import
java.util.List
;
import
java.util.List
;
...
@@ -126,4 +125,37 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
...
@@ -126,4 +125,37 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
* @return 返回设备号信息
* @return 返回设备号信息
*/
*/
List
<
BasicDeviceDTO
>
selectBindDeviceByVehicleIdOrderByCreatedDate
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
List
<
BasicDeviceDTO
>
selectBindDeviceByVehicleIdOrderByCreatedDate
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
/**
* 根据车辆ID查询设备信息列表
*
* @param vehicleId
* @return
*/
List
<
DeviceInformationVO
>
getByVehicleId
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
/**
* 查找车辆最早安装的有线设备sn码
*
* @param vehicleId
* @return
*/
String
getEarliestWireDeviceSn
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
/**
* 根据userId列表查询所有车辆最早绑定的有线设备的sn码列表
*
* @param userIds
* @return
*/
List
<
String
>
getVehicleEarliestWireDeviceSnByUserIds
(
@Param
(
"userIds"
)
List
<
Long
>
userIds
);
/**
* 查找账号权限下所有车辆最早绑定的有线设备id列表
*
* @return
*/
@DataPerm
(
showSql
=
true
)
@DataPermShare
(
showSql
=
true
)
List
<
Long
>
getVehicleEarliestWireDeviceIdsByPermit
();
}
}
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
View file @
6b8d2f0
...
@@ -17,6 +17,7 @@ import org.apache.ibatis.annotations.Mapper;
...
@@ -17,6 +17,7 @@ import org.apache.ibatis.annotations.Mapper;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
@Mapper
@Mapper
...
@@ -403,4 +404,12 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
...
@@ -403,4 +404,12 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
* @return 设备离线数据
* @return 设备离线数据
*/
*/
List
<
OfflineExport
>
findOfflineDataByVehicleId
(
@Param
(
"vehicleId"
)
Long
vehicleId
,
@Param
(
"offlineStartTime"
)
String
OfflineStartTime
);
List
<
OfflineExport
>
findOfflineDataByVehicleId
(
@Param
(
"vehicleId"
)
Long
vehicleId
,
@Param
(
"offlineStartTime"
)
String
OfflineStartTime
);
/**
* 获取车辆(设备)激活时间(因为车辆绑定设备的激活时间取值顺序是:工单完成时间、车辆入库时间)
*
* @param vehicleId
* @return
*/
Date
getActiveDate
(
@Param
(
"vehicleId"
)
Long
vehicleId
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/model/dto/BasicInformationDTO.java
View file @
6b8d2f0
...
@@ -20,6 +20,11 @@ public class BasicInformationDTO implements Serializable {
...
@@ -20,6 +20,11 @@ public class BasicInformationDTO implements Serializable {
private
String
lesseeName
;
private
String
lesseeName
;
/**
/**
* 承租人联系电话
*/
private
String
lesseePhone
;
/**
* 店面名称
* 店面名称
*/
*/
private
String
shopName
;
private
String
shopName
;
...
@@ -35,11 +40,31 @@ public class BasicInformationDTO implements Serializable {
...
@@ -35,11 +40,31 @@ public class BasicInformationDTO implements Serializable {
private
String
workOrderNo
;
private
String
workOrderNo
;
/**
/**
* 工单安装城市
*/
private
String
installationCity
;
/**
* 车架号
* 车架号
*/
*/
private
String
vin
;
private
String
vin
;
/**
/**
* 车辆品牌
*/
private
String
brandName
;
/**
* 车系
*/
private
String
seriesName
;
/**
* 车型
*/
private
String
typeName
;
/**
* 创建时间
* 创建时间
*/
*/
private
String
createTime
;
private
String
createTime
;
...
...
src/main/java/cn/com/glsx/admin/modules/model/vo/AlarmTimeLinePointVo.java
0 → 100644
View file @
6b8d2f0
package
cn
.
com
.
glsx
.
admin
.
modules
.
model
.
vo
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @Title: 车辆警情时间轴节点视图对象
* @Description:
* @Author xiehx
* @Date 2024/5/31
**/
@ApiModel
(
value
=
"警情时间轴节点对象"
)
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
AlarmTimeLinePointVo
implements
Serializable
{
@ApiModelProperty
(
value
=
"报警类型"
)
private
String
alarmType
;
@ApiModelProperty
(
value
=
"报警时间,yyyy-MM-dd HH:mm:ss"
)
private
String
alarmTime
;
@ApiModelProperty
(
value
=
"报警设备"
)
private
String
device
;
/**
* 警情级别(排序用)
*/
@JsonIgnore
private
int
alarmLevel
;
}
src/main/java/cn/com/glsx/admin/modules/model/vo/AlarmTimeLineVo.java
0 → 100644
View file @
6b8d2f0
package
cn
.
com
.
glsx
.
admin
.
modules
.
model
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @Title: 车辆警情时间轴视图对象
* @Description:
* @Author xiehx
* @Date 2024/5/31
**/
@ApiModel
(
value
=
"警情时间轴对象"
)
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
AlarmTimeLineVo
implements
Serializable
{
@ApiModelProperty
(
value
=
"录入时间"
)
private
String
orderCreatedTime
;
@ApiModelProperty
(
value
=
"报警信息列表"
)
private
List
<
AlarmTimeLinePointVo
>
alarmInfoList
;
@ApiModelProperty
(
value
=
"最后检测时间"
)
private
String
finalPositTime
;
}
src/main/java/cn/com/glsx/admin/modules/model/vo/BasicInformationVO.java
View file @
6b8d2f0
...
@@ -23,6 +23,12 @@ public class BasicInformationVO implements Serializable {
...
@@ -23,6 +23,12 @@ public class BasicInformationVO implements Serializable {
private
String
lesseeName
;
private
String
lesseeName
;
/**
/**
* 承租人电话
*/
@ApiModelProperty
(
value
=
"承租人电话"
)
private
String
lesseePhone
;
/**
* 店面名称
* 店面名称
*/
*/
@ApiModelProperty
(
value
=
"店面名称"
)
@ApiModelProperty
(
value
=
"店面名称"
)
...
@@ -47,7 +53,31 @@ public class BasicInformationVO implements Serializable {
...
@@ -47,7 +53,31 @@ public class BasicInformationVO implements Serializable {
private
String
vin
;
private
String
vin
;
/**
/**
* 创建时间
* 工单安装城市
*/
@ApiModelProperty
(
value
=
"工单安装城市"
)
private
String
installationCity
;
/**
* 车辆品牌名称
*/
@ApiModelProperty
(
value
=
"车辆品牌名称"
)
private
String
brandName
;
/**
* 车辆系别名称
*/
@ApiModelProperty
(
value
=
"车辆系别名称"
)
private
String
seriesName
;
/**
* 车辆类型名称
*/
@ApiModelProperty
(
value
=
"车辆类型名称"
)
private
String
typeName
;
/**
* 工单创建时间
*/
*/
@ApiModelProperty
(
value
=
"创建时间"
)
@ApiModelProperty
(
value
=
"创建时间"
)
private
String
createTime
;
private
String
createTime
;
...
@@ -57,4 +87,5 @@ public class BasicInformationVO implements Serializable {
...
@@ -57,4 +87,5 @@ public class BasicInformationVO implements Serializable {
*/
*/
@ApiModelProperty
(
value
=
"设备状态"
)
@ApiModelProperty
(
value
=
"设备状态"
)
private
List
<
DeviceInformationVO
>
deviceInformationVOList
;
private
List
<
DeviceInformationVO
>
deviceInformationVOList
;
}
}
src/main/java/cn/com/glsx/admin/modules/model/vo/DeviceInformationVO.java
View file @
6b8d2f0
...
@@ -28,15 +28,21 @@ public class DeviceInformationVO implements Serializable {
...
@@ -28,15 +28,21 @@ public class DeviceInformationVO implements Serializable {
private
Integer
source
;
private
Integer
source
;
/**
/**
* 总里程,单位km
*/
@ApiModelProperty
(
value
=
"总里程,单位km"
)
private
Double
totalMileage
;
/**
* 设备类型 字符串
* 设备类型 字符串
*/
*/
@ApiModelProperty
(
value
=
"设备类型字符串"
)
@ApiModelProperty
(
value
=
"设备类型字符串"
)
private
String
sourceStr
;
private
String
sourceStr
;
/**
/**
* 设备状态
* 设备状态
(0 行驶中 1 静止 2离线 3 在线)
*/
*/
@ApiModelProperty
(
value
=
"设备状态"
)
@ApiModelProperty
(
value
=
"设备状态
(0 行驶中 1 静止 2离线 3 在线)
"
)
private
Integer
deviceState
;
private
Integer
deviceState
;
/**
/**
...
@@ -46,6 +52,12 @@ public class DeviceInformationVO implements Serializable {
...
@@ -46,6 +52,12 @@ public class DeviceInformationVO implements Serializable {
private
String
deviceStateStr
;
private
String
deviceStateStr
;
/**
/**
* 最后定位时间
*/
@ApiModelProperty
(
value
=
"最后定位时间"
)
private
String
finalPositTime
;
/**
* 定位地址
* 定位地址
*/
*/
@ApiModelProperty
(
value
=
"定位地址"
)
@ApiModelProperty
(
value
=
"定位地址"
)
...
...
src/main/java/cn/com/glsx/admin/modules/model/vo/VehicleUsageAnalysisPointVO.java
0 → 100644
View file @
6b8d2f0
package
cn
.
com
.
glsx
.
admin
.
modules
.
model
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* 车辆用量分析图点返回参数
*/
@ApiModel
(
value
=
"车辆用量分析图点返回参数"
)
@AllArgsConstructor
@NoArgsConstructor
@Data
public
class
VehicleUsageAnalysisPointVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"x轴坐标"
)
private
String
x
;
@ApiModelProperty
(
value
=
"y轴坐标"
)
private
Integer
y
;
}
src/main/java/cn/com/glsx/admin/modules/model/vo/VehicleUsageAnalysisVO.java
0 → 100644
View file @
6b8d2f0
package
cn
.
com
.
glsx
.
admin
.
modules
.
model
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* 车辆用量分析返回参数
*/
@ApiModel
(
value
=
"车辆用量分析返回参数"
)
@Data
public
class
VehicleUsageAnalysisVO
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"日均里程,单位km"
)
private
Double
average
;
@ApiModelProperty
(
value
=
"超过全平台百分之多少的车主,单位%"
)
private
Integer
percentage
;
@ApiModelProperty
(
value
=
"使用天数"
)
private
Integer
days
;
@ApiModelProperty
(
value
=
"活跃度 1低风险 2中风险 3高风险"
)
private
Integer
level
;
@ApiModelProperty
(
value
=
"活跃度等级对应提示语"
)
private
String
tips
;
@ApiModelProperty
(
value
=
"使用天数。日期:天数,日期间隔:一周"
)
private
List
<
VehicleUsageAnalysisPointVO
>
daysOfVehicle
;
@ApiModelProperty
(
value
=
"日里程。日期:里程,里程单位km"
)
private
List
<
VehicleUsageAnalysisPointVO
>
mileage
;
}
src/main/java/cn/com/glsx/admin/modules/remote/RemoteAlarmService.java
View file @
6b8d2f0
...
@@ -4,6 +4,7 @@ import cn.com.glsx.admin.modules.utils.StringUtil;
...
@@ -4,6 +4,7 @@ import cn.com.glsx.admin.modules.utils.StringUtil;
import
cn.com.glsx.alarm.api.AlarmFeignClient
;
import
cn.com.glsx.alarm.api.AlarmFeignClient
;
import
cn.com.glsx.alarm.services.model.*
;
import
cn.com.glsx.alarm.services.model.*
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
...
@@ -105,4 +106,15 @@ public class RemoteAlarmService {
...
@@ -105,4 +106,15 @@ public class RemoteAlarmService {
}
}
return
countAlarmRecCount
;
return
countAlarmRecCount
;
}
}
public
List
<
CommonAlarmDto
>
selectLatestAlarmOfEachType
(
List
<
String
>
snList
)
{
R
<
List
<
CommonAlarmDto
>>
searchR
=
alarmFeignClient
.
selectLatestAlarmOfEachType
(
snList
);
if
(
searchR
.
getCode
()
!=
200
||
!
searchR
.
getMessage
().
equalsIgnoreCase
(
"success"
))
{
log
.
info
(
JSON
.
toJSONString
(
snList
)
+
"find final.code:"
+
searchR
.
getCode
()
+
";message:"
+
searchR
.
getMessage
());
return
null
;
}
List
<
CommonAlarmDto
>
alarmList
=
searchR
.
getDataList
(
new
TypeToken
<
List
<
CommonAlarmDto
>>()
{
}.
getType
());
return
alarmList
;
}
}
}
src/main/java/cn/com/glsx/admin/modules/remote/RemoteStuJudgeAlarmService.java
View file @
6b8d2f0
...
@@ -92,4 +92,15 @@ public class RemoteStuJudgeAlarmService {
...
@@ -92,4 +92,15 @@ public class RemoteStuJudgeAlarmService {
}
}
return
stuJudgeAlarmDtoList
;
return
stuJudgeAlarmDtoList
;
}
}
public
List
<
StuJudgeAlarmDto
>
selectLatestAlarmOfEachType
(
List
<
String
>
snList
)
{
R
<
List
<
StuJudgeAlarmDto
>>
alarmDataListR
=
stuJudgeAlarmFeignClient
.
selectLatestAlarmOfEachType
(
snList
);
List
<
StuJudgeAlarmDto
>
alarmDataList
=
alarmDataListR
.
getDataList
(
new
TypeToken
<
List
<
StuJudgeAlarmDto
>>()
{
}.
getType
());
if
(
CollectionUtils
.
isEmpty
(
alarmDataList
))
{
alarmDataList
=
Lists
.
newArrayList
();
}
return
alarmDataList
;
}
}
}
src/main/java/cn/com/glsx/admin/modules/service/DeviceService.java
View file @
6b8d2f0
package
cn
.
com
.
glsx
.
admin
.
modules
.
service
;
package
cn
.
com
.
glsx
.
admin
.
modules
.
service
;
import
cn.com.glsx.admin.common.constants.ConstantsDevice
;
import
cn.com.glsx.admin.common.constants.ConstantsDevice
;
import
cn.com.glsx.admin.common.exception.AdminException
;
import
cn.com.glsx.admin.modules.entity.Device
;
import
cn.com.glsx.admin.modules.entity.Device
;
import
cn.com.glsx.admin.modules.entity.Vehicle
;
import
cn.com.glsx.admin.modules.entity.VehicleDevice
;
import
cn.com.glsx.admin.modules.entity.VehicleDevice
;
import
cn.com.glsx.admin.modules.mapper.DeviceLocationMapper
;
import
cn.com.glsx.admin.modules.mapper.DeviceMapper
;
import
cn.com.glsx.admin.modules.mapper.DeviceMapper
;
import
cn.com.glsx.admin.modules.mapper.VehicleDeviceMapper
;
import
cn.com.glsx.admin.modules.mapper.VehicleDeviceMapper
;
import
cn.com.glsx.admin.modules.mapper.VehicleMapper
;
import
cn.com.glsx.admin.modules.model.export.FinalPositioningExport
;
import
cn.com.glsx.admin.modules.model.param.FinalPositioningSearch
;
import
cn.com.glsx.admin.modules.model.param.TrackInfoBo
;
import
cn.com.glsx.admin.modules.model.param.TrackInfoBo
;
import
cn.com.glsx.admin.modules.model.vo.DeviceInformationVO
;
import
cn.com.glsx.admin.modules.remote.RemoteDeviceService
;
import
cn.com.glsx.admin.modules.remote.RemoteDeviceService
;
import
cn.com.glsx.admin.modules.remote.RemoteFeignDeviceService
;
import
cn.com.glsx.devicemonitor.api.dto.response.DeviceDTO
;
import
cn.com.glsx.devicemonitor.api.dto.response.DeviceDTO
;
import
cn.com.glsx.devicemonitor.api.dto.response.DeviceStatusModel
;
import
cn.com.glsx.devicemonitor.api.enums.DeviceStatusEnum
;
import
cn.com.glsx.devicemonitor.api.feign.DeviceFeignService
;
import
cn.com.glsx.devicemonitor.api.feign.DeviceFeignService
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.core.web.R
;
import
com.glsx.plat.core.web.R
;
import
com.google.common.collect.Maps
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
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
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
/**
* @Desc:设备service
* @Desc:设备service
...
@@ -40,6 +57,18 @@ public class DeviceService {
...
@@ -40,6 +57,18 @@ public class DeviceService {
@Autowired
@Autowired
private
VehicleDeviceMapper
vehicleDeviceMapper
;
private
VehicleDeviceMapper
vehicleDeviceMapper
;
@Autowired
private
RemoteFeignDeviceService
remoteFeignDeviceService
;
@Autowired
private
DeviceLocationMapper
deviceLocationMapper
;
@Autowired
private
FinalPositioningService
finalPositioningService
;
@Autowired
private
VehicleMapper
vehicleMapper
;
/**
/**
* 插入设备数据
* 插入设备数据
*
*
...
@@ -234,4 +263,61 @@ public class DeviceService {
...
@@ -234,4 +263,61 @@ public class DeviceService {
vehicleDevice
.
setBindStatus
(
1
);
vehicleDevice
.
setBindStatus
(
1
);
return
vehicleDeviceMapper
.
select
(
vehicleDevice
);
return
vehicleDeviceMapper
.
select
(
vehicleDevice
);
}
}
/**
* 根据车架号查询绑定的设备列表信息
*
* @param vehicleId
* @return
*/
public
List
<
DeviceInformationVO
>
getByVehicleId
(
Long
vehicleId
)
{
Vehicle
vehicle
=
vehicleMapper
.
selectById
(
vehicleId
);
if
(
vehicle
==
null
)
{
throw
new
AdminException
(
"该车辆不存在"
);
}
List
<
DeviceInformationVO
>
deviceStatusInfoVOList
=
vehicleDeviceMapper
.
getByVehicleId
(
vehicleId
);
if
(
CollectionUtils
.
isEmpty
(
deviceStatusInfoVOList
))
{
return
deviceStatusInfoVOList
;
}
//过滤DeviceType为空的数据,预防空指针
Map
<
String
,
Integer
>
snsMap
=
deviceStatusInfoVOList
.
stream
().
filter
(
m
->
m
.
getSource
()
!=
null
)
.
collect
(
Collectors
.
toMap
(
DeviceInformationVO:
:
getSn
,
DeviceInformationVO:
:
getSource
,
(
o
,
n
)
->
n
));
log
.
info
(
"获取设备状态 请求参数:{}"
,
JSON
.
toJSONString
(
snsMap
));
Map
<
String
,
DeviceStatusModel
>
deviceStatusMap
=
remoteFeignDeviceService
.
getDeviceStatusBySns
(
snsMap
);
log
.
info
(
"获取设备状态 请求结果:{}"
,
JSON
.
toJSONString
(
deviceStatusMap
));
FinalPositioningSearch
search
=
new
FinalPositioningSearch
();
search
.
setKeywords
(
vehicle
.
getVin
());
search
.
setPageNumber
(
1
);
search
.
setPageSize
(
10
);
log
.
info
(
"获取设备最后定位信息 请求参数:{}"
,
JSON
.
toJSONString
(
search
));
List
<
FinalPositioningExport
>
finalPositioningList
=
finalPositioningService
.
findFinalPositioningList
(
search
);
log
.
info
(
"获取设备最后定位信息 请求结果:{}"
,
JSON
.
toJSONString
(
finalPositioningList
));
Map
<
String
,
FinalPositioningExport
>
snLocationMap
=
Maps
.
newHashMap
();
if
(
CollectionUtils
.
isNotEmpty
(
finalPositioningList
))
{
snLocationMap
=
finalPositioningList
.
stream
().
collect
(
Collectors
.
toMap
(
FinalPositioningExport:
:
getSn
,
Function
.
identity
(),
(
o
,
n
)
->
n
));
}
for
(
DeviceInformationVO
vo
:
deviceStatusInfoVOList
)
{
String
sn
=
vo
.
getSn
();
DeviceStatusModel
deviceStatusModel
=
deviceStatusMap
.
get
(
sn
);
if
(!
Objects
.
isNull
(
deviceStatusModel
))
{
vo
.
setDeviceState
(
deviceStatusModel
.
getStatus
());
vo
.
setDeviceStateStr
(
deviceStatusModel
.
getStatusTime
());
}
else
{
vo
.
setDeviceState
(
DeviceStatusEnum
.
OFFLINE
.
getCode
());
vo
.
setDeviceStateStr
(
DeviceStatusEnum
.
OFFLINE
.
getName
());
}
FinalPositioningExport
finalLocation
=
snLocationMap
.
get
(
sn
);
if
(!
Objects
.
isNull
(
finalLocation
))
{
vo
.
setFinalPositTime
(
finalLocation
.
getLastPoiTime
());
vo
.
setAddress
(
finalLocation
.
getLastPoiAddress
());
}
}
return
deviceStatusInfoVOList
;
}
}
}
src/main/java/cn/com/glsx/admin/modules/service/RiskAssessmentService.java
View file @
6b8d2f0
...
@@ -12,10 +12,13 @@ import cn.com.glsx.admin.modules.model.dto.BasicDeviceDTO;
...
@@ -12,10 +12,13 @@ import cn.com.glsx.admin.modules.model.dto.BasicDeviceDTO;
import
cn.com.glsx.admin.modules.model.dto.BasicInformationDTO
;
import
cn.com.glsx.admin.modules.model.dto.BasicInformationDTO
;
import
cn.com.glsx.admin.modules.model.dto.UserBehaviorDayDTO
;
import
cn.com.glsx.admin.modules.model.dto.UserBehaviorDayDTO
;
import
cn.com.glsx.admin.modules.model.dto.UserBehaviorWeekDTO
;
import
cn.com.glsx.admin.modules.model.dto.UserBehaviorWeekDTO
;
import
cn.com.glsx.admin.modules.model.export.FinalPositioningExport
;
import
cn.com.glsx.admin.modules.model.export.OfflineExport
;
import
cn.com.glsx.admin.modules.model.export.OfflineExport
;
import
cn.com.glsx.admin.modules.model.param.FinalPositioningSearch
;
import
cn.com.glsx.admin.modules.model.vo.*
;
import
cn.com.glsx.admin.modules.model.vo.*
;
import
cn.com.glsx.admin.modules.remote.*
;
import
cn.com.glsx.admin.modules.remote.*
;
import
cn.com.glsx.admin.modules.utils.DateUtil
;
import
cn.com.glsx.admin.modules.utils.DateUtil
;
import
cn.com.glsx.alarm.services.model.CommonAlarmDto
;
import
cn.com.glsx.alarm.services.model.StuJudgeAlarmDto
;
import
cn.com.glsx.alarm.services.model.StuJudgeAlarmDto
;
import
cn.com.glsx.auth.utils.ShieldContextHolder
;
import
cn.com.glsx.auth.utils.ShieldContextHolder
;
import
cn.com.glsx.devicemonitor.api.dto.LngLatDTO
;
import
cn.com.glsx.devicemonitor.api.dto.LngLatDTO
;
...
@@ -23,6 +26,7 @@ import cn.com.glsx.devicemonitor.api.dto.request.ResidentRequest;
...
@@ -23,6 +26,7 @@ import cn.com.glsx.devicemonitor.api.dto.request.ResidentRequest;
import
cn.com.glsx.devicemonitor.api.dto.request.StayPointRequest
;
import
cn.com.glsx.devicemonitor.api.dto.request.StayPointRequest
;
import
cn.com.glsx.devicemonitor.api.dto.response.*
;
import
cn.com.glsx.devicemonitor.api.dto.response.*
;
import
cn.com.glsx.devicemonitor.api.enums.DeviceStatusEnum
;
import
cn.com.glsx.devicemonitor.api.enums.DeviceStatusEnum
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
...
@@ -33,7 +37,13 @@ import org.apache.commons.collections.CollectionUtils;
...
@@ -33,7 +37,13 @@ import org.apache.commons.collections.CollectionUtils;
import
org.apache.commons.lang.time.DateUtils
;
import
org.apache.commons.lang.time.DateUtils
;
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
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.weekend.WeekendSqls
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -79,6 +89,13 @@ public class RiskAssessmentService {
...
@@ -79,6 +89,13 @@ public class RiskAssessmentService {
private
WhitelistSnMapper
whitelistSnMapper
;
private
WhitelistSnMapper
whitelistSnMapper
;
@Autowired
@Autowired
private
DeviceStayOftenMapper
deviceStayOftenMapper
;
private
DeviceStayOftenMapper
deviceStayOftenMapper
;
@Autowired
private
FinalPositioningService
finalPositioningService
;
@Autowired
private
DeviceLocationMapper
deviceLocationMapper
;
@Autowired
private
DeviceJourneyOverviewMapper
deviceJourneyOverviewMapper
;
/**
/**
* 获取停留点列表
* 获取停留点列表
...
@@ -144,7 +161,7 @@ public class RiskAssessmentService {
...
@@ -144,7 +161,7 @@ public class RiskAssessmentService {
}
}
/**
/**
* 获取
设备
基础信息
* 获取
车辆
基础信息
*
*
* @param vehicleId 车辆ID
* @param vehicleId 车辆ID
* @return 设备基础信息
* @return 设备基础信息
...
@@ -162,11 +179,16 @@ public class RiskAssessmentService {
...
@@ -162,11 +179,16 @@ public class RiskAssessmentService {
throw
new
AdminException
(
vehicleId
+
"该车辆信息为空"
);
throw
new
AdminException
(
vehicleId
+
"该车辆信息为空"
);
}
}
basicInformationVO
.
setLesseeName
(
basicInformationDTO
.
getLesseeName
());
basicInformationVO
.
setLesseeName
(
basicInformationDTO
.
getLesseeName
());
basicInformationVO
.
setLesseePhone
(
basicInformationDTO
.
getLesseePhone
());
basicInformationVO
.
setShopName
(
basicInformationDTO
.
getShopName
());
basicInformationVO
.
setShopName
(
basicInformationDTO
.
getShopName
());
// 取组织层级一级名称
// 取组织层级一级名称
basicInformationVO
.
setUserName
(
organizationApiService
.
getFirstLevelOrgName
(
basicInformationDTO
.
getCreatedBy
()));
basicInformationVO
.
setUserName
(
organizationApiService
.
getFirstLevelOrgName
(
basicInformationDTO
.
getCreatedBy
()));
basicInformationVO
.
setWorkOrderNo
(
basicInformationDTO
.
getWorkOrderNo
());
basicInformationVO
.
setWorkOrderNo
(
basicInformationDTO
.
getWorkOrderNo
());
basicInformationVO
.
setInstallationCity
(
basicInformationDTO
.
getInstallationCity
());
basicInformationVO
.
setVin
(
basicInformationDTO
.
getVin
());
basicInformationVO
.
setVin
(
basicInformationDTO
.
getVin
());
basicInformationVO
.
setBrandName
(
basicInformationDTO
.
getBrandName
());
basicInformationVO
.
setSeriesName
(
basicInformationDTO
.
getSeriesName
());
basicInformationVO
.
setTypeName
(
basicInformationDTO
.
getTypeName
());
basicInformationVO
.
setCreateTime
(
basicInformationDTO
.
getCreateTime
());
basicInformationVO
.
setCreateTime
(
basicInformationDTO
.
getCreateTime
());
// 通过设备号获取设备组合信息
// 通过设备号获取设备组合信息
String
sns
=
basicInformationDTO
.
getSns
();
String
sns
=
basicInformationDTO
.
getSns
();
...
@@ -490,4 +512,457 @@ public class RiskAssessmentService {
...
@@ -490,4 +512,457 @@ public class RiskAssessmentService {
}
}
return
userBehaviorDayNewList
;
return
userBehaviorDayNewList
;
}
}
/**
*
* @param vehicleId
* @return
*/
public
List
<
AlarmTimeLinePointVo
>
getAlarmTimeLine
(
Long
vehicleId
)
{
// 查询工单入库时间
Vehicle
vehicle
=
vehicleMapper
.
selectById
(
vehicleId
);
if
(
Objects
.
isNull
(
vehicle
))
{
throw
new
AdminException
(
"车辆不存在"
);
}
List
<
BasicDeviceDTO
>
devices
=
vehicleDeviceMapper
.
selectBindDeviceByVehicleIdOrderByCreatedDate
(
vehicleId
);
List
<
String
>
snList
=
devices
.
stream
().
map
(
device
->
device
.
getSn
()).
collect
(
Collectors
.
toList
());
Map
<
String
,
String
>
snDeviceNameMap
=
new
HashMap
<>();
int
wireTypeNum
=
1
;
int
wireLessTypeNum
=
1
;
for
(
BasicDeviceDTO
device
:
devices
)
{
Integer
type
=
device
.
getSource
();
String
typeName
=
TypeConverseEnum
.
SourceEnum
.
getStrBySourceType
(
type
);
if
(
type
.
equals
(
TypeConverseEnum
.
SourceEnum
.
HAS_SOURCE
.
getSourceType
()))
{
snDeviceNameMap
.
put
(
device
.
getSn
(),
typeName
+
wireTypeNum
);
wireTypeNum
++;
}
else
{
snDeviceNameMap
.
put
(
device
.
getSn
(),
typeName
+
wireLessTypeNum
);
wireLessTypeNum
++;
}
}
// 查询大数据研判警情:黑区、聚集
List
<
AlarmTimeLinePointVo
>
alarmInfoList
=
Lists
.
newArrayList
();
log
.
info
(
"查询大数据研判警情 请求参数:{}"
,
JSONUtil
.
toJsonStr
(
snList
));
List
<
StuJudgeAlarmDto
>
stuJudgeAlarmList
=
remoteStuJudgeAlarmService
.
selectLatestAlarmOfEachType
(
snList
);
log
.
info
(
"查询大数据研判警情 请求结果:{}"
,
JSONUtil
.
toJsonStr
(
stuJudgeAlarmList
));
stuJudgeAlarmList
.
forEach
(
alarm
->
{
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
pointVo
.
setAlarmType
(
TypeConverseEnum
.
AlarmTypeEnum
.
getStrByAlarmType
(
alarm
.
getAlarmType
()));
pointVo
.
setAlarmTime
(
alarm
.
getAlarmBeginTime
());
pointVo
.
setDevice
(
snDeviceNameMap
.
get
(
alarm
.
getSn
()));
pointVo
.
setAlarmLevel
(
1
);
alarmInfoList
.
add
(
pointVo
);
});
// 查询防拆警情:断电、光感、翻转
log
.
info
(
"查询防拆警情 请求参数:{}"
,
JSONUtil
.
toJsonStr
(
snList
));
List
<
CommonAlarmDto
>
tearDownAlarmList
=
remoteAlarmService
.
selectLatestAlarmOfEachType
(
snList
);
log
.
info
(
"查询防拆警情 请求结果:{}"
,
JSONUtil
.
toJsonStr
(
tearDownAlarmList
));
if
(
CollectionUtils
.
isNotEmpty
(
tearDownAlarmList
))
{
tearDownAlarmList
.
forEach
(
alarm
->
{
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
pointVo
.
setAlarmLevel
(
1
);
pointVo
.
setAlarmTime
(
alarm
.
getBeginTime
());
pointVo
.
setDevice
(
snDeviceNameMap
.
get
(
alarm
.
getSn
()));
pointVo
.
setAlarmType
(
TypeConverseEnum
.
AlarmRecTypeEnum
.
getStrByAlarmType
(
alarm
.
getAlarmType
()));
alarmInfoList
.
add
(
pointVo
);
});
}
// 查询离线警情
AlarmTimeLinePointVo
offlinePointVo
=
getOffLinePoint
(
snList
,
snDeviceNameMap
);
if
(
Objects
.
nonNull
(
offlinePointVo
)
&&
!
falseOffline
(
vehicle
.
getVin
()))
{
alarmInfoList
.
add
(
offlinePointVo
);
}
// 查询警情研判:多种警情
List
<
AlarmWarnAnalyse
>
alarmWarnAnalyseList
=
alarmWarnAnalyseMapper
.
selectLatestAlarmOfEachType
(
vehicleId
);
if
(
CollectionUtils
.
isNotEmpty
(
alarmWarnAnalyseList
))
{
alarmWarnAnalyseList
.
forEach
(
alarm
->
{
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
pointVo
.
setAlarmLevel
(
alarm
.
getAlarmLevel
());
pointVo
.
setAlarmTime
(
DateUtil
.
formatDate
(
alarm
.
getAlarmTime
()));
pointVo
.
setAlarmType
(
alarm
.
getAlarmExplain
());
String
[]
snArr
=
alarm
.
getDeviceNoes
().
split
(
";"
);
for
(
String
sn
:
snArr
)
{
if
(
snDeviceNameMap
.
containsKey
(
sn
))
{
pointVo
.
setDevice
(
snDeviceNameMap
.
get
(
sn
));
break
;
}
}
alarmInfoList
.
add
(
pointVo
);
});
}
// 警情按触发时间顺序排序,再按等级优先级排序
Comparator
<
AlarmTimeLinePointVo
>
comparator
=
(
e1
,
e2
)
->
{
Date
date1
=
DateUtil
.
parseDate
(
e1
.
getAlarmTime
());
Date
date2
=
DateUtil
.
parseDate
(
e2
.
getAlarmTime
());
if
(
date1
.
equals
(
date2
))
{
return
Integer
.
compare
(
e1
.
getAlarmLevel
(),
e2
.
getAlarmLevel
());
}
else
{
return
date1
.
compareTo
(
date2
);
}
};
alarmInfoList
.
sort
(
comparator
);
// 获取录入时间节点
WorkOrder
workOrder
=
workOrderMapper
.
selectById
(
vehicle
.
getWorkOrderId
());
AlarmTimeLinePointVo
firstPoint
=
new
AlarmTimeLinePointVo
();
firstPoint
.
setAlarmType
(
"录入时间"
);
firstPoint
.
setAlarmTime
(
DateUtil
.
formatDate
(
workOrder
.
getCreatedDate
()));
alarmInfoList
.
add
(
0
,
firstPoint
);
// 获取最后检测时间节点
getLatestCheckPoint
(
alarmInfoList
,
vehicle
,
snDeviceNameMap
);
return
alarmInfoList
;
}
/**
* 通过车架号判断车辆是否是假性离线
* 假性离线有三种情况
*
* @param vin 车架号
* @return true是假性离线 false不是假性离线
*/
private
boolean
falseOffline
(
String
vin
)
{
boolean
result
=
false
;
List
<
String
>
vinList
=
Lists
.
newArrayList
(
vin
);
// 一 获取设备都离线 最后定位点在家庭围栏或者工作地围栏 获取车架通过权限控制 当存在设备都离线的车辆时才进行计算
List
<
String
>
fakeOfflineVinList
=
fakeOfflineVinMapper
.
getFakeOfflineVinByFence
(
vinList
);
log
.
info
(
"getFakeOfflineVinByFence:{}"
,
JSONUtil
.
toJsonStr
(
fakeOfflineVinList
));
if
(
CollectionUtils
.
isNotEmpty
(
fakeOfflineVinList
))
{
result
=
Boolean
.
TRUE
;
}
// 二 十日内状态反复变化 假性离线
List
<
FakeOfflineChangeFrequently
>
changeFrequentlyList
=
fakeOfflineChangeFrequentlyMapper
.
listByVin
(
vinList
);
log
.
info
(
"listByVin:{}"
,
JSONUtil
.
toJsonStr
(
changeFrequentlyList
));
if
(
CollectionUtils
.
isNotEmpty
(
changeFrequentlyList
))
{
result
=
Boolean
.
TRUE
;
}
// 三 获取本部门以及下级部门的白名单
Set
<
Long
>
deptIds
=
organizationApiService
.
getAllSubOrgIds
();
log
.
info
(
"isFakeOffline userId:"
+
ShieldContextHolder
.
getUserId
()
+
";deptIds:"
+
JSONUtil
.
toJsonStr
(
deptIds
));
// 从白名单列表获取白名单设备号及其车架号
List
<
String
>
writeListVinList
=
whitelistSnMapper
.
getWriteListVinListAndDeptIds
(
deptIds
,
vinList
);
log
.
info
(
"getWriteListVinListAndDeptIds:{}"
,
JSONUtil
.
toJsonStr
(
writeListVinList
));
// 白名单不为空 并且白名单包括车架号
if
(
CollectionUtils
.
isNotEmpty
(
writeListVinList
))
{
result
=
Boolean
.
TRUE
;
}
return
result
;
}
/**
* 获取最后检测时间节点
*
* @param alarmInfoList
* @param vehicle
*/
private
void
getLatestCheckPoint
(
List
<
AlarmTimeLinePointVo
>
alarmInfoList
,
Vehicle
vehicle
,
Map
<
String
,
String
>
snDeviceNameMap
)
{
FinalPositioningSearch
search
=
new
FinalPositioningSearch
();
search
.
setKeywords
(
vehicle
.
getVin
());
search
.
setPageNumber
(
1
);
search
.
setPageSize
(
10
);
List
<
FinalPositioningExport
>
finalPositioningList
=
finalPositioningService
.
findFinalPositioningList
(
search
);
if
(
CollectionUtils
.
isEmpty
(
finalPositioningList
))
{
return
;
}
// 时间排序
TreeMap
<
String
,
String
>
sortedMap
=
new
TreeMap
<>(
new
Comparator
<
String
>()
{
@Override
public
int
compare
(
String
o1
,
String
o2
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
DateUtil
.
YMDHMS
);
try
{
Date
time1
=
sdf
.
parse
(
o1
);
Date
time2
=
sdf
.
parse
(
o2
);
// 倒序排序
return
time2
.
compareTo
(
time1
);
}
catch
(
ParseException
e
)
{
throw
new
IllegalArgumentException
(
"Invalid time format"
,
e
);
}
}
});
for
(
FinalPositioningExport
position
:
finalPositioningList
)
{
String
sn
=
position
.
getSn
();
if
(
StringUtils
.
isNotBlank
(
position
.
getLastPoiTime
()))
{
sortedMap
.
put
(
position
.
getLastPoiTime
(),
sn
);
}
if
(
StringUtils
.
isNotBlank
(
position
.
getFinalGpsTime
()))
{
sortedMap
.
put
(
position
.
getFinalGpsTime
(),
sn
);
}
if
(
StringUtils
.
isNotBlank
(
position
.
getFinalBsTime
()))
{
sortedMap
.
put
(
position
.
getFinalBsTime
(),
sn
);
}
}
AlarmTimeLinePointVo
lastPoint
=
new
AlarmTimeLinePointVo
();
lastPoint
.
setAlarmType
(
"最后检测"
);
if
(
sortedMap
.
size
()
==
0
)
{
String
sn
=
finalPositioningList
.
get
(
0
).
getSn
();
lastPoint
.
setDevice
(
snDeviceNameMap
.
get
(
sn
));
}
else
{
Map
.
Entry
<
String
,
String
>
firstEntry
=
sortedMap
.
firstEntry
();
String
time
=
firstEntry
.
getKey
();
String
sn
=
firstEntry
.
getValue
();
lastPoint
.
setAlarmTime
(
time
);
lastPoint
.
setDevice
(
snDeviceNameMap
.
get
(
sn
));
}
alarmInfoList
.
add
(
lastPoint
);
}
/**
* 获取离线警情
*
* @param snList 车辆设备号集合
*/
private
AlarmTimeLinePointVo
getOffLinePoint
(
List
<
String
>
snList
,
Map
<
String
,
String
>
snDeviceNameMap
)
{
List
<
DeviceLocation
>
deviceLocationList
=
deviceLocationMapper
.
findLocationListBySnList
(
snList
);
if
(
CollectionUtils
.
isEmpty
(
deviceLocationList
))
{
return
null
;
}
// 是否离线判断 前三天时间范围内存在上报记录则不算离线
for
(
DeviceLocation
location
:
deviceLocationList
)
{
Date
date
=
DateUtils
.
addDays
(
new
Date
(),
-
3
);
Date
lastGpsTime
=
location
.
getLastGpsTime
();
if
(
Objects
.
nonNull
(
lastGpsTime
)
&&
lastGpsTime
.
compareTo
(
date
)
>
0
)
{
return
null
;
}
Date
lastBsTime
=
location
.
getLastBsTime
();
if
(
Objects
.
nonNull
(
lastBsTime
)
&&
lastBsTime
.
compareTo
(
date
)
>
0
)
{
return
null
;
}
}
// 取基准时间
Date
latestTime
=
null
;
String
alarmSn
=
null
;
for
(
DeviceLocation
location
:
deviceLocationList
)
{
Date
lastGpsTime
=
location
.
getLastGpsTime
();
if
(
Objects
.
nonNull
(
lastGpsTime
))
{
latestTime
=
lastGpsTime
;
alarmSn
=
location
.
getSn
();
break
;
}
Date
lastBsTime
=
location
.
getLastBsTime
();
if
(
Objects
.
nonNull
(
lastBsTime
))
{
latestTime
=
lastBsTime
;
alarmSn
=
location
.
getSn
();
break
;
}
}
// 不存在基准时间则以第一个设备为准
if
(
Objects
.
isNull
(
latestTime
))
{
return
null
;
}
// 取最近上报时间点
for
(
DeviceLocation
location
:
deviceLocationList
)
{
Date
lastGpsTime
=
location
.
getLastGpsTime
();
if
(
Objects
.
nonNull
(
lastGpsTime
)
&&
lastGpsTime
.
compareTo
(
latestTime
)
>
0
)
{
latestTime
=
lastGpsTime
;
alarmSn
=
location
.
getSn
();
}
Date
lastBsTime
=
location
.
getLastBsTime
();
if
(
Objects
.
nonNull
(
lastBsTime
)
&&
lastBsTime
.
compareTo
(
latestTime
)
>
0
)
{
latestTime
=
lastBsTime
;
alarmSn
=
location
.
getSn
();
}
}
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
pointVo
.
setAlarmLevel
(
3
);
pointVo
.
setAlarmTime
(
DateUtil
.
formatDate
(
latestTime
));
pointVo
.
setAlarmType
(
"离线报警"
);
pointVo
.
setDevice
(
snDeviceNameMap
.
get
(
alarmSn
));
return
pointVo
;
}
private
static
List
<
FinalPositioningExport
>
customSort
(
List
<
FinalPositioningExport
>
finalPositioningList
)
{
return
finalPositioningList
.
stream
()
.
sorted
(
Comparator
.
comparing
(
FinalPositioningExport:
:
getLastPoiTime
,
(
time1
,
time2
)
->
{
if
(
Objects
.
isNull
(
time1
)
&&
Objects
.
isNull
(
time2
))
{
return
0
;
}
if
(
Objects
.
isNull
(
time1
))
{
return
-
1
;
}
if
(
Objects
.
isNull
(
time2
))
{
return
1
;
}
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
LocalDateTime
dateTime1
=
LocalDateTime
.
parse
(
time1
,
formatter
);
LocalDateTime
dateTime2
=
LocalDateTime
.
parse
(
time2
,
formatter
);
return
dateTime2
.
compareTo
(
dateTime1
);
})
)
.
collect
(
Collectors
.
toList
());
}
public
VehicleUsageAnalysisVO
usageAnalysis
(
Long
vehicleId
)
{
VehicleUsageAnalysisVO
analysisVO
=
new
VehicleUsageAnalysisVO
();
//每日平均里程数
String
sn
=
vehicleDeviceMapper
.
getEarliestWireDeviceSn
(
vehicleId
);
log
.
info
(
"sn:{}"
,
sn
);
Example
overviewExample
=
new
Example
.
Builder
(
DeviceJourneyOverview
.
class
).
where
(
WeekendSqls
.<
DeviceJourneyOverview
>
custom
()
.
andEqualTo
(
DeviceJourneyOverview:
:
getSn
,
sn
).
andEqualTo
(
DeviceJourneyOverview:
:
getDelFlag
,
0
)).
build
();
DeviceJourneyOverview
overview
=
deviceJourneyOverviewMapper
.
selectOneByExample
(
overviewExample
);
//激活日期
Date
activeDate
=
vehicleMapper
.
getActiveDate
(
vehicleId
);
if
(!
Objects
.
isNull
(
overview
))
{
int
activeDays
=
(
int
)
cn
.
hutool
.
core
.
date
.
DateUtil
.
between
(
activeDate
,
DateUtils
.
addDays
(
new
Date
(),
-
1
),
DateUnit
.
DAY
);
Integer
distance
=
overview
.
getDistance
();
double
average
=
distance
/
1000.0
/
activeDays
;
int
tempAverage
=
(
int
)
(
average
*
1000
);
analysisVO
.
setAverage
(
tempAverage
/
1000.0
);
}
else
{
analysisVO
.
setAverage
(
0.000
);
}
//超过全平台百分比车主
int
percentage
=
100
;
if
(!
Objects
.
isNull
(
overview
))
{
List
<
Long
>
vehicleDeviceIds
=
vehicleDeviceMapper
.
getVehicleEarliestWireDeviceIdsByPermit
();
Example
vdExample
=
new
Example
.
Builder
(
VehicleDevice
.
class
).
where
(
WeekendSqls
.<
VehicleDevice
>
custom
()
.
andIn
(
VehicleDevice:
:
getId
,
vehicleDeviceIds
)).
build
();
List
<
VehicleDevice
>
devices
=
vehicleDeviceMapper
.
selectByExample
(
vdExample
);
List
<
String
>
snList
=
devices
.
stream
().
map
(
VehicleDevice:
:
getSn
).
collect
(
Collectors
.
toList
());
Example
allOverviewExample
=
new
Example
.
Builder
(
DeviceJourneyOverview
.
class
)
.
where
(
WeekendSqls
.<
DeviceJourneyOverview
>
custom
()
.
andIn
(
DeviceJourneyOverview:
:
getSn
,
snList
).
andEqualTo
(
DeviceJourneyOverview:
:
getDelFlag
,
0
))
.
orderByDesc
(
"distance"
).
build
();
List
<
DeviceJourneyOverview
>
overviews
=
deviceJourneyOverviewMapper
.
selectByExample
(
allOverviewExample
);
List
<
Integer
>
allDistance
=
overviews
.
stream
().
map
(
DeviceJourneyOverview:
:
getDistance
).
collect
(
Collectors
.
toList
());
percentage
=
((
allDistance
.
indexOf
(
overview
.
getDistance
())
+
1
)
*
100
)
/
snList
.
size
();
analysisVO
.
setPercentage
(
100
-
percentage
);
}
else
{
analysisVO
.
setPercentage
(
0
);
}
//用车活跃度
if
(
percentage
<=
33
)
{
analysisVO
.
setLevel
(
3
);
analysisVO
.
setTips
(
"建议电呼,核实用车行为"
);
}
else
if
(
percentage
<=
66
)
{
analysisVO
.
setLevel
(
2
);
analysisVO
.
setTips
(
"重点观察"
);
}
else
{
analysisVO
.
setLevel
(
1
);
analysisVO
.
setTips
(
"继续观察"
);
}
//用车天数 最后定位日期-激活日期
Vehicle
vehicle
=
vehicleMapper
.
selectById
(
vehicleId
);
FinalPositioningSearch
search
=
new
FinalPositioningSearch
();
search
.
setKeywords
(
vehicle
.
getVin
());
search
.
setPageNumber
(
1
);
search
.
setPageSize
(
10
);
List
<
FinalPositioningExport
>
finalPositioningList
=
finalPositioningService
.
findFinalPositioningList
(
search
);
if
(
CollectionUtils
.
isNotEmpty
(
finalPositioningList
))
{
Map
<
String
,
FinalPositioningExport
>
snLocationMap
=
finalPositioningList
.
stream
().
collect
(
Collectors
.
toMap
(
FinalPositioningExport:
:
getSn
,
Function
.
identity
(),
(
o
,
n
)
->
n
));
FinalPositioningExport
finalPosition
=
snLocationMap
.
get
(
sn
);
if
(
Objects
.
nonNull
(
finalPosition
)
&&
!
StringUtils
.
isEmpty
(
finalPosition
.
getLastPoiTime
()))
{
Date
lastPoiDate
=
DateUtil
.
parseDate
(
finalPosition
.
getLastPoiTime
());
if
(
lastPoiDate
.
after
(
activeDate
))
{
int
daysOfUsage
=
(
int
)
cn
.
hutool
.
core
.
date
.
DateUtil
.
betweenDay
(
activeDate
,
lastPoiDate
,
true
);
analysisVO
.
setDays
(
daysOfUsage
);
}
}
}
if
(
Objects
.
isNull
(
analysisVO
.
getDays
()))
{
analysisVO
.
setDays
(
0
);
}
//日里程
List
<
VehicleUsageAnalysisPointVO
>
mileage
=
deviceJourneyMapper
.
statisMileageBySnGroupByDate
(
sn
);
if
(
CollectionUtils
.
isNotEmpty
(
mileage
))
{
String
firstDateStr
=
mileage
.
get
(
0
).
getX
();
String
lastDateStr
=
mileage
.
get
(
mileage
.
size
()
-
1
).
getX
();
if
(
DateUtil
.
isSameWeek
(
DateUtil
.
parseDateYmd
(
firstDateStr
),
DateUtil
.
parseDateYmd
(
lastDateStr
)))
{
mileage
=
fillBlankDate
(
mileage
,
DateUtil
.
getFirstDateOfWeek
(
DateUtil
.
parseDateYmd
(
firstDateStr
)),
DateUtil
.
getLastDateOfWeek
(
DateUtil
.
parseDateYmd
(
firstDateStr
)),
1
);
analysisVO
.
setMileage
(
mileage
);
return
analysisVO
;
}
else
{
mileage
=
fillBlankDate
(
mileage
,
DateUtil
.
getFirstDateOfWeek
(
DateUtil
.
parseDateYmd
(
firstDateStr
)),
DateUtil
.
getLastDateOfWeek
(
DateUtil
.
parseDateYmd
(
lastDateStr
)),
1
);
analysisVO
.
setMileage
(
mileage
);
}
// 周用车天数
List
<
VehicleUsageAnalysisPointVO
>
usage
=
deviceJourneyMapper
.
statisUsageBySnGroupByWeek
(
sn
);
String
firstWeek
=
usage
.
get
(
0
).
getX
();
String
lastWeek
=
usage
.
get
(
usage
.
size
()
-
1
).
getX
();
usage
=
fillBlankDate
(
usage
,
DateUtil
.
parseDateYmd
(
firstWeek
),
DateUtil
.
parseDateYmd
(
lastWeek
),
7
);
analysisVO
.
setDaysOfVehicle
(
usage
);
}
else
{
analysisVO
.
setMileage
(
Lists
.
newArrayList
());
analysisVO
.
setDaysOfVehicle
(
Lists
.
newArrayList
());
}
return
analysisVO
;
}
/**
* 根据步长填充前后日期之间缺少的数据
*
* @param points
* @param startDate
* @param endDate
* @param factor
* @return
*/
private
List
<
VehicleUsageAnalysisPointVO
>
fillBlankDate
(
List
<
VehicleUsageAnalysisPointVO
>
points
,
Date
startDate
,
Date
endDate
,
int
factor
)
{
long
between
=
cn
.
hutool
.
core
.
date
.
DateUtil
.
between
(
startDate
,
endDate
,
DateUnit
.
DAY
);
//间隔大于12周则设置开始日期和节数日期间隔为12周,否则不调整
if
(
between
>
12
*
7
)
{
if
(
factor
==
1
)
{
startDate
=
DateUtil
.
addDays
(
endDate
,
-
12
*
7
+
1
);
}
else
if
(
factor
==
7
)
{
startDate
=
DateUtil
.
addDays
(
endDate
,
-
11
*
7
);
}
}
List
<
VehicleUsageAnalysisPointVO
>
resultList
=
new
ArrayList
<>();
Map
<
String
,
Integer
>
map
=
new
HashMap
<>();
for
(;
startDate
.
before
(
endDate
);)
{
map
.
put
(
DateUtil
.
formatDateYmd
(
startDate
),
0
);
startDate
=
DateUtils
.
addDays
(
startDate
,
factor
);
}
map
.
put
(
DateUtil
.
formatDateYmd
(
endDate
),
0
);
Map
<
String
,
Integer
>
mapTemp
=
points
.
stream
().
collect
(
Collectors
.
toMap
(
VehicleUsageAnalysisPointVO:
:
getX
,
VehicleUsageAnalysisPointVO:
:
getY
));
map
.
forEach
((
k
,
v
)
->
{
if
(
mapTemp
.
containsKey
(
k
))
{
resultList
.
add
(
new
VehicleUsageAnalysisPointVO
(
k
,
mapTemp
.
get
(
k
)));
}
else
{
resultList
.
add
(
new
VehicleUsageAnalysisPointVO
(
k
,
v
));
}
});
resultList
.
sort
(
Comparator
.
comparing
(
o
->
DateUtil
.
parseDateYmd
(
o
.
getX
())));
return
resultList
;
}
}
}
src/main/java/cn/com/glsx/admin/modules/utils/DateUtil.java
View file @
6b8d2f0
...
@@ -1585,6 +1585,70 @@ public class DateUtil extends org.apache.commons.lang.time.DateUtils {
...
@@ -1585,6 +1585,70 @@ public class DateUtil extends org.apache.commons.lang.time.DateUtils {
return
weekCount
;
// 获取该年共有多少周
return
weekCount
;
// 获取该年共有多少周
}
}
/**
* 比较返回最大的日期
*
* @param date1
* @param date2
* @return
*/
public
static
Date
getMaxDate
(
Date
date1
,
Date
date2
)
{
if
(
date1
==
null
)
{
return
date2
;
}
if
(
date2
==
null
)
{
return
date1
;
}
return
date1
.
after
(
date2
)
?
date1
:
date2
;
}
/**
* 判断两个日期是否是在同一周内
*
* @param date1
* @param date2
* @return
*/
public
static
boolean
isSameWeek
(
Date
date1
,
Date
date2
)
{
if
(
date1
==
null
||
date2
==
null
)
{
throw
new
IllegalArgumentException
(
"Both dates must not be null"
);
}
Calendar
c1
=
Calendar
.
getInstance
();
c1
.
setTime
(
date1
);
int
week1
=
c1
.
get
(
Calendar
.
WEEK_OF_YEAR
);
int
year1
=
c1
.
get
(
Calendar
.
YEAR
);
Calendar
c2
=
Calendar
.
getInstance
();
c2
.
setTime
(
date2
);
int
week2
=
c2
.
get
(
Calendar
.
WEEK_OF_YEAR
);
int
year2
=
c2
.
get
(
Calendar
.
YEAR
);
return
year1
==
year2
&&
week1
==
week2
;
}
public
static
Date
getFirstDateOfWeek
(
Date
date
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
// 将周的开始设置为周一
calendar
.
setFirstDayOfWeek
(
Calendar
.
MONDAY
);
// 获取周一日期
calendar
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
return
calendar
.
getTime
();
}
public
static
Date
getLastDateOfWeek
(
Date
date
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
// 将周的开始设置为周一
calendar
.
setFirstDayOfWeek
(
Calendar
.
MONDAY
);
calendar
.
set
(
Calendar
.
DAY_OF_WEEK
,
Calendar
.
MONDAY
);
calendar
.
add
(
Calendar
.
DAY_OF_MONTH
,
6
);
return
calendar
.
getTime
();
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// System.out.println(formatDate(getStartDateOfCurrentDay(new Date())));
// System.out.println(formatDate(getStartDateOfCurrentDay(new Date())));
System
.
out
.
println
(
getMaxDayOfCurrentMonth
());
System
.
out
.
println
(
getMaxDayOfCurrentMonth
());
...
...
src/main/resources/mapper/AlarmWarnAnalyseMapper.xml
View file @
6b8d2f0
...
@@ -35,5 +35,20 @@
...
@@ -35,5 +35,20 @@
WHERE deal_status = 2
WHERE deal_status = 2
AND vehicle_id = #{vehicleId}
AND vehicle_id = #{vehicleId}
</select>
</select>
<select
id=
"selectLatestAlarmOfEachType"
resultMap=
"BaseResultMap"
>
SELECT
t1.id, t1.device_noes, t1.alarm_time, t1.deal_status, t1.vehicle_id, t1.alarm_level, t1.alarm_explain,
t1.alarm_suggest, t1.alarm_type, t1.del_flag, t1.created_date, t1.created_by, t1.updated_date, t1.updated_by
FROM t_alarm_warn_analyse t1
inner join (
SELECT vehicle_id, alarm_explain, max(alarm_time) alarm_time
FROM t_alarm_warn_analyse
where vehicle_id = #{vehicleId} and del_flag = 0 and deal_status = 2
group by vehicle_id, alarm_explain
) t2 on t2.vehicle_id = t1.vehicle_id and t2.alarm_explain = t1.alarm_explain and t2.alarm_time = t1.alarm_time
<where>
t1.del_flag = 0 and t1.deal_status = 2
</where>
</select>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/DeviceJourneyMapper.xml
View file @
6b8d2f0
...
@@ -75,7 +75,24 @@
...
@@ -75,7 +75,24 @@
SUM(mileage)/1000 AS dayNum
SUM(mileage)/1000 AS dayNum
FROM t_device_journey
FROM t_device_journey
WHERE sn = #{sn}
WHERE sn = #{sn}
AND del_flag = 0
GROUP BY dayInt
GROUP BY dayInt
ORDER BY dayInt
ORDER BY dayInt
</select>
</select>
<select
id=
"statisUsageBySnGroupByWeek"
resultType=
"cn.com.glsx.admin.modules.model.vo.VehicleUsageAnalysisPointVO"
>
SELECT DATE_FORMAT(DATE_ADD(begin_time, INTERVAL (6-WEEKDAY(begin_time)) DAY), '%Y-%m-%d') AS x, count(distinct date(begin_time)) AS y
FROM t_device_journey
where sn = #{sn} and del_flag = 0
group by x
order by x
</select>
<select
id=
"statisMileageBySnGroupByDate"
resultType=
"cn.com.glsx.admin.modules.model.vo.VehicleUsageAnalysisPointVO"
>
SELECT DATE_FORMAT(begin_time, '%Y-%m-%d') AS x, sum(mileage)/1000 AS y
FROM t_device_journey
WHERE sn = #{sn} and del_flag = 0
GROUP BY x
ORDER BY x
</select>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/DeviceJourneyOverviewMapper.xml
0 → 100644
View file @
6b8d2f0
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.com.glsx.admin.modules.mapper.DeviceJourneyOverviewMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.admin.modules.entity.DeviceJourneyOverview"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"sn"
jdbcType=
"VARCHAR"
property=
"sn"
/>
<result
column=
"vd_id"
jdbcType=
"INTEGER"
property=
"vdId"
/>
<result
column=
"total_journey_count"
jdbcType=
"INTEGER"
property=
"totalJourneyCount"
/>
<result
column=
"distance"
jdbcType=
"INTEGER"
property=
"distance"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"updated_date"
jdbcType=
"TIMESTAMP"
property=
"updatedDate"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, sn, vd_id, total_journey_count, distance, del_flag, created_date, created_by,
updated_date, updated_by
</sql>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/VehicleDeviceMapper.xml
View file @
6b8d2f0
...
@@ -339,4 +339,45 @@
...
@@ -339,4 +339,45 @@
and tvd.del_flag = 0
and tvd.del_flag = 0
order by tvd.created_date
order by tvd.created_date
</select>
</select>
<select
id=
"getByVehicleId"
resultType=
"cn.com.glsx.admin.modules.model.vo.DeviceInformationVO"
>
select
tvd.sn sn,
td.source source,
ifnull(tdjo.distance, 0)/1000.0 totalMileage
from t_vehicle_device tvd
left join t_device td on td.sn = tvd.sn
left join t_device_journey_overview tdjo on tdjo.sn = tvd.sn
where tvd.vehicle_id = #{vehicleId}
and tvd.bind_status = 1
and tvd.del_flag = 0
order by tvd.wire_type desc, tvd.created_date
</select>
<select
id=
"getEarliestWireDeviceSn"
resultType=
"java.lang.String"
>
select tvd.sn
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_device td on td.sn = tvd.sn
where tv.id = #{vehicleId} and tv.del_flag = 0 and tvd.del_flag = 0 and tvd.bind_status = 1 and td.source = 1
order by tvd.id asc limit 1
</select>
<select
id=
"getVehicleEarliestWireDeviceSnByUserIds"
resultType=
"java.lang.String"
>
SELECT t1.sn FROM neshield.t_vehicle_device t1
inner join (
SELECT min(id) id, vehicle_id FROM neshield.t_vehicle_device
where wire_type = 1 and bind_status = 1 and del_flag = 0
and created_by in
<foreach
collection=
"userIds"
item=
"userId"
open=
"("
close=
")"
separator=
","
>
#{userId}
</foreach>
group by vehicle_id
) t2 on t2.id = t1.id
</select>
<select
id=
"getVehicleEarliestWireDeviceIdsByPermit"
resultType=
"java.lang.Long"
>
select min(tvd.id)
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
where tv.del_flag = 0 and tvd.del_flag = 0 and tvd.bind_status = 1 and tvd.wire_type = 1
group by tv.id
</select>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/main/resources/mapper/VehicleMapper.xml
View file @
6b8d2f0
...
@@ -1525,9 +1525,14 @@
...
@@ -1525,9 +1525,14 @@
resultType=
"cn.com.glsx.admin.modules.model.dto.BasicInformationDTO"
>
resultType=
"cn.com.glsx.admin.modules.model.dto.BasicInformationDTO"
>
select tv.id,
select tv.id,
twv.lessee_name AS lesseeName,
twv.lessee_name AS lesseeName,
twv.lessee_phone AS lesseePhone,
tw.`shop_name` AS shopName,
tw.`shop_name` AS shopName,
tw.partner_order_no AS workOrderNo,
tw.partner_order_no AS workOrderNo,
concat(tw.province, tw.city) AS installationCity,
tv.vin as vin,
tv.vin as vin,
tv.brand_name as brandName,
tv.series_name as seriesName,
tv.type_name as typeName,
tw.created_date AS createTime,
tw.created_date AS createTime,
group_concat(tvd.sn ORDER BY tvd.id) as sns,
group_concat(tvd.sn ORDER BY tvd.id) as sns,
group_concat(td.source ORDER BY tvd.id) as sources,
group_concat(td.source ORDER BY tvd.id) as sources,
...
@@ -1577,4 +1582,12 @@
...
@@ -1577,4 +1582,12 @@
</if>
</if>
order by vdId desc
order by vdId desc
</select>
</select>
<select
id=
"getActiveDate"
resultType=
"java.util.Date"
>
select
IFNULL(tw.finished_time, tv.created_date)
from t_vehicle tv
left join t_workorder tw on tw.id = tv.workorder_id
where tv.id = #{vehicleId}
and tv.del_flag = 0
</select>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment