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
900b7da2
Commit
900b7da2
authored
May 27, 2024
by
hanbing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[update] 围观大数据平台-信号评价时间粒度调整
parent
03a6d8f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
MainlineEvaluateServiceImpl.java
...t/wanji/opt/service/impl/MainlineEvaluateServiceImpl.java
+38
-0
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/service/impl/MainlineEvaluateServiceImpl.java
View file @
900b7da2
...
@@ -147,7 +147,9 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
...
@@ -147,7 +147,9 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
Integer
minutesSpan
=
minutes
-
1
;
// 排除结束时间
Integer
minutesSpan
=
minutes
-
1
;
// 排除结束时间
String
metricName
=
bo
.
getMetricCode
();
String
metricName
=
bo
.
getMetricCode
();
Date
startTime
=
bo
.
getStartTime
();
Date
startTime
=
bo
.
getStartTime
();
startTime
=
roundDownToNearest5Minutes
(
startTime
);
Date
endTime
=
bo
.
getEndTime
();
Date
endTime
=
bo
.
getEndTime
();
endTime
=
roundUpToNearest5Minutes
(
endTime
);
// 从 Kafka 查询绿灯空放时长
// 从 Kafka 查询绿灯空放时长
KafkaConsumerUtil
kafkaConsumerUtil
=
new
KafkaConsumerUtil
(
bootstrapServers
,
"bottom-curve-empty-phase"
);
KafkaConsumerUtil
kafkaConsumerUtil
=
new
KafkaConsumerUtil
(
bootstrapServers
,
"bottom-curve-empty-phase"
);
...
@@ -660,6 +662,42 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
...
@@ -660,6 +662,42 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
return
res
;
return
res
;
}
}
/**
* Rounds the given date to the nearest previous 5-minute interval.
*
* @param date the date to be rounded
* @return the rounded date
*/
private
Date
roundDownToNearest5Minutes
(
Date
date
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
int
unroundedMinutes
=
calendar
.
get
(
Calendar
.
MINUTE
);
int
mod
=
unroundedMinutes
%
5
;
calendar
.
add
(
Calendar
.
MINUTE
,
-
mod
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
calendar
.
getTime
();
}
/**
* Rounds the given date to the nearest next 5-minute interval.
*
* @param date the date to be rounded
* @return the rounded date
*/
private
Date
roundUpToNearest5Minutes
(
Date
date
)
{
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
int
unroundedMinutes
=
calendar
.
get
(
Calendar
.
MINUTE
);
int
mod
=
unroundedMinutes
%
5
;
if
(
mod
!=
0
)
{
calendar
.
add
(
Calendar
.
MINUTE
,
5
-
mod
);
}
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
return
calendar
.
getTime
();
}
@Override
@Override
public
List
<
MainlineListVO
>
mainlineList
()
{
public
List
<
MainlineListVO
>
mainlineList
()
{
List
<
MainlineListVO
>
res
=
new
ArrayList
<>();
List
<
MainlineListVO
>
res
=
new
ArrayList
<>();
...
...
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