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 a23936fc
authored
Jun 11, 2024
by
谢海旭
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
预警分析时间轴接口优化
1 parent
592c092e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
38 deletions
src/main/java/cn/com/glsx/admin/modules/controller/RiskAssessmentController.java
src/main/java/cn/com/glsx/admin/modules/service/RiskAssessmentService.java
src/main/java/cn/com/glsx/admin/modules/controller/RiskAssessmentController.java
View file @
a23936f
...
@@ -93,6 +93,7 @@ public class RiskAssessmentController extends AbstractController {
...
@@ -93,6 +93,7 @@ public class RiskAssessmentController extends AbstractController {
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
AlarmTimeLinePointVo
.
class
)})
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"OK"
,
response
=
AlarmTimeLinePointVo
.
class
)})
@GetMapping
(
value
=
"/getAlarmTimeLine"
)
@GetMapping
(
value
=
"/getAlarmTimeLine"
)
public
R
<
List
<
AlarmTimeLinePointVo
>>
getAlarmTimeLine
(
@RequestParam
(
"vehicleId"
)
Long
vehicleId
)
{
public
R
<
List
<
AlarmTimeLinePointVo
>>
getAlarmTimeLine
(
@RequestParam
(
"vehicleId"
)
Long
vehicleId
)
{
log
.
info
(
"查询车辆警情时间轴信息 vehicleId:{}"
,
vehicleId
);
List
<
AlarmTimeLinePointVo
>
alarmTimeLinePointVos
=
riskAssessmentService
.
getAlarmTimeLine
(
vehicleId
);
List
<
AlarmTimeLinePointVo
>
alarmTimeLinePointVos
=
riskAssessmentService
.
getAlarmTimeLine
(
vehicleId
);
return
R
.
ok
().
data
(
alarmTimeLinePointVos
);
return
R
.
ok
().
data
(
alarmTimeLinePointVos
);
}
}
...
...
src/main/java/cn/com/glsx/admin/modules/service/RiskAssessmentService.java
View file @
a23936f
...
@@ -529,50 +529,54 @@ public class RiskAssessmentService {
...
@@ -529,50 +529,54 @@ public class RiskAssessmentService {
List
<
VehicleDevice
>
devices
=
vehicleDeviceMapper
.
selectBindDeviceByVehicleId
(
vehicleId
);
List
<
VehicleDevice
>
devices
=
vehicleDeviceMapper
.
selectBindDeviceByVehicleId
(
vehicleId
);
List
<
String
>
snList
=
devices
.
stream
().
map
(
device
->
device
.
getSn
()).
collect
(
Collectors
.
toList
());
List
<
String
>
snList
=
devices
.
stream
().
map
(
device
->
device
.
getSn
()).
collect
(
Collectors
.
toList
());
devices
.
sort
(
Comparator
.
comparing
(
VehicleDevice:
:
getId
));
Map
<
String
,
String
>
snDeviceNameMap
=
new
HashMap
<>();
int
wireTypeNum
=
1
;
int
wireLessTypeNum
=
1
;
for
(
VehicleDevice
device
:
devices
)
{
Integer
type
=
device
.
getWireType
();
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
();
List
<
AlarmTimeLinePointVo
>
alarmInfoList
=
Lists
.
newArrayList
();
log
.
info
(
"查询大数据研判警情 请求参数:{}"
,
JSONUtil
.
toJsonStr
(
snList
));
List
<
StuJudgeAlarmDto
>
stuJudgeAlarmList
=
remoteStuJudgeAlarmService
.
selectLatestAlarmOfEachType
(
snList
);
List
<
StuJudgeAlarmDto
>
stuJudgeAlarmList
=
remoteStuJudgeAlarmService
.
selectLatestAlarmOfEachType
(
snList
);
log
.
info
(
"查询大数据研判警情 请求结果:{}"
,
JSONUtil
.
toJsonStr
(
stuJudgeAlarmList
));
stuJudgeAlarmList
.
forEach
(
alarm
->
{
stuJudgeAlarmList
.
forEach
(
alarm
->
{
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
// 2聚集 3黑区 TODO 优化
pointVo
.
setAlarmType
(
TypeConverseEnum
.
AlarmTypeEnum
.
getStrByAlarmType
(
alarm
.
getAlarmType
()));
pointVo
.
setAlarmType
(
alarm
.
getAlarmType
().
equals
(
3
)?
"黑区"
:
"聚集"
);
pointVo
.
setAlarmTime
(
alarm
.
getAlarmEndTime
());
pointVo
.
setAlarmTime
(
alarm
.
getAlarmEndTime
());
// TODO 处理 设备类型名称+排序序号,如“有线设备1”
pointVo
.
setDevice
(
snDeviceNameMap
.
get
(
alarm
.
getSn
()));
pointVo
.
setDevice
(
"有线设备1"
);
pointVo
.
setAlarmLevel
(
1
);
pointVo
.
setAlarmLevel
(
1
);
alarmInfoList
.
add
(
pointVo
);
alarmInfoList
.
add
(
pointVo
);
});
});
// 查询防拆警情:断电、光感、翻转
// 查询防拆警情:断电、光感、翻转
// TODO 接口测试,生效中的警情没有,只有开始时间没有结束时间
// TODO 接口测试,生效中的警情没有,只有开始时间没有结束时间
log
.
info
(
"查询防拆警情 请求参数:{}"
,
JSONUtil
.
toJsonStr
(
snList
));
List
<
CommonAlarmDto
>
tearDownAlarmList
=
remoteAlarmService
.
selectLatestAlarmOfEachType
(
snList
);
List
<
CommonAlarmDto
>
tearDownAlarmList
=
remoteAlarmService
.
selectLatestAlarmOfEachType
(
snList
);
log
.
info
(
"查询防拆警情 请求结果:{}"
,
JSONUtil
.
toJsonStr
(
tearDownAlarmList
));
if
(
CollectionUtils
.
isNotEmpty
(
tearDownAlarmList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
tearDownAlarmList
))
{
tearDownAlarmList
.
forEach
(
alarm
->
{
tearDownAlarmList
.
forEach
(
alarm
->
{
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
pointVo
.
setAlarmLevel
(
1
);
pointVo
.
setAlarmLevel
(
1
);
pointVo
.
setAlarmTime
(
alarm
.
getBeginTime
());
pointVo
.
setAlarmTime
(
alarm
.
getBeginTime
());
// TODO 处理 设备类型名称+排序序号,如“有线设备1”
pointVo
.
setDevice
(
snDeviceNameMap
.
get
(
alarm
.
getSn
()));
pointVo
.
setDevice
(
"有线设备1"
);
pointVo
.
setAlarmType
(
TypeConverseEnum
.
AlarmRecTypeEnum
.
getStrByAlarmType
(
alarm
.
getAlarmType
()));
// TODO 优化
switch
(
alarm
.
getAlarmType
())
{
case
1
:
pointVo
.
setAlarmType
(
"断电"
);
break
;
case
99
:
pointVo
.
setAlarmType
(
"光感"
);
break
;
case
15
:
pointVo
.
setAlarmType
(
"翻转"
);
break
;
default
:
break
;
}
alarmInfoList
.
add
(
pointVo
);
alarmInfoList
.
add
(
pointVo
);
});
});
}
}
// 查询离线警情
// 查询离线警情
getOffLinePoint
(
snList
,
alarmInfoList
);
getOffLinePoint
(
snList
,
alarmInfoList
,
snDeviceNameMap
);
// 查询警情研判:多种警情
// 查询警情研判:多种警情
List
<
AlarmWarnAnalyse
>
alarmWarnAnalyseList
=
alarmWarnAnalyseMapper
.
selectLatestAlarmOfEachType
(
vehicleId
);
List
<
AlarmWarnAnalyse
>
alarmWarnAnalyseList
=
alarmWarnAnalyseMapper
.
selectLatestAlarmOfEachType
(
vehicleId
);
...
@@ -582,8 +586,14 @@ public class RiskAssessmentService {
...
@@ -582,8 +586,14 @@ public class RiskAssessmentService {
pointVo
.
setAlarmLevel
(
alarm
.
getAlarmLevel
());
pointVo
.
setAlarmLevel
(
alarm
.
getAlarmLevel
());
pointVo
.
setAlarmTime
(
DateUtil
.
formatDate
(
alarm
.
getAlarmTime
()));
pointVo
.
setAlarmTime
(
DateUtil
.
formatDate
(
alarm
.
getAlarmTime
()));
pointVo
.
setAlarmType
(
alarm
.
getAlarmExplain
());
pointVo
.
setAlarmType
(
alarm
.
getAlarmExplain
());
// TODO 处理 设备类型名称+排序序号,如“有线设备1”
pointVo
.
setDevice
(
"有线设备1"
);
String
[]
snArr
=
alarm
.
getDeviceNoes
().
split
(
";"
);
for
(
String
sn
:
snArr
)
{
if
(
snDeviceNameMap
.
containsKey
(
sn
))
{
pointVo
.
setDevice
(
snDeviceNameMap
.
get
(
sn
));
break
;
}
}
alarmInfoList
.
add
(
pointVo
);
alarmInfoList
.
add
(
pointVo
);
});
});
}
}
...
@@ -592,7 +602,6 @@ public class RiskAssessmentService {
...
@@ -592,7 +602,6 @@ public class RiskAssessmentService {
Comparator
<
AlarmTimeLinePointVo
>
comparator
=
(
e1
,
e2
)
->
{
Comparator
<
AlarmTimeLinePointVo
>
comparator
=
(
e1
,
e2
)
->
{
Date
date1
=
DateUtil
.
parseDate
(
e1
.
getAlarmTime
());
Date
date1
=
DateUtil
.
parseDate
(
e1
.
getAlarmTime
());
Date
date2
=
DateUtil
.
parseDate
(
e2
.
getAlarmTime
());
Date
date2
=
DateUtil
.
parseDate
(
e2
.
getAlarmTime
());
// TODO 考虑判空
if
(
date1
.
equals
(
date2
))
{
if
(
date1
.
equals
(
date2
))
{
return
Integer
.
compare
(
e1
.
getAlarmLevel
(),
e2
.
getAlarmLevel
());
return
Integer
.
compare
(
e1
.
getAlarmLevel
(),
e2
.
getAlarmLevel
());
}
else
{
}
else
{
...
@@ -609,8 +618,7 @@ public class RiskAssessmentService {
...
@@ -609,8 +618,7 @@ public class RiskAssessmentService {
alarmInfoList
.
add
(
0
,
firstPoint
);
alarmInfoList
.
add
(
0
,
firstPoint
);
// 获取最后检测时间节点
// 获取最后检测时间节点
getLatestCheckPoint
(
alarmInfoList
,
vehicle
);
getLatestCheckPoint
(
alarmInfoList
,
vehicle
,
snDeviceNameMap
);
return
alarmInfoList
;
return
alarmInfoList
;
}
}
...
@@ -620,7 +628,7 @@ public class RiskAssessmentService {
...
@@ -620,7 +628,7 @@ public class RiskAssessmentService {
* @param alarmInfoList
* @param alarmInfoList
* @param vehicle
* @param vehicle
*/
*/
private
void
getLatestCheckPoint
(
List
<
AlarmTimeLinePointVo
>
alarmInfoList
,
Vehicle
vehicle
)
{
private
void
getLatestCheckPoint
(
List
<
AlarmTimeLinePointVo
>
alarmInfoList
,
Vehicle
vehicle
,
Map
<
String
,
String
>
snDeviceNameMap
)
{
FinalPositioningSearch
search
=
new
FinalPositioningSearch
();
FinalPositioningSearch
search
=
new
FinalPositioningSearch
();
search
.
setKeywords
(
vehicle
.
getVin
());
search
.
setKeywords
(
vehicle
.
getVin
());
search
.
setPageNumber
(
1
);
search
.
setPageNumber
(
1
);
...
@@ -634,7 +642,7 @@ public class RiskAssessmentService {
...
@@ -634,7 +642,7 @@ public class RiskAssessmentService {
TreeMap
<
String
,
String
>
sortedMap
=
new
TreeMap
<>(
new
Comparator
<
String
>()
{
TreeMap
<
String
,
String
>
sortedMap
=
new
TreeMap
<>(
new
Comparator
<
String
>()
{
@Override
@Override
public
int
compare
(
String
o1
,
String
o2
)
{
public
int
compare
(
String
o1
,
String
o2
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
DateUtil
.
YMDHMS
);
try
{
try
{
Date
time1
=
sdf
.
parse
(
o1
);
Date
time1
=
sdf
.
parse
(
o1
);
Date
time2
=
sdf
.
parse
(
o2
);
Date
time2
=
sdf
.
parse
(
o2
);
...
@@ -662,16 +670,14 @@ public class RiskAssessmentService {
...
@@ -662,16 +670,14 @@ public class RiskAssessmentService {
AlarmTimeLinePointVo
lastPoint
=
new
AlarmTimeLinePointVo
();
AlarmTimeLinePointVo
lastPoint
=
new
AlarmTimeLinePointVo
();
lastPoint
.
setAlarmType
(
"最后检测"
);
lastPoint
.
setAlarmType
(
"最后检测"
);
if
(
sortedMap
.
size
()
==
0
)
{
if
(
sortedMap
.
size
()
==
0
)
{
// TODO 处理 设备类型名称+排序序号,如“有线设备1”
String
sn
=
finalPositioningList
.
get
(
0
).
getSn
();
String
sn
=
finalPositioningList
.
get
(
0
).
getSn
();
lastPoint
.
setDevice
(
"有线设备1"
);
lastPoint
.
setDevice
(
snDeviceNameMap
.
get
(
sn
)
);
}
else
{
}
else
{
Map
.
Entry
<
String
,
String
>
firstEntry
=
sortedMap
.
firstEntry
();
Map
.
Entry
<
String
,
String
>
firstEntry
=
sortedMap
.
firstEntry
();
String
time
=
firstEntry
.
getKey
();
String
time
=
firstEntry
.
getKey
();
String
sn
=
firstEntry
.
getValue
();
String
sn
=
firstEntry
.
getValue
();
lastPoint
.
setAlarmTime
(
time
);
lastPoint
.
setAlarmTime
(
time
);
// TODO 处理 设备类型名称+排序序号,如“有线设备1”
lastPoint
.
setDevice
(
snDeviceNameMap
.
get
(
sn
));
lastPoint
.
setDevice
(
"有线设备1"
);
}
}
alarmInfoList
.
add
(
lastPoint
);
alarmInfoList
.
add
(
lastPoint
);
...
@@ -683,13 +689,13 @@ public class RiskAssessmentService {
...
@@ -683,13 +689,13 @@ public class RiskAssessmentService {
* @param snList
* @param snList
* @param alarmInfoList
* @param alarmInfoList
*/
*/
private
void
getOffLinePoint
(
List
<
String
>
snList
,
List
<
AlarmTimeLinePointVo
>
alarmInfoList
)
{
private
void
getOffLinePoint
(
List
<
String
>
snList
,
List
<
AlarmTimeLinePointVo
>
alarmInfoList
,
Map
<
String
,
String
>
snDeviceNameMap
)
{
List
<
DeviceLocation
>
deviceLocationList
=
deviceLocationMapper
.
findLocationListBySnList
(
snList
);
List
<
DeviceLocation
>
deviceLocationList
=
deviceLocationMapper
.
findLocationListBySnList
(
snList
);
if
(
CollectionUtils
.
isEmpty
(
deviceLocationList
))
{
if
(
CollectionUtils
.
isEmpty
(
deviceLocationList
))
{
return
;
return
;
}
}
// 是否离线判断
// 是否离线判断
前三天时间范围内存在上报记录则不算离线
for
(
DeviceLocation
location
:
deviceLocationList
)
{
for
(
DeviceLocation
location
:
deviceLocationList
)
{
Date
date
=
DateUtils
.
addDays
(
new
Date
(),
-
3
);
Date
date
=
DateUtils
.
addDays
(
new
Date
(),
-
3
);
Date
lastGpsTime
=
location
.
getLastGpsTime
();
Date
lastGpsTime
=
location
.
getLastGpsTime
();
...
@@ -703,6 +709,7 @@ public class RiskAssessmentService {
...
@@ -703,6 +709,7 @@ public class RiskAssessmentService {
}
}
}
}
// 取基准时间
Date
latestTime
=
null
;
Date
latestTime
=
null
;
String
alarmSn
=
null
;
String
alarmSn
=
null
;
for
(
DeviceLocation
location
:
deviceLocationList
)
{
for
(
DeviceLocation
location
:
deviceLocationList
)
{
...
@@ -721,17 +728,18 @@ public class RiskAssessmentService {
...
@@ -721,17 +728,18 @@ public class RiskAssessmentService {
}
}
}
}
// 不存在基准时间则以第一个设备为准
if
(
Objects
.
isNull
(
latestTime
))
{
if
(
Objects
.
isNull
(
latestTime
))
{
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
AlarmTimeLinePointVo
pointVo
=
new
AlarmTimeLinePointVo
();
pointVo
.
setAlarmLevel
(
3
);
pointVo
.
setAlarmLevel
(
3
);
pointVo
.
setAlarmType
(
"离线报警"
);
pointVo
.
setAlarmType
(
"离线报警"
);
// TODO 处理 设备类型名称+排序序号,如“有线设备1”
String
sn
=
deviceLocationList
.
get
(
0
).
getSn
();
String
sn
=
deviceLocationList
.
get
(
0
).
getSn
();
pointVo
.
setDevice
(
"有线设备1"
);
pointVo
.
setDevice
(
snDeviceNameMap
.
get
(
sn
)
);
alarmInfoList
.
add
(
pointVo
);
alarmInfoList
.
add
(
pointVo
);
return
;
return
;
}
}
// 取最近上报时间点
for
(
DeviceLocation
location
:
deviceLocationList
)
{
for
(
DeviceLocation
location
:
deviceLocationList
)
{
Date
lastGpsTime
=
location
.
getLastGpsTime
();
Date
lastGpsTime
=
location
.
getLastGpsTime
();
if
(
Objects
.
nonNull
(
lastGpsTime
)
&&
lastGpsTime
.
compareTo
(
latestTime
)
>
0
)
{
if
(
Objects
.
nonNull
(
lastGpsTime
)
&&
lastGpsTime
.
compareTo
(
latestTime
)
>
0
)
{
...
@@ -750,8 +758,7 @@ public class RiskAssessmentService {
...
@@ -750,8 +758,7 @@ public class RiskAssessmentService {
pointVo
.
setAlarmLevel
(
3
);
pointVo
.
setAlarmLevel
(
3
);
pointVo
.
setAlarmTime
(
DateUtil
.
formatDate
(
latestTime
));
pointVo
.
setAlarmTime
(
DateUtil
.
formatDate
(
latestTime
));
pointVo
.
setAlarmType
(
"离线报警"
);
pointVo
.
setAlarmType
(
"离线报警"
);
// TODO 处理 设备类型名称+排序序号,如“有线设备1”
pointVo
.
setDevice
(
snDeviceNameMap
.
get
(
alarmSn
));
pointVo
.
setDevice
(
"有线设备1"
);
alarmInfoList
.
add
(
pointVo
);
alarmInfoList
.
add
(
pointVo
);
}
}
...
...
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