Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
traffic-signal-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
signal
traffic-signal-platform
Commits
be18693d
Commit
be18693d
authored
Apr 07, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 代码优化
parent
b96af529
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
63 deletions
+122
-63
SituationDetectionServiceImpl.java
...wanji/web/service/impl/SituationDetectionServiceImpl.java
+31
-10
CommonEventWarnTask.java
...src/main/java/net/wanji/web/task/CommonEventWarnTask.java
+40
-22
SignalStatusTask.java
...ce/src/main/java/net/wanji/web/task/SignalStatusTask.java
+51
-31
No files found.
signal-control-service/src/main/java/net/wanji/web/service/impl/SituationDetectionServiceImpl.java
View file @
be18693d
...
@@ -410,13 +410,15 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
...
@@ -410,13 +410,15 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
@Override
@Override
public
List
<
JurisdictionAreaTreeVO
>
jurisdictionTree
(
Integer
areaId
,
Integer
type
)
throws
Exception
{
public
List
<
JurisdictionAreaTreeVO
>
jurisdictionTree
(
Integer
areaId
,
Integer
type
)
throws
Exception
{
List
<
JurisdictionAreaTreeVO
>
resultList
=
new
ArrayList
<>();
List
<
JurisdictionAreaTreeVO
>
resultList
=
new
ArrayList
<>();
//
辖区构建
//
查询辖区列表
LambdaQueryWrapper
<
TBaseAreaInfo
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
TBaseAreaInfo
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
TBaseAreaInfo:
:
getType
,
type
);
queryWrapper
.
eq
(
TBaseAreaInfo:
:
getType
,
type
);
if
(
Objects
.
nonNull
(
areaId
))
{
if
(
Objects
.
nonNull
(
areaId
))
{
queryWrapper
.
eq
(
TBaseAreaInfo:
:
getCode
,
areaId
);
queryWrapper
.
eq
(
TBaseAreaInfo:
:
getCode
,
areaId
);
}
}
List
<
TBaseAreaInfo
>
tBaseAreaInfos
=
tBaseAreaInfoMapper
.
selectList
(
queryWrapper
);
List
<
TBaseAreaInfo
>
tBaseAreaInfos
=
tBaseAreaInfoMapper
.
selectList
(
queryWrapper
);
// 通过辖区获取辖区内路口
List
<
Integer
>
areadCodeList
=
tBaseAreaInfos
.
stream
().
map
(
TBaseAreaInfo:
:
getCode
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
areadCodeList
=
tBaseAreaInfos
.
stream
().
map
(
TBaseAreaInfo:
:
getCode
).
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
TBaseAreaCross
>
crossQuery
=
new
LambdaQueryWrapper
<>();
LambdaQueryWrapper
<
TBaseAreaCross
>
crossQuery
=
new
LambdaQueryWrapper
<>();
if
(!
CollectionUtils
.
isEmpty
(
areadCodeList
))
{
if
(!
CollectionUtils
.
isEmpty
(
areadCodeList
))
{
...
@@ -424,9 +426,10 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
...
@@ -424,9 +426,10 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
}
}
List
<
TBaseAreaCross
>
tBaseAreaCrosses
=
tBaseAreaCrossMapper
.
selectList
(
crossQuery
);
List
<
TBaseAreaCross
>
tBaseAreaCrosses
=
tBaseAreaCrossMapper
.
selectList
(
crossQuery
);
LambdaQueryWrapper
<
TBaseCrossInfo
>
crossInfoQuery
=
new
LambdaQueryWrapper
<>();
// 查询路口信息
List
<
TBaseCrossInfo
>
tBaseCrossInfos
=
tBaseCrossInfoMapper
.
selectList
(
crossInfoQuery
);
List
<
TBaseCrossInfo
>
tBaseCrossInfos
=
tBaseCrossInfoMapper
.
selectList
(
new
LambdaQueryWrapper
<>()
);
// 将路口和辖区转化为辖区实体
getJurisdictionAreaTreeVO
(
resultList
,
tBaseAreaInfos
,
tBaseAreaCrosses
,
tBaseCrossInfos
);
getJurisdictionAreaTreeVO
(
resultList
,
tBaseAreaInfos
,
tBaseAreaCrosses
,
tBaseCrossInfos
);
// 构建树结构
// 构建树结构
...
@@ -533,8 +536,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
...
@@ -533,8 +536,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
Map
<
String
,
String
>
crossIdLocationMap
=
tBaseCrossInfos
.
stream
().
collect
(
Collectors
.
toMap
(
TBaseCrossInfo:
:
getId
,
TBaseCrossInfo:
:
getLocation
));
Map
<
String
,
String
>
crossIdLocationMap
=
tBaseCrossInfos
.
stream
().
collect
(
Collectors
.
toMap
(
TBaseCrossInfo:
:
getId
,
TBaseCrossInfo:
:
getLocation
));
// 辖区列表
// 辖区列表
LambdaQueryWrapper
<
TBaseAreaInfo
>
tBaseAreaInfoLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
List
<
TBaseAreaInfo
>
jurisdictionAreaList
=
tBaseAreaInfoMapper
.
selectList
(
new
LambdaQueryWrapper
<>());
List
<
TBaseAreaInfo
>
jurisdictionAreaList
=
tBaseAreaInfoMapper
.
selectList
(
tBaseAreaInfoLambdaQueryWrapper
);
// 构建区域返回列表
// 构建区域返回列表
for
(
Map
.
Entry
<
Integer
,
List
<
TBaseAreaCross
>>
entry
:
areaIdMap
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
List
<
TBaseAreaCross
>>
entry
:
areaIdMap
.
entrySet
())
{
...
@@ -570,8 +572,9 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
...
@@ -570,8 +572,9 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
@Override
@Override
public
List
<
SignalFaultInfoVO
>
listSignalFaultInfos
(
String
dealStatus
)
throws
Exception
{
public
List
<
SignalFaultInfoVO
>
listSignalFaultInfos
(
String
dealStatus
)
throws
Exception
{
TDeviceStatusInfo
tDeviceStatusInfo
=
new
TDeviceStatusInfo
();
TDeviceStatusInfo
tDeviceStatusInfo
=
new
TDeviceStatusInfo
();
tDeviceStatusInfo
.
setType
(
1
);
tDeviceStatusInfo
.
setType
(
1
);
// 信号机
List
<
TDeviceStatusInfo
>
tDeviceStatusInfos
=
allDeviceStatusMapper
.
selectByEntity
(
tDeviceStatusInfo
);
List
<
TDeviceStatusInfo
>
tDeviceStatusInfos
=
allDeviceStatusMapper
.
selectByEntity
(
tDeviceStatusInfo
);
// 获取utc库中路口信息表的信号机ip
List
<
CrossInfoOutVo
>
crossInfoOutVoList
=
getCrossInfoOutVoList
(
new
CrossInfoPageVO
());
List
<
CrossInfoOutVo
>
crossInfoOutVoList
=
getCrossInfoOutVoList
(
new
CrossInfoPageVO
());
List
<
SignalFaultInfoVO
>
signalFaultInfoVOS
=
new
ArrayList
<>(
tDeviceStatusInfos
.
size
());
List
<
SignalFaultInfoVO
>
signalFaultInfoVOS
=
new
ArrayList
<>(
tDeviceStatusInfos
.
size
());
...
@@ -634,8 +637,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
...
@@ -634,8 +637,7 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
public
List
<
SignalOperationModeVO
>
listSignalControlList
(
Integer
operationMode
)
{
public
List
<
SignalOperationModeVO
>
listSignalControlList
(
Integer
operationMode
)
{
List
<
SignalOperationModeVO
>
signalOperationModeVOS
=
new
ArrayList
<>();
List
<
SignalOperationModeVO
>
signalOperationModeVOS
=
new
ArrayList
<>();
List
<
TCrossControlHist
>
tCrossControlHists
=
controlHistMapper
.
selectRecentList
();
List
<
TCrossControlHist
>
tCrossControlHists
=
controlHistMapper
.
selectRecentList
();
LambdaQueryWrapper
<
TBaseCrossInfo
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
List
<
TBaseCrossInfo
>
tBaseCrossInfos
=
tBaseCrossInfoMapper
.
selectList
(
new
LambdaQueryWrapper
<>());
List
<
TBaseCrossInfo
>
tBaseCrossInfos
=
tBaseCrossInfoMapper
.
selectList
(
queryWrapper
);
if
(!
CollectionUtils
.
isEmpty
(
tCrossControlHists
))
{
if
(!
CollectionUtils
.
isEmpty
(
tCrossControlHists
))
{
if
(
Objects
.
nonNull
(
operationMode
))
{
if
(
Objects
.
nonNull
(
operationMode
))
{
if
(
operationMode
==
1
)
{
//中心优化
if
(
operationMode
==
1
)
{
//中心优化
...
@@ -713,7 +715,6 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
...
@@ -713,7 +715,6 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
@Override
@Override
public
List
<
SignalManufacturerCountInfoVO
>
signalManufacturerInfoCount
()
throws
Exception
{
public
List
<
SignalManufacturerCountInfoVO
>
signalManufacturerInfoCount
()
throws
Exception
{
List
<
SignalManufacturerCountInfoVO
>
resultList
=
new
ArrayList
<>();
List
<
ManufacturerInfoOutVO
>
manufacturerInfoOutVOList
=
getManufacturerInfoOutVOList
(
new
ManufacturerVO
());
List
<
ManufacturerInfoOutVO
>
manufacturerInfoOutVOList
=
getManufacturerInfoOutVOList
(
new
ManufacturerVO
());
List
<
CrossInfoOutVo
>
crossInfoOutVoList
=
getCrossInfoOutVoList
(
new
CrossInfoPageVO
());
List
<
CrossInfoOutVo
>
crossInfoOutVoList
=
getCrossInfoOutVoList
(
new
CrossInfoPageVO
());
...
@@ -721,6 +722,20 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
...
@@ -721,6 +722,20 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
// key:nickName value:List<crossId>
// key:nickName value:List<crossId>
Map
<
String
,
List
<
String
>>
nickNameCrossIdMap
=
getCrossIdNickNameMap
(
manufacturerInfoOutVOList
,
crossInfoOutVoList
);
Map
<
String
,
List
<
String
>>
nickNameCrossIdMap
=
getCrossIdNickNameMap
(
manufacturerInfoOutVOList
,
crossInfoOutVoList
);
List
<
TDeviceStatusInfo
>
tDeviceStatusInfos
=
allDeviceStatusMapper
.
selectByEntity
(
new
TDeviceStatusInfo
());
List
<
TDeviceStatusInfo
>
tDeviceStatusInfos
=
allDeviceStatusMapper
.
selectByEntity
(
new
TDeviceStatusInfo
());
List
<
SignalManufacturerCountInfoVO
>
resultList
=
getResultList
(
nickNameCrossIdMap
,
tDeviceStatusInfos
);
return
resultList
;
}
/**
* 统计不同厂商在线离线数量
*
* @param nickNameCrossIdMap
* @param tDeviceStatusInfos
* @return
*/
private
static
List
<
SignalManufacturerCountInfoVO
>
getResultList
(
Map
<
String
,
List
<
String
>>
nickNameCrossIdMap
,
List
<
TDeviceStatusInfo
>
tDeviceStatusInfos
)
{
List
<
SignalManufacturerCountInfoVO
>
resultList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
nickNameCrossIdMap
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
String
>>
entry
:
nickNameCrossIdMap
.
entrySet
())
{
SignalManufacturerCountInfoVO
signalManufacturerCountInfoVO
=
new
SignalManufacturerCountInfoVO
();
SignalManufacturerCountInfoVO
signalManufacturerCountInfoVO
=
new
SignalManufacturerCountInfoVO
();
String
nickName
=
entry
.
getKey
();
String
nickName
=
entry
.
getKey
();
...
@@ -749,10 +764,16 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
...
@@ -749,10 +764,16 @@ public class SituationDetectionServiceImpl implements SituationDetectionService
signalManufacturerCountInfoVO
.
setFaultCount
(
faultCount
);
signalManufacturerCountInfoVO
.
setFaultCount
(
faultCount
);
resultList
.
add
(
signalManufacturerCountInfoVO
);
resultList
.
add
(
signalManufacturerCountInfoVO
);
}
}
return
resultList
;
return
resultList
;
}
}
/**
* 统计当前路口归属厂商列表
*
* @param manufacturerInfoOutVOList
* @param crossInfoOutVoList
* @return
*/
private
Map
<
String
,
List
<
String
>>
getCrossIdNickNameMap
(
List
<
ManufacturerInfoOutVO
>
manufacturerInfoOutVOList
,
List
<
CrossInfoOutVo
>
crossInfoOutVoList
)
{
private
Map
<
String
,
List
<
String
>>
getCrossIdNickNameMap
(
List
<
ManufacturerInfoOutVO
>
manufacturerInfoOutVOList
,
List
<
CrossInfoOutVo
>
crossInfoOutVoList
)
{
Map
<
String
,
List
<
String
>>
crossIdNickNameMap
=
new
HashMap
<>();
Map
<
String
,
List
<
String
>>
crossIdNickNameMap
=
new
HashMap
<>();
for
(
ManufacturerInfoOutVO
manufacturerInfoOutVO
:
manufacturerInfoOutVOList
)
{
for
(
ManufacturerInfoOutVO
manufacturerInfoOutVO
:
manufacturerInfoOutVOList
)
{
...
...
signal-control-service/src/main/java/net/wanji/web/task/CommonEventWarnTask.java
View file @
be18693d
...
@@ -48,7 +48,7 @@ public class CommonEventWarnTask {
...
@@ -48,7 +48,7 @@ public class CommonEventWarnTask {
if
(!
CollectionUtils
.
isEmpty
(
events
))
{
if
(!
CollectionUtils
.
isEmpty
(
events
))
{
for
(
WebSocketServer
entry
:
events
)
{
for
(
WebSocketServer
entry
:
events
)
{
String
userId
=
entry
.
getUserId
();
String
userId
=
entry
.
getUserId
();
getCommonEnventWarnData
(
userId
);
commonEnventWarnDataSend
(
userId
);
}
}
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -56,7 +56,7 @@ public class CommonEventWarnTask {
...
@@ -56,7 +56,7 @@ public class CommonEventWarnTask {
}
}
}
}
private
void
getCommonEnventWarnData
(
String
userId
)
throws
IOException
{
private
void
commonEnventWarnDataSend
(
String
userId
)
throws
IOException
{
// 信号机故障
// 信号机故障
JsonViewObject
signalWarnData
=
getSignalWarnData
();
JsonViewObject
signalWarnData
=
getSignalWarnData
();
if
(
Objects
.
nonNull
(
signalWarnData
))
{
if
(
Objects
.
nonNull
(
signalWarnData
))
{
...
@@ -84,10 +84,10 @@ public class CommonEventWarnTask {
...
@@ -84,10 +84,10 @@ public class CommonEventWarnTask {
private
JsonViewObject
getSignalWarnData
()
{
private
JsonViewObject
getSignalWarnData
()
{
List
<
CommonEventAlarmOutVo
>
results
=
new
ArrayList
<>();
List
<
CommonEventAlarmOutVo
>
results
=
new
ArrayList
<>();
JsonViewObject
jsonViewObject
=
utcFeignClients
.
runningStatusAlarm
();
JsonViewObject
jsonViewObject
=
utcFeignClients
.
runningStatusAlarm
();
if
(
Objects
.
isNull
(
jsonViewObject
)
||
jsonViewObject
.
getCode
()
!=
200
)
{
if
(
Objects
.
isNull
(
jsonViewObject
)
||
jsonViewObject
.
getCode
()
!=
200
)
{
return
jsonViewObject
.
fail
(
"信号机告警UTC服务调用异常!"
);
return
jsonViewObject
.
fail
(
"信号机告警UTC服务调用异常!"
);
}
}
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
now
=
LocalDateTime
.
now
();
String
formatNow
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
now
);
String
formatNow
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
now
);
List
<
Map
<
String
,
Object
>>
content
=
(
List
<
Map
<
String
,
Object
>>)
jsonViewObject
.
getContent
();
List
<
Map
<
String
,
Object
>>
content
=
(
List
<
Map
<
String
,
Object
>>)
jsonViewObject
.
getContent
();
...
@@ -97,6 +97,7 @@ public class CommonEventWarnTask {
...
@@ -97,6 +97,7 @@ public class CommonEventWarnTask {
String
crossId
=
(
String
)
result
.
get
(
"crossId"
);
String
crossId
=
(
String
)
result
.
get
(
"crossId"
);
Integer
currentStatus
=
(
Integer
)
result
.
get
(
"status"
);
Integer
currentStatus
=
(
Integer
)
result
.
get
(
"status"
);
Integer
currentFaultType
=
(
Integer
)
result
.
get
(
"faultType"
);
Integer
currentFaultType
=
(
Integer
)
result
.
get
(
"faultType"
);
String
coordinate
=
""
;
String
coordinate
=
""
;
String
crossName
=
""
;
String
crossName
=
""
;
TDeviceStatusInfo
tDeviceStatusInfo1
=
new
TDeviceStatusInfo
();
TDeviceStatusInfo
tDeviceStatusInfo1
=
new
TDeviceStatusInfo
();
...
@@ -112,25 +113,8 @@ public class CommonEventWarnTask {
...
@@ -112,25 +113,8 @@ public class CommonEventWarnTask {
crossName
=
tDeviceStatusInfo
.
getName
();
crossName
=
tDeviceStatusInfo
.
getName
();
}
}
}
}
if
(
SignalStatusTask
.
isExucuteUpdate
(
currentStatus
,
currentFaultType
,
tDeviceStatusInfo1
))
{
CommonEventAlarmOutVo
commonEventAlarmOutVo
=
new
CommonEventAlarmOutVo
();
buildSignalWarnData
(
results
,
formatNow
,
signalId
,
currentStatus
,
currentFaultType
,
coordinate
,
crossName
,
tDeviceStatusInfo1
);
commonEventAlarmOutVo
.
setEventType
(
3
);
commonEventAlarmOutVo
.
setEventId
(
signalId
);
commonEventAlarmOutVo
.
setEventName
(
crossName
);
if
(
currentStatus
==
0
)
{
commonEventAlarmOutVo
.
setStatus
(
"11"
);
commonEventAlarmOutVo
.
setEventDesc
(
crossName
.
concat
(
"信号机离线"
));
}
else
if
(
currentStatus
==
1
){
commonEventAlarmOutVo
.
setStatus
(
String
.
valueOf
(
0
));
commonEventAlarmOutVo
.
setEventDesc
(
crossName
.
concat
(
"信号机上线"
));
}
else
{
commonEventAlarmOutVo
.
setStatus
(
String
.
valueOf
(
currentFaultType
));
commonEventAlarmOutVo
.
setEventDesc
(
crossName
.
concat
(
"信号机故障"
));
}
commonEventAlarmOutVo
.
setStartTime
(
formatNow
);
commonEventAlarmOutVo
.
setCoordinate
(
coordinate
);
results
.
add
(
commonEventAlarmOutVo
);
}
});
});
// 无告警数据
// 无告警数据
if
(
CollectionUtils
.
isEmpty
(
results
))
{
if
(
CollectionUtils
.
isEmpty
(
results
))
{
...
@@ -140,4 +124,38 @@ public class CommonEventWarnTask {
...
@@ -140,4 +124,38 @@ public class CommonEventWarnTask {
jsonViewObject
.
setContent
(
results
);
jsonViewObject
.
setContent
(
results
);
return
jsonViewObject
;
return
jsonViewObject
;
}
}
/**
* 构建信号机告警消息
*
* @param results
* @param formatNow
* @param signalId
* @param currentStatus
* @param currentFaultType
* @param coordinate
* @param crossName
* @param tDeviceStatusInfo1
*/
private
static
void
buildSignalWarnData
(
List
<
CommonEventAlarmOutVo
>
results
,
String
formatNow
,
String
signalId
,
Integer
currentStatus
,
Integer
currentFaultType
,
String
coordinate
,
String
crossName
,
TDeviceStatusInfo
tDeviceStatusInfo1
)
{
if
(
SignalStatusTask
.
isExucuteUpdate
(
currentStatus
,
currentFaultType
,
tDeviceStatusInfo1
))
{
CommonEventAlarmOutVo
commonEventAlarmOutVo
=
new
CommonEventAlarmOutVo
();
commonEventAlarmOutVo
.
setEventType
(
3
);
commonEventAlarmOutVo
.
setEventId
(
signalId
);
commonEventAlarmOutVo
.
setEventName
(
crossName
);
if
(
currentStatus
==
0
)
{
commonEventAlarmOutVo
.
setStatus
(
"11"
);
commonEventAlarmOutVo
.
setEventDesc
(
crossName
.
concat
(
"信号机离线"
));
}
else
if
(
currentStatus
==
1
){
commonEventAlarmOutVo
.
setStatus
(
String
.
valueOf
(
0
));
commonEventAlarmOutVo
.
setEventDesc
(
crossName
.
concat
(
"信号机上线"
));
}
else
{
commonEventAlarmOutVo
.
setStatus
(
String
.
valueOf
(
currentFaultType
));
commonEventAlarmOutVo
.
setEventDesc
(
crossName
.
concat
(
"信号机故障"
));
}
commonEventAlarmOutVo
.
setStartTime
(
formatNow
);
commonEventAlarmOutVo
.
setCoordinate
(
coordinate
);
results
.
add
(
commonEventAlarmOutVo
);
}
}
}
}
signal-control-service/src/main/java/net/wanji/web/task/SignalStatusTask.java
View file @
be18693d
...
@@ -47,9 +47,11 @@ public class SignalStatusTask {
...
@@ -47,9 +47,11 @@ public class SignalStatusTask {
log
.
error
(
"定时任务同步信号机设备状态utcService调用异常"
);
log
.
error
(
"定时任务同步信号机设备状态utcService调用异常"
);
return
;
return
;
}
}
// utc服务信号机状态列表
List
<
Map
<
String
,
Object
>>
source
=
(
List
<
Map
<
String
,
Object
>>)
jsonViewObject
.
getContent
();
List
<
Map
<
String
,
Object
>>
source
=
(
List
<
Map
<
String
,
Object
>>)
jsonViewObject
.
getContent
();
List
<
SignalStatusVO
>
content
=
BeanMapUtils
.
mapsToObjects
(
source
,
SignalStatusVO
.
class
);
List
<
SignalStatusVO
>
content
=
BeanMapUtils
.
mapsToObjects
(
source
,
SignalStatusVO
.
class
);
List
<
String
>
crossIdList
=
content
.
stream
().
map
(
SignalStatusVO:
:
getCrossId
).
collect
(
Collectors
.
toList
());
List
<
String
>
crossIdList
=
content
.
stream
().
map
(
SignalStatusVO:
:
getCrossId
).
collect
(
Collectors
.
toList
());
// 信号机状态信息
List
<
CrossInfoPO
>
crossInfoPOList
=
new
ArrayList
<>();
List
<
CrossInfoPO
>
crossInfoPOList
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
crossIdList
))
{
if
(!
CollectionUtils
.
isEmpty
(
crossIdList
))
{
crossInfoPOList
=
crossInfoMapper
.
selectByCrossIds
(
crossIdList
);
crossInfoPOList
=
crossInfoMapper
.
selectByCrossIds
(
crossIdList
);
...
@@ -57,13 +59,7 @@ public class SignalStatusTask {
...
@@ -57,13 +59,7 @@ public class SignalStatusTask {
List
<
CrossInfoPO
>
finalCrossInfoPOList
=
crossInfoPOList
;
List
<
CrossInfoPO
>
finalCrossInfoPOList
=
crossInfoPOList
;
content
.
forEach
(
signalStatusVO
->
{
content
.
forEach
(
signalStatusVO
->
{
String
crossId
=
signalStatusVO
.
getCrossId
();
String
crossId
=
signalStatusVO
.
getCrossId
();
String
name
=
null
;
String
name
=
getSignalName
(
finalCrossInfoPOList
,
crossId
);
for
(
CrossInfoPO
crossInfoPO
:
finalCrossInfoPOList
)
{
if
(
StringUtils
.
equals
(
crossId
,
crossInfoPO
.
getId
()))
{
name
=
crossInfoPO
.
getName
();
break
;
}
}
Integer
currentSignalStatus
=
signalStatusVO
.
getStatus
()
==
null
?
0
:
signalStatusVO
.
getStatus
();
Integer
currentSignalStatus
=
signalStatusVO
.
getStatus
()
==
null
?
0
:
signalStatusVO
.
getStatus
();
Integer
currentFaultType
=
signalStatusVO
.
getFaultType
()
==
null
?
0
:
signalStatusVO
.
getFaultType
();
Integer
currentFaultType
=
signalStatusVO
.
getFaultType
()
==
null
?
0
:
signalStatusVO
.
getFaultType
();
// 信号机在线,但是故障,数据库状态为2
// 信号机在线,但是故障,数据库状态为2
...
@@ -72,30 +68,7 @@ public class SignalStatusTask {
...
@@ -72,30 +68,7 @@ public class SignalStatusTask {
}
}
// 更新数据库状态
// 更新数据库状态
LambdaQueryWrapper
<
TDeviceStatusInfo
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
updateSignalStatus
(
signalStatusVO
,
crossId
,
name
,
currentSignalStatus
,
currentFaultType
);
if
(
StringUtils
.
isNotEmpty
(
crossId
))
{
lambdaQueryWrapper
.
eq
(
TDeviceStatusInfo:
:
getCode
,
crossId
);
TDeviceStatusInfo
tDeviceStatusInfo
=
tDeviceStatusMapper
.
selectOne
(
lambdaQueryWrapper
);
if
(
Objects
.
nonNull
(
tDeviceStatusInfo
))
{
if
(
isExucuteUpdate
(
currentSignalStatus
,
currentFaultType
,
tDeviceStatusInfo
))
{
tDeviceStatusInfo
.
setStatus
(
currentSignalStatus
);
tDeviceStatusInfo
.
setFaultType
(
currentFaultType
);
tDeviceStatusInfo
.
setGmtCreate
(
new
Date
());
// 实时数据,创建和修改时间一致
tDeviceStatusMapper
.
updateById
(
tDeviceStatusInfo
);
insertDeviceStatusLog
(
signalStatusVO
,
crossId
,
currentSignalStatus
,
currentFaultType
,
name
);
}
}
else
{
TDeviceStatusInfo
deviceStatusInfo
=
new
TDeviceStatusInfo
();
deviceStatusInfo
.
setCode
(
crossId
);
deviceStatusInfo
.
setName
(
name
);
deviceStatusInfo
.
setType
(
1
);
deviceStatusInfo
.
setFaultType
(
currentFaultType
);
deviceStatusInfo
.
setStatus
(
currentSignalStatus
);
deviceStatusInfo
.
setGmtCreate
(
new
Date
());
deviceStatusInfo
.
setId
(
null
);
tDeviceStatusMapper
.
insert
(
deviceStatusInfo
);
}
}
insertControlHist
(
signalStatusVO
);
insertControlHist
(
signalStatusVO
);
});
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -103,6 +76,53 @@ public class SignalStatusTask {
...
@@ -103,6 +76,53 @@ public class SignalStatusTask {
}
}
}
}
private
static
String
getSignalName
(
List
<
CrossInfoPO
>
finalCrossInfoPOList
,
String
crossId
)
{
String
name
=
null
;
for
(
CrossInfoPO
crossInfoPO
:
finalCrossInfoPOList
)
{
if
(
StringUtils
.
equals
(
crossId
,
crossInfoPO
.
getId
()))
{
name
=
crossInfoPO
.
getName
();
break
;
}
}
return
name
;
}
/**
* 更新信号机状态
*
* @param signalStatusVO
* @param crossId
* @param name
* @param currentSignalStatus
* @param currentFaultType
*/
private
void
updateSignalStatus
(
SignalStatusVO
signalStatusVO
,
String
crossId
,
String
name
,
Integer
currentSignalStatus
,
Integer
currentFaultType
)
{
LambdaQueryWrapper
<
TDeviceStatusInfo
>
lambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
if
(
StringUtils
.
isNotEmpty
(
crossId
))
{
lambdaQueryWrapper
.
eq
(
TDeviceStatusInfo:
:
getCode
,
crossId
);
TDeviceStatusInfo
tDeviceStatusInfo
=
tDeviceStatusMapper
.
selectOne
(
lambdaQueryWrapper
);
if
(
Objects
.
nonNull
(
tDeviceStatusInfo
))
{
if
(
isExucuteUpdate
(
currentSignalStatus
,
currentFaultType
,
tDeviceStatusInfo
))
{
tDeviceStatusInfo
.
setStatus
(
currentSignalStatus
);
tDeviceStatusInfo
.
setFaultType
(
currentFaultType
);
tDeviceStatusInfo
.
setGmtCreate
(
new
Date
());
// 实时数据,创建和修改时间一致
tDeviceStatusMapper
.
updateById
(
tDeviceStatusInfo
);
insertDeviceStatusLog
(
signalStatusVO
,
crossId
,
currentSignalStatus
,
currentFaultType
,
name
);
}
}
else
{
TDeviceStatusInfo
deviceStatusInfo
=
new
TDeviceStatusInfo
();
deviceStatusInfo
.
setCode
(
crossId
);
deviceStatusInfo
.
setName
(
name
);
deviceStatusInfo
.
setType
(
1
);
deviceStatusInfo
.
setFaultType
(
currentFaultType
);
deviceStatusInfo
.
setStatus
(
currentSignalStatus
);
deviceStatusInfo
.
setGmtCreate
(
new
Date
());
deviceStatusInfo
.
setId
(
null
);
tDeviceStatusMapper
.
insert
(
deviceStatusInfo
);
}
}
}
/**
/**
* 插入控制历史表
* 插入控制历史表
*
*
...
...
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