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
5c4e63a8
Commit
5c4e63a8
authored
Dec 12, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 灯态增加线程
parent
09c5fc13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
45 deletions
+51
-45
SignalDataCache.java
...ain/java/net/wanji/utc/hisense/cache/SignalDataCache.java
+1
-1
HisensePhaseCountDownTask.java
...net/wanji/utc/hisense/task/HisensePhaseCountDownTask.java
+50
-44
No files found.
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/cache/SignalDataCache.java
View file @
5c4e63a8
...
@@ -26,5 +26,5 @@ public class SignalDataCache {
...
@@ -26,5 +26,5 @@ public class SignalDataCache {
public
static
final
Map
<
String
,
LightsStatusVO
>
runningStateInfoCache
=
new
ConcurrentHashMap
<>();
public
static
final
Map
<
String
,
LightsStatusVO
>
runningStateInfoCache
=
new
ConcurrentHashMap
<>();
// 海信推送方案相位信息,未计算灯态缓存
// 海信推送方案相位信息,未计算灯态缓存
public
static
final
Map
<
String
,
LightsStatusVO
>
runningStateInfoCacheNoLamp
=
new
ConcurrentHashMap
<>();
public
static
final
Map
<
String
,
LightsStatusVO
>
runningStateInfoCacheNoLamp
=
new
ConcurrentHashMap
<>();
public
static
final
Map
<
String
,
Long
>
runningStatusStampMap
=
new
HashMap
<>();
public
static
final
Map
<
String
,
Long
>
runningStatusStampMap
=
new
Concurrent
HashMap
<>();
}
}
signal-utc-hisense-service/src/main/java/net/wanji/utc/hisense/task/HisensePhaseCountDownTask.java
View file @
5c4e63a8
...
@@ -19,6 +19,7 @@ import net.wanji.utc.hisense.pojo.dto.CrossSchemePhaseCountDownDTO;
...
@@ -19,6 +19,7 @@ import net.wanji.utc.hisense.pojo.dto.CrossSchemePhaseCountDownDTO;
import
net.wanji.utc.hisense.pojo.dto.PhaseCountDownDTO
;
import
net.wanji.utc.hisense.pojo.dto.PhaseCountDownDTO
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -40,60 +41,65 @@ public class HisensePhaseCountDownTask {
...
@@ -40,60 +41,65 @@ public class HisensePhaseCountDownTask {
private
CrossSchemeMapper
crossSchemeMapper
;
private
CrossSchemeMapper
crossSchemeMapper
;
@Resource
@Resource
private
CrossLightsMapper
crossLightsMapper
;
private
CrossLightsMapper
crossLightsMapper
;
@Resource
(
name
=
"commonThreadPoolExecutor"
)
ThreadPoolTaskExecutor
commonThreadPoolExecutor
;
@Scheduled
(
fixedRate
=
1000
,
initialDelay
=
1000
)
@Scheduled
(
fixedRate
=
1000
,
initialDelay
=
1000
)
public
void
phaseTimeCountDown
()
throws
Exception
{
public
void
phaseTimeCountDown
()
throws
Exception
{
try
{
commonThreadPoolExecutor
.
execute
(()
->
{
Map
<
String
,
LightsStatusVO
>
runningStateInfoCacheNoLamp
=
SignalDataCache
.
runningStateInfoCacheNoLamp
;
try
{
if
(!
runningStateInfoCacheNoLamp
.
isEmpty
())
{
Map
<
String
,
LightsStatusVO
>
runningStateInfoCacheNoLamp
=
SignalDataCache
.
runningStateInfoCacheNoLamp
;
for
(
Map
.
Entry
<
String
,
LightsStatusVO
>
entry
:
runningStateInfoCacheNoLamp
.
entrySet
())
{
if
(!
runningStateInfoCacheNoLamp
.
isEmpty
())
{
String
crossId
=
entry
.
getKey
();
for
(
Map
.
Entry
<
String
,
LightsStatusVO
>
entry
:
runningStateInfoCacheNoLamp
.
entrySet
())
{
LightsStatusVO
lightsStatusVO
=
entry
.
getValue
();
String
crossId
=
entry
.
getKey
();
long
timeStamp
=
Long
.
parseLong
(
lightsStatusVO
.
getTimeStamp
());
LightsStatusVO
lightsStatusVO
=
entry
.
getValue
();
String
schemeStartTime
=
lightsStatusVO
.
getSchemeStartTime
();
long
timeStamp
=
Long
.
parseLong
(
lightsStatusVO
.
getTimeStamp
());
String
phaseId
=
lightsStatusVO
.
getPhaseId
();
String
schemeStartTime
=
lightsStatusVO
.
getSchemeStartTime
();
String
schemeId
=
lightsStatusVO
.
getSchemeId
();
String
phaseId
=
lightsStatusVO
.
getPhaseId
();
CrossSchemePO
crossSchemePO
=
crossSchemeMapper
.
selectByCrossIdAndSchemeNo
(
crossId
,
Integer
.
valueOf
(
schemeId
));
String
schemeId
=
lightsStatusVO
.
getSchemeId
();
CrossSchemePO
crossSchemePO
=
crossSchemeMapper
.
selectByCrossIdAndSchemeNo
(
crossId
,
Integer
.
valueOf
(
schemeId
));
// 通过时段表,切换方案 凌晨00:00 如果切换下一个日期方案,可能RefreshCacheTask还没执行
// 通过时段表,切换方案 凌晨00:00 如果切换下一个日期方案,可能RefreshCacheTask还没执行
String
nextSectionSchemeNo
=
CrossRunSchemeCache
.
currentRunSchemeNoCache
.
get
(
crossId
);
String
nextSectionSchemeNo
=
CrossRunSchemeCache
.
currentRunSchemeNoCache
.
get
(
crossId
);
Date
currentDate
=
new
Date
();
Date
currentDate
=
new
Date
();
String
currentTime
=
String
.
valueOf
(
currentDate
.
getTime
());
String
currentTime
=
String
.
valueOf
(
currentDate
.
getTime
());
Date
date2HoursAgo
=
DateUtils
.
addHours
(
currentDate
,
-
1
);
Date
date2HoursAgo
=
DateUtils
.
addHours
(
currentDate
,
-
1
);
if
(
StringUtils
.
equalsIgnoreCase
(
schemeStartTime
,
currentTime
)
||
Long
.
parseLong
(
schemeStartTime
)
<
date2HoursAgo
.
getTime
())
{
if
(
StringUtils
.
equalsIgnoreCase
(
schemeStartTime
,
currentTime
)
||
Long
.
parseLong
(
schemeStartTime
)
<
date2HoursAgo
.
getTime
())
{
crossSchemePO
=
crossSchemeMapper
.
selectByCrossIdAndSchemeNo
(
crossId
,
Integer
.
valueOf
(
nextSectionSchemeNo
));
crossSchemePO
=
crossSchemeMapper
.
selectByCrossIdAndSchemeNo
(
crossId
,
Integer
.
valueOf
(
nextSectionSchemeNo
));
executeNextSectionScheme
(
crossId
,
lightsStatusVO
,
crossSchemePO
);
executeNextSectionScheme
(
crossId
,
lightsStatusVO
,
crossSchemePO
);
lightsStatusVO
.
setCycleLen
(
crossSchemePO
.
getCycle
());
lightsStatusVO
.
setCycleLen
(
crossSchemePO
.
getCycle
());
}
else
{
}
else
{
executeNextPeriod
(
crossId
,
lightsStatusVO
,
phaseId
,
crossSchemePO
);
executeNextPeriod
(
crossId
,
lightsStatusVO
,
phaseId
,
crossSchemePO
);
}
}
// 当前方案下一周期
// 当前方案下一周期
setDirLampGroupMap
(
lightsStatusVO
);
setDirLampGroupMap
(
lightsStatusVO
);
if
(
Objects
.
nonNull
(
lightsStatusVO
.
getDirLampGroupMap
()))
{
if
(
Objects
.
nonNull
(
lightsStatusVO
.
getDirLampGroupMap
()))
{
if
(
Objects
.
equals
(
crossId
,
"13NI00B5RM0"
))
{
if
(
Objects
.
equals
(
crossId
,
"13NI00B5RM0"
))
{
List
<
String
>
dirList
=
Arrays
.
asList
(
"1"
,
"3"
,
"7"
);
List
<
String
>
dirList
=
Arrays
.
asList
(
"1"
,
"3"
,
"7"
);
Map
<
String
,
Object
>
dirLampGroupMap
=
lightsStatusVO
.
getDirLampGroupMap
();
Map
<
String
,
Object
>
dirLampGroupMap
=
lightsStatusVO
.
getDirLampGroupMap
();
for
(
String
dir
:
dirList
)
{
for
(
String
dir
:
dirList
)
{
if
(!
dirLampGroupMap
.
containsKey
(
dir
))
{
if
(!
dirLampGroupMap
.
containsKey
(
dir
))
{
Map
<
Integer
,
String
>
value
=
new
HashMap
<>();
Map
<
Integer
,
String
>
value
=
new
HashMap
<>();
setAllTurnColorRed
(
value
,
null
,
null
);
setAllTurnColorRed
(
value
,
null
,
null
);
dirLampGroupMap
.
put
(
dir
,
value
);
dirLampGroupMap
.
put
(
dir
,
value
);
}
}
}
lightsStatusVO
.
setDirLampGroupMap
(
dirLampGroupMap
);
}
}
lightsStatusVO
.
setDirLampGroupMap
(
dirLampGroupMap
);
// 当前时间戳自动加1s
lightsStatusVO
.
setTimeStamp
(
String
.
valueOf
(
timeStamp
+
1000
));
// 红灯倒计时
getRedCountDown
(
crossId
,
lightsStatusVO
,
schemeId
);
SignalDataCache
.
runningStateInfoCache
.
put
(
crossId
,
lightsStatusVO
);
}
}
// 当前时间戳自动加1s
lightsStatusVO
.
setTimeStamp
(
String
.
valueOf
(
timeStamp
+
1000
));
// 红灯倒计时
getRedCountDown
(
crossId
,
lightsStatusVO
,
schemeId
);
SignalDataCache
.
runningStateInfoCache
.
put
(
crossId
,
lightsStatusVO
);
}
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"定时任务计算路口相位灯态倒计时异常"
,
e
);
throw
new
RuntimeException
(
e
);
}
}
}
catch
(
Exception
e
)
{
});
log
.
error
(
"定时任务计算路口相位灯态倒计时异常"
,
e
);
throw
new
Exception
(
e
);
}
}
}
private
static
void
getRedCountDown
(
String
crossId
,
LightsStatusVO
lightsStatusVO
,
String
schemeId
)
{
private
static
void
getRedCountDown
(
String
crossId
,
LightsStatusVO
lightsStatusVO
,
String
schemeId
)
{
...
...
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