Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
AppTag
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
dataplatform
AppTag
Commits
cfed409d
Commit
cfed409d
authored
Mar 16, 2020
by
jinfeng.wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
eaca92f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
0 deletions
+138
-0
offer_package_tag.job
azkaban/offer_package_tag.job
+4
-0
offer_package_tag.sh
azkaban/offer_package_tag.sh
+11
-0
GetPackageFromOffer.java
...n/java/com/mobvista/apptag/utils/GetPackageFromOffer.java
+123
-0
No files found.
azkaban/offer_package_tag.job
0 → 100644
View file @
cfed409d
type=command
retries=3
command=sh -x offer_package_tag.sh
\ No newline at end of file
azkaban/offer_package_tag.sh
0 → 100644
View file @
cfed409d
#!/usr/sh
today
=
${
ScheduleTime
:-
$1
}
dateTime
=
$(
date
+%Y-%m-%d
-d
"-1 day
$today
"
)
java
-jar
-Dloader
.main
=
com.mobvista.apptag.utils.GetPackageFromOffer apptag.jar
${
dateTime
}
if
[[
$?
-ne
0
]]
;
then
exit
255
fi
\ No newline at end of file
src/main/java/com/mobvista/apptag/utils/GetPackageFromOffer.java
0 → 100644
View file @
cfed409d
package
com
.
mobvista
.
apptag
.
utils
;
import
java.sql.*
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* @package: com.mobvista.apptag.utils
* @author: wangjf
* @date: 2020/3/16
* @time: 9:21 上午
* @email: jinfeng.wang@mobvista.com
* @phone: 152-1062-7698
*/
public
class
GetPackageFromOffer
{
private
static
final
String
CONNECTION_URL
=
"jdbc:mysql://adn-data-foronlinetest.c5yzcdreb1xr.us-east-1.rds.amazonaws.com:3306/mob_adn?useUnicode=true&characterEncoding=utf8&useSSL=false"
;
private
static
final
String
DRIVER
=
"com.mysql.jdbc.Driver"
;
private
static
final
String
USER
=
"adnro"
;
private
static
final
String
PASSWORD
=
"YcM123glh"
;
private
static
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
public
static
void
main
(
String
[]
args
)
throws
SQLException
{
String
date
=
""
;
if
(
args
.
length
==
1
)
{
date
=
args
[
0
];
}
else
{
System
.
exit
(
1
);
}
List
list
=
readOffer
(
date
);
insert
(
list
);
System
.
out
.
println
(
"Insert "
+
list
.
size
()
+
" package_names"
);
}
/**
* 从新建单子中获取 package_name
*
* @param date
* @return
* @throws SQLException
*/
static
List
readOffer
(
String
date
)
throws
SQLException
{
ResultSet
resultSet
=
null
;
String
start
=
date
+
" 00:00:00"
;
String
end
=
date
+
" 23:59:59"
;
String
sql
=
String
.
format
(
"SELECT package_name FROM "
+
"(SELECT trace_app_id package_name FROM mob_adn.campaign_list "
+
"WHERE `timestamp` BETWEEN @startTime AND @endTime GROUP BY trace_app_id "
+
"UNION "
+
"SELECT package_name FROM mob_adn.publisher_channel "
+
"WHERE `timestamp` BETWEEN @startTime AND @endTime GROUP BY package_name) t "
+
"GROUP BY package_name"
);
try
{
long
startTime
=
sdf
.
parse
(
start
).
getTime
();
long
endTime
=
sdf
.
parse
(
end
).
getTime
();
Class
.
forName
(
DRIVER
);
Connection
connection
=
DriverManager
.
getConnection
(
CONNECTION_URL
,
USER
,
PASSWORD
);
sql
=
sql
.
replace
(
"@startTime"
,
String
.
valueOf
(
startTime
/
1000
))
.
replace
(
"@endTime"
,
String
.
valueOf
(
endTime
/
1000
));
System
.
out
.
println
(
sql
);
PreparedStatement
preparedStatement
=
connection
.
prepareStatement
(
sql
);
resultSet
=
preparedStatement
.
executeQuery
();
}
catch
(
ParseException
e
)
{
System
.
out
.
println
(
"Parse Date Error!!!"
);
}
catch
(
SQLException
|
ClassNotFoundException
e
)
{
System
.
out
.
println
(
"SQL Execute Error!!!"
);
}
return
covertList
(
resultSet
);
}
/**
* 批量写入
*
* @param list
*/
static
void
insert
(
List
<
String
>
list
)
{
if
(
list
.
size
()
%
1000
==
0
)
{
for
(
int
i
=
0
;
i
<
list
.
size
()
/
1000
;
i
++)
{
int
fromIndex
=
i
*
1000
+
1
;
int
toIndex
;
if
(
i
==
list
.
size
()
/
1000
)
{
toIndex
=
list
.
size
();
}
else
{
toIndex
=
(
i
+
1
)
*
1000
;
}
Set
<
String
>
set
=
new
HashSet
<>(
list
.
subList
(
fromIndex
,
toIndex
));
MySqlUtil
mySqlUtil
=
new
MySqlUtil
();
mySqlUtil
.
insert
(
set
);
}
}
else
{
for
(
int
i
=
0
;
i
<
list
.
size
()
/
1000
+
1
;
i
++)
{
int
fromIndex
=
i
*
1000
+
1
;
int
toIndex
;
if
(
i
==
list
.
size
()
/
1000
)
{
toIndex
=
list
.
size
();
}
else
{
toIndex
=
(
i
+
1
)
*
1000
;
}
Set
<
String
>
set
=
new
HashSet
<>(
list
.
subList
(
fromIndex
,
toIndex
));
MySqlUtil
mySqlUtil
=
new
MySqlUtil
();
mySqlUtil
.
insert
(
set
);
}
}
}
/**
* @param rs
* @return
* @throws SQLException
*/
static
List
covertList
(
ResultSet
rs
)
throws
SQLException
{
List
<
String
>
list
=
new
ArrayList
();
while
(
rs
.
next
())
{
list
.
add
(
rs
.
getString
(
"package_name"
));
}
return
list
;
}
}
\ 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