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
74779c9d
Commit
74779c9d
authored
Apr 11, 2020
by
赵建伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update codes
parent
901911a0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
8 deletions
+40
-8
CtrEstimatePfrOperator.java
...va/com/gmei/data/ctr/operator/CtrEstimatePfrOperator.java
+2
-3
CtrEstimatePfrMysqlSink.java
.../java/com/gmei/data/ctr/sink/CtrEstimatePfrMysqlSink.java
+38
-5
No files found.
src/main/java/com/gmei/data/ctr/operator/CtrEstimatePfrOperator.java
View file @
74779c9d
...
@@ -94,9 +94,8 @@ public class CtrEstimatePfrOperator implements BaseOperator{
...
@@ -94,9 +94,8 @@ public class CtrEstimatePfrOperator implements BaseOperator{
JSONObject
paramsObject
=
jsonObject
.
getJSONObject
(
"params"
);
JSONObject
paramsObject
=
jsonObject
.
getJSONObject
(
"params"
);
if
(
null
!=
paramsObject
)
{
if
(
null
!=
paramsObject
)
{
String
pageName
=
paramsObject
.
getString
(
"page_name"
);
String
pageName
=
paramsObject
.
getString
(
"page_name"
);
if
(
"diary_detail"
.
equals
(
pageName
)
if
(
"diary_detail"
.
equals
(
pageName
)
||
"diarybook_detail"
.
equals
(
pageName
)
||
"diarybook_detail"
.
equals
(
pageName
)
||
"user_post_detail"
.
equals
(
pageName
)
||
"post_detail"
.
equals
(
pageName
)
||
"topic_detail"
.
equals
(
pageName
)
||
"welfare_detail"
.
equals
(
pageName
)
||
"welfare_detail"
.
equals
(
pageName
)
||
"answer_detail"
.
equals
(
pageName
))
{
||
"answer_detail"
.
equals
(
pageName
))
{
String
businessId
=
paramsObject
.
getString
(
"business_id"
);
String
businessId
=
paramsObject
.
getString
(
"business_id"
);
...
...
src/main/java/com/gmei/data/ctr/sink/CtrEstimatePfrMysqlSink.java
View file @
74779c9d
...
@@ -39,7 +39,7 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
...
@@ -39,7 +39,7 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
@Override
@Override
public
void
invoke
(
DeviceCurrentEstimatePfrTmp
deviceCurrentEstimatePfrTmp
,
Context
context
)
throws
Exception
{
public
void
invoke
(
DeviceCurrentEstimatePfrTmp
deviceCurrentEstimatePfrTmp
,
Context
context
)
throws
Exception
{
try
{
try
{
insert
Or
Del
(
deviceCurrentEstimatePfrTmp
);
insert
And
Del
(
deviceCurrentEstimatePfrTmp
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
e
.
printStackTrace
();
e
.
printStackTrace
();
int
numReties
=
1
;
int
numReties
=
1
;
...
@@ -48,7 +48,7 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
...
@@ -48,7 +48,7 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
try
{
try
{
numReties
++;
numReties
++;
Thread
.
sleep
(
retryInteral
);
Thread
.
sleep
(
retryInteral
);
insert
Or
Del
(
deviceCurrentEstimatePfrTmp
);
insert
And
Del
(
deviceCurrentEstimatePfrTmp
);
}
catch
(
Exception
e1
){
}
catch
(
Exception
e1
){
lastException
=
e1
;
lastException
=
e1
;
continue
;
continue
;
...
@@ -65,11 +65,20 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
...
@@ -65,11 +65,20 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
}
}
/**
/**
* 数据写入方法
* 最近偏好持久化
* @param deviceCurrentEstimatePfrTmp
*/
private
void
insertAndDel
(
DeviceCurrentEstimatePfrTmp
deviceCurrentEstimatePfrTmp
)
{
insert
(
deviceCurrentEstimatePfrTmp
);
del
(
deviceCurrentEstimatePfrTmp
);
}
/**
* 插入最新数据
* @param deviceCurrentEstimatePfrTmp
* @param deviceCurrentEstimatePfrTmp
* @throws SQLException
* @throws SQLException
*/
*/
private
void
insert
OrDel
(
DeviceCurrentEstimatePfrTmp
deviceCurrentEstimatePfrTmp
)
{
private
void
insert
(
DeviceCurrentEstimatePfrTmp
deviceCurrentEstimatePfrTmp
)
{
Statement
statement
=
null
;
Statement
statement
=
null
;
java
.
util
.
Date
date
=
new
Date
();
java
.
util
.
Date
date
=
new
Date
();
try
{
try
{
...
@@ -104,6 +113,30 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
...
@@ -104,6 +113,30 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
DateUtils
.
getTimeStr
(
date
)
DateUtils
.
getTimeStr
(
date
)
)
)
);
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
finally
{
try
{
if
(
statement
!=
null
)
{
statement
.
close
();
}
if
(
connection
!=
null
)
{
connection
.
close
();
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
}
/**
* 删除过期数据
* @param deviceCurrentEstimatePfrTmp
*/
private
void
del
(
DeviceCurrentEstimatePfrTmp
deviceCurrentEstimatePfrTmp
)
{
Statement
statement
=
null
;
java
.
util
.
Date
date
=
new
Date
();
try
{
statement
.
executeUpdate
(
statement
.
executeUpdate
(
String
.
format
(
String
.
format
(
"delete from device_recently_estimate_view_pfr where "
+
"delete from device_recently_estimate_view_pfr where "
+
...
@@ -117,7 +150,7 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
...
@@ -117,7 +150,7 @@ public class CtrEstimatePfrMysqlSink extends RichSinkFunction<DeviceCurrentEstim
DateUtils
.
getSevenDaysAgoTimeStr
(
date
)
DateUtils
.
getSevenDaysAgoTimeStr
(
date
)
)
)
);
);
System
.
out
.
println
(
deviceCurrentEstimatePfrTmp
);
System
.
out
.
println
(
deviceCurrentEstimatePfrTmp
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
}
finally
{
...
...
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