Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wj-datacenter-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
jinan
wj-datacenter-platform
Commits
9b89cea1
Commit
9b89cea1
authored
Nov 15, 2023
by
xululu@wanji.net.cn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
程序优化
parent
a1375a7f
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
82 deletions
+92
-82
Constant.java
...src/main/java/com/wanji/indicators/constant/Constant.java
+5
-0
CarTrajectoryIndexMain.java
...ji/indicators/task/trajectory/CarTrajectoryIndexMain.java
+9
-12
Test2.java
...main/java/com/wanji/indicators/task/trajectory/Test2.java
+9
-3
PhaseEmptyTimeProcessFunction.java
...s/task/trajectory/func/PhaseEmptyTimeProcessFunction.java
+65
-64
VehicleGapTimeProcessFunction.java
...s/task/trajectory/func/VehicleGapTimeProcessFunction.java
+3
-2
config.properties
wj-realtime-computing/src/main/resources/config.properties
+1
-1
No files found.
wj-realtime-computing/src/main/java/com/wanji/indicators/constant/Constant.java
View file @
9b89cea1
...
...
@@ -73,6 +73,11 @@ public class Constant {
*/
public
static
int
CROSSING
=
1
;
/**
* 行人灯转向
*/
public
static
final
String
PEDESTRAIN_LIGHT_CODE
=
"20"
;
/**
* 入侵结果
*/
...
...
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/CarTrajectoryIndexMain.java
View file @
9b89cea1
...
...
@@ -468,13 +468,14 @@ public class CarTrajectoryIndexMain {
//计算溢出
SingleOutputStreamOperator
<
CarTrackModel
>
carTrackStreamInCrossRoad
=
frameModelStream
.
flatMap
(
new
CarTrackInCrossRoadFlatMap
())
SingleOutputStreamOperator
<
CarTrackModel
>
carTrackStreamInCrossRoad
=
frameModelStream
.
flatMap
(
new
CarTrackInCrossRoadFlatMap
())
.
setParallelism
(
1
)
.
name
(
"过滤出位于路口和指定路段区域带有车牌的车辆轨迹数据"
);
//计算1分钟内的路口溢出指数和是否死锁
double
avgSpeedEvaluationIndex
=
Double
.
parseDouble
(
properties
.
getProperty
(
"road.overflow.avg.speed"
));
String
durationEvaluationIndex
=
properties
.
getProperty
(
"road.overflow.duration"
);
int
durationEvaluationIndex
=
Integer
.
parseInt
(
properties
.
getProperty
(
"road.overflow.duration"
)
);
int
carNumber
=
Integer
.
parseInt
(
properties
.
getProperty
(
"cross.road.deadlock.car.number"
));
double
crossAvgSpeedIndex
=
Double
.
parseDouble
(
properties
.
getProperty
(
"cross.road.deadlock.avg.speed"
));
...
...
@@ -492,7 +493,7 @@ public class CarTrajectoryIndexMain {
//过滤出位于指定区域内的数据
List
<
CarTrackModel
>
carTracesInSpecificArea
=
carInCrossRoadList
.
stream
().
filter
(
car
->
car
.
getIsInSpecificArea
()
==
1
).
collect
(
Collectors
.
toList
());
List
<
CarTrackModel
>
carTracesInCrossRoad
=
carInCrossRoadList
.
stream
().
filter
(
car
->
car
.
getRoadnet
().
getInCrossFlag
()
==
1
).
collect
(
Collectors
.
toList
());
//根据路口进行
预取
划分
//根据路口进行
区域
划分
Map
<
String
,
List
<
CarTrackModel
>>
groupMapInExitArea
=
carTracesInSpecificArea
.
stream
().
collect
(
Collectors
.
groupingBy
(
car
->
car
.
getRoadnet
().
getRid
()));
//对每个路口区域进行统计
...
...
@@ -513,6 +514,7 @@ public class CarTrajectoryIndexMain {
map
.
put
(
timestamp
,
avgSpeed
);
});
//出口车道的平均速度
double
ridAvgSpeed
=
map
.
values
().
stream
().
mapToDouble
(
number
->
number
).
summaryStatistics
().
getAverage
();
List
<
Map
.
Entry
<
Long
,
Double
>>
entryList
=
map
.
entrySet
().
stream
().
sorted
(
Map
.
Entry
.
comparingByKey
()).
collect
(
Collectors
.
toList
());
...
...
@@ -528,7 +530,7 @@ public class CarTrajectoryIndexMain {
consecutiveSeconds
=
0
;
}
}
if
(
consecutiveSeconds
>
Integer
.
parseInt
(
durationEvaluationIndex
)
){
if
(
consecutiveSeconds
>
durationEvaluationIndex
){
//计算路口的溢出指数
double
index
=
30
/
ridAvgSpeed
;
if
(
index
>
5
){
...
...
@@ -537,7 +539,7 @@ public class CarTrajectoryIndexMain {
detail
.
setRid
(
rid
);
detail
.
setTimestamp
(
overflowTimestamp
);
detail
.
setDatetime
(
DateUtil
.
toDateTime
(
overflowTimestamp
,
DateUtil
.
YYYY_MM_DD_HH_MM_SS
));
detail
.
setIndex
(
index
);
detail
.
setIndex
(
Double
.
parseDouble
(
String
.
format
(
"%.2f"
,
index
))
);
details
.
add
(
detail
);
}
...
...
@@ -550,6 +552,7 @@ public class CarTrajectoryIndexMain {
OverFlowIndexResult
result
=
new
OverFlowIndexResult
();
result
.
setCrossId
(
crossId
);
result
.
setDetails
(
details
);
//溢出上报时间戳
result
.
setGlobalTimeStamp
(
context
.
window
().
getEnd
());
result
.
setDateTime
(
DateUtil
.
toDateTime
(
result
.
getGlobalTimeStamp
(),
DateUtil
.
YYYY_MM_DD_HH_MM_SS
));
result
.
setStartTime
(
context
.
window
().
getStart
());
...
...
@@ -559,13 +562,7 @@ public class CarTrajectoryIndexMain {
if
(
details
.
size
()
>=
2
){
Map
<
String
,
List
<
CarTrackModel
>>
groupMapByPlate
=
carTracesInCrossRoad
.
stream
().
collect
(
Collectors
.
groupingBy
(
CarTrackModel:
:
getPicLicense
));
if
(
groupMapByPlate
.
size
()
>
carNumber
){
AtomicReference
<
Double
>
totalCarSpeed
=
new
AtomicReference
<>((
double
)
0
);
groupMapByPlate
.
forEach
((
carPlate
,
traces
)
->
{
double
carAvgSpeed
=
traces
.
stream
().
mapToDouble
(
CarTrackModel:
:
getSpeed
).
summaryStatistics
().
getAverage
();
totalCarSpeed
.
updateAndGet
(
v
->
(
v
+
carAvgSpeed
));
});
double
crossAvgSpeed
=
totalCarSpeed
.
get
()
/
groupMapByPlate
.
size
();
double
crossAvgSpeed
=
carTracesInCrossRoad
.
stream
().
mapToDouble
(
CarTrackModel:
:
getSpeed
).
summaryStatistics
().
getAverage
();
if
(
crossAvgSpeed
<
crossAvgSpeedIndex
){
result
.
setDeadLock
(
true
);
}
...
...
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/Test2.java
View file @
9b89cea1
package
com
.
wanji
.
indicators
.
task
.
trajectory
;
import
java.util.UUID
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author : jenny
...
...
@@ -10,7 +12,11 @@ import java.util.UUID;
*/
public
class
Test2
{
public
static
void
main
(
String
[]
args
)
{
String
eventSerialNumber
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
System
.
out
.
println
(
eventSerialNumber
);
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
filteredList
=
list
.
stream
()
.
filter
(
element
->
element
.
length
()
>
4
)
.
collect
(
Collectors
.
toList
());
System
.
out
.
println
(
filteredList
.
size
());
}
}
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/func/PhaseEmptyTimeProcessFunction.java
View file @
9b89cea1
This diff is collapsed.
Click to expand it.
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/func/VehicleGapTimeProcessFunction.java
View file @
9b89cea1
...
...
@@ -55,6 +55,7 @@ public class VehicleGapTimeProcessFunction extends KeyedProcessFunction<String,
ridLightStatusList
.
stream
()
.
filter
(
o
->
Objects
.
nonNull
(
o
)
&&
!
StringUtils
.
isEmpty
(
o
.
getLampState
())
&&
o
.
getLampState
().
trim
().
equals
(
LightStatusEnum
.
GREEN
.
getType
()))
.
filter
(
o
->
o
.
getDir
()
==
1
||
o
.
getDir
()
==
4
||
o
.
getDir
()
==
5
)
//南北方向
.
filter
(
o
->
!
o
.
getTurn
().
equals
(
Constant
.
PEDESTRAIN_LIGHT_CODE
))
//非行人灯
.
collect
(
Collectors
.
groupingBy
(
CrossRidTurnLampStatusModel:
:
getDir
));
//存储当前南北方向绿灯结束的路口和绿灯时长
...
...
@@ -64,7 +65,7 @@ public class VehicleGapTimeProcessFunction extends KeyedProcessFunction<String,
for
(
String
key:
keys
){
String
[]
split
=
key
.
trim
().
split
(
"-"
);
int
dir
=
Integer
.
parseInt
(
split
[
1
]);
if
(
groupLightStatus
.
containsKey
(
dir
)){
if
(
!
groupLightStatus
.
containsKey
(
dir
)){
expiredGreenLightMap
.
put
(
dir
,
greenTotalTimeState
.
get
(
key
));
}
}
...
...
@@ -140,7 +141,7 @@ public class VehicleGapTimeProcessFunction extends KeyedProcessFunction<String,
VehicleHeadTimeModel
timeModel
=
new
VehicleHeadTimeModel
();
timeModel
.
setLaneId
(
laneId
);
timeModel
.
setCrossId
(
lastCar
.
getRoadnet
().
getCrossId
()
);
timeModel
.
setCrossId
(
crossId
);
timeModel
.
setRid
(
lastCar
.
getRoadnet
().
getRid
());
timeModel
.
setDir
(
dir
);
timeModel
.
setHeadTime
(
time
);
...
...
wj-realtime-computing/src/main/resources/config.properties
View file @
9b89cea1
...
...
@@ -56,7 +56,7 @@ north.south.rid.direction.list=13NG40B5SK013NI00B5RM00:1,13NEH0B5RJ013NGH0B5RC00
#路口溢出评价指标
road.overflow.avg.speed
=
5.0
road.overflow.duration
=
3
road.overflow.duration
=
3
000
road.overflow.deadlock.index.analysis.topic
=
crossroad.overflow.deadlock.index.analysis
#路口失衡topic
...
...
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