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
jinan
traffic-signal-platform
Commits
8d0eb7b8
Commit
8d0eb7b8
authored
Oct 07, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 优化海信灯态代码结构
parent
8ebc081a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
29 deletions
+43
-29
SignalStatusServiceImpl.java
...nji/utc/hisense/service/impl/SignalStatusServiceImpl.java
+35
-25
HisensePhaseCountDownTask.java
...net/wanji/utc/hisense/task/HisensePhaseCountDownTask.java
+8
-4
No files found.
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/service/impl/SignalStatusServiceImpl.java
View file @
8d0eb7b8
...
...
@@ -173,29 +173,7 @@ public class SignalStatusServiceImpl implements SignalStatusService {
lightsStatusVO
.
setPhasePlanId
(
String
.
valueOf
(
planId
));
List
<
CrossSchemePhaseCountDownDTO
>
crossSchemePhaseCountDownList
=
CrossSchemePhaseTimeCountCache
.
crossSchemePhaseCountDownList
;
if
(!
CollectionUtils
.
isEmpty
(
crossSchemePhaseCountDownList
))
{
for
(
CrossSchemePhaseCountDownDTO
dto
:
crossSchemePhaseCountDownList
)
{
String
crossIdCache
=
dto
.
getCrossId
();
String
schemeNoCache
=
dto
.
getSchemeNo
();
if
(
StringUtils
.
equalsIgnoreCase
(
crossIdCache
,
crossId
)
&&
StringUtils
.
equalsIgnoreCase
(
schemeNoCache
,
String
.
valueOf
(
planId
)))
{
List
<
PhaseCountDownDTO
>
phaseCountDownDTOList
=
dto
.
getPhaseCountDownDTOList
();
int
lastPhaseCountTime
=
0
;
int
phaseTimeCountDown
=
0
;
String
phaseNo
=
null
;
for
(
PhaseCountDownDTO
phaseCountDownDTO
:
phaseCountDownDTOList
)
{
phaseNo
=
phaseCountDownDTO
.
getPhaseNo
();
Integer
changePhaseTime
=
phaseCountDownDTO
.
getChangePhaseTime
();
if
(
lastPhaseCountTime
<=
runTime
&&
runTime
<
changePhaseTime
)
{
phaseTimeCountDown
=
changePhaseTime
-
runTime
;
break
;
}
lastPhaseCountTime
=
changePhaseTime
;
}
lightsStatusVO
.
setPhaseId
(
phaseNo
);
lightsStatusVO
.
setCyclePhaseCountDown
(
phaseTimeCountDown
);
}
}
}
setLightsStatusVOPhaseNoAndCountDown
(
lightsStatusVO
,
crossId
,
runTime
,
planId
,
crossSchemePhaseCountDownList
);
SignalDataCache
.
runningStateInfoCache
.
put
(
crossId
,
lightsStatusVO
);
}
}
...
...
@@ -203,6 +181,40 @@ public class SignalStatusServiceImpl implements SignalStatusService {
}
}
/**
* 通过周期倒计时判断当前相位号,相位倒计时时间
* @param lightsStatusVO
* @param crossId
* @param runTime
* @param planId
* @param crossSchemePhaseCountDownList
*/
private
static
void
setLightsStatusVOPhaseNoAndCountDown
(
LightsStatusVO
lightsStatusVO
,
String
crossId
,
int
runTime
,
int
planId
,
List
<
CrossSchemePhaseCountDownDTO
>
crossSchemePhaseCountDownList
)
{
if
(!
CollectionUtils
.
isEmpty
(
crossSchemePhaseCountDownList
))
{
for
(
CrossSchemePhaseCountDownDTO
dto
:
crossSchemePhaseCountDownList
)
{
String
crossIdCache
=
dto
.
getCrossId
();
String
schemeNoCache
=
dto
.
getSchemeNo
();
if
(
StringUtils
.
equalsIgnoreCase
(
crossIdCache
,
crossId
)
&&
StringUtils
.
equalsIgnoreCase
(
schemeNoCache
,
String
.
valueOf
(
planId
)))
{
List
<
PhaseCountDownDTO
>
phaseCountDownDTOList
=
dto
.
getPhaseCountDownDTOList
();
int
lastPhaseCountTime
=
0
;
int
phaseTimeCountDown
=
0
;
String
phaseNo
=
null
;
for
(
PhaseCountDownDTO
phaseCountDownDTO
:
phaseCountDownDTOList
)
{
phaseNo
=
phaseCountDownDTO
.
getPhaseNo
();
Integer
changePhaseTime
=
phaseCountDownDTO
.
getChangePhaseTime
();
if
(
lastPhaseCountTime
<=
runTime
&&
runTime
<
changePhaseTime
)
{
phaseTimeCountDown
=
changePhaseTime
-
runTime
;
break
;
}
lastPhaseCountTime
=
changePhaseTime
;
}
lightsStatusVO
.
setPhaseId
(
phaseNo
);
lightsStatusVO
.
setCyclePhaseCountDown
(
phaseTimeCountDown
);
}
}
}
}
/**
* @description 通过方向转向获取路口方案的相位号
*/
...
...
@@ -229,9 +241,7 @@ public class SignalStatusServiceImpl implements SignalStatusService {
}
}
}
log
.
error
(
"当前路口:{},方案号:{},相位号:{}"
,
crossId
,
planId
,
phaseNo
);
return
phaseNo
;
}
}
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/task/HisensePhaseCountDownTask.java
View file @
8d0eb7b8
...
...
@@ -54,7 +54,7 @@ public class HisensePhaseCountDownTask {
String
currentTime
=
String
.
valueOf
(
new
Date
().
getTime
());
if
(
StringUtils
.
equalsIgnoreCase
(
schemeStartTime
,
currentTime
))
{
crossSchemePO
=
crossSchemeMapper
.
selectByCrossIdAndSchemeNo
(
crossId
,
Integer
.
valueOf
(
nextSectionSchemeNo
));
executeNextSectionScheme
(
crossId
,
lightsStatusVO
,
"1"
,
crossSchemePO
);
executeNextSectionScheme
(
crossId
,
lightsStatusVO
,
crossSchemePO
);
lightsStatusVO
.
setCycleLen
(
crossSchemePO
.
getCycle
());
}
else
{
executeNextPeriod
(
crossId
,
lightsStatusVO
,
phaseId
,
crossSchemePO
);
...
...
@@ -71,17 +71,18 @@ public class HisensePhaseCountDownTask {
* @description 通过日计划缓存,切换下一个时段方案
* @param crossId
* @param lightsStatusVO
* @param phaseId
* @param crossSchemePO
*/
private
void
executeNextSectionScheme
(
String
crossId
,
LightsStatusVO
lightsStatusVO
,
String
phaseId
,
CrossSchemePO
crossSchemePO
)
{
private
void
executeNextSectionScheme
(
String
crossId
,
LightsStatusVO
lightsStatusVO
,
CrossSchemePO
crossSchemePO
)
{
if
(
Objects
.
nonNull
(
crossSchemePO
))
{
List
<
CrossPhasePO
>
nextSchemePhaseList
=
crossPhaseMapper
.
selectByCrossIdAndPlanId
(
crossId
,
String
.
valueOf
(
crossSchemePO
.
getId
()));
Integer
phaseTime
=
0
;
String
phaseId
=
null
;
if
(!
CollectionUtils
.
isEmpty
(
nextSchemePhaseList
))
{
for
(
CrossPhasePO
crossPhasePO
:
nextSchemePhaseList
)
{
if
(
StringUtils
.
equalsIgnoreCase
(
phaseId
,
crossPhasePO
.
getPhaseNo
()))
{
if
(
Objects
.
equals
(
1
,
crossPhasePO
.
getSort
()))
{
phaseTime
=
crossPhasePO
.
getPhaseTime
();
phaseId
=
crossPhasePO
.
getPhaseNo
();
}
}
}
...
...
@@ -139,6 +140,9 @@ public class HisensePhaseCountDownTask {
String
phaseNo
=
String
.
valueOf
(
phaseDirTurnPojo
.
getPhaseNo
());
if
(
StringUtils
.
equalsIgnoreCase
(
schemeNo
,
currentSchemeNo
)
&&
StringUtils
.
equalsIgnoreCase
(
currentPhaseNo
,
String
.
valueOf
(
phaseNo
)))
{
PhaseCountDownDTO
phaseCountDownDTO
=
getPhaseCountDownDTO
(
crossId
,
schemeNo
,
phaseNo
);
if
(
Objects
.
isNull
(
phaseCountDownDTO
))
{
continue
;
}
Integer
yellowTime
=
phaseCountDownDTO
.
getYellowTime
();
Integer
redTime
=
phaseCountDownDTO
.
getRedTime
();
Map
<
Integer
,
List
<
CrossLightsPO
>>
dirTurnMap
=
phaseDirTurnPojo
.
getDirTurnMap
();
...
...
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