Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
flink_warehouse_rt
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
data
flink_warehouse_rt
Commits
e15a2105
Commit
e15a2105
authored
Dec 27, 2019
by
刘喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init project flink_warehouse_rt
parent
0f62fca8
Show whitespace changes
Inline
Side-by-side
Showing
54 changed files
with
6732 additions
and
0 deletions
+6732
-0
pom.xml
pom.xml
+157
-0
BlPreciseExposureAppBean.java
src/main/java/com/gmei/bean/bl/BlPreciseExposureAppBean.java
+153
-0
BlPreciseExposureAppUserTypeBean.java
...va/com/gmei/bean/bl/BlPreciseExposureAppUserTypeBean.java
+87
-0
BlPreciseExposureBean.java
src/main/java/com/gmei/bean/bl/BlPreciseExposureBean.java
+429
-0
BlPreciseExposureDeviceBean.java
...in/java/com/gmei/bean/bl/BlPreciseExposureDeviceBean.java
+235
-0
BlPreciseExposureParamsBean.java
...in/java/com/gmei/bean/bl/BlPreciseExposureParamsBean.java
+225
-0
BlPreciseExposureParamsExposureCardsBean.java
...mei/bean/bl/BlPreciseExposureParamsExposureCardsBean.java
+192
-0
DimCardContentType.java
src/main/java/com/gmei/bean/dim/DimCardContentType.java
+92
-0
DimCity.java
src/main/java/com/gmei/bean/dim/DimCity.java
+214
-0
DimPageType.java
src/main/java/com/gmei/bean/dim/DimPageType.java
+191
-0
DimTable.java
src/main/java/com/gmei/bean/dim/DimTable.java
+82
-0
MlPreciseExposureBean.java
src/main/java/com/gmei/bean/ml/MlPreciseExposureBean.java
+529
-0
CacheServiceAbstract.java
src/main/java/com/gmei/cache/CacheServiceAbstract.java
+32
-0
DimCardContentTypeDao.java
src/main/java/com/gmei/cache/DimCardContentTypeDao.java
+106
-0
DimCityDao.java
src/main/java/com/gmei/cache/DimCityDao.java
+186
-0
DimPageTypeDao.java
src/main/java/com/gmei/cache/DimPageTypeDao.java
+134
-0
DimTableCallable.java
src/main/java/com/gmei/cache/DimTableCallable.java
+88
-0
DimTableDao.java
src/main/java/com/gmei/cache/DimTableDao.java
+98
-0
MlPreciseExposureDao.java
src/main/java/com/gmei/cache/MlPreciseExposureDao.java
+152
-0
SimpleCacheService.java
src/main/java/com/gmei/cache/SimpleCacheService.java
+119
-0
BlMaiDianOutputSelector.java
src/main/java/com/gmei/function/BlMaiDianOutputSelector.java
+38
-0
BlPreciseExposureFilterFunction.java
...va/com/gmei/function/BlPreciseExposureFilterFunction.java
+54
-0
BlPreciseExposureMapFunction.java
.../java/com/gmei/function/BlPreciseExposureMapFunction.java
+225
-0
DimRichAsyncFunction.java
src/main/java/com/gmei/function/DimRichAsyncFunction.java
+215
-0
MlPreciseExposureKeySelector.java
.../java/com/gmei/function/MlPreciseExposureKeySelector.java
+61
-0
MlpreciseExposureFlatMapFunction.java
...a/com/gmei/function/MlpreciseExposureFlatMapFunction.java
+139
-0
MysqlJdbcDim.java
src/main/java/com/gmei/jdbc/MysqlJdbcDim.java
+142
-0
MysqlJdbcSink.java
src/main/java/com/gmei/jdbc/MysqlJdbcSink.java
+200
-0
BlPreciseExposureSchema.java
src/main/java/com/gmei/schema/BlPreciseExposureSchema.java
+93
-0
DayBucketAssigner.java
src/main/java/com/gmei/sink/DayBucketAssigner.java
+27
-0
MlPreciseExposureMysqlSink.java
src/main/java/com/gmei/sink/MlPreciseExposureMysqlSink.java
+79
-0
BlMaiDianKafkaSource.java
src/main/java/com/gmei/source/BlMaiDianKafkaSource.java
+78
-0
bl_et_mg_preciseexposure_inc_d.sql
...main/java/com/gmei/sql/bl_et_mg_preciseexposure_inc_d.sql
+161
-0
dim_table_ddl.sql
src/main/java/com/gmei/sql/dim_table_ddl.sql
+155
-0
dim_table_dml.sql
src/main/java/com/gmei/sql/dim_table_dml.sql
+0
-0
PreciseExposureStreaming.java
...ain/java/com/gmei/streaming/PreciseExposureStreaming.java
+167
-0
BeanReflectUtil.java
src/main/java/com/gmei/utils/BeanReflectUtil.java
+86
-0
DateUtil.java
src/main/java/com/gmei/utils/DateUtil.java
+48
-0
DimTableList.java
src/main/java/com/gmei/utils/DimTableList.java
+54
-0
DimCardContentTypeDaoTest.java
src/test/java/com/gmei/cache/DimCardContentTypeDaoTest.java
+34
-0
DimCityDaoTest.java
src/test/java/com/gmei/cache/DimCityDaoTest.java
+70
-0
DimPageTypeDaoTest.java
src/test/java/com/gmei/cache/DimPageTypeDaoTest.java
+37
-0
DimTableDaoTest.java
src/test/java/com/gmei/cache/DimTableDaoTest.java
+118
-0
BlMaiDianSplitEtl.java
src/test/java/com/gmei/etl/BlMaiDianSplitEtl.java
+42
-0
BlPreciseExposureEtl.java
src/test/java/com/gmei/etl/BlPreciseExposureEtl.java
+272
-0
MlPreciseExposureEtl.java
src/test/java/com/gmei/etl/MlPreciseExposureEtl.java
+217
-0
BlPreciseExposureMapFunctionTest.java
...a/com/gmei/function/BlPreciseExposureMapFunctionTest.java
+53
-0
MyConsumer.java
src/test/java/com/gmei/kafka/MyConsumer.java
+53
-0
MyProducter.java
src/test/java/com/gmei/kafka/MyProducter.java
+94
-0
BlPreciseExposureKafkaSink.java
src/test/java/com/gmei/sink/BlPreciseExposureKafkaSink.java
+57
-0
MlPreciseExposureMysqlSinkTest.java
...st/java/com/gmei/sink/MlPreciseExposureMysqlSinkTest.java
+47
-0
BlMaiDianKafkaSourceTest.java
src/test/java/com/gmei/source/BlMaiDianKafkaSourceTest.java
+58
-0
BeanReflectUtilTest.java
src/test/java/com/gmei/utils/BeanReflectUtilTest.java
+41
-0
DateUtilTest.java
src/test/java/com/gmei/utils/DateUtilTest.java
+16
-0
No files found.
pom.xml
0 → 100644
View file @
e15a2105
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.gmei.flink
</groupId>
<artifactId>
flink_warehouse_rt_test
</artifactId>
<packaging>
jar
</packaging>
<version>
1.0-SNAPSHOT
</version>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<flink.version>
1.9.0
</flink.version>
<slf4j.version>
1.7.7
</slf4j.version>
<log4j.version>
1.2.17
</log4j.version>
<scala.binary.version>
2.10
</scala.binary.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.apache.flink
</groupId>
<artifactId>
flink-connector-kafka-0.11_2.11
</artifactId>
<version>
${flink.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.kafka
</groupId>
<artifactId>
kafka-clients
</artifactId>
<version>
2.1.1
</version>
</dependency>
<dependency>
<groupId>
org.apache.flink
</groupId>
<artifactId>
flink-streaming-java_2.11
</artifactId>
<version>
${flink.version}
</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>
org.apache.flink
</groupId>
<artifactId>
flink-java
</artifactId>
<version>
${flink.version}
</version>
<!-- provided在这表示此依赖只在代码编译的时候使用,运行和打包的时候不使用 -->
<!--<scope>provided</scope>-->
</dependency>
<dependency>
<groupId>
org.apache.flink
</groupId>
<artifactId>
flink-clients_2.11
</artifactId>
<version>
${flink.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.flink
</groupId>
<artifactId>
flink-statebackend-rocksdb_2.11
</artifactId>
<version>
${flink.version}
</version>
</dependency>
<dependency>
<groupId>
org.apache.flink
</groupId>
<artifactId>
flink-json
</artifactId>
<version>
${flink.version}
</version>
</dependency>
<dependency>
<groupId>
org.msgpack
</groupId>
<artifactId>
msgpack
</artifactId>
<version>
0.6.11
</version>
</dependency>
<dependency>
<groupId>
org.codehaus.jackson
</groupId>
<artifactId>
jackson-core-asl
</artifactId>
<version>
1.8.8
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.62
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
24.0-jre
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
5.1.38
</version>
<!--<version>8.0.12</version>-->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.1
</version>
<configuration>
<source>
1.8
</source>
<!-- If you want to use Java 8, change this to "1.8" -->
<target>
1.8
</target>
<!-- If you want to use Java 8, change this to "1.8" -->
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-assembly-plugin
</artifactId>
<version>
2.3
</version>
<configuration>
<appendAssemblyId>
false
</appendAssemblyId>
<descriptorRefs>
<descriptorRef>
jar-with-dependencies
</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>
com.gmei.streaming.PreciseExposureStreaming
</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>
make-assembly
</id>
<phase>
package
</phase>
<goals>
<goal>
assembly
</goal>
</goals>
</execution>
</executions>
</plugin>
<!--使单元测试不影响项目的编译-->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<configuration>
<skip>
true
</skip>
<!--跳过单元测试-->
<!--<testFailureIgnore>true</testFailureIgnore>--><!--这个网上很多的解决方式是这个,其实这个,其实这个配置后打包还是会编译单元测试类的,只是忽略编译单元测试类的错误.-->
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
src/main/java/com/gmei/bean/bl/BlPreciseExposureAppBean.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
bl
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty
;
/**
* ClassName: BlPreciseExposureBean
* TableName: Bl_Et_Mg_PreciseExposure_Inc_D
* Function: TODO ADD FUNCTION.
* Reason: TODO ADD REASON.
* Date: 2019/12/3 下午5:07
*
* @author liuzhe
* @since JDK 1.8
*/
/*
{
"gm_nginx_key":2,
"version":"110",
"params":{
"up_slide_times":0,
"down_loading_times":0,
"exposure_cards":{
},
"up_loading_times":0,
"is_exposure":1,
"tab_name":"精选",
"referrer_id":"",
"down_slide_times":0,
"referrer":"",
"page_name":"home",
"business_id":""
},
"app_session_id":"C3280044-5C8E-459D-AE6C-8E26BBACD6C9",
"gm_nginx_timestamp":1546307958.631,
"create_at":"1546307958",
"app":{
"channel":"AppStore",
"version":"7.7.35",
"serial_id":42,
"current_city_id":"worldwide",
"name":"gengmei_user",
"user_type":{
}
},
"device":{
"is_WiFi":"0",
"device_type":"ios",
"device_id":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"lng":0,
"lat":0,
"ip":"10.156.100.97",
"manufacturer":"Apple",
"idfa":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"idfv":"352A6D64-17CA-4520-831A-2CE9507631D8"
},
"user_id":"30864538",
"type":"home_choiceness_card_exposure"
}
*/
public
class
BlPreciseExposureAppBean
{
@JsonProperty
(
value
=
"channel"
)
private
String
app_channel
;
@JsonProperty
(
value
=
"version"
)
private
String
app_version
;
@JsonProperty
(
value
=
"serial_id"
)
private
String
app_serial_id
;
@JsonProperty
(
value
=
"current_city_id"
)
private
String
app_current_city_id
;
@JsonProperty
(
value
=
"name"
)
private
String
app_code
;
@JsonProperty
(
value
=
"user_type"
)
private
BlPreciseExposureAppUserTypeBean
app_user_type
;
public
BlPreciseExposureAppBean
()
{
}
public
String
getApp_channel
()
{
return
app_channel
;
}
public
void
setApp_channel
(
String
app_channel
)
{
this
.
app_channel
=
app_channel
;
}
public
String
getApp_version
()
{
return
app_version
;
}
public
void
setApp_version
(
String
app_version
)
{
this
.
app_version
=
app_version
;
}
public
String
getApp_serial_id
()
{
return
app_serial_id
;
}
public
void
setApp_serial_id
(
String
app_serial_id
)
{
this
.
app_serial_id
=
app_serial_id
;
}
public
String
getApp_current_city_id
()
{
return
app_current_city_id
;
}
public
void
setApp_current_city_id
(
String
app_current_city_id
)
{
this
.
app_current_city_id
=
app_current_city_id
;
}
public
String
getApp_code
()
{
return
app_code
;
}
public
void
setApp_code
(
String
app_code
)
{
this
.
app_code
=
app_code
;
}
public
BlPreciseExposureAppUserTypeBean
getApp_user_type
()
{
return
app_user_type
;
}
public
void
setApp_user_type
(
BlPreciseExposureAppUserTypeBean
app_user_type
)
{
this
.
app_user_type
=
app_user_type
;
}
public
BlPreciseExposureAppBean
(
String
app_channel
,
String
app_version
,
String
app_serial_id
,
String
app_current_city_id
,
String
app_code
,
BlPreciseExposureAppUserTypeBean
app_user_type
)
{
this
.
app_channel
=
app_channel
;
this
.
app_version
=
app_version
;
this
.
app_serial_id
=
app_serial_id
;
this
.
app_current_city_id
=
app_current_city_id
;
this
.
app_code
=
app_code
;
this
.
app_user_type
=
app_user_type
;
}
@Override
public
String
toString
()
{
return
"BlPreciseExposureAppBean{"
+
"app_channel='"
+
app_channel
+
'\''
+
", app_version='"
+
app_version
+
'\''
+
", app_serial_id='"
+
app_serial_id
+
'\''
+
", app_current_city_id='"
+
app_current_city_id
+
'\''
+
", app_code='"
+
app_code
+
'\''
+
", app_user_type="
+
app_user_type
+
'}'
;
}
}
src/main/java/com/gmei/bean/bl/BlPreciseExposureAppUserTypeBean.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
bl
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty
;
/**
* ClassName: BlPreciseExposureBean
* TableName: Bl_Et_Mg_PreciseExposure_Inc_D
* Function: TODO ADD FUNCTION.
* Reason: TODO ADD REASON.
* Date: 2019/12/3 下午5:07
*
* @author liuzhe
* @since JDK 1.8
*/
/*
{
"gm_nginx_key":2,
"version":"110",
"params":{
"up_slide_times":0,
"down_loading_times":0,
"exposure_cards":{
},
"up_loading_times":0,
"is_exposure":1,
"tab_name":"精选",
"referrer_id":"",
"down_slide_times":0,
"referrer":"",
"page_name":"home",
"business_id":""
},
"app_session_id":"C3280044-5C8E-459D-AE6C-8E26BBACD6C9",
"gm_nginx_timestamp":1546307958.631,
"create_at":"1546307958",
"app":{
"channel":"AppStore",
"version":"7.7.35",
"serial_id":42,
"current_city_id":"worldwide",
"name":"gengmei_user",
"user_type":{
}
},
"device":{
"is_WiFi":"0",
"device_type":"ios",
"device_id":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"lng":0,
"lat":0,
"ip":"10.156.100.97",
"manufacturer":"Apple",
"idfa":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"idfv":"352A6D64-17CA-4520-831A-2CE9507631D8"
},
"user_id":"30864538",
"type":"home_choiceness_card_exposure"
}
*/
public
class
BlPreciseExposureAppUserTypeBean
{
private
String
config_type
;
public
BlPreciseExposureAppUserTypeBean
()
{
}
public
String
getConfig_type
()
{
return
config_type
;
}
public
void
setConfig_type
(
String
config_type
)
{
this
.
config_type
=
config_type
;
}
public
BlPreciseExposureAppUserTypeBean
(
String
config_type
)
{
this
.
config_type
=
config_type
;
}
@Override
public
String
toString
()
{
return
"BlPreciseExposureAppUserTypeBean{"
+
"config_type='"
+
config_type
+
'\''
+
'}'
;
}
}
src/main/java/com/gmei/bean/bl/BlPreciseExposureBean.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
bl
;
import
java.util.ArrayList
;
/**
* ClassName: BlPreciseExposureBean
* TableName: Bl_Et_Mg_PreciseExposure_Inc_D
* Function:
* Reason: BL层精准曝光BEAN类
* Date: 2019/12/3 下午5:07
*
* @author liuzhe
* @since JDK 1.8
*/
/*
{
"gm_nginx_key":2,
"version":"110",
"params":{
"up_slide_times":0,
"down_loading_times":0,
"exposure_cards":{
},
"up_loading_times":0,
"is_exposure":1,
"tab_name":"精选",
"referrer_id":"",
"down_slide_times":0,
"referrer":"",
"page_name":"home",
"business_id":""
},
"app_session_id":"C3280044-5C8E-459D-AE6C-8E26BBACD6C9",
"gm_nginx_timestamp":1546307958.631,
"create_at":"1546307958",
"app":{
"channel":"AppStore",
"version":"7.7.35",
"serial_id":42,
"current_city_id":"worldwide",
"name":"gengmei_user",
"user_type":{
}
},
"device":{
"is_WiFi":"0",
"device_type":"ios",
"device_id":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"lng":0,
"lat":0,
"ip":"10.156.100.97",
"manufacturer":"Apple",
"idfa":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"idfv":"352A6D64-17CA-4520-831A-2CE9507631D8"
},
"user_id":"30864538",
"type":"home_choiceness_card_exposure"
}
*/
public
class
BlPreciseExposureBean
{
private
String
gm_nginx_timestamp
;
private
String
create_timestamp
;
private
String
user_id
;
private
String
action
;
private
Integer
down_loading_times
;
private
Integer
down_slide_times
;
private
Integer
up_loading_times
;
private
Integer
up_slide_times
;
private
String
page_code
;
private
String
tab_name
;
private
String
business_id
;
private
String
referrer_code
;
private
String
referrer_id
;
private
ArrayList
<
BlPreciseExposureParamsExposureCardsBean
>
exposure_cards
;
private
String
is_exposure
;
private
String
is_popup
;
private
String
filter
;
private
String
query
;
private
String
app_grey_type
;
private
String
app_channel
;
private
String
app_version
;
private
String
app_current_city_id
;
private
String
app_code
;
private
String
device_os_type
;
private
String
device_model
;
private
String
device_id
;
private
String
device_android_id
;
private
String
device_idfv
;
private
String
gm_nginx_time_date
;
private
String
gm_nginx_time_day
;
private
String
create_time_date
;
private
String
create_time_day
;
public
BlPreciseExposureBean
()
{
}
public
BlPreciseExposureBean
(
String
gm_nginx_timestamp
,
String
create_timestamp
,
String
user_id
,
String
action
,
Integer
down_loading_times
,
Integer
down_slide_times
,
Integer
up_loading_times
,
Integer
up_slide_times
,
String
page_code
,
String
tab_name
,
String
business_id
,
String
referrer_code
,
String
referrer_id
,
ArrayList
<
BlPreciseExposureParamsExposureCardsBean
>
exposure_cards
,
String
is_exposure
,
String
is_popup
,
String
filter
,
String
query
,
String
app_grey_type
,
String
app_channel
,
String
app_version
,
String
app_current_city_id
,
String
app_code
,
String
device_os_type
,
String
device_model
,
String
device_id
,
String
device_android_id
,
String
device_idfv
,
String
gm_nginx_time_date
,
String
gm_nginx_time_day
,
String
create_time_date
,
String
create_time_day
)
{
this
.
gm_nginx_timestamp
=
gm_nginx_timestamp
;
this
.
create_timestamp
=
create_timestamp
;
this
.
user_id
=
user_id
;
this
.
action
=
action
;
this
.
down_loading_times
=
down_loading_times
;
this
.
down_slide_times
=
down_slide_times
;
this
.
up_loading_times
=
up_loading_times
;
this
.
up_slide_times
=
up_slide_times
;
this
.
page_code
=
page_code
;
this
.
tab_name
=
tab_name
;
this
.
business_id
=
business_id
;
this
.
referrer_code
=
referrer_code
;
this
.
referrer_id
=
referrer_id
;
this
.
exposure_cards
=
exposure_cards
;
this
.
is_exposure
=
is_exposure
;
this
.
is_popup
=
is_popup
;
this
.
filter
=
filter
;
this
.
query
=
query
;
this
.
app_grey_type
=
app_grey_type
;
this
.
app_channel
=
app_channel
;
this
.
app_version
=
app_version
;
this
.
app_current_city_id
=
app_current_city_id
;
this
.
app_code
=
app_code
;
this
.
device_os_type
=
device_os_type
;
this
.
device_model
=
device_model
;
this
.
device_id
=
device_id
;
this
.
device_android_id
=
device_android_id
;
this
.
device_idfv
=
device_idfv
;
this
.
gm_nginx_time_date
=
gm_nginx_time_date
;
this
.
gm_nginx_time_day
=
gm_nginx_time_day
;
this
.
create_time_date
=
create_time_date
;
this
.
create_time_day
=
create_time_day
;
}
public
String
getGm_nginx_timestamp
()
{
return
gm_nginx_timestamp
;
}
public
void
setGm_nginx_timestamp
(
String
gm_nginx_timestamp
)
{
this
.
gm_nginx_timestamp
=
gm_nginx_timestamp
;
}
public
String
getCreate_timestamp
()
{
return
create_timestamp
;
}
public
void
setCreate_timestamp
(
String
create_timestamp
)
{
this
.
create_timestamp
=
create_timestamp
;
}
public
String
getUser_id
()
{
return
user_id
;
}
public
void
setUser_id
(
String
user_id
)
{
this
.
user_id
=
user_id
;
}
public
String
getAction
()
{
return
action
;
}
public
void
setAction
(
String
action
)
{
this
.
action
=
action
;
}
public
Integer
getDown_loading_times
()
{
return
down_loading_times
;
}
public
void
setDown_loading_times
(
Integer
down_loading_times
)
{
this
.
down_loading_times
=
down_loading_times
;
}
public
Integer
getDown_slide_times
()
{
return
down_slide_times
;
}
public
void
setDown_slide_times
(
Integer
down_slide_times
)
{
this
.
down_slide_times
=
down_slide_times
;
}
public
Integer
getUp_loading_times
()
{
return
up_loading_times
;
}
public
void
setUp_loading_times
(
Integer
up_loading_times
)
{
this
.
up_loading_times
=
up_loading_times
;
}
public
Integer
getUp_slide_times
()
{
return
up_slide_times
;
}
public
void
setUp_slide_times
(
Integer
up_slide_times
)
{
this
.
up_slide_times
=
up_slide_times
;
}
public
String
getPage_code
()
{
return
page_code
;
}
public
void
setPage_code
(
String
page_code
)
{
this
.
page_code
=
page_code
;
}
public
String
getTab_name
()
{
return
tab_name
;
}
public
void
setTab_name
(
String
tab_name
)
{
this
.
tab_name
=
tab_name
;
}
public
String
getBusiness_id
()
{
return
business_id
;
}
public
void
setBusiness_id
(
String
business_id
)
{
this
.
business_id
=
business_id
;
}
public
String
getReferrer_code
()
{
return
referrer_code
;
}
public
void
setReferrer_code
(
String
referrer_code
)
{
this
.
referrer_code
=
referrer_code
;
}
public
String
getReferrer_id
()
{
return
referrer_id
;
}
public
void
setReferrer_id
(
String
referrer_id
)
{
this
.
referrer_id
=
referrer_id
;
}
public
ArrayList
<
BlPreciseExposureParamsExposureCardsBean
>
getExposure_cards
()
{
return
exposure_cards
;
}
public
void
setExposure_cards
(
ArrayList
<
BlPreciseExposureParamsExposureCardsBean
>
exposure_cards
)
{
this
.
exposure_cards
=
exposure_cards
;
}
public
String
getIs_exposure
()
{
return
is_exposure
;
}
public
void
setIs_exposure
(
String
is_exposure
)
{
this
.
is_exposure
=
is_exposure
;
}
public
String
getIs_popup
()
{
return
is_popup
;
}
public
void
setIs_popup
(
String
is_popup
)
{
this
.
is_popup
=
is_popup
;
}
public
String
getFilter
()
{
return
filter
;
}
public
void
setFilter
(
String
filter
)
{
this
.
filter
=
filter
;
}
public
String
getQuery
()
{
return
query
;
}
public
void
setQuery
(
String
query
)
{
this
.
query
=
query
;
}
public
String
getApp_grey_type
()
{
return
app_grey_type
;
}
public
void
setApp_grey_type
(
String
app_grey_type
)
{
this
.
app_grey_type
=
app_grey_type
;
}
public
String
getApp_channel
()
{
return
app_channel
;
}
public
void
setApp_channel
(
String
app_channel
)
{
this
.
app_channel
=
app_channel
;
}
public
String
getApp_version
()
{
return
app_version
;
}
public
void
setApp_version
(
String
app_version
)
{
this
.
app_version
=
app_version
;
}
public
String
getApp_current_city_id
()
{
return
app_current_city_id
;
}
public
void
setApp_current_city_id
(
String
app_current_city_id
)
{
this
.
app_current_city_id
=
app_current_city_id
;
}
public
String
getApp_code
()
{
return
app_code
;
}
public
void
setApp_code
(
String
app_code
)
{
this
.
app_code
=
app_code
;
}
public
String
getDevice_os_type
()
{
return
device_os_type
;
}
public
void
setDevice_os_type
(
String
device_os_type
)
{
this
.
device_os_type
=
device_os_type
;
}
public
String
getDevice_model
()
{
return
device_model
;
}
public
void
setDevice_model
(
String
device_model
)
{
this
.
device_model
=
device_model
;
}
public
String
getDevice_id
()
{
return
device_id
;
}
public
void
setDevice_id
(
String
device_id
)
{
this
.
device_id
=
device_id
;
}
public
String
getDevice_android_id
()
{
return
device_android_id
;
}
public
void
setDevice_android_id
(
String
device_android_id
)
{
this
.
device_android_id
=
device_android_id
;
}
public
String
getDevice_idfv
()
{
return
device_idfv
;
}
public
void
setDevice_idfv
(
String
device_idfv
)
{
this
.
device_idfv
=
device_idfv
;
}
public
String
getGm_nginx_time_date
()
{
return
gm_nginx_time_date
;
}
public
void
setGm_nginx_time_date
(
String
gm_nginx_time_date
)
{
this
.
gm_nginx_time_date
=
gm_nginx_time_date
;
}
public
String
getGm_nginx_time_day
()
{
return
gm_nginx_time_day
;
}
public
void
setGm_nginx_time_day
(
String
gm_nginx_time_day
)
{
this
.
gm_nginx_time_day
=
gm_nginx_time_day
;
}
public
String
getCreate_time_date
()
{
return
create_time_date
;
}
public
void
setCreate_time_date
(
String
create_time_date
)
{
this
.
create_time_date
=
create_time_date
;
}
public
String
getCreate_time_day
()
{
return
create_time_day
;
}
public
void
setCreate_time_day
(
String
create_time_day
)
{
this
.
create_time_day
=
create_time_day
;
}
@Override
public
String
toString
()
{
return
"BlPreciseExposureBean{"
+
"gm_nginx_timestamp='"
+
gm_nginx_timestamp
+
'\''
+
", create_timestamp='"
+
create_timestamp
+
'\''
+
", user_id='"
+
user_id
+
'\''
+
", action='"
+
action
+
'\''
+
", down_loading_times="
+
down_loading_times
+
", down_slide_times="
+
down_slide_times
+
", up_loading_times="
+
up_loading_times
+
", up_slide_times="
+
up_slide_times
+
", page_code='"
+
page_code
+
'\''
+
", tab_name='"
+
tab_name
+
'\''
+
", business_id='"
+
business_id
+
'\''
+
", referrer_code='"
+
referrer_code
+
'\''
+
", referrer_id='"
+
referrer_id
+
'\''
+
", exposure_cards="
+
exposure_cards
+
", is_exposure='"
+
is_exposure
+
'\''
+
", is_popup='"
+
is_popup
+
'\''
+
", filter='"
+
filter
+
'\''
+
", query='"
+
query
+
'\''
+
", app_grey_type='"
+
app_grey_type
+
'\''
+
", app_channel='"
+
app_channel
+
'\''
+
", app_version='"
+
app_version
+
'\''
+
", app_current_city_id='"
+
app_current_city_id
+
'\''
+
", app_code='"
+
app_code
+
'\''
+
", device_os_type='"
+
device_os_type
+
'\''
+
", device_model='"
+
device_model
+
'\''
+
", device_id='"
+
device_id
+
'\''
+
", device_android_id='"
+
device_android_id
+
'\''
+
", device_idfv='"
+
device_idfv
+
'\''
+
", gm_nginx_time_date='"
+
gm_nginx_time_date
+
'\''
+
", gm_nginx_time_day='"
+
gm_nginx_time_day
+
'\''
+
", create_time_date='"
+
create_time_date
+
'\''
+
", create_time_day='"
+
create_time_day
+
'\''
+
'}'
;
}
}
src/main/java/com/gmei/bean/bl/BlPreciseExposureDeviceBean.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
bl
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
/**
* ClassName: BlPreciseExposureBean
* TableName: Bl_Et_Mg_PreciseExposure_Inc_D
* Function: TODO ADD FUNCTION.
* Reason: TODO ADD REASON.
* Date: 2019/12/3 下午5:07
*
* @author liuzhe
* @since JDK 1.8
*/
/*
{
"gm_nginx_key":2,
"version":"110",
"params":{
"up_slide_times":0,
"down_loading_times":0,
"exposure_cards":{
},
"up_loading_times":0,
"is_exposure":1,
"tab_name":"精选",
"referrer_id":"",
"down_slide_times":0,
"referrer":"",
"page_name":"home",
"business_id":""
},
"app_session_id":"C3280044-5C8E-459D-AE6C-8E26BBACD6C9",
"gm_nginx_timestamp":1546307958.631,
"create_at":"1546307958",
"app":{
"channel":"AppStore",
"version":"7.7.35",
"serial_id":42,
"current_city_id":"worldwide",
"name":"gengmei_user",
"user_type":{
}
},
"device":{
"is_WiFi":"0",
"device_type":"ios",
"device_id":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"lng":0,
"lat":0,
"ip":"10.156.100.97",
"manufacturer":"Apple",
"idfa":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"idfv":"352A6D64-17CA-4520-831A-2CE9507631D8"
},
"user_id":"30864538",
"type":"home_choiceness_card_exposure"
}
*/
public
class
BlPreciseExposureDeviceBean
{
@JsonProperty
(
value
=
"is_WiFi"
)
private
String
device_is_WiFi
;
@JsonProperty
(
value
=
"device_type"
)
private
String
device_os_type
;
@JsonProperty
(
value
=
"model"
)
private
String
device_model
;
@JsonProperty
(
value
=
"sys_version"
)
private
String
device_sys_version
;
@JsonProperty
(
value
=
"net_type"
)
private
String
device_net_type
;
@JsonProperty
(
value
=
"device_id"
)
private
String
device_id
;
@JsonProperty
(
value
=
"android_device_id"
)
private
String
device_android_id
;
@JsonProperty
(
value
=
"lng"
)
private
String
device_lng
;
@JsonProperty
(
value
=
"lat"
)
private
String
device_lat
;
@JsonProperty
(
value
=
"ip"
)
private
String
device_ip
;
@JsonProperty
(
value
=
"manufacturer"
)
private
String
device_manufacturer
;
@JsonProperty
(
value
=
"idfv"
)
private
String
device_idfv
;
@JsonProperty
(
value
=
"idfa"
)
private
String
device_idfa
;
public
BlPreciseExposureDeviceBean
()
{
}
public
BlPreciseExposureDeviceBean
(
String
device_is_WiFi
,
String
device_os_type
,
String
device_model
,
String
device_sys_version
,
String
device_net_type
,
String
device_id
,
String
device_android_id
,
String
device_lng
,
String
device_lat
,
String
device_ip
,
String
device_manufacturer
,
String
device_idfv
,
String
device_idfa
)
{
this
.
device_is_WiFi
=
device_is_WiFi
;
this
.
device_os_type
=
device_os_type
;
this
.
device_model
=
device_model
;
this
.
device_sys_version
=
device_sys_version
;
this
.
device_net_type
=
device_net_type
;
this
.
device_id
=
device_id
;
this
.
device_android_id
=
device_android_id
;
this
.
device_lng
=
device_lng
;
this
.
device_lat
=
device_lat
;
this
.
device_ip
=
device_ip
;
this
.
device_manufacturer
=
device_manufacturer
;
this
.
device_idfv
=
device_idfv
;
this
.
device_idfa
=
device_idfa
;
}
public
String
getDevice_is_WiFi
()
{
return
device_is_WiFi
;
}
public
void
setDevice_is_WiFi
(
String
device_is_WiFi
)
{
this
.
device_is_WiFi
=
device_is_WiFi
;
}
public
String
getDevice_os_type
()
{
return
device_os_type
;
}
public
void
setDevice_os_type
(
String
device_os_type
)
{
this
.
device_os_type
=
device_os_type
;
}
public
String
getDevice_model
()
{
return
device_model
;
}
public
void
setDevice_model
(
String
device_model
)
{
this
.
device_model
=
device_model
;
}
public
String
getDevice_sys_version
()
{
return
device_sys_version
;
}
public
void
setDevice_sys_version
(
String
device_sys_version
)
{
this
.
device_sys_version
=
device_sys_version
;
}
public
String
getDevice_net_type
()
{
return
device_net_type
;
}
public
void
setDevice_net_type
(
String
device_net_type
)
{
this
.
device_net_type
=
device_net_type
;
}
public
String
getDevice_id
()
{
return
device_id
;
}
public
void
setDevice_id
(
String
device_id
)
{
this
.
device_id
=
device_id
;
}
public
String
getDevice_android_id
()
{
return
device_android_id
;
}
public
void
setDevice_android_id
(
String
device_android_id
)
{
this
.
device_android_id
=
device_android_id
;
}
public
String
getDevice_lng
()
{
return
device_lng
;
}
public
void
setDevice_lng
(
String
device_lng
)
{
this
.
device_lng
=
device_lng
;
}
public
String
getDevice_lat
()
{
return
device_lat
;
}
public
void
setDevice_lat
(
String
device_lat
)
{
this
.
device_lat
=
device_lat
;
}
public
String
getDevice_ip
()
{
return
device_ip
;
}
public
void
setDevice_ip
(
String
device_ip
)
{
this
.
device_ip
=
device_ip
;
}
public
String
getDevice_manufacturer
()
{
return
device_manufacturer
;
}
public
void
setDevice_manufacturer
(
String
device_manufacturer
)
{
this
.
device_manufacturer
=
device_manufacturer
;
}
public
String
getDevice_idfv
()
{
return
device_idfv
;
}
public
void
setDevice_idfv
(
String
device_idfv
)
{
this
.
device_idfv
=
device_idfv
;
}
public
String
getDevice_idfa
()
{
return
device_idfa
;
}
public
void
setDevice_idfa
(
String
device_idfa
)
{
this
.
device_idfa
=
device_idfa
;
}
@Override
public
String
toString
()
{
return
"BlPreciseExposureDeviceBean{"
+
"device_is_WiFi='"
+
device_is_WiFi
+
'\''
+
", device_os_type='"
+
device_os_type
+
'\''
+
", device_model='"
+
device_model
+
'\''
+
", device_sys_version='"
+
device_sys_version
+
'\''
+
", device_net_type='"
+
device_net_type
+
'\''
+
", device_id='"
+
device_id
+
'\''
+
", device_android_id='"
+
device_android_id
+
'\''
+
", device_lng='"
+
device_lng
+
'\''
+
", device_lat='"
+
device_lat
+
'\''
+
", device_ip='"
+
device_ip
+
'\''
+
", device_manufacturer='"
+
device_manufacturer
+
'\''
+
", device_idfv='"
+
device_idfv
+
'\''
+
", device_idfa='"
+
device_idfa
+
'\''
+
'}'
;
}
}
src/main/java/com/gmei/bean/bl/BlPreciseExposureParamsBean.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
bl
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty
;
/**
* ClassName: BlPreciseExposureBean
* TableName: Bl_Et_Mg_PreciseExposure_Inc_D
* Function: TODO ADD FUNCTION.
* Reason: TODO ADD REASON.
* Date: 2019/12/3 下午5:07
*
* @author liuzhe
* @since JDK 1.8
*/
/*
{
"gm_nginx_key":2,
"version":"110",
"params":{
"up_slide_times":0,
"down_loading_times":0,
"exposure_cards":{
},
"up_loading_times":0,
"is_exposure":1,
"tab_name":"精选",
"referrer_id":"",
"down_slide_times":0,
"referrer":"",
"page_name":"home",
"business_id":""
},
"app_session_id":"C3280044-5C8E-459D-AE6C-8E26BBACD6C9",
"gm_nginx_timestamp":1546307958.631,
"create_at":"1546307958",
"app":{
"channel":"AppStore",
"version":"7.7.35",
"serial_id":42,
"current_city_id":"worldwide",
"name":"gengmei_user",
"user_type":{
}
},
"device":{
"is_WiFi":"0",
"device_type":"ios",
"device_id":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"lng":0,
"lat":0,
"ip":"10.156.100.97",
"manufacturer":"Apple",
"idfa":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"idfv":"352A6D64-17CA-4520-831A-2CE9507631D8"
},
"user_id":"30864538",
"type":"home_choiceness_card_exposure"
}
*/
public
class
BlPreciseExposureParamsBean
{
private
Integer
down_loading_times
;
private
Integer
down_slide_times
;
private
Integer
up_loading_times
;
private
Integer
up_slide_times
;
@JsonProperty
(
value
=
"page_name"
)
private
String
page_code
;
private
String
tab_name
;
private
String
business_id
;
@JsonProperty
(
value
=
"referrer"
)
private
String
referrer_code
;
private
String
referrer_id
;
private
BlPreciseExposureParamsExposureCardsBean
exposure_cards
;
private
String
is_exposure
;
private
String
filter
;
private
String
query
;
public
BlPreciseExposureParamsBean
()
{
}
public
Integer
getDown_loading_times
()
{
return
down_loading_times
;
}
public
void
setDown_loading_times
(
Integer
down_loading_times
)
{
this
.
down_loading_times
=
down_loading_times
;
}
public
Integer
getDown_slide_times
()
{
return
down_slide_times
;
}
public
void
setDown_slide_times
(
Integer
down_slide_times
)
{
this
.
down_slide_times
=
down_slide_times
;
}
public
Integer
getUp_loading_times
()
{
return
up_loading_times
;
}
public
void
setUp_loading_times
(
Integer
up_loading_times
)
{
this
.
up_loading_times
=
up_loading_times
;
}
public
Integer
getUp_slide_times
()
{
return
up_slide_times
;
}
public
void
setUp_slide_times
(
Integer
up_slide_times
)
{
this
.
up_slide_times
=
up_slide_times
;
}
public
String
getPage_code
()
{
return
page_code
;
}
public
void
setPage_code
(
String
page_code
)
{
this
.
page_code
=
page_code
;
}
public
String
getTab_name
()
{
return
tab_name
;
}
public
void
setTab_name
(
String
tab_name
)
{
this
.
tab_name
=
tab_name
;
}
public
String
getBusiness_id
()
{
return
business_id
;
}
public
void
setBusiness_id
(
String
business_id
)
{
this
.
business_id
=
business_id
;
}
public
String
getReferrer_code
()
{
return
referrer_code
;
}
public
void
setReferrer_code
(
String
referrer_code
)
{
this
.
referrer_code
=
referrer_code
;
}
public
String
getReferrer_id
()
{
return
referrer_id
;
}
public
void
setReferrer_id
(
String
referrer_id
)
{
this
.
referrer_id
=
referrer_id
;
}
public
BlPreciseExposureParamsExposureCardsBean
getExposure_cards
()
{
return
exposure_cards
;
}
public
void
setExposure_cards
(
BlPreciseExposureParamsExposureCardsBean
exposure_cards
)
{
this
.
exposure_cards
=
exposure_cards
;
}
public
String
getIs_exposure
()
{
return
is_exposure
;
}
public
void
setIs_exposure
(
String
is_exposure
)
{
this
.
is_exposure
=
is_exposure
;
}
public
String
getFilter
()
{
return
filter
;
}
public
void
setFilter
(
String
filter
)
{
this
.
filter
=
filter
;
}
public
String
getQuery
()
{
return
query
;
}
public
void
setQuery
(
String
query
)
{
this
.
query
=
query
;
}
public
BlPreciseExposureParamsBean
(
Integer
down_loading_times
,
Integer
down_slide_times
,
Integer
up_loading_times
,
Integer
up_slide_times
,
String
page_code
,
String
tab_name
,
String
business_id
,
String
referrer_code
,
String
referrer_id
,
BlPreciseExposureParamsExposureCardsBean
exposure_cards
,
String
is_exposure
,
String
filter
,
String
query
)
{
this
.
down_loading_times
=
down_loading_times
;
this
.
down_slide_times
=
down_slide_times
;
this
.
up_loading_times
=
up_loading_times
;
this
.
up_slide_times
=
up_slide_times
;
this
.
page_code
=
page_code
;
this
.
tab_name
=
tab_name
;
this
.
business_id
=
business_id
;
this
.
referrer_code
=
referrer_code
;
this
.
referrer_id
=
referrer_id
;
this
.
exposure_cards
=
exposure_cards
;
this
.
is_exposure
=
is_exposure
;
this
.
filter
=
filter
;
this
.
query
=
query
;
}
@Override
public
String
toString
()
{
return
"BlPreciseExposureParamsBean{"
+
"down_loading_times="
+
down_loading_times
+
", down_slide_times="
+
down_slide_times
+
", up_loading_times="
+
up_loading_times
+
", up_slide_times="
+
up_slide_times
+
", page_code='"
+
page_code
+
'\''
+
", tab_name='"
+
tab_name
+
'\''
+
", business_id='"
+
business_id
+
'\''
+
", referrer_code='"
+
referrer_code
+
'\''
+
", referrer_id='"
+
referrer_id
+
'\''
+
", exposure_cards="
+
exposure_cards
+
", is_exposure='"
+
is_exposure
+
'\''
+
", filter='"
+
filter
+
'\''
+
", query='"
+
query
+
'\''
+
'}'
;
}
}
src/main/java/com/gmei/bean/bl/BlPreciseExposureParamsExposureCardsBean.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
bl
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty
;
/**
* ClassName: BlPreciseExposureBean
* TableName: Bl_Et_Mg_PreciseExposure_Inc_D
* Function: TODO ADD FUNCTION.
* Reason: TODO ADD REASON.
* Date: 2019/12/3 下午5:07
*
* @author liuzhe
* @since JDK 1.8
*/
/*
{
"gm_nginx_key":2,
"version":"110",
"params":{
"up_slide_times":0,
"down_loading_times":0,
"exposure_cards":{
},
"up_loading_times":0,
"is_exposure":1,
"tab_name":"精选",
"referrer_id":"",
"down_slide_times":0,
"referrer":"",
"page_name":"home",
"business_id":""
},
"app_session_id":"C3280044-5C8E-459D-AE6C-8E26BBACD6C9",
"gm_nginx_timestamp":1546307958.631,
"create_at":"1546307958",
"app":{
"channel":"AppStore",
"version":"7.7.35",
"serial_id":42,
"current_city_id":"worldwide",
"name":"gengmei_user",
"user_type":{
}
},
"device":{
"is_WiFi":"0",
"device_type":"ios",
"device_id":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"lng":0,
"lat":0,
"ip":"10.156.100.97",
"manufacturer":"Apple",
"idfa":"DE8EA66A-BDE9-47CD-9795-24E444F5BC17",
"idfv":"352A6D64-17CA-4520-831A-2CE9507631D8"
},
"user_id":"30864538",
"type":"home_choiceness_card_exposure"
}
*/
/*
get_json_object(result_card,"$.card_id") as card_id, --卡片id
get_json_object(result_card,"$.card_content_type") as card_content_type, --卡片内容类型
get_json_object(result_card,"$.card_type") as card_type, --卡片类型
get_json_object(result_card,"$.transaction_type") as transaction_type, --卡片业务类型
get_json_object(result_card,"$.absolute_position") as absolute_position, --绝对位置
get_json_object(result_card,"$.relative_position") as relative_position, --相对位置
get_json_object(result_card,"$.filter_f") as filter_f,
get_json_object(result_card,"$.is_cpc") as is_cpc, --是否为cpc收费卡片
get_json_object(result_card,"$.cpc_referer") as cpc_referer, --cpc_referer
get_json_object(result_card,"$.in_page_pose ") as in_page_pose,
get_json_object(result_card,"$.result_status") as result_status, --结果状态
get_json_object(result_card,"$.sec_tab_name") as sec_tab_name, --二级页面名称
--非正常卡片通用参数(banner 豆腐块 icon)
get_json_object(result_card,"$.module_id") as module_id, --模块id
get_json_object(result_card,"$.card_name ") as card_name, --卡片名字
get_json_object(result_card,"$.url") as url, --跳转链接
--豆腐块额外参数
get_json_object(result_card,"$.module_type") as module_type, --模块类型
get_json_object(result_card,"$.grid") as grid, --区域 (a、b、c、d,目前线上最多四张图片)
--icon的额外参数
get_json_object(result_card,"$.total_position") as total_position,--总共有几屏
get_json_object(result_card,"$.current_position") as current_position --icon在第几屏
*/
public
class
BlPreciseExposureParamsExposureCardsBean
{
private
String
card_id
;
private
String
card_content_type
;
private
String
card_type
;
private
String
transaction_type
;
private
String
is_cpc
;
private
String
cpc_referer
;
private
String
absolute_position
;
private
String
relative_position
;
public
BlPreciseExposureParamsExposureCardsBean
()
{
}
public
String
getCard_type
()
{
return
card_type
;
}
public
void
setCard_type
(
String
card_type
)
{
this
.
card_type
=
card_type
;
}
public
String
getCpc_referer
()
{
return
cpc_referer
;
}
public
void
setCpc_referer
(
String
cpc_referer
)
{
this
.
cpc_referer
=
cpc_referer
;
}
public
String
getCard_id
()
{
return
card_id
;
}
public
void
setCard_id
(
String
card_id
)
{
this
.
card_id
=
card_id
;
}
public
String
getCard_content_type
()
{
return
card_content_type
;
}
public
void
setCard_content_type
(
String
card_content_type
)
{
this
.
card_content_type
=
card_content_type
;
}
public
String
getIs_cpc
()
{
return
is_cpc
;
}
public
void
setIs_cpc
(
String
is_cpc
)
{
this
.
is_cpc
=
is_cpc
;
}
public
String
getAbsolute_position
()
{
return
absolute_position
;
}
public
void
setAbsolute_position
(
String
absolute_position
)
{
this
.
absolute_position
=
absolute_position
;
}
public
String
getTransaction_type
()
{
return
transaction_type
;
}
public
void
setTransaction_type
(
String
transaction_type
)
{
this
.
transaction_type
=
transaction_type
;
}
public
String
getRelative_position
()
{
return
relative_position
;
}
public
void
setRelative_position
(
String
relative_position
)
{
this
.
relative_position
=
relative_position
;
}
public
BlPreciseExposureParamsExposureCardsBean
(
String
card_id
,
String
card_content_type
,
String
card_type
,
String
transaction_type
,
String
is_cpc
,
String
cpc_referer
,
String
absolute_position
,
String
relative_position
)
{
this
.
card_id
=
card_id
;
this
.
card_content_type
=
card_content_type
;
this
.
card_type
=
card_type
;
this
.
transaction_type
=
transaction_type
;
this
.
is_cpc
=
is_cpc
;
this
.
cpc_referer
=
cpc_referer
;
this
.
absolute_position
=
absolute_position
;
this
.
relative_position
=
relative_position
;
}
@Override
public
String
toString
()
{
return
"BlPreciseExposureParamsExposureCardsBean{"
+
"card_id='"
+
card_id
+
'\''
+
", card_content_type='"
+
card_content_type
+
'\''
+
", card_type='"
+
card_type
+
'\''
+
", transaction_type='"
+
transaction_type
+
'\''
+
", is_cpc='"
+
is_cpc
+
'\''
+
", cpc_referer='"
+
cpc_referer
+
'\''
+
", absolute_position='"
+
absolute_position
+
'\''
+
", relative_position='"
+
relative_position
+
'\''
+
'}'
;
}
}
src/main/java/com/gmei/bean/dim/DimCardContentType.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
dim
;
/**
* ClassName: DimCardContentType
* Function:
* Reason: 卡片内容类型DIM_CARD_CONTENT_TYPE
* Date: 2019/12/6 下午8:20
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimCardContentType
{
private
String
code
;
//编码
private
String
pk
;
//主键
private
String
name
;
//名称
private
String
memo
;
//说明
private
String
new_code
;
//转换后编码
private
Integer
oid
;
//排序
public
DimCardContentType
()
{
}
public
DimCardContentType
(
String
code
,
String
pk
,
String
name
,
String
memo
,
String
new_code
,
Integer
oid
)
{
this
.
code
=
code
;
this
.
pk
=
pk
;
this
.
name
=
name
;
this
.
memo
=
memo
;
this
.
new_code
=
new_code
;
this
.
oid
=
oid
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getPk
()
{
return
pk
;
}
public
void
setPk
(
String
pk
)
{
this
.
pk
=
pk
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getMemo
()
{
return
memo
;
}
public
void
setMemo
(
String
memo
)
{
this
.
memo
=
memo
;
}
public
String
getNew_code
()
{
return
new_code
;
}
public
void
setNew_code
(
String
new_code
)
{
this
.
new_code
=
new_code
;
}
public
Integer
getOid
()
{
return
oid
;
}
public
void
setOid
(
Integer
oid
)
{
this
.
oid
=
oid
;
}
@Override
public
String
toString
()
{
return
"DimCity{"
+
"code='"
+
code
+
'\''
+
", pk='"
+
pk
+
'\''
+
", name='"
+
name
+
'\''
+
", memo='"
+
memo
+
'\''
+
", new_code='"
+
new_code
+
'\''
+
", oid="
+
oid
+
'}'
;
}
}
src/main/java/com/gmei/bean/dim/DimCity.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
dim
;
/**
* ClassName: DimCity
* Function:
* Reason: 城市码表DIM_CITY
* Date: 2019/12/6 下午8:20
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimCity
{
private
String
code
;
//城市编码
private
String
pk
;
//城市TAGID
private
String
name
;
//城市名称
private
String
memo
;
//城市说明
private
String
parent_province_code
;
//省份编码
private
String
parent_province_pk
;
//省份TAGID
private
String
parent_province_name
;
//省份名称
private
String
parent_province_memo
;
//省份说明
private
String
parent_country_code
;
//国家编码
private
String
parent_country_pk
;
//国家TAGID
private
String
parent_country_name
;
//国家名称
private
String
parent_country_memo
;
//国家说明
private
String
parent_region_code
;
//区域编码
private
String
parent_region_pk
;
//区域ID
private
String
parent_region_name
;
//区域名称
private
String
parent_region_memo
;
//区域说明
private
Integer
oid
;
//排序
public
DimCity
()
{
}
public
DimCity
(
String
code
,
String
pk
,
String
name
,
String
memo
,
String
parent_province_code
,
String
parent_province_pk
,
String
parent_province_name
,
String
parent_province_memo
,
String
parent_country_code
,
String
parent_country_pk
,
String
parent_country_name
,
String
parent_country_memo
,
String
parent_region_code
,
String
parent_region_pk
,
String
parent_region_name
,
String
parent_region_memo
,
Integer
oid
)
{
this
.
code
=
code
;
this
.
pk
=
pk
;
this
.
name
=
name
;
this
.
memo
=
memo
;
this
.
parent_province_code
=
parent_province_code
;
this
.
parent_province_pk
=
parent_province_pk
;
this
.
parent_province_name
=
parent_province_name
;
this
.
parent_province_memo
=
parent_province_memo
;
this
.
parent_country_code
=
parent_country_code
;
this
.
parent_country_pk
=
parent_country_pk
;
this
.
parent_country_name
=
parent_country_name
;
this
.
parent_country_memo
=
parent_country_memo
;
this
.
parent_region_code
=
parent_region_code
;
this
.
parent_region_pk
=
parent_region_pk
;
this
.
parent_region_name
=
parent_region_name
;
this
.
parent_region_memo
=
parent_region_memo
;
this
.
oid
=
oid
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getPk
()
{
return
pk
;
}
public
void
setPk
(
String
pk
)
{
this
.
pk
=
pk
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getMemo
()
{
return
memo
;
}
public
void
setMemo
(
String
memo
)
{
this
.
memo
=
memo
;
}
public
String
getParent_province_code
()
{
return
parent_province_code
;
}
public
void
setParent_province_code
(
String
parent_province_code
)
{
this
.
parent_province_code
=
parent_province_code
;
}
public
String
getParent_province_pk
()
{
return
parent_province_pk
;
}
public
void
setParent_province_pk
(
String
parent_province_pk
)
{
this
.
parent_province_pk
=
parent_province_pk
;
}
public
String
getParent_province_name
()
{
return
parent_province_name
;
}
public
void
setParent_province_name
(
String
parent_province_name
)
{
this
.
parent_province_name
=
parent_province_name
;
}
public
String
getParent_province_memo
()
{
return
parent_province_memo
;
}
public
void
setParent_province_memo
(
String
parent_province_memo
)
{
this
.
parent_province_memo
=
parent_province_memo
;
}
public
String
getParent_country_code
()
{
return
parent_country_code
;
}
public
void
setParent_country_code
(
String
parent_country_code
)
{
this
.
parent_country_code
=
parent_country_code
;
}
public
String
getParent_country_pk
()
{
return
parent_country_pk
;
}
public
void
setParent_country_pk
(
String
parent_country_pk
)
{
this
.
parent_country_pk
=
parent_country_pk
;
}
public
String
getParent_country_name
()
{
return
parent_country_name
;
}
public
void
setParent_country_name
(
String
parent_country_name
)
{
this
.
parent_country_name
=
parent_country_name
;
}
public
String
getParent_country_memo
()
{
return
parent_country_memo
;
}
public
void
setParent_country_memo
(
String
parent_country_memo
)
{
this
.
parent_country_memo
=
parent_country_memo
;
}
public
String
getParent_region_code
()
{
return
parent_region_code
;
}
public
void
setParent_region_code
(
String
parent_region_code
)
{
this
.
parent_region_code
=
parent_region_code
;
}
public
String
getParent_region_pk
()
{
return
parent_region_pk
;
}
public
String
getParent_region_name
()
{
return
parent_region_name
;
}
public
void
setParent_region_name
(
String
parent_region_name
)
{
this
.
parent_region_name
=
parent_region_name
;
}
public
String
getParent_region_memo
()
{
return
parent_region_memo
;
}
public
void
setParent_region_memo
(
String
parent_region_memo
)
{
this
.
parent_region_memo
=
parent_region_memo
;
}
@Override
public
String
toString
()
{
return
"DimCity{"
+
"code='"
+
code
+
'\''
+
", pk='"
+
pk
+
'\''
+
", name='"
+
name
+
'\''
+
", memo='"
+
memo
+
'\''
+
", parent_province_code='"
+
parent_province_code
+
'\''
+
", parent_province_pk='"
+
parent_province_pk
+
'\''
+
", parent_province_name='"
+
parent_province_name
+
'\''
+
", parent_province_memo='"
+
parent_province_memo
+
'\''
+
", parent_country_code='"
+
parent_country_code
+
'\''
+
", parent_country_pk='"
+
parent_country_pk
+
'\''
+
", parent_country_name='"
+
parent_country_name
+
'\''
+
", parent_country_memo='"
+
parent_country_memo
+
'\''
+
", parent_region_code='"
+
parent_region_code
+
'\''
+
", parent_region_pk='"
+
parent_region_pk
+
'\''
+
", parent_region_name='"
+
parent_region_name
+
'\''
+
", parent_region_memo='"
+
parent_region_memo
+
'\''
+
", oid="
+
oid
+
'}'
;
}
public
void
setParent_region_pk
(
String
parent_region_pk
)
{
this
.
parent_region_pk
=
parent_region_pk
;
}
public
Integer
getOid
()
{
return
oid
;
}
public
void
setOid
(
Integer
oid
)
{
this
.
oid
=
oid
;
}
}
src/main/java/com/gmei/bean/dim/DimPageType.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
dim
;
/**
* ClassName: DimPageType
* Function:
* Reason: 页面类型码表DIM_PAGE_TYPE
* Date: 2019/12/6 下午8:20
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimPageType
{
private
String
code
;
//页面编码
private
String
pk
;
//页面主键
private
String
name
;
//页面名称
private
String
memo
;
//页面说明
private
String
parent_app_code
;
//上级APP编码
private
String
parent_app_pk
;
//上级APP主键
private
String
parent_app_name
;
//上级APP名称
private
String
parent_app_memo
;
//上级APP说明
private
String
type_s_code
;
//页面分类小类编码
private
String
type_s_name
;
//页面分类小类名称
private
String
type_m_code
;
//页面分类中类编码
private
String
type_m_name
;
//页面分类中类名称
private
String
type_l_code
;
//页面分类大类编码
private
String
type_l_name
;
//页面分类大类名称
private
Integer
oid
;
//排序
public
DimPageType
()
{
}
public
DimPageType
(
String
code
,
String
pk
,
String
name
,
String
memo
,
String
parent_app_code
,
String
parent_app_pk
,
String
parent_app_name
,
String
parent_app_memo
,
String
type_s_code
,
String
type_s_name
,
String
type_m_code
,
String
type_m_name
,
String
type_l_code
,
String
type_l_name
,
Integer
oid
)
{
this
.
code
=
code
;
this
.
pk
=
pk
;
this
.
name
=
name
;
this
.
memo
=
memo
;
this
.
parent_app_code
=
parent_app_code
;
this
.
parent_app_pk
=
parent_app_pk
;
this
.
parent_app_name
=
parent_app_name
;
this
.
parent_app_memo
=
parent_app_memo
;
this
.
type_s_code
=
type_s_code
;
this
.
type_s_name
=
type_s_name
;
this
.
type_m_code
=
type_m_code
;
this
.
type_m_name
=
type_m_name
;
this
.
type_l_code
=
type_l_code
;
this
.
type_l_name
=
type_l_name
;
this
.
oid
=
oid
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getPk
()
{
return
pk
;
}
public
void
setPk
(
String
pk
)
{
this
.
pk
=
pk
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getMemo
()
{
return
memo
;
}
public
void
setMemo
(
String
memo
)
{
this
.
memo
=
memo
;
}
public
String
getParent_app_code
()
{
return
parent_app_code
;
}
public
void
setParent_app_code
(
String
parent_app_code
)
{
this
.
parent_app_code
=
parent_app_code
;
}
public
String
getParent_app_pk
()
{
return
parent_app_pk
;
}
public
void
setParent_app_pk
(
String
parent_app_pk
)
{
this
.
parent_app_pk
=
parent_app_pk
;
}
public
String
getParent_app_name
()
{
return
parent_app_name
;
}
public
void
setParent_app_name
(
String
parent_app_name
)
{
this
.
parent_app_name
=
parent_app_name
;
}
public
String
getParent_app_memo
()
{
return
parent_app_memo
;
}
public
void
setParent_app_memo
(
String
parent_app_memo
)
{
this
.
parent_app_memo
=
parent_app_memo
;
}
public
String
getType_s_code
()
{
return
type_s_code
;
}
public
void
setType_s_code
(
String
type_s_code
)
{
this
.
type_s_code
=
type_s_code
;
}
public
String
getType_s_name
()
{
return
type_s_name
;
}
public
void
setType_s_name
(
String
type_s_name
)
{
this
.
type_s_name
=
type_s_name
;
}
public
String
getType_m_code
()
{
return
type_m_code
;
}
public
void
setType_m_code
(
String
type_m_code
)
{
this
.
type_m_code
=
type_m_code
;
}
public
String
getType_m_name
()
{
return
type_m_name
;
}
public
void
setType_m_name
(
String
type_m_name
)
{
this
.
type_m_name
=
type_m_name
;
}
public
String
getType_l_code
()
{
return
type_l_code
;
}
public
void
setType_l_code
(
String
type_l_code
)
{
this
.
type_l_code
=
type_l_code
;
}
public
String
getType_l_name
()
{
return
type_l_name
;
}
public
void
setType_l_name
(
String
type_l_name
)
{
this
.
type_l_name
=
type_l_name
;
}
public
Integer
getOid
()
{
return
oid
;
}
public
void
setOid
(
Integer
oid
)
{
this
.
oid
=
oid
;
}
@Override
public
String
toString
()
{
return
"DimPageType{"
+
"code='"
+
code
+
'\''
+
", pk='"
+
pk
+
'\''
+
", name='"
+
name
+
'\''
+
", memo='"
+
memo
+
'\''
+
", parent_app_code='"
+
parent_app_code
+
'\''
+
", parent_app_pk='"
+
parent_app_pk
+
'\''
+
", parent_app_name='"
+
parent_app_name
+
'\''
+
", parent_app_memo='"
+
parent_app_memo
+
'\''
+
", type_s_code='"
+
type_s_code
+
'\''
+
", type_s_name='"
+
type_s_name
+
'\''
+
", type_m_code='"
+
type_m_code
+
'\''
+
", type_m_name='"
+
type_m_name
+
'\''
+
", type_l_code='"
+
type_l_code
+
'\''
+
", type_l_name='"
+
type_l_name
+
'\''
+
", oid="
+
oid
+
'}'
;
}
}
src/main/java/com/gmei/bean/dim/DimTable.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
dim
;
/**
* ClassName: DimTable
* Function:
* Reason: 标准码表共用
* include DIM_CARD_TYPE、DIM_TRANSACTION_TYPE、DIM_CARD_CONTENT_TYPE
* Date: 2019/12/6 下午8:20
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimTable
{
private
String
code
;
//编码
private
String
pk
;
//主键
private
String
name
;
//名称
private
String
memo
;
//说明
private
Integer
oid
;
//排序
public
DimTable
()
{
}
public
DimTable
(
String
code
,
String
pk
,
String
name
,
String
memo
,
Integer
oid
)
{
this
.
code
=
code
;
this
.
pk
=
pk
;
this
.
name
=
name
;
this
.
memo
=
memo
;
this
.
oid
=
oid
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getPk
()
{
return
pk
;
}
public
void
setPk
(
String
pk
)
{
this
.
pk
=
pk
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getMemo
()
{
return
memo
;
}
public
void
setMemo
(
String
memo
)
{
this
.
memo
=
memo
;
}
public
Integer
getOid
()
{
return
oid
;
}
public
void
setOid
(
Integer
oid
)
{
this
.
oid
=
oid
;
}
@Override
public
String
toString
()
{
return
"DimCity{"
+
"code='"
+
code
+
'\''
+
", pk='"
+
pk
+
'\''
+
", name='"
+
name
+
'\''
+
", memo='"
+
memo
+
'\''
+
", oid="
+
oid
+
'}'
;
}
}
src/main/java/com/gmei/bean/ml/MlPreciseExposureBean.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
bean
.
ml
;
/**
* ClassName: MlPreciseExposureBean
* TableName: ML_C_ET_PE_PRECISEEXPOSURE_DIMEM_D_RT
* Function:
* Reason: ML层精准曝光BEAN类
* Date: 2019/12/3 下午5:07
*
* @author liuzhe
* @since JDK 1.8
*/
/*
get_json_object(result_card,"$.card_id") as card_id, --卡片id
get_json_object(result_card,"$.card_content_type") as card_content_type, --卡片内容类型
get_json_object(result_card,"$.card_type") as card_type, --卡片类型
get_json_object(result_card,"$.transaction_type") as transaction_type, --卡片业务类型
get_json_object(result_card,"$.absolute_position") as absolute_position, --绝对位置
get_json_object(result_card,"$.relative_position") as relative_position, --相对位置
get_json_object(result_card,"$.filter_f") as filter_f,
get_json_object(result_card,"$.is_cpc") as is_cpc, --是否为cpc收费卡片
get_json_object(result_card,"$.cpc_referer") as cpc_referer, --cpc_referer
get_json_object(result_card,"$.in_page_pose ") as in_page_pose,
get_json_object(result_card,"$.result_status") as result_status, --结果状态
get_json_object(result_card,"$.sec_tab_name") as sec_tab_name, --二级页面名称
--非正常卡片通用参数(banner 豆腐块 icon)
get_json_object(result_card,"$.module_id") as module_id, --模块id
get_json_object(result_card,"$.card_name ") as card_name, --卡片名字
get_json_object(result_card,"$.url") as url, --跳转链接
--豆腐块额外参数
get_json_object(result_card,"$.module_type") as module_type, --模块类型
get_json_object(result_card,"$.grid") as grid, --区域 (a、b、c、d,目前线上最多四张图片)
--icon的额外参数
get_json_object(result_card,"$.total_position") as total_position,--总共有几屏
get_json_object(result_card,"$.current_position") as current_position --icon在第几屏
*/
public
class
MlPreciseExposureBean
{
// private String gm_nginx_timestamp;
// private String create_timestamp;
private
String
user_id
;
private
String
action
;
// private String action_name; //匹配码表DIM_ACTION_TYPE(只有两种不需要关联)
private
String
page_code
;
private
String
page_name
;
//匹配码表DIM_PAGE_TYPE
private
String
tab_name
;
private
String
business_id
;
private
String
referrer_code
;
private
String
referrer_name
;
//匹配码表DIM_PAGE_TYPE
private
String
referrer_id
;
private
String
card_id
;
private
String
card_content_type
;
private
String
card_content_type_name
;
//匹配码表DIM_CARD_CONTENT_TYPE
private
String
card_type
;
private
String
card_type_name
;
//匹配码表DIM_CARD_TYPE
private
String
is_cpc
;
private
String
cpc_referer
;
// private String absolute_position;
// private String relative_position;
private
String
transaction_type
;
private
String
transaction_type_name
;
//匹配码表DIM_TRANSACTION_TYPE
private
String
filter
;
private
String
query
;
// private String app_grey_type;
// private String app_channel;
private
String
app_version
;
private
String
current_city_id
;
private
String
current_city_name
;
//匹配码表DIM_CITY
private
String
current_province_id
;
//匹配码表DIM_CITY
private
String
current_province_name
;
//匹配码表DIM_CITY
private
String
current_country_id
;
//匹配码表DIM_CITY
private
String
current_country_name
;
//匹配码表DIM_CITY
private
String
current_region_id
;
//匹配码表DIM_CITY
private
String
current_region_name
;
//匹配码表DIM_CITY
private
String
app_code
;
private
String
device_os_type
;
// private String device_model;
private
String
device_id
;
// private String device_android_id;
// private String device_idfv;
// private String gm_nginx_time_date;
// private String create_time_date;
private
String
create_time_day
;
private
String
gm_nginx_time_day
;
private
Integer
preciseexposure_num
;
public
MlPreciseExposureBean
()
{
}
public
MlPreciseExposureBean
(
String
user_id
,
String
action
,
String
page_code
,
String
page_name
,
String
tab_name
,
String
business_id
,
String
referrer_code
,
String
referrer_name
,
String
referrer_id
,
String
card_id
,
String
card_content_type
,
String
card_content_type_name
,
String
card_type
,
String
card_type_name
,
String
is_cpc
,
String
cpc_referer
,
String
transaction_type
,
String
transaction_type_name
,
String
filter
,
String
query
,
String
app_version
,
String
current_city_id
,
String
current_city_name
,
String
current_province_id
,
String
current_province_name
,
String
current_country_id
,
String
current_country_name
,
String
current_region_id
,
String
current_region_name
,
String
app_code
,
String
device_os_type
,
String
device_id
,
String
create_time_day
,
String
gm_nginx_time_day
,
Integer
preciseexposure_num
)
{
this
.
user_id
=
user_id
;
this
.
action
=
action
;
// this.action_name = action_name;
this
.
page_code
=
page_code
;
this
.
page_name
=
page_name
;
this
.
tab_name
=
tab_name
;
this
.
business_id
=
business_id
;
this
.
referrer_code
=
referrer_code
;
this
.
referrer_name
=
referrer_name
;
this
.
referrer_id
=
referrer_id
;
this
.
card_id
=
card_id
;
this
.
card_content_type
=
card_content_type
;
this
.
card_content_type_name
=
card_content_type_name
;
this
.
card_type
=
card_type
;
this
.
card_type_name
=
card_type_name
;
this
.
is_cpc
=
is_cpc
;
this
.
cpc_referer
=
cpc_referer
;
this
.
transaction_type
=
transaction_type
;
this
.
transaction_type_name
=
transaction_type_name
;
this
.
filter
=
filter
;
this
.
query
=
query
;
// this.app_channel = app_channel;
this
.
app_version
=
app_version
;
this
.
current_city_id
=
current_city_id
;
this
.
current_city_name
=
current_city_name
;
this
.
current_province_id
=
current_province_id
;
this
.
current_province_name
=
current_province_name
;
this
.
current_country_id
=
current_country_id
;
this
.
current_country_name
=
current_country_name
;
this
.
current_region_id
=
current_region_id
;
this
.
current_region_name
=
current_region_name
;
this
.
app_code
=
app_code
;
this
.
device_os_type
=
device_os_type
;
this
.
device_id
=
device_id
;
this
.
create_time_day
=
create_time_day
;
this
.
gm_nginx_time_day
=
gm_nginx_time_day
;
this
.
preciseexposure_num
=
preciseexposure_num
;
}
public
String
getUser_id
()
{
return
user_id
;
}
public
void
setUser_id
(
String
user_id
)
{
this
.
user_id
=
user_id
;
}
public
String
getAction
()
{
return
action
;
}
public
void
setAction
(
String
action
)
{
this
.
action
=
action
;
}
// public String getAction_name() {
// return action_name;
// }
// public void setAction_name(String action_name) {
// this.action_name = action_name;
// }
public
String
getPage_code
()
{
return
page_code
;
}
public
void
setPage_code
(
String
page_code
)
{
this
.
page_code
=
page_code
;
}
public
String
getPage_name
()
{
return
page_name
;
}
public
void
setPage_name
(
String
page_name
)
{
this
.
page_name
=
page_name
;
}
public
String
getTab_name
()
{
return
tab_name
;
}
public
void
setTab_name
(
String
tab_name
)
{
this
.
tab_name
=
tab_name
;
}
public
String
getBusiness_id
()
{
return
business_id
;
}
public
void
setBusiness_id
(
String
business_id
)
{
this
.
business_id
=
business_id
;
}
public
String
getReferrer_code
()
{
return
referrer_code
;
}
public
void
setReferrer_code
(
String
referrer_code
)
{
this
.
referrer_code
=
referrer_code
;
}
public
String
getReferrer_name
()
{
return
referrer_name
;
}
public
void
setReferrer_name
(
String
referrer_name
)
{
this
.
referrer_name
=
referrer_name
;
}
public
String
getReferrer_id
()
{
return
referrer_id
;
}
public
void
setReferrer_id
(
String
referrer_id
)
{
this
.
referrer_id
=
referrer_id
;
}
public
String
getCard_id
()
{
return
card_id
;
}
public
void
setCard_id
(
String
card_id
)
{
this
.
card_id
=
card_id
;
}
public
String
getCard_content_type
()
{
return
card_content_type
;
}
public
void
setCard_content_type
(
String
card_content_type
)
{
this
.
card_content_type
=
card_content_type
;
}
public
String
getCard_content_type_name
()
{
return
card_content_type_name
;
}
public
void
setCard_content_type_name
(
String
card_content_type_name
)
{
this
.
card_content_type_name
=
card_content_type_name
;
}
public
String
getCard_type
()
{
return
card_type
;
}
public
void
setCard_type
(
String
card_type
)
{
this
.
card_type
=
card_type
;
}
public
String
getCard_type_name
()
{
return
card_type_name
;
}
public
void
setCard_type_name
(
String
card_type_name
)
{
this
.
card_type_name
=
card_type_name
;
}
public
String
getIs_cpc
()
{
return
is_cpc
;
}
public
void
setIs_cpc
(
String
is_cpc
)
{
this
.
is_cpc
=
is_cpc
;
}
public
String
getCpc_referer
()
{
return
cpc_referer
;
}
public
void
setCpc_referer
(
String
cpc_referer
)
{
this
.
cpc_referer
=
cpc_referer
;
}
// public String getAbsolute_position() {
// return absolute_position;
// }
//
// public void setAbsolute_position(String absolute_position) {
// this.absolute_position = absolute_position;
// }
//
// public String getRelative_position() {
// return relative_position;
// }
//
// public void setRelative_position(String relative_position) {
// this.relative_position = relative_position;
// }
public
String
getTransaction_type
()
{
return
transaction_type
;
}
public
void
setTransaction_type
(
String
transaction_type
)
{
this
.
transaction_type
=
transaction_type
;
}
public
String
getTransaction_type_name
()
{
return
transaction_type_name
;
}
public
void
setTransaction_type_name
(
String
transaction_type_name
)
{
this
.
transaction_type_name
=
transaction_type_name
;
}
public
String
getFilter
()
{
return
filter
;
}
public
void
setFilter
(
String
filter
)
{
this
.
filter
=
filter
;
}
public
String
getQuery
()
{
return
query
;
}
public
void
setQuery
(
String
query
)
{
this
.
query
=
query
;
}
// public String getApp_channel() {
// return app_channel;
// }
// public void setApp_channel(String app_channel) {
// this.app_channel = app_channel;
// }
public
String
getApp_version
()
{
return
app_version
;
}
public
void
setApp_version
(
String
app_version
)
{
this
.
app_version
=
app_version
;
}
public
String
getCurrent_city_id
()
{
return
current_city_id
;
}
public
void
setCurrent_city_id
(
String
current_city_id
)
{
this
.
current_city_id
=
current_city_id
;
}
public
String
getCurrent_city_name
()
{
return
current_city_name
;
}
public
void
setCurrent_city_name
(
String
current_city_name
)
{
this
.
current_city_name
=
current_city_name
;
}
public
String
getCurrent_province_id
()
{
return
current_province_id
;
}
public
void
setCurrent_province_id
(
String
current_province_id
)
{
this
.
current_province_id
=
current_province_id
;
}
public
String
getCurrent_province_name
()
{
return
current_province_name
;
}
public
void
setCurrent_province_name
(
String
current_province_name
)
{
this
.
current_province_name
=
current_province_name
;
}
public
String
getCurrent_country_id
()
{
return
current_country_id
;
}
public
void
setCurrent_country_id
(
String
current_country_id
)
{
this
.
current_country_id
=
current_country_id
;
}
public
String
getCurrent_country_name
()
{
return
current_country_name
;
}
public
void
setCurrent_country_name
(
String
current_country_name
)
{
this
.
current_country_name
=
current_country_name
;
}
public
String
getCurrent_region_id
()
{
return
current_region_id
;
}
public
void
setCurrent_region_id
(
String
current_region_id
)
{
this
.
current_region_id
=
current_region_id
;
}
public
String
getCurrent_region_name
()
{
return
current_region_name
;
}
public
void
setCurrent_region_name
(
String
current_region_name
)
{
this
.
current_region_name
=
current_region_name
;
}
public
String
getApp_code
()
{
return
app_code
;
}
public
void
setApp_code
(
String
app_code
)
{
this
.
app_code
=
app_code
;
}
public
String
getDevice_os_type
()
{
return
device_os_type
;
}
public
void
setDevice_os_type
(
String
device_os_type
)
{
this
.
device_os_type
=
device_os_type
;
}
public
String
getDevice_id
()
{
return
device_id
;
}
public
void
setDevice_id
(
String
device_id
)
{
this
.
device_id
=
device_id
;
}
public
String
getCreate_time_day
()
{
return
create_time_day
;
}
public
void
setCreate_time_day
(
String
create_time_day
)
{
this
.
create_time_day
=
create_time_day
;
}
public
String
getGm_nginx_time_day
()
{
return
gm_nginx_time_day
;
}
public
void
setGm_nginx_time_day
(
String
gm_nginx_time_day
)
{
this
.
gm_nginx_time_day
=
gm_nginx_time_day
;
}
public
Integer
getPreciseexposure_num
()
{
return
preciseexposure_num
;
}
public
void
setPreciseexposure_num
(
Integer
preciseexposure_num
)
{
this
.
preciseexposure_num
=
preciseexposure_num
;
}
// @Override
//// public String toString() {
//// return user_id + '\001' +
//// action + '\001' +
////// action_name + '\001' +
//// page_code + '\001' +
//// page_name + '\001' +
//// tab_name + '\001' +
//// business_id + '\001' +
//// referrer_code + '\001' +
//// referrer_name + '\001' +
//// referrer_id + '\001' +
//// card_id + '\001' +
//// card_content_type + '\001' +
//// card_content_type_name + '\001' +
//// card_type + '\001' +
//// card_type_name + '\001' +
//// is_cpc + '\001' +
//// cpc_referer + '\001' +
//// transaction_type + '\001' +
//// transaction_type_name + '\001' +
//// filter + '\001' +
//// query + '\001' +
////// app_channel + '\001' +
//// app_version + '\001' +
//// current_city_id + '\001' +
//// current_city_name + '\001' +
//// current_province_id + '\001' +
//// current_province_name + '\001' +
//// current_country_id + '\001' +
//// current_country_name + '\001' +
//// current_region_id + '\001' +
//// current_region_name + '\001' +
//// app_code + '\001' +
//// device_os_type + '\001' +
//// device_id + '\001' +
//// create_time_day + '\001' +
//// gm_nginx_time_day + '\001' +
//// preciseexposure_num;
//// }
@Override
public
String
toString
()
{
return
"MlPreciseExposureBean{"
+
"user_id='"
+
user_id
+
'\''
+
", action='"
+
action
+
'\''
+
", page_code='"
+
page_code
+
'\''
+
", page_name='"
+
page_name
+
'\''
+
", tab_name='"
+
tab_name
+
'\''
+
", business_id='"
+
business_id
+
'\''
+
", referrer_code='"
+
referrer_code
+
'\''
+
", referrer_name='"
+
referrer_name
+
'\''
+
", referrer_id='"
+
referrer_id
+
'\''
+
", card_id='"
+
card_id
+
'\''
+
", card_content_type='"
+
card_content_type
+
'\''
+
", card_content_type_name='"
+
card_content_type_name
+
'\''
+
", card_type='"
+
card_type
+
'\''
+
", card_type_name='"
+
card_type_name
+
'\''
+
", is_cpc='"
+
is_cpc
+
'\''
+
", cpc_referer='"
+
cpc_referer
+
'\''
+
", transaction_type='"
+
transaction_type
+
'\''
+
", transaction_type_name='"
+
transaction_type_name
+
'\''
+
", filter='"
+
filter
+
'\''
+
", query='"
+
query
+
'\''
+
", app_version='"
+
app_version
+
'\''
+
", current_city_id='"
+
current_city_id
+
'\''
+
", current_city_name='"
+
current_city_name
+
'\''
+
", current_province_id='"
+
current_province_id
+
'\''
+
", current_province_name='"
+
current_province_name
+
'\''
+
", current_country_id='"
+
current_country_id
+
'\''
+
", current_country_name='"
+
current_country_name
+
'\''
+
", current_region_id='"
+
current_region_id
+
'\''
+
", current_region_name='"
+
current_region_name
+
'\''
+
", app_code='"
+
app_code
+
'\''
+
", device_os_type='"
+
device_os_type
+
'\''
+
", device_id='"
+
device_id
+
'\''
+
", create_time_day='"
+
create_time_day
+
'\''
+
", gm_nginx_time_day='"
+
gm_nginx_time_day
+
'\''
+
", preciseexposure_num="
+
preciseexposure_num
+
'}'
;
}
}
src/main/java/com/gmei/cache/CacheServiceAbstract.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
java.util.Map
;
import
java.util.concurrent.Callable
;
/**
* ClassName: CacheServiceAbstract
* Function:
* Reason: 缓存抽象类
* Date: 2019/12/10 下午7:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
abstract
class
CacheServiceAbstract
<
K
,
V
>
{
abstract
V
getValue
(
K
key
,
Callable
<
V
>
callable
);
// abstract V getValue(K key, Callable<Optional<V>> callable);
abstract
void
clearCache
();
abstract
Long
cacheSize
();
abstract
void
putValue
(
K
key
,
V
value
);
abstract
void
invalidate
(
Object
key
);
// abstract void putValues(ArrayList<V> ts);
abstract
void
putValues
(
Map
<
K
,
V
>
map
);
}
src/main/java/com/gmei/cache/DimCardContentTypeDao.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.dim.DimCardContentType
;
import
com.gmei.jdbc.MysqlJdbcDim
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
/**
* ClassName: DimCardContentTypeDao
* Function:
* Reason: dim_card_content_type卡片内容类型数据库操作类
* Date: 2019/12/10 下午7:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimCardContentTypeDao
{
private
MysqlJdbcDim
mysqlJdbcDim
;
private
ResultSet
resultSet
;
private
String
sql
;
private
String
dimJdbcUrl
;
public
DimCardContentTypeDao
()
{
}
public
DimCardContentTypeDao
(
String
dimJdbcUrl
)
{
this
.
dimJdbcUrl
=
dimJdbcUrl
;
this
.
mysqlJdbcDim
=
MysqlJdbcDim
.
getInstance
(
dimJdbcUrl
);
}
/**
* Function: findAllDimCardContentType
* Reason: 查询所有卡片内容类型信息
* Date: 2019/12/25 下午5:32
*
* @author liuzhe
* @since JDK 1.8
*/
public
ArrayList
<
DimCardContentType
>
findAllDimCardContentType
(
String
tableName
)
{
sql
=
String
.
format
(
"select code, pk, name, memo, new_code"
+
" from %s"
,
tableName
);
ArrayList
<
DimCardContentType
>
dimCardContentTypeList
=
new
ArrayList
<>();
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
try
{
while
(
resultSet
.
next
())
{
DimCardContentType
dimCardContentType
=
new
DimCardContentType
();
dimCardContentType
.
setCode
(
resultSet
.
getString
(
1
));
dimCardContentType
.
setPk
(
resultSet
.
getString
(
2
));
dimCardContentType
.
setName
(
resultSet
.
getString
(
3
));
dimCardContentType
.
setMemo
(
resultSet
.
getString
(
4
));
dimCardContentType
.
setNew_code
(
resultSet
.
getString
(
5
));
dimCardContentTypeList
.
add
(
dimCardContentType
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
resultSet
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
return
dimCardContentTypeList
;
}
/**
* Function: findDimCardContentTypeByCode
* Reason: 通过卡片内容类型编码查询信息
* Date: 2019/12/25 下午5:34
*
* @author liuzhe
* @since JDK 1.8
*/
public
DimCardContentType
findDimCardContentTypeByCode
(
String
tableName
,
String
code
){
if
(
code
==
null
||
code
.
trim
().
length
()
==
0
)
{
return
null
;
}
else
{
code
=
code
.
trim
();
}
String
sql
=
String
.
format
(
"select code, pk, name, memo, new_code "
+
" from %s "
+
" where code = '%s'"
,
tableName
,
code
);
DimCardContentType
dimCardContentType
=
new
DimCardContentType
();
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
try
{
while
(
resultSet
.
next
())
{
dimCardContentType
.
setCode
(
code
);
dimCardContentType
.
setPk
(
resultSet
.
getString
(
2
));
dimCardContentType
.
setName
(
resultSet
.
getString
(
3
));
dimCardContentType
.
setMemo
(
resultSet
.
getString
(
4
));
dimCardContentType
.
setNew_code
(
resultSet
.
getString
(
5
));
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
mysqlJdbcDim
.
close
(
null
,
null
,
resultSet
);
}
return
dimCardContentType
;
}
}
\ No newline at end of file
src/main/java/com/gmei/cache/DimCityDao.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.dim.DimCity
;
import
com.gmei.jdbc.MysqlJdbcDim
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
/**
* ClassName: DimCityDao
* Function:
* Reason: dim_city城市码表数据库操作类
* Date: 2019/12/10 下午7:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimCityDao
{
private
MysqlJdbcDim
mysqlJdbcDim
;
private
ResultSet
resultSet
;
private
String
sql
;
private
Connection
conn
;
private
String
dimJdbcUrl
;
public
DimCityDao
()
{
}
public
DimCityDao
(
String
dimJdbcUrl
)
{
this
.
dimJdbcUrl
=
dimJdbcUrl
;
this
.
mysqlJdbcDim
=
MysqlJdbcDim
.
getInstance
(
dimJdbcUrl
);
}
/**
* Function: findDimCityByCode
* Reason: 根据城市ID查询城市信息
* Date: 2019/12/7 下午7:56
*
* @author liuzhe
* @since JDK 1.8
*/
public
DimCity
findDimCityByCode
(
String
tableName
,
String
code
){
if
(
code
==
null
||
code
.
trim
().
length
()
==
0
)
{
return
null
;
}
else
{
code
=
code
.
trim
();
}
mysqlJdbcDim
.
getConnection
();
String
sql
=
String
.
format
(
"select code, pk, name, memo, "
+
" parent_province_code, parent_province_pk, parent_province_memo,"
+
" parent_country_code, parent_country_pk, parent_country_name,"
+
" parent_region_code, parent_region_pk, parent_region_name "
+
" from %s "
+
" where code = '%s'"
,
tableName
,
code
);
// ArrayList<DimCity> dimCityList = new ArrayList<>();
DimCity
dimCity
=
new
DimCity
();
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
try
{
while
(
resultSet
.
next
())
{
dimCity
.
setCode
(
code
);
dimCity
.
setPk
(
resultSet
.
getString
(
2
));
dimCity
.
setName
(
resultSet
.
getString
(
3
));
dimCity
.
setMemo
(
resultSet
.
getString
(
4
));
dimCity
.
setParent_province_code
(
resultSet
.
getString
(
5
));
dimCity
.
setParent_province_pk
(
resultSet
.
getString
(
6
));
dimCity
.
setParent_province_name
(
resultSet
.
getString
(
7
));
dimCity
.
setParent_country_code
(
resultSet
.
getString
(
8
));
dimCity
.
setParent_country_pk
(
resultSet
.
getString
(
9
));
dimCity
.
setParent_country_name
(
resultSet
.
getString
(
10
));
dimCity
.
setParent_region_code
(
resultSet
.
getString
(
11
));
dimCity
.
setParent_region_pk
(
resultSet
.
getString
(
12
));
dimCity
.
setParent_region_name
(
resultSet
.
getString
(
13
));
// dimCityList.add(dimCity);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
mysqlJdbcDim
.
close
(
null
,
null
,
resultSet
);
}
return
dimCity
;
}
/**
* Function: findDimCityByPk
* Reason: 根据城市TAGID查询城市信息
* Date: 2019/12/7 下午7:56
*
* @author liuzhe
* @since JDK 1.8
*/
public
DimCity
findDimCityByPk
(
String
tableName
,
String
pk
){
if
(
pk
==
null
||
pk
.
trim
().
length
()
==
0
)
{
return
null
;
}
pk
=
pk
.
trim
();
mysqlJdbcDim
.
getConnection
();
String
sql
=
String
.
format
(
"select code, pk, name, memo, "
+
" parent_province_code, parent_province_pk, parent_province_memo,"
+
" parent_country_code, parent_country_pk, parent_country_name,"
+
" parent_region_code, parent_region_pk, parent_region_name "
+
" from %s "
+
" where pk = '%s'"
,
tableName
,
pk
);
// ArrayList<DimCity> dimCityList = new ArrayList<>();
DimCity
dimCity
=
new
DimCity
();
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
try
{
while
(
resultSet
.
next
())
{
dimCity
.
setCode
(
resultSet
.
getString
(
1
));
dimCity
.
setPk
(
pk
);
dimCity
.
setName
(
resultSet
.
getString
(
3
));
dimCity
.
setMemo
(
resultSet
.
getString
(
4
));
dimCity
.
setParent_province_code
(
resultSet
.
getString
(
5
));
dimCity
.
setParent_province_pk
(
resultSet
.
getString
(
6
));
dimCity
.
setParent_province_name
(
resultSet
.
getString
(
7
));
dimCity
.
setParent_country_code
(
resultSet
.
getString
(
8
));
dimCity
.
setParent_country_pk
(
resultSet
.
getString
(
9
));
dimCity
.
setParent_country_name
(
resultSet
.
getString
(
10
));
dimCity
.
setParent_region_code
(
resultSet
.
getString
(
11
));
dimCity
.
setParent_region_pk
(
resultSet
.
getString
(
12
));
dimCity
.
setParent_region_name
(
resultSet
.
getString
(
13
));
// dimCityList.add(dimCity);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
mysqlJdbcDim
.
close
(
conn
,
null
,
resultSet
);
}
return
dimCity
;
}
/**
* Function: findAllDimCity
* Reason: 查询所有城市信息
* Date: 2019/12/25 下午5:21
*
* @author liuzhe
* @since JDK 1.8
*/
public
ArrayList
<
DimCity
>
findAllDimCity
(
String
tableName
)
{
mysqlJdbcDim
.
getConnection
();
sql
=
String
.
format
(
"select code, pk, name, memo, "
+
" parent_province_code, parent_province_pk, parent_province_memo,"
+
" parent_country_code, parent_country_pk, parent_country_name,"
+
" parent_region_code, parent_region_pk, parent_region_name "
+
" from %s"
,
tableName
);
ArrayList
<
DimCity
>
dimCityList
=
new
ArrayList
<>();
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
try
{
while
(
resultSet
.
next
())
{
DimCity
dimCity
=
new
DimCity
();
dimCity
.
setCode
(
resultSet
.
getString
(
1
));
dimCity
.
setPk
(
resultSet
.
getString
(
2
));
dimCity
.
setName
(
resultSet
.
getString
(
3
));
dimCity
.
setMemo
(
resultSet
.
getString
(
4
));
dimCity
.
setParent_province_code
(
resultSet
.
getString
(
5
));
dimCity
.
setParent_province_pk
(
resultSet
.
getString
(
6
));
dimCity
.
setParent_province_name
(
resultSet
.
getString
(
7
));
dimCity
.
setParent_country_code
(
resultSet
.
getString
(
8
));
dimCity
.
setParent_country_pk
(
resultSet
.
getString
(
9
));
dimCity
.
setParent_country_name
(
resultSet
.
getString
(
10
));
dimCity
.
setParent_region_code
(
resultSet
.
getString
(
11
));
dimCity
.
setParent_region_pk
(
resultSet
.
getString
(
12
));
dimCity
.
setParent_region_name
(
resultSet
.
getString
(
13
));
dimCityList
.
add
(
dimCity
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
resultSet
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
return
dimCityList
;
}
}
src/main/java/com/gmei/cache/DimPageTypeDao.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.dim.DimPageType
;
import
com.gmei.jdbc.MysqlJdbcDim
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
/**
* ClassName: DimPageTypeDao
* Function:
* Reason: dim_page_type页面名称标准化就三级分类码表数据库操作类
* Date: 2019/12/10 下午7:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimPageTypeDao
{
private
MysqlJdbcDim
mysqlJdbcDim
;
private
ResultSet
resultSet
;
private
String
sql
;
private
Connection
conn
;
private
String
dimJdbcUrl
;
public
DimPageTypeDao
()
{
}
public
DimPageTypeDao
(
String
dimJdbcUrl
)
{
this
.
dimJdbcUrl
=
dimJdbcUrl
;
this
.
mysqlJdbcDim
=
MysqlJdbcDim
.
getInstance
(
dimJdbcUrl
);
}
/**
* Function: findAllDimPageType
* Reason: 查询所有页面信息(gengmei_user)
* Date: 2019/12/25 下午5:23
*
* @author liuzhe
* @since JDK 1.8
*/
public
ArrayList
<
DimPageType
>
findAllDimPageType
(
String
tableName
)
{
mysqlJdbcDim
.
getConnection
();
sql
=
String
.
format
(
"select code, pk, name, memo, "
+
" parent_app_code, parent_app_pk, parent_app_name, "
+
" type_s_code, type_s_name, "
+
" type_m_code, type_m_name, "
+
" type_l_code, type_l_name "
+
" from %s"
+
" where parent_app_code = 'gengmei_user'"
,
tableName
);
ArrayList
<
DimPageType
>
dimPageTypeList
=
new
ArrayList
<>();
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
try
{
while
(
resultSet
.
next
())
{
DimPageType
dimPageType
=
new
DimPageType
();
dimPageType
.
setCode
(
resultSet
.
getString
(
1
));
dimPageType
.
setPk
(
resultSet
.
getString
(
2
));
dimPageType
.
setName
(
resultSet
.
getString
(
3
));
dimPageType
.
setMemo
(
resultSet
.
getString
(
4
));
dimPageType
.
setParent_app_code
(
resultSet
.
getString
(
5
));
dimPageType
.
setParent_app_pk
(
resultSet
.
getString
(
6
));
dimPageType
.
setParent_app_name
(
resultSet
.
getString
(
7
));
dimPageType
.
setType_s_code
(
resultSet
.
getString
(
8
));
dimPageType
.
setType_s_name
(
resultSet
.
getString
(
9
));
dimPageType
.
setType_m_code
(
resultSet
.
getString
(
10
));
dimPageType
.
setType_m_name
(
resultSet
.
getString
(
11
));
dimPageType
.
setType_l_code
(
resultSet
.
getString
(
12
));
dimPageType
.
setType_l_name
(
resultSet
.
getString
(
13
));
dimPageTypeList
.
add
(
dimPageType
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
mysqlJdbcDim
.
close
(
null
,
null
,
resultSet
);
}
return
dimPageTypeList
;
}
/**
* Function: findDimPageTypeByCode
* Reason: 根据页面编码查询页面信息(gengmei_user)
* Date: 2019/12/25 下午5:23
*
* @author liuzhe
* @since JDK 1.8
*/
public
DimPageType
findDimPageTypeByCode
(
String
tableName
,
String
code
){
if
(
code
==
null
||
code
.
trim
().
length
()
==
0
)
{
return
null
;
}
else
{
code
=
code
.
trim
();
}
mysqlJdbcDim
.
getConnection
();
String
sql
=
String
.
format
(
"select code, pk, name, memo, "
+
" parent_app_code, parent_app_pk, parent_app_name, "
+
" type_s_code, type_s_name, "
+
" type_m_code, type_m_name, "
+
" type_l_code, type_l_name "
+
" from %s"
+
" where parent_app_code = 'gengmei_user'"
+
" and code = '%s'"
,
tableName
,
code
);
// ArrayList<DimPageType> dimPageTypeList = new ArrayList<>();
DimPageType
dimPageType
=
new
DimPageType
();
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
try
{
while
(
resultSet
.
next
())
{
dimPageType
.
setCode
(
code
);
dimPageType
.
setPk
(
resultSet
.
getString
(
2
));
dimPageType
.
setName
(
resultSet
.
getString
(
3
));
dimPageType
.
setMemo
(
resultSet
.
getString
(
4
));
dimPageType
.
setParent_app_code
(
resultSet
.
getString
(
5
));
dimPageType
.
setParent_app_pk
(
resultSet
.
getString
(
6
));
dimPageType
.
setParent_app_name
(
resultSet
.
getString
(
7
));
dimPageType
.
setType_s_code
(
resultSet
.
getString
(
8
));
dimPageType
.
setType_s_name
(
resultSet
.
getString
(
9
));
dimPageType
.
setType_m_code
(
resultSet
.
getString
(
10
));
dimPageType
.
setType_m_name
(
resultSet
.
getString
(
11
));
dimPageType
.
setType_l_code
(
resultSet
.
getString
(
12
));
dimPageType
.
setType_l_name
(
resultSet
.
getString
(
13
));
// dimPageTypeList.add(dimPageType);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
mysqlJdbcDim
.
close
(
null
,
null
,
resultSet
);
}
return
dimPageType
;
}
}
src/main/java/com/gmei/cache/DimTableCallable.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.dim.DimCity
;
import
com.gmei.utils.DimTableList
;
import
java.util.concurrent.Callable
;
/**
* ClassName: DimTableCallable
* Function:
* Reason: 通用Dim码表多线程调用类
* Date: 2019/12/6 下午9:05t
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimTableCallable
<
V
>
implements
Callable
<
V
>
{
private
String
code
;
private
String
tableName
;
private
String
dimJdbcUrl
;
public
DimTableCallable
(
String
code
,
String
tableName
,
String
dimJdbcUrl
)
{
this
.
code
=
code
;
this
.
tableName
=
tableName
;
this
.
dimJdbcUrl
=
dimJdbcUrl
;
}
public
DimTableCallable
()
{}
@Override
public
V
call
()
{
// try {
if
(
code
==
null
)
{
switch
(
DimTableList
.
getDimTableByName
(
tableName
))
{
case
DIM_CITY:
DimCityDao
dimCityDao
=
new
DimCityDao
(
dimJdbcUrl
);
return
(
V
)
dimCityDao
.
findAllDimCity
(
tableName
);
case
DIM_CARD_CONTENT_TYPE:
DimCardContentTypeDao
dimCardContentTypeDao
=
new
DimCardContentTypeDao
(
dimJdbcUrl
);
return
(
V
)
dimCardContentTypeDao
.
findAllDimCardContentType
(
tableName
);
case
DIM_TRANSACTION_TYPE:
DimTableDao
dimTransactionTypeDao
=
new
DimTableDao
(
dimJdbcUrl
);
return
(
V
)
dimTransactionTypeDao
.
findAllDimTable
(
tableName
);
case
DIM_PAGE_TYPE:
DimPageTypeDao
dimPageTypeDao
=
new
DimPageTypeDao
(
dimJdbcUrl
);
return
(
V
)
dimPageTypeDao
.
findAllDimPageType
(
tableName
);
case
DIM_CARD_TYPE:
DimTableDao
dimCardTypeDao
=
new
DimTableDao
(
dimJdbcUrl
);
return
(
V
)
dimCardTypeDao
.
findAllDimTable
(
tableName
);
default
:
return
null
;
}
}
else
{
switch
(
DimTableList
.
getDimTableByName
(
tableName
))
{
case
DIM_CITY:
DimCityDao
dimCityDao
=
new
DimCityDao
(
dimJdbcUrl
);
DimCity
dimCity
=
dimCityDao
.
findDimCityByCode
(
tableName
,
code
);
if
(
dimCity
==
null
)
{
dimCity
=
dimCityDao
.
findDimCityByPk
(
tableName
,
code
);
}
return
(
V
)
dimCity
;
case
DIM_CARD_CONTENT_TYPE:
DimCardContentTypeDao
dimCardContentTypeDao
=
new
DimCardContentTypeDao
(
dimJdbcUrl
);
return
(
V
)
dimCardContentTypeDao
.
findDimCardContentTypeByCode
(
tableName
,
code
);
case
DIM_TRANSACTION_TYPE:
DimTableDao
dimTransactionTypeDao
=
new
DimTableDao
(
dimJdbcUrl
);
return
(
V
)
dimTransactionTypeDao
.
findDimTableByCode
(
tableName
,
code
);
case
DIM_PAGE_TYPE:
DimPageTypeDao
dimPageTypeDao
=
new
DimPageTypeDao
(
dimJdbcUrl
);
return
(
V
)
dimPageTypeDao
.
findDimPageTypeByCode
(
tableName
,
code
);
case
DIM_CARD_TYPE:
DimTableDao
dimCardTypeDao
=
new
DimTableDao
(
dimJdbcUrl
);
return
(
V
)
dimCardTypeDao
.
findDimTableByCode
(
tableName
,
code
);
default
:
return
null
;
}
}
// } catch (Exception e) {
// e.printStackTrace();
// return null;
// }
}
}
src/main/java/com/gmei/cache/DimTableDao.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.dim.DimTable
;
import
com.gmei.jdbc.MysqlJdbcDim
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
/**
* ClassName: DimTableDao
* Function:
* Reason: 通用Dim码表
* Date: 2019/12/10 下午7:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimTableDao
{
private
MysqlJdbcDim
mysqlJdbcDim
;
private
ResultSet
resultSet
;
private
String
sql
;
private
Connection
conn
;
private
String
dimJdbcUrl
;
public
DimTableDao
()
{
}
public
DimTableDao
(
String
dimJdbcUrl
)
{
this
.
dimJdbcUrl
=
dimJdbcUrl
;
this
.
mysqlJdbcDim
=
MysqlJdbcDim
.
getInstance
(
dimJdbcUrl
);
}
/**
* Function: findAllDimTable
* Reason: 查询所有码表信息
* Date: 2019/12/25 下午5:26
*
* @author liuzhe
* @since JDK 1.8
*/
public
ArrayList
<
DimTable
>
findAllDimTable
(
String
tableName
)
{
mysqlJdbcDim
.
getConnection
();
sql
=
String
.
format
(
"select code, pk, name, memo from %s"
,
tableName
);
ArrayList
<
DimTable
>
dimTableList
=
new
ArrayList
<>();
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
try
{
while
(
resultSet
.
next
())
{
DimTable
dim_table
=
new
DimTable
();
dim_table
.
setCode
(
resultSet
.
getString
(
1
));
dim_table
.
setPk
(
resultSet
.
getString
(
2
));
dim_table
.
setName
(
resultSet
.
getString
(
3
));
dim_table
.
setMemo
(
resultSet
.
getString
(
4
));
dimTableList
.
add
(
dim_table
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
mysqlJdbcDim
.
close
(
null
,
null
,
resultSet
);
}
return
dimTableList
;
}
/**
* Function: findDimTableByCode
* Reason: 根据编码查询码表信息
* Date: 2019/12/25 下午5:26
*
* @author liuzhe
* @since JDK 1.8
*/
public
DimTable
findDimTableByCode
(
String
tableName
,
String
code
){
if
(
code
==
null
||
code
.
trim
().
length
()
==
0
)
{
return
null
;
}
else
{
code
=
code
.
trim
();
}
mysqlJdbcDim
.
getConnection
();
String
sql
=
String
.
format
(
"select code, pk, name, memo from %s where code = '%s'"
,
tableName
,
code
);
DimTable
dimTable
=
new
DimTable
();
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
try
{
while
(
resultSet
.
next
())
{
dimTable
.
setCode
(
code
);
dimTable
.
setPk
(
resultSet
.
getString
(
2
));
dimTable
.
setName
(
resultSet
.
getString
(
3
));
dimTable
.
setMemo
(
resultSet
.
getString
(
4
));
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
mysqlJdbcDim
.
close
(
null
,
null
,
resultSet
);
}
return
dimTable
;
}
}
src/main/java/com/gmei/cache/MlPreciseExposureDao.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
com.gmei.jdbc.MysqlJdbcSink
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* ClassName: MlPreciseExposureDao
* Function:
* Reason: ml_c_et_pe_preciseexposure_dimen_d_rt数据下发操作类
* Date: 2019/12/19 上午11:35
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
MlPreciseExposureDao
{
private
MysqlJdbcSink
mysqlJdbcSink
;
private
String
sql
;
private
String
sinkJdbcUrl
;
private
String
sinkTableName
;
public
MlPreciseExposureDao
(
String
sinkJdbcUrl
,
String
sinkTableName
)
{
this
.
sinkJdbcUrl
=
sinkJdbcUrl
;
this
.
sinkTableName
=
sinkTableName
;
this
.
mysqlJdbcSink
=
MysqlJdbcSink
.
getInstance
(
sinkJdbcUrl
);
}
/**
* Function: insertMlPreciseExposure
* Reason: 向表中插入数据
* Date: 2019/12/25 下午5:38
*
* @author liuzhe
* @since JDK 1.8
*/
public
void
insertMlPreciseExposure
(
MlPreciseExposureBean
mlPreciseExposureBean
)
throws
Exception
{
sql
=
"insert into "
+
sinkTableName
+
"\n"
+
" (action,\n"
+
" app_code,\n"
+
" page_code,\n"
+
" page_name,\n"
+
" tab_name,\n"
+
" business_id,\n"
+
" referrer_code,\n"
+
" referrer_name,\n"
+
" referrer_id,\n"
+
" card_id,\n"
+
" card_content_type,\n"
+
" card_content_type_name,\n"
+
" card_type,\n"
+
" card_type_name,\n"
+
" is_cpc,\n"
+
" cpc_referer,\n"
+
" transaction_type,\n"
+
" transaction_type_name,\n"
+
" filter,\n"
+
" query,\n"
+
" app_version,\n"
+
" user_id,\n"
+
" device_id,\n"
+
" device_os_type,\n"
+
" current_city_id,\n"
+
" current_city_name,\n"
+
" current_province_id,\n"
+
" current_province_name,\n"
+
" current_country_id,\n"
+
" current_country_name,\n"
+
" current_region_id,\n"
+
" current_region_name,\n"
+
" create_time_day,\n"
+
" gm_nginx_time_day,\n"
+
" preciseexposure_num)\n"
+
"values\n"
+
" (?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?,\n"
+
" ?)"
;
List
<
Object
>
params
=
new
ArrayList
<
Object
>();
params
.
add
(
mlPreciseExposureBean
.
getAction
());
// params.add(mlPreciseExposureBean.getAction_name());
params
.
add
(
mlPreciseExposureBean
.
getApp_code
());
params
.
add
(
mlPreciseExposureBean
.
getPage_code
());
params
.
add
(
mlPreciseExposureBean
.
getPage_name
());
params
.
add
(
mlPreciseExposureBean
.
getTab_name
());
params
.
add
(
mlPreciseExposureBean
.
getBusiness_id
());
params
.
add
(
mlPreciseExposureBean
.
getReferrer_code
());
params
.
add
(
mlPreciseExposureBean
.
getReferrer_name
());
params
.
add
(
mlPreciseExposureBean
.
getReferrer_id
());
params
.
add
(
mlPreciseExposureBean
.
getCard_id
());
params
.
add
(
mlPreciseExposureBean
.
getCard_content_type
());
params
.
add
(
mlPreciseExposureBean
.
getCard_content_type_name
());
params
.
add
(
mlPreciseExposureBean
.
getCard_type
());
params
.
add
(
mlPreciseExposureBean
.
getCard_type_name
());
params
.
add
(
mlPreciseExposureBean
.
getIs_cpc
());
params
.
add
(
mlPreciseExposureBean
.
getCpc_referer
());
params
.
add
(
mlPreciseExposureBean
.
getTransaction_type
());
params
.
add
(
mlPreciseExposureBean
.
getTransaction_type_name
());
params
.
add
(
mlPreciseExposureBean
.
getFilter
());
params
.
add
(
mlPreciseExposureBean
.
getQuery
());
params
.
add
(
mlPreciseExposureBean
.
getApp_version
());
params
.
add
(
mlPreciseExposureBean
.
getUser_id
());
params
.
add
(
mlPreciseExposureBean
.
getDevice_id
());
params
.
add
(
mlPreciseExposureBean
.
getDevice_os_type
());
params
.
add
(
mlPreciseExposureBean
.
getCurrent_city_id
());
params
.
add
(
mlPreciseExposureBean
.
getCurrent_city_name
());
params
.
add
(
mlPreciseExposureBean
.
getCurrent_province_id
());
params
.
add
(
mlPreciseExposureBean
.
getCurrent_province_name
());
params
.
add
(
mlPreciseExposureBean
.
getCurrent_country_id
());
params
.
add
(
mlPreciseExposureBean
.
getCurrent_country_name
());
params
.
add
(
mlPreciseExposureBean
.
getCurrent_region_id
());
params
.
add
(
mlPreciseExposureBean
.
getCurrent_region_name
());
params
.
add
(
mlPreciseExposureBean
.
getCreate_time_day
());
params
.
add
(
mlPreciseExposureBean
.
getGm_nginx_time_day
());
params
.
add
(
mlPreciseExposureBean
.
getPreciseexposure_num
());
// System.out.println(params.toString());
mysqlJdbcSink
.
update
(
sql
,
params
);
}
}
src/main/java/com/gmei/cache/SimpleCacheService.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.google.common.cache.Cache
;
import
com.google.common.cache.CacheBuilder
;
import
com.google.common.cache.CacheLoader
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.TimeUnit
;
/**
* Created by allen on 2017/4/6.
*/
public
class
SimpleCacheService
<
K
,
V
>
extends
CacheServiceAbstract
<
K
,
V
>
implements
Serializable
{
private
Cache
<
K
,
V
>
cache
=
null
;
private
int
maximumSize
=
1000
;
private
int
expireAfterWrite
=
1
;
public
SimpleCacheService
()
{
createCache
();
}
public
SimpleCacheService
(
int
maximumSize
,
int
expireAfterWrite
)
{
this
.
maximumSize
=
maximumSize
;
this
.
expireAfterWrite
=
expireAfterWrite
;
createCache
();
}
public
void
createCache
()
{
cache
=
CacheBuilder
.
newBuilder
()
.
maximumSize
(
maximumSize
)
.
expireAfterWrite
(
expireAfterWrite
,
TimeUnit
.
HOURS
)
.
build
();
}
@Override
public
V
getValue
(
final
K
key
,
final
Callable
<
V
>
callable
)
{
if
(
key
==
null
)
{
return
null
;
}
try
{
return
cache
.
get
(
key
,
callable
);
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
public
Map
<
K
,
V
>
asMap
(
Cache
cache
)
{
Map
cacheMap
=
cache
.
asMap
();
return
cacheMap
;
}
@Override
public
void
putValue
(
K
key
,
V
value
)
{
cache
.
put
(
key
,
value
);
}
@Override
public
void
invalidate
(
Object
key
)
{
cache
.
invalidate
(
key
);
}
@Override
public
void
clearCache
(){
this
.
cache
.
invalidateAll
();
}
@Override
public
Long
cacheSize
()
{
return
this
.
cache
.
size
();
}
@Override
public
void
putValues
(
Map
<
K
,
V
>
map
)
{
cache
.
putAll
(
map
);
// cache = new CacheLoader() {
// @Override
// public Object load(Object o) throws Exception {
// for (Object o : objects) {
// cache.put(o.getcode(), value);
// }
// return o;
// }
// };
// new CacheLoader<Long, Optional<Object>>() {
//
// @Override
// public Optional<Object> load(Long storeId) throws Exception {
// Object s = null;
//
// List<Object> results = null;
// if (results != null && results.size() > 0) {
// s = results.get(0);
// }
//
// return Optional.ofNullable(s);
// }
//
// }
}
public
Cache
<
K
,
V
>
getCache
()
{
return
cache
;
}
// public void putValues(Map<K, V> map) {
//
// }
}
src/main/java/com/gmei/function/BlMaiDianOutputSelector.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
function
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.flink.streaming.api.collector.selector.OutputSelector
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* ClassName: BlMaiDianOutputSelector
* Function:
* Reason: BL层数据选择器
* Date: 2019/12/7 上午11:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
BlMaiDianOutputSelector
implements
OutputSelector
<
String
>
{
@Override
public
Iterable
<
String
>
select
(
String
s
)
{
List
<
String
>
output
=
new
ArrayList
<
String
>();
JSONObject
jsonObject
=
JSON
.
parseObject
(
s
);
String
action
=
jsonObject
.
getString
(
"type"
);
// System.out.println(s);
if
(
"home_choiceness_card_exposure"
.
equals
(
action
)
||
"page_precise_exposure"
.
equals
(
action
))
{
output
.
add
(
"et_pe"
);
}
else
if
(
"page_view"
.
equals
(
action
))
{
output
.
add
(
"et_le"
);
}
else
if
(
StringUtils
.
containsIgnoreCase
(
action
,
"click"
))
{
output
.
add
(
"et_ck"
);
}
else
{
output
.
add
(
"et_ot"
);
}
return
output
;
}
}
src/main/java/com/gmei/function/BlPreciseExposureFilterFunction.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
function
;
import
com.gmei.bean.bl.BlPreciseExposureBean
;
import
org.apache.flink.api.common.functions.FilterFunction
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* ClassName: BlPreciseExposureFilterFunction
* Function:
* Reason: BL层数据筛选器
* Date: 2019/12/7 上午11:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
BlPreciseExposureFilterFunction
implements
FilterFunction
<
BlPreciseExposureBean
>
{
@Override
public
boolean
filter
(
BlPreciseExposureBean
blPreciseExposureBean
)
throws
Exception
{
String
app_code
=
blPreciseExposureBean
.
getApp_code
();
String
is_exposure
=
blPreciseExposureBean
.
getIs_exposure
();
String
is_popup
=
blPreciseExposureBean
.
getIs_popup
();
String
app_version
=
blPreciseExposureBean
.
getApp_version
();
String
page_code
=
blPreciseExposureBean
.
getPage_code
();
Boolean
flag
=
true
;
// System.out.println(blPreciseExposureBean);
//清洗掉app_code不等于gengmei_user与is_exposure不等于1的
//1.5 Home页精准曝光触发两次
//问题描述:在7.7.70','7.7.71','7.7.72','7.7.75','7.7.76','7.8.0','7.8.1' (7.7.70--7.9.0)版本中的首页精准曝光会触发两次,经确认,需要去除page_name='home'
//1.6 品类聚合页的精准曝光问题
//问题描述:品类聚合页的精准曝光没做,但是数据中却有精准曝光、而且有问题,因此过滤掉,目前还不能确定什么版本可以解决,先暂时根据page_name过滤掉page_name='category'
//1.15 当首页精准曝光是通过弹窗触发或者点击push的时候,会有额外的精准曝光数据,需要去掉这部分数据
List
<
String
>
app_version_list
=
Arrays
.
asList
(
"7.7.70"
,
"7.7.71"
,
"7.7.72"
,
"7.7.75"
,
"7.7.76"
,
"7.8.0"
,
"7.8.1"
);
String
[]
version
=
app_version
.
split
(
"\\."
);
if
(
version
.
length
!=
3
)
{
flag
=
false
;
// return false;
}
else
if
(!
"gengmei_user"
.
equals
(
app_code
)
||
!
"1"
.
equals
(
is_exposure
))
{
flag
=
false
;
// return false;
}
else
if
(
app_version_list
.
contains
(
app_version
)
&&
"home"
.
equals
(
page_code
))
{
flag
=
false
;
// return false;
}
else
if
(
"category"
.
equals
(
page_code
)
&&
"7"
.
equals
(
version
[
0
])
&&
Integer
.
parseInt
(
version
[
1
])
<
14
)
{
flag
=
false
;
// return false;
}
else
if
(
"home"
.
equals
(
page_code
)
&&
"1"
.
equals
(
is_popup
))
{
flag
=
false
;
}
// System.out.println(flag);
return
flag
;
}
}
src/main/java/com/gmei/function/BlPreciseExposureMapFunction.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
function
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gmei.bean.bl.BlPreciseExposureBean
;
import
com.gmei.bean.bl.BlPreciseExposureParamsExposureCardsBean
;
import
com.gmei.utils.BeanReflectUtil
;
import
com.gmei.utils.DateUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.flink.api.common.functions.MapFunction
;
import
java.util.ArrayList
;
/**
* ClassName: BlPreciseExposureMapFunction
* Function:
* Reason: BL层数据清洗转换器(一对一)
* Date: 2019/12/7 上午11:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
BlPreciseExposureMapFunction
implements
MapFunction
<
String
,
BlPreciseExposureBean
>
{
@Override
public
BlPreciseExposureBean
map
(
String
string
)
throws
Exception
{
BlPreciseExposureBean
blPreciseExposureBean
=
new
BlPreciseExposureBean
();
JSONObject
app
=
null
;
String
gm_nginx_timestamp
=
null
;
String
create_timestamp
=
null
;
String
user_id
=
null
;
String
action
=
null
;
String
app_grey_type
=
null
;
String
app_channel
=
null
;
String
app_version
=
null
;
String
app_current_city_id
=
null
;
String
app_code
=
null
;
JSONObject
params
=
null
;
Integer
down_loading_times
=
null
;
Integer
down_slide_times
=
null
;
Integer
up_loading_times
=
null
;
Integer
up_slide_times
=
null
;
String
page_code
=
null
;
String
tab_name
=
null
;
String
business_id
=
null
;
String
referrer_code
=
null
;
String
referrer_id
=
null
;
String
is_exposure
=
null
;
String
is_popup
=
null
;
String
filter
=
null
;
String
query
=
null
;
JSONArray
jsonArrayExposureCards
=
null
;
JSONObject
device
=
null
;
String
device_os_type
=
null
;
String
device_model
=
null
;
String
device_id
=
null
;
String
device_idfv
=
null
;
String
device_android_id
=
null
;
String
gm_nginx_time_date
=
null
;
String
gm_nginx_time_day
=
null
;
String
create_time_date
=
null
;
String
create_time_day
=
null
;
//去除掉json中的回车、换行、制表
String
jsonString
=
string
.
replaceAll
(
"(\\\\n|\\\\r|\\\\t)"
,
""
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
jsonString
);
//一级别JSON
app
=
jsonObject
.
getJSONObject
(
"app"
);
gm_nginx_timestamp
=
String
.
valueOf
(
jsonObject
.
get
(
"gm_nginx_timestamp"
));
create_timestamp
=
String
.
valueOf
(
jsonObject
.
get
(
"create_at"
));
user_id
=
jsonObject
.
getString
(
"user_id"
);
action
=
jsonObject
.
getString
(
"type"
);
//二级别JSON
//APP
if
(
app
!=
null
)
{
app_grey_type
=
app
.
getString
(
"grey_type"
);
app_channel
=
app
.
getString
(
"channel"
);
app_version
=
app
.
getString
(
"version"
);
app_current_city_id
=
app
.
getString
(
"current_city_id"
);
app_code
=
app
.
getString
(
"name"
);
}
//1.2 absolute_position参数类型不完整
//问题描述:在'7.7.35', '7.7.36', '7.7.40'params的absolute_position缺少左边引号
String
paramsString
=
String
.
valueOf
(
jsonObject
.
get
(
"params"
));
if
(
"7.7.35"
.
equals
(
app_version
)
||
"7.7.36"
.
equals
(
app_version
)
||
"7.7.40"
.
equals
(
app_version
))
{
paramsString
=
paramsString
.
replace
(
"absolute_position"
,
"\\\"absolute_position"
);
}
//PARAMS
params
=
JSON
.
parseObject
(
paramsString
);
if
(
params
!=
null
)
{
down_loading_times
=
params
.
getInteger
(
"down_loading_times"
);
down_slide_times
=
params
.
getInteger
(
"down_slide_times"
);
up_loading_times
=
params
.
getInteger
(
"up_loading_times"
);
up_slide_times
=
params
.
getInteger
(
"up_slide_times"
);
page_code
=
params
.
getString
(
"page_name"
);
tab_name
=
params
.
getString
(
"tab_name"
);
business_id
=
params
.
getString
(
"business_id"
);
referrer_code
=
params
.
getString
(
"referrer"
);
referrer_id
=
params
.
getString
(
"referrer_id"
);
is_exposure
=
params
.
getString
(
"is_exposure"
);
is_popup
=
params
.
getString
(
"is_popup"
);
filter
=
params
.
getString
(
"filter"
);
query
=
params
.
getString
(
"query"
);
}
//1.4 初版精准曝光格式错误
//问题描述:在'7.7.60'版本中美购页卡片的card_id和transaction_type这两个参数是数组的形式
// ArrayList<BlPreciseExposureParamsExposureCardsBean> exposure_cards =(ArrayList<BlPreciseExposureParamsExposureCardsBean>)JSONArray.parseArray(params.getJSONArray("exposure_cards").toString(), BlPreciseExposureParamsExposureCardsBean.class);
ArrayList
<
BlPreciseExposureParamsExposureCardsBean
>
exposure_cards
=
new
ArrayList
<>();
try
{
jsonArrayExposureCards
=
JSONArray
.
parseArray
(
params
.
getJSONArray
(
"exposure_cards"
).
toString
());
for
(
int
i
=
0
;
i
<
jsonArrayExposureCards
.
size
();
i
++)
{
JSONObject
jsonCard
=
jsonArrayExposureCards
.
getJSONObject
(
i
);
String
card_id
=
jsonCard
.
getString
(
"card_id"
);
String
transaction_type
=
jsonCard
.
getString
(
"transaction_type"
);
String
card_content_type
=
jsonCard
.
getString
(
"card_content_type"
);
// if("service".equals(card_content_type) && "7.7.60".equals(app_version)) {
if
(
StringUtils
.
startsWithIgnoreCase
(
card_id
,
"["
)
&&
StringUtils
.
endsWithIgnoreCase
(
card_id
,
"]"
))
{
JSONArray
card_id_list
=
JSONArray
.
parseArray
(
card_id
);
JSONArray
transaction_type_list
=
null
;
if
(
StringUtils
.
startsWithIgnoreCase
(
transaction_type
,
"["
)
&&
StringUtils
.
endsWithIgnoreCase
(
transaction_type
,
"]"
))
{
transaction_type_list
=
JSONArray
.
parseArray
(
transaction_type
);
}
for
(
int
j
=
0
;
j
<
card_id_list
.
size
();
j
++)
{
BlPreciseExposureParamsExposureCardsBean
cardsBean
=
new
BlPreciseExposureParamsExposureCardsBean
();
cardsBean
.
setCard_id
(
card_id_list
.
getString
(
j
));
try
{
cardsBean
.
setTransaction_type
(
transaction_type_list
.
getString
(
j
));
}
catch
(
Exception
e
)
{
cardsBean
.
setTransaction_type
(
null
);
}
cardsBean
.
setCard_content_type
(
card_content_type
);
cardsBean
.
setCard_type
(
jsonCard
.
getString
(
"card_type"
));
cardsBean
.
setIs_cpc
(
jsonCard
.
getString
(
"is_cpc"
));
cardsBean
.
setCpc_referer
(
jsonCard
.
getString
(
"cpc_referer"
));
cardsBean
.
setAbsolute_position
(
jsonCard
.
getString
(
"absolute_position"
));
cardsBean
.
setRelative_position
(
jsonCard
.
getString
(
"relative_position"
));
exposure_cards
.
add
(
cardsBean
);
}
}
else
{
BlPreciseExposureParamsExposureCardsBean
cardsBean
=
JSON
.
toJavaObject
(
jsonCard
,
BlPreciseExposureParamsExposureCardsBean
.
class
);
exposure_cards
.
add
(
cardsBean
);
}
}
}
catch
(
Exception
e
)
{
// System.out.println(JSON.parseObject(params.getString("exposure_cards")).toString());
}
//DEVICE
device
=
jsonObject
.
getJSONObject
(
"device"
);
if
(
device
!=
null
)
{
device_os_type
=
device
.
getString
(
"device_type"
);
device_model
=
device
.
getString
(
"model"
);
device_id
=
device
.
getString
(
"device_id"
);
device_idfv
=
device
.
getString
(
"idfv"
);
device_android_id
=
device
.
getString
(
"android_device_id"
);
}
//1.1 ios系统精准曝光埋点channel字段
//问题描述:ios系统精准曝光埋点channel字段AppStore应该修改为App Store
if
(
"AppStore"
.
equals
(
app_channel
))
{
app_channel
=
"App Store"
;
}
//日志时间处理
gm_nginx_time_date
=
DateUtil
.
timestampFormat
(
gm_nginx_timestamp
,
DateUtil
.
DateType
.
SECOND
);
gm_nginx_time_day
=
DateUtil
.
timestampFormat
(
gm_nginx_timestamp
,
DateUtil
.
DateType
.
DAY
);
create_time_date
=
DateUtil
.
timestampFormat
(
create_timestamp
,
DateUtil
.
DateType
.
SECOND
);
create_time_day
=
DateUtil
.
timestampFormat
(
create_timestamp
,
DateUtil
.
DateType
.
DAY
);
//1.7 result_status参数位置问题(未处理)
//问题描述:搜索结果百科(search_result_wiki)和搜索结果美购(search_result_welfare)的result_status埋点埋在exposure_data里面了为了都获得该参数值,因此需要从两处拿取,默认先取exposure_data里的result_satus字段值(数据中发现不只是这两个页面)search_result_diary、search_result_doctor、search_result_hospital也存在
//1.9 搜索结果页tab_name参数不该存在
//问题描述:在搜索结果页出现tab_name参数,参数值和page_name一样,在点击的时候页面有跳转,因此,不应该有tab_name参数
if
(
StringUtils
.
containsIgnoreCase
(
page_code
,
"search_result"
))
{
tab_name
=
null
;
}
blPreciseExposureBean
.
setGm_nginx_timestamp
(
gm_nginx_timestamp
);
blPreciseExposureBean
.
setCreate_timestamp
(
create_timestamp
);
blPreciseExposureBean
.
setUser_id
(
user_id
);
blPreciseExposureBean
.
setAction
(
action
);
blPreciseExposureBean
.
setApp_grey_type
(
app_grey_type
);
blPreciseExposureBean
.
setApp_channel
(
app_channel
);
blPreciseExposureBean
.
setApp_version
(
app_version
);
blPreciseExposureBean
.
setApp_current_city_id
(
app_current_city_id
);
blPreciseExposureBean
.
setApp_code
(
app_code
);
blPreciseExposureBean
.
setDown_loading_times
(
down_loading_times
);
blPreciseExposureBean
.
setDown_slide_times
(
down_slide_times
);
blPreciseExposureBean
.
setUp_loading_times
(
up_loading_times
);
blPreciseExposureBean
.
setUp_slide_times
(
up_slide_times
);
blPreciseExposureBean
.
setPage_code
(
page_code
);
blPreciseExposureBean
.
setTab_name
(
tab_name
);
blPreciseExposureBean
.
setBusiness_id
(
business_id
);
blPreciseExposureBean
.
setReferrer_code
(
referrer_code
);
blPreciseExposureBean
.
setReferrer_id
(
referrer_id
);
blPreciseExposureBean
.
setExposure_cards
(
exposure_cards
);
blPreciseExposureBean
.
setIs_exposure
(
is_exposure
);
blPreciseExposureBean
.
setIs_popup
(
is_popup
);
blPreciseExposureBean
.
setFilter
(
filter
);
blPreciseExposureBean
.
setQuery
(
query
);
blPreciseExposureBean
.
setDevice_os_type
(
device_os_type
);
blPreciseExposureBean
.
setDevice_model
(
device_model
);
blPreciseExposureBean
.
setDevice_id
(
device_id
!=
null
&&
device_id
!=
""
?
device_id
:
device_idfv
);
blPreciseExposureBean
.
setDevice_android_id
(
device_android_id
);
blPreciseExposureBean
.
setDevice_idfv
(
device_idfv
);
blPreciseExposureBean
.
setGm_nginx_time_date
(
gm_nginx_time_date
);
blPreciseExposureBean
.
setGm_nginx_time_day
(
gm_nginx_time_day
);
blPreciseExposureBean
.
setCreate_time_date
(
create_time_date
);
blPreciseExposureBean
.
setCreate_time_day
(
create_time_day
);
// System.out.println(blPreciseExposureBean);
return
BeanReflectUtil
.
setNullValue
(
blPreciseExposureBean
);
}
}
src/main/java/com/gmei/function/DimRichAsyncFunction.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
function
;
import
com.gmei.bean.dim.DimCity
;
import
com.gmei.bean.dim.DimCardContentType
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
com.gmei.bean.dim.DimPageType
;
import
com.gmei.bean.dim.DimTable
;
import
com.gmei.cache.DimTableCallable
;
import
com.gmei.cache.SimpleCacheService
;
import
com.gmei.utils.DimTableList
;
import
com.google.common.base.Function
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Maps
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.streaming.api.functions.async.ResultFuture
;
import
org.apache.flink.streaming.api.functions.async.RichAsyncFunction
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
/**
* ClassName: DimRichAsyncFunction
* Function:
* Reason: ML层维度关联器(异步调用)
* Date: 2019/12/7 上午11:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DimRichAsyncFunction
extends
RichAsyncFunction
<
MlPreciseExposureBean
,
MlPreciseExposureBean
>
{
public
static
final
SimpleCacheService
<
String
,
DimCity
>
dimCityCache
=
new
SimpleCacheService
<>(
2000
,
24
);
public
static
final
SimpleCacheService
<
String
,
DimTable
>
dimCardTypeCache
=
new
SimpleCacheService
<>(
2000
,
24
);
public
static
final
SimpleCacheService
<
String
,
DimTable
>
dimTransactionTypeCache
=
new
SimpleCacheService
<>(
2000
,
24
);
public
static
final
SimpleCacheService
<
String
,
DimPageType
>
dimPageTypeCache
=
new
SimpleCacheService
<>(
2000
,
24
);
public
static
final
SimpleCacheService
<
String
,
DimCardContentType
>
dimCardContentTypeCache
=
new
SimpleCacheService
<>(
2000
,
24
);
public
String
dimJdbcUrl
;
public
DimRichAsyncFunction
(
String
dimJdbcUrl
)
{
this
.
dimJdbcUrl
=
dimJdbcUrl
;
}
@Override
public
void
open
(
Configuration
parameters
)
throws
Exception
{
super
.
open
(
parameters
);
initDimTable
();
}
@Override
public
void
asyncInvoke
(
MlPreciseExposureBean
mlPreciseExposureBean
,
ResultFuture
<
MlPreciseExposureBean
>
resultFuture
)
throws
Exception
{
String
current_city_id
=
mlPreciseExposureBean
.
getCurrent_city_id
();
String
page_code
=
mlPreciseExposureBean
.
getPage_code
();
String
referrer_code
=
mlPreciseExposureBean
.
getReferrer_code
();
String
card_type
=
mlPreciseExposureBean
.
getCard_type
();
String
card_content_type
=
mlPreciseExposureBean
.
getCard_content_type
();
String
transaction_type
=
mlPreciseExposureBean
.
getTransaction_type
();
String
gm_nginx_time_day
=
mlPreciseExposureBean
.
getGm_nginx_time_day
();
//刷新一次缓存
// if(gm_nginx_time_day != null){
// if(gm_nginx_time_day.compareTo(gm_nginx_time_day) < 0){
// dimCityCache.clearCache();
// dimCardTypeCache.clearCache();
// dimTransactionTypeCache.clearCache();
// dimPageTypeCache.clearCache();
// dimCardContentTypeCache.clearCache();
// initDimTable();
// }
// }
//1.8 城市字段问题
//问题描述:城市id为数字tagid的修正为正确的拼音,还加了过滤重复的数据
//解决方案:dimCityCache缓存中的key既有城市ID又有城市TAGID,获取到城市对象后将正确的城市ID填充到Current_city_id中
if
(
current_city_id
!=
null
)
{
DimCity
dimCity
=
dimCityCache
.
getValue
(
current_city_id
,
new
DimTableCallable
(
current_city_id
,
DimTableList
.
DIM_CITY
.
getTableName
(),
dimJdbcUrl
));
if
(
dimCity
.
getName
()
==
null
)
{
dimCityCache
.
invalidate
(
current_city_id
);
}
else
{
mlPreciseExposureBean
.
setCurrent_city_id
(
dimCity
.
getCode
());
mlPreciseExposureBean
.
setCurrent_city_name
(
dimCity
.
getName
());
mlPreciseExposureBean
.
setCurrent_province_id
(
dimCity
.
getParent_province_code
());
mlPreciseExposureBean
.
setCurrent_province_name
(
dimCity
.
getParent_province_name
());
mlPreciseExposureBean
.
setCurrent_country_id
(
dimCity
.
getParent_country_code
());
mlPreciseExposureBean
.
setCurrent_country_name
(
dimCity
.
getParent_country_name
());
mlPreciseExposureBean
.
setCurrent_region_id
(
dimCity
.
getParent_region_code
());
mlPreciseExposureBean
.
setCurrent_region_name
(
dimCity
.
getParent_region_name
());
}
}
if
(
page_code
!=
null
)
{
DimPageType
dimPageType
=
dimPageTypeCache
.
getValue
(
page_code
,
new
DimTableCallable
(
page_code
,
DimTableList
.
DIM_PAGE_TYPE
.
getTableName
(),
dimJdbcUrl
));
if
(
dimPageType
.
getName
()
==
null
)
{
dimPageTypeCache
.
invalidate
(
page_code
);
}
else
{
mlPreciseExposureBean
.
setPage_name
(
dimPageType
.
getName
());
}
}
if
(
referrer_code
!=
null
)
{
DimPageType
dimReferrerType
=
dimPageTypeCache
.
getValue
(
referrer_code
,
new
DimTableCallable
(
referrer_code
,
DimTableList
.
DIM_PAGE_TYPE
.
getTableName
(),
dimJdbcUrl
));
if
(
dimReferrerType
.
getName
()
==
null
)
{
dimPageTypeCache
.
invalidate
(
page_code
);
}
else
{
mlPreciseExposureBean
.
setReferrer_name
(
dimReferrerType
.
getName
());
}
}
if
(
card_content_type
!=
null
)
{
DimCardContentType
dimCardContentType
=
dimCardContentTypeCache
.
getValue
(
card_content_type
,
new
DimTableCallable
(
card_content_type
,
DimTableList
.
DIM_CARD_CONTENT_TYPE
.
getTableName
(),
dimJdbcUrl
));
if
(
dimCardContentType
.
getName
()
==
null
)
{
dimCardContentTypeCache
.
invalidate
(
card_content_type
);
}
else
{
mlPreciseExposureBean
.
setCard_content_type
(
dimCardContentType
.
getNew_code
());
mlPreciseExposureBean
.
setCard_content_type_name
(
dimCardContentType
.
getName
());
}
}
if
(
card_type
!=
null
)
{
DimTable
dimCardType
=
dimCardTypeCache
.
getValue
(
card_type
,
new
DimTableCallable
(
card_type
,
DimTableList
.
DIM_CARD_TYPE
.
getTableName
(),
dimJdbcUrl
));
if
(
dimCardType
.
getName
()
==
null
){
dimCardTypeCache
.
invalidate
(
card_type
);
}
else
{
mlPreciseExposureBean
.
setCard_type_name
(
dimCardType
.
getName
());
}
}
if
(
transaction_type
!=
null
)
{
DimTable
dimTransactionType
=
dimTransactionTypeCache
.
getValue
(
transaction_type
,
new
DimTableCallable
(
transaction_type
,
DimTableList
.
DIM_TRANSACTION_TYPE
.
getTableName
(),
dimJdbcUrl
));
if
(
dimTransactionType
.
getName
()
==
null
)
{
dimTransactionTypeCache
.
invalidate
(
transaction_type
);
}
else
{
mlPreciseExposureBean
.
setTransaction_type_name
(
dimTransactionType
.
getName
());
}
}
List
<
String
>
card_content_type_list_ch
=
Arrays
.
asList
(
"指定网页"
);
if
(
card_content_type_list_ch
.
contains
(
card_content_type
))
{
System
.
out
.
println
(
mlPreciseExposureBean
);
}
// System.out.println(mlPreciseExposureBean);
resultFuture
.
complete
(
Collections
.
singleton
(
mlPreciseExposureBean
));
}
/**
* Function: initDimTable
* Reason: dim码表缓存初始化
* Date: 2019/12/25 下午5:16
*
* @author liuzhe
* @since JDK 1.8
*/
public
void
initDimTable
()
throws
Exception
{
ExecutorService
es
=
Executors
.
newFixedThreadPool
(
DimTableList
.
values
().
length
);
Future
dimCityFuture
=
es
.
submit
(
new
DimTableCallable
(
null
,
DimTableList
.
DIM_CITY
.
getTableName
(),
dimJdbcUrl
));
Future
dimCardTypeFuture
=
es
.
submit
(
new
DimTableCallable
(
null
,
DimTableList
.
DIM_CARD_TYPE
.
getTableName
(),
dimJdbcUrl
));
Future
dimCardContentTypeFuture
=
es
.
submit
(
new
DimTableCallable
(
null
,
DimTableList
.
DIM_CARD_CONTENT_TYPE
.
getTableName
(),
dimJdbcUrl
));
Future
dimPageTypeFuture
=
es
.
submit
(
new
DimTableCallable
(
null
,
DimTableList
.
DIM_PAGE_TYPE
.
getTableName
(),
dimJdbcUrl
));
Future
dimTransactionTypeFuture
=
es
.
submit
(
new
DimTableCallable
(
null
,
DimTableList
.
DIM_TRANSACTION_TYPE
.
getTableName
(),
dimJdbcUrl
));
ArrayList
<
DimCity
>
dimCityList
=
(
ArrayList
<
DimCity
>)
dimCityFuture
.
get
();
ArrayList
<
DimTable
>
dimCardTypeList
=
(
ArrayList
<
DimTable
>)
dimCardTypeFuture
.
get
();
ArrayList
<
DimCardContentType
>
dimCardContentList
=
(
ArrayList
<
DimCardContentType
>)
dimCardContentTypeFuture
.
get
();
ArrayList
<
DimPageType
>
dimPageTypeList
=
(
ArrayList
<
DimPageType
>)
dimPageTypeFuture
.
get
();
ArrayList
<
DimTable
>
dimTransactionTypeList
=
(
ArrayList
<
DimTable
>)
dimTransactionTypeFuture
.
get
();
ImmutableMap
<
String
,
DimCity
>
dimCityCodeMap
=
Maps
.
uniqueIndex
(
dimCityList
,
new
Function
<
DimCity
,
String
>()
{
@Override
public
String
apply
(
DimCity
dimCity
)
{
return
dimCity
.
getCode
();
}
});
ImmutableMap
<
String
,
DimCity
>
dimCityTagMap
=
Maps
.
uniqueIndex
(
dimCityList
,
new
Function
<
DimCity
,
String
>()
{
@Override
public
String
apply
(
DimCity
dimCity
)
{
return
dimCity
.
getPk
();
}
});
ImmutableMap
<
String
,
DimTable
>
dimCardTypeMap
=
Maps
.
uniqueIndex
(
dimCardTypeList
,
new
Function
<
DimTable
,
String
>()
{
@Override
public
String
apply
(
DimTable
dimTable
)
{
return
dimTable
.
getCode
();
}
});
ImmutableMap
<
String
,
DimCardContentType
>
dimCardContentMap
=
Maps
.
uniqueIndex
(
dimCardContentList
,
new
Function
<
DimCardContentType
,
String
>()
{
@Override
public
String
apply
(
DimCardContentType
dimTableTransForm
)
{
return
dimTableTransForm
.
getCode
();
}
});
ImmutableMap
<
String
,
DimPageType
>
dimPageTypeMap
=
Maps
.
uniqueIndex
(
dimPageTypeList
,
new
Function
<
DimPageType
,
String
>()
{
@Override
public
String
apply
(
DimPageType
dimPageType
)
{
return
dimPageType
.
getCode
();
}
});
ImmutableMap
<
String
,
DimTable
>
dimTransactionTypeMap
=
Maps
.
uniqueIndex
(
dimTransactionTypeList
,
new
Function
<
DimTable
,
String
>()
{
@Override
public
String
apply
(
DimTable
dimTable
)
{
return
dimTable
.
getCode
();
}
});
dimCityCache
.
putValues
(
dimCityCodeMap
);
//根据city_id匹配城市
dimCityCache
.
putValues
(
dimCityTagMap
);
//根据tag_id匹配城市
dimCardTypeCache
.
putValues
(
dimCardTypeMap
);
dimCardContentTypeCache
.
putValues
(
dimCardContentMap
);
dimPageTypeCache
.
putValues
(
dimPageTypeMap
);
dimTransactionTypeCache
.
putValues
(
dimTransactionTypeMap
);
System
.
out
.
println
(
"dimCityCache:"
+
dimCityCache
.
cacheSize
());
System
.
out
.
println
(
"dimCardTypeCache:"
+
dimCardTypeCache
.
cacheSize
());
System
.
out
.
println
(
"dimCardContentTypeCache:"
+
dimCardContentTypeCache
.
cacheSize
());
System
.
out
.
println
(
"dimPageTypeCache:"
+
dimPageTypeCache
.
cacheSize
());
System
.
out
.
println
(
"dimTransactionTypeCache:"
+
dimTransactionTypeCache
.
cacheSize
());
}
}
src/main/java/com/gmei/function/MlPreciseExposureKeySelector.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
function
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
org.apache.flink.api.java.functions.KeySelector
;
import
java.util.ArrayList
;
/**
* ClassName: MlPreciseExposureKeySelector
* Function:
* Reason: ML层数据聚合分组器
* Date: 2019/12/7 上午11:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
MlPreciseExposureKeySelector
implements
KeySelector
<
MlPreciseExposureBean
,
Object
>
{
@Override
public
Object
getKey
(
MlPreciseExposureBean
mlPreciseExposureBean
)
throws
Exception
{
ArrayList
list
=
groupByFields
(
mlPreciseExposureBean
);
return
list
;
}
/**
* Function: groupByFields
* Reason: 分组字段(GROUP BY)
* Date: 2019/12/25 下午5:17
*
* @author liuzhe
* @since JDK 1.8
*/
public
ArrayList
groupByFields
(
MlPreciseExposureBean
mlPreciseExposureBean
)
{
ArrayList
groupByFields
=
new
ArrayList
();
groupByFields
.
add
(
mlPreciseExposureBean
.
getUser_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getAction
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getApp_code
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getTab_name
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getBusiness_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getReferrer_code
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getReferrer_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCard_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCard_content_type
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCard_type
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getIs_cpc
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCpc_referer
());
// groupByFields.add(mlPreciseExposureBean.getAbsolute_position());
// groupByFields.add(mlPreciseExposureBean.getRelative_position());
groupByFields
.
add
(
mlPreciseExposureBean
.
getTransaction_type
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getFilter
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getQuery
());
// groupByFields.add(mlPreciseExposureBean.getChannel_id());
groupByFields
.
add
(
mlPreciseExposureBean
.
getApp_version
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCurrent_city_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getApp_code
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getDevice_os_type
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getDevice_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCreate_time_day
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getGm_nginx_time_day
());
return
groupByFields
;
}
}
src/main/java/com/gmei/function/MlpreciseExposureFlatMapFunction.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
function
;
import
com.gmei.bean.bl.BlPreciseExposureBean
;
import
com.gmei.bean.bl.BlPreciseExposureParamsExposureCardsBean
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
com.gmei.utils.BeanReflectUtil
;
import
org.apache.flink.api.common.functions.FlatMapFunction
;
import
org.apache.flink.util.Collector
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* ClassName: MlpreciseExposureFlatMapFunction
* Function:
* Reason: ML层数据清洗转换器(一对多)
* Date: 2019/12/7 上午11:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
MlpreciseExposureFlatMapFunction
implements
FlatMapFunction
<
BlPreciseExposureBean
,
MlPreciseExposureBean
>
{
@Override
public
void
flatMap
(
BlPreciseExposureBean
blPreciseExposureBean
,
Collector
<
MlPreciseExposureBean
>
collector
)
throws
Exception
{
ArrayList
<
MlPreciseExposureBean
>
mlPreciseExposureBeanList
=
flatmapBlPreciseExposure
(
blPreciseExposureBean
);
// System.out.println("MlpreciseExposureFlatMapFunction" + blPreciseExposureBean);
for
(
MlPreciseExposureBean
mlPreciseExposureBean
:
mlPreciseExposureBeanList
)
{
collector
.
collect
(
mlPreciseExposureBean
);
}
}
/**
* Function: flatmapBlPreciseExposure
* Reason: 数据爆炸(LATERAL VIEW EXPLODE)
* Date: 2019/12/25 下午5:14
*
* @author liuzhe
* @since JDK 1.8
*/
public
ArrayList
<
MlPreciseExposureBean
>
flatmapBlPreciseExposure
(
BlPreciseExposureBean
blPreciseExposureBean
)
throws
Exception
{
ArrayList
<
BlPreciseExposureParamsExposureCardsBean
>
exposure_cards
=
blPreciseExposureBean
.
getExposure_cards
();
String
app_version
=
blPreciseExposureBean
.
getApp_version
();
String
device_os_type
=
blPreciseExposureBean
.
getDevice_os_type
();
ArrayList
<
MlPreciseExposureBean
>
mlPreciseExposureBeanList
=
new
ArrayList
<>();
for
(
BlPreciseExposureParamsExposureCardsBean
exposureCardsBean:
exposure_cards
)
{
String
card_id
=
exposureCardsBean
.
getCard_id
();
String
card_content_type
=
exposureCardsBean
.
getCard_content_type
();
String
card_type
=
exposureCardsBean
.
getCard_type
();
String
is_cpc
=
exposureCardsBean
.
getIs_cpc
();
String
cpc_referer
=
exposureCardsBean
.
getCpc_referer
();
String
absolute_position
=
exposureCardsBean
.
getAbsolute_position
();
String
relative_position
=
exposureCardsBean
.
getRelative_position
();
String
transaction_type
=
exposureCardsBean
.
getTransaction_type
();
//1.3 绝对位置和相对位置位置错误
//问题描述:在'7.7.35','7.7.36' android的绝对位置和相对位置写反
if
(
"android"
.
equals
(
device_os_type
)
&&
(
"7.7.35"
.
equals
(
app_version
)
||
"7.7.36"
.
equals
(
app_version
)))
{
String
change
=
absolute_position
;
absolute_position
=
relative_position
;
relative_position
=
change
;
}
//1.10 banner、豆腐块、icon、搜索词和功能区入口的card_type参数问题
//问题描述:当卡片类型为豆腐块、icon、banner、搜索词和功能区入口的时候的时候正确的card_type的参数值被赋给了card_content_type(banner、icon、gadget、search_query、function_entrance)
List
<
String
>
card_content_type_list
=
Arrays
.
asList
(
"banner"
,
"icon"
,
"gadget"
,
"search_query"
,
"function_entrance"
);
if
(
card_content_type_list
.
contains
(
card_content_type
))
{
card_type
=
card_content_type
;
card_content_type
=
null
;
}
if
(
"search_query"
.
equals
(
card_type
))
{
card_type
=
"search_word"
;
}
//1.12 card_content_type的qa值应该被换成q_a
if
(
"qa"
.
equals
(
card_content_type
))
{
card_content_type
=
card_content_type
.
replace
(
"qa"
,
"q_a"
);
}
//1.13 target_name与card_name的参数的统一
//问题描述:将target_name参数的值赋给card_name
//1.14 百科卡片曝光新增参数wiki_type
//问题:从7.19.0版本开始,百科卡片曝光,新增了wiki_type参数
//card_type为card的标准码值为common_card,数据中为card
if
(
"card"
.
equals
(
card_type
))
{
card_type
=
"common_card"
;
}
//card_type为banner的标准码值为common_banner,数据中为banner
if
(
"banner"
.
equals
(
card_type
))
{
card_type
=
"common_banner"
;
}
MlPreciseExposureBean
mlPreciseExposureBean
=
new
MlPreciseExposureBean
();
mlPreciseExposureBean
.
setUser_id
(
blPreciseExposureBean
.
getUser_id
());
mlPreciseExposureBean
.
setAction
(
blPreciseExposureBean
.
getAction
());
mlPreciseExposureBean
.
setPage_code
(
blPreciseExposureBean
.
getPage_code
());
mlPreciseExposureBean
.
setTab_name
(
blPreciseExposureBean
.
getTab_name
());
mlPreciseExposureBean
.
setBusiness_id
(
blPreciseExposureBean
.
getBusiness_id
());
mlPreciseExposureBean
.
setReferrer_code
(
blPreciseExposureBean
.
getReferrer_code
());
mlPreciseExposureBean
.
setReferrer_id
(
blPreciseExposureBean
.
getReferrer_id
());
mlPreciseExposureBean
.
setCard_id
(
card_id
);
mlPreciseExposureBean
.
setCard_content_type
(
card_content_type
);
mlPreciseExposureBean
.
setCard_type
(
card_type
);
mlPreciseExposureBean
.
setIs_cpc
(
is_cpc
);
mlPreciseExposureBean
.
setCpc_referer
(
cpc_referer
);
// mlPreciseExposureBean.setAbsolute_position(absolute_position);
// mlPreciseExposureBean.setRelative_position(relative_position);
mlPreciseExposureBean
.
setTransaction_type
(
transaction_type
);
// mlPreciseExposureBean.setChannel_id(blPreciseExposureBean.getApp_channel());
mlPreciseExposureBean
.
setApp_version
(
blPreciseExposureBean
.
getApp_version
());
mlPreciseExposureBean
.
setCurrent_city_id
(
blPreciseExposureBean
.
getApp_current_city_id
());
mlPreciseExposureBean
.
setApp_code
(
blPreciseExposureBean
.
getApp_code
());
mlPreciseExposureBean
.
setDevice_os_type
(
blPreciseExposureBean
.
getDevice_os_type
());
mlPreciseExposureBean
.
setDevice_id
(
blPreciseExposureBean
.
getDevice_id
());
mlPreciseExposureBean
.
setCreate_time_day
(
blPreciseExposureBean
.
getCreate_time_day
());
mlPreciseExposureBean
.
setGm_nginx_time_day
(
blPreciseExposureBean
.
getGm_nginx_time_day
());
mlPreciseExposureBean
.
setPreciseexposure_num
(
1
);
//1.11 transaction_type的空值需要被修正
//问题描述:transaction_type='' 需要替换为NULL
// List<String> card_content_type_list_ch = Arrays.asList("正常搜索","指定网页","美购详情页ID","医生主页ID","秒杀专场","交易专题ID","秒杀聚合","新专题聚合","医院主页ID","福利专题列表");
List
<
String
>
card_content_type_list_ch
=
Arrays
.
asList
(
"指定网页"
);
if
(
card_content_type_list_ch
.
contains
(
card_content_type
))
{
System
.
out
.
println
(
mlPreciseExposureBean
);
}
mlPreciseExposureBeanList
.
add
(
BeanReflectUtil
.
setNullValue
(
mlPreciseExposureBean
));
}
return
mlPreciseExposureBeanList
;
}
}
src/main/java/com/gmei/jdbc/MysqlJdbcDim.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
jdbc
;
import
java.sql.*
;
import
java.util.List
;
/**
* ClassName: MysqlJdbcDim
* Function:
* Reason: 单例模式的码表层jdbc工具
* Date: 2019/12/7 上午11:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
MysqlJdbcDim
{
private
volatile
static
MysqlJdbcDim
mysqlJdbcDim
=
null
;
// public static String driver = "com.mysql.cj.jdbc.Driver";
// public static String url = "jdbc:mysql://localhost:3306/zhengxing?useSSL=false&serverTimezone=UTC";
// //?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT&allowMultiQueries=true&useSSL=false
// public static String username = "jayden";
// public static String password = "jayden548493";
// private String driver = "com.mysql.jdbc.Driver";
// private String url = "jdbc:mysql://172.22.30.12:3506/test?useUnicode=true&characterEncoding=UTF-8";//设置连接字符串
// private String username = "work";
// private String password = "zJnxVEhyyxeC7ciqxdMITVyWqOFc2mew";
private
String
driver
=
"com.mysql.jdbc.Driver"
;
private
String
url
;
private
Connection
conn
;
private
PreparedStatement
ps
;
private
MysqlJdbcDim
(
String
url
)
{
this
.
url
=
url
;
}
public
static
MysqlJdbcDim
getInstance
(
String
url
)
{
if
(
mysqlJdbcDim
==
null
)
{
synchronized
(
MysqlJdbcDim
.
class
)
{
if
(
mysqlJdbcDim
==
null
)
{
mysqlJdbcDim
=
new
MysqlJdbcDim
(
url
);
}
}
}
return
mysqlJdbcDim
;
}
public
Connection
getConnection
()
{
try
{
Class
.
forName
(
driver
);
if
(
conn
==
null
||
conn
.
isClosed
())
{
// conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/zhengxing?useSSL=false&serverTimezone=UTC", "jayden", "jayden548943");
// conn = DriverManager.getConnection(url, username, password);
conn
=
DriverManager
.
getConnection
(
url
);
}
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
conn
;
}
public
void
insert
(
String
sql
,
List
<
Object
>
param
)
throws
SQLException
{
ps
=
conn
.
prepareStatement
(
sql
);
if
(
param
!=
null
&&
param
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
param
.
size
();
i
++)
{
ps
.
setObject
(
i
+
1
,
param
.
get
(
i
));
}
}
ps
.
executeUpdate
();
}
public
void
insert
(
String
sql
)
throws
SQLException
{
Statement
st
=
null
;
st
=
conn
.
createStatement
();
st
.
executeUpdate
(
sql
);
}
public
ResultSet
query
(
String
sql
,
List
<
Object
>
param
)
{
Statement
st
=
null
;
PreparedStatement
ps
=
null
;
ResultSet
rs
=
null
;
try
{
ps
=
conn
.
prepareStatement
(
sql
);
if
(
param
!=
null
&&
param
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
param
.
size
();
i
++)
{
ps
.
setObject
(
i
+
1
,
param
.
get
(
i
));
}
}
if
(!
ps
.
isClosed
())
System
.
out
.
println
(
"Succeeded connecting to the prepareStatement!"
);
rs
=
ps
.
executeQuery
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
rs
;
}
public
ResultSet
query
(
String
sql
)
{
if
(
conn
==
null
){
conn
=
getConnection
();
}
ResultSet
rs
=
null
;
Statement
st
=
null
;
try
{
st
=
conn
.
createStatement
();
rs
=
st
.
executeQuery
(
sql
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
rs
;
}
public
static
void
close
(
Connection
con
,
Statement
st
,
ResultSet
rs
)
{
if
(
rs
!=
null
)
{
try
{
rs
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
if
(
st
!=
null
)
{
try
{
st
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
if
(
con
!=
null
)
{
try
{
con
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
src/main/java/com/gmei/jdbc/MysqlJdbcSink.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
jdbc
;
import
java.sql.*
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* ClassName: MysqlJdbcSink
* Function:
* Reason: 单例模式的数据下发jdbc工具
* Date: 2019/12/7 上午11:01
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
MysqlJdbcSink
{
private
volatile
static
MysqlJdbcSink
mysqlJdbcSink
=
null
;
// private static String driver = "com.mysql.cj.jdbc.Driver";
// public static String url = "jdbc:mysql://localhost:3306/zhengxing?useSSL=false&serverTimezone=UTC";
// //?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT&allowMultiQueries=true&useSSL=false
// public static String username = "jayden";
// public static String password = "jayden548493";
// private String driver = "com.mysql.jdbc.Driver";
// private String url = "jdbc:mysql://172.22.30.12:3506/test?useUnicode=true&characterEncoding=UTF-8";//设置连接字符串
// //rewriteBatchedStatements=true
// private String username = "work";
// private String password = "zJnxVEhyyxeC7ciqxdMITVyWqOFc2mew";
private
String
driver
=
"com.mysql.jdbc.Driver"
;
private
String
url
;
private
Connection
conn
;
private
MysqlJdbcSink
(
String
url
)
{
this
.
url
=
url
;
}
public
static
MysqlJdbcSink
getInstance
(
String
url
)
{
if
(
mysqlJdbcSink
==
null
)
{
synchronized
(
MysqlJdbcSink
.
class
)
{
if
(
mysqlJdbcSink
==
null
)
{
mysqlJdbcSink
=
new
MysqlJdbcSink
(
url
);
}
}
}
return
mysqlJdbcSink
;
}
public
Connection
getConnection
()
{
try
{
Class
.
forName
(
driver
);
if
(
conn
==
null
||
conn
.
isClosed
())
{
// conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/zhengxing?useSSL=false&serverTimezone=UTC", "jayden", "jayden548943");
// conn = DriverManager.getConnection(url, username, password);
conn
=
DriverManager
.
getConnection
(
url
);
}
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
conn
;
}
public
void
update
(
String
sql
,
List
<
Object
>
params
)
throws
SQLException
{
PreparedStatement
ps
=
null
;
try
{
ps
=
conn
.
prepareStatement
(
sql
);
if
(
params
!=
null
&&
params
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
params
.
size
();
i
++)
{
ps
.
setObject
(
i
+
1
,
params
.
get
(
i
));
}
}
int
resultNum
=
ps
.
executeUpdate
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
ps
.
close
();
}
// System.out.println(printRealSql(sql, params).replaceAll("(\\s+|\\\\n)", ""));
}
public
void
insert
(
String
sql
)
throws
SQLException
{
Statement
st
=
null
;
try
{
st
=
conn
.
createStatement
();
st
.
executeUpdate
(
sql
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
st
.
close
();
}
}
public
String
printRealSql
(
String
sql
,
List
<
Object
>
params
)
{
if
(
params
==
null
||
params
.
size
()
==
0
)
{
// System.out.println("The SQL is------------>\n" + sql);
return
sql
;
}
if
(!
match
(
sql
,
params
))
{
System
.
out
.
println
(
"SQL 语句中的占位符与参数个数不匹配。SQL:"
+
sql
);
return
null
;
}
int
cols
=
params
.
size
();
// values = params.toArray(index, count);
// Object[] values = new Object[cols];
// System.arraycopy(params, 0, values, 0, cols);
Object
[]
values
=
params
.
toArray
(
new
Object
[
cols
]);
for
(
int
i
=
0
;
i
<
cols
;
i
++)
{
Object
value
=
values
[
i
];
if
(
value
instanceof
Date
)
{
values
[
i
]
=
"'"
+
value
+
"'"
;
}
else
if
(
value
instanceof
String
)
{
values
[
i
]
=
"'"
+
value
+
"'"
;
}
else
if
(
value
instanceof
Boolean
)
{
values
[
i
]
=
(
Boolean
)
value
?
1
:
0
;
}
}
String
statement
=
String
.
format
(
sql
.
replaceAll
(
"\\?"
,
"%s"
),
values
);
// System.out.println("The SQL is------------>\n" + statement);
return
statement
;
}
private
static
boolean
match
(
String
sql
,
List
<
Object
>
params
)
{
if
(
params
==
null
||
params
.
size
()
==
0
)
return
true
;
// 没有参数,完整输出
Matcher
m
=
Pattern
.
compile
(
"(\\?)"
).
matcher
(
sql
);
int
count
=
0
;
while
(
m
.
find
())
{
count
++;
}
return
count
==
params
.
size
();
}
// public ResultSet query(String sql, List<Object> param) {
// try {
// ps = conn.prepareStatement(sql);
//
// if (param != null && param.size() > 0) {
// for (int i = 0; i < param.size(); i++) {
// ps.setObject(i + 1, param.get(i));
// }
// }
// if(!ps.isClosed())
// System.out.println("Succeeded connecting to the prepareStatement!");
// rs = ps.executeQuery();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// return rs;
// }
public
ResultSet
query
(
String
sql
)
{
// System.out.println(sql);
if
(
conn
==
null
){
conn
=
getConnection
();
}
ResultSet
rs
=
null
;
Statement
st
=
null
;
try
{
st
=
conn
.
createStatement
();
rs
=
st
.
executeQuery
(
sql
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
return
rs
;
}
public
void
close
(
Connection
con
,
Statement
st
,
ResultSet
rs
)
{
if
(
rs
!=
null
)
{
try
{
rs
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
if
(
st
!=
null
)
{
try
{
st
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
if
(
con
!=
null
)
{
try
{
con
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
src/main/java/com/gmei/schema/BlPreciseExposureSchema.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
schema
;
import
com.gmei.bean.bl.BlPreciseExposureBean
;
import
org.apache.flink.api.common.serialization.DeserializationSchema
;
import
org.apache.flink.api.common.serialization.SerializationSchema
;
import
org.apache.flink.api.common.typeinfo.BasicTypeInfo
;
import
org.apache.flink.api.common.typeinfo.TypeInformation
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
;
import
org.msgpack.MessagePack
;
import
org.msgpack.type.Value
;
import
org.msgpack.type.ValueFactory
;
import
java.io.IOException
;
import
java.io.ObjectOutputStream
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
static
org
.
apache
.
flink
.
util
.
Preconditions
.
checkNotNull
;
/**
* ClassName: BlPreciseExposureSchema
* Function:
* Reason: 暂时未用到
* Date: 2019/12/17 下午4:51
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
BlPreciseExposureSchema
implements
DeserializationSchema
<
String
>,
SerializationSchema
<
String
>
{
private
static
final
long
serialVersionUID
=
1L
;
private
transient
Charset
charset
;
public
BlPreciseExposureSchema
()
{
this
(
StandardCharsets
.
UTF_8
);
}
public
BlPreciseExposureSchema
(
Charset
charset
)
{
this
.
charset
=
checkNotNull
(
charset
);
}
public
Charset
getCharset
()
{
return
charset
;
}
private
void
writeObject
(
ObjectOutputStream
out
)
throws
IOException
{
out
.
defaultWriteObject
();
out
.
writeUTF
(
charset
.
name
());
}
private
void
readObject
(
java
.
io
.
ObjectInputStream
in
)
throws
IOException
,
ClassNotFoundException
{
in
.
defaultReadObject
();
String
charsetName
=
in
.
readUTF
();
this
.
charset
=
Charset
.
forName
(
charsetName
);
}
@Override
public
String
deserialize
(
byte
[]
bytes
)
throws
IOException
{
String
msg
=
new
String
(
bytes
,
StandardCharsets
.
UTF_8
);
ObjectMapper
mapper
=
new
ObjectMapper
();
JsonNode
jsonNode
=
mapper
.
readTree
(
msg
);
BlPreciseExposureBean
blPreciseExposureBean
=
mapper
.
readValue
(
msg
,
BlPreciseExposureBean
.
class
);
MessagePack
msgpack
=
new
MessagePack
();
Value
MSGPACK_STRING_VALUE_CONTENT
=
ValueFactory
.
createRawValue
(
"content"
.
getBytes
(
StandardCharsets
.
US_ASCII
));
String
contentString
=
""
;
try
{
contentString
=
msgpack
.
read
(
bytes
).
asMapValue
().
get
(
MSGPACK_STRING_VALUE_CONTENT
).
asRawValue
().
getString
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
contentString
;
}
@Override
public
boolean
isEndOfStream
(
String
s
)
{
return
false
;
}
@Override
public
byte
[]
serialize
(
String
s
)
{
return
s
.
getBytes
(
charset
);
}
@Override
public
TypeInformation
<
String
>
getProducedType
()
{
return
BasicTypeInfo
.
STRING_TYPE_INFO
;
}
}
src/main/java/com/gmei/sink/DayBucketAssigner.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
sink
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
org.apache.flink.core.io.SimpleVersionedSerializer
;
import
org.apache.flink.streaming.api.functions.sink.filesystem.BucketAssigner
;
import
org.apache.flink.streaming.api.functions.sink.filesystem.bucketassigners.SimpleVersionedStringSerializer
;
/**
* ClassName: DayBucketAssigner
* Function:
* Reason: 按照日期分区
* Date: 2019/12/17 下午7:49
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DayBucketAssigner
implements
BucketAssigner
<
MlPreciseExposureBean
,
String
>
{
@Override
public
String
getBucketId
(
MlPreciseExposureBean
mlPreciseExposureBean
,
Context
context
)
{
String
gm_nginx_time_day
=
mlPreciseExposureBean
.
getGm_nginx_time_day
();
return
gm_nginx_time_day
;
}
@Override
public
SimpleVersionedSerializer
<
String
>
getSerializer
()
{
return
SimpleVersionedStringSerializer
.
INSTANCE
;
}
}
src/main/java/com/gmei/sink/MlPreciseExposureMysqlSink.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
sink
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
com.gmei.cache.MlPreciseExposureDao
;
import
com.gmei.jdbc.MysqlJdbcSink
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.streaming.api.functions.sink.RichSinkFunction
;
import
java.sql.Connection
;
/**
* ClassName: MlPreciseExposureMysqlSink
* Function:
* Reason: 数据下发mysql
* Date: 2019/12/16 下午6:45
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
MlPreciseExposureMysqlSink
extends
RichSinkFunction
<
MlPreciseExposureBean
>
{
private
MysqlJdbcSink
mysqlJdbcSink
;
private
Connection
conn
;
private
MlPreciseExposureDao
mlPreciseExposureDao
;
private
int
maxRetry
=
1
;
private
long
retryTime
=
3000
;
private
String
sinkJdbcUrl
;
private
String
sinkTableName
;
public
MlPreciseExposureMysqlSink
(
String
sinkJdbcUrl
,
String
sinkTableName
)
{
this
.
sinkJdbcUrl
=
sinkJdbcUrl
;
this
.
sinkTableName
=
sinkTableName
;
}
@Override
public
void
open
(
Configuration
parameters
)
throws
Exception
{
super
.
open
(
parameters
);
mysqlJdbcSink
=
MysqlJdbcSink
.
getInstance
(
sinkJdbcUrl
);
mlPreciseExposureDao
=
new
MlPreciseExposureDao
(
sinkJdbcUrl
,
sinkTableName
);
conn
=
mysqlJdbcSink
.
getConnection
();
}
@Override
public
void
invoke
(
MlPreciseExposureBean
value
,
Context
context
)
throws
Exception
{
try
{
conn
.
setAutoCommit
(
false
);
mlPreciseExposureDao
.
insertMlPreciseExposure
(
value
);
conn
.
commit
();
}
catch
(
Exception
e
)
{
conn
.
rollback
();
int
numRetry
=
1
;
Exception
lastException
=
e
;
while
(
numRetry
<=
maxRetry
)
{
try
{
numRetry
++;
Thread
.
sleep
(
retryTime
);
mysqlJdbcSink
.
close
(
conn
,
null
,
null
);
conn
=
mysqlJdbcSink
.
getConnection
();
conn
.
setAutoCommit
(
false
);
mlPreciseExposureDao
.
insertMlPreciseExposure
(
value
);
conn
.
commit
();
}
catch
(
Exception
e1
)
{
conn
.
rollback
();
lastException
=
e1
;
continue
;
}
return
;
}
throw
lastException
;
}
}
@Override
public
void
close
()
throws
Exception
{
super
.
close
();
mysqlJdbcSink
.
close
(
conn
,
null
,
null
);
}
}
src/main/java/com/gmei/source/BlMaiDianKafkaSource.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
source
;
import
org.apache.flink.api.common.serialization.SimpleStringSchema
;
import
org.apache.flink.streaming.api.datastream.DataStreamSource
;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer011
;
import
java.util.Properties
;
/**
* ClassName: BlMaiDianKafkaSource
* Function:
* Reason: 获取kafka资源
* Date: 2019/12/5 下午3:54
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
BlMaiDianKafkaSource
{
private
String
brokers
;
private
String
topic
;
private
String
groupId
;
public
BlMaiDianKafkaSource
()
{
}
public
BlMaiDianKafkaSource
(
String
brokers
,
String
topic
,
String
groupId
)
{
this
.
brokers
=
brokers
;
this
.
topic
=
topic
;
this
.
groupId
=
groupId
;
}
/**
* Function: addSource
* Reason: 获取kafka资源
* Date: 2019/12/25 下午4:49
*
* @author liuzhe
* @since JDK 1.8
*/
public
FlinkKafkaConsumer011
<
String
>
addSource
()
{
Properties
props
=
new
Properties
();
props
.
put
(
"bootstrap.servers"
,
brokers
);
props
.
put
(
"group.id"
,
groupId
);
props
.
put
(
"enable.auto.commit"
,
"true"
);
props
.
put
(
"auto.commit.interval.ms"
,
"1000"
);
// props.put("auto.offset.reset", "earliest");
props
.
put
(
"key.deserializer"
,
"org.apache.kafka.common.serialization.StringDeserializer"
);
props
.
put
(
"value.deserializer"
,
"org.apache.kafka.common.serialization.StringDeserializer"
);
FlinkKafkaConsumer011
<
String
>
myConsumer
=
new
FlinkKafkaConsumer011
<
String
>(
topic
,
new
SimpleStringSchema
(),
props
);
myConsumer
.
setStartFromGroupOffsets
();
//默认消费策略
// myConsumer.setStartFromEarliest();
return
myConsumer
;
}
public
DataStreamSource
<
String
>
addSource
(
StreamExecutionEnvironment
streamExecutionEnvironment
)
{
StreamExecutionEnvironment
env
=
streamExecutionEnvironment
;
String
topicName
=
"test"
;
String
groupId
=
"group1"
;
Properties
props
=
new
Properties
();
props
.
put
(
"bootstrap.servers"
,
"localhost:9092"
);
props
.
put
(
"group.id"
,
groupId
);
props
.
put
(
"enable.auto.commit"
,
"true"
);
props
.
put
(
"auto.commit.interval.ms"
,
"1000"
);
props
.
put
(
"auto.offset.reset"
,
"earliest"
);
props
.
put
(
"key.deserializer"
,
"org.apache.kafka.common.serialization.StringDeserializer"
);
props
.
put
(
"value.deserializer"
,
"org.apache.kafka.common.serialization.StringDeserializer"
);
FlinkKafkaConsumer011
<
String
>
myConsumer
=
new
FlinkKafkaConsumer011
<
String
>(
topicName
,
new
SimpleStringSchema
(),
props
);
myConsumer
.
setStartFromGroupOffsets
();
//默认消费策略
// myConsumer.setStartFromEarliest();
DataStreamSource
<
String
>
dataStreamSource
=
env
.
addSource
(
myConsumer
);
return
dataStreamSource
;
}
}
src/main/java/com/gmei/sql/bl_et_mg_preciseexposure_inc_d.sql
0 → 100644
View file @
e15a2105
INSERT
OVERWRITE
TABLE
BL_ET_MG_PRECISEEXPOSURE_INC_D
PARTITION
(
PARTITION_DAY
=
'${partition_day}'
)
SELECT
T1
.
JSON
AS
JSON
,
--原始日志
T1
.
GM_NGINX_KEY
AS
GM_NGINX_KEY
,
T1
.
VERSION
AS
VERSION
,
T1
.
PARAMS
AS
PARAMS
,
--埋点参数字段
T1
.
APP_SESSION_ID
AS
APP_SESSION_ID
,
--客户端会话ID
T1
.
GM_NGINX_TIMESTAMP
AS
GM_NGINX_TIMESTAMP
,
--服务端接收时间戳
T1
.
CREATE_TIMESTAMP
AS
CREATE_TIMESTAMP
,
--时间戳
T1
.
APP
AS
APP
,
--埋点APP字段
T1
.
DEVICE
AS
DEVICE
,
--埋点DEVICE字段
T1
.
USER_ID
AS
USER_ID
,
--用户ID
T1
.
ACTION
AS
TYPE
,
--事件名称
T1
.
PARAMS_DOWN_LOADING_TIMES
AS
PARAMS_DOWN_LOADING_TIMES
,
--下拉加载次数
T1
.
PARAMS_DOWN_SLIDE_TIMES
AS
PARAMS_DOWN_SLIDE_TIMES
,
--下拉滑动次数
T1
.
PARAMS_UP_LOADING_TIMES
AS
PARAMS_UP_LOADING_TIMES
,
--上拉加载次数
T1
.
PARAMS_UP_SLIDE_TIMES
AS
PARAMS_UP_SLIDE_TIMES
,
--上拉滑动次数
T1
.
PARAMS_PAGE_NAME
AS
PARAMS_PAGE_NAME
,
--页面编码
T1
.
PARAMS_TAB_NAME
AS
PARAMS_TAB_NAME
,
--页面TAB名称
T1
.
PARAMS_BUSINESS_ID
AS
PARAMS_BUSINESS_ID
,
--页面ID
T1
.
PARAMS_REFERRER
AS
PARAMS_REFERRER
,
--来源页面编码
T1
.
PARAMS_REFERRER_ID
AS
PARAMS_REFERRER_ID
,
--来源页面ID
T1
.
PARAMS_EXPOSURE_CARDS
AS
PARAMS_EXPOSURE_CARDS
,
--精准曝光数据块
T1
.
PARAMS_IS_EXPOSURE
AS
PARAMS_IS_EXPOSURE
,
--是否是精准曝光
T1
.
PARAMS_FILTER
AS
PARAMS_FILTER
,
--筛选器内容
T1
.
PARAMS_QUERY
AS
PARAMS_QUERY
,
--搜索词
T1
.
APP_GREY_TYPE
AS
APP_GREY_TYPE
,
--灰度组类型
T1
.
APP_CHANNEL
AS
APP_CHANNEL
,
--渠道ID
T1
.
APP_VERSION
AS
APP_VERSION
,
--客户端版本
T1
.
APP_SERIAL_ID
AS
APP_SERIAL_ID
,
--埋点序列ID
NVL
(
T2
.
CITY_ID
,
T1
.
APP_CURRENT_CITY_ID
)
AS
APP_CURRENT_CITY_ID
,
--当前城市ID
T1
.
APP_NAME
AS
APP_NAME
,
--APP名称
T1
.
APP_USER_TYPE
AS
APP_USER_TYPE
,
--APP用户类型
T1
.
DEVICE_IS_WIFI
AS
DEVICE_IS_WIFI
,
--是否WIFI
T1
.
DEVICE_TYPE
AS
DEVICE_TYPE
,
--设备类型
T1
.
DEVICE_MODEL
AS
DEVICE_MODEL
,
--设备型号
T1
.
DEVICE_SYS_VERSION
AS
DEVICE_SYS_VERSION
,
--设备系统版本
T1
.
DEVICE_NET_TYPE
AS
DEVICE_NET_TYPE
,
--设备网络类型
T1
.
DEVICE_ID
AS
DEVICE_ID
,
--设备ID
T1
.
DEVICE_ANDROID_ID
AS
DEVICE_ANDROID_ID
,
--设备安卓ID
T1
.
DEVICE_LNG
AS
DEVICE_LNG
,
--设备经度
T1
.
DEVICE_LAT
AS
DEVICE_LAT
,
--设备纬度
T1
.
DEVICE_IP
AS
DEVICE_IP
,
--设备IP
T1
.
DEVICE_MANUFACTURER
AS
DEVICE_MANUFACTURER
,
--设备制造商
T1
.
DEVICE_IDFV
AS
DEVICE_IDFV
,
--设备IDFV
T1
.
DEVICE_IDFA
AS
DEVICE_IDFA
,
--设备IDFA
T1
.
GM_NGINX_TIME_DATE
AS
GM_NGINX_TIME_DATE
,
--服务端接收时间
T1
.
GM_NGINX_TIME_DAY
AS
GM_NGINX_TIME_DAY
,
--服务端接收日期
T1
.
TIME_DATE
AS
CREATE_TIME_DATE
,
--时间戳格式化后的时间
T1
.
TIME_DAY
AS
CREATE_TIME_DAY
--时间戳格式化后的日期
FROM
(
SELECT
REGEXP_REPLACE
(
REGEXP_REPLACE
(
T
.
JSON
,
'
\\
s+'
,
''
),
'
\\\\\\\\
n'
,
''
)
JSON
,
--原始JSON
--第一级别JSON
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.gm_nginx_key'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.gm_nginx_key'
)))
GM_NGINX_KEY
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.version'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.version'
)))
VERSION
,
CASE
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params'
))
=
''
OR
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params'
)
IS
NULL
THEN
JSON_MAP
(
'{}'
,
'string,string'
)
WHEN
IS_JSON
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params'
))
=
'true'
THEN
JSON_MAP
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params'
)),
'string,string'
)
ELSE
JSON_MAP
(
REGEXP_REPLACE
(
REGEXP_REPLACE
(
REGEXP_REPLACE
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params'
)),
'("){2}'
,
'"'
),
':",'
,
':"",'
),
':"}'
,
':""}'
),
'string,string'
)
END
PARAMS
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app_session_id'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app_session_id'
)))
APP_SESSION_ID
,
CAST
(
CAST
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.gm_nginx_timestamp'
))
AS
DOUBLE
)
AS
BIGINT
)
GM_NGINX_TIMESTAMP
,
CAST
(
CAST
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.create_at'
))
AS
DOUBLE
)
AS
BIGINT
)
CREATE_TIMESTAMP
,
CASE
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app'
))
=
''
OR
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app'
)
IS
NULL
THEN
JSON_MAP
(
'{}'
,
'string,string'
)
ELSE
JSON_MAP
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app'
)),
'string,string'
)
END
AS
APP
,
CASE
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device'
))
=
''
OR
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device'
)
IS
NULL
THEN
JSON_MAP
(
'{}'
,
'string,string'
)
ELSE
JSON_MAP
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device'
)),
'string,string'
)
END
AS
DEVICE
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.user_id'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.user_id'
)))
AS
USER_ID
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.type'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.type'
)))
AS
ACTION
,
--第二级别JSON
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.down_loading_times'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.down_loading_times'
)))
AS
PARAMS_DOWN_LOADING_TIMES
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.down_slide_times'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.down_slide_times'
)))
AS
PARAMS_DOWN_SLIDE_TIMES
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.up_loading_times'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.up_loading_times'
)))
AS
PARAMS_UP_LOADING_TIMES
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.up_slide_times'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.up_slide_times'
)))
AS
PARAMS_UP_SLIDE_TIMES
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.page_name'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.page_name'
)))
AS
PARAMS_PAGE_NAME
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.tab_name'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.tab_name'
)))
AS
PARAMS_TAB_NAME
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.business_id'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.business_id'
)))
AS
PARAMS_BUSINESS_ID
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.referrer'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.referrer'
)))
AS
PARAMS_REFERRER
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.referrer_id'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.referrer_id'
)))
AS
PARAMS_REFERRER_ID
,
CASE
WHEN
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.device_type'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.device_type'
)))
=
'android'
AND
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.version'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.version'
)))
IN
(
'7.7.35'
,
'7.7.36'
,
'7.7.40'
)
THEN
JSON_SPLIT
(
REGEXP_REPLACE
(
TO_JSON
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.exposure_cards'
))),
'absolute_position'
,
'
\\\\
"absolute_position'
))
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.exposure_cards'
))
=
''
OR
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.exposure_cards'
)
IS
NULL
THEN
ARRAY
()
ELSE
JSON_SPLIT
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.exposure_cards'
)))
END
PARAMS_EXPOSURE_CARDS
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.is_exposure'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.is_exposure'
)))
PARAMS_IS_EXPOSURE
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.filter'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.filter'
)))
PARAMS_FILTER
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.query'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.params.query'
)))
PARAMS_QUERY
,
CASE
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.grey_type'
))
IN
(
''
,
'unknown'
)
OR
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.grey_type'
)
IS
NULL
THEN
JSON_MAP
(
'{}'
,
'string,string'
)
ELSE
JSON_MAP
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.grey_type'
)),
'string,string'
)
END
APP_GREY_TYPE
,
CASE
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.channel'
))
=
''
THEN
NULL
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.channel'
))
=
'AppStore'
THEN
'App Store'
ELSE
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.channel'
))
END
AS
APP_CHANNEL
,
-- IF(TRIM(GET_JSON_OBJECT(LV.RAW, '$.app.channel'))= '', NULL, TRIM(GET_JSON_OBJECT(LV.RAW, '$.app.channel'))) APP_CHANNEL,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.version'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.version'
)))
APP_VERSION
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.serial_id'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.serial_id'
)))
APP_SERIAL_ID
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.current_city_id'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.current_city_id'
)))
APP_CURRENT_CITY_ID
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.name'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.name'
)))
APP_NAME
,
CASE
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.user_type'
))
=
''
OR
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.user_type'
)
IS
NULL
THEN
JSON_MAP
(
'{}'
,
'string,string'
)
ELSE
JSON_MAP
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.app.user_type'
)),
'string,string'
)
END
AS
APP_USER_TYPE
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.is_WiFi'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.is_WiFi'
)))
DEVICE_IS_WIFI
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.device_type'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.device_type'
)))
DEVICE_TYPE
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.model'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.model'
)))
DEVICE_MODEL
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.sys_version'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.sys_version'
)))
DEVICE_SYS_VERSION
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.net_type'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.net_type'
)))
DEVICE_NET_TYPE
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.android_device_id'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.android_device_id'
)))
DEVICE_ANDROID_ID
,
CASE
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.device_id'
))
=
''
AND
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.idfv'
))
<>
''
THEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.idfv'
))
WHEN
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.device_id'
))
=
''
AND
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.idfv'
))
=
''
THEN
NULL
ELSE
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.device_id'
))
END
AS
DEVICE_ID
,
-- IF(TRIM(GET_JSON_OBJECT(LV.RAW, '$.device.device_id'))= '', NULL, TRIM(GET_JSON_OBJECT(LV.RAW, '$.device.device_id'))) DEVICE_ID,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.lng'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.lng'
)))
DEVICE_LNG
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.lat'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.lat'
)))
DEVICE_LAT
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.ip'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.ip'
)))
DEVICE_IP
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.manufacturer'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.manufacturer'
)))
DEVICE_MANUFACTURER
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.idfv'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.idfv'
)))
DEVICE_IDFV
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.idfa'
))
=
''
,
NULL
,
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.device.idfa'
)))
DEVICE_IDFA
,
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.gm_nginx_timestamp'
))
=
''
,
NULL
,
FROM_UNIXTIME
(
CAST
(
CAST
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.gm_nginx_timestamp'
))
AS
DOUBLE
)
AS
BIGINT
),
'yyyy-MM-dd HH:mm:ss'
))
GM_NGINX_TIME_DATE
,
--服务端接收时间
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.gm_nginx_timestamp'
))
=
''
,
NULL
,
FROM_UNIXTIME
(
CAST
(
CAST
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.gm_nginx_timestamp'
))
AS
DOUBLE
)
AS
BIGINT
),
'yyyyMMdd'
))
GM_NGINX_TIME_DAY
,
--服务端接收日期
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.create_at'
))
=
''
,
NULL
,
FROM_UNIXTIME
(
CAST
(
CAST
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.create_at'
))
AS
DOUBLE
)
AS
BIGINT
),
'yyyy-MM-dd HH:mm:ss'
))
TIME_DATE
,
--时间戳格式化后的时间
IF
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.create_at'
))
=
''
,
NULL
,
FROM_UNIXTIME
(
CAST
(
CAST
(
TRIM
(
GET_JSON_OBJECT
(
LV
.
RAW
,
'$.create_at'
))
AS
DOUBLE
)
AS
BIGINT
),
'yyyyMMdd'
))
TIME_DAY
--时间戳格式化后的日期
FROM
TL
.
TL_LOG_PRECISE_EXPOSURE
T
LATERAL
VIEW
JSON_TUPLE
(
REGEXP_REPLACE
(
REGEXP_REPLACE
(
T
.
JSON
,
'
\\\\\\\\
n'
,
''
),
'
\\
s+'
,
''
),
'@raw'
)
LV
AS
RAW
WHERE
T
.
PARTITION_DAY
=
'${partition_day}'
)
T1
LEFT
JOIN
(
SELECT
T
.
ID
AS
CITY_ID
,
T
.
TAG_ID
AS
TAG_ID
FROM
TL
.
TL_ZX_API_CITY
T
WHERE
T
.
PARTITION_DAY
=
'${partition_day}'
AND
T
.
IS_ONLINE
=
'true'
)
T2
ON
T1
.
APP_CURRENT_CITY_ID
=
T2
.
TAG_ID
;
\ No newline at end of file
src/main/java/com/gmei/sql/dim_table_ddl.sql
0 → 100644
View file @
e15a2105
CREATE
TABLE
`dim_city`
(
`code`
varchar
(
100
)
COMMENT
'城市编码'
PRIMARY
KEY
,
`pk`
varchar
(
100
)
COMMENT
'城市TAGID'
DEFAULT
NULL
,
`name`
varchar
(
100
)
COMMENT
'城市名称'
DEFAULT
NULL
,
`memo`
varchar
(
100
)
COMMENT
'城市说明'
DEFAULT
NULL
,
`parent_province_code`
varchar
(
100
)
COMMENT
'省份编码'
DEFAULT
NULL
,
`parent_province_pk`
varchar
(
100
)
COMMENT
'省份TAGID'
DEFAULT
NULL
,
`parent_province_name`
varchar
(
100
)
COMMENT
'省份名称'
DEFAULT
NULL
,
`parent_province_memo`
varchar
(
100
)
COMMENT
'省份说明'
DEFAULT
NULL
,
`parent_country_code`
varchar
(
100
)
COMMENT
'国家编码'
DEFAULT
NULL
,
`parent_country_pk`
varchar
(
100
)
COMMENT
'国家TAGID'
DEFAULT
NULL
,
`parent_country_name`
varchar
(
100
)
COMMENT
'国家名称'
DEFAULT
NULL
,
`parent_country_memo`
varchar
(
100
)
COMMENT
'国家说明'
DEFAULT
NULL
,
`parent_region_code`
varchar
(
100
)
COMMENT
'区域编码'
DEFAULT
NULL
,
`parent_region_pk`
varchar
(
100
)
COMMENT
'区域ID'
DEFAULT
NULL
,
`parent_region_name`
varchar
(
100
)
COMMENT
'区域名称'
DEFAULT
NULL
,
`parent_region_memo`
varchar
(
100
)
COMMENT
'区域说明'
DEFAULT
NULL
,
`oid`
int
COMMENT
'排序'
DEFAULT
NULL
)
COMMENT
'城市码表'
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
TABLE
`dim_page_type`
(
`code`
varchar
(
100
)
COMMENT
'页面编码'
NOT
NULL
,
`pk`
varchar
(
100
)
COMMENT
'页面主键'
DEFAULT
NULL
,
`name`
varchar
(
100
)
COMMENT
'页面名称'
DEFAULT
NULL
,
`memo`
varchar
(
100
)
COMMENT
'页面说明'
DEFAULT
NULL
,
`parent_app_code`
varchar
(
100
)
COMMENT
'上级APP编码'
,
`parent_app_pk`
varchar
(
100
)
COMMENT
'上级APP主键'
DEFAULT
NULL
,
`parent_app_name`
varchar
(
100
)
COMMENT
'上级APP名称'
DEFAULT
NULL
,
`parent_app_memo`
varchar
(
100
)
COMMENT
'上级APP说明'
DEFAULT
NULL
,
`type_s_code`
varchar
(
100
)
COMMENT
'页面分类小类编码'
DEFAULT
NULL
,
`type_s_name`
varchar
(
100
)
COMMENT
'页面分类小类名称'
DEFAULT
NULL
,
`type_m_code`
varchar
(
100
)
COMMENT
'页面分类中类编码'
DEFAULT
NULL
,
`type_m_name`
varchar
(
100
)
COMMENT
'页面分类中类名称'
DEFAULT
NULL
,
`type_l_code`
varchar
(
100
)
COMMENT
'页面分类大类编码'
DEFAULT
NULL
,
`type_l_name`
varchar
(
100
)
COMMENT
'页面分类大类名称'
DEFAULT
NULL
,
`oid`
int
COMMENT
'排序'
DEFAULT
NULL
,
PRIMARY
KEY
(
`code`
,
`parent_app_code`
)
)
COMMENT
'页面分类码表'
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
TABLE
`dim_card_content_type`
(
`code`
varchar
(
100
)
COMMENT
'编码'
PRIMARY
KEY
,
`pk`
varchar
(
100
)
COMMENT
'主键'
DEFAULT
NULL
,
`name`
varchar
(
100
)
COMMENT
'名称'
DEFAULT
NULL
,
`memo`
varchar
(
100
)
COMMENT
'说明'
DEFAULT
NULL
,
`new_code`
varchar
(
100
)
COMMENT
'转换后编码'
DEFAULT
NULL
,
`oid`
int
COMMENT
'排序'
DEFAULT
NULL
)
COMMENT
'卡片内容类型码表'
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
TABLE
`dim_card_type`
(
`code`
varchar
(
100
)
COMMENT
'编码'
PRIMARY
KEY
,
`pk`
varchar
(
100
)
COMMENT
'主键'
DEFAULT
NULL
,
`name`
varchar
(
100
)
COMMENT
'名称'
DEFAULT
NULL
,
`memo`
varchar
(
100
)
COMMENT
'说明'
DEFAULT
NULL
,
`new_code`
varchar
(
100
)
COMMENT
'转换后编码'
DEFAULT
NULL
,
`oid`
int
COMMENT
'排序'
DEFAULT
NULL
)
COMMENT
'卡片类型码表'
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
TABLE
`dim_transaction_type`
(
`code`
varchar
(
100
)
COMMENT
'编码'
PRIMARY
KEY
,
`pk`
varchar
(
100
)
COMMENT
'主键'
DEFAULT
NULL
,
`name`
varchar
(
100
)
COMMENT
'名称'
DEFAULT
NULL
,
`memo`
varchar
(
100
)
COMMENT
'说明'
DEFAULT
NULL
,
`oid`
int
COMMENT
'排序'
DEFAULT
NULL
)
COMMENT
'业务类型码表'
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
CREATE
TABLE
`ml_c_et_pe_preciseexposure_dimen_d_rt`
(
`user_id`
varchar
(
200
)
comment
'用户ID'
default
null
,
`action`
varchar
(
200
)
comment
'事件接口'
default
null
,
`page_code`
varchar
(
200
)
comment
'页面编码'
default
null
,
`page_name`
varchar
(
200
)
comment
'页面名称'
default
null
,
`tab_name`
varchar
(
200
)
comment
'TAB名称'
default
null
,
`business_id`
varchar
(
200
)
comment
'业务ID'
default
null
,
`referrer_code`
varchar
(
200
)
comment
'来源页编码'
default
null
,
`referrer_name`
varchar
(
200
)
comment
'来源页名称'
default
null
,
`referrer_id`
varchar
(
200
)
comment
'来源页业务ID'
default
null
,
`card_id`
varchar
(
200
)
comment
'卡片ID'
default
null
,
`card_content_type`
varchar
(
200
)
comment
'卡片内容类型'
default
null
,
`card_content_type_name`
varchar
(
200
)
comment
'卡片内容类型名称'
default
null
,
`card_type`
varchar
(
200
)
comment
'卡片类型'
default
null
,
`card_type_name`
varchar
(
200
)
comment
'卡片类型'
default
null
,
`is_cpc`
varchar
(
200
)
comment
'是否CPC'
default
null
,
`cpc_referer`
varchar
(
200
)
comment
'CPC来源'
default
null
,
`transaction_type`
varchar
(
200
)
comment
'业务类型'
default
null
,
`transaction_type_name`
varchar
(
200
)
comment
'业务类型名称'
default
null
,
`filter`
varchar
(
200
)
comment
'筛选器'
default
null
,
`query`
varchar
(
200
)
comment
'搜索词'
default
null
,
`app_version`
varchar
(
200
)
comment
'APP版本'
default
null
,
`current_city_id`
varchar
(
200
)
comment
'当前城市ID'
default
null
,
`current_city_name`
varchar
(
200
)
comment
'当前城市名称'
default
null
,
`current_province_id`
varchar
(
200
)
comment
'当前省份ID'
default
null
,
`current_province_name`
varchar
(
200
)
comment
'当前省份名称'
default
null
,
`current_country_id`
varchar
(
200
)
comment
'当前国家ID'
default
null
,
`current_country_name`
varchar
(
200
)
comment
'当前国家名称'
default
null
,
`current_region_id`
varchar
(
200
)
comment
'当前区域ID'
default
null
,
`current_region_name`
varchar
(
200
)
comment
'当前区域名称'
default
null
,
`app_code`
varchar
(
200
)
comment
'APP编码'
default
null
,
`device_os_type`
varchar
(
200
)
comment
'设备系统类型'
default
null
,
`device_id`
varchar
(
200
)
comment
'设备ID'
default
null
,
`create_time_day`
varchar
(
200
)
comment
'日志创建时间'
default
null
,
`gm_nginx_time_day`
varchar
(
200
)
comment
'日志接收时间'
default
null
,
`preciseexposure_num`
int
comment
'精准曝光数量'
default
null
)
COMMENT
'精准曝光实时表'
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
SELECT
t1
.
CODE
,
t1
.
pk
,
t1
.
NAME
,
t1
.
memo
,
t1
.
parent_app_code
,
t1
.
parent_app_pk
,
t2
.
NAME
parent_app_name
,
t2
.
memo
parent_app_memo
,
t1
.
type_l_code
,
t1
.
type_l_name
,
t1
.
type_m_code
,
t1
.
type_m_name
,
t1
.
type_s_code
,
t1
.
type_s_name
,
t1
.
oid
FROM
dim
.
dim_page_type
t1
LEFT
JOIN
dim
.
dim_app_name
t2
ON
t1
.
parent_app_code
=
t2
.
CODE
;
SELECT
t1
.
CODE
,
t1
.
pk
,
t1
.
NAME
,
t1
.
memo
,
t1
.
parent_code
parent_province_code
,
t1
.
parent_pk
parent_province_pk
,
t2
.
NAME
parent_province_name
,
t2
.
memo
parent_province_memo
,
t2
.
parent_country_code
,
t2
.
parent_country_pk
,
t3
.
NAME
parent_country_name
,
t3
.
memo
parent_country_memo
,
t2
.
parent_region_code
,
t2
.
parent_region_pk
,
t4
.
NAME
parent_region_name
,
t4
.
memo
parent_region_memo
,
t1
.
oid
FROM
dim
.
dim_city
t1
LEFT
JOIN
dim
.
dim_province
t2
ON
t1
.
parent_code
=
t2
.
CODE
LEFT
JOIN
dim
.
dim_country
t3
ON
t2
.
parent_country_code
=
t3
.
CODE
LEFT
JOIN
dim
.
dim_region
t4
ON
t2
.
parent_region_code
=
t4
.
CODE
;
\ No newline at end of file
src/main/java/com/gmei/sql/dim_table_dml.sql
0 → 100644
View file @
e15a2105
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/main/java/com/gmei/streaming/PreciseExposureStreaming.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
streaming
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
com.gmei.function.*
;
import
com.gmei.sink.MlPreciseExposureMysqlSink
;
import
com.gmei.source.BlMaiDianKafkaSource
;
import
org.apache.flink.api.java.utils.ParameterTool
;
import
org.apache.flink.streaming.api.TimeCharacteristic
;
import
org.apache.flink.streaming.api.datastream.*
;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.api.windowing.time.Time
;
import
org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer011
;
import
java.util.concurrent.*
;
/**
* ClassName: PreciseExposureStreaming
* Function:
* Reason: flink主类
* Date: 2019/12/5 下午3:54
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
PreciseExposureStreaming
{
/**
* Function: main
* Reason: 执行入口
* Date: 2019/12/24 上午11:03
* args: inBrokes、inTopic、inzk、groupId、outTableName、outBrokers、outTopic、dimJdbcUrl、sinkJdbcUrl
* 运行参数设置:
* 时间属性: ProcessingTime
* 聚合窗口时间: 30秒
* 并行度: 1
* 异步查询最长等待时间: 1分钟
* 缓存大小: 2000
* 缓存过期时间: 24小时
* @author liuzhe
* @since JDK 1.8
*/
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
inBrokers
=
null
;
String
inTopic
=
null
;
String
groupId
=
null
;
String
dimJdbcUrl
=
null
;
String
sinkJdbcUrl
=
null
;
String
sinkTableName
=
null
;
ParameterTool
parameterTool
=
null
;
try
{
// ./flink run flink-stat-1.0-SNAPSHOT.jar -brokers kafka.dev.gengmei:9092 -topic gm-logging-test -sinkUrl jdbc:phoenix:localhost:2181 -sinkTable data.device_for_flink -zxUrl jdbc:mysql://localhost/seven?user=root&password=123123 -zxTable statistic_promotion_channel
// ./flink run flink-stat-1.0-SNAPSHOT.jar -brokers 172.21.40.14:9092 -topic gm-precise_exposure-test
parameterTool
=
ParameterTool
.
fromArgs
(
args
);
inBrokers
=
parameterTool
.
getRequired
(
"inBrokers"
);
inTopic
=
parameterTool
.
getRequired
(
"inTopic"
);
groupId
=
parameterTool
.
get
(
"groupId"
,
"flink_preciseexposure_group"
);
dimJdbcUrl
=
parameterTool
.
getRequired
(
"dimJdbcUrl"
);
sinkJdbcUrl
=
parameterTool
.
getRequired
(
"sinkJdbcUrl"
);
sinkTableName
=
parameterTool
.
getRequired
(
"sinkTableName"
);
// Boolean startFromLatest = parameterTool.getBoolean("startFromLatest", false);
// Integer windowSize = parameterTool.getInt("windowSize", 10);
// Integer parallelism = parameterTool.getInt("parallelism", 1);
printUsage
(
parameterTool
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
printUsage
();
}
StreamExecutionEnvironment
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
();
//设置时间属性(EventTime:事件时间;IngestionTime:接入时间;ProcessingTime:处理时间(默认))
env
.
setStreamTimeCharacteristic
(
TimeCharacteristic
.
ProcessingTime
);
//正式环境
BlMaiDianKafkaSource
blMaiDianKafkaSource
=
new
BlMaiDianKafkaSource
(
inBrokers
,
inTopic
,
groupId
);
//测试环境
// BlMaiDianKafkaSource blMaiDianKafkaSource = new BlMaiDianKafkaSource("localhost:9092", "test", "group1");
FlinkKafkaConsumer011
<
String
>
myConsumer
=
blMaiDianKafkaSource
.
addSource
();
DataStreamSource
blMaiDianSource
=
env
.
addSource
(
myConsumer
);
// BlMaiDianKafkaSource blMaiDianKafkaSource = new BlMaiDianKafkaSource();
// DataStreamSource blMaiDianSource = blMaiDianKafkaSource.addSource(env);
@SuppressWarnings
(
"unchecked"
)
SplitStream
<
String
>
blMaiDianDataStream
=
blMaiDianSource
.
split
(
new
BlMaiDianOutputSelector
());
//等价与Time.seconds(30):30秒
DataStream
<
MlPreciseExposureBean
>
mlPreciseExposureStream
=
blMaiDianDataStream
.
select
(
"et_pe"
)
.
map
(
new
BlPreciseExposureMapFunction
())
.
filter
(
new
BlPreciseExposureFilterFunction
())
.
flatMap
(
new
MlpreciseExposureFlatMapFunction
())
.
keyBy
(
new
MlPreciseExposureKeySelector
())
.
timeWindow
(
Time
.
of
(
30
,
TimeUnit
.
SECONDS
))
.
sum
(
"preciseexposure_num"
);
//乱序异步调用关联维度码表
// timeout:请求最长等待时间;capacity:请求最大并发数
DataStream
<
MlPreciseExposureBean
>
mlPreciseExposureJsonDimStream
=
AsyncDataStream
.
unorderedWait
(
mlPreciseExposureStream
,
new
DimRichAsyncFunction
(
dimJdbcUrl
),
1
,
TimeUnit
.
MINUTES
,
1000
)
.
setParallelism
(
1
);
// String outputPath = "/opt/flink/data";
// DayBucketAssigner dayBucketAssigner = new DayBucketAssigner();
// StreamingFileSink<MlPreciseExposureBean> streamingFileSink = StreamingFileSink
// .forRowFormat(new Path(outputPath), new SimpleStringEncoder())
// .withBucketAssigner(dayBucketAssigner)
// .build();
// mlPreciseExposureJsonDimStream.print();
// mlPreciseExposureJsonDimStream.addSink(new PrintSinkFunction<>());
mlPreciseExposureJsonDimStream
.
addSink
(
new
MlPreciseExposureMysqlSink
(
sinkJdbcUrl
,
sinkTableName
)).
name
(
"mlPreciseExposureSink"
);
env
.
execute
(
"ml_c_et_pe_preciseexposure_dimen_d_rt_test"
);
}
/**
* Function: printUsage
* Reason: 打印参数说明
* Date: 2019/12/26 下午2:39
*
* @author liuzhe
* @since JDK 1.8
*/
public
static
void
printUsage
(){
System
.
out
.
println
(
"Missing parameters!\n"
+
"Usage:\n"
+
" --inBrokers <kafka brokers> \n"
+
" --inTopic <kafka topic>\n"
+
" --groupid <kafka groupid, default: flink_preciseexposure_group> \n"
+
" --startFromLatest <start from the latest kafka record, default: false> \n"
+
" --windowSize <window size(second), default: 10 (10s)> \n"
+
" --dimJdbcUrl <dim database url> \n"
+
" --sinkJdbcUrl <target database url> \n"
+
" --sinkTableName <target table> \n"
+
" --parallelism <parallelism, default 1> \n"
);
}
/**
* Function: printUsage
* Reason: 打印参数
* Date: 2019/12/25 下午5:00
*
* @author liuzhe
* @since JDK 1.8
*/
public
static
void
printUsage
(
ParameterTool
args
){
ParameterTool
parameterTool
=
args
;
System
.
out
.
println
(
"Print parameters!\n"
+
"Usage:\n"
+
" --inBrokers "
+
parameterTool
.
getRequired
(
"inBrokers"
)
+
" \n"
+
" --inTopic "
+
parameterTool
.
getRequired
(
"inTopic"
)
+
"\n"
+
" --groupid "
+
parameterTool
.
get
(
"groupId"
,
"flink_preciseexposure_group"
)
+
" \n"
+
" --startFromLatest <start from the latest kafka record, default: false> \n"
+
" --windowSize <window size(second), default: 10 (10s)> \n"
+
" --dimJdbcUrl "
+
parameterTool
.
getRequired
(
"dimJdbcUrl"
)
+
" \n"
+
" --sinkJdbcUrl "
+
parameterTool
.
getRequired
(
"sinkJdbcUrl"
)
+
" \n"
+
" --sinkTableName "
+
parameterTool
.
getRequired
(
"sinkTableName"
)
+
" \n"
+
" --parallelism <parallelism, default 1> \n"
);
}
}
src/main/java/com/gmei/utils/BeanReflectUtil.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
utils
;
import
java.lang.reflect.Field
;
/**
* ClassName: BeanReflectUtil
* Function:
* Reason: 类反射工具类
* Date: 2019/12/5 下午3:54
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
BeanReflectUtil
{
/**
* Function: getFieldValue
* Reason: 通过类反射获取属性值
* Date: 2019/12/25 下午4:41
*
* @author liuzhe
* @since JDK 1.8
*/
public
static
<
T
>
Object
getFieldValue
(
T
obj
,
String
field
)
throws
Exception
{
Class
<?>
claz
=
obj
.
getClass
();
Field
f
=
null
;
Object
fieldValue
=
null
;
Field
[]
fields
=
claz
.
getDeclaredFields
();
for
(
int
i
=
0
;
i
<
fields
.
length
;
i
++)
{
if
(
fields
[
i
].
getName
().
equals
(
field
))
{
f
=
claz
.
getDeclaredField
(
field
);
f
.
setAccessible
(
true
);
fieldValue
=
f
.
get
(
obj
);
}
}
return
fieldValue
;
}
/**
* Function: setFieldValue
* Reason: 通过类反射设置属性值
* Date: 2019/12/25 下午4:41
*
* @author liuzhe
* @since JDK 1.8
*/
public
static
<
T
>
void
setFieldValue
(
T
obj
,
String
field
,
Object
value
)
{
Class
<?>
claz
=
obj
.
getClass
();
Field
f
=
null
;
try
{
Field
[]
fields
=
claz
.
getDeclaredFields
();
for
(
int
i
=
0
;
i
<
fields
.
length
;
i
++)
{
if
(
fields
[
i
].
getName
().
equals
(
field
))
{
f
=
claz
.
getDeclaredField
(
field
);
f
.
setAccessible
(
true
);
f
.
set
(
obj
,
value
);
}
}
}
catch
(
Exception
e
)
{
e
.
getStackTrace
();
}
}
/**
* Function: setNullValue
* Reason: 通过类反射设置所有空字符串为NULL
* Date: 2019/12/25 下午4:42
*
* @author liuzhe
* @since JDK 1.8
*/
public
static
<
T
>
T
setNullValue
(
T
source
)
throws
IllegalArgumentException
,
IllegalAccessException
,
SecurityException
{
Field
[]
fields
=
source
.
getClass
().
getDeclaredFields
();
for
(
Field
field
:
fields
)
{
if
(
field
.
getGenericType
().
toString
().
equals
(
"class java.lang.String"
))
{
field
.
setAccessible
(
true
);
Object
obj
=
field
.
get
(
source
);
if
(
obj
!=
null
&&
obj
.
equals
(
""
))
{
field
.
set
(
source
,
null
);
}
}
}
return
source
;
}
}
src/main/java/com/gmei/utils/DateUtil.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
utils
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* ClassName: DateUtil
* Function:
* Reason: 日期格式工具类
* Date: 2019/12/17 下午4:51
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
DateUtil
{
static
SimpleDateFormat
secDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
static
SimpleDateFormat
dayDate
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
public
enum
DateType
{
DAY
,
SECOND
;
}
/**
* Function: timestampFormat.
* DAY:yyyyMMdd
* SECOND:yyyy-MM-dd HH:mm:ss
* Reason: timestamp时间戳格式化.
* Date: 2019/12/25 下午4:43
*
* @author liuzhe
* @since JDK 1.8
*/
public
static
String
timestampFormat
(
String
timestamp
,
DateType
type
)
{
Double
timestampDouble
=
Double
.
parseDouble
(
timestamp
);
Long
timestampLong
=
new
Double
(
timestampDouble
*
1000
).
longValue
();
Date
date
=
new
Date
(
timestampLong
);
switch
(
type
)
{
case
DAY:
return
dayDate
.
format
(
date
);
case
SECOND:
return
secDate
.
format
(
date
);
default
:
return
null
;
}
}
}
src/main/java/com/gmei/utils/DimTableList.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
utils
;
/**
* ClassName: DimTableList
* Function:
* Reason: 维度码表列表枚举类
* Date: 2019/12/12 上午11:34
*
* @author liuzhe
* @since JDK 1.8
*/
public
enum
DimTableList
{
DIM_CITY
(
"dim_city"
,
"城市码表"
),
DIM_CARD_TYPE
(
"dim_card_type"
,
"卡片类型码表"
),
DIM_CARD_CONTENT_TYPE
(
"dim_card_content_type"
,
"卡片内容类型码表"
),
DIM_PAGE_TYPE
(
"dim_page_type"
,
"页面分类编码"
),
DIM_TRANSACTION_TYPE
(
"dim_transaction_type"
,
"业务类型码表"
),
;
private
String
tableName
;
private
String
tableComment
;
DimTableList
(
String
tableName
,
String
tableComment
)
{
this
.
tableName
=
tableName
;
this
.
tableComment
=
tableComment
;
}
public
String
getTableName
()
{
return
tableName
;
}
public
void
setTableName
(
String
tableName
)
{
this
.
tableName
=
tableName
;
}
public
String
getTableComment
()
{
return
tableComment
;
}
public
void
setTableComment
(
String
tableComment
)
{
this
.
tableComment
=
tableComment
;
}
public
static
DimTableList
getDimTableByName
(
String
tableName
)
{
for
(
DimTableList
dimTable
:
values
())
{
if
(
dimTable
.
getTableName
().
equals
(
tableName
))
{
return
dimTable
;
}
}
return
null
;
}
}
\ No newline at end of file
src/test/java/com/gmei/cache/DimCardContentTypeDaoTest.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.dim.DimCardContentType
;
import
org.junit.Test
;
import
java.util.ArrayList
;
public
class
DimCardContentTypeDaoTest
{
@Test
public
void
findAlldimTableTransFormTest
()
{
DimCardContentTypeDao
dimCardContentTypeDao
=
new
DimCardContentTypeDao
();
ArrayList
<
DimCardContentType
>
dimCardContentTypeList
;
try
{
dimCardContentTypeList
=
dimCardContentTypeDao
.
findAllDimCardContentType
(
"dim_card_content_type"
);
for
(
DimCardContentType
dimCardContentType
:
dimCardContentTypeList
)
System
.
out
.
println
(
dimCardContentType
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
finddimTableTransFormByCodeTest
()
{
DimCardContentTypeDao
dimCardContentTypeDao
=
new
DimCardContentTypeDao
();
DimCardContentType
dimCardContentType
;
try
{
dimCardContentType
=
dimCardContentTypeDao
.
findDimCardContentTypeByCode
(
"dim_card_content_type"
,
"diary"
);
System
.
out
.
println
(
dimCardContentType
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
src/test/java/com/gmei/cache/DimCityDaoTest.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.dim.DimCity
;
import
org.junit.Test
;
import
java.util.ArrayList
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
public
class
DimCityDaoTest
{
@Test
public
void
findAllDimCityTest
()
{
SimpleCacheService
<
String
,
DimCity
>
dimCityCache
=
null
;
DimTableCallable
dimCityCallable
=
new
DimTableCallable
(
"beijing"
,
"dim_city"
,
null
);
ExecutorService
es
=
Executors
.
newFixedThreadPool
(
2
);
Future
future
=
es
.
submit
(
dimCityCallable
);
try
{
ArrayList
<
DimCity
>
dimCityList
=
(
ArrayList
<
DimCity
>)
future
.
get
();
for
(
DimCity
dimCity
:
dimCityList
)
{
System
.
out
.
println
(
dimCity
);
}
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
}
// DimCity dimCity = dimCityCache.getValue("beijing", dimCityCallable);
//
// new DimCityCallable("beijing", "multi");
// ArrayList<DimCity> dimCityList;
// try {
// dimCityList = findAllDimCity("dim_city");
// for (DimCity dimCity : dimCityList)
// } catch (Exception e) {
// e.printStackTrace();
// }
}
@Test
public
void
findDimCityByCodeTest
()
{
SimpleCacheService
<
String
,
DimCity
>
dimCityCache
=
null
;
DimTableCallable
dimCityCallable
=
new
DimTableCallable
(
"beijing"
,
"dim_city"
,
null
);
ExecutorService
es
=
Executors
.
newFixedThreadPool
(
2
);
Future
future
=
es
.
submit
(
dimCityCallable
);
try
{
DimCity
dimCity
=
(
DimCity
)
future
.
get
();
// for (DimCity dimCity : dimCityList) {
System
.
out
.
println
(
dimCity
);
// }
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
}
// ArrayList<DimCity> dimCityList;
// try {
// dimCityList = findDimCityByCode("dim_city", "beijing");
// for (DimCity dimCity : dimCityList) {
// System.out.println(dimCity);
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
}
}
src/test/java/com/gmei/cache/DimPageTypeDaoTest.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.dim.DimPageType
;
import
org.junit.Test
;
import
java.util.ArrayList
;
public
class
DimPageTypeDaoTest
{
@Test
public
void
findAllDimPageTypeTest
()
{
DimPageTypeDao
dimPageTypeDao
=
new
DimPageTypeDao
();
ArrayList
<
DimPageType
>
dimPageTypeList
;
try
{
dimPageTypeList
=
dimPageTypeDao
.
findAllDimPageType
(
"dim_page_type"
);
for
(
DimPageType
dimPageType
:
dimPageTypeList
)
System
.
out
.
println
(
dimPageType
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
findDimPageTypeByCodeTest
()
{
DimPageTypeDao
dimPageTypeDao
=
new
DimPageTypeDao
();
DimPageType
dimPageType
;
// ArrayList<DimPageType> dimPageTypeList;
try
{
dimPageType
=
dimPageTypeDao
.
findDimPageTypeByCode
(
"dim_page_type"
,
"home"
);
// for (DimPageType dimPageType : dimPageTypeList)
System
.
out
.
println
(
dimPageType
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
src/test/java/com/gmei/cache/DimTableDaoTest.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
cache
;
import
com.gmei.bean.dim.DimCity
;
import
com.gmei.bean.dim.DimPageType
;
import
com.gmei.bean.dim.DimTable
;
import
com.gmei.utils.DimTableList
;
import
org.junit.Test
;
import
java.util.ArrayList
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
public
class
DimTableDaoTest
{
@Test
public
void
findAllDimTableTest
()
{
// DimTableDao dimTableDao = new DimTableDao();
// ArrayList<DimTable> dimTableList;
// try {
// dimTableList = dimTableDao.findAllDimTable("dim_city");
// for (DimTable dimTable : dimTableList)
// System.out.println(dimTable);
// } catch (Exception e) {
// e.printStackTrace();
// }
SimpleCacheService
<
String
,
DimCity
>
dimCityCache
=
null
;
DimTableCallable
dimTableCallable
=
new
DimTableCallable
(
null
,
DimTableList
.
DIM_CITY
.
getTableName
(),
null
);
ExecutorService
es
=
Executors
.
newFixedThreadPool
(
2
);
Future
future
=
es
.
submit
(
dimTableCallable
);
try
{
ArrayList
<
DimCity
>
dimCityList
=
(
ArrayList
<
DimCity
>)
future
.
get
();
for
(
DimCity
dimCity
:
dimCityList
)
{
System
.
out
.
println
(
dimCity
);
}
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
findDimTableByCodeTest
()
{
// DimTableDao dimTableDao = new DimTableDao();
// DimTable dimTable;
// try {
// dimTable = dimTableDao.findDimTableByCode("dim_city", "beijing");
// System.out.println(dimTable);
// } catch (Exception e) {
// e.printStackTrace();
// }
SimpleCacheService
<
String
,
DimCity
>
dimCityCache
=
null
;
DimTableCallable
dimCityCallable
=
new
DimTableCallable
(
"beijing"
,
DimTableList
.
DIM_CITY
.
getTableName
(),
null
);
DimTableCallable
dimPageTypeCallable
=
new
DimTableCallable
(
"home"
,
DimTableList
.
DIM_PAGE_TYPE
.
getTableName
(),
null
);
DimTableCallable
dimCardContentTypeCallable
=
new
DimTableCallable
(
"diary"
,
DimTableList
.
DIM_CARD_CONTENT_TYPE
.
getTableName
(),
null
);
ExecutorService
es
=
Executors
.
newFixedThreadPool
(
3
);
Future
future1
=
es
.
submit
(
dimCityCallable
);
Future
future2
=
es
.
submit
(
dimPageTypeCallable
);
Future
future3
=
es
.
submit
(
dimCardContentTypeCallable
);
System
.
out
.
println
(
"start"
);
try
{
DimCity
dimCity
=
(
DimCity
)
future1
.
get
();
DimPageType
dimPageType
=
(
DimPageType
)
future2
.
get
();
DimTable
dimCardContentType
=
(
DimTable
)
future3
.
get
();
System
.
out
.
println
(
dimCity
);
System
.
out
.
println
(
dimPageType
);
System
.
out
.
println
(
dimCardContentType
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
findCacheTest
()
{
SimpleCacheService
<
String
,
DimCity
>
dimCityCache
=
new
SimpleCacheService
<>(
2000
,
24
);
DimTableCallable
dimCityCallable
=
new
DimTableCallable
(
"beijing"
,
DimTableList
.
DIM_CITY
.
getTableName
(),
null
);
ExecutorService
es
=
Executors
.
newFixedThreadPool
(
2
);
Future
future1
=
es
.
submit
(
dimCityCallable
);
DimCity
dimCity
=
null
;
try
{
dimCity
=
(
DimCity
)
future1
.
get
();
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
catch
(
ExecutionException
e
)
{
e
.
printStackTrace
();
}
// dimCityCache.putValue("beijing",dimCity);
DimCity
dimCityCacheValue
=
null
;
try
{
dimCityCacheValue
=
dimCityCache
.
getValue
(
"beijing"
,
new
DimTableCallable
<
DimCity
>(
"beijing"
,
DimTableList
.
DIM_CITY
.
getTableName
(),
null
));
}
catch
(
Exception
e
)
{
dimCityCacheValue
=
null
;
e
.
printStackTrace
();
}
System
.
out
.
println
(
dimCityCacheValue
);
// ExecutorService es = Executors.newFixedThreadPool(2);
// Future future = es.submit(dimTableCallable);
// System.out.println("start");
// try {
// DimCity dimCity = (DimCity)future.get();
// System.out.println(dimCity);
// } catch (InterruptedException e) {
// e.printStackTrace();
// } catch (ExecutionException e) {
// e.printStackTrace();
// }
}
}
src/test/java/com/gmei/etl/BlMaiDianSplitEtl.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
etl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gmei.bean.bl.BlPreciseExposureBean
;
import
com.gmei.bean.bl.BlPreciseExposureParamsExposureCardsBean
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationFeature
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
/**
* ClassName: BlMaiDianSplitEtl
* Function: TODO ADD FUNCTION.
* Reason: TODO ADD REASON.
* Date: 2019/12/4 下午4:58
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
BlMaiDianSplitEtl
implements
Serializable
{
/**
* Function: split流
* Reason: TODO ADD REASON.
* Date: 2019/12/7 下午7:56
*
* @author liuzhe
* @since JDK 1.8
*/
public
String
mapBlPreciseExposureBean
(
String
string
)
throws
Exception
{
return
null
;
}
}
src/test/java/com/gmei/etl/BlPreciseExposureEtl.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
etl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.gmei.bean.bl.BlPreciseExposureBean
;
import
com.gmei.bean.bl.BlPreciseExposureParamsExposureCardsBean
;
import
com.gmei.utils.BeanReflectUtil
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationFeature
;
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
;
import
org.junit.Test
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
/**
* ClassName: BlPreciseExposureEtl
* Function: TODO ADD FUNCTION.
* Reason: TODO ADD REASON.
* Date: 2019/12/4 下午4:58
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
BlPreciseExposureEtl
implements
Serializable
{
/**
* Function: 废弃.
* Reason: TODO ADD REASON.
* Date: 2019/12/7 下午7:54
*
* @author liuzhe
* @since JDK 1.8
*/
public
BlPreciseExposureBean
getBlPreciseExposureBeanJackJson
(
String
string
)
throws
IOException
{
ObjectMapper
mapper
=
new
ObjectMapper
();
// System.out.println(string);
// JsonNode jsonNode = mapper.readTree(string);
// JsonNode jsonNode = mapper.readTree(string);
// String data = jsonNode.findValue("@raw").asText();
mapper
.
configure
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
,
false
);
BlPreciseExposureBean
blPreciseExposureBean
=
mapper
.
readValue
(
string
,
BlPreciseExposureBean
.
class
);
// mapper.readValue()
// System.out.println(blPreciseExposureBean.toString());
return
blPreciseExposureBean
;
}
/**
* Function: mapBlPreciseExposureBean
* Reason: map一对一
* Date: 2019/12/7 下午7:56
*
* @author liuzhe
* @since JDK 1.8
*/
public
BlPreciseExposureBean
mapBlPreciseExposureBean
(
String
string
)
throws
Exception
{
BlPreciseExposureBean
blPreciseExposureBean
=
new
BlPreciseExposureBean
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
string
);
//一级别JSON
JSONObject
app
=
jsonObject
.
getJSONObject
(
"app"
);
String
gm_nginx_timestamp
=
String
.
valueOf
(
jsonObject
.
get
(
"gm_nginx_timestamp"
));
String
create_timestamp
=
String
.
valueOf
(
jsonObject
.
get
(
"create_at"
));
String
user_id
=
jsonObject
.
getString
(
"user_id"
);
String
action
=
jsonObject
.
getString
(
"type"
);
//二级别JSON
//APP
String
app_grey_type
=
app
.
getString
(
"grey_type"
);
String
app_channel
=
app
.
getString
(
"channel"
);
String
app_version
=
app
.
getString
(
"version"
);
String
app_current_city_id
=
app
.
getString
(
"current_city_id"
);
String
app_code
=
app
.
getString
(
"name"
);
//1.2 absolute_position参数类型不完整
//问题描述:在'7.7.35', '7.7.36', '7.7.40'params的absolute_position缺少左边引号
String
paramsString
=
String
.
valueOf
(
jsonObject
.
get
(
"params"
));
if
(
"7.7.35"
.
equals
(
app_version
)
||
"7.7.36"
.
equals
(
app_version
)
||
"7.7.40"
.
equals
(
app_version
))
{
paramsString
=
paramsString
.
replace
(
"absolute_position"
,
"\\\"absolute_position"
);
}
//PARAMS
JSONObject
params
=
JSON
.
parseObject
(
paramsString
);
Integer
down_loading_times
=
params
.
getInteger
(
"down_loading_times"
);
Integer
down_slide_times
=
params
.
getInteger
(
"down_slide_times"
);
Integer
up_loading_times
=
params
.
getInteger
(
"up_loading_times"
);
Integer
up_slide_times
=
params
.
getInteger
(
"up_slide_times"
);
String
page_code
=
params
.
getString
(
"page_name"
);
String
tab_name
=
params
.
getString
(
"tab_name"
);
String
business_id
=
params
.
getString
(
"business_id"
);
String
referrer_code
=
params
.
getString
(
"referrer"
);
String
referrer_id
=
params
.
getString
(
"referrer_id"
);
//1.4 初版精准曝光格式错误
//问题描述:在'7.7.60'版本中美购页卡片的card_id和transaction_type这两个参数是数组的形式
// ArrayList<BlPreciseExposureParamsExposureCardsBean> exposure_cards =(ArrayList<BlPreciseExposureParamsExposureCardsBean>)JSONArray.parseArray(params.getJSONArray("exposure_cards").toString(), BlPreciseExposureParamsExposureCardsBean.class);
ArrayList
<
BlPreciseExposureParamsExposureCardsBean
>
exposure_cards
=
new
ArrayList
<>();
JSONArray
jsonArray
=
JSONArray
.
parseArray
(
params
.
getJSONArray
(
"exposure_cards"
).
toString
());
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
JSONObject
jsonCard
=
jsonArray
.
getJSONObject
(
i
);
String
card_id
=
jsonCard
.
getString
(
"card_id"
);
String
transaction_type
=
jsonCard
.
getString
(
"transaction_type"
);
String
card_content_type
=
jsonCard
.
getString
(
"card_content_type"
);
if
(
"service"
.
equals
(
card_content_type
)
&&
"7.7.60"
.
equals
(
app_version
))
{
JSONArray
card_id_list
=
JSONArray
.
parseArray
(
card_id
);
JSONArray
transaction_type_list
=
JSONArray
.
parseArray
(
transaction_type
);
for
(
int
j
=
0
;
j
<
card_id_list
.
size
();
j
++)
{
BlPreciseExposureParamsExposureCardsBean
cardsBean
=
new
BlPreciseExposureParamsExposureCardsBean
();
cardsBean
.
setCard_id
(
card_id_list
.
getString
(
j
));
cardsBean
.
setTransaction_type
(
transaction_type_list
.
getString
(
j
));
cardsBean
.
setCard_content_type
(
card_content_type
);
cardsBean
.
setCard_type
(
jsonCard
.
getString
(
"card_type"
));
cardsBean
.
setIs_cpc
(
jsonCard
.
getString
(
"is_cpc"
));
cardsBean
.
setCpc_referer
(
jsonCard
.
getString
(
"cpc_referer"
));
cardsBean
.
setAbsolute_position
(
jsonCard
.
getString
(
"absolute_position"
));
cardsBean
.
setRelative_position
(
jsonCard
.
getString
(
"relative_position"
));
exposure_cards
.
add
(
cardsBean
);
}
}
else
{
BlPreciseExposureParamsExposureCardsBean
cardsBean
=
JSON
.
toJavaObject
(
jsonCard
,
BlPreciseExposureParamsExposureCardsBean
.
class
);
exposure_cards
.
add
(
cardsBean
);
}
}
String
is_exposure
=
params
.
getString
(
"is_exposure"
);
String
filter
=
params
.
getString
(
"filter"
);
String
query
=
params
.
getString
(
"query"
);
//DEVICE
JSONObject
device
=
jsonObject
.
getJSONObject
(
"device"
);
String
device_os_type
=
device
.
getString
(
"device_type"
);
String
device_model
=
device
.
getString
(
"model"
);
String
device_id
=
device
.
getString
(
"device_id"
);
String
device_idfv
=
device
.
getString
(
"idfv"
);
String
device_android_id
=
device
.
getString
(
"android_device_id"
);
//1.1 ios系统精准曝光埋点channel字段
//问题描述:ios系统精准曝光埋点channel字段AppStore应该修改为App Store
if
(
"AppStore"
.
equals
(
app_channel
))
{
app_channel
=
"App Store"
;
}
//日志时间处理
SimpleDateFormat
secDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
dayDate
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
Double
gm_nginx_timestampDouble
=
Double
.
parseDouble
(
gm_nginx_timestamp
);
Long
gm_nginx_timestampLong
=
new
Double
(
gm_nginx_timestampDouble
*
1000
).
longValue
();
Date
gmDate
=
new
Date
(
gm_nginx_timestampLong
);
Date
createDate
=
new
Date
(
Long
.
parseLong
(
create_timestamp
)
*
1000
);
String
gm_nginx_time_date
=
secDate
.
format
(
gmDate
);
String
gm_nginx_time_day
=
dayDate
.
format
(
gmDate
);
String
create_time_date
=
secDate
.
format
(
createDate
);
String
create_time_day
=
dayDate
.
format
(
createDate
);
//1.7 result_status参数位置问题(未处理)
//问题描述:搜索结果百科(search_result_wiki)和搜索结果美购(search_result_welfare)的result_status埋点埋在exposure_data里面了为了都获得该参数值,因此需要从两处拿取,默认先取exposure_data里的result_satus字段值(数据中发现不只是这两个页面)search_result_diary、search_result_doctor、search_result_hospital也存在
//1.9 搜索结果页tab_name参数不该存在
//问题描述:在搜索结果页出现tab_name参数,参数值和page_name一样,在点击的时候页面有跳转,因此,不应该有tab_name参数
if
(
page_code
.
contains
(
"search_result"
))
{
tab_name
=
null
;
}
blPreciseExposureBean
.
setGm_nginx_timestamp
(
gm_nginx_timestamp
);
blPreciseExposureBean
.
setCreate_timestamp
(
create_timestamp
);
blPreciseExposureBean
.
setUser_id
(
user_id
);
blPreciseExposureBean
.
setAction
(
action
);
blPreciseExposureBean
.
setApp_grey_type
(
app_grey_type
);
blPreciseExposureBean
.
setApp_channel
(
app_channel
);
blPreciseExposureBean
.
setApp_version
(
app_version
);
blPreciseExposureBean
.
setApp_current_city_id
(
app_current_city_id
);
blPreciseExposureBean
.
setApp_code
(
app_code
);
blPreciseExposureBean
.
setDown_loading_times
(
down_loading_times
);
blPreciseExposureBean
.
setDown_slide_times
(
down_slide_times
);
blPreciseExposureBean
.
setUp_loading_times
(
up_loading_times
);
blPreciseExposureBean
.
setUp_slide_times
(
up_slide_times
);
blPreciseExposureBean
.
setPage_code
(
page_code
);
blPreciseExposureBean
.
setTab_name
(
tab_name
);
blPreciseExposureBean
.
setBusiness_id
(
business_id
);
blPreciseExposureBean
.
setReferrer_code
(
referrer_code
);
blPreciseExposureBean
.
setReferrer_id
(
referrer_id
);
blPreciseExposureBean
.
setExposure_cards
(
exposure_cards
);
blPreciseExposureBean
.
setIs_exposure
(
is_exposure
);
blPreciseExposureBean
.
setFilter
(
filter
);
blPreciseExposureBean
.
setQuery
(
query
);
blPreciseExposureBean
.
setDevice_os_type
(
device_os_type
);
blPreciseExposureBean
.
setDevice_model
(
device_model
);
blPreciseExposureBean
.
setDevice_id
(
device_id
==
null
||
device_id
==
""
?
device_id
:
device_idfv
);
blPreciseExposureBean
.
setDevice_android_id
(
device_android_id
);
blPreciseExposureBean
.
setDevice_idfv
(
device_idfv
);
blPreciseExposureBean
.
setGm_nginx_time_date
(
gm_nginx_time_date
);
blPreciseExposureBean
.
setGm_nginx_time_day
(
gm_nginx_time_day
);
blPreciseExposureBean
.
setCreate_time_date
(
create_time_date
);
blPreciseExposureBean
.
setCreate_time_day
(
create_time_day
);
return
BeanReflectUtil
.
setNullValue
(
blPreciseExposureBean
);
}
/**
* Function: filterBlPreciseExposureBean
* Reason: 筛选数据
* Date: 2019/12/7 下午7:57
*
* @author liuzhe
* @since JDK 1.8
*/
public
Boolean
filterBlPreciseExposureBean
(
BlPreciseExposureBean
blPreciseExposureBean
)
throws
Exception
{
String
app_code
=
blPreciseExposureBean
.
getApp_code
();
String
is_exposure
=
blPreciseExposureBean
.
getIs_exposure
();
String
app_version
=
blPreciseExposureBean
.
getApp_version
();
String
page_code
=
blPreciseExposureBean
.
getPage_code
();
//清洗掉app_code不等于gengmei_user与is_exposure不等于1的
//1.5 Home页精准曝光触发两次
//问题描述:在7.7.70','7.7.71','7.7.72','7.7.75','7.7.76','7.8.0','7.8.1' (7.7.70--7.9.0)版本中的首页精准曝光会触发两次,经确认,需要去除page_name='home'
//1.6 品类聚合页的精准曝光问题
//问题描述:品类聚合页的精准曝光没做,但是数据中却有精准曝光、而且有问题,因此过滤掉,目前还不能确定什么版本可以解决,先暂时根据page_name过滤掉page_name='category'
List
<
String
>
app_version_list
=
Arrays
.
asList
(
"7.7.70"
,
"7.7.71"
,
"7.7.72"
,
"7.7.75"
,
"7.7.76"
,
"7.8.0"
,
"7.8.1"
);
String
[]
version
=
app_version
.
split
(
"."
);
if
(!
"gengmei_user"
.
equals
(
app_code
)
||
!
"1"
.
equals
(
is_exposure
))
{
return
false
;
}
else
if
(
app_version_list
.
contains
(
app_version
)
&&
"home"
.
equals
(
page_code
))
{
return
false
;
}
else
if
(
"category"
.
equals
(
page_code
)
&&
"7"
.
equals
(
version
[
0
])
&&
Integer
.
parseInt
(
version
[
1
])
<
14
)
{
return
false
;
}
return
true
;
}
@Test
public
void
getBlPreciseExposureBeanTest
()
{
BlPreciseExposureEtl
blPreciseExposureEtl
=
new
BlPreciseExposureEtl
();
// String json = "{\"create_at\":\"1575134961\",\"gm_nginx_timestamp\":1575134961.718,\"user_id\":\"31665831\",\"version\":\"110\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":0,\"is_popup\":\"0\",\"exposure_cards\":[{\"absolute_position\":\"0\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"0\",\"card_id\":2},{\"absolute_position\":\"1\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"1\",\"card_id\":2},{\"absolute_position\":\"2\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"2\",\"card_id\":2},{\"absolute_position\":\"3\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"3\",\"card_id\":2},{\"absolute_position\":\"4\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"4\",\"card_id\":2}],\"tab_name\":\"\",\"down_slide_times\":0,\"page_name\":\"home\",\"up_loading_times\":0,\"is_exposure\":\"1\",\"referrer\":\"\",\"business_id\":\"\",\"referrer_id\":\"\"},\"app_session_id\":\"FE675C8B-4FD4-4FC6-9EC7-415F715A750B\",\"app\":{\"version\":\"7.18.2\",\"grey_type\":\"{\\\"report_result\\\":0,\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"post_detail\\\":\\\"0\\\",\\\"video_steep\\\":1,\\\"face_scan\\\":0}\",\"current_city_id\":\"nanjing\",\"name\":\"gengmei_user\",\"user_type\":{\"config_type\":1},\"serial_id\":12,\"channel\":\"AppStore\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"5F193A07-781F-4EF1-86B4-452251307081\",\"sys_version\":\"13.2.3\",\"lng\":118.93133562169,\"is_WiFi\":\"0\",\"manufacturer\":\"Apple\",\"device_id\":\"F88745FE-DF54-4639-B7E2-28554C7DFAAF\",\"device_type\":\"ios\",\"ip\":\"10.190.42.125\",\"idfa\":\"F88745FE-DF54-4639-B7E2-28554C7DFAAF\",\"lat\":32.121287439102,\"model\":\"iPhone8,2\"},\"type\":\"page_precise_exposure\"}";
// String json = "{\"gm_nginx_key\":1,\"version\":\"205\",\"params\":{\"up_slide_times\":\"2\",\"down_loading_times\":\"0\",\"exposure_cards\":\"[{\\\"card_id\\\":\\\"16449302\\\",\\\"card_source_type\\\":\\\"doris\\\",\\\"card_content_type\\\":\\\"diary\\\",\\\"card_type\\\":\\\"card\\\",absolute_position\\\":\\\"0\\\",\\\"relative_position\\\":\\\"0\\\"}]\",\"up_loading_times\":\"0\",\"is_exposure\":\"1\",\"tab_name\":\"精选\",\"page_name\":\"home\",\"business_id\":\"\",\"referrer\":\"\",\"referrer_id\":\"\",\"down_slide_times\":\"1\"},\"app_session_id\":\"f3d24a27-27f0-4545-b132-51030765cf49\",\"gm_nginx_timestamp\":1546307958.444,\"create_at\":\"1546307958\",\"type\":\"home_choiceness_card_exposure\",\"device\":{\"is_WiFi\":\"1\",\"ip\":\"192.168.1.100\",\"manufacturer\":\"vivo\",\"device_type\":\"android\",\"lat\":\"0.0\",\"device_id\":\"863208034156179\",\"lng\":\"0.0\"},\"app\":{\"channel\":\"vivo\",\"user_type\":{\"config_type\":\"1\"},\"serial_id\":6,\"current_city_id\":\"worldwide\",\"name\":\"gengmei_user\",\"version\":\"7.7.36\"},\"user_id\":\"\"}";
String
json
=
"{\"create_at\":\"1576128422\",\"gm_nginx_timestamp\":1576128422.463,\"user_id\":\"31038796\",\"version\":\"110\",\"params\":{\"down_loading_times\":1,\"up_slide_times\":5,\"exposure_cards\":[{\"absolute_position\":0,\"result_status\":\"1\",\"card_content_type\":\"service\",\"transaction_type\":\"[\\\"-1\\\",\\\"-1\\\",\\\"-1\\\"]\",\"card_type\":\"card\",\"card_source_type\":\"[\\\"\\\",\\\"\\\",\\\"\\\"]\",\"relative_position\":0,\"card_id\":\"[\\\"5821997\\\",\\\"5762189\\\",\\\"5671097\\\"]\"},{\"absolute_position\":1,\"card_content_type\":\"wiki_collect\",\"card_type\":\"card\",\"relative_position\":1,\"wiki_word\":{},\"card_id\":\"127\"},{\"absolute_position\":2,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":3,\"card_id\":\"15337295\"},{\"absolute_position\":3,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":4,\"card_id\":\"15635897\"},{\"absolute_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":5,\"card_id\":\"16082820\"},{\"absolute_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":5,\"card_id\":\"16082820\"},{\"absolute_position\":5,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":4,\"card_id\":\"699299\"},{\"absolute_position\":6,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"article\",\"relative_position\":5,\"card_id\":\"19589790\"},{\"absolute_position\":7,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":6,\"card_id\":\"15764401\"},{\"absolute_position\":8,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":4,\"card_id\":\"15633799\"},{\"absolute_position\":9,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":5,\"card_id\":\"16622540\"},{\"absolute_position\":10,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":6,\"card_id\":\"699573\"},{\"absolute_position\":11,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":4,\"card_id\":\"686812\"},{\"absolute_position\":12,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":5,\"card_id\":\"15328675\"},{\"absolute_position\":13,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":6,\"card_id\":\"11201557\"},{\"absolute_position\":14,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":4,\"card_id\":\"700888\"},{\"absolute_position\":15,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":5,\"card_id\":\"706569\"}],\"tab_name\":\"综合\",\"down_slide_times\":8,\"query\":\"玻尿酸\",\"up_loading_times\":0,\"is_exposure\":1,\"referrer\":\"search_home\",\"business_id\":\"\",\"page_name\":\"search_result_more\",\"referrer_id\":\"\"},\"app_session_id\":\"559D8BA2-7FC1-402C-BB12-F860EFA26925\",\"app\":{\"user_type\":{\"config_type\":1},\"current_city_id\":\"chengdu\",\"version\":\"7.7.60\",\"name\":\"gengmei_user\",\"serial_id\":14,\"channel\":\"AppStore\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"CD8D7E3B-B833-49EE-B509-6B9F1B3963B9\",\"lng\":104.07933463616,\"is_WiFi\":\"0\",\"manufacturer\":\"Apple\",\"ip\":\"10.187.49.153\",\"device_id\":\"4A0275C1-4734-404A-93DD-BAA272401A27\",\"device_type\":\"ios\",\"lat\":30.654052050073,\"idfa\":\"4A0275C1-4734-404A-93DD-BAA272401A27\"},\"type\":\"page_precise_exposure\"}"
;
BlPreciseExposureBean
blPreciseExposureBean
=
null
;
try
{
blPreciseExposureBean
=
blPreciseExposureEtl
.
mapBlPreciseExposureBean
(
json
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
blPreciseExposureBean
.
toString
());
}
@Test
public
void
filterBlPreciseExposureBeanTest
()
{
BlPreciseExposureEtl
blPreciseExposureEtl
=
new
BlPreciseExposureEtl
();
// String json = "{\"create_at\":\"1575134961\",\"gm_nginx_timestamp\":1575134961.718,\"user_id\":\"31665831\",\"version\":\"110\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":0,\"is_popup\":\"0\",\"exposure_cards\":[{\"absolute_position\":\"0\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"0\",\"card_id\":2},{\"absolute_position\":\"1\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"1\",\"card_id\":2},{\"absolute_position\":\"2\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"2\",\"card_id\":2},{\"absolute_position\":\"3\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"3\",\"card_id\":2},{\"absolute_position\":\"4\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"4\",\"card_id\":2}],\"tab_name\":\"\",\"down_slide_times\":0,\"page_name\":\"home\",\"up_loading_times\":0,\"is_exposure\":\"1\",\"referrer\":\"\",\"business_id\":\"\",\"referrer_id\":\"\"},\"app_session_id\":\"FE675C8B-4FD4-4FC6-9EC7-415F715A750B\",\"app\":{\"version\":\"7.18.2\",\"grey_type\":\"{\\\"report_result\\\":0,\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"post_detail\\\":\\\"0\\\",\\\"video_steep\\\":1,\\\"face_scan\\\":0}\",\"current_city_id\":\"nanjing\",\"name\":\"gengmei_user\",\"user_type\":{\"config_type\":1},\"serial_id\":12,\"channel\":\"AppStore\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"5F193A07-781F-4EF1-86B4-452251307081\",\"sys_version\":\"13.2.3\",\"lng\":118.93133562169,\"is_WiFi\":\"0\",\"manufacturer\":\"Apple\",\"device_id\":\"F88745FE-DF54-4639-B7E2-28554C7DFAAF\",\"device_type\":\"ios\",\"ip\":\"10.190.42.125\",\"idfa\":\"F88745FE-DF54-4639-B7E2-28554C7DFAAF\",\"lat\":32.121287439102,\"model\":\"iPhone8,2\"},\"type\":\"page_precise_exposure\"}";
String
json
=
"{\"gm_nginx_key\":1,\"version\":\"205\",\"params\":{\"up_slide_times\":\"2\",\"down_loading_times\":\"0\",\"exposure_cards\":\"[{\\\"card_id\\\":\\\"16449302\\\",\\\"card_source_type\\\":\\\"doris\\\",\\\"card_content_type\\\":\\\"diary\\\",\\\"card_type\\\":\\\"card\\\",absolute_position\\\":\\\"0\\\",\\\"relative_position\\\":\\\"0\\\"}]\",\"up_loading_times\":\"0\",\"is_exposure\":\"1\",\"tab_name\":\"精选\",\"page_name\":\"home\",\"business_id\":\"\",\"referrer\":\"\",\"referrer_id\":\"\",\"down_slide_times\":\"1\"},\"app_session_id\":\"f3d24a27-27f0-4545-b132-51030765cf49\",\"gm_nginx_timestamp\":1546307958.444,\"create_at\":\"1546307958\",\"type\":\"home_choiceness_card_exposure\",\"device\":{\"is_WiFi\":\"1\",\"ip\":\"192.168.1.100\",\"manufacturer\":\"vivo\",\"device_type\":\"android\",\"lat\":\"0.0\",\"device_id\":\"863208034156179\",\"lng\":\"0.0\"},\"app\":{\"channel\":\"vivo\",\"user_type\":{\"config_type\":\"1\"},\"serial_id\":6,\"current_city_id\":\"worldwide\",\"name\":\"gengmei_user\",\"version\":\"7.7.36\"},\"user_id\":\"\"}"
;
BlPreciseExposureBean
blPreciseExposureBean
=
null
;
Boolean
flag
=
null
;
try
{
blPreciseExposureBean
=
blPreciseExposureEtl
.
mapBlPreciseExposureBean
(
json
);
flag
=
blPreciseExposureEtl
.
filterBlPreciseExposureBean
(
blPreciseExposureBean
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
blPreciseExposureBean
.
getIs_exposure
());
System
.
out
.
println
(
flag
);
}
}
src/test/java/com/gmei/etl/MlPreciseExposureEtl.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
etl
;
import
com.gmei.bean.bl.BlPreciseExposureBean
;
import
com.gmei.bean.bl.BlPreciseExposureParamsExposureCardsBean
;
import
com.gmei.bean.dim.DimCity
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
com.gmei.cache.SimpleCacheService
;
import
com.gmei.jdbc.MysqlJdbcDim
;
import
com.gmei.utils.BeanReflectUtil
;
import
org.junit.Test
;
import
java.io.Serializable
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* ClassName: BlPreciseExposureEtl
* Function: TODO ADD FUNCTION.
* Reason: TODO ADD REASON.
* Date: 2019/12/4 下午4:58
*
* @author liuzhe
* @since JDK 1.8
*/
public
class
MlPreciseExposureEtl
implements
Serializable
{
/**
* Function: flatmapMlPreciseExposureBean
* Reason: 数据一对多
* Date: 2019/12/7 下午7:57
*
* @author liuzhe
* @since JDK 1.8
*/
public
ArrayList
<
MlPreciseExposureBean
>
flatmapMlPreciseExposureBean
(
BlPreciseExposureBean
blPreciseExposureBean
)
throws
Exception
{
ArrayList
<
BlPreciseExposureParamsExposureCardsBean
>
exposure_cards
=
blPreciseExposureBean
.
getExposure_cards
();
String
app_version
=
blPreciseExposureBean
.
getApp_version
();
String
device_os_type
=
blPreciseExposureBean
.
getDevice_os_type
();
ArrayList
<
MlPreciseExposureBean
>
mlPreciseExposureBeanList
=
new
ArrayList
<>();
for
(
BlPreciseExposureParamsExposureCardsBean
exposureCardsBean:
exposure_cards
)
{
String
card_id
=
exposureCardsBean
.
getCard_id
();
String
card_content_type
=
exposureCardsBean
.
getCard_content_type
();
String
card_type
=
exposureCardsBean
.
getCard_type
();
String
is_cpc
=
exposureCardsBean
.
getIs_cpc
();
String
cpc_referer
=
exposureCardsBean
.
getCpc_referer
();
String
absolute_position
=
exposureCardsBean
.
getAbsolute_position
();
String
relative_position
=
exposureCardsBean
.
getRelative_position
();
String
transaction_type
=
exposureCardsBean
.
getTransaction_type
();
//1.3 绝对位置和相对位置位置错误
//问题描述:在'7.7.35','7.7.36' android的绝对位置和相对位置写反
if
(
"android"
.
equals
(
device_os_type
)
&&
(
"7.7.35"
.
equals
(
app_version
)
||
"7.7.36"
.
equals
(
app_version
)))
{
String
change
=
absolute_position
;
absolute_position
=
relative_position
;
relative_position
=
change
;
}
//1.10 banner、豆腐块、icon、搜索词和功能区入口的card_type参数问题
//问题描述:当卡片类型为豆腐块、icon、banner、搜索词和功能区入口的时候的时候正确的card_type的参数值被赋给了card_content_type(banner、icon、gadget、search_query、function_entrance)
List
<
String
>
card_content_type_list
=
Arrays
.
asList
(
"banner"
,
"icon"
,
"gadget"
,
"search_query"
,
"function_entrance"
);
if
(
card_content_type_list
.
contains
(
card_content_type
))
{
card_type
=
card_content_type
;
card_content_type
=
null
;
}
if
(
"search_query"
.
equals
(
card_content_type
))
{
card_type
=
"search_word"
;
}
//1.12 card_content_type的qa值应该被换成q_a
card_content_type
=
card_content_type
.
replace
(
"qa"
,
"q_a"
);
//1.13 target_name与card_name的参数的统一
//问题描述:将target_name参数的值赋给card_name
//1.14 百科卡片曝光新增参数wiki_type
//问题:从7.19.0版本开始,百科卡片曝光,新增了wiki_type参数
MlPreciseExposureBean
mlPreciseExposureBean
=
new
MlPreciseExposureBean
();
mlPreciseExposureBean
.
setUser_id
(
blPreciseExposureBean
.
getUser_id
());
mlPreciseExposureBean
.
setAction
(
blPreciseExposureBean
.
getAction
());
mlPreciseExposureBean
.
setPage_code
(
blPreciseExposureBean
.
getPage_code
());
mlPreciseExposureBean
.
setTab_name
(
blPreciseExposureBean
.
getTab_name
());
mlPreciseExposureBean
.
setBusiness_id
(
blPreciseExposureBean
.
getBusiness_id
());
mlPreciseExposureBean
.
setReferrer_code
(
blPreciseExposureBean
.
getReferrer_code
());
mlPreciseExposureBean
.
setReferrer_id
(
blPreciseExposureBean
.
getReferrer_id
());
mlPreciseExposureBean
.
setCard_id
(
card_id
);
mlPreciseExposureBean
.
setCard_content_type
(
card_content_type
);
mlPreciseExposureBean
.
setCard_type
(
card_type
);
mlPreciseExposureBean
.
setIs_cpc
(
is_cpc
);
mlPreciseExposureBean
.
setCpc_referer
(
cpc_referer
);
// mlPreciseExposureBean.setAbsolute_position(absolute_position);
// mlPreciseExposureBean.setRelative_position(relative_position);
mlPreciseExposureBean
.
setTransaction_type
(
transaction_type
);
// mlPreciseExposureBean.setApp_channel(blPreciseExposureBean.getApp_channel());
mlPreciseExposureBean
.
setApp_version
(
blPreciseExposureBean
.
getApp_version
());
mlPreciseExposureBean
.
setCurrent_city_id
(
blPreciseExposureBean
.
getApp_current_city_id
());
mlPreciseExposureBean
.
setApp_code
(
blPreciseExposureBean
.
getApp_code
());
mlPreciseExposureBean
.
setDevice_os_type
(
blPreciseExposureBean
.
getDevice_os_type
());
mlPreciseExposureBean
.
setDevice_id
(
blPreciseExposureBean
.
getDevice_id
());
mlPreciseExposureBean
.
setCreate_time_day
(
blPreciseExposureBean
.
getCreate_time_day
());
mlPreciseExposureBean
.
setPreciseexposure_num
(
1
);
//1.11 transaction_type的空值需要被修正
//问题描述:transaction_type='' 需要替换为NULL
mlPreciseExposureBeanList
.
add
(
BeanReflectUtil
.
setNullValue
(
mlPreciseExposureBean
));
}
return
mlPreciseExposureBeanList
;
}
/**
* Function: groupByFields
* Reason: groupBy字段
* Date: 2019/12/7 下午7:57
*
* @author liuzhe
* @since JDK 1.8
*/
public
Object
groupByFields
(
MlPreciseExposureBean
mlPreciseExposureBean
)
{
ArrayList
groupByFields
=
new
ArrayList
();
groupByFields
.
add
(
mlPreciseExposureBean
.
getUser_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getAction
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getApp_code
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getTab_name
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getBusiness_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getReferrer_code
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getReferrer_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCard_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCard_content_type
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCard_type
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getIs_cpc
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCpc_referer
());
// groupByFields.add(mlPreciseExposureBean.getAbsolute_position());
// groupByFields.add(mlPreciseExposureBean.getRelative_position());
groupByFields
.
add
(
mlPreciseExposureBean
.
getTransaction_type
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getFilter
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getQuery
());
// groupByFields.add(mlPreciseExposureBean.getApp_channel());
groupByFields
.
add
(
mlPreciseExposureBean
.
getApp_version
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCurrent_city_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getApp_code
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getDevice_os_type
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getDevice_id
());
groupByFields
.
add
(
mlPreciseExposureBean
.
getCreate_time_day
());
return
groupByFields
;
}
public
MlPreciseExposureBean
leftJoinDimTable
(
MlPreciseExposureBean
mlPreciseExposureBean
,
String
field
,
Object
dim
)
{
SimpleCacheService
<
String
,
Object
>
dimCityCache
;
// CityInfo cityInfo = cityInfoCache.getValue(city_id, new CityCallable(city_id));
dimCityCache
=
new
SimpleCacheService
<>(
2000
,
24
);
// dimCityCache.putValue(code, new DimCity(code, pk, name, memo));
// Object dimCity = dimCityCache.getValue(field, new DimCityCallable(field, "single"));
// mlPreciseExposureBean.setCityId2(cityInfo.getCity_id(),cityInfo.getId());
// BeanReflectUtil.setFieldValue(mlPreciseExposureBean, field, dimCity.getCode());
return
mlPreciseExposureBean
;
}
private
ArrayList
<
DimCity
>
findAllCity
()
throws
Exception
{
String
sinkJdbcUrl
=
""
;
MysqlJdbcDim
mysqlJdbcDim
=
MysqlJdbcDim
.
getInstance
(
sinkJdbcUrl
);
Connection
connection
;
// connection = mysqlJdbcDim.getConnection();
String
sql
=
"select code, pk, name, memo from dim_city"
;
ArrayList
<
DimCity
>
dimCityList
=
new
ArrayList
<>();
ResultSet
resultSet
=
null
;
try
{
resultSet
=
mysqlJdbcDim
.
query
(
sql
);
while
(
resultSet
.
next
()){
DimCity
dim_city
=
new
DimCity
();
dim_city
.
setCode
(
resultSet
.
getString
(
0
));
dim_city
.
setPk
(
resultSet
.
getString
(
1
));
dim_city
.
setName
(
resultSet
.
getString
(
2
));
dim_city
.
setMemo
(
resultSet
.
getString
(
3
));
dimCityList
.
add
(
dim_city
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
resultSet
.
close
();
return
dimCityList
;
}
@Test
public
void
flatmapMlPreciseExposureBeanTest
()
{
BlPreciseExposureEtl
blPreciseExposureEtl
=
new
BlPreciseExposureEtl
();
MlPreciseExposureEtl
mlPreciseExposureEtl
=
new
MlPreciseExposureEtl
();
// String json = "{\"create_at\":\"1575134961\",\"gm_nginx_timestamp\":1575134961.718,\"user_id\":\"31665831\",\"version\":\"110\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":0,\"is_popup\":\"0\",\"exposure_cards\":[{\"absolute_position\":\"0\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"0\",\"card_id\":2},{\"absolute_position\":\"1\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"1\",\"card_id\":2},{\"absolute_position\":\"2\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"2\",\"card_id\":2},{\"absolute_position\":\"3\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"3\",\"card_id\":2},{\"absolute_position\":\"4\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"4\",\"card_id\":2}],\"tab_name\":\"\",\"down_slide_times\":0,\"page_name\":\"home\",\"up_loading_times\":0,\"is_exposure\":\"1\",\"referrer\":\"\",\"business_id\":\"\",\"referrer_id\":\"\"},\"app_session_id\":\"FE675C8B-4FD4-4FC6-9EC7-415F715A750B\",\"app\":{\"version\":\"7.18.2\",\"grey_type\":\"{\\\"report_result\\\":0,\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"post_detail\\\":\\\"0\\\",\\\"video_steep\\\":1,\\\"face_scan\\\":0}\",\"current_city_id\":\"nanjing\",\"name\":\"gengmei_user\",\"user_type\":{\"config_type\":1},\"serial_id\":12,\"channel\":\"AppStore\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"5F193A07-781F-4EF1-86B4-452251307081\",\"sys_version\":\"13.2.3\",\"lng\":118.93133562169,\"is_WiFi\":\"0\",\"manufacturer\":\"Apple\",\"device_id\":\"F88745FE-DF54-4639-B7E2-28554C7DFAAF\",\"device_type\":\"ios\",\"ip\":\"10.190.42.125\",\"idfa\":\"F88745FE-DF54-4639-B7E2-28554C7DFAAF\",\"lat\":32.121287439102,\"model\":\"iPhone8,2\"},\"type\":\"page_precise_exposure\"}";
// String json = "{\"gm_nginx_key\":1,\"version\":\"205\",\"params\":{\"up_slide_times\":\"2\",\"down_loading_times\":\"0\",\"exposure_cards\":\"[{\\\"card_id\\\":\\\"16449302\\\",\\\"card_source_type\\\":\\\"doris\\\",\\\"card_content_type\\\":\\\"diary\\\",\\\"card_type\\\":\\\"card\\\",absolute_position\\\":\\\"0\\\",\\\"relative_position\\\":\\\"0\\\"}]\",\"up_loading_times\":\"0\",\"is_exposure\":\"1\",\"tab_name\":\"精选\",\"page_name\":\"home\",\"business_id\":\"\",\"referrer\":\"\",\"referrer_id\":\"\",\"down_slide_times\":\"1\"},\"app_session_id\":\"f3d24a27-27f0-4545-b132-51030765cf49\",\"gm_nginx_timestamp\":1546307958.444,\"create_at\":\"1546307958\",\"type\":\"home_choiceness_card_exposure\",\"device\":{\"is_WiFi\":\"1\",\"ip\":\"192.168.1.100\",\"manufacturer\":\"vivo\",\"device_type\":\"android\",\"lat\":\"0.0\",\"device_id\":\"863208034156179\",\"lng\":\"0.0\"},\"app\":{\"channel\":\"vivo\",\"user_type\":{\"config_type\":\"1\"},\"serial_id\":6,\"current_city_id\":\"worldwide\",\"name\":\"gengmei_user\",\"version\":\"7.7.36\"},\"user_id\":\"\"}";
String
json
=
"{\"create_at\":\"1575135041\",\"gm_nginx_timestamp\":1575135040.498,\"user_id\":\"\",\"version\":\"147\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":6,\"is_exposure\":\"1\",\"exposure_cards\":[{\"absolute_position\":0,\"relative_position\":0,\"card_type\":\"card\",\"wiki_word\":[\"项目档案:1\",\"手术锦囊:2\",\"相近项目:3\"],\"card_content_type\":\"qa\",\"card_id\":\"7\"},{\"cpc_referer\":\"1\",\"relative_position\":0,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":0,\"card_content_type\":\"answer\",\"card_id\":\"684889\"},{\"cpc_referer\":\"1\",\"relative_position\":1,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":1,\"card_content_type\":\"answer\",\"card_id\":\"692624\"},{\"cpc_referer\":\"1\",\"relative_position\":2,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":2,\"card_content_type\":\"user_post\",\"card_id\":66263},{\"cpc_referer\":\"1\",\"relative_position\":3,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":3,\"card_content_type\":\"user_post\",\"card_id\":70670},{\"cpc_referer\":\"1\",\"relative_position\":4,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":4,\"card_content_type\":\"diary\",\"card_id\":15329391},{\"cpc_referer\":\"1\",\"relative_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":5,\"card_content_type\":\"article\",\"card_id\":\"19507071\"},{\"cpc_referer\":\"1\",\"relative_position\":5,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":6,\"card_content_type\":\"answer\",\"card_id\":\"518138\"},{\"cpc_referer\":\"1\",\"relative_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":7,\"card_content_type\":\"answer\",\"card_id\":\"684319\"},{\"cpc_referer\":\"1\",\"relative_position\":5,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":8,\"card_content_type\":\"user_post\",\"card_id\":69002}],\"tab_name\":\"综合\",\"down_slide_times\":0,\"query\":\"纹眉\",\"filter\":\"\",\"referrer_id\":\"\",\"referrer\":\"search_home\",\"up_loading_times\":0,\"business_id\":\"\",\"page_name\":\"search_result_more\"},\"app_session_id\":\"424bcbcf-3b6e-4331-89b3-9fcd0c7bfbaf\",\"app\":{\"version\":\"7.18.4\",\"grey_type\":\"{\\\"video_steep\\\":1,\\\"post_detail\\\":\\\"0\\\",\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"face_scan\\\":0,\\\"report_result\\\":0}\",\"current_city_id\":\"chongqing\",\"user_type\":{\"config_type\":\"1\"},\"name\":\"gengmei_user\",\"serial_id\":35,\"channel\":\"huawei\"},\"gm_nginx_key\":1,\"device\":{\"android_device_id\":\"androidid_b49fb6a87b10bad0\",\"sys_version\":\"9\",\"lng\":\"106.618722\",\"is_WiFi\":\"0\",\"lat\":\"29.720561\",\"device_id\":\"861198041466947\",\"manufacturer\":\"HUAWEI\",\"net_type\":\"4G\",\"device_type\":\"android\",\"ip\":\"192.168.3.3\",\"model\":\"LYA-AL00\"},\"type\":\"page_precise_exposure\"}"
;
BlPreciseExposureBean
blPreciseExposureBean
=
null
;
ArrayList
<
MlPreciseExposureBean
>
mlPreciseExposureBeanList
;
Boolean
flag
=
null
;
System
.
out
.
println
(
json
);
try
{
blPreciseExposureBean
=
blPreciseExposureEtl
.
mapBlPreciseExposureBean
(
json
);
mlPreciseExposureBeanList
=
mlPreciseExposureEtl
.
flatmapMlPreciseExposureBean
(
blPreciseExposureBean
);
for
(
MlPreciseExposureBean
mlPreciseExposureBean
:
mlPreciseExposureBeanList
)
{
System
.
out
.
println
(
mlPreciseExposureBean
.
toString
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
src/test/java/com/gmei/function/BlPreciseExposureMapFunctionTest.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
function
;
import
com.gmei.bean.bl.BlPreciseExposureBean
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
org.junit.Test
;
import
java.util.ArrayList
;
public
class
BlPreciseExposureMapFunctionTest
{
@Test
public
void
testMap
()
{
String
json
=
"{\"create_at\":\"1576355745\",\"gm_nginx_timestamp\":1577283386.396,\"user_id\":\"30374524\",\"version\":\"110\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":0,\"is_popup\":\"0\",\"exposure_cards\":[{\"absolute_position\":\"0\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"0\",\"card_id\":2},{\"absolute_position\":\"0\",\"target_name\":\"\",\"transaction_type\":\"-1\",\"card_type\":\"card\",\"card_content_type\":\"gadget\",\"relative_position\":\"\",\"card_id\":916},{\"absolute_position\":\"1\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"1\",\"card_id\":2},{\"target_name\":\"双12大促-主会场\",\"absolute_position\":\"1\",\"card_content_type\":\"指定网页\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"relative_position\":\"\",\"in_page_pos\":\"top\",\"card_id\":null},{\"absolute_position\":\"2\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"2\",\"card_id\":2},{\"absolute_position\":\"3\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"3\",\"card_id\":2},{\"absolute_position\":\"4\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"4\",\"card_id\":2}],\"tab_name\":\"\",\"down_slide_times\":0,\"page_name\":\"home\",\"up_loading_times\":0,\"is_exposure\":\"1\",\"referrer\":\"\",\"business_id\":\"\",\"referrer_id\":\"\"},\"app_session_id\":\"386FA2C1-F140-408A-BC05-7085446D6A18\",\"app\":{\"name\":\"gengmei_user\",\"grey_type\":\"{\\\"report_result\\\":0,\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"post_detail\\\":\\\"0\\\",\\\"video_steep\\\":1,\\\"face_scan\\\":0}\",\"current_city_id\":\"weifang\",\"version\":\"7.19.1\",\"user_type\":{\"config_type\":1},\"serial_id\":1,\"channel\":\"AppStore\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"D4BC83F7-82DE-42A2-8B51-61841D3572B4\",\"sys_version\":\"12.4.1\",\"lng\":0,\"is_WiFi\":\"1\",\"lat\":0,\"device_id\":\"D4BC83F7-82DE-42A2-8B51-61841D3572B4\",\"idfa\":\"00000000-0000-0000-0000-000000000000\",\"ip\":\"192.168.0.101\",\"device_type\":\"ios\",\"manufacturer\":\"Apple\",\"model\":\"iPhone10,2\"},\"type\":\"page_precise_exposure\"}"
;
// String json = "{\"create_at\":\"1576347089\",\"gm_nginx_timestamp\":1576347089.299,\"user_id\":\"31961883\",\"version\":\"110\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":5,\"exposure_cards\":{},\"tab_name\":\"service\",\"down_slide_times\":1,\"page_name\":\"category\",\"up_loading_times\":1,\"is_exposure\":\"1\",\"referrer\":\"home\",\"business_id\":\"9\",\"filter\":\"智能排序\",\"referrer_id\":\"\"},\"app_session_id\":\"0092AC31-EF72-44FF-AE1E-8BB6F8448A08\",\"app\":{\"version\":\"7.19.1\",\"grey_type\":\"{\\n \\\"report_result\\\" : 0,\\n \\\"face_detect_result\\\" : \\\"B\\\",\\n \\\"home\\\" : \\\"0\\\",\\n \\\"post_detail\\\" : \\\"0\\\",\\n \\\"video_steep\\\" : 0,\\n \\\"face_scan\\\" : 0\\n}\",\"current_city_id\":\"liuan\",\"name\":\"gengmei_user\",\"user_type\":{\"config_type\":1},\"serial_id\":28,\"channel\":\"App Store\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"51E1C5FD-B710-4820-91A6-E54C77AA4C60\",\"sys_version\":\"12.4.1\",\"lng\":116.48697900811,\"is_WiFi\":\"1\",\"manufacturer\":\"Apple\",\"device_id\":\"CD1187A7-091C-4497-96A3-A716BE510905\",\"device_type\":\"ios\",\"ip\":\"192.168.0.101\",\"idfa\":\"CD1187A7-091C-4497-96A3-A716BE510905\",\"lat\":31.757989657248,\"model\":\"iPhone10,1\"},\"type\":\"page_precise_exposure\"}";
// String json = "{\"app\":{\"user_type\":{\"config_type\":1},\"serial_id\":5,\"name\":\"gengmei_user\",\"channel\":\"App Store\",\"version\":\"7.7.40\",\"current_city_id\":\"beijin\n" +
// "g\"},\"app_session_id\":\"805E7CE4-0FB1-44E1-B32F-837B62D11D91\",\"gm_nginx_timestamp\":1576347092.686,\"user_id\":\"29105318\",\"gm_nginx_key\":1,\"creat\n" +
// "e_at\":\"1576347092\",\"params\":{\"exposure_cards\":{ },\"referrer\":\"\",\"referrer_id\":\"\",\"up_slide_times\":0,\"down_loading_times\":0,\"page_name\":\"home\"\n" +
// ",\"tab_name\":\"精选\",\"business_id\":\"\",\"up_loading_times\":0,\"down_slide_times\":0,\"is_exposure\":1},\"type\":\"home_choiceness_card_exposure\",\"versi\n" +
// "on\":\"110\",\"device\":{\"lng\":116.25638817524,\"device_id\":\"00DB1D03-3116-4084-AD86-0596EDFA2E3D\",\"is_WiFi\":\"1\",\"ip\":\"10.10.62.107\",\"idfa\":\"00DB1\n" +
// "D03-3116-4084-AD86-0596EDFA2E3D\",\"idfv\":\"1E6E56F7-3E3C-4F62-83EB-E9DBE7BC1AD1\",\"device_type\":\"ios\",\"lat\":40.073574956895,\"manufacturer\":\"Apple\"}}";
BlPreciseExposureMapFunction
blPreciseExposureMapFunction
=
new
BlPreciseExposureMapFunction
();
MlpreciseExposureFlatMapFunction
mlpreciseExposureFlatMapFunction
=
new
MlpreciseExposureFlatMapFunction
();
BlPreciseExposureBean
blPreciseExposureBean
=
null
;
try
{
blPreciseExposureBean
=
blPreciseExposureMapFunction
.
map
(
json
);
ArrayList
<
MlPreciseExposureBean
>
mlPreciseExposureBeanArrayList
=
mlpreciseExposureFlatMapFunction
.
flatmapBlPreciseExposure
(
blPreciseExposureBean
);
for
(
MlPreciseExposureBean
mlPreciseExposureBean
:
mlPreciseExposureBeanArrayList
)
{
System
.
out
.
println
(
mlPreciseExposureBean
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
// System.out.println(blPreciseExposureBean);
}
@Test
public
void
testReplace
()
{
String
json
=
"{\"{\\n}\"}"
;
System
.
out
.
println
(
json
);
// String jsonOnly = json.replace("\n", "").replace("\r","");
String
jsonAll
=
json
.
replaceAll
(
"[\\n\\r\\t]"
,
""
);
// System.out.println(jsonOnly);
System
.
out
.
println
(
"------------"
);
System
.
out
.
println
(
jsonAll
);
}
@Test
public
void
testHex2Int
()
{
String
hex
=
"0x356a192b7913b04c54574d18c28d46e6395428ab"
;
System
.
out
.
println
(
Integer
.
parseInt
(
hex
,
16
));
}
}
src/test/java/com/gmei/kafka/MyConsumer.java
0 → 100755
View file @
e15a2105
package
com
.
gmei
.
kafka
;
import
org.apache.kafka.clients.consumer.ConsumerRecord
;
import
org.apache.kafka.clients.consumer.ConsumerRecords
;
import
org.apache.kafka.clients.consumer.KafkaConsumer
;
import
java.util.*
;
public
class
MyConsumer
{
public
static
void
main
(
String
[]
args
)
{
String
topicName
=
"test"
;
String
groupId
=
"group1"
;
//构造java.util.Properties对象
Properties
props
=
new
Properties
();
// 必须指定属性。
props
.
put
(
"bootstrap.servers"
,
"localhost:9092"
);
// 必须指定属性。
props
.
put
(
"group.id"
,
groupId
);
props
.
put
(
"enable.auto.commit"
,
"true"
);
props
.
put
(
"auto.commit.interval.ms"
,
"1000"
);
// 从最早的消息开始读取
props
.
put
(
"auto.offset.reset"
,
"earliest"
);
// 必须指定
props
.
put
(
"key.deserializer"
,
"org.apache.kafka.common.serialization.StringDeserializer"
);
// 必须指定
props
.
put
(
"value.deserializer"
,
"org.apache.kafka.common.serialization.StringDeserializer"
);
// 使用创建的Properties实例构造consumer实例
KafkaConsumer
<
String
,
String
>
consumer
=
new
KafkaConsumer
<
String
,
String
>(
props
);
// 订阅topic。调用kafkaConsumer.subscribe方法订阅consumer group所需的topic列表
consumer
.
subscribe
(
Arrays
.
asList
(
topicName
));
try
{
while
(
true
)
{
//循环调用kafkaConsumer.poll方法获取封装在ConsumerRecord的topic消息。
ConsumerRecords
<
String
,
String
>
records
=
consumer
.
poll
(
1000
);
//获取到封装在ConsumerRecords消息以后,处理获取到ConsumerRecord对象。
for
(
ConsumerRecord
<
String
,
String
>
record
:
records
)
{
//简单的打印输出
System
.
out
.
println
(
"offset = "
+
record
.
offset
()
+
",key = "
+
record
.
key
()
+
",value ="
+
record
.
value
());
}
}
}
catch
(
Exception
e
)
{
//关闭kafkaConsumer
System
.
out
.
println
(
"消息消费结束......"
);
consumer
.
close
();
}
System
.
out
.
println
(
"关闭消费者......"
);
}
}
src/test/java/com/gmei/kafka/MyProducter.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
kafka
;
import
org.apache.kafka.clients.producer.KafkaProducer
;
import
org.apache.kafka.clients.producer.Producer
;
import
org.apache.kafka.clients.producer.ProducerRecord
;
import
java.util.Properties
;
public
class
MyProducter
{
public
static
void
main
(
String
[]
args
)
{
// 构造一个java.util.Properties对象
Properties
props
=
new
Properties
();
// 指定bootstrap.servers属性。必填,无默认值。用于创建向kafka broker服务器的连接。
props
.
put
(
"bootstrap.servers"
,
"localhost:9092"
);
// 指定key.serializer属性。必填,无默认值。被发送到broker端的任何消息的格式都必须是字节数组。
// 因此消息的各个组件都必须首先做序列化,然后才能发送到broker。该参数就是为消息的key做序列化只用的。
props
.
put
(
"key.serializer"
,
"org.apache.kafka.common.serialization.StringSerializer"
);
// 指定value.serializer属性。必填,无默认值。和key.serializer类似。此被用来对消息体即消息value部分做序列化。
// 将消息value部分转换成字节数组。
props
.
put
(
"value.serializer"
,
"org.apache.kafka.common.serialization.StringSerializer"
);
//acks参数用于控制producer生产消息的持久性(durability)。参数可选值,0、1、-1(all)。
props
.
put
(
"acks"
,
"-1"
);
//props.put(ProducerConfig.ACKS_CONFIG, "1");
//在producer内部自动实现了消息重新发送。默认值0代表不进行重试。
props
.
put
(
"retries"
,
3
);
//props.put(ProducerConfig.RETRIES_CONFIG, 3);
//调优producer吞吐量和延时性能指标都有非常重要作用。默认值16384即16KB。
props
.
put
(
"batch.size"
,
323840
);
//props.put(ProducerConfig.BATCH_SIZE_CONFIG, 323840);
//控制消息发送延时行为的,该参数默认值是0。表示消息需要被立即发送,无须关系batch是否被填满。
props
.
put
(
"linger.ms"
,
10
);
//props.put(ProducerConfig.LINGER_MS_CONFIG, 10);
//指定了producer端用于缓存消息的缓冲区的大小,单位是字节,默认值是33554432即32M。
props
.
put
(
"buffer.memory"
,
33554432
);
//props.put(ProducerConfig.BUFFER_MEMORY_CONFIG, 33554432);
props
.
put
(
"max.block.ms"
,
3000
);
//props.put(ProducerConfig.MAX_BLOCK_MS_CONFIG, 3000);
//设置producer段是否压缩消息,默认值是none。即不压缩消息。GZIP、Snappy、LZ4
//props.put("compression.type", "none");
//props.put(ProducerConfig.COMPRESSION_TYPE_CONFIG, "none");
//该参数用于控制producer发送请求的大小。producer端能够发送的最大消息大小。
//props.put("max.request.size", 10485760);
//props.put(ProducerConfig.MAX_REQUEST_SIZE_CONFIG, 10485760);
//producer发送请求给broker后,broker需要在规定时间范围内将处理结果返还给producer。默认30s
//props.put("request.timeout.ms", 60000);
//props.put(ProducerConfig.REQUEST_TIMEOUT_MS_CONFIG, 60000);
// Properties props = new Properties();
// props.setProperty("metadata.broker.list","10.10.10.100:9090");
// props.setProperty("serializer.class","kafka.serializer.StringEncoder");
// props.put("request.required.acks","1");
// ProducerConfig config = new ProducerConfig(props);
//创建生产这对象
Producer
<
String
,
String
>
producer
=
new
KafkaProducer
<
String
,
String
>(
props
);
String
json
=
"{\"create_at\":\"1577364648\",\"gm_nginx_timestamp\":1577364646.542,\"user_id\":\"\",\"version\":\"147\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":0,\"is_popup\":0,\"exposure_cards\":[{\"absolute_position\":0,\"transaction_type\":\"\",\"relative_position\":0,\"card_content_type\":\"function_entrance\",\"card_id\":2},{\"absolute_position\":1,\"transaction_type\":\"\",\"relative_position\":0,\"card_content_type\":\"function_entrance\",\"card_id\":2},{\"absolute_position\":2,\"transaction_type\":\"\",\"relative_position\":0,\"card_content_type\":\"function_entrance\",\"card_id\":2},{\"absolute_position\":3,\"transaction_type\":\"\",\"relative_position\":0,\"card_content_type\":\"function_entrance\",\"card_id\":2},{\"absolute_position\":4,\"transaction_type\":\"\",\"relative_position\":0,\"card_content_type\":\"function_entrance\",\"card_id\":2},{\"target_name\":\"\",\"relative_position\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":0,\"card_content_type\":\"gadget\",\"card_id\":923},{\"target_name\":\"12月新人专场\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":0,\"card_content_type\":\"福利专题列表\",\"card_id\":6377},{\"target_name\":\"双旦大促-主会场-华西\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":1,\"card_content_type\":\"福利专题列表\",\"card_id\":6565},{\"target_name\":\"眼部双旦-banner\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":2,\"card_content_type\":\"新专题聚合\",\"card_id\":38},{\"target_name\":\"鼻部-双旦大促-banner\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":3,\"card_content_type\":\"新专题聚合\",\"card_id\":46},{\"target_name\":\"12.26社区\",\"relative_position\":0,\"transaction_type\":\"operation\",\"card_type\":\"card\",\"in_page_pos\":\"top\",\"card_content_type\":\"指定网页\",\"absolute_position\":4},{\"target_name\":\"吸脂填充-双旦\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":5,\"card_content_type\":\"新专题聚合\",\"card_id\":42},{\"target_name\":\"美肤三针双旦-banner\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":6,\"card_content_type\":\"新专题聚合\",\"card_id\":39},{\"target_name\":\"轮廓双旦banner\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":7,\"card_content_type\":\"新专题聚合\",\"card_id\":36},{\"target_name\":\"12月新人专场\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":0,\"card_content_type\":\"福利专题列表\",\"card_id\":6377},{\"target_name\":\"双旦大促-主会场-华西\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":1,\"card_content_type\":\"福利专题列表\",\"card_id\":6565},{\"target_name\":\"眼部双旦-banner\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":2,\"card_content_type\":\"新专题聚合\",\"card_id\":38},{\"target_name\":\"鼻部-双旦大促-banner\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":3,\"card_content_type\":\"新专题聚合\",\"card_id\":46},{\"target_name\":\"12.26社区\",\"relative_position\":0,\"transaction_type\":\"operation\",\"card_type\":\"card\",\"in_page_pos\":\"top\",\"card_content_type\":\"指定网页\",\"absolute_position\":4},{\"target_name\":\"吸脂填充-双旦\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":5,\"card_content_type\":\"新专题聚合\",\"card_id\":42},{\"target_name\":\"美肤三针双旦-banner\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":6,\"card_content_type\":\"新专题聚合\",\"card_id\":39},{\"target_name\":\"轮廓双旦banner\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":7,\"card_content_type\":\"新专题聚合\",\"card_id\":36},{\"target_name\":\"12月新人专场\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":0,\"card_content_type\":\"福利专题列表\",\"card_id\":6377},{\"target_name\":\"双旦大促-主会场-华西\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":1,\"card_content_type\":\"福利专题列表\",\"card_id\":6565},{\"target_name\":\"眼部双旦-banner\",\"relative_position\":0,\"in_page_pos\":\"top\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"absolute_position\":2,\"card_content_type\":\"新专题聚合\",\"card_id\":38}],\"tab_name\":\"\",\"down_slide_times\":0,\"page_name\":\"home\",\"up_loading_times\":0,\"referrer_id\":\"\",\"referrer\":\"\",\"is_exposure\":\"1\",\"business_id\":\"\"},\"app_session_id\":\"6d167db8-147d-4ded-b7a8-0d9f176f91a1\",\"app\":{\"version\":\"7.19.2\",\"grey_type\":\"unknown\",\"current_city_id\":\"chongqing\",\"user_type\":{},\"name\":\"gengmei_user\",\"serial_id\":1,\"channel\":\"huawei\"},\"gm_nginx_key\":1,\"device\":{\"android_device_id\":\"androidid_99a0301553dc4f12\",\"sys_version\":\"10\",\"lng\":\"106.56958\",\"is_WiFi\":\"1\",\"lat\":\"29.680635\",\"device_id\":\"864674045613095\",\"manufacturer\":\"HUAWEI\",\"net_type\":\"wifi\",\"device_type\":\"android\",\"ip\":\"192.168.0.100\",\"model\":\"VOG-AL00\"},\"type\":\"page_precise_exposure\"}"
;
// String json = "{\"create_at\":\"1577324083\",\"gm_nginx_timestamp\":1577324083.74,\"user_id\":\"32339790\",\"version\":\"110\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":13,\"exposure_cards\":[{\"absolute_position\":\"23\",\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":\"0\",\"card_id\":\"689089\"},{\"absolute_position\":\"26\",\"transaction_type\":\"\",\"relative_position\":\"3\",\"card_content_type\":\"search_query\",\"in_page_pos\":\"related_search\",\"card_id\":[\"注射美容\",\"硅胶丰额头\",\"祛颊脂垫\",\"胶原蛋白填充垫下巴\",\"面部不对称改善\",\"膨体丰额头\"]},{\"absolute_position\":\"27\",\"cpc_referer\":1,\"relative_position\":\"1\",\"transaction_type\":\"-1\",\"card_type\":\"card\",\"is_cpc\":0,\"card_content_type\":\"diary\",\"card_id\":15804523},{\"absolute_position\":\"28\",\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"article\",\"relative_position\":\"2\",\"card_id\":\"19514087\"},{\"absolute_position\":\"29\",\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":\"3\",\"card_id\":\"696977\"},{\"absolute_position\":\"30\",\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":\"4\",\"card_id\":\"686606\"},{\"absolute_position\":\"33\",\"cpc_referer\":1,\"relative_position\":\"4\",\"transaction_type\":\"-1\",\"card_type\":\"card\",\"is_cpc\":0,\"card_content_type\":\"diary\",\"card_id\":15965971},{\"absolute_position\":\"34\",\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"article\",\"relative_position\":\"2\",\"card_id\":\"19515896\"},{\"absolute_position\":\"35\",\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":\"3\",\"card_id\":\"700587\"},{\"absolute_position\":\"36\",\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":\"4\",\"card_id\":\"700403\"},{\"absolute_position\":\"39\",\"transaction_type\":\"\",\"relative_position\":\"3\",\"card_content_type\":\"search_query\",\"in_page_pos\":\"related_search\",\"card_id\":[\"长下巴矫正\",\"激光溶脂瘦脸\",\"额头\",\"人工骨垫下巴\",\"下巴截骨前移\",\"玻尿酸丰耳垂\"]},{\"absolute_position\":\"40\",\"cpc_referer\":1,\"relative_position\":\"4\",\"transaction_type\":\"-1\",\"card_type\":\"card\",\"is_cpc\":0,\"card_content_type\":\"diary\",\"card_id\":15953555}],\"tab_name\":\"综合\",\"down_slide_times\":1,\"query\":\"瘦脸针\",\"up_loading_times\":1,\"is_exposure\":\"1\",\"referrer\":\"search_home\",\"business_id\":\"\",\"page_name\":\"search_result_more\",\"referrer_id\":\"\"},\"app_session_id\":\"5A18488E-0965-45EE-B35A-BE82266B785B\",\"app\":{\"version\":\"7.19.1\",\"grey_type\":\"{\\\"report_result\\\":0,\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"post_detail\\\":\\\"0\\\",\\\"video_steep\\\":1,\\\"face_scan\\\":0}\",\"current_city_id\":\"qingdao\",\"name\":\"gengmei_user\",\"user_type\":{\"config_type\":1},\"serial_id\":14,\"channel\":\"AppStore\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"F7B0BC42-DCDD-4AE8-A0A1-C205233A94A4\",\"sys_version\":\"12.4\",\"lng\":120.38120711884,\"is_WiFi\":\"0\",\"manufacturer\":\"Apple\",\"device_id\":\"BD96C788-434E-46EB-898C-DF2941882425\",\"device_type\":\"ios\",\"ip\":\"10.171.24.14\",\"idfa\":\"BD96C788-434E-46EB-898C-DF2941882425\",\"lat\":36.08928448005,\"model\":\"iPhone11,6\"},\"type\":\"page_precise_exposure\"}";
// String json = "{\"create_at\":\"1577275915\",\"gm_nginx_timestamp\":1577275916.509,\"user_id\":\"32368787\",\"version\":\"147\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":0,\"is_exposure\":\"1\",\"exposure_cards\":[{\"absolute_position\":0,\"transaction_type\":\"\",\"card_type\":\"card\",\"relative_position\":0,\"card_content_type\":\"banner\",\"card_id\":\"\"},{\"cpc_referer\":\"2\",\"relative_position\":0,\"absolute_position\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"card_content_type\":\"service\",\"result_status\":\"1\",\"card_id\":\"5785839\"},{\"cpc_referer\":\"2\",\"relative_position\":0,\"absolute_position\":1,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"card_content_type\":\"service\",\"result_status\":\"1\",\"card_id\":\"5785492\"},{\"cpc_referer\":\"2\",\"relative_position\":0,\"absolute_position\":2,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"card_content_type\":\"service\",\"result_status\":\"1\",\"card_id\":\"5742979\"},{\"cpc_referer\":\"2\",\"relative_position\":0,\"absolute_position\":3,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"card_content_type\":\"service\",\"result_status\":\"1\",\"card_id\":\"5750757\"},{\"cpc_referer\":\"1\",\"relative_position\":0,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":0,\"card_content_type\":\"answer\",\"card_id\":\"332510\"},{\"cpc_referer\":\"1\",\"relative_position\":1,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":1,\"card_content_type\":\"answer\",\"card_id\":\"307094\"},{\"cpc_referer\":\"1\",\"relative_position\":2,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":2,\"card_content_type\":\"user_post\",\"card_id\":70366}],\"tab_name\":\"综合\",\"down_slide_times\":0,\"query\":\"魔镜\",\"filter\":\"\",\"referrer_id\":\"\",\"referrer\":\"search_home\",\"up_loading_times\":0,\"business_id\":\"\",\"page_name\":\"search_result_more\"},\"app_session_id\":\"7c55ad0f-a0a8-46c8-ad21-bd9f3f12449f\",\"app\":{\"version\":\"7.19.2\",\"grey_type\":\"{\\\"video_steep\\\":0,\\\"post_detail\\\":\\\"0\\\",\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"face_scan\\\":0,\\\"report_result\\\":0}\",\"current_city_id\":\"xining\",\"user_type\":{\"config_type\":\"1\"},\"name\":\"gengmei_user\",\"serial_id\":32,\"channel\":\"guangdiantongand05\"},\"gm_nginx_key\":1,\"device\":{\"android_device_id\":\"androidid_2117151825754036\",\"sys_version\":\"9\",\"lng\":\"101.689229\",\"is_WiFi\":\"1\",\"lat\":\"36.944768\",\"device_id\":\"865787042243564\",\"manufacturer\":\"Xiaomi\",\"net_type\":\"wifi\",\"device_type\":\"android\",\"ip\":\"192.168.0.10\",\"model\":\"RedmiNote7Pro\"},\"type\":\"page_precise_exposure\"}";
// String json = "{\"create_at\":\"1576355745\",\"gm_nginx_timestamp\":1577283386.396,\"user_id\":\"30374524\",\"version\":\"110\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":0,\"is_popup\":\"0\",\"exposure_cards\":[{\"absolute_position\":\"0\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"0\",\"card_id\":2},{\"absolute_position\":\"0\",\"target_name\":\"\",\"transaction_type\":\"-1\",\"card_type\":\"card\",\"card_content_type\":\"gadget\",\"relative_position\":\"\",\"card_id\":916},{\"absolute_position\":\"1\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"1\",\"card_id\":2},{\"target_name\":\"双12大促-主会场\",\"absolute_position\":\"1\",\"card_content_type\":\"指定网页\",\"transaction_type\":\"operation\",\"card_type\":\"card\",\"relative_position\":\"\",\"in_page_pos\":\"top\",\"card_id\":null},{\"absolute_position\":\"2\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"2\",\"card_id\":2},{\"absolute_position\":\"3\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"3\",\"card_id\":2},{\"absolute_position\":\"4\",\"transaction_type\":\"\",\"card_content_type\":\"function_entrance\",\"relative_position\":\"4\",\"card_id\":2}],\"tab_name\":\"\",\"down_slide_times\":0,\"page_name\":\"home\",\"up_loading_times\":0,\"is_exposure\":\"1\",\"referrer\":\"\",\"business_id\":\"\",\"referrer_id\":\"\"},\"app_session_id\":\"386FA2C1-F140-408A-BC05-7085446D6A18\",\"app\":{\"name\":\"gengmei_user\",\"grey_type\":\"{\\\"report_result\\\":0,\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"post_detail\\\":\\\"0\\\",\\\"video_steep\\\":1,\\\"face_scan\\\":0}\",\"current_city_id\":\"weifang\",\"version\":\"7.19.1\",\"user_type\":{\"config_type\":1},\"serial_id\":1,\"channel\":\"AppStore\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"D4BC83F7-82DE-42A2-8B51-61841D3572B4\",\"sys_version\":\"12.4.1\",\"lng\":0,\"is_WiFi\":\"1\",\"lat\":0,\"device_id\":\"D4BC83F7-82DE-42A2-8B51-61841D3572B4\",\"idfa\":\"00000000-0000-0000-0000-000000000000\",\"ip\":\"192.168.0.101\",\"device_type\":\"ios\",\"manufacturer\":\"Apple\",\"model\":\"iPhone10,2\"},\"type\":\"page_precise_exposure\"}";
// String json = "{\"create_at\":\"1576128422\",\"gm_nginx_timestamp\":1576128422.463,\"user_id\":\"31038796\",\"version\":\"110\",\"params\":{\"down_loading_times\":1,\"up_slide_times\":5,\"exposure_cards\":[{\"absolute_position\":0,\"result_status\":\"1\",\"card_content_type\":\"service\",\"transaction_type\":\"[\\\"-1\\\",\\\"-1\\\",\\\"-1\\\"]\",\"card_type\":\"card\",\"card_source_type\":\"[\\\"\\\",\\\"\\\",\\\"\\\"]\",\"relative_position\":0,\"card_id\":\"[\\\"5821997\\\",\\\"5762189\\\",\\\"5671097\\\"]\"},{\"absolute_position\":1,\"card_content_type\":\"wiki_collect\",\"card_type\":\"card\",\"relative_position\":1,\"wiki_word\":{},\"card_id\":\"127\"},{\"absolute_position\":2,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":3,\"card_id\":\"15337295\"},{\"absolute_position\":3,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":4,\"card_id\":\"15635897\"},{\"absolute_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":5,\"card_id\":\"16082820\"},{\"absolute_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":5,\"card_id\":\"16082820\"},{\"absolute_position\":5,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":4,\"card_id\":\"699299\"},{\"absolute_position\":6,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"article\",\"relative_position\":5,\"card_id\":\"19589790\"},{\"absolute_position\":7,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":6,\"card_id\":\"15764401\"},{\"absolute_position\":8,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":4,\"card_id\":\"15633799\"},{\"absolute_position\":9,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":5,\"card_id\":\"16622540\"},{\"absolute_position\":10,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":6,\"card_id\":\"699573\"},{\"absolute_position\":11,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":4,\"card_id\":\"686812\"},{\"absolute_position\":12,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":5,\"card_id\":\"15328675\"},{\"absolute_position\":13,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"diary\",\"relative_position\":6,\"card_id\":\"11201557\"},{\"absolute_position\":14,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":4,\"card_id\":\"700888\"},{\"absolute_position\":15,\"transaction_type\":\"\",\"card_type\":\"card\",\"card_content_type\":\"answer\",\"relative_position\":5,\"card_id\":\"706569\"}],\"tab_name\":\"综合\",\"down_slide_times\":8,\"query\":\"玻尿酸\",\"up_loading_times\":0,\"is_exposure\":1,\"referrer\":\"search_home\",\"business_id\":\"\",\"page_name\":\"search_result_more\",\"referrer_id\":\"\"},\"app_session_id\":\"559D8BA2-7FC1-402C-BB12-F860EFA26925\",\"app\":{\"user_type\":{\"config_type\":1},\"current_city_id\":\"chengdu\",\"version\":\"7.7.60\",\"name\":\"gengmei_user\",\"serial_id\":14,\"channel\":\"AppStore\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"CD8D7E3B-B833-49EE-B509-6B9F1B3963B9\",\"lng\":104.07933463616,\"is_WiFi\":\"0\",\"manufacturer\":\"Apple\",\"ip\":\"10.187.49.153\",\"device_id\":\"4A0275C1-4734-404A-93DD-BAA272401A27\",\"device_type\":\"ios\",\"lat\":30.654052050073,\"idfa\":\"4A0275C1-4734-404A-93DD-BAA272401A27\"},\"type\":\"page_precise_exposure\"}";
// String json = "{\"create_at\":\"1575135041\",\"gm_nginx_timestamp\":1575135040.498,\"user_id\":\"\",\"version\":\"147\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":6,\"is_exposure\":\"1\",\"exposure_cards\":[{\"absolute_position\":0,\"relative_position\":0,\"card_type\":\"card\",\"wiki_word\":[\"项目档案:1\",\"手术锦囊:2\",\"相近项目:3\"],\"card_content_type\":\"wiki_item\",\"card_id\":\"7\"},{\"cpc_referer\":\"1\",\"relative_position\":0,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":0,\"card_content_type\":\"answer\",\"card_id\":\"684889\"},{\"cpc_referer\":\"1\",\"relative_position\":1,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":1,\"card_content_type\":\"answer\",\"card_id\":\"692624\"},{\"cpc_referer\":\"1\",\"relative_position\":2,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":2,\"card_content_type\":\"user_post\",\"card_id\":66263},{\"cpc_referer\":\"1\",\"relative_position\":3,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":3,\"card_content_type\":\"user_post\",\"card_id\":66263},{\"cpc_referer\":\"1\",\"relative_position\":4,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":4,\"card_content_type\":\"diary\",\"card_id\":15329391},{\"cpc_referer\":\"1\",\"relative_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":5,\"card_content_type\":\"article\",\"card_id\":\"19507071\"},{\"cpc_referer\":\"1\",\"relative_position\":5,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":6,\"card_content_type\":\"answer\",\"card_id\":\"518138\"},{\"cpc_referer\":\"1\",\"relative_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":7,\"card_content_type\":\"answer\",\"card_id\":\"684319\"},{\"cpc_referer\":\"1\",\"relative_position\":5,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":8,\"card_content_type\":\"user_post\",\"card_id\":69002}],\"tab_name\":\"综合\",\"down_slide_times\":0,\"query\":\"纹眉\",\"filter\":\"\",\"referrer_id\":\"\",\"referrer\":\"search_home\",\"up_loading_times\":0,\"business_id\":\"\",\"page_name\":\"search_result_more\"},\"app_session_id\":\"424bcbcf-3b6e-4331-89b3-9fcd0c7bfbaf\",\"app\":{\"version\":\"7.18.4\",\"grey_type\":\"{\\\"video_steep\\\":1,\\\"post_detail\\\":\\\"0\\\",\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"face_scan\\\":0,\\\"report_result\\\":0}\",\"current_city_id\":\"chongqing\",\"user_type\":{\"config_type\":\"1\"},\"name\":\"gengmei_user\",\"serial_id\":35,\"channel\":\"huawei\"},\"gm_nginx_key\":1,\"device\":{\"android_device_id\":\"androidid_b49fb6a87b10bad0\",\"sys_version\":\"9\",\"lng\":\"106.618722\",\"is_WiFi\":\"0\",\"lat\":\"29.720561\",\"device_id\":\"861198041466947\",\"manufacturer\":\"HUAWEI\",\"net_type\":\"4G\",\"device_type\":\"android\",\"ip\":\"192.168.3.3\",\"model\":\"LYA-AL00\"},\"type\":\"page_precise_exposure\"}";
//生成消息
try
{
boolean
flag
=
true
;
while
(
flag
)
{
//发送消息
// producer.send(new ProducerRecord<String, String>("test", Integer.toString(1), Integer.toString(2)));
// String message=getDate("dim_sigtyp","seqnum","code","name");
// KeyedMessage<String, String> data = new KeyedMessage<String, String>("test3",message);
// 构造待发送的消息对象ProduceRecord的对象,指定消息要发送到的topic主题,分区以及对应的key和value键值对。
// 注意,分区和key信息可以不用指定,由kafka自行确定目标分区。
// ProducerRecord<String, String> producerRecord = new ProducerRecord<String, String>("test",
// Integer.toString("row"), Integer.toString("{\"@raw\":\"{\\\"create_at\\\":\\\"1575129599\\\",\\\"gm_nginx_timestamp\\\":1575129600.382,\\\"user_id\\\":\\\"\\\",\\\"version\\\":\\\"147\\\",\\\"params\\\":{\\\"down_loading_times\\\":0,\\\"up_slide_times\\\":0,\\\"is_popup\\\":0,\\\"exposure_cards\\\":[{\\\"absolute_position\\\":0,\\\"transaction_type\\\":\\\"\\\",\\\"relative_position\\\":0,\\\"card_content_type\\\":\\\"function_entrance\\\",\\\"card_id\\\":1},{\\\"absolute_position\\\":1,\\\"transaction_type\\\":\\\"\\\",\\\"relative_position\\\":0,\\\"card_content_type\\\":\\\"function_entrance\\\",\\\"card_id\\\":1},{\\\"absolute_position\\\":2,\\\"transaction_type\\\":\\\"\\\",\\\"relative_position\\\":0,\\\"card_content_type\\\":\\\"function_entrance\\\",\\\"card_id\\\":1},{\\\"absolute_position\\\":3,\\\"transaction_type\\\":\\\"\\\",\\\"relative_position\\\":0,\\\"card_content_type\\\":\\\"function_entrance\\\",\\\"card_id\\\":1},{\\\"absolute_position\\\":4,\\\"transaction_type\\\":\\\"\\\",\\\"relative_position\\\":0,\\\"card_content_type\\\":\\\"function_entrance\\\",\\\"card_id\\\":1}],\\\"tab_name\\\":\\\"\\\",\\\"down_slide_times\\\":0,\\\"page_name\\\":\\\"home\\\",\\\"up_loading_times\\\":0,\\\"referrer_id\\\":\\\"\\\",\\\"referrer\\\":\\\"\\\",\\\"is_exposure\\\":\\\"1\\\",\\\"business_id\\\":\\\"\\\"},\\\"app_session_id\\\":\\\"cb2cf436-183a-4f4c-a3ac-0f8f54759f37\\\",\\\"app\\\":{\\\"version\\\":\\\"7.19.0\\\",\\\"grey_type\\\":\\\"{\\\\\\\"video_steep\\\\\\\": 0, \\\\\\\"post_detail\\\\\\\": \\\\\\\"0\\\\\\\", \\\\\\\"face_detect_result\\\\\\\": \\\\\\\"B\\\\\\\", \\\\\\\"home\\\\\\\": \\\\\\\"0\\\\\\\", \\\\\\\"face_scan\\\\\\\": 0, \\\\\\\"report_result\\\\\\\": 0}\\\",\\\"current_city_id\\\":\\\"zibo\\\",\\\"user_type\\\":{\\\"config_type\\\":\\\"1\\\"},\\\"name\\\":\\\"gengmei_user\\\",\\\"serial_id\\\":14,\\\"channel\\\":\\\"xiaomi\\\"},\\\"gm_nginx_key\\\":1,\\\"device\\\":{\\\"android_device_id\\\":\\\"androidid_e645aab7a96734d6\\\",\\\"sys_version\\\":\\\"9\\\",\\\"lng\\\":\\\"117.901306\\\",\\\"is_WiFi\\\":\\\"0\\\",\\\"lat\\\":\\\"36.658066\\\",\\\"device_id\\\":\\\"863976043011292\\\",\\\"manufacturer\\\":\\\"Xiaomi\\\",\\\"net_type\\\":\\\"4G\\\",\\\"device_type\\\":\\\"android\\\",\\\"ip\\\":\\\"10.117.57.93\\\",\\\"model\\\":\\\"MI 8\\\"},\\\"type\\\":\\\"page_precise_exposure\\\"}\"}\n"));
// 调用kafkaProduce的send方法发送消息
ProducerRecord
<
String
,
String
>
producerRecord
=
new
ProducerRecord
<
String
,
String
>(
"test"
,
// "raw", "{\"@raw\":\"{\"gm_nginx_key\":2,\"version\":\"110\",\"params\":{\"up_slide_times\":0,\"down_loading_times\":0,\"exposure_cards\":{},\"up_loading_times\":0,\"is_exposure\":1,\"tab_name\":\"精选\",\"referrer_id\":\"\",\"down_slide_times\":0,\"referrer\":\"\",\"page_name\":\"home\",\"business_id\":\"\"},\"app_session_id\":\"C3280044-5C8E-459D-AE6C-8E26BBACD6C9\",\"gm_nginx_timestamp\":1546307958.631,\"create_at\":\"1546307958\",\"app\":{\"channel\":\"AppStore\",\"version\":\"7.7.35\",\"serial_id\":42,\"current_city_id\":\"worldwide\",\"name\":\"gengmei_user\",\"user_type\":{}},\"device\":{\"is_WiFi\":\"0\",\"device_type\":\"ios\",\"device_id\":\"DE8EA66A-BDE9-47CD-9795-24E444F5BC17\",\"lng\":0,\"lat\":0,\"ip\":\"10.156.100.97\",\"manufacturer\":\"Apple\",\"idfa\":\"DE8EA66A-BDE9-47CD-9795-24E444F5BC17\",\"idfv\":\"352A6D64-17CA-4520-831A-2CE9507631D8\"},\"user_id\":\"30864538\",\"type\":\"home_choiceness_card_exposure\"}\"}");
// "test","{\"gm_nginx_key\":2,\"version\":\"110\",\"params\":{\"up_slide_times\":0,\"down_loading_times\":0,\"exposure_cards\":{},\"up_loading_times\":0,\"is_exposure\":1,\"tab_name\":\"精选\",\"referrer_id\":\"\",\"down_slide_times\":0,\"referrer\":\"\",\"page_name\":\"home\",\"business_id\":\"\"},\"app_session_id\":\"C3280044-5C8E-459D-AE6C-8E26BBACD6C9\",\"gm_nginx_timestamp\":1546307958.631,\"create_at\":\"1546307958\",\"app\":{\"channel\":\"AppStore\",\"version\":\"7.7.35\",\"serial_id\":42,\"current_city_id\":\"worldwide\",\"name\":\"gengmei_user\",\"user_type\":{}},\"device\":{\"is_WiFi\":\"0\",\"device_type\":\"ios\",\"device_id\":\"DE8EA66A-BDE9-47CD-9795-24E444F5BC17\",\"lng\":0,\"lat\":0,\"ip\":\"10.156.100.97\",\"manufacturer\":\"Apple\",\"idfa\":\"DE8EA66A-BDE9-47CD-9795-24E444F5BC17\",\"idfv\":\"352A6D64-17CA-4520-831A-2CE9507631D8\"},\"user_id\":\"30864538\",\"type\":\"home_choiceness_card_exposure\"}");
"test"
,
json
);
producer
.
send
(
producerRecord
);
Thread
.
sleep
(
20000
);
System
.
out
.
println
(
"======================"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
producer
.
close
();
}
}
src/test/java/com/gmei/sink/BlPreciseExposureKafkaSink.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
sink
;
import
org.apache.flink.api.common.serialization.SimpleStringSchema
;
import
org.apache.flink.streaming.api.CheckpointingMode
;
import
org.apache.flink.streaming.api.datastream.DataStreamSource
;
import
org.apache.flink.streaming.api.environment.CheckpointConfig
;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011
;
import
org.apache.flink.streaming.connectors.kafka.internals.KeyedSerializationSchemaWrapper
;
import
java.util.Properties
;
public
class
BlPreciseExposureKafkaSink
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
//获取Flink的运行环境
StreamExecutionEnvironment
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
();
//checkpoint配置
env
.
enableCheckpointing
(
5000
);
env
.
getCheckpointConfig
().
setCheckpointingMode
(
CheckpointingMode
.
EXACTLY_ONCE
);
env
.
getCheckpointConfig
().
setMinPauseBetweenCheckpoints
(
500
);
env
.
getCheckpointConfig
().
setCheckpointTimeout
(
60000
);
env
.
getCheckpointConfig
().
setMaxConcurrentCheckpoints
(
1
);
env
.
getCheckpointConfig
().
enableExternalizedCheckpoints
(
CheckpointConfig
.
ExternalizedCheckpointCleanup
.
RETAIN_ON_CANCELLATION
);
//设置statebackend
//env.setStateBackend(new RocksDBStateBackend("hdfs://hadoop100:9000/flink/checkpoints",true));
DataStreamSource
<
String
>
text
=
env
.
socketTextStream
(
"hadoop100"
,
9001
,
"\n"
);
// String brokerList = "localhost:9092";
String
brokerList
=
"172.21.40.14:9092"
;
// String topic = "test";
String
topic
=
"gm-precise_exposure-test"
;
Properties
prop
=
new
Properties
();
prop
.
setProperty
(
"bootstrap.servers"
,
brokerList
);
//第一种解决方案,设置FlinkKafkaProducer011里面的事务超时时间
//设置事务超时时间
//prop.setProperty("transaction.timeout.ms",60000*15+"");
//第二种解决方案,设置kafka的最大事务超时时间
//FlinkKafkaProducer011<String> myProducer = new FlinkKafkaProducer011<>(brokerList, topic, new SimpleStringSchema());
//使用仅一次语义的kafkaProducer
FlinkKafkaProducer011
<
String
>
myProducer
=
new
FlinkKafkaProducer011
<
String
>(
topic
,
new
KeyedSerializationSchemaWrapper
<
String
>(
new
SimpleStringSchema
()),
prop
,
FlinkKafkaProducer011
.
Semantic
.
EXACTLY_ONCE
);
text
.
addSink
(
myProducer
);
env
.
execute
(
"BL_ET_MG_PRECISEEXPOSURE_INC_D_RT"
);
}
}
src/test/java/com/gmei/sink/MlPreciseExposureMysqlSinkTest.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
sink
;
import
com.gmei.bean.bl.BlPreciseExposureBean
;
import
com.gmei.bean.ml.MlPreciseExposureBean
;
import
com.gmei.cache.MlPreciseExposureDao
;
import
com.gmei.function.BlPreciseExposureMapFunction
;
import
com.gmei.function.MlpreciseExposureFlatMapFunction
;
import
com.gmei.jdbc.MysqlJdbcSink
;
import
org.junit.Test
;
import
java.util.ArrayList
;
public
class
MlPreciseExposureMysqlSinkTest
{
@Test
public
void
mlMysqlSinkTest
()
{
String
sinkJdbcUrl
=
""
;
String
sinkTableName
=
""
;
String
json
=
"{\"create_at\":\"1575135041\",\"gm_nginx_timestamp\":1575135040.498,\"user_id\":\"\",\"version\":\"147\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":6,\"is_exposure\":\"1\",\"exposure_cards\":[{\"absolute_position\":0,\"relative_position\":0,\"card_type\":\"card\",\"wiki_word\":[\"项目档案:1\",\"手术锦囊:2\",\"相近项目:3\"],\"card_content_type\":\"qa\",\"card_id\":\"7\"},{\"cpc_referer\":\"1\",\"relative_position\":0,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":0,\"card_content_type\":\"answer\",\"card_id\":\"684889\"},{\"cpc_referer\":\"1\",\"relative_position\":1,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":1,\"card_content_type\":\"answer\",\"card_id\":\"692624\"},{\"cpc_referer\":\"1\",\"relative_position\":2,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":2,\"card_content_type\":\"user_post\",\"card_id\":66263},{\"cpc_referer\":\"1\",\"relative_position\":3,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":3,\"card_content_type\":\"user_post\",\"card_id\":70670},{\"cpc_referer\":\"1\",\"relative_position\":4,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":4,\"card_content_type\":\"diary\",\"card_id\":15329391},{\"cpc_referer\":\"1\",\"relative_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":5,\"card_content_type\":\"article\",\"card_id\":\"19507071\"},{\"cpc_referer\":\"1\",\"relative_position\":5,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":6,\"card_content_type\":\"answer\",\"card_id\":\"518138\"},{\"cpc_referer\":\"1\",\"relative_position\":4,\"transaction_type\":\"\",\"card_type\":\"card\",\"absolute_position\":7,\"card_content_type\":\"answer\",\"card_id\":\"684319\"},{\"cpc_referer\":\"1\",\"relative_position\":5,\"is_cpc\":0,\"transaction_type\":\"-1\",\"card_type\":\"card\",\"absolute_position\":8,\"card_content_type\":\"user_post\",\"card_id\":69002}],\"tab_name\":\"综合\",\"down_slide_times\":0,\"query\":\"纹眉\",\"filter\":\"\",\"referrer_id\":\"\",\"referrer\":\"search_home\",\"up_loading_times\":0,\"business_id\":\"\",\"page_name\":\"search_result_more\"},\"app_session_id\":\"424bcbcf-3b6e-4331-89b3-9fcd0c7bfbaf\",\"app\":{\"version\":\"7.18.4\",\"grey_type\":\"{\\\"video_steep\\\":1,\\\"post_detail\\\":\\\"0\\\",\\\"face_detect_result\\\":\\\"B\\\",\\\"home\\\":\\\"0\\\",\\\"face_scan\\\":0,\\\"report_result\\\":0}\",\"current_city_id\":\"chongqing\",\"user_type\":{\"config_type\":\"1\"},\"name\":\"gengmei_user\",\"serial_id\":35,\"channel\":\"huawei\"},\"gm_nginx_key\":1,\"device\":{\"android_device_id\":\"androidid_b49fb6a87b10bad0\",\"sys_version\":\"9\",\"lng\":\"106.618722\",\"is_WiFi\":\"0\",\"lat\":\"29.720561\",\"device_id\":\"861198041466947\",\"manufacturer\":\"HUAWEI\",\"net_type\":\"4G\",\"device_type\":\"android\",\"ip\":\"192.168.3.3\",\"model\":\"LYA-AL00\"},\"type\":\"page_precise_exposure\"}"
;
// String json = "{\"create_at\":\"1576347089\",\"gm_nginx_timestamp\":1576347089.299,\"user_id\":\"31961883\",\"version\":\"110\",\"params\":{\"down_loading_times\":0,\"up_slide_times\":5,\"exposure_cards\":{},\"tab_name\":\"service\",\"down_slide_times\":1,\"page_name\":\"category\",\"up_loading_times\":1,\"is_exposure\":\"1\",\"referrer\":\"home\",\"business_id\":\"9\",\"filter\":\"智能排序\",\"referrer_id\":\"\"},\"app_session_id\":\"0092AC31-EF72-44FF-AE1E-8BB6F8448A08\",\"app\":{\"version\":\"7.19.1\",\"grey_type\":\"{\\n \\\"report_result\\\" : 0,\\n \\\"face_detect_result\\\" : \\\"B\\\",\\n \\\"home\\\" : \\\"0\\\",\\n \\\"post_detail\\\" : \\\"0\\\",\\n \\\"video_steep\\\" : 0,\\n \\\"face_scan\\\" : 0\\n}\",\"current_city_id\":\"liuan\",\"name\":\"gengmei_user\",\"user_type\":{\"config_type\":1},\"serial_id\":28,\"channel\":\"App Store\"},\"gm_nginx_key\":1,\"device\":{\"idfv\":\"51E1C5FD-B710-4820-91A6-E54C77AA4C60\",\"sys_version\":\"12.4.1\",\"lng\":116.48697900811,\"is_WiFi\":\"1\",\"manufacturer\":\"Apple\",\"device_id\":\"CD1187A7-091C-4497-96A3-A716BE510905\",\"device_type\":\"ios\",\"ip\":\"192.168.0.101\",\"idfa\":\"CD1187A7-091C-4497-96A3-A716BE510905\",\"lat\":31.757989657248,\"model\":\"iPhone10,1\"},\"type\":\"page_precise_exposure\"}";
// String json = "{\"app\":{\"user_type\":{\"config_type\":1},\"serial_id\":5,\"name\":\"gengmei_user\",\"channel\":\"App Store\",\"version\":\"7.7.40\",\"current_city_id\":\"beijin\n" +
// "g\"},\"app_session_id\":\"805E7CE4-0FB1-44E1-B32F-837B62D11D91\",\"gm_nginx_timestamp\":1576347092.686,\"user_id\":\"29105318\",\"gm_nginx_key\":1,\"creat\n" +
// "e_at\":\"1576347092\",\"params\":{\"exposure_cards\":{ },\"referrer\":\"\",\"referrer_id\":\"\",\"up_slide_times\":0,\"down_loading_times\":0,\"page_name\":\"home\"\n" +
// ",\"tab_name\":\"精选\",\"business_id\":\"\",\"up_loading_times\":0,\"down_slide_times\":0,\"is_exposure\":1},\"type\":\"home_choiceness_card_exposure\",\"versi\n" +
// "on\":\"110\",\"device\":{\"lng\":116.25638817524,\"device_id\":\"00DB1D03-3116-4084-AD86-0596EDFA2E3D\",\"is_WiFi\":\"1\",\"ip\":\"10.10.62.107\",\"idfa\":\"00DB1\n" +
// "D03-3116-4084-AD86-0596EDFA2E3D\",\"idfv\":\"1E6E56F7-3E3C-4F62-83EB-E9DBE7BC1AD1\",\"device_type\":\"ios\",\"lat\":40.073574956895,\"manufacturer\":\"Apple\"}}";
BlPreciseExposureMapFunction
blPreciseExposureMapFunction
=
new
BlPreciseExposureMapFunction
();
MlpreciseExposureFlatMapFunction
mlpreciseExposureFlatMapFunction
=
new
MlpreciseExposureFlatMapFunction
();
BlPreciseExposureBean
blPreciseExposureBean
=
null
;
MysqlJdbcSink
mysqlJdbcSink
=
MysqlJdbcSink
.
getInstance
(
sinkJdbcUrl
);
MlPreciseExposureDao
mlPreciseExposureDao
=
new
MlPreciseExposureDao
(
sinkJdbcUrl
,
sinkTableName
);
try
{
blPreciseExposureBean
=
blPreciseExposureMapFunction
.
map
(
json
);
// conn = mysqlJdbcSink.getConnection();
// conn.setAutoCommit(false);
ArrayList
<
MlPreciseExposureBean
>
mlPreciseExposureBeanArrayList
=
mlpreciseExposureFlatMapFunction
.
flatmapBlPreciseExposure
(
blPreciseExposureBean
);
for
(
MlPreciseExposureBean
mlPreciseExposureBean
:
mlPreciseExposureBeanArrayList
)
{
mlPreciseExposureDao
.
insertMlPreciseExposure
(
mlPreciseExposureBean
);
}
// conn.commit();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
src/test/java/com/gmei/source/BlMaiDianKafkaSourceTest.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
source
;
import
org.apache.flink.api.common.serialization.SimpleStringSchema
;
import
org.apache.flink.streaming.api.datastream.DataStreamSource
;
import
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
;
import
org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer011
;
import
java.util.Properties
;
public
class
BlMaiDianKafkaSourceTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
//获取Flink的运行环境
StreamExecutionEnvironment
env
=
StreamExecutionEnvironment
.
getExecutionEnvironment
();
// //checkpoint配置
// env.enableCheckpointing(5000);
// env.getCheckpointConfig().setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE);
// env.getCheckpointConfig().setMinPauseBetweenCheckpoints(500);
// env.getCheckpointConfig().setCheckpointTimeout(60000);
// env.getCheckpointConfig().setMaxConcurrentCheckpoints(1);
// env.getCheckpointConfig().enableExternalizedCheckpoints(CheckpointConfig.ExternalizedCheckpointCleanup.RETAIN_ON_CANCELLATION);
//
// //设置statebackend
//
// env.setStateBackend(new Sta("file:///Users/mac/opt/flink/checkpoints",true));
String
topicName
=
"test"
;
String
groupId
=
"group1"
;
//构造java.util.Properties对象
Properties
props
=
new
Properties
();
// 必须指定属性。
props
.
put
(
"bootstrap.servers"
,
"localhost:9092"
);
// 必须指定属性。
props
.
put
(
"group.id"
,
groupId
);
props
.
put
(
"enable.auto.commit"
,
"true"
);
props
.
put
(
"auto.commit.interval.ms"
,
"1000"
);
// 从最早的消息开始读取
// props.put("auto.offset.reset", "earliest");
props
.
put
(
"auto.offset.reset"
,
"latest"
);
// 必须指定
props
.
put
(
"key.deserializer"
,
"org.apache.kafka.common.serialization.StringDeserializer"
);
// 必须指定
props
.
put
(
"value.deserializer"
,
"org.apache.kafka.common.serialization.StringDeserializer"
);
// FlinkKafkaConsumer011<ObjectNode> MyConsumer = new FlinkKafkaConsumer011<ObjectNode>(topicName, new JSONDeserializationSchema(), props);
FlinkKafkaConsumer011
<
String
>
myConsumer
=
new
FlinkKafkaConsumer011
<
String
>(
topicName
,
new
SimpleStringSchema
(),
props
);
myConsumer
.
setStartFromGroupOffsets
();
//默认消费策略
DataStreamSource
<
String
>
text
=
env
.
addSource
(
myConsumer
);
text
.
print
().
setParallelism
(
1
);
env
.
execute
(
"BL_ET_MG_PRECISEEXPOSURE_INC_D_RT"
);
}
}
src/test/java/com/gmei/utils/BeanReflectUtilTest.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
utils
;
import
com.gmei.bean.bl.BlPreciseExposureParamsExposureCardsBean
;
import
org.junit.Test
;
public
class
BeanReflectUtilTest
{
@Test
public
void
setNullValueTest
()
{
BlPreciseExposureParamsExposureCardsBean
cardBean
=
new
BlPreciseExposureParamsExposureCardsBean
(
"123"
,
"diary"
,
"card"
,
""
,
null
,
null
,
"1"
,
"2"
);
try
{
BeanReflectUtil
.
setNullValue
(
cardBean
);
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
cardBean
);
}
@Test
public
void
setFieldValueTest
()
{
BlPreciseExposureParamsExposureCardsBean
cardBean
=
new
BlPreciseExposureParamsExposureCardsBean
(
"123"
,
"diary"
,
"card"
,
""
,
null
,
null
,
"1"
,
"2"
);
BeanReflectUtil
.
setFieldValue
(
cardBean
,
"transaction_type"
,
"-1"
);
System
.
out
.
println
(
cardBean
);
}
@Test
public
void
getFieldValueTest
()
throws
Exception
{
BlPreciseExposureParamsExposureCardsBean
cardBean
=
new
BlPreciseExposureParamsExposureCardsBean
(
"123"
,
"diary"
,
"card"
,
""
,
null
,
null
,
"1"
,
"2"
);
String
transaction_type
=
(
String
)
BeanReflectUtil
.
getFieldValue
(
cardBean
,
"card_type"
);
System
.
out
.
println
(
transaction_type
);
}
}
src/test/java/com/gmei/utils/DateUtilTest.java
0 → 100644
View file @
e15a2105
package
com
.
gmei
.
utils
;
import
org.junit.Test
;
public
class
DateUtilTest
{
@Test
public
void
timestamp2StringTest
()
{
String
timestamp
=
"1576347089.299"
;
String
timestampYMD
=
DateUtil
.
timestampFormat
(
timestamp
,
DateUtil
.
DateType
.
SECOND
);
String
timestampY
=
DateUtil
.
timestampFormat
(
timestamp
,
DateUtil
.
DateType
.
DAY
);
System
.
out
.
println
(
timestampYMD
);
System
.
out
.
println
(
timestampY
);
}
}
\ 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