Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
ctr-estimate
Project
Project
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
赵建伟
ctr-estimate
Commits
06c8e414
Commit
06c8e414
authored
Apr 11, 2020
by
赵建伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update codes
parent
6d29fa3b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
101 additions
and
247 deletions
+101
-247
CtrPfrCrtBean.java
src/main/java/com/gmei/data/ctr/bean/CtrPfrCrtBean.java
+6
-6
CtrPfrRctBean.java
src/main/java/com/gmei/data/ctr/bean/CtrPfrRctBean.java
+0
-0
CtrPfrRctTmpBean.java
src/main/java/com/gmei/data/ctr/bean/CtrPfrRctTmpBean.java
+0
-145
TestCtrPfrCrtMain.java
src/main/java/com/gmei/data/ctr/main/TestCtrPfrCrtMain.java
+2
-1
CtrPfrCrtOperator.java
...in/java/com/gmei/data/ctr/operator/CtrPfrCrtOperator.java
+4
-7
CtrPfrRctOperator.java
...in/java/com/gmei/data/ctr/operator/CtrPfrRctOperator.java
+2
-2
CtrPfrCrtMysqlSink.java
src/main/java/com/gmei/data/ctr/sink/CtrPfrCrtMysqlSink.java
+18
-18
CtrPfrRctMysqlSink.java
src/main/java/com/gmei/data/ctr/sink/CtrPfrRctMysqlSink.java
+21
-21
JrAsyncPfrCrtSource.java
...in/java/com/gmei/data/ctr/source/JrAsyncPfrCrtSource.java
+21
-20
JrAsyncPfrRctSource.java
...in/java/com/gmei/data/ctr/source/JrAsyncPfrRctSource.java
+27
-27
No files found.
src/main/java/com/gmei/data/ctr/bean/CtrPfrCrt
Tmp
Bean.java
→
src/main/java/com/gmei/data/ctr/bean/CtrPfrCrtBean.java
View file @
06c8e414
...
...
@@ -6,7 +6,7 @@ package com.gmei.data.ctr.bean;
* @Date 2020/3/31
* @Version V1.0
**/
public
class
CtrPfrCrt
Tmp
Bean
{
public
class
CtrPfrCrtBean
{
private
String
deviceId
;
private
String
statisticsType
;
private
String
statisticsTypeId
;
...
...
@@ -20,10 +20,10 @@ public class CtrPfrCrtTmpBean {
private
String
partitionDate
;
private
String
lastUpdateTime
;
public
CtrPfrCrt
Tmp
Bean
(
String
deviceId
,
String
statisticsType
,
String
statisticsTypeId
,
String
projectPfr
,
String
firstDemandsPfr
,
String
firstPositionsPfr
,
String
firstSolutionsPfr
,
String
secondDemandsPfr
,
String
secondPositionsPfr
,
String
secondSolutionsPfr
,
String
partitionDate
,
String
lastUpdateTime
)
{
public
CtrPfrCrtBean
(
String
deviceId
,
String
statisticsType
,
String
statisticsTypeId
,
String
projectPfr
,
String
firstDemandsPfr
,
String
firstPositionsPfr
,
String
firstSolutionsPfr
,
String
secondDemandsPfr
,
String
secondPositionsPfr
,
String
secondSolutionsPfr
,
String
partitionDate
,
String
lastUpdateTime
)
{
this
.
deviceId
=
deviceId
;
this
.
statisticsType
=
statisticsType
;
this
.
statisticsTypeId
=
statisticsTypeId
;
...
...
@@ -38,7 +38,7 @@ public class CtrPfrCrtTmpBean {
this
.
lastUpdateTime
=
lastUpdateTime
;
}
public
CtrPfrCrt
Tmp
Bean
()
{
public
CtrPfrCrtBean
()
{
}
public
String
getDeviceId
()
{
...
...
src/main/java/com/gmei/data/ctr/bean/CtrPfrRctBean.java
View file @
06c8e414
This diff is collapsed.
Click to expand it.
src/main/java/com/gmei/data/ctr/bean/CtrPfrRctTmpBean.java
deleted
100644 → 0
View file @
6d29fa3b
package
com
.
gmei
.
data
.
ctr
.
bean
;
/**
* @ClassName DeviceCurrentEstimatePfrTmp
* @Author apple
* @Date 2020/3/31
* @Version V1.0
**/
public
class
CtrPfrRctTmpBean
{
private
String
deviceId
;
private
String
statisticsType
;
private
String
statisticsTypeId
;
private
String
projectPfr
;
private
String
firstDemandsPfr
;
private
String
firstPositionsPfr
;
private
String
firstSolutionsPfr
;
private
String
secondDemandsPfr
;
private
String
secondPositionsPfr
;
private
String
secondSolutionsPfr
;
private
String
lastUpdateTime
;
public
CtrPfrRctTmpBean
(
String
deviceId
,
String
statisticsType
,
String
statisticsTypeId
,
String
projectPfr
,
String
firstDemandsPfr
,
String
firstPositionsPfr
,
String
firstSolutionsPfr
,
String
secondDemandsPfr
,
String
secondPositionsPfr
,
String
secondSolutionsPfr
,
String
lastUpdateTime
)
{
this
.
deviceId
=
deviceId
;
this
.
statisticsType
=
statisticsType
;
this
.
statisticsTypeId
=
statisticsTypeId
;
this
.
projectPfr
=
projectPfr
;
this
.
firstDemandsPfr
=
firstDemandsPfr
;
this
.
firstPositionsPfr
=
firstPositionsPfr
;
this
.
firstSolutionsPfr
=
firstSolutionsPfr
;
this
.
secondDemandsPfr
=
secondDemandsPfr
;
this
.
secondPositionsPfr
=
secondPositionsPfr
;
this
.
secondSolutionsPfr
=
secondSolutionsPfr
;
this
.
lastUpdateTime
=
lastUpdateTime
;
}
public
CtrPfrRctTmpBean
()
{
}
public
String
getDeviceId
()
{
return
deviceId
;
}
public
void
setDeviceId
(
String
deviceId
)
{
this
.
deviceId
=
deviceId
;
}
public
String
getStatisticsType
()
{
return
statisticsType
;
}
public
void
setStatisticsType
(
String
statisticsType
)
{
this
.
statisticsType
=
statisticsType
;
}
public
String
getStatisticsTypeId
()
{
return
statisticsTypeId
;
}
public
void
setStatisticsTypeId
(
String
statisticsTypeId
)
{
this
.
statisticsTypeId
=
statisticsTypeId
;
}
public
String
getProjectPfr
()
{
return
projectPfr
;
}
public
void
setProjectPfr
(
String
projectPfr
)
{
this
.
projectPfr
=
projectPfr
;
}
public
String
getFirstDemandsPfr
()
{
return
firstDemandsPfr
;
}
public
void
setFirstDemandsPfr
(
String
firstDemandsPfr
)
{
this
.
firstDemandsPfr
=
firstDemandsPfr
;
}
public
String
getFirstPositionsPfr
()
{
return
firstPositionsPfr
;
}
public
void
setFirstPositionsPfr
(
String
firstPositionsPfr
)
{
this
.
firstPositionsPfr
=
firstPositionsPfr
;
}
public
String
getFirstSolutionsPfr
()
{
return
firstSolutionsPfr
;
}
public
void
setFirstSolutionsPfr
(
String
firstSolutionsPfr
)
{
this
.
firstSolutionsPfr
=
firstSolutionsPfr
;
}
public
String
getSecondDemandsPfr
()
{
return
secondDemandsPfr
;
}
public
void
setSecondDemandsPfr
(
String
secondDemandsPfr
)
{
this
.
secondDemandsPfr
=
secondDemandsPfr
;
}
public
String
getSecondPositionsPfr
()
{
return
secondPositionsPfr
;
}
public
void
setSecondPositionsPfr
(
String
secondPositionsPfr
)
{
this
.
secondPositionsPfr
=
secondPositionsPfr
;
}
public
String
getSecondSolutionsPfr
()
{
return
secondSolutionsPfr
;
}
public
void
setSecondSolutionsPfr
(
String
secondSolutionsPfr
)
{
this
.
secondSolutionsPfr
=
secondSolutionsPfr
;
}
public
String
getLastUpdateTime
()
{
return
lastUpdateTime
;
}
public
void
setLastUpdateTime
(
String
lastUpdateTime
)
{
this
.
lastUpdateTime
=
lastUpdateTime
;
}
@Override
public
String
toString
()
{
return
"DeviceCurrentEstimatePfrTmp{"
+
"deviceId='"
+
deviceId
+
'\''
+
", statisticsType='"
+
statisticsType
+
'\''
+
", statisticsTypeId='"
+
statisticsTypeId
+
'\''
+
", projectPfr='"
+
projectPfr
+
'\''
+
", firstDemandsPfr='"
+
firstDemandsPfr
+
'\''
+
", firstPositionsPfr='"
+
firstPositionsPfr
+
'\''
+
", firstSolutionsPfr='"
+
firstSolutionsPfr
+
'\''
+
", secondDemandsPfr='"
+
secondDemandsPfr
+
'\''
+
", secondPositionsPfr='"
+
secondPositionsPfr
+
'\''
+
", secondSolutionsPfr='"
+
secondSolutionsPfr
+
'\''
+
", lastUpdateTime='"
+
lastUpdateTime
+
'\''
+
'}'
;
}
}
src/main/java/com/gmei/data/ctr/main/TestCtrPfrCrtMain.java
View file @
06c8e414
package
com
.
gmei
.
data
.
ctr
.
main
;
import
com.gmei.data.ctr.operator.CtrPfrCrtOperator
;
import
com.gmei.data.ctr.operator.CtrPfrRctOperator
;
import
com.gmei.data.ctr.source.MaidianKafkaSource
;
import
org.apache.flink.api.java.utils.ParameterTool
;
...
...
@@ -56,7 +57,7 @@ public class TestCtrPfrCrtMain {
startTime
).
getInstance
();
// 执行处理核心逻辑
new
CtrPfr
Rc
tOperator
(
new
CtrPfr
Cr
tOperator
(
MaidianDataStream
,
outJdbcUrl
,
maxRetry
,
...
...
src/main/java/com/gmei/data/ctr/operator/CtrPfrCrtOperator.java
View file @
06c8e414
...
...
@@ -3,12 +3,9 @@ package com.gmei.data.ctr.operator;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gmei.data.ctr.bean.CtrPfrCrtEtlBean
;
import
com.gmei.data.ctr.bean.CtrPfrCrtTmpBean
;
import
com.gmei.data.ctr.bean.CtrPfrRctEtlBean
;
import
com.gmei.data.ctr.bean.CtrPfrRctTmpBean
;
import
com.gmei.data.ctr.bean.CtrPfrCrtBean
;
import
com.gmei.data.ctr.sink.CtrPfrCrtMysqlSink
;
import
com.gmei.data.ctr.sink.CtrPfrRctMysqlSink
;
import
com.gmei.data.ctr.source.JrAsyncPfrRctSource
;
import
com.gmei.data.ctr.source.JrAsyncPfrCrtSource
;
import
com.gmei.data.ctr.utils.DateUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.flink.api.common.functions.FilterFunction
;
...
...
@@ -154,8 +151,8 @@ public class CtrPfrCrtOperator implements BaseOperator{
return
ctrPfrCrtEtlBean
;
}
}).
setParallelism
(
parallelism
);
DataStream
<
CtrPfrCrt
Tmp
Bean
>
tidbAsyncDataStream
=
AsyncDataStream
.
unorderedWait
(
map02
,
new
JrAsyncPfr
Rc
tSource
(
jerryJdbcUrl
,
jerryUsername
,
jerryPassword
),
1
,
TimeUnit
.
MINUTES
,
1000
)
DataStream
<
CtrPfrCrtBean
>
tidbAsyncDataStream
=
AsyncDataStream
.
unorderedWait
(
map02
,
new
JrAsyncPfr
Cr
tSource
(
jerryJdbcUrl
,
jerryUsername
,
jerryPassword
),
1
,
TimeUnit
.
MINUTES
,
1000
)
.
uid
(
"tidbAsyncDataStream"
)
.
setParallelism
(
parallelism
);
...
...
src/main/java/com/gmei/data/ctr/operator/CtrPfrRctOperator.java
View file @
06c8e414
...
...
@@ -3,7 +3,7 @@ package com.gmei.data.ctr.operator;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gmei.data.ctr.bean.CtrPfrRctEtlBean
;
import
com.gmei.data.ctr.bean.CtrPfrRct
Tmp
Bean
;
import
com.gmei.data.ctr.bean.CtrPfrRctBean
;
import
com.gmei.data.ctr.sink.CtrPfrRctMysqlSink
;
import
com.gmei.data.ctr.source.JrAsyncPfrRctSource
;
import
com.gmei.data.ctr.utils.DateUtils
;
...
...
@@ -154,7 +154,7 @@ public class CtrPfrRctOperator implements BaseOperator{
}
}).
setParallelism
(
parallelism
);
//map.print();
DataStream
<
CtrPfrRct
Tmp
Bean
>
tidbAsyncDataStream
=
AsyncDataStream
DataStream
<
CtrPfrRctBean
>
tidbAsyncDataStream
=
AsyncDataStream
.
unorderedWait
(
map02
,
new
JrAsyncPfrRctSource
(
jerryJdbcUrl
,
jerryUsername
,
jerryPassword
),
1
,
TimeUnit
.
MINUTES
,
1000
)
.
uid
(
"tidbAsyncDataStream"
)
.
setParallelism
(
parallelism
);
...
...
src/main/java/com/gmei/data/ctr/sink/CtrPfrCrtMysqlSink.java
View file @
06c8e414
package
com
.
gmei
.
data
.
ctr
.
sink
;
import
com.gmei.data.ctr.bean.CtrPfrCrt
Tmp
Bean
;
import
com.gmei.data.ctr.bean.CtrPfrCrtBean
;
import
com.gmei.data.ctr.common.Constants
;
import
com.gmei.data.ctr.utils.DateUtils
;
import
com.gmei.data.ctr.utils.JDBCUtils
;
...
...
@@ -20,7 +20,7 @@ import java.util.Date;
* @Date 2020/3/31
* @Version V1.0
**/
public
class
CtrPfrCrtMysqlSink
extends
RichSinkFunction
<
CtrPfrCrt
Tmp
Bean
>
{
public
class
CtrPfrCrtMysqlSink
extends
RichSinkFunction
<
CtrPfrCrtBean
>
{
private
int
maxRetry
;
private
long
retryInteral
;
private
String
jdbcUrl
;
...
...
@@ -37,9 +37,9 @@ public class CtrPfrCrtMysqlSink extends RichSinkFunction<CtrPfrCrtTmpBean> {
super
.
open
(
parameters
);
}
@Override
public
void
invoke
(
CtrPfrCrt
TmpBean
ctrPfrCrtTmp
Bean
,
Context
context
)
throws
Exception
{
public
void
invoke
(
CtrPfrCrt
Bean
ctrPfrCrt
Bean
,
Context
context
)
throws
Exception
{
try
{
insertAndDel
(
ctrPfrCrt
Tmp
Bean
);
insertAndDel
(
ctrPfrCrtBean
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
int
numReties
=
1
;
...
...
@@ -48,7 +48,7 @@ public class CtrPfrCrtMysqlSink extends RichSinkFunction<CtrPfrCrtTmpBean> {
try
{
numReties
++;
Thread
.
sleep
(
retryInteral
);
insertAndDel
(
ctrPfrCrt
Tmp
Bean
);
insertAndDel
(
ctrPfrCrtBean
);
}
catch
(
Exception
e1
){
lastException
=
e1
;
continue
;
...
...
@@ -66,13 +66,13 @@ public class CtrPfrCrtMysqlSink extends RichSinkFunction<CtrPfrCrtTmpBean> {
/**
* 插入最新数据
* @param ctrPfrCrt
Tmp
Bean
* @param ctrPfrCrtBean
* @throws SQLException
*/
private
void
insertAndDel
(
CtrPfrCrt
TmpBean
ctrPfrCrtTmp
Bean
)
{
private
void
insertAndDel
(
CtrPfrCrt
Bean
ctrPfrCrt
Bean
)
{
Statement
statement
=
null
;
Date
date
=
new
Date
();
if
(
null
!=
ctrPfrCrt
Tmp
Bean
){
if
(
null
!=
ctrPfrCrtBean
){
try
{
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
...
...
@@ -91,16 +91,16 @@ public class CtrPfrCrtMysqlSink extends RichSinkFunction<CtrPfrCrtTmpBean> {
"partition_date,"
+
"last_update_time"
+
") values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')"
,
ctrPfrCrt
Tmp
Bean
.
getDeviceId
(),
ctrPfrCrt
Tmp
Bean
.
getStatisticsType
(),
ctrPfrCrt
Tmp
Bean
.
getStatisticsTypeId
(),
ctrPfrCrt
Tmp
Bean
.
getProjectPfr
(),
ctrPfrCrt
Tmp
Bean
.
getFirstDemandsPfr
(),
ctrPfrCrt
Tmp
Bean
.
getFirstPositionsPfr
(),
ctrPfrCrt
Tmp
Bean
.
getFirstSolutionsPfr
(),
ctrPfrCrt
Tmp
Bean
.
getSecondDemandsPfr
(),
ctrPfrCrt
Tmp
Bean
.
getSecondPositionsPfr
(),
ctrPfrCrt
Tmp
Bean
.
getSecondSolutionsPfr
(),
ctrPfrCrtBean
.
getDeviceId
(),
ctrPfrCrtBean
.
getStatisticsType
(),
ctrPfrCrtBean
.
getStatisticsTypeId
(),
ctrPfrCrtBean
.
getProjectPfr
(),
ctrPfrCrtBean
.
getFirstDemandsPfr
(),
ctrPfrCrtBean
.
getFirstPositionsPfr
(),
ctrPfrCrtBean
.
getFirstSolutionsPfr
(),
ctrPfrCrtBean
.
getSecondDemandsPfr
(),
ctrPfrCrtBean
.
getSecondPositionsPfr
(),
ctrPfrCrtBean
.
getSecondSolutionsPfr
(),
DateUtils
.
getDateStr
(
date
),
DateUtils
.
getTimeStr
(
date
)
)
...
...
src/main/java/com/gmei/data/ctr/sink/CtrPfrRctMysqlSink.java
View file @
06c8e414
package
com
.
gmei
.
data
.
ctr
.
sink
;
import
com.gmei.data.ctr.bean.CtrPfrRct
Tmp
Bean
;
import
com.gmei.data.ctr.bean.CtrPfrRctBean
;
import
com.gmei.data.ctr.common.Constants
;
import
com.gmei.data.ctr.utils.DateUtils
;
import
com.gmei.data.ctr.utils.JDBCUtils
;
...
...
@@ -20,7 +20,7 @@ import java.util.Date;
* @Date 2020/3/31
* @Version V1.0
**/
public
class
CtrPfrRctMysqlSink
extends
RichSinkFunction
<
CtrPfrRct
Tmp
Bean
>
{
public
class
CtrPfrRctMysqlSink
extends
RichSinkFunction
<
CtrPfrRctBean
>
{
private
int
maxRetry
;
private
long
retryInteral
;
private
String
jdbcUrl
;
...
...
@@ -37,9 +37,9 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctTmpBean> {
super
.
open
(
parameters
);
}
@Override
public
void
invoke
(
CtrPfrRct
TmpBean
ctrPfrRctTmp
Bean
,
Context
context
)
throws
Exception
{
public
void
invoke
(
CtrPfrRct
Bean
ctrPfrRct
Bean
,
Context
context
)
throws
Exception
{
try
{
insertAndDel
(
ctrPfrRct
Tmp
Bean
);
insertAndDel
(
ctrPfrRctBean
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
int
numReties
=
1
;
...
...
@@ -48,7 +48,7 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctTmpBean> {
try
{
numReties
++;
Thread
.
sleep
(
retryInteral
);
insertAndDel
(
ctrPfrRct
Tmp
Bean
);
insertAndDel
(
ctrPfrRctBean
);
}
catch
(
Exception
e1
){
lastException
=
e1
;
continue
;
...
...
@@ -66,13 +66,13 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctTmpBean> {
/**
* 插入最新数据
* @param ctrPfrRct
Tmp
Bean
* @param ctrPfrRctBean
* @throws SQLException
*/
private
void
insertAndDel
(
CtrPfrRct
TmpBean
ctrPfrRctTmp
Bean
)
{
private
void
insertAndDel
(
CtrPfrRct
Bean
ctrPfrRct
Bean
)
{
Statement
statement
=
null
;
Date
date
=
new
Date
();
if
(
null
!=
ctrPfrRct
Tmp
Bean
){
if
(
null
!=
ctrPfrRctBean
){
try
{
statement
=
connection
.
createStatement
();
statement
.
executeUpdate
(
...
...
@@ -90,16 +90,16 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctTmpBean> {
"second_solutions_pfr,"
+
"last_update_time"
+
") values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')"
,
ctrPfrRct
Tmp
Bean
.
getDeviceId
(),
ctrPfrRct
Tmp
Bean
.
getStatisticsType
(),
ctrPfrRct
Tmp
Bean
.
getStatisticsTypeId
(),
ctrPfrRct
Tmp
Bean
.
getProjectPfr
(),
ctrPfrRct
Tmp
Bean
.
getFirstDemandsPfr
(),
ctrPfrRct
Tmp
Bean
.
getFirstPositionsPfr
(),
ctrPfrRct
Tmp
Bean
.
getFirstSolutionsPfr
(),
ctrPfrRct
Tmp
Bean
.
getSecondDemandsPfr
(),
ctrPfrRct
Tmp
Bean
.
getSecondPositionsPfr
(),
ctrPfrRct
Tmp
Bean
.
getSecondSolutionsPfr
(),
ctrPfrRctBean
.
getDeviceId
(),
ctrPfrRctBean
.
getStatisticsType
(),
ctrPfrRctBean
.
getStatisticsTypeId
(),
ctrPfrRctBean
.
getProjectPfr
(),
ctrPfrRctBean
.
getFirstDemandsPfr
(),
ctrPfrRctBean
.
getFirstPositionsPfr
(),
ctrPfrRctBean
.
getFirstSolutionsPfr
(),
ctrPfrRctBean
.
getSecondDemandsPfr
(),
ctrPfrRctBean
.
getSecondPositionsPfr
(),
ctrPfrRctBean
.
getSecondSolutionsPfr
(),
DateUtils
.
getTimeStr
(
date
)
)
);
...
...
@@ -110,9 +110,9 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctTmpBean> {
"statistics_type = '%s' and "
+
"statistics_type_id = '%s' and "
+
"last_update_time <= '%s'"
,
ctrPfrRct
Tmp
Bean
.
getDeviceId
(),
ctrPfrRct
Tmp
Bean
.
getStatisticsType
(),
ctrPfrRct
Tmp
Bean
.
getStatisticsTypeId
(),
ctrPfrRctBean
.
getDeviceId
(),
ctrPfrRctBean
.
getStatisticsType
(),
ctrPfrRctBean
.
getStatisticsTypeId
(),
DateUtils
.
getSevenDaysAgoTimeStr
(
date
)
)
);
...
...
src/main/java/com/gmei/data/ctr/source/JrAsyncPfrCrtSource.java
View file @
06c8e414
...
...
@@ -2,7 +2,7 @@ package com.gmei.data.ctr.source;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.gmei.data.ctr.bean.CtrPfrRctEtlBean
;
import
com.gmei.data.ctr.bean.CtrPfrRct
Tmp
Bean
;
import
com.gmei.data.ctr.bean.CtrPfrRctBean
;
import
com.gmei.data.ctr.common.Constants
;
import
com.gmei.data.ctr.utils.DateUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -28,7 +28,7 @@ import static java.util.concurrent.Executors.newFixedThreadPool;
* @Date 2020/3/29
* @Version V1.0
**/
public
class
JrAsyncPfrCrtSource
extends
RichAsyncFunction
<
CtrPfrRctEtlBean
,
CtrPfrRct
Tmp
Bean
>
{
public
class
JrAsyncPfrCrtSource
extends
RichAsyncFunction
<
CtrPfrRctEtlBean
,
CtrPfrRctBean
>
{
private
String
jerryJdbcUrl
;
private
String
jerryUsername
;
private
String
jerryPassword
;
...
...
@@ -54,20 +54,20 @@ public class JrAsyncPfrCrtSource extends RichAsyncFunction<CtrPfrRctEtlBean, Ctr
dataSource
.
setMaxActive
(
20
);
}
@Override
public
void
asyncInvoke
(
CtrPfrRctEtlBean
ctrPfrRctEtlBean
,
ResultFuture
<
CtrPfrRct
Tmp
Bean
>
resultFuture
)
throws
Exception
{
Future
<
CtrPfrRct
Tmp
Bean
>
future
=
executorService
.
submit
(()
->
{
public
void
asyncInvoke
(
CtrPfrRctEtlBean
ctrPfrRctEtlBean
,
ResultFuture
<
CtrPfrRctBean
>
resultFuture
)
throws
Exception
{
Future
<
CtrPfrRctBean
>
future
=
executorService
.
submit
(()
->
{
return
queryFromMySql
(
ctrPfrRctEtlBean
);
});
CompletableFuture
.
supplyAsync
(
new
Supplier
<
CtrPfrRct
Tmp
Bean
>()
{
CompletableFuture
.
supplyAsync
(
new
Supplier
<
CtrPfrRctBean
>()
{
@Override
public
CtrPfrRct
Tmp
Bean
get
()
{
public
CtrPfrRctBean
get
()
{
try
{
return
future
.
get
();
}
catch
(
Exception
e
)
{
return
null
;
}
}
}).
thenAccept
((
CtrPfrRct
Tmp
Bean
dbResult
)
->{
}).
thenAccept
((
CtrPfrRctBean
dbResult
)
->{
resultFuture
.
complete
(
Collections
.
singleton
(
dbResult
));
});
}
...
...
@@ -81,8 +81,8 @@ public class JrAsyncPfrCrtSource extends RichAsyncFunction<CtrPfrRctEtlBean, Ctr
}
}
private
CtrPfrRct
Tmp
Bean
queryFromMySql
(
CtrPfrRctEtlBean
ctrPfrRctEtlBean
)
{
CtrPfrRct
Tmp
Bean
dcept
=
null
;
private
CtrPfrRctBean
queryFromMySql
(
CtrPfrRctEtlBean
ctrPfrRctEtlBean
)
{
CtrPfrRctBean
dcept
=
null
;
String
statisticsType
=
ctrPfrRctEtlBean
.
getStatisticsType
();
String
deviceId
=
ctrPfrRctEtlBean
.
getDeviceId
();
String
statisticsTypeId
=
ctrPfrRctEtlBean
.
getStatisticsTypeId
();
...
...
@@ -115,8 +115,8 @@ public class JrAsyncPfrCrtSource extends RichAsyncFunction<CtrPfrRctEtlBean, Ctr
return
dcept
;
}
private
CtrPfrRct
Tmp
Bean
findTagInfo
(
String
sql
,
CtrPfrRctEtlBean
ctrPfrRctEtlBean
){
CtrPfrRct
TmpBean
ctrPfrRctTmp
Bean
=
null
;
private
CtrPfrRctBean
findTagInfo
(
String
sql
,
CtrPfrRctEtlBean
ctrPfrRctEtlBean
){
CtrPfrRct
Bean
ctrPfrRct
Bean
=
null
;
Connection
connection
=
null
;
PreparedStatement
stmt
=
null
;
ResultSet
rs
=
null
;
...
...
@@ -125,14 +125,14 @@ public class JrAsyncPfrCrtSource extends RichAsyncFunction<CtrPfrRctEtlBean, Ctr
stmt
=
connection
.
prepareStatement
(
sql
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
()){
ctrPfrRct
TmpBean
=
new
CtrPfrRctTmp
Bean
();
ctrPfrRct
Tmp
Bean
.
setProjectPfr
(
rs
.
getString
(
"project_tags"
));
ctrPfrRct
Tmp
Bean
.
setFirstDemandsPfr
(
rs
.
getString
(
"first_demands"
));
ctrPfrRct
Tmp
Bean
.
setFirstPositionsPfr
(
rs
.
getString
(
"first_positions"
));
ctrPfrRct
Tmp
Bean
.
setFirstSolutionsPfr
(
rs
.
getString
(
"first_solutions"
));
ctrPfrRct
Tmp
Bean
.
setSecondDemandsPfr
(
rs
.
getString
(
"second_demands"
));
ctrPfrRct
Tmp
Bean
.
setSecondPositionsPfr
(
rs
.
getString
(
"second_positions"
));
ctrPfrRct
Tmp
Bean
.
setSecondSolutionsPfr
(
rs
.
getString
(
"second_solutions"
));
ctrPfrRct
Bean
=
new
CtrPfrRct
Bean
();
ctrPfrRctBean
.
setProjectPfr
(
rs
.
getString
(
"project_tags"
));
ctrPfrRctBean
.
setFirstDemandsPfr
(
rs
.
getString
(
"first_demands"
));
ctrPfrRctBean
.
setFirstPositionsPfr
(
rs
.
getString
(
"first_positions"
));
ctrPfrRctBean
.
setFirstSolutionsPfr
(
rs
.
getString
(
"first_solutions"
));
ctrPfrRctBean
.
setSecondDemandsPfr
(
rs
.
getString
(
"second_demands"
));
ctrPfrRctBean
.
setSecondPositionsPfr
(
rs
.
getString
(
"second_positions"
));
ctrPfrRctBean
.
setSecondSolutionsPfr
(
rs
.
getString
(
"second_solutions"
));
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
...
...
@@ -151,6 +151,6 @@ public class JrAsyncPfrCrtSource extends RichAsyncFunction<CtrPfrRctEtlBean, Ctr
e
.
printStackTrace
();
}
}
return
ctrPfrRct
Tmp
Bean
;
return
ctrPfrRctBean
;
}
}
\ No newline at end of file
src/main/java/com/gmei/data/ctr/source/JrAsyncPfrRctSource.java
View file @
06c8e414
...
...
@@ -2,9 +2,9 @@ package com.gmei.data.ctr.source;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.gmei.data.ctr.bean.CtrPfrCrtEtlBean
;
import
com.gmei.data.ctr.bean.CtrPfrCrtTmpBean
;
import
com.gmei.data.ctr.bean.CtrPfrCrtBean
;
import
com.gmei.data.ctr.bean.CtrPfrRctBean
;
import
com.gmei.data.ctr.bean.CtrPfrRctEtlBean
;
import
com.gmei.data.ctr.bean.CtrPfrRctTmpBean
;
import
com.gmei.data.ctr.common.Constants
;
import
com.gmei.data.ctr.utils.DateUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -30,7 +30,7 @@ import static java.util.concurrent.Executors.newFixedThreadPool;
* @Date 2020/3/29
* @Version V1.0
**/
public
class
JrAsyncPfrRctSource
extends
RichAsyncFunction
<
CtrPfr
CrtEtlBean
,
CtrPfrCrtTmp
Bean
>
{
public
class
JrAsyncPfrRctSource
extends
RichAsyncFunction
<
CtrPfr
RctEtlBean
,
CtrPfrRct
Bean
>
{
private
String
jerryJdbcUrl
;
private
String
jerryUsername
;
private
String
jerryPassword
;
...
...
@@ -56,20 +56,20 @@ public class JrAsyncPfrRctSource extends RichAsyncFunction<CtrPfrCrtEtlBean, Ctr
dataSource
.
setMaxActive
(
20
);
}
@Override
public
void
asyncInvoke
(
CtrPfr
CrtEtlBean
ctrPfrCrtEtlBean
,
ResultFuture
<
CtrPfrCrtTmp
Bean
>
resultFuture
)
throws
Exception
{
Future
<
CtrPfr
CrtTmp
Bean
>
future
=
executorService
.
submit
(()
->
{
return
queryFromMySql
(
ctrPfr
Cr
tEtlBean
);
public
void
asyncInvoke
(
CtrPfr
RctEtlBean
ctrPfrRctEtlBean
,
ResultFuture
<
CtrPfrRct
Bean
>
resultFuture
)
throws
Exception
{
Future
<
CtrPfr
Rct
Bean
>
future
=
executorService
.
submit
(()
->
{
return
queryFromMySql
(
ctrPfr
Rc
tEtlBean
);
});
CompletableFuture
.
supplyAsync
(
new
Supplier
<
CtrPfr
CrtTmp
Bean
>()
{
CompletableFuture
.
supplyAsync
(
new
Supplier
<
CtrPfr
Rct
Bean
>()
{
@Override
public
CtrPfr
CrtTmp
Bean
get
()
{
public
CtrPfr
Rct
Bean
get
()
{
try
{
return
future
.
get
();
}
catch
(
Exception
e
)
{
return
null
;
}
}
}).
thenAccept
((
CtrPfr
CrtTmp
Bean
dbResult
)
->{
}).
thenAccept
((
CtrPfr
Rct
Bean
dbResult
)
->{
resultFuture
.
complete
(
Collections
.
singleton
(
dbResult
));
});
}
...
...
@@ -83,11 +83,11 @@ public class JrAsyncPfrRctSource extends RichAsyncFunction<CtrPfrCrtEtlBean, Ctr
}
}
private
CtrPfr
CrtTmpBean
queryFromMySql
(
CtrPfrCrtEtlBean
ctrPfrCr
tEtlBean
)
{
CtrPfr
CrtTmp
Bean
dcept
=
null
;
String
statisticsType
=
ctrPfr
Cr
tEtlBean
.
getStatisticsType
();
String
deviceId
=
ctrPfr
Cr
tEtlBean
.
getDeviceId
();
String
statisticsTypeId
=
ctrPfr
Cr
tEtlBean
.
getStatisticsTypeId
();
private
CtrPfr
RctBean
queryFromMySql
(
CtrPfrRctEtlBean
ctrPfrRc
tEtlBean
)
{
CtrPfr
Rct
Bean
dcept
=
null
;
String
statisticsType
=
ctrPfr
Rc
tEtlBean
.
getStatisticsType
();
String
deviceId
=
ctrPfr
Rc
tEtlBean
.
getDeviceId
();
String
statisticsTypeId
=
ctrPfr
Rc
tEtlBean
.
getStatisticsTypeId
();
if
(
statisticsType
!=
null
&&
deviceId
!=
null
&&
statisticsTypeId
!=
null
){
String
sql
=
""
;
if
(
"service"
.
equals
(
statisticsType
)){
...
...
@@ -104,13 +104,12 @@ public class JrAsyncPfrRctSource extends RichAsyncFunction<CtrPfrCrtEtlBean, Ctr
"from strategy_answer_tagv3_info where content_id = '%s'"
,
statisticsTypeId
);
}
if
(
StringUtils
.
isNotBlank
(
sql
)){
dcept
=
findTagInfo
(
sql
,
ctrPfr
Cr
tEtlBean
);
dcept
=
findTagInfo
(
sql
,
ctrPfr
Rc
tEtlBean
);
if
(
null
!=
dcept
){
Date
date
=
new
Date
();
dcept
.
setDeviceId
(
deviceId
);
dcept
.
setStatisticsType
(
statisticsType
);
dcept
.
setStatisticsTypeId
(
statisticsTypeId
);
dcept
.
setPartitionDate
(
DateUtils
.
getDateStr
(
date
));
dcept
.
setLastUpdateTime
(
DateUtils
.
getTimeStr
(
date
));
}
}
...
...
@@ -118,8 +117,8 @@ public class JrAsyncPfrRctSource extends RichAsyncFunction<CtrPfrCrtEtlBean, Ctr
return
dcept
;
}
private
CtrPfr
CrtTmpBean
findTagInfo
(
String
sql
,
CtrPfrCrtEtlBean
ctrPfrCr
tEtlBean
){
CtrPfr
CrtTmpBean
ctrPfrCrtTmp
Bean
=
null
;
private
CtrPfr
RctBean
findTagInfo
(
String
sql
,
CtrPfrRctEtlBean
ctrPfrRc
tEtlBean
){
CtrPfr
RctBean
ctrPfrRct
Bean
=
null
;
Connection
connection
=
null
;
PreparedStatement
stmt
=
null
;
ResultSet
rs
=
null
;
...
...
@@ -128,14 +127,14 @@ public class JrAsyncPfrRctSource extends RichAsyncFunction<CtrPfrCrtEtlBean, Ctr
stmt
=
connection
.
prepareStatement
(
sql
);
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
()){
ctrPfr
CrtTmpBean
=
new
CtrPfrCrtTmp
Bean
();
ctrPfr
CrtTmp
Bean
.
setProjectPfr
(
rs
.
getString
(
"project_tags"
));
ctrPfr
CrtTmp
Bean
.
setFirstDemandsPfr
(
rs
.
getString
(
"first_demands"
));
ctrPfr
CrtTmp
Bean
.
setFirstPositionsPfr
(
rs
.
getString
(
"first_positions"
));
ctrPfr
CrtTmp
Bean
.
setFirstSolutionsPfr
(
rs
.
getString
(
"first_solutions"
));
ctrPfr
CrtTmp
Bean
.
setSecondDemandsPfr
(
rs
.
getString
(
"second_demands"
));
ctrPfr
CrtTmp
Bean
.
setSecondPositionsPfr
(
rs
.
getString
(
"second_positions"
));
ctrPfr
CrtTmp
Bean
.
setSecondSolutionsPfr
(
rs
.
getString
(
"second_solutions"
));
ctrPfr
RctBean
=
new
CtrPfrRct
Bean
();
ctrPfr
Rct
Bean
.
setProjectPfr
(
rs
.
getString
(
"project_tags"
));
ctrPfr
Rct
Bean
.
setFirstDemandsPfr
(
rs
.
getString
(
"first_demands"
));
ctrPfr
Rct
Bean
.
setFirstPositionsPfr
(
rs
.
getString
(
"first_positions"
));
ctrPfr
Rct
Bean
.
setFirstSolutionsPfr
(
rs
.
getString
(
"first_solutions"
));
ctrPfr
Rct
Bean
.
setSecondDemandsPfr
(
rs
.
getString
(
"second_demands"
));
ctrPfr
Rct
Bean
.
setSecondPositionsPfr
(
rs
.
getString
(
"second_positions"
));
ctrPfr
Rct
Bean
.
setSecondSolutionsPfr
(
rs
.
getString
(
"second_solutions"
));
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
...
...
@@ -154,6 +153,6 @@ public class JrAsyncPfrRctSource extends RichAsyncFunction<CtrPfrCrtEtlBean, Ctr
e
.
printStackTrace
();
}
}
return
ctrPfr
CrtTmp
Bean
;
return
ctrPfr
Rct
Bean
;
}
}
\ No newline at end of file
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