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
d4287251
Commit
d4287251
authored
May 11, 2024
by
duanruiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
aa67a4c4
ef4813aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
43 deletions
+44
-43
MatchResultDataMain.java
...s/task/citybrain/matchresultdata/MatchResultDataMain.java
+2
-2
TargetInfoReceiveMain.java
...sk/citybrainreceive/targetinfo/TargetInfoReceiveMain.java
+15
-14
CarTrajectoryIndexMain.java
...ji/indicators/task/trajectory/CarTrajectoryIndexMain.java
+27
-27
No files found.
wj-realtime-computing/src/main/java/com/wanji/indicators/task/citybrain/matchresultdata/MatchResultDataMain.java
View file @
d4287251
...
...
@@ -21,7 +21,6 @@ import org.apache.kafka.common.serialization.StringDeserializer;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Properties
;
...
...
@@ -103,6 +102,7 @@ public class MatchResultDataMain {
List
<
TargetInfoVO
>
targetInfoVOList
=
new
ArrayList
<>();
String
orgCode
=
frameModel
.
getOrgCode
();
Long
globalTimeStamp
=
frameModel
.
getGlobalTimeStamp
();
for
(
CarTrackModel
participant
:
participantList
)
{
TargetInfoVO
targetInfoVO
=
new
TargetInfoVO
();
...
...
@@ -123,7 +123,7 @@ public class MatchResultDataMain {
targetInfoVO
.
setLaneNo
(
Integer
.
parseInt
(
s
));
}
targetInfoVO
.
setData_time
(
new
Date
().
getTime
()
);
targetInfoVO
.
setData_time
(
globalTimeStamp
);
targetInfoVO
.
setDeviceNo
(
orgCode
);
targetInfoVO
.
setId
(
participant
.
getId
());
targetInfoVO
.
setCarType
(
CarTypeConverter
.
convertWanjiToBrain
(
participant
.
getOriginalType
()));
...
...
wj-realtime-computing/src/main/java/com/wanji/indicators/task/citybrainreceive/targetinfo/TargetInfoReceiveMain.java
View file @
d4287251
...
...
@@ -12,14 +12,15 @@ import org.apache.flink.connector.kafka.source.reader.deserializer.KafkaRecordDe
import
org.apache.flink.streaming.api.datastream.DataStream
;
import
org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator
;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.api.functions.windowing.AllWindowFunction
;
import
org.apache.flink.streaming.api.windowing.assigners.Tumbling
Processing
TimeWindows
;
import
org.apache.flink.streaming.api.functions.windowing.
Process
AllWindowFunction
;
import
org.apache.flink.streaming.api.windowing.assigners.Tumbling
Event
TimeWindows
;
import
org.apache.flink.streaming.api.windowing.time.Time
;
import
org.apache.flink.streaming.api.windowing.windows.TimeWindow
;
import
org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer
;
import
org.apache.flink.util.Collector
;
import
org.apache.kafka.common.serialization.StringDeserializer
;
import
java.time.Duration
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.StreamSupport
;
...
...
@@ -63,27 +64,27 @@ public class TargetInfoReceiveMain {
SingleOutputStreamOperator
<
TargetInfoReceiveModel
>
frameModelStream
=
stream
.
map
(
new
TargetInfoReceiveMap
())
.
name
(
"接收城市大脑轨迹数据-JsonToObject"
)
//
.assignTimestampsAndWatermarks(
//
WatermarkStrategy
// .<TargetInfoReceiveModel>forBoundedOutOfOrderness(Duration.ofMillis(50
))
//
.withTimestampAssigner((element, recordTimestamp)
//
-> element.getBody().get(0).getData_time())
//
)
.
assignTimestampsAndWatermarks
(
WatermarkStrategy
.<
TargetInfoReceiveModel
>
forBoundedOutOfOrderness
(
Duration
.
ofSeconds
(
6
))
.
withTimestampAssigner
((
element
,
recordTimestamp
)
->
element
.
getBody
().
get
(
0
).
getData_time
())
)
;
SingleOutputStreamOperator
<
E1FrameMiniVO
>
resultStream
=
frameModelStream
//
.windowAll(TumblingEventTimeWindows.of(Time.milliseconds(100)))
.
windowAll
(
TumblingProcessingTimeWindows
.
of
(
Time
.
milliseconds
(
100
)))
.
apply
(
new
AllWindowFunction
<
TargetInfoReceiveModel
,
E1FrameMiniVO
,
TimeWindow
>()
{
.
windowAll
(
TumblingEventTimeWindows
.
of
(
Time
.
milliseconds
(
100
)))
//
.windowAll(TumblingProcessingTimeWindows.of(Time.milliseconds(100)))
.
process
(
new
Process
AllWindowFunction
<
TargetInfoReceiveModel
,
E1FrameMiniVO
,
TimeWindow
>()
{
@Override
public
void
apply
(
TimeWindow
window
,
Iterable
<
TargetInfoReceiveModel
>
values
,
Collector
<
E1FrameMiniVO
>
out
)
throws
Exception
{
public
void
process
(
Context
context
,
Iterable
<
TargetInfoReceiveModel
>
elements
,
Collector
<
E1FrameMiniVO
>
out
)
throws
Exception
{
E1FrameMiniVO
e1FrameMiniVO
=
new
E1FrameMiniVO
();
TimeWindow
window
=
context
.
window
();
long
windowEnd
=
window
.
getEnd
();
Date
date
=
new
Date
(
windowEnd
);
e1FrameMiniVO
.
setTimeStamp
(
date
);
e1FrameMiniVO
.
setGlobalTimeStamp
(
windowEnd
);
List
<
E1FrameParticipantMiniVO
>
participantMiniVOList
=
buildE1FrameParticipant
(
value
s
);
List
<
E1FrameParticipantMiniVO
>
participantMiniVOList
=
buildE1FrameParticipant
(
element
s
);
e1FrameMiniVO
.
setE1FrameParticipant
(
participantMiniVOList
);
e1FrameMiniVO
.
setOrgCode
(
""
);
e1FrameMiniVO
.
setParticipantNum
(
participantMiniVOList
.
size
());
...
...
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/CarTrajectoryIndexMain.java
View file @
d4287251
...
...
@@ -758,33 +758,33 @@ public class CarTrajectoryIndexMain {
.
name
(
"将失衡事件写入mysql"
);
SingleOutputStreamOperator
<
LineCongestion
>
lineCongestion
=
splitCongestionStream
.
keyBy
(
value
->
"constantKey"
)
.
process
(
new
LineCongestionFunction
())
.
setParallelism
(
1
)
.
name
(
"计算干线拥堵事件"
);
SingleOutputStreamOperator
<
LineCongestion
>
lineCongestionDuration
=
lineCongestion
.
keyBy
(
value
->
"constantKey"
)
.
process
(
new
LineCongestionDuration
())
.
setParallelism
(
1
)
.
name
(
"给干线拥堵事件添加开始时间和持续时长"
);
SingleOutputStreamOperator
<
String
>
lineCongestionResult
=
lineCongestionDuration
.
flatMap
(
new
FlatMapFunction
<
LineCongestion
,
String
>()
{
@Override
public
void
flatMap
(
LineCongestion
result
,
Collector
<
String
>
collector
)
{
String
value
=
JSONObject
.
toJSONString
(
result
);
collector
.
collect
(
value
);
}
})
.
setParallelism
(
1
).
name
(
"将干线拥堵事件转成json字符串"
);
lineCongestionResult
.
addSink
(
new
FlinkKafkaProducer
<
String
>(
kafkaServerAddress
,
lineSinkTopic
,
new
SimpleStringSchema
()
)).
setParallelism
(
1
).
name
(
"将
将干线拥堵事件发送至kafka"
);
//
SingleOutputStreamOperator<LineCongestion> lineCongestion = splitCongestionStream
//
.keyBy(value -> "constantKey")
//
.process(new LineCongestionFunction())
//
.setParallelism(1)
//
.name("计算干线拥堵事件");
//
//
SingleOutputStreamOperator<LineCongestion> lineCongestionDuration = lineCongestion
//
.keyBy(value -> "constantKey")
//
.process(new LineCongestionDuration())
//
.setParallelism(1)
//
.name("给干线拥堵事件添加开始时间和持续时长");
//
//
SingleOutputStreamOperator<String> lineCongestionResult = lineCongestionDuration
//
.flatMap(new FlatMapFunction<LineCongestion, String>() {
//
@Override
//
public void flatMap(LineCongestion result, Collector<String> collector) {
//
String value = JSONObject.toJSONString(result);
//
collector.collect(value);
//
}
//
})
//
.setParallelism(1).name("将干线拥堵事件转成json字符串");
//
//
lineCongestionResult.addSink(new FlinkKafkaProducer<String>(
//
kafkaServerAddress,
//
lineSinkTopic,
//
new SimpleStringSchema()
// )).setParallelism(1).name("
将干线拥堵事件发送至kafka");
env
.
execute
(
"计算拥堵-溢出-失衡-死锁-相位空放"
);
}
catch
(
Exception
e
)
{
...
...
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