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
49ba4c57
Commit
49ba4c57
authored
Apr 15, 2020
by
赵建伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update codes
parent
6ff8b6a8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
40 deletions
+83
-40
PfrRecentInfo.java
src/main/java/com/gmei/data/ctr/bean/PfrRecentInfo.java
+5
-0
CtrPfrRctMysqlSink.java
src/main/java/com/gmei/data/ctr/sink/CtrPfrRctMysqlSink.java
+25
-22
StringUtil.java
src/main/java/com/gmei/data/ctr/utils/StringUtil.java
+53
-18
No files found.
src/main/java/com/gmei/data/ctr/bean/PfrRecentInfo.java
View file @
49ba4c57
...
...
@@ -17,6 +17,11 @@ public class PfrRecentInfo implements java.lang.Comparable<PfrRecentInfo>{
this
.
lastUpdateTime
=
lastUpdateTime
;
}
public
PfrRecentInfo
(
String
pfrName
,
Integer
pfrCount
)
{
this
.
pfrName
=
pfrName
;
this
.
pfrCount
=
pfrCount
;
}
public
PfrRecentInfo
()
{
}
...
...
src/main/java/com/gmei/data/ctr/sink/CtrPfrRctMysqlSink.java
View file @
49ba4c57
...
...
@@ -133,21 +133,21 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctBean> {
LinkedList
<
PfrRecentInfo
>
secondPositionsPfrQueue10
=
getNewQueue
(
pfrRecent10QueueBean
.
getSecondPositionsPfrQueue
(),
secondPositionsPfr
,
timeStr
,
10
);
LinkedList
<
PfrRecentInfo
>
secondSolutionsPfrQueue10
=
getNewQueue
(
pfrRecent10QueueBean
.
getSecondSolutionsPfrQueue
(),
secondSolutionsPfr
,
timeStr
,
10
);
String
projectPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2String
(
projectPfrQueue3
);
String
firstDemandsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2String
(
firstDemandsPfrQueue3
);
String
firstPositionsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2String
(
firstPositionsPfrQueue3
);
String
firstSolutionsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2String
(
firstSolutionsPfrQueue3
);
String
secondDemandsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2String
(
secondDemandsPfrQueue3
);
String
secondPositionsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2String
(
secondPositionsPfrQueue3
);
String
secondSolutionsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2String
(
secondSolutionsPfrQueue3
);
String
projectPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
projectPfrQueue3
);
String
firstDemandsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
firstDemandsPfrQueue3
);
String
firstPositionsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
firstPositionsPfrQueue3
);
String
firstSolutionsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
firstSolutionsPfrQueue3
);
String
secondDemandsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
secondDemandsPfrQueue3
);
String
secondPositionsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
secondPositionsPfrQueue3
);
String
secondSolutionsPfrRecent3
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
secondSolutionsPfrQueue3
);
String
projectPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2String
(
projectPfrQueue10
);
String
firstDemandsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2String
(
firstDemandsPfrQueue10
);
String
firstPositionsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2String
(
firstPositionsPfrQueue10
);
String
firstSolutionsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2String
(
firstSolutionsPfrQueue10
);
String
secondDemandsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2String
(
secondDemandsPfrQueue10
);
String
secondPositionsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2String
(
secondPositionsPfrQueue10
);
String
secondSolutionsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2String
(
secondSolutionsPfrQueue10
);
String
projectPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
projectPfrQueue10
);
String
firstDemandsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
firstDemandsPfrQueue10
);
String
firstPositionsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
firstPositionsPfrQueue10
);
String
firstSolutionsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
firstSolutionsPfrQueue10
);
String
secondDemandsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
secondDemandsPfrQueue10
);
String
secondPositionsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
secondPositionsPfrQueue10
);
String
secondSolutionsPfrRecent10
=
StringUtil
.
transPfrRecentInfoList2S
plitedPairedS
tring
(
secondSolutionsPfrQueue10
);
pfrRecent10QueueBean
=
new
PfrRecent10QueueBean
(
deviceId
,
...
...
@@ -314,20 +314,23 @@ public class CtrPfrRctMysqlSink extends RichSinkFunction<CtrPfrRctBean> {
private
LinkedList
<
PfrRecentInfo
>
getNewQueue
(
LinkedList
<
PfrRecentInfo
>
oldQueue
,
String
pfrStr
,
String
timeStr
,
Integer
queueSize
){
LinkedList
<
PfrRecentInfo
>
newQueue
=
new
LinkedList
<>();
Map
<
String
,
Integer
>
pfrMap
=
StringUtil
.
transString2Map
(
pfrStr
);
//
Map<String,Integer> pfrMap = StringUtil.transString2Map(pfrStr);
for
(
PfrRecentInfo
pfrRecentInfo
:
oldQueue
)
{
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
);
}
// String pfrName = pfrRecentInfo.getPfrName();
// Integer pfrCount = pfrRecentInfo.getPfrCount();
newQueue
.
add
(
pfrRecentInfo
);
// if(pfrMap.keySet().contains(pfrName)){
// newQueue.add(new PfrRecentInfo(pfrName,pfrCount + 1 ,timeStr));
// }else{
// newQueue.add(pfrRecentInfo);
// }
}
}
newQueue
.
add
(
new
PfrRecentInfo
(
pfrStr
,
1
,
timeStr
));
while
(
newQueue
.
size
()
>
queueSize
){
Collections
.
sort
(
newQueue
);
newQueue
.
removeLast
();
...
...
src/main/java/com/gmei/data/ctr/utils/StringUtil.java
View file @
49ba4c57
...
...
@@ -70,6 +70,35 @@ public class StringUtil {
return
str
.
substring
(
0
,
str
.
length
()
-
1
);
}
public
static
String
transPfrRecentInfoList2SplitedPairedString
(
LinkedList
<
PfrRecentInfo
>
list
){
LinkedList
<
PfrRecentInfo
>
newList
=
new
LinkedList
<>();
for
(
PfrRecentInfo
pfrRecentInfo:
list
)
{
String
pfrName
=
pfrRecentInfo
.
getPfrName
();
if
(
pfrName
.
contains
(
","
)){
String
[]
splits
=
pfrName
.
split
(
","
);
for
(
String
split
:
splits
){
newList
.
add
(
new
PfrRecentInfo
(
split
,
1
));
}
}
else
{
newList
.
add
(
new
PfrRecentInfo
(
pfrName
,
1
));
}
}
Map
<
String
,
Integer
>
map
=
new
HashMap
<>();
for
(
PfrRecentInfo
pfrRecentInfo:
newList
)
{
String
pfrName
=
pfrRecentInfo
.
getPfrName
();
if
(
map
.
keySet
().
contains
(
pfrRecentInfo
.
getPfrName
())){
Integer
rs
=
map
.
get
(
pfrName
);
map
.
put
(
pfrName
,
pfrRecentInfo
.
getPfrCount
()
+
rs
);
}
else
{
map
.
put
(
pfrName
,
pfrRecentInfo
.
getPfrCount
());
}
}
return
transMap2PairedString
(
map
);
}
public
static
Map
<
String
,
Integer
>
increaseByKey
(
Map
<
String
,
Integer
>
oldMap
,
String
str
){
Map
<
String
,
Integer
>
stringIntegerMap
=
transString2Map
(
str
);
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
oldMap
.
entrySet
()){
...
...
@@ -97,23 +126,29 @@ public class StringUtil {
}
public
static
void
main
(
String
[]
args
)
{
String
str
=
"xx:1,yy:2,zz:3"
;
String
newPfr
=
"xx,yy,zz"
;
String
s
=
increasePfr
(
str
,
newPfr
);
System
.
out
.
println
(
s
);
System
.
out
.
println
(
transString2PairedString
(
newPfr
));
JSONArray
ja
=
new
JSONArray
();
LinkedList
<
String
>
list
=
new
LinkedList
<
String
>();
list
.
add
(
"c"
);
list
.
add
(
"b"
);
list
.
add
(
"d"
);
list
.
add
(
"a"
);
Collections
.
sort
(
list
);
list
.
removeLast
();
for
(
String
ss:
list
)
{
System
.
out
.
println
(
ss
);
}
// String str = "xx:1,yy:2,zz:3";
// String newPfr = "xx,yy,zz";
// String s = increasePfr(str, newPfr);
// System.out.println(s);
// System.out.println(transString2PairedString(newPfr));
//
// JSONArray ja = new JSONArray();
//
// LinkedList<String> list = new LinkedList<String>();
// list.add("c");
// list.add("b");
// list.add("d");
// list.add("a");
// Collections.sort(list);
// list.removeLast();
// for (String ss: list) {
// System.out.println(ss);
// }
LinkedList
<
PfrRecentInfo
>
list
=
new
LinkedList
<>();
list
.
add
(
new
PfrRecentInfo
(
"xx,yy"
,
1
));
list
.
add
(
new
PfrRecentInfo
(
"xx"
,
1
));
list
.
add
(
new
PfrRecentInfo
(
"yy"
,
1
));
String
rs
=
transPfrRecentInfoList2SplitedPairedString
(
list
);
System
.
out
.
println
(
rs
);
}
}
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