Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mobvista-dmp
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
王金锋
mobvista-dmp
Commits
fcc273b7
Commit
fcc273b7
authored
Aug 02, 2021
by
WangJinfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rtdmp alter
parent
cdea637e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
176 additions
and
1 deletion
+176
-1
package.sh
package.sh
+9
-0
pom.xml
pom.xml
+6
-0
RTDmpAlter.java
src/main/java/mobvista/dmp/datasource/rtdmp/RTDmpAlter.java
+158
-0
config.properties
src/main/resources/config.properties
+3
-1
No files found.
package.sh
View file @
fcc273b7
...
...
@@ -16,6 +16,15 @@ fi
echo
"mvn install taobao-sdk-java-auto_1545720399572-20190823.jar"
mvn
install
:install-file
-DgroupId
=
com.alibaba
-DartifactId
=
dingtalk-sdk
-Dversion
=
1479188381469-20210727
-Dpackaging
=
jar
-Dfile
=
src/main/resources/jars/taobao-sdk-java-auto_1479188381469-20210727.jar
if
[
$?
-ne
0
]
;
then
exit
255
fi
echo
"mvn install taobao-sdk-java-auto_1479188381469-20210727.jar"
mvn clean compile package
||
exit
1
mkdir
target/zip
...
...
pom.xml
View file @
fcc273b7
...
...
@@ -272,6 +272,12 @@
<version>
1545720399572-20190823
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
dingtalk-sdk
</artifactId>
<version>
1479188381469-20210727
</version>
</dependency>
<dependency>
<groupId>
org.asynchttpclient
</groupId>
<artifactId>
async-http-client
</artifactId>
<version>
2.12.1
</version>
...
...
src/main/java/mobvista/dmp/datasource/rtdmp/RTDmpAlter.java
0 → 100644
View file @
fcc273b7
package
mobvista
.
dmp
.
datasource
.
rtdmp
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.dingtalk.api.DefaultDingTalkClient
;
import
com.dingtalk.api.DingTalkClient
;
import
com.dingtalk.api.request.OapiRobotSendRequest
;
import
com.dingtalk.api.response.OapiRobotSendResponse
;
import
com.taobao.api.ApiException
;
import
mobvista.dmp.common.Constants
;
import
mobvista.dmp.util.DateUtil
;
import
mobvista.dmp.util.MD5Util
;
import
mobvista.dmp.util.PropertyUtil
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.URISyntaxException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* @package: mobvista.dmp.datasource.rtdmp
* @author: wangjf
* @date: 2021/8/2
* @time: 3:08 下午
* @email: jinfeng.wang@mobvista.com
*/
public
class
RTDmpAlter
{
public
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ServerMain
.
class
);
private
static
final
String
BASE_URL
=
PropertyUtil
.
getProperty
(
"config.properties"
,
"rtdmp.url"
);
public
static
void
main
(
String
[]
args
)
{
String
update_time_start
;
String
update_time_end
;
if
(
args
.
length
>=
2
)
{
update_time_start
=
args
[
0
];
update_time_end
=
args
[
1
];
}
else
{
Calendar
cal
=
Calendar
.
getInstance
();
Date
date
=
new
Date
();
cal
.
setTime
(
date
);
cal
.
add
(
Calendar
.
DATE
,
-
7
);
update_time_start
=
DateUtil
.
format
(
cal
.
getTime
(),
"yyyy-MM-dd 00"
)
+
":00:00"
;
cal
.
setTime
(
date
);
cal
.
add
(
Calendar
.
DATE
,
-
1
);
update_time_end
=
DateUtil
.
format
(
cal
.
getTime
(),
"yyyy-MM-dd 23"
)
+
":59:59"
;
}
JSONObject
requestBody
=
new
JSONObject
();
requestBody
.
put
(
"update_time_start"
,
update_time_start
);
requestBody
.
put
(
"update_time_end"
,
update_time_end
);
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
List
<
BasicNameValuePair
>
formparams
=
new
ArrayList
<>();
String
serverUrl
=
BASE_URL
+
"rtdmp/audience/query"
;
URIBuilder
uri
=
new
URIBuilder
();
try
{
uri
=
new
URIBuilder
(
serverUrl
)
.
addParameter
(
"update_time_start"
,
update_time_start
)
.
addParameter
(
"update_time_end"
,
update_time_end
)
.
addParameter
(
"audience_type"
,
"3"
)
.
addParameter
(
"is_offline"
,
"1"
);
}
catch
(
URISyntaxException
e
)
{
e
.
printStackTrace
();
}
RequestConfig
requestConfig
=
RequestConfig
.
custom
()
.
setConnectTimeout
(
5000
).
setConnectionRequestTimeout
(
5000
)
.
setSocketTimeout
(
5000
).
build
();
HttpGet
httpGet
=
new
HttpGet
();
try
{
logger
.
info
(
"uri -->> "
+
uri
.
build
());
httpGet
=
new
HttpGet
(
uri
.
build
());
}
catch
(
URISyntaxException
e
)
{
e
.
printStackTrace
();
}
String
key
=
UUID
.
randomUUID
().
toString
();
String
token
=
MD5Util
.
getMD5Str
(
key
);
httpGet
.
setHeader
(
"Auth-System"
,
"dmp"
);
httpGet
.
setHeader
(
"Content-Type"
,
"text/plain"
);
httpGet
.
setHeader
(
"key"
,
key
);
httpGet
.
setHeader
(
"token"
,
token
);
CloseableHttpResponse
response
;
JSONObject
jsonObject
;
try
{
response
=
client
.
execute
(
httpGet
);
BufferedReader
rd
=
new
BufferedReader
(
new
InputStreamReader
(
response
.
getEntity
().
getContent
()));
StringBuilder
result
=
new
StringBuilder
();
String
line
;
while
((
line
=
rd
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
}
jsonObject
=
Constants
.
String2JSONObject
(
result
.
toString
());
}
catch
(
IOException
e
)
{
jsonObject
=
new
JSONObject
();
logger
.
info
(
e
.
getMessage
());
}
finally
{
httpGet
.
abort
();
}
JSONArray
data
=
jsonObject
.
getJSONArray
(
"data"
);
Set
<
Integer
>
set
=
new
HashSet
<>();
for
(
int
i
=
0
;
i
<
data
.
size
();
i
++)
{
set
.
add
(
data
.
getJSONObject
(
i
).
getIntValue
(
"id"
));
}
if
(
set
.
size
()
>
0
)
{
System
.
out
.
println
(
set
);
dingTalkAlert
(
set
);
}
}
private
static
void
dingTalkAlert
(
Set
<
Integer
>
set
)
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
DingTalkClient
client
=
new
DefaultDingTalkClient
(
"https://oapi.dingtalk.com/robot/send?access_token=7b176034a8d87c77463b5c5296974a9a000774da18f245021a368839e69dcf97"
);
OapiRobotSendRequest
request
=
new
OapiRobotSendRequest
();
request
.
setMsgtype
(
"markdown"
);
OapiRobotSendRequest
.
Markdown
markdown
=
new
OapiRobotSendRequest
.
Markdown
();
markdown
.
setTitle
(
"运算人群包更新告警"
);
markdown
.
setText
(
"#### 截止 "
+
sdf
.
format
(
new
Date
())
+
" 未更新的运算人群包有:\n"
+
">"
+
set
+
"\n"
+
"> ###### 请注意 @15210627698! \n"
);
request
.
setMarkdown
(
markdown
);
OapiRobotSendRequest
.
At
at
=
new
OapiRobotSendRequest
.
At
();
at
.
setAtMobiles
(
Arrays
.
asList
(
"15210627698"
));
at
.
setIsAtAll
(
false
);
request
.
setAt
(
at
);
OapiRobotSendResponse
response
=
null
;
try
{
response
=
client
.
execute
(
request
);
}
catch
(
ApiException
e
)
{
logger
.
error
(
e
.
getMessage
());
}
System
.
out
.
println
(
response
.
getMsg
());
}
}
src/main/resources/config.properties
View file @
fcc273b7
...
...
@@ -67,7 +67,9 @@ iqiyi.tag.30001990.android=com.iqiyi.english
# rtdmp
# rtdmp.url=http://13.228.176.169:5535/
rtdmp.url
=
http://ip-172-31-29-117:8688/
# rtdmp.url=http://ip-172-31-29-117:8688/
rtdmp.url
=
http://portal-rtdmp.mintegral.com/
# rtdmp.url=http://localhost:8688/
...
...
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