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
6ff8b6a8
Commit
6ff8b6a8
authored
Apr 14, 2020
by
赵建伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update codes
parent
c638a07c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
11 deletions
+21
-11
CtrPfrRctMysqlSink.java
src/main/java/com/gmei/data/ctr/sink/CtrPfrRctMysqlSink.java
+11
-7
DateUtil.java
src/main/java/com/gmei/data/ctr/utils/DateUtil.java
+9
-3
StringUtil.java
src/main/java/com/gmei/data/ctr/utils/StringUtil.java
+1
-1
No files found.
src/main/java/com/gmei/data/ctr/sink/CtrPfrRctMysqlSink.java
View file @
6ff8b6a8
...
...
@@ -272,7 +272,7 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctBean> {
"second_solutions_pfr_recent3,"
+
"second_solutions_pfr_recent10,"
+
"pfr_recent10_queue_info,"
+
"last_update_time
,
"
+
"last_update_time"
+
") values ('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s',"
+
"'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')"
,
deviceId
,
...
...
@@ -316,12 +316,16 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctBean> {
LinkedList
<
PfrRecentInfo
>
newQueue
=
new
LinkedList
<>();
Map
<
String
,
Integer
>
pfrMap
=
StringUtil
.
transString2Map
(
pfrStr
);
for
(
PfrRecentInfo
pfrRecentInfo
:
oldQueue
)
{
String
pfrName
=
pfrRecentInfo
.
getPfrName
();
Integer
pfrCount
=
pfrRecentInfo
.
getPfrCount
();
if
(
pfrMap
.
keySet
().
contains
(
pfrName
)){
newQueue
.
add
(
new
PfrRecentInfo
(
pfrName
,
pfrCount
+
1
,
timeStr
));
}
else
{
newQueue
.
add
(
pfrRecentInfo
);
String
sevenDaysAgoTimeStr
=
DateUtil
.
getSevenDaysAgoTimeStr
(
new
Date
());
String
lastUpdateTime
=
pfrRecentInfo
.
getLastUpdateTime
();
if
(
DateUtil
.
getTimestampByDateStr
(
lastUpdateTime
)
>
DateUtil
.
getTimestampByDateStr
(
sevenDaysAgoTimeStr
)){
String
pfrName
=
pfrRecentInfo
.
getPfrName
();
Integer
pfrCount
=
pfrRecentInfo
.
getPfrCount
();
if
(
pfrMap
.
keySet
().
contains
(
pfrName
)){
newQueue
.
add
(
new
PfrRecentInfo
(
pfrName
,
pfrCount
+
1
,
timeStr
));
}
else
{
newQueue
.
add
(
pfrRecentInfo
);
}
}
}
while
(
newQueue
.
size
()
>
queueSize
){
...
...
src/main/java/com/gmei/data/ctr/utils/DateUtil.java
View file @
6ff8b6a8
...
...
@@ -91,9 +91,15 @@ public class DateUtil {
* @return
* @throws ParseException
*/
public
static
Long
getTimestampByDateStr
(
String
dateStr
)
throws
ParseException
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
DATE_FORMATE_YMDHMS
);
return
simpleDateFormat
.
parse
(
dateStr
).
getTime
();
public
static
Long
getTimestampByDateStr
(
String
dateStr
)
{
Long
rs
=
0L
;
try
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
DATE_FORMATE_YMDHMS
);
rs
=
simpleDateFormat
.
parse
(
dateStr
).
getTime
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
rs
;
}
/**
...
...
src/main/java/com/gmei/data/ctr/utils/StringUtil.java
View file @
6ff8b6a8
...
...
@@ -49,7 +49,7 @@ public class StringUtil {
}
public
static
LinkedList
<
PfrRecentInfo
>
transString2PfrRecentInfoList
(
String
str
,
String
timeStr
){
LinkedList
<
PfrRecentInfo
>
pfrRecentInfoList
=
n
ull
;
LinkedList
<
PfrRecentInfo
>
pfrRecentInfoList
=
n
ew
LinkedList
<>()
;
String
[]
splits
=
str
.
split
(
","
);
for
(
String
split
:
splits
)
{
if
(
StringUtils
.
isNotBlank
(
split
)){
...
...
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