Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
ZHHT-IRN-BD-ANALYSIS
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
李凯旋
ZHHT-IRN-BD-ANALYSIS
Commits
cea35adf
Commit
cea35adf
authored
Nov 03, 2022
by
余根龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加fast
parent
7c006f0b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
8 deletions
+135
-8
Location.java
...streaming/src/main/java/com/zhht/irn/entity/Location.java
+40
-0
Travel.java
...m-streaming/src/main/java/com/zhht/irn/entity/Travel.java
+52
-0
TravelInfoJob.java
...reaming/src/main/java/com/zhht/irn/job/TravelInfoJob.java
+43
-8
No files found.
realtime/hologram-streaming/src/main/java/com/zhht/irn/entity/Location.java
View file @
cea35adf
...
@@ -17,4 +17,44 @@ public class Location {
...
@@ -17,4 +17,44 @@ public class Location {
// 此时车辆所处的车道ID
// 此时车辆所处的车道ID
private
String
lineId
;
private
String
lineId
;
public
Double
getLongitude
()
{
return
longitude
;
}
public
void
setLongitude
(
Double
longitude
)
{
this
.
longitude
=
longitude
;
}
public
Double
getLatitude
()
{
return
latitude
;
}
public
void
setLatitude
(
Double
latitude
)
{
this
.
latitude
=
latitude
;
}
public
Double
getSpeed
()
{
return
speed
;
}
public
void
setSpeed
(
Double
speed
)
{
this
.
speed
=
speed
;
}
public
Date
getDtTranjectory
()
{
return
dtTranjectory
;
}
public
void
setDtTranjectory
(
Date
dtTranjectory
)
{
this
.
dtTranjectory
=
dtTranjectory
;
}
public
String
getLineId
()
{
return
lineId
;
}
public
void
setLineId
(
String
lineId
)
{
this
.
lineId
=
lineId
;
}
}
}
realtime/hologram-streaming/src/main/java/com/zhht/irn/entity/Travel.java
View file @
cea35adf
...
@@ -104,6 +104,17 @@ public class Travel {
...
@@ -104,6 +104,17 @@ public class Travel {
// 备注
// 备注
private
String
remark
;
private
String
remark
;
//实际停车次数
private
int
stopCount
;
//停车总时长
private
double
stopTime
;
//平均车速
private
double
aveSpeed
;
//最低速度
private
double
minSpeed
;
//最高速度
private
double
maxSpeed
;
public
Long
getId
()
{
public
Long
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -343,4 +354,44 @@ public class Travel {
...
@@ -343,4 +354,44 @@ public class Travel {
public
void
setRemark
(
String
remark
)
{
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
this
.
remark
=
remark
;
}
}
public
int
getStopCount
()
{
return
stopCount
;
}
public
void
setStopCount
(
int
stopCount
)
{
this
.
stopCount
=
stopCount
;
}
public
double
getStopTime
()
{
return
stopTime
;
}
public
void
setStopTime
(
double
stopTime
)
{
this
.
stopTime
=
stopTime
;
}
public
double
getAveSpeed
()
{
return
aveSpeed
;
}
public
void
setAveSpeed
(
double
aveSpeed
)
{
this
.
aveSpeed
=
aveSpeed
;
}
public
double
getMinSpeed
()
{
return
minSpeed
;
}
public
void
setMinSpeed
(
double
minSpeed
)
{
this
.
minSpeed
=
minSpeed
;
}
public
double
getMaxSpeed
()
{
return
maxSpeed
;
}
public
void
setMaxSpeed
(
double
maxSpeed
)
{
this
.
maxSpeed
=
maxSpeed
;
}
}
}
\ No newline at end of file
realtime/hologram-streaming/src/main/java/com/zhht/irn/job/TravelInfoJob.java
View file @
cea35adf
...
@@ -20,9 +20,7 @@ import org.slf4j.Logger;
...
@@ -20,9 +20,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
/**
/**
...
@@ -35,10 +33,8 @@ public class TravelInfoJob {
...
@@ -35,10 +33,8 @@ public class TravelInfoJob {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TravelInfoJob
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
TravelInfoJob
.
class
);
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// 获取流式运行环境
// 获取流式运行环境
StreamExecutionEnvironment
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
();
StreamExecutionEnvironment
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
();
// 获取Kafka配置文件
// 获取Kafka配置文件
ParameterTool
finkArgs
=
ParameterTool
.
fromArgs
(
args
);
ParameterTool
finkArgs
=
ParameterTool
.
fromArgs
(
args
);
String
kafkaConfigPath
=
finkArgs
.
getRequired
(
"kafka.conf"
);
String
kafkaConfigPath
=
finkArgs
.
getRequired
(
"kafka.conf"
);
...
@@ -81,9 +77,48 @@ public class TravelInfoJob {
...
@@ -81,9 +77,48 @@ public class TravelInfoJob {
@Override
@Override
public
Travel
map
(
String
s
)
throws
Exception
{
public
Travel
map
(
String
s
)
throws
Exception
{
// json 格式字符串转化为 TravelInfo 实体类
// json 格式字符串转化为 TravelInfo 实体类
Travel
travelInfo
=
JSON
.
parseObject
(
s
,
Travel
.
class
);
Travel
travel
=
JSON
.
parseObject
(
s
,
Travel
.
class
);
String
crossId
=
travel
.
getCrossId
();
return
null
;
String
recordId
=
travel
.
getRecordId
();
long
carId
=
travel
.
getCarId
();
List
<
Location
>
locations
=
travel
.
getLocations
();
//两个location之间的间隔时长0.1s
double
intervalTime
=
0.1
;
//停车次数
int
stopCount
=
0
;
//停车总时长
double
stopTime
=
0
;
//速度总和
double
totalSpeed
=
0
;
//速度数组
List
<
Double
>
speedList
=
new
ArrayList
<
Double
>();
//上一个location的速度,初始化取第一条数据
double
lastSpeed
=
locations
.
get
(
0
).
getSpeed
();
for
(
int
i
=
0
;
i
<
locations
.
size
();
i
++){
Location
location
=
locations
.
get
(
i
);
Double
speed
=
location
.
getSpeed
();
speedList
.
add
(
speed
);
if
(
speed
<=
3
){
if
(
lastSpeed
>
3
)
{
stopCount
=
stopCount
+
1
;
}
stopTime
=
stopTime
+
intervalTime
;
}
totalSpeed
=
totalSpeed
+
speed
;
lastSpeed
=
speed
;
}
//最大速度
double
maxSpeed
=
Collections
.
max
(
speedList
);
//最小速度,初始化0
double
minSpeed
=
Collections
.
min
(
speedList
);
//平均速度
double
aveSpeed
=
totalSpeed
/
locations
.
size
();
travel
.
setStopCount
(
stopCount
);
travel
.
setStopTime
(
stopTime
);
travel
.
setAveSpeed
(
aveSpeed
);
travel
.
setMaxSpeed
(
maxSpeed
);
travel
.
setMinSpeed
(
minSpeed
);
return
travel
;
}
}
}).
filter
(
new
FilterFunction
<
Travel
>()
{
}).
filter
(
new
FilterFunction
<
Travel
>()
{
@Override
@Override
...
...
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