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
3b9149ec
Commit
3b9149ec
authored
Apr 26, 2024
by
hanbing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 城市大脑-干线评价-兼容环比跨天查询
parent
7656cac6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
14 deletions
+55
-14
MainlineSchemeEvaluateBO.java
.../main/java/net/wanji/opt/bo/MainlineSchemeEvaluateBO.java
+4
-0
MainlineEvaluateServiceImpl.java
...t/wanji/opt/service/impl/MainlineEvaluateServiceImpl.java
+29
-13
TimeArrayUtil.java
.../main/java/net/wanji/common/utils/tool/TimeArrayUtil.java
+22
-1
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/bo/MainlineSchemeEvaluateBO.java
View file @
3b9149ec
...
...
@@ -30,4 +30,8 @@ public class MainlineSchemeEvaluateBO {
@ApiModelProperty
(
value
=
"分析时段结束时间 格式 yyyy-MM-dd HH:mm:ss"
)
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Date
endTime
;
@ApiModelProperty
(
value
=
"是否用于城市大脑"
)
private
Integer
isCityBrain
;
}
signal-optimize-service/src/main/java/net/wanji/opt/service/impl/MainlineEvaluateServiceImpl.java
View file @
3b9149ec
...
...
@@ -913,6 +913,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
String
metricName
=
bo
.
getMetricName
();
Date
boStartTime
=
bo
.
getStartTime
();
Date
boEndTime
=
bo
.
getEndTime
();
Integer
isCityBrain
=
bo
.
getIsCityBrain
();
MainlineSchemeEvaluateVO
res
=
new
MainlineSchemeEvaluateVO
();
...
...
@@ -932,7 +933,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
String
strategyCode
=
strategyPO
.
getStrategyCode
();
setCurveElementListAndEvaluateList
(
dirName
,
metricName
,
greenwaveId
,
boStartTime
,
boEndTime
,
startHourMinuteStr
,
endHourMinuteStr
,
res
,
strategyCode
);
endHourMinuteStr
,
res
,
strategyCode
,
isCityBrain
);
return
res
;
}
...
...
@@ -1383,7 +1384,8 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
private
void
setCurveElementListAndEvaluateList
(
String
dirName
,
String
metricName
,
Integer
greenwaveId
,
Date
boStartTime
,
Date
boEndTime
,
String
startHourMinuteStr
,
String
endHourMinuteStr
,
MainlineSchemeEvaluateVO
res
,
String
strategyCode
)
{
String
startHourMinuteStr
,
String
endHourMinuteStr
,
MainlineSchemeEvaluateVO
res
,
String
strategyCode
,
Integer
isCityBrain
)
{
String
boStartTimeStr
=
sdf
.
format
(
boStartTime
);
String
boEndTimeStr
=
sdf
.
format
(
boEndTime
);
...
...
@@ -1391,16 +1393,25 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
// 获取绿波历史数据
List
<
GreenwaveHistPO
>
greenwaveHistPOList
=
greenwaveHistMapper
.
selectByIdAndTimeSection
(
greenwaveId
,
boStartTimeStr
,
boEndTimeStr
);
// 过滤时段内的数据
List
<
GreenwaveHistPO
>
filteredGreenwaveList
=
greenwaveHistPOList
.
stream
()
.
filter
(
po
->
{
try
{
return
isTimeInRange
(
po
.
getGmtModified
(),
startHourMinuteStr
,
endHourMinuteStr
);
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
})
.
collect
(
Collectors
.
toList
());
List
<
GreenwaveHistPO
>
filteredGreenwaveList
;
if
(
ObjectUtil
.
isEmpty
(
isCityBrain
))
{
// 过滤时段内的数据
filteredGreenwaveList
=
greenwaveHistPOList
.
stream
()
.
filter
(
po
->
{
try
{
return
isTimeInRange
(
po
.
getGmtModified
(),
startHourMinuteStr
,
endHourMinuteStr
);
}
catch
(
ParseException
e
)
{
throw
new
RuntimeException
(
e
);
}
})
.
collect
(
Collectors
.
toList
());
}
else
{
filteredGreenwaveList
=
greenwaveHistPOList
.
stream
()
.
filter
(
greenwaveHistPO
->
!
boStartTime
.
after
(
greenwaveHistPO
.
getGmtModified
())
&&
!
boEndTime
.
before
(
greenwaveHistPO
.
getGmtModified
()))
.
collect
(
Collectors
.
toList
());
}
// 获取绿波指标
double
noparkPassRate
=
filteredGreenwaveList
.
stream
()
.
mapToDouble
(
GreenwaveHistPO:
:
getNoparkPassRate
)
...
...
@@ -1556,7 +1567,12 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
res
.
setEvaluateList
(
evaluateList
);
// 生成曲线图
List
<
String
>
timeArray
=
TimeArrayUtil
.
getCustomTimeIntervals
(
startHourMinuteStr
,
endHourMinuteStr
,
5
);
List
<
String
>
timeArray
;
if
(
ObjectUtil
.
isEmpty
(
isCityBrain
))
{
timeArray
=
TimeArrayUtil
.
getCustomTimeIntervals
(
startHourMinuteStr
,
endHourMinuteStr
,
5
);
}
else
{
timeArray
=
TimeArrayUtil
.
getMultiDayTimeIntervals
(
boStartTime
,
boEndTime
,
5
);
}
if
(
Objects
.
equals
(
metricName
,
StrategyAndMetricsEnum
.
Metrics
.
NO_PARK_PASS_RATE
.
getDescription
())
||
Objects
.
equals
(
metricName
,
StrategyAndMetricsEnum
.
Metrics
.
CORD_RELIABILITY
.
getDescription
())
||
Objects
.
equals
(
metricName
,
StrategyAndMetricsEnum
.
Metrics
.
UNCOORDINATE_PHASE_QUEUE
.
getDescription
())
...
...
wj-common/src/main/java/net/wanji/common/utils/tool/TimeArrayUtil.java
View file @
3b9149ec
...
...
@@ -3,8 +3,9 @@ package net.wanji.common.utils.tool;
import
java.text.MessageFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.
List
;
import
java.util.
Calendar
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author Kent HAN
...
...
@@ -90,4 +91,24 @@ public class TimeArrayUtil {
System
.
out
.
println
(
interval
);
}
}
/**
* 跨天生成时间数组。如 ["23:55", "00:00" ... ]
* minutes,分钟段。如按每15分钟生成,则 minute 传15。
* @author Kent HAN
* @date 2022/11/3 16:30
*/
public
static
List
<
String
>
getMultiDayTimeIntervals
(
Date
boStartTime
,
Date
boEndTime
,
int
minutes
)
{
List
<
String
>
intervals
=
new
ArrayList
<>();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm"
);
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
boStartTime
);
while
(!
calendar
.
getTime
().
after
(
boEndTime
))
{
intervals
.
add
(
sdf
.
format
(
calendar
.
getTime
()));
calendar
.
add
(
Calendar
.
MINUTE
,
minutes
);
}
return
intervals
;
}
}
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