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
eee551f9
Commit
eee551f9
authored
Dec 09, 2024
by
zhoushiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
路口服务水平加权计算
parent
2dbbce32
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
42 deletions
+93
-42
ServiceLevelEnum.java
...rc/main/java/net/wanji/opt/constant/ServiceLevelEnum.java
+54
-0
GreenwaveHistProviderImpl.java
...net/wanji/opt/service/impl/GreenwaveHistProviderImpl.java
+3
-3
RunningEvaluateServiceImpl.java
...et/wanji/opt/service/impl/RunningEvaluateServiceImpl.java
+31
-38
CrossDataRealtimePO.java
...c/main/java/net/wanji/databus/po/CrossDataRealtimePO.java
+4
-0
CrossDataRealtimeMapper.xml
...bus/src/main/resources/mapper/CrossDataRealtimeMapper.xml
+1
-1
No files found.
signal-optimize-service/src/main/java/net/wanji/opt/constant/ServiceLevelEnum.java
0 → 100644
View file @
eee551f9
package
net
.
wanji
.
opt
.
constant
;
/**
* @ClassName ServiceLevelEnum
* @Description
* @Date 2021/4/15 11:13
* @Version 1.0
*/
public
enum
ServiceLevelEnum
{
CROSS_PHASE_EMPTY
(
"A"
,
1
),
CROSS_UNBALANCE
(
"B"
,
2
),
CROSS_OVERFLOW
(
"C"
,
3
),
CROSS_DEADLOCK
(
"D"
,
4
),
GREEN_WAVE_SLOW_RUN
(
"E"
,
5
),
GREEN_WAVE_CONGEST
(
"F"
,
6
),
;
String
type
;
Integer
val
;
ServiceLevelEnum
(
String
type
,
Integer
val
)
{
this
.
type
=
type
;
this
.
val
=
val
;
}
public
String
getType
(){
return
type
;
}
public
Integer
getVal
()
{
return
val
;
}
public
static
ServiceLevelEnum
getByType
(
String
type
){
for
(
ServiceLevelEnum
abnormalEnum
:
ServiceLevelEnum
.
values
())
{
if
(
abnormalEnum
.
getType
().
equals
(
type
)){
return
abnormalEnum
;
}
}
return
null
;
}
public
static
ServiceLevelEnum
getByVal
(
Integer
type
){
for
(
ServiceLevelEnum
abnormalEnum
:
ServiceLevelEnum
.
values
())
{
if
(
abnormalEnum
.
getVal
().
equals
(
type
)){
return
abnormalEnum
;
}
}
return
null
;
}
}
signal-optimize-service/src/main/java/net/wanji/opt/service/impl/GreenwaveHistProviderImpl.java
View file @
eee551f9
...
...
@@ -288,9 +288,9 @@ public class GreenwaveHistProviderImpl extends BaseDubboInterfaceImpl<GreenwaveH
}
int
totalTime
=
Seconds
.
secondsBetween
(
startDateTime
,
endDateTime
).
getSeconds
();
for
(
GreenWaveRunStateVO
vo
:
list
)
{
if
(
vo
.
getDuration
()<=
0
)
{
vo
.
setDuration
(
getRandomValue
(
totalTime
/
10
,
120
));
}
//
if (vo.getDuration()<=0) {
//
vo.setDuration(getRandomValue(totalTime / 10, 120));
//
}
vo
.
setTotalTime
(
totalTime
);
}
...
...
signal-optimize-service/src/main/java/net/wanji/opt/service/impl/RunningEvaluateServiceImpl.java
View file @
eee551f9
...
...
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
net.wanji.common.enums.CrossStatusEnum
;
...
...
@@ -23,11 +24,13 @@ import net.wanji.databus.po.BaseCrossInfoPO;
import
net.wanji.databus.po.CrossDataHistPO
;
import
net.wanji.databus.po.CrossTurnInfoPO
;
import
net.wanji.databus.po.LaneInfoPO
;
import
net.wanji.databus.po.TBaseCrossInfo
;
import
net.wanji.databus.vo.RunningEvaluateCrossListVO
;
import
net.wanji.opt.bo.CrossNameBO
;
import
net.wanji.opt.bo.MetricsDetailBO
;
import
net.wanji.opt.common.KafkaConsumerUtil
;
import
net.wanji.opt.constant.EventAbnormalEnum
;
import
net.wanji.opt.constant.ServiceLevelEnum
;
import
net.wanji.opt.dto.PhaseEmptyResult
;
import
net.wanji.opt.service.GreenwaveHistProvider
;
import
net.wanji.opt.service.RunningEvaluateService
;
...
...
@@ -150,54 +153,44 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
String
crossId
=
bo
.
getCrossId
();
List
<
CrossDataHistPO
>
crossDataHistPOList
=
buildCrossDataHistPOList
(
bo
,
crossId
);
for
(
CrossDataHistPO
po
:
crossDataHistPOList
)
{
//历史未存服务水平字段数据置为A,否则分组报异常
po
.
setServiceLevel
(
po
.
getServiceLevel
()==
null
?
"A"
:
po
.
getServiceLevel
());
}
String
startTime
=
net
.
wanji
.
common
.
utils
.
tool
.
DateUtil
.
formatDate
(
bo
.
getStartDate
(),
"yyyy-MM-dd HH:mm:ss"
);
String
endTime
=
net
.
wanji
.
common
.
utils
.
tool
.
DateUtil
.
formatDate
(
bo
.
getEndDate
(),
"yyyy-MM-dd HH:mm:ss"
);
List
<
GreenWaveRunStateVO
>
runStateList
=
greenwaveHistProvider
.
findGreenWaveRunState
(
null
,
bo
.
getCrossId
(),
startTime
,
endTime
,
"701,702,703"
);
Map
<
Integer
,
GreenWaveRunStateVO
>
groupList
=
runStateList
.
stream
().
collect
(
Collectors
.
toMap
(
o
->
o
.
getState
(),
o
->
o
));
// 服务水平
double
sumA
=
crossDataHistPOList
.
stream
()
.
filter
(
po
->
isInTimeRange
(
po
.
getBatchTime
()))
.
mapToDouble
(
po
->
po
.
getFlow
()
*
po
.
getSturation
())
.
sum
();
String
startTime
=
net
.
wanji
.
common
.
utils
.
tool
.
DateUtil
.
formatDate
(
bo
.
getStartDate
(),
"yyyy-MM-dd HH:mm:ss"
);
String
endTime
=
net
.
wanji
.
common
.
utils
.
tool
.
DateUtil
.
formatDate
(
bo
.
getEndDate
(),
"yyyy-MM-dd HH:mm:ss"
);
int
sumB
=
crossDataHistPOList
.
stream
()
.
filter
(
po
->
isInTimeRange
(
po
.
getBatchTime
()))
.
mapToInt
(
CrossDataHistPO:
:
getFlow
)
.
sum
();
//按服务水平分组
Map
<
String
,
List
<
CrossDataHistPO
>>
groupByServerLevel
=
crossDataHistPOList
.
stream
().
collect
(
Collectors
.
groupingBy
(
o
->
o
.
getServiceLevel
()));
double
total
=
0
;
for
(
Map
.
Entry
<
String
,
List
<
CrossDataHistPO
>>
entry1
:
groupByServerLevel
.
entrySet
())
{
String
key
=
entry1
.
getKey
();
total
+=
ServiceLevelEnum
.
getByType
(
key
).
getVal
()
*
entry1
.
getValue
().
size
();
}
int
avgService
=
(
int
)
Math
.
round
(
total
/
crossDataHistPOList
.
size
());
String
serviceLevel
=
ServiceLevelEnum
.
getByVal
(
avgService
).
getType
();
double
saturation
=
sumA
/
sumB
;
String
serviceLevel
=
CrossUtil
.
getServiceLevel
(
saturation
);
vo
.
setServiceLevel
(
serviceLevel
);
// *******************************************************************************************************//
List
<
GreenWaveRunStateVO
>
runStateList
=
greenwaveHistProvider
.
findGreenWaveRunState
(
null
,
bo
.
getCrossId
(),
startTime
,
endTime
,
"701,702,703"
);
Map
<
Integer
,
GreenWaveRunStateVO
>
groupList
=
runStateList
.
stream
().
collect
(
Collectors
.
toMap
(
o
->
o
.
getState
(),
o
->
o
));
// List<CrossDataHistPO> congestionEventList = buildCongestionEvents(crossDataHistPOList); // 获取拥堵事件集合
// vo.setCongestionTimes(congestionEventList.size());
// int congestionSum = congestionEventList.stream()
// .filter(Objects::nonNull)
// .map(CrossDataHistPO::getDuration)
// .filter(Objects::nonNull)
// .mapToInt(Integer::intValue)
// .sum();
// vo.setCongestionSum(congestionSum);
vo
.
setUnbalanceTimes
(
groupList
.
get
(
EventAbnormalEnum
.
CROSS_UNBALANCE
.
getType
())
==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_UNBALANCE
.
getType
()).
getCount
());
int
unbalanceSum
=
groupList
.
get
(
EventAbnormalEnum
.
CROSS_UNBALANCE
.
getType
())
==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_UNBALANCE
.
getType
()).
getDuration
();
vo
.
setUnbalanceSum
(
Math
.
round
(
unbalanceSum
/
60
));
vo
.
set
UnbalanceTimes
(
groupList
.
get
(
EventAbnormalEnum
.
CROSS_UNBALANCE
.
getType
())==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_UNBALANCE
.
getType
()).
getCount
());
int
unbalanceSum
=
groupList
.
get
(
EventAbnormalEnum
.
CROSS_UNBALANCE
.
getType
())==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_UNBALANCE
.
getType
()).
getDuration
();
vo
.
set
UnbalanceSum
(
unbalanceSum
);
vo
.
set
SpilloverTimes
(
groupList
.
get
(
EventAbnormalEnum
.
CROSS_OVERFLOW
.
getType
())
==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_OVERFLOW
.
getType
()).
getCount
());
int
spilloverSum
=
groupList
.
get
(
EventAbnormalEnum
.
CROSS_OVERFLOW
.
getType
())
==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_OVERFLOW
.
getType
()).
getDuration
();
vo
.
set
SpilloverSum
(
Math
.
round
(
spilloverSum
/
60
)
);
vo
.
setSpilloverTimes
(
groupList
.
get
(
EventAbnormalEnum
.
CROSS_OVERFLOW
.
getType
())==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_OVERFLOW
.
getType
()).
getCount
());
int
spilloverSum
=
groupList
.
get
(
EventAbnormalEnum
.
CROSS_OVERFLOW
.
getType
())==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_OVERFLOW
.
getType
()).
getDuration
();
vo
.
setSpilloverSum
(
spilloverSum
);
int
emptyPhaseCount
=
groupList
.
get
(
EventAbnormalEnum
.
CROSS_PHASE_EMPTY
.
getType
())==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_PHASE_EMPTY
.
getType
()).
getCount
();
int
emptyPhaseSum
=
groupList
.
get
(
EventAbnormalEnum
.
CROSS_PHASE_EMPTY
.
getType
())==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_PHASE_EMPTY
.
getType
()).
getDuration
();
int
emptyPhaseCount
=
groupList
.
get
(
EventAbnormalEnum
.
CROSS_PHASE_EMPTY
.
getType
())
==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_PHASE_EMPTY
.
getType
()).
getCount
();
int
emptyPhaseSum
=
groupList
.
get
(
EventAbnormalEnum
.
CROSS_PHASE_EMPTY
.
getType
())
==
null
?
0
:
groupList
.
get
(
EventAbnormalEnum
.
CROSS_PHASE_EMPTY
.
getType
()).
getDuration
();
vo
.
setEmptyPhaseTimes
(
emptyPhaseCount
);
vo
.
setEmptyPhaseSum
(
emptyPhaseSum
);
vo
.
setEmptyPhaseSum
(
Math
.
round
(
emptyPhaseSum
/
60
)
);
// *******************************************************************************************************//
return
vo
;
}
...
...
wj-databus/src/main/java/net/wanji/databus/po/CrossDataRealtimePO.java
View file @
eee551f9
...
...
@@ -211,4 +211,8 @@ public class CrossDataRealtimePO {
@ApiModelProperty
(
value
=
"是否空放 0否 1是"
,
notes
=
""
)
@TableField
(
"empty_pass"
)
private
Integer
emptyPass
;
@ApiModelProperty
(
value
=
"服务水平[A-F]"
,
notes
=
""
)
@TableField
(
"service_level"
)
private
String
serviceLevel
;
}
wj-databus/src/main/resources/mapper/CrossDataRealtimeMapper.xml
View file @
eee551f9
...
...
@@ -125,7 +125,7 @@
</select>
<select
id=
"selectByCrossName"
resultType=
"net.wanji.databus.vo.RunningEvaluateCrossListVO"
>
select t1.cross_id as crossId, t1.sturation as sturation, t2.name as crossName, t1.
congestion_index
select t1.cross_id as crossId, t1.sturation as sturation, t2.name as crossName, t1.
traffic_index congestionIndex, t1.service_level serviceLevel
from t_cross_data_realtime t1 join t_base_cross_info t2 on t1.cross_id = t2.id and t2.is_signal = 1
<where>
<if
test=
"crossName != null and crossName != ''"
>
...
...
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