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
9bf58b0b
Commit
9bf58b0b
authored
Nov 17, 2022
by
余根龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化周期时长为0时报错
parent
edee39b8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
GreenRadioJob.java
...reaming/src/main/java/com/zhht/irn/job/GreenRadioJob.java
+10
-2
GreenRadioSink.java
...aming/src/main/java/com/zhht/irn/sink/GreenRadioSink.java
+3
-3
No files found.
realtime/hologram-streaming/src/main/java/com/zhht/irn/job/GreenRadioJob.java
View file @
9bf58b0b
...
@@ -22,7 +22,7 @@ public class GreenRadioJob {
...
@@ -22,7 +22,7 @@ public class GreenRadioJob {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
StreamExecutionEnvironment
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
();
StreamExecutionEnvironment
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
();
FlinkUtils
.
createKafkaStream
(
args
,
env
,
"signal_cycle_data"
)
FlinkUtils
.
createKafkaStream
(
args
,
env
,
"signal_cycle_data"
,
"greenRadioJob"
)
.
map
(
record
->
{
.
map
(
record
->
{
// 字符串解析为实体类
// 字符串解析为实体类
Cycle
cycle
=
JSON
.
parseObject
(
record
,
Cycle
.
class
);
Cycle
cycle
=
JSON
.
parseObject
(
record
,
Cycle
.
class
);
...
@@ -49,7 +49,15 @@ public class GreenRadioJob {
...
@@ -49,7 +49,15 @@ public class GreenRadioJob {
int
phaseValidGreen
=
green
+
yellow
+
allRed
-
phaseLossTime
;
int
phaseValidGreen
=
green
+
yellow
+
allRed
-
phaseLossTime
;
// 阶段绿信比 = 阶段有效绿灯时间/周期时长
// 阶段绿信比 = 阶段有效绿灯时间/周期时长
double
phaseGreenRatio
=
Double
.
valueOf
(
phaseValidGreen
)
/
cycle
.
getDuration
();
Integer
duration
=
cycle
.
getDuration
();
System
.
out
.
println
(
"********duration:"
+
duration
);
double
phaseGreenRatio
=
0
;
if
(
duration
!=
null
&&
duration
!=
0
){
phaseGreenRatio
=
Double
.
valueOf
(
phaseValidGreen
)
/
duration
;
}
if
(
duration
==
0
)
{
System
.
out
.
println
(
"********phaseGreenRatio:"
+
phaseGreenRatio
);
}
//组装阶段绿信比、有效绿灯时间、损失时间
//组装阶段绿信比、有效绿灯时间、损失时间
stage
.
setGreenRatio
(
phaseGreenRatio
);
stage
.
setGreenRatio
(
phaseGreenRatio
);
stage
.
setValidGreen
(
phaseValidGreen
);
stage
.
setValidGreen
(
phaseValidGreen
);
...
...
realtime/hologram-streaming/src/main/java/com/zhht/irn/sink/GreenRadioSink.java
View file @
9bf58b0b
...
@@ -28,8 +28,8 @@ public class GreenRadioSink extends RichSinkFunction<Cycle> {
...
@@ -28,8 +28,8 @@ public class GreenRadioSink extends RichSinkFunction<Cycle> {
public
void
open
(
Configuration
parameters
)
throws
Exception
{
public
void
open
(
Configuration
parameters
)
throws
Exception
{
super
.
open
(
parameters
);
super
.
open
(
parameters
);
// path暂定为固定值
// path暂定为固定值
String
path
=
"F:\\workspace\\ZHHT-IRN-BD-ANALYSIS
\\realtime\\hologram-streaming\\src\\main\\resources\\mysql.properties"
;
//String path = ".
\\realtime\\hologram-streaming\\src\\main\\resources\\mysql.properties";
connection
=
MySQLUtils
.
getConnection
(
path
);
connection
=
MySQLUtils
.
getConnection
();
String
cycleSql
=
"insert into app_cycle_green_ratio"
+
String
cycleSql
=
"insert into app_cycle_green_ratio"
+
"(id,cross_code,signal_code,begin_time,end_time,duration,cycle_order,green_ratio,loss_time,update_time) "
+
"(id,cross_code,signal_code,begin_time,end_time,duration,cycle_order,green_ratio,loss_time,update_time) "
+
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
;
"values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
;
...
@@ -63,7 +63,7 @@ public class GreenRadioSink extends RichSinkFunction<Cycle> {
...
@@ -63,7 +63,7 @@ public class GreenRadioSink extends RichSinkFunction<Cycle> {
for
(
int
i
=
0
;
i
<
stageList
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
stageList
.
size
();
i
++){
Stage
phase
=
stageList
.
get
(
i
);
Stage
phase
=
stageList
.
get
(
i
);
insertPhasePstmt
.
setLong
(
1
,
cycle
.
getCycleOrder
());
insertPhasePstmt
.
setLong
(
1
,
cycle
.
getCycleOrder
());
insertPhasePstmt
.
setString
(
2
,
phas
e
.
getCrossCode
());
insertPhasePstmt
.
setString
(
2
,
cycl
e
.
getCrossCode
());
insertPhasePstmt
.
setString
(
3
,
phase
.
getPhaseValue
());
insertPhasePstmt
.
setString
(
3
,
phase
.
getPhaseValue
());
insertPhasePstmt
.
setString
(
4
,
cycle
.
getBeginDateTime
());
insertPhasePstmt
.
setString
(
4
,
cycle
.
getBeginDateTime
());
insertPhasePstmt
.
setString
(
5
,
cycle
.
getEndDateTime
());
insertPhasePstmt
.
setString
(
5
,
cycle
.
getEndDateTime
());
...
...
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