1. 數(shù)據(jù)時序
數(shù)據(jù)時序圖
- 通過CK接管MySQL業(yè)務庫數(shù)據(jù)。
- 使用XXL-JOB作為調度工具,通過SHELL腳本做ETL操作,在CK中建立數(shù)倉模型,最終結果表反寫到MySQL報表庫中插爹。
- 報表平臺通過Dataway創(chuàng)建接口哄辣,給前端提供數(shù)據(jù)请梢。
2. 使用教程
2.1. CK入門
官方文檔非常詳細:https://clickhouse.com/docs/zh
2.1.1. 接管業(yè)務庫
- 使用MySQL引擎創(chuàng)建xuanfb_user_sales庫
CREATE DATABASE IF NOT EXISTS xuanfb_user_sales
ENGINE = MySQL('127.0.0.1:3306', 'xuanfb_user_sales', 'test_rw', '123456');
2.驗證結果
select * from xuanfb_user_sales.ztc_clue;
通過CK查詢MySQL數(shù)據(jù)庫
2.1.2.建庫建表
1.創(chuàng)建testdb庫
CREATE DATABASE IF NOT EXISTS testdb
2.創(chuàng)建dwd_customer表
CREATE TABLE testdb.dwd_customer
(
`clue_id` String,
`NicheUUID` String,
`project_id` String,
`name` String,
`mobile` Nullable(String),
`referrer_account_id` Nullable(String),
`referrer_name` Nullable(String),
`counselor_user_id` Nullable(String),
`counselor_name` Nullable(String),
`create_time` DateTime
)
ENGINE = ReplacingMergeTree(create_time)
ORDER BY (clue_id,NicheUUID)
SETTINGS index_granularity = 8192;
創(chuàng)建庫表
2.1.3.手工ETL
1.初始化數(shù)據(jù)
insert into testdb.dwd_customer (clue_id,NicheUUID,project_id,name,mobile,referrer_account_id,referrer_name,counselor_user_id,counselor_name,create_time)
select zc.clue_id,NicheUUID,zc.project_id,zc.name,mobile,zc.referrer_account_id,zc.referrer_name,zc.counselor_user_id,zc.counselor_name,zc.create_time
from xuanfb_user_sales.ztc_clue zc left join xuanfb_user_sales.m_niche mn on zc.clue_id = mn.LeadUUID ;
查看數(shù)據(jù)
2.1.4.調度工具
統(tǒng)一使用xxl-job進行調度。官方參考文檔:https://www.xuxueli.com/xxl-job/
-
新建調度任務
新建任務
2.編輯調度腳本
打開腳本編輯器
添加Shell腳本
2.2. Dataway入門
官方參考文檔:https://www.hasor.net/
2.2.1. 后臺管理
地址:http://localhost:8080/report-center/interface-ui/#/
Dataway后臺管理
2.2.2.編寫UDF函數(shù)
/**
* @description: 數(shù)據(jù)權限-測試
* @author: Dreamson.Ma
* @create: 2022-08-22 21:30
**/
@Slf4j
@Component
@DimUdf("dpUdf")
public class DpUdf implements Udf {
@Resource
private UserTokenService userTokenService;
@Override
public Object call(Hints hints, Object... objects) {
log.info("當前用戶信息:{}", userTokenService.getUser());
return "2";
}
}
2.2.3.編寫DataSQL
hint FRAGMENT_SQL_QUERY_BY_PAGE = true
hint FRAGMENT_SQL_QUERY_BY_PAGE_NUMBER_OFFSET = 1
var dataFun = @@sql(ownerType) <%
select
owner_name as ownerName,
card_id as cardId,
(case gender
when 0 then '一手業(yè)主'
when 1 then '二手業(yè)主'
when 2 then '一手/二手業(yè)主'
end) as gender
from owner_profile where owner_type = #{ownerType}
and card_id is not null
%>
var queryPage = dataFun(dpUdf());
run queryPage.setPageInfo({
"pageSize" : 5, // 頁大小
"currentPage" : 1 // 第3頁
});
return {
"pageInfo": queryPage.pageInfo(),
"pageData": queryPage.data()
}
2.2.4.測試力穗、冒煙毅弧、發(fā)布
Dataway測試、冒煙当窗、發(fā)布