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
8de91809
Commit
8de91809
authored
Sep 13, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 海信灯态优化
parent
35a6f847
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
123 additions
and
19 deletions
+123
-19
CrossPhaseDirTurnCache.java
...a/net/wanji/utc/hisense/cache/CrossPhaseDirTurnCache.java
+3
-1
CrossLisghtsLaneDirEnum.java
...nji/utc/hisense/common/enums/CrossLisghtsLaneDirEnum.java
+73
-0
DataBrainTurnEnum.java
...net/wanji/utc/hisense/common/enums/DataBrainTurnEnum.java
+1
-1
SignalStatusServiceImpl.java
...nji/utc/hisense/service/impl/SignalStatusServiceImpl.java
+46
-17
No files found.
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/cache/CrossPhaseDirTurnCache.java
View file @
8de91809
...
@@ -66,6 +66,8 @@ public class CrossPhaseDirTurnCache implements CommandLineRunner {
...
@@ -66,6 +66,8 @@ public class CrossPhaseDirTurnCache implements CommandLineRunner {
String
schemeNo
=
schemeIdNoMap
.
get
(
planId
);
String
schemeNo
=
schemeIdNoMap
.
get
(
planId
);
if
(
StringUtils
.
isNotBlank
(
schemeNo
))
{
if
(
StringUtils
.
isNotBlank
(
schemeNo
))
{
crossPhaseDirTurnPojo
.
setSchemeNo
(
Integer
.
valueOf
(
schemeNo
));
crossPhaseDirTurnPojo
.
setSchemeNo
(
Integer
.
valueOf
(
schemeNo
));
}
else
{
crossPhaseDirTurnPojo
.
setSchemeNo
(-
1
);
}
}
Integer
phaseId
=
crossPhasePO
.
getId
();
Integer
phaseId
=
crossPhasePO
.
getId
();
...
@@ -79,7 +81,7 @@ public class CrossPhaseDirTurnCache implements CommandLineRunner {
...
@@ -79,7 +81,7 @@ public class CrossPhaseDirTurnCache implements CommandLineRunner {
Map
<
Integer
,
List
<
Integer
>>
dirTurnMap
=
new
HashMap
<>();
Map
<
Integer
,
List
<
Integer
>>
dirTurnMap
=
new
HashMap
<>();
for
(
Map
.
Entry
<
Integer
,
List
<
CrossLightsPO
>>
entry
:
phaseDirMap
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
List
<
CrossLightsPO
>>
entry
:
phaseDirMap
.
entrySet
())
{
Integer
dir
=
entry
.
getKey
();
Integer
dir
=
entry
.
getKey
();
List
<
Integer
>
turnList
=
entry
.
getValue
().
stream
().
map
(
CrossLightsPO:
:
getTurn
).
collect
(
Collectors
.
toList
());
List
<
Integer
>
turnList
=
entry
.
getValue
().
stream
().
map
(
CrossLightsPO:
:
getTurn
).
sorted
().
collect
(
Collectors
.
toList
());
dirTurnMap
.
put
(
dir
,
turnList
);
dirTurnMap
.
put
(
dir
,
turnList
);
crossPhaseDirTurnPojo
.
setDirTurnMap
(
dirTurnMap
);
crossPhaseDirTurnPojo
.
setDirTurnMap
(
dirTurnMap
);
}
}
...
...
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/common/enums/CrossLisghtsLaneDirEnum.java
0 → 100644
View file @
8de91809
package
net
.
wanji
.
utc
.
hisense
.
common
.
enums
;
import
java.util.Objects
;
/**
* @author duanruiming
* @date 2023/03/29 17:47
*/
public
enum
CrossLisghtsLaneDirEnum
{
ONE
(
1
,
5
,
"北"
),
TWO
(
2
,
6
,
"东北"
),
THREE
(
3
,
7
,
"东"
),
FOUR
(
4
,
8
,
"东南"
),
FIVE
(
5
,
1
,
"南"
),
SIX
(
6
,
2
,
"西南"
),
SEVEN
(
7
,
3
,
"西"
),
EIGHT
(
8
,
4
,
"西北"
);
private
final
int
lightDir
;
private
final
int
laneDir
;
private
final
String
msg
;
/**
* 通过灯组方向获取车道方向
*
* @param lightDir
* @return
*/
public
static
Integer
getLaneDirByLightsDir
(
Integer
lightDir
)
{
CrossLisghtsLaneDirEnum
[]
values
=
CrossLisghtsLaneDirEnum
.
values
();
for
(
CrossLisghtsLaneDirEnum
value
:
values
)
{
if
(
Objects
.
equals
(
value
.
getLightDir
(),
lightDir
))
{
return
value
.
getLaneDir
();
}
}
return
null
;
}
/**
* 通过车道方向获取灯组方向
*
* @param laneDir
* @return
*/
public
static
Integer
getLightsDirByLaneDir
(
Integer
laneDir
)
{
CrossLisghtsLaneDirEnum
[]
values
=
CrossLisghtsLaneDirEnum
.
values
();
for
(
CrossLisghtsLaneDirEnum
value
:
values
)
{
if
(
Objects
.
equals
(
value
.
getLaneDir
(),
laneDir
))
{
return
value
.
getLightDir
();
}
}
return
null
;
}
CrossLisghtsLaneDirEnum
(
int
lightDir
,
int
laneDir
,
String
msg
)
{
this
.
lightDir
=
lightDir
;
this
.
laneDir
=
laneDir
;
this
.
msg
=
msg
;
}
public
int
getLightDir
()
{
return
lightDir
;
}
public
int
getLaneDir
()
{
return
laneDir
;
}
public
String
getMsg
()
{
return
msg
;
}
}
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/common/enums/DataBrainTurnEnum.java
View file @
8de91809
...
@@ -18,7 +18,7 @@ public enum DataBrainTurnEnum {
...
@@ -18,7 +18,7 @@ public enum DataBrainTurnEnum {
RIGHT
(
13
,
2
),
//右转
RIGHT
(
13
,
2
),
//右转
STRAIGHT
(
11
,
3
),
// 直行
STRAIGHT
(
11
,
3
),
// 直行
TURN
(
31
,
4
),
TURN
(
31
,
4
),
OTHER
(
99
,
99
);
OTHER
(
99
,
20
);
//行人
private
Integer
hisenseTurn
;
private
Integer
hisenseTurn
;
private
Integer
wjTurn
;
private
Integer
wjTurn
;
...
...
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/service/impl/SignalStatusServiceImpl.java
View file @
8de91809
...
@@ -8,11 +8,10 @@ import net.wanji.databus.po.CrossInfoPO;
...
@@ -8,11 +8,10 @@ import net.wanji.databus.po.CrossInfoPO;
import
net.wanji.databus.po.SignalStatusLogPO
;
import
net.wanji.databus.po.SignalStatusLogPO
;
import
net.wanji.databus.vo.LightsStatusVO
;
import
net.wanji.databus.vo.LightsStatusVO
;
import
net.wanji.utc.hisense.cache.CrossInfoCache
;
import
net.wanji.utc.hisense.cache.CrossInfoCache
;
import
net.wanji.utc.hisense.cache.CrossPhaseDirTurnCache
;
import
net.wanji.utc.hisense.cache.SignalDataCache
;
import
net.wanji.utc.hisense.cache.SignalDataCache
;
import
net.wanji.utc.hisense.common.enums.DataBrainControlModeEnum
;
import
net.wanji.utc.hisense.common.enums.*
;
import
net.wanji.utc.hisense.common.enums.DataBrainDirEnum
;
import
net.wanji.utc.hisense.pojo.CrossPhaseDirTurnPojo
;
import
net.wanji.utc.hisense.common.enums.DataBrainLampStatusEnum
;
import
net.wanji.utc.hisense.common.enums.DataBrainTurnEnum
;
import
net.wanji.utc.hisense.pojo.convert.HisenseLightStatusPojo
;
import
net.wanji.utc.hisense.pojo.convert.HisenseLightStatusPojo
;
import
net.wanji.utc.hisense.service.SignalStatusService
;
import
net.wanji.utc.hisense.service.SignalStatusService
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
...
@@ -81,9 +80,6 @@ public class SignalStatusServiceImpl implements SignalStatusService {
...
@@ -81,9 +80,6 @@ public class SignalStatusServiceImpl implements SignalStatusService {
int
period
=
content
.
getPeriod
();
int
period
=
content
.
getPeriod
();
int
planId
=
content
.
getPlanId
();
int
planId
=
content
.
getPlanId
();
Long
signalMachineStamp
=
content
.
getSignalMachineStamp
();
Long
signalMachineStamp
=
content
.
getSignalMachineStamp
();
if
(
StringUtils
.
equals
(
crossId
,
"13NF80B5QN0"
))
{
log
.
error
(
"当前路口编号:{}, 周期倒计时:{},周期时间:{}"
,
crossId
,
cycleCountDown
,
period
);
}
lightsStatusVO
.
setCrossId
(
crossId
);
lightsStatusVO
.
setCrossId
(
crossId
);
lightsStatusVO
.
setSchemeId
(
String
.
valueOf
(
planId
));
lightsStatusVO
.
setSchemeId
(
String
.
valueOf
(
planId
));
String
runMode
=
String
.
valueOf
(
DataBrainControlModeEnum
.
getWjControlMode
(
hiControlMode
));
String
runMode
=
String
.
valueOf
(
DataBrainControlModeEnum
.
getWjControlMode
(
hiControlMode
));
...
@@ -91,9 +87,6 @@ public class SignalStatusServiceImpl implements SignalStatusService {
...
@@ -91,9 +87,6 @@ public class SignalStatusServiceImpl implements SignalStatusService {
lightsStatusVO
.
setCycleCountDown
(
cycleCountDown
);
lightsStatusVO
.
setCycleCountDown
(
cycleCountDown
);
lightsStatusVO
.
setCycleLen
(
period
);
lightsStatusVO
.
setCycleLen
(
period
);
lightsStatusVO
.
setSchemeStartTime
(
String
.
valueOf
(
signalMachineStamp
));
lightsStatusVO
.
setSchemeStartTime
(
String
.
valueOf
(
signalMachineStamp
));
// 保证不为空值
lightsStatusVO
.
setPhaseMap
(
Collections
.
emptyMap
());
lightsStatusVO
.
setPhaseMap
(
Collections
.
emptyMap
());
lightsStatusVO
.
setControlMode
(
runMode
);
lightsStatusVO
.
setControlMode
(
runMode
);
lightsStatusVO
.
setCode
(
hiCrossId
);
lightsStatusVO
.
setCode
(
hiCrossId
);
...
@@ -104,25 +97,33 @@ public class SignalStatusServiceImpl implements SignalStatusService {
...
@@ -104,25 +97,33 @@ public class SignalStatusServiceImpl implements SignalStatusService {
if
(!
CollectionUtils
.
isEmpty
(
lampRealInfos
))
{
if
(!
CollectionUtils
.
isEmpty
(
lampRealInfos
))
{
Map
<
Integer
,
List
<
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
>>
dirLampMap
=
lampRealInfos
.
stream
().
collect
(
Collectors
.
groupingBy
(
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
::
getRoadDirection
));
Map
<
Integer
,
List
<
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
>>
dirLampMap
=
lampRealInfos
.
stream
().
collect
(
Collectors
.
groupingBy
(
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
::
getRoadDirection
));
Map
<
String
,
Object
>
dirMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
dirMap
=
new
HashMap
<>();
Map
<
Integer
,
List
<
Integer
>>
dirTurnMap
=
new
HashMap
<>();
for
(
Map
.
Entry
<
Integer
,
List
<
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
>>
dirEntry
:
dirLampMap
.
entrySet
())
{
for
(
Map
.
Entry
<
Integer
,
List
<
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
>>
dirEntry
:
dirLampMap
.
entrySet
())
{
Integer
roadDirection
=
dirEntry
.
getKey
(
);
Integer
roadDirection
=
DataBrainDirEnum
.
getWjLightsDir
(
dirEntry
.
getKey
()
);
List
<
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
>
dirLampList
=
dirEntry
.
getValue
();
List
<
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
>
dirLampList
=
dirEntry
.
getValue
();
Map
<
String
,
String
>
turnMap
=
new
HashMap
<>();
Map
<
String
,
String
>
turnMap
=
new
HashMap
<>();
List
<
Integer
>
hisTurnList
=
new
ArrayList
<>();
for
(
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
lampRealInfo
:
dirLampList
)
{
for
(
HisenseLightStatusPojo
.
ContentBody
.
LampRealInfos
lampRealInfo
:
dirLampList
)
{
String
lampStatus
=
lampRealInfo
.
getLampStatus
();
String
lampStatus
=
lampRealInfo
.
getLampStatus
();
Integer
countDown
=
lampRealInfo
.
getCountDown
();
Integer
countDown
=
lampRealInfo
.
getCountDown
();
Integer
roadFlowDirection
=
lampRealInfo
.
getRoadFlowDirection
();
Integer
roadFlowDirection
=
lampRealInfo
.
getRoadFlowDirection
();
if
(
roadFlowDirection
==
99
)
{
Integer
wjTurn
=
DataBrainTurnEnum
.
getWjTurn
(
roadFlowDirection
);
continue
;
}
if
(
StringUtils
.
endsWithIgnoreCase
(
lampStatus
,
"23"
))
{
if
(
StringUtils
.
endsWithIgnoreCase
(
lampStatus
,
"23"
))
{
lightsStatusVO
.
setPhaseId
(
"0"
);
lightsStatusVO
.
setCyclePhaseCountDown
(
countDown
);
lightsStatusVO
.
setCyclePhaseCountDown
(
countDown
);
hisTurnList
.
add
(
wjTurn
);
}
}
turnMap
.
put
(
String
.
valueOf
(
DataBrainTurnEnum
.
getWjTurn
(
roadFlowDirection
)),
DataBrainLampStatusEnum
.
getWjLampStatus
(
lampStatus
));
turnMap
.
put
(
String
.
valueOf
(
wjTurn
),
DataBrainLampStatusEnum
.
getWjLampStatus
(
lampStatus
));
}
dirMap
.
put
(
String
.
valueOf
(
roadDirection
),
turnMap
);
// 获取当前绿灯方向转向
if
(!
CollectionUtils
.
isEmpty
(
hisTurnList
))
{
dirTurnMap
.
put
(
roadDirection
,
hisTurnList
);
}
}
dirMap
.
put
(
String
.
valueOf
(
DataBrainDirEnum
.
getWjLightsDir
(
roadDirection
)),
turnMap
);
}
}
// 通过路口编号获取当前相位缓存
Integer
currentPhaseNo
=
getCurrentPhagetseNo
(
crossId
,
planId
,
dirTurnMap
);
lightsStatusVO
.
setPhaseId
(
String
.
valueOf
(
currentPhaseNo
));
lightsStatusVO
.
setDirLampGroupMap
(
dirMap
);
lightsStatusVO
.
setDirLampGroupMap
(
dirMap
);
crossPriority
.
offer
(
lightsStatusVO
);
crossPriority
.
offer
(
lightsStatusVO
);
if
(
crossPriority
.
size
()
>
100
)
{
if
(
crossPriority
.
size
()
>
100
)
{
...
@@ -135,5 +136,33 @@ public class SignalStatusServiceImpl implements SignalStatusService {
...
@@ -135,5 +136,33 @@ public class SignalStatusServiceImpl implements SignalStatusService {
}
}
}
}
/**
* @description 通过方向转向获取路口方案的相位号
*/
private
static
Integer
getCurrentPhagetseNo
(
String
crossId
,
int
planId
,
Map
<
Integer
,
List
<
Integer
>>
hisDirTurnMap
)
{
Integer
phaseNo
=
null
;
List
<
CrossPhaseDirTurnPojo
>
crossPhaseDirTurnList
=
CrossPhaseDirTurnCache
.
getCrossPhaseDirTurnCache
(
crossId
);
if
(!
CollectionUtils
.
isEmpty
(
crossPhaseDirTurnList
))
{
List
<
CrossPhaseDirTurnPojo
>
schemeNoList
=
crossPhaseDirTurnList
.
stream
().
filter
(
po
->
Objects
.
equals
(
po
.
getSchemeNo
(),
planId
)).
collect
(
Collectors
.
toList
());
for
(
CrossPhaseDirTurnPojo
crossPhaseDirTurnPojo
:
schemeNoList
)
{
Map
<
Integer
,
List
<
Integer
>>
dirTurnCache
=
crossPhaseDirTurnPojo
.
getDirTurnMap
();
for
(
Map
.
Entry
<
Integer
,
List
<
Integer
>>
dirTurnCacheEntry
:
dirTurnCache
.
entrySet
())
{
Integer
dirCache
=
dirTurnCacheEntry
.
getKey
();
for
(
Map
.
Entry
<
Integer
,
List
<
Integer
>>
hisEntry
:
hisDirTurnMap
.
entrySet
())
{
Integer
hisDir
=
hisEntry
.
getKey
();
if
(
Objects
.
equals
(
dirCache
,
CrossLisghtsLaneDirEnum
.
getLightsDirByLaneDir
(
hisDir
)))
{
List
<
Integer
>
turnListCache
=
dirTurnCacheEntry
.
getValue
();
if
(
hisEntry
.
getValue
().
stream
().
allMatch
(
turnListCache:
:
contains
))
{
phaseNo
=
crossPhaseDirTurnPojo
.
getPhaseNo
();
}
}
}
}
}
}
log
.
error
(
"当前路口:{},方案号:{},相位号:{}"
,
crossId
,
planId
,
phaseNo
);
return
phaseNo
;
}
}
}
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