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
b94fb4dc
Commit
b94fb4dc
authored
Aug 23, 2023
by
hanbing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 新信号评价-运行评价-详细指标查询-指标信息
parent
b0526758
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
15 deletions
+103
-15
SignalEvaluateServiceImpl.java
...net/wanji/web/service/impl/SignalEvaluateServiceImpl.java
+2
-2
RunningEvaluateServiceImpl.java
...et/wanji/opt/service/impl/RunningEvaluateServiceImpl.java
+74
-5
RunningEvaluateMetricsDetailVO.java
...java/net/wanji/opt/vo/RunningEvaluateMetricsDetailVO.java
+2
-3
TimeArrayUtil.java
.../main/java/net/wanji/common/utils/tool/TimeArrayUtil.java
+22
-2
CrossDataHistMapper.xml
wj-databus/src/main/resources/mapper/CrossDataHistMapper.xml
+1
-1
CrossDirDataHistMapper.xml
...abus/src/main/resources/mapper/CrossDirDataHistMapper.xml
+1
-1
CrossTurnDataHistMapper.xml
...bus/src/main/resources/mapper/CrossTurnDataHistMapper.xml
+1
-1
No files found.
signal-control-service/src/main/java/net/wanji/web/service/impl/SignalEvaluateServiceImpl.java
View file @
b94fb4dc
...
...
@@ -39,7 +39,7 @@ public class SignalEvaluateServiceImpl implements SignalEvaluateService {
}
private
FlowQueueOutVO
getDayQueue
(
String
adCode
,
String
crossId
,
Date
currentTime
)
{
List
<
String
>
time
=
TimeArrayUtil
.
get
Time
Array
();
List
<
String
>
time
=
TimeArrayUtil
.
get
Hour
Array
();
double
[]
toDay
=
new
double
[
24
];
double
[]
yesterday
=
new
double
[
24
];
double
[]
lastWeekDay
=
new
double
[
24
];
...
...
@@ -63,7 +63,7 @@ public class SignalEvaluateServiceImpl implements SignalEvaluateService {
}
private
FlowQueueOutVO
getDayFlow
(
String
adCode
,
String
crossId
,
Date
currentTime
)
{
List
<
String
>
time
=
TimeArrayUtil
.
get
Time
Array
();
List
<
String
>
time
=
TimeArrayUtil
.
get
Hour
Array
();
double
[]
toDay
=
new
double
[
24
];
double
[]
yesterday
=
new
double
[
24
];
double
[]
lastWeekDay
=
new
double
[
24
];
...
...
signal-optimize-service/src/main/java/net/wanji/opt/service/impl/RunningEvaluateServiceImpl.java
View file @
b94fb4dc
...
...
@@ -175,7 +175,7 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
public
List
<
RunningEvaluateSchemeProblemsVO
>
schemeProblems
(
CrossIdAndStartEndDateBO
bo
)
{
String
crossId
=
bo
.
getCrossId
();
List
<
RunningEvaluateSchemeProblemsVO
>
res
=
new
ArrayList
<>();
List
<
String
>
timeArray
=
TimeArrayUtil
.
get
Time
Array
();
List
<
String
>
timeArray
=
TimeArrayUtil
.
get
Hour
Array
();
for
(
String
time
:
timeArray
)
{
RunningEvaluateSchemeProblemsVO
vo
=
new
RunningEvaluateSchemeProblemsVO
();
...
...
@@ -253,9 +253,78 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
if
(
CollectionUtil
.
isEmpty
(
metricHistDTOList
))
{
return
res
;
}
res
.
setProblemStatusList
(
buildProblemStatusList
(
metricHistDTOList
));
res
.
setSchemeList
(
buildSchemeList
(
metricHistDTOList
,
crossId
));
// res.setMetricsList(buildMetricsList(metricHistDTOList, minutes));
// 路口级别全量数据
List
<
MetricHistDTO
>
crossDTOList
=
crossDataHistMapper
.
selectMetricHistDTO
(
crossId
,
startStamp
,
endStamp
);
// 过滤有问题的记录
List
<
MetricHistDTO
>
filteredList
=
crossDTOList
.
stream
()
.
filter
(
metricHistDTO
->
metricHistDTO
.
getStatus
()
!=
null
&&
metricHistDTO
.
getStatus
()
!=
0
)
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtil
.
isEmpty
(
filteredList
))
{
return
res
;
}
res
.
setProblemStatusList
(
buildProblemStatusList
(
filteredList
));
res
.
setSchemeList
(
buildSchemeList
(
filteredList
,
crossId
));
// 使用全量数据按时间粒度聚合指标
res
.
setMetricsList
(
buildMetricsList
(
metricHistDTOList
,
minutes
));
return
res
;
}
private
List
<
RunningEvaluateMetricsDetailVO
.
CrossMetrics
>
buildMetricsList
(
List
<
MetricHistDTO
>
metricHistDTOList
,
Integer
minutes
)
{
List
<
RunningEvaluateMetricsDetailVO
.
CrossMetrics
>
res
=
new
ArrayList
<>();
// 按时间段分组
Map
<
String
,
List
<
MetricHistDTO
>>
groupedByTime
=
metricHistDTOList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
metricHistDTO
->
{
long
timestampInSeconds
=
metricHistDTO
.
getBatchTime
()
*
1000L
;
Date
date
=
new
Date
(
timestampInSeconds
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm"
);
int
minuteOfDay
=
date
.
getMinutes
()
+
date
.
getHours
()
*
60
;
int
roundedMinute
=
(
minuteOfDay
/
minutes
)
*
minutes
;
date
.
setHours
(
roundedMinute
/
60
);
date
.
setMinutes
(
roundedMinute
%
60
);
return
sdf
.
format
(
date
);
}));
// 获取时间段数组
List
<
String
>
minuteSectionArray
=
TimeArrayUtil
.
getMinuteSectionArray
(
minutes
);
// 计算指标
for
(
String
section
:
minuteSectionArray
)
{
RunningEvaluateMetricsDetailVO
.
CrossMetrics
crossMetrics
=
new
RunningEvaluateMetricsDetailVO
.
CrossMetrics
();
crossMetrics
.
setMetricTime
(
section
);
List
<
MetricHistDTO
>
dtoList
=
groupedByTime
.
get
(
section
);
if
(
CollectionUtil
.
isNotEmpty
(
dtoList
))
{
int
flowSum
=
0
;
double
speedSum
=
0.0
;
int
capacitySum
=
0
;
double
sturationSum
=
0.0
;
double
stopTimesSum
=
0.0
;
int
delayTimeSum
=
0
;
for
(
MetricHistDTO
metricHistDTO
:
dtoList
)
{
Integer
flow
=
metricHistDTO
.
getFlow
();
Double
speed
=
metricHistDTO
.
getSpeed
();
Integer
capacity
=
metricHistDTO
.
getCapacity
();
Double
sturation
=
metricHistDTO
.
getSturation
();
Double
stopTimes
=
metricHistDTO
.
getStopTimes
();
Integer
delayTime
=
metricHistDTO
.
getDelayTime
();
if
(
flow
!=
null
)
flowSum
+=
flow
;
if
(
speed
!=
null
)
speedSum
+=
speed
;
if
(
capacity
!=
null
)
capacitySum
+=
capacity
;
if
(
sturation
!=
null
)
sturationSum
+=
sturationSum
;
if
(
stopTimes
!=
null
)
stopTimesSum
+=
stopTimes
;
if
(
delayTime
!=
null
)
delayTimeSum
+=
delayTime
;
}
int
size
=
dtoList
.
size
();
crossMetrics
.
setFlow
(
flowSum
/
size
);
crossMetrics
.
setSpeed
(
speedSum
/
size
);
crossMetrics
.
setCapacity
(
capacitySum
/
size
);
crossMetrics
.
setSturation
(
sturationSum
/
size
);
crossMetrics
.
setStopTimes
(
stopTimesSum
/
size
);
crossMetrics
.
setDelayTime
(
delayTimeSum
/
size
);
}
res
.
add
(
crossMetrics
);
}
return
res
;
}
...
...
@@ -506,7 +575,7 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
// 构造结果集
List
<
RunningEvaluateIndexStatusVO
>
res
=
new
ArrayList
<>();
List
<
String
>
timeArray
=
TimeArrayUtil
.
get
Time
Array
();
List
<
String
>
timeArray
=
TimeArrayUtil
.
get
Hour
Array
();
for
(
String
time
:
timeArray
)
{
RunningEvaluateIndexStatusVO
vo
=
new
RunningEvaluateIndexStatusVO
();
vo
.
setTime
(
time
);
...
...
signal-optimize-service/src/main/java/net/wanji/opt/vo/RunningEvaluateMetricsDetailVO.java
View file @
b94fb4dc
...
...
@@ -75,8 +75,7 @@ public class RunningEvaluateMetricsDetailVO {
@Data
public
static
class
CrossMetrics
{
@ApiModelProperty
(
value
=
"时间"
)
@JsonFormat
(
shape
=
JsonFormat
.
Shape
.
STRING
,
pattern
=
"HH:mm"
,
timezone
=
"GMT+8"
)
private
Date
metricTime
;
private
String
metricTime
;
@ApiModelProperty
(
value
=
"流量"
)
private
Integer
flow
;
...
...
@@ -91,7 +90,7 @@ public class RunningEvaluateMetricsDetailVO {
private
Double
sturation
;
@ApiModelProperty
(
value
=
"平均停车次数"
)
private
Double
stop
Number
;
private
Double
stop
Times
;
@ApiModelProperty
(
value
=
"平均延误(秒)"
)
private
Integer
delayTime
;
...
...
wj-common/src/main/java/net/wanji/common/utils/tool/TimeArrayUtil.java
View file @
b94fb4dc
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.Date
;
/**
* @author Kent HAN
...
...
@@ -11,12 +13,12 @@ import java.util.List;
public
class
TimeArrayUtil
{
/**
* 返回一天的
时间
数组,按小时。如 ["00:00", "01:00" ... "23:00"]
* 返回一天的
小时
数组,按小时。如 ["00:00", "01:00" ... "23:00"]
*
* @author Kent HAN
* @date 2022/11/3 16:30
*/
public
static
List
<
String
>
get
Time
Array
()
{
public
static
List
<
String
>
get
Hour
Array
()
{
List
<
String
>
res
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
24
;
i
++)
{
if
(
i
<
10
)
{
...
...
@@ -27,4 +29,22 @@ public class TimeArrayUtil {
}
return
res
;
}
/**
* 按分钟段返回一天的时间数组。如 ["00:15", "00:30" ... ]
* minutes,分钟段。如按每15分钟生成,则 minute 传15。
* @author Kent HAN
* @date 2022/11/3 16:30
*/
public
static
List
<
String
>
getMinuteSectionArray
(
Integer
minutes
)
{
List
<
String
>
timeSegments
=
new
ArrayList
<>();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"HH:mm"
);
for
(
int
i
=
0
;
i
<
24
*
60
;
i
+=
minutes
)
{
Date
date
=
new
Date
();
date
.
setHours
(
i
/
60
);
date
.
setMinutes
(
i
%
60
);
timeSegments
.
add
(
sdf
.
format
(
date
));
}
return
timeSegments
;
}
}
wj-databus/src/main/resources/mapper/CrossDataHistMapper.xml
View file @
b94fb4dc
...
...
@@ -78,7 +78,7 @@
<select
id=
"selectMetricHistDTO"
resultType=
"net.wanji.databus.dto.MetricHistDTO"
>
select status, start_time, duration, flow, speed, sturation, stop_times, delay_time, batch_time
from t_cross_data_hist
where cross_id = #{crossId}
and status != 0
where cross_id = #{crossId}
and batch_time
<![CDATA[ >= ]]>
#{startStamp}
and batch_time
<![CDATA[ <= ]]>
#{endStamp}
order by batch_time
...
...
wj-databus/src/main/resources/mapper/CrossDirDataHistMapper.xml
View file @
b94fb4dc
...
...
@@ -110,7 +110,7 @@
<select
id=
"selectMetricHistDTO"
resultType=
"net.wanji.databus.dto.MetricHistDTO"
>
select status, start_time, duration, flow, speed, sturation, capacity, stop_times, delay_time, batch_time
from t_cross_dir_data_hist
where cross_id = #{crossId}
and status != 0
where cross_id = #{crossId}
and batch_time
<![CDATA[ >= ]]>
#{startStamp}
and batch_time
<![CDATA[ <= ]]>
#{endStamp}
order by batch_time
...
...
wj-databus/src/main/resources/mapper/CrossTurnDataHistMapper.xml
View file @
b94fb4dc
...
...
@@ -69,7 +69,7 @@
<select
id=
"selectMetricHistDTO"
resultType=
"net.wanji.databus.dto.MetricHistDTO"
>
select status, flow, speed, sturation, stop_times, delay_time, batch_time
from t_cross_turn_data_hist
where cross_id = #{crossId}
and status != 0
where cross_id = #{crossId}
and batch_time
<![CDATA[ >= ]]>
#{startStamp}
and batch_time
<![CDATA[ <= ]]>
#{endStamp}
order by batch_time
...
...
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