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
db66455c
Commit
db66455c
authored
Feb 18, 2025
by
duanruiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 策略锁定时间计算逻辑
parent
e7f03570
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
15 deletions
+58
-15
StrategyControlServiceImpl.java
...pt/synthesis/service/impl/StrategyControlServiceImpl.java
+58
-15
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/synthesis/service/impl/StrategyControlServiceImpl.java
View file @
db66455c
...
@@ -33,6 +33,7 @@ import net.wanji.opt.vo.StrategyNameCrossVO;
...
@@ -33,6 +33,7 @@ import net.wanji.opt.vo.StrategyNameCrossVO;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeansException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -610,9 +611,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -610,9 +611,8 @@ public class StrategyControlServiceImpl implements StrategyControlService {
Map
<
Integer
,
GreenwaveInfoPO
>
greenWaveMap
=
GreenWaveInfoCache
.
greenWaveMap
;
Map
<
Integer
,
GreenwaveInfoPO
>
greenWaveMap
=
GreenWaveInfoCache
.
greenWaveMap
;
GreenwaveInfoPO
greenwaveInfoPO
=
greenWaveMap
.
get
(
greenId
);
GreenwaveInfoPO
greenwaveInfoPO
=
greenWaveMap
.
get
(
greenId
);
String
dir
=
entity
.
getDir
();
String
dir
=
entity
.
getDir
();
String
desc
=
GreenBeltDirEnum
.
getDesc
(
dir
);
ext
.
setBizId
(
String
.
valueOf
(
entity
.
getGreenId
()));
ext
.
setBizId
(
String
.
valueOf
(
entity
.
getGreenId
()));
ext
.
setCrossName
(
greenwaveInfoPO
.
getName
()
+
desc
);
ext
.
setCrossName
(
greenwaveInfoPO
.
getName
());
String
location
=
greenwaveInfoPO
.
getWkt
();
String
location
=
greenwaveInfoPO
.
getWkt
();
ext
.
setWkt
(
location
);
ext
.
setWkt
(
location
);
ext
.
setOptMethod
(
optMethod
);
ext
.
setOptMethod
(
optMethod
);
...
@@ -1284,23 +1284,66 @@ public class StrategyControlServiceImpl implements StrategyControlService {
...
@@ -1284,23 +1284,66 @@ public class StrategyControlServiceImpl implements StrategyControlService {
@Override
@Override
public
JsonViewObject
strategyLockSend
(
StrategyLockSendVO
strategyLockSendVO
)
throws
Exception
{
public
JsonViewObject
strategyLockSend
(
StrategyLockSendVO
strategyLockSendVO
)
throws
Exception
{
ObjectMapper
mapper
=
JacksonUtils
.
getInstance
();
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
JsonViewObject
jsonViewObject
=
JsonViewObject
.
newInstance
();
String
crossId
=
strategyLockSendVO
.
getCrossId
();
try
{
LambdaQueryWrapper
<
StrategyDailyPlanInfoEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
ObjectMapper
instance
=
JacksonUtils
.
getInstance
();
queryWrapper
.
eq
(
StrategyDailyPlanInfoEntity:
:
getCrossId
,
crossId
);
LambdaQueryWrapper
<
StrategyControlDataEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
List
<
StrategyDailyPlanInfoEntity
>
dailyPlanInfos
=
strategyDailyPlanInfoMapper
.
selectList
(
queryWrapper
);
Date
current
=
new
Date
();
if
(!
CollectionUtils
.
isEmpty
(
dailyPlanInfos
))
{
queryWrapper
.
eq
(
StrategyControlDataEntity:
:
getBizId
,
strategyLockSendVO
.
getCrossId
());
for
(
StrategyDailyPlanInfoEntity
dailyPlanInfo
:
dailyPlanInfos
)
{
queryWrapper
.
eq
(
StrategyControlDataEntity:
:
getBizType
,
0
);
String
dailyPlanStr
=
dailyPlanInfo
.
getDailyPlanDetails
();
queryWrapper
.
le
(
StrategyControlDataEntity:
:
getScheduleStart
,
current
);
StrategyControlDetailList
.
DailyPlan
.
DailyPlanDetail
dailyPlanDetail
=
new
StrategyControlDetailList
.
DailyPlan
.
DailyPlanDetail
();
queryWrapper
.
ge
(
StrategyControlDataEntity:
:
getScheduleEnd
,
current
);
List
<
StrategyControlDetailList
.
DailyPlan
.
DailyPlanDetail
>
dailyPlanDetails
=
mapper
.
readValue
(
dailyPlanStr
,
new
TypeReference
<
List
<
StrategyControlDetailList
.
DailyPlan
.
DailyPlanDetail
>>()
{});
queryWrapper
.
orderByAsc
(
StrategyControlDataEntity:
:
getId
);
if
(!
CollectionUtils
.
isEmpty
(
dailyPlanDetails
))
{
List
<
StrategyControlDataEntity
>
entities
=
strategyControlInfoMapper
.
selectList
(
queryWrapper
);
for
(
StrategyControlDetailList
.
DailyPlan
.
DailyPlanDetail
item
:
dailyPlanDetails
)
{
for
(
StrategyControlDataEntity
entity
:
entities
)
{
String
strategyNo
=
item
.
getStrategyNo
();
StrategyControlDataEntity
result
=
new
StrategyControlDataEntity
();
BeanUtils
.
copyProperties
(
entity
,
result
);
String
time
=
entity
.
getTime
();
List
<
StrategyControlDataVO
.
TimeTable
>
timeTables
=
instance
.
readValue
(
time
,
new
TypeReference
<
List
<
StrategyControlDataVO
.
TimeTable
>>()
{});
for
(
StrategyControlDataVO
.
TimeTable
timeTable
:
timeTables
)
{
Integer
week
=
timeTable
.
getWeek
();
int
curWeek
=
DateUtil
.
getWeek
(
new
Date
());
if
(
curWeek
==
0
)
{
curWeek
=
7
;
}
if
(!
Objects
.
equals
(
curWeek
,
week
))
{
continue
;
}
String
[]
timeList
=
timeTable
.
getTimeList
();
for
(
String
s
:
timeList
)
{
String
[]
hours
=
s
.
split
(
","
);
for
(
String
hour
:
hours
)
{
String
[]
currentHour
=
hour
.
split
(
"-"
);
String
startHour
=
currentHour
[
0
];
String
entHour
=
currentHour
[
1
];
if
(
StringUtils
.
equals
(
"24:00"
,
entHour
))
{
entHour
=
"23:59"
;
}
String
format
=
DateUtil
.
format
(
current
,
Constants
.
DATE_FORMAT
.
E_DATE_FORMAT_HOUR_MINUTE
);
Date
currentTime
=
DateUtil
.
parse
(
format
,
"HH:mm"
);
Date
startHourDate
=
DateUtil
.
parse
(
startHour
,
"HH:mm"
);
Date
endHourDate
=
DateUtil
.
parse
(
entHour
,
"HH:mm"
);
if
(
currentTime
.
after
(
startHourDate
)
&&
currentTime
.
before
(
endHourDate
))
{
// 正在执行测策略 0=绿波带,1=失衡,2=溢出,3=空放
Integer
strategy
=
entity
.
getStrategy
();
// 当前策略延长时间
Double
lockTime
=
strategyLockSendVO
.
getLockTime
();
LocalTime
lockEndTime
=
LocalTime
.
parse
(
entHour
);
if
(
Objects
.
equals
(
lockTime
,
0.5
))
{
lockEndTime
=
lockEndTime
.
plusMinutes
(
30
);
}
else
{
lockEndTime
=
lockEndTime
.
plusHours
(
lockTime
.
intValue
());
}
log
.
error
(
"延长之后时间:{}"
,
lockEndTime
.
toString
());
}
}
}
}
}
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"策略锁定下发失败:{}"
,
e
);
return
jsonViewObject
.
success
(
"策略锁定成功"
);
}
}
log
.
error
(
"收到请求参数:{}"
,
strategyLockSendVO
);
log
.
error
(
"收到请求参数:{}"
,
strategyLockSendVO
);
return
jsonViewObject
.
success
(
"策略锁定成功"
);
return
jsonViewObject
.
success
(
"策略锁定成功"
);
...
...
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