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
bf0a2bf1
Commit
bf0a2bf1
authored
Aug 18, 2023
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 添加红灯倒计时
parent
728c8b9b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
11 deletions
+33
-11
DTSignalStatusServiceImpl.java
.../wanji/utc/dt/service/impl/DTSignalStatusServiceImpl.java
+17
-1
RealTimeTask.java
...ice/src/main/java/net/wanji/utc/dt/task/RealTimeTask.java
+16
-3
SignalStatusTask.java
...ce/src/main/java/net/wanji/utc/task/SignalStatusTask.java
+0
-7
No files found.
signal-utc-dt-service/src/main/java/net/wanji/utc/dt/service/impl/DTSignalStatusServiceImpl.java
View file @
bf0a2bf1
...
...
@@ -135,10 +135,13 @@ public class DTSignalStatusServiceImpl implements SignalStatusService {
List
<
String
>
lightsStatus
=
SignalDataCache
.
realTimeLightCache
.
get
(
crossId
);
List
<
PhaseStageStatusPojo
>
phaseStageStatusPojos
=
SignalDataCache
.
realTimePhaseStatusStageCache
.
get
(
crossId
);
List
<
RunningStatusPojo
>
runningStatusPojos
=
SignalDataCache
.
realTimeRunStatusCache
.
get
(
crossId
);
if
(
CollectionUtils
.
isEmpty
(
lightsStatus
)
||
CollectionUtils
.
isEmpty
(
phaseStageStatusPojos
)
||
CollectionUtils
.
isEmpty
(
runningStatusPojos
))
{
throw
new
Exception
(
"获取东土信号机实时数据为空"
);
}
return
getLightsStatusVOs
(
crossId
,
lightsStatus
,
phaseStageStatusPojos
,
runningStatusPojos
);
}
public
static
List
<
PhaseStageStatusPojo
>
getPhaseStageStatus
(
String
crossId
)
throws
Exception
{
public
static
List
<
PhaseStageStatusPojo
>
getPhaseStageStatus
(
String
crossId
)
throws
Exception
{
List
<
PhaseStageStatusPojo
>
phaseStageStatusPojos
=
new
ArrayList
<>();
CrossInfoPO
crossInfoPO
=
DTControlCommandServiceImpl
.
checkCrossId
(
crossId
);
String
message
=
String
.
format
(
Constants
.
COMMAND_COMMON
,
Constants
.
COMMAND_QUERY
,
Constants
.
COMMAND_PHASE_STAGE_STATUS
);
...
...
@@ -179,6 +182,7 @@ public class DTSignalStatusServiceImpl implements SignalStatusService {
for
(
int
j
=
0
;
j
<
runningStatusPojos
.
size
();
j
++)
{
RunningStatusPojo
runningStatusPojo
=
runningStatusPojos
.
get
(
j
);
LightsStatusVO
lightsStatusVO
=
new
LightsStatusVO
();
Map
<
String
,
Object
>
phaseMap
=
new
HashMap
<>();
String
controlModel
=
String
.
valueOf
(
ControlModelEnum
.
getWjControlMode
(
runningStatusPojo
.
getControlMode
().
substring
(
2
,
4
)));
lightsStatusVO
.
setCrossId
(
crossId
);
lightsStatusVO
.
setRunMode
(
controlModel
);
...
...
@@ -191,6 +195,7 @@ public class DTSignalStatusServiceImpl implements SignalStatusService {
Integer
currentSchemeId
=
runningStatusPojo
.
getSchemeId
();
Integer
currentPhaseStageId
=
runningStatusPojo
.
getPhaseStageId
();
List
<
SchemeInfoPojo
>
schemeInfoPojos
=
SignalDataCache
.
schemeInfoCache
.
get
(
crossId
);
if
(!
CollectionUtils
.
isEmpty
(
schemeInfoPojos
))
{
for
(
SchemeInfoPojo
schemeInfoPojo
:
schemeInfoPojos
)
{
if
(
Objects
.
equals
(
schemeInfoPojo
.
getSchemeId
(),
currentSchemeId
))
{
...
...
@@ -214,13 +219,24 @@ public class DTSignalStatusServiceImpl implements SignalStatusService {
List
<
PhaseInfoPojo
>
phaseInfoPojos
=
SignalDataCache
.
phaseInfoCache
.
get
(
crossId
);
Integer
redTime
=
0
;
for
(
PhaseInfoPojo
phaseInfoPojo
:
phaseInfoPojos
)
{
Integer
lightsId
=
phaseInfoPojo
.
getLightsId
();
if
(
phaseInfoPojo
.
getPhaseId
()
==
phaseList
.
get
(
0
))
{
redTime
=
phaseInfoPojo
.
getRedTime
();
}
List
<
LightsInfoPojo
>
lightsInfoPojos
=
SignalDataCache
.
lightInfoCache
.
get
(
crossId
);
for
(
LightsInfoPojo
lightsInfoPojo
:
lightsInfoPojos
)
{
if
(
Objects
.
equals
(
lightsInfoPojo
.
getLightId
(),
lightsId
))
{
Integer
lightsDir
=
lightsInfoPojo
.
getLightsDir
(
lightsId
);
Integer
type
=
lightsInfoPojo
.
getType
();
Integer
lightsTurn
=
lightsInfoPojo
.
getTurnDir
(
lightsDir
,
type
);
phaseMap
.
put
(
String
.
join
(
"-"
,
String
.
valueOf
(
lightsDir
),
String
.
valueOf
(
lightsTurn
)),
phaseStageTime
);
}
}
}
lightsStatusVO
.
setSchemeId
(
String
.
valueOf
(
currentSchemeId
));
lightsStatusVO
.
setCycleLen
(
schemeInfoPojo
.
getCycle
());
lightsStatusVO
.
setCycleCountDown
(
phaseStageStatusPojo
.
getRemainTime
());
lightsStatusVO
.
setPhaseMap
(
phaseMap
);
// 当运行时间小于过渡时,运行的时上一个阶段,
int
realRemainTime
=
phaseStageStatusPojo
.
getRemainTime
();
Integer
runningTime
=
phaseStageStatusPojo
.
getRunningTime
();
...
...
signal-utc-dt-service/src/main/java/net/wanji/utc/dt/task/RealTimeTask.java
View file @
bf0a2bf1
package
net
.
wanji
.
utc
.
dt
.
task
;
import
net.wanji.databus.dto.PlanSectionDTO
;
import
net.wanji.databus.dto.SchemePhaseLightsDTO
;
import
net.wanji.databus.po.CrossInfoPO
;
import
net.wanji.utc.dt.cache.CrossInfoCache
;
import
net.wanji.utc.dt.cache.SignalDataCache
;
import
net.wanji.utc.dt.pojo.dtconvert.PhaseStageStatusPojo
;
import
net.wanji.utc.dt.pojo.dtconvert.RunningStatusPojo
;
import
net.wanji.utc.dt.service.StaticInfoService
;
import
net.wanji.utc.dt.service.impl.DTSignalStatusServiceImpl
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -24,11 +26,13 @@ public class RealTimeTask {
@Resource
(
name
=
"commonThreadPoolExecutor"
)
ThreadPoolTaskExecutor
commonThreadPoolExecutor
;
@Scheduled
(
initialDelay
=
60
*
1000
,
fixedRate
=
1000
)
@Resource
StaticInfoService
staticInfoService
;
@Scheduled
(
initialDelay
=
30
*
1000
,
fixedRate
=
60
*
1000
)
public
void
getRealTimeLightStatus
()
throws
Exception
{
Map
<
String
,
CrossInfoPO
>
crossInfoCache
=
CrossInfoCache
.
getCrossInfoCache
();
if
(!
crossInfoCache
.
isEmpty
())
{
System
.
err
.
println
(
new
Date
());
for
(
Map
.
Entry
<
String
,
CrossInfoPO
>
entry
:
crossInfoCache
.
entrySet
())
{
String
crossId
=
entry
.
getKey
();
commonThreadPoolExecutor
.
execute
(()
->
{
...
...
@@ -39,6 +43,15 @@ public class RealTimeTask {
SignalDataCache
.
realTimeRunStatusCache
.
put
(
crossId
,
runningStatusPojos
);
List
<
PhaseStageStatusPojo
>
phaseStageStatus
=
DTSignalStatusServiceImpl
.
getPhaseStageStatus
(
crossId
);
SignalDataCache
.
realTimePhaseStatusStageCache
.
put
(
crossId
,
phaseStageStatus
);
// 静态数据
SchemePhaseLightsDTO
schemePhaseLightsDTO
=
new
SchemePhaseLightsDTO
();
schemePhaseLightsDTO
.
setCrossId
(
crossId
);
staticInfoService
.
schemePhaseLights
(
schemePhaseLightsDTO
);
PlanSectionDTO
planSectionDTO
=
new
PlanSectionDTO
();
planSectionDTO
.
setCrossId
(
crossId
);
planSectionDTO
.
setPlanNo
(-
1
);
staticInfoService
.
planSection
(
planSectionDTO
);
staticInfoService
.
crossSchedules
(
crossId
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
...
...
signal-utc-service/src/main/java/net/wanji/utc/task/SignalStatusTask.java
View file @
bf0a2bf1
...
...
@@ -25,7 +25,6 @@ import org.springframework.scheduling.annotation.Scheduled;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StopWatch
;
import
javax.annotation.Resource
;
import
java.util.*
;
...
...
@@ -89,14 +88,8 @@ public class SignalStatusTask {
if
(
StringUtils
.
equals
(
BasicEnum
.
ManufacturerEnum
.
HK
.
getCode
(),
manufacturerInfoPO
.
getCode
()))
{
lightsStatusVOS
=
hkLightsStatusService
.
getHkLightsStatus
(
crossId
);
}
else
if
(
StringUtils
.
equals
(
BasicEnum
.
ManufacturerEnum
.
DT
.
getCode
(),
manufacturerInfoPO
.
getCode
())){
StopWatch
stopWatch
=
new
StopWatch
();
stopWatch
.
start
();
JsonViewObject
jsonViewObject
=
utcDTFeignClients
.
lightStatus
(
crossId
);
lightsStatusVOS
=
mapper
.
convertValue
(
jsonViewObject
.
getContent
(),
new
TypeReference
<
List
<
LightsStatusVO
>>()
{});
stopWatch
.
stop
();
log
.
error
(
"运行时间:{}"
,
stopWatch
.
getTotalTimeMillis
());
log
.
error
(
"dirLampGroupMap:{}"
,
lightsStatusVOS
.
get
(
0
).
getDirLampGroupMap
());
}
else
if
(
StringUtils
.
equals
(
BasicEnum
.
ManufacturerEnum
.
HISENSE
.
getCode
(),
manufacturerInfoPO
.
getCode
())){
JsonViewObject
jsonViewObject
=
utcHisenseFeignClients
.
lightStatus
(
crossId
);
lightsStatusVOS
=
mapper
.
convertValue
(
jsonViewObject
.
getContent
(),
new
TypeReference
<
List
<
LightsStatusVO
>>()
{});
...
...
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