add workflow 荟聚API_2,dev

This commit is contained in:
root 2024-06-06 14:32:05 +08:00
parent a1073b69f1
commit 500e6fec83
3 changed files with 79 additions and 82 deletions

View File

@ -7,7 +7,7 @@ CREATE TABLE IF NOT EXISTS p30_common.d_scrm_contact (
, email VARCHAR(50)
, email_data_ind char(1)
, email_availability char(1)
, mobile_number VARCHAR(20)
, mobile_phone VARCHAR(20)
, mobile_phone_data_ind char(1)
, mobile_phone_availability char(1)
, full_name VARCHAR(20)
@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS p30_common.d_scrm_contact (
COMMENT ON COLUMN p30_common.d_scrm_contact.email IS '邮箱';
COMMENT ON COLUMN p30_common.d_scrm_contact.email_data_ind IS '邮箱数据标志';
COMMENT ON COLUMN p30_common.d_scrm_contact.email_availability IS '邮箱有效性';
COMMENT ON COLUMN p30_common.d_scrm_contact.mobile_number IS '手机号码';
COMMENT ON COLUMN p30_common.d_scrm_contact.mobile_phone IS '手机号码';
COMMENT ON COLUMN p30_common.d_scrm_contact.mobile_phone_data_ind IS '手机号数据标志';
COMMENT ON COLUMN p30_common.d_scrm_contact.mobile_phone_availability IS '手机号数据有效性';
COMMENT ON COLUMN p30_common.d_scrm_contact.full_name IS '姓名';

View File

@ -4,18 +4,18 @@
/*Brilliance stems from wisdoms. */
/*************Head Section**************************************************************************/
/*Script Use: Periodically load data to :d_scrm_contact(SCRM联系方式) */
/*Create Date:2024-05-06 14:06:46 */
/*Create Date:2024-06-06 14:19:20 */
/*SDM Developed By: dev */
/*SDM Developed Date: 2024-01-18 */
/*SDM Checked By: dev */
/*SDM Checked Date: 2024-05-06 */
/*SDM Checked Date: 2024-06-06 */
/*Script Developed By: dev */
/*Script Checked By: dev */
/*Source table 1: .t01_scrm_contact_his */
/*Source table 1: :PDMDB.t01_scrm_contact_merge */
/*Source table 2: :SADB.select distinct on (scrm_leads_id) * from p20_pdm.t01_scrm_contact_update tscu
order by scrm_leads_id,update_time desc*/
/*Source table 3: p20_pdm.t01_scrm_contact */
/*Source table 4: :SADB.t01_scrm_contact_merge */
/*Source table 4: :PDMDB.t01_scrm_contact_his */
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
/*Target Table:d_scrm_contact */
/*ETL Job Name:d_scrm_contact */
@ -43,66 +43,7 @@ ON COMMIT PRESERVE ROWS;
/*****************************************************************************************************/
/* GROUP 1:Source Table:t01_scrm_contact_his**********************************************************/
/*****************************************************************************************************/
INSERT INTO d_scrm_contact_agi_CUR_I (
scrm_leads_id /*SCRM线索ID*/
,city_name /*城市*/
,company_name /*公司*/
,email /*邮箱*/
,email_data_ind /*邮箱数据标志*/
,email_availability /*邮箱有效性*/
,mobile_number /*手机号码*/
,mobile_phone_data_ind /*手机号数据标志*/
,mobile_phone_availability /*手机号数据有效性*/
,full_name /*姓名*/
,prov_name /*省份*/
,create_time /*创建时间*/
,wechat_id /*身份-企业微信外部联系人*/
,update_time /*更新时间*/
,Etl_Batch_No /*作业批次号*/
,Etl_First_Dt /*最初入库时间*/
,Etl_Job /*作业名称*/
,Etl_Proc_Dt /*本次入库时间*/
,Etl_Tx_Dt /*作业运行时间*/
,Src_Sysname /*来源系统*/
,Src_Table /*来源表*/
)
SELECT
COALESCE(TRIM(p0.scrm_leads_id),'') /*scrm_leads_id*/
,coalesce(p1.city_name,p0.city_name) /*city_name*/
,coalesce(p1.company_name,p0.company_name) /*company_name*/
,coalesce(p1.email,p0.email) /*email*/
,case when length(coalesce(p1.email,p0.email))>1 then '1' else 0 end /*email_data_ind*/
,case when coalesce(p1.email,p0.email) ~ '[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$' and length(coalesce(p1.email,p0.email))>10 then '1'
else '0' end /*email_availability*/
,coalesce(p1.mobile_number,p0.mobile_number,'') /*mobile_number*/
,case when length(coalesce(p1.mobile_number,p0.mobile_number))>1 then '1' else 0 end /*mobile_phone_data_ind*/
,case when coalesce(p1.mobile_number,p0.mobile_number) ~ '^1[3-9]\d{9}$' then '1'
else '0' end /*mobile_phone_availability*/
,coalesce(p1.full_name,p0.full_name,'') /*full_name*/
,coalesce(p1.prov_name,p0.prov_name) /*prov_name*/
,COALESCE(p0.create_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*create_time*/
,coalesce(p1.wechat_id,p0.wechat_id) /*wechat_id*/
,COALESCE(p0.update_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*update_time*/
,0 /*Etl_Batch_No*/
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_First_Dt*/
,:ETLJOB /*Etl_Job*/
,current_timestamp(0) /*Etl_Proc_Dt*/
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_Tx_Dt*/
,Substr('t01_scrm_contact_his',1,3) /*Src_Sysname*/
,'t01_scrm_contact_his' /*Src_Table*/
FROM None.t01_scrm_contact_his p0
LEFT JOIN (select distinct on (scrm_leads_id) * from p20_pdm.t01_scrm_contact_update tscu
order by scrm_leads_id,update_time desc) p1
ON p0 .scrm_leads_id =p1 .scrm_leads_id
;
/*****************************************************************************************************/
/* GROUP 2:Source Table:t01_scrm_contact**************************************************************/
/* GROUP 1:Source Table:t01_scrm_contact**************************************************************/
/*****************************************************************************************************/
INSERT INTO d_scrm_contact_agi_CUR_I (
@ -112,7 +53,7 @@ INSERT INTO d_scrm_contact_agi_CUR_I (
,email /*邮箱*/
,email_data_ind /*邮箱数据标志*/
,email_availability /*邮箱有效性*/
,mobile_number /*手机号码*/
,mobile_phone /*手机号码*/
,mobile_phone_data_ind /*手机号数据标志*/
,mobile_phone_availability /*手机号数据有效性*/
,full_name /*姓名*/
@ -136,7 +77,7 @@ SELECT
,case when length(p0.email)>1 then '1' else 0 end /*email_data_ind*/
,case when p0.email ~ '[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$' and length(p0.email)>10 then '1'
else '0' end /*email_availability*/
,replace(p0.mobile_number,'.0','') /*mobile_number*/
,replace(p0.mobile_number,'.0','') /*mobile_phone*/
,case when length(replace(p0.mobile_number,'.0',''))>1 then '1' else 0 end /*mobile_phone_data_ind*/
,case when replace(p0.mobile_number,'.0','') ~ '^1[3-9]\d{9}$' then '1'
else '0' end /*mobile_phone_availability*/
@ -154,7 +95,7 @@ SELECT
,'t01_scrm_contact' /*Src_Table*/
FROM p20_pdm.t01_scrm_contact p0
LEFT JOIN :SADB.t01_scrm_contact_merge p1
LEFT JOIN :PDMDB.t01_scrm_contact_merge p1
ON p0.scrm_leads_id =p1.merged_leads_id
where p1.scrm_leads_id is null
@ -162,6 +103,65 @@ where p1.scrm_leads_id is null
/*****************************************************************************************************/
/* GROUP 2:Source Table:t01_scrm_contact_his**********************************************************/
/*****************************************************************************************************/
INSERT INTO d_scrm_contact_agi_CUR_I (
scrm_leads_id /*SCRM线索ID*/
,city_name /*城市*/
,company_name /*公司*/
,email /*邮箱*/
,email_data_ind /*邮箱数据标志*/
,email_availability /*邮箱有效性*/
,mobile_phone /*手机号码*/
,mobile_phone_data_ind /*手机号数据标志*/
,mobile_phone_availability /*手机号数据有效性*/
,full_name /*姓名*/
,prov_name /*省份*/
,create_time /*创建时间*/
,wechat_id /*身份-企业微信外部联系人*/
,update_time /*更新时间*/
,Etl_Batch_No /*作业批次号*/
,Etl_First_Dt /*最初入库时间*/
,Etl_Job /*作业名称*/
,Etl_Proc_Dt /*本次入库时间*/
,Etl_Tx_Dt /*作业运行时间*/
,Src_Sysname /*来源系统*/
,Src_Table /*来源表*/
)
SELECT
COALESCE(TRIM(p0.scrm_leads_id),'') /*scrm_leads_id*/
,coalesce(p1.city_name,p0.city_name) /*city_name*/
,coalesce(p1.company_name,p0.company_name) /*company_name*/
,coalesce(p1.email,p0.email) /*email*/
,case when length(coalesce(p1.email,p0.email))>1 then '1' else 0 end /*email_data_ind*/
,case when coalesce(p1.email,p0.email) ~ '[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$' and length(coalesce(p1.email,p0.email))>10 then '1'
else '0' end /*email_availability*/
,coalesce(p1.mobile_number,p0.mobile_number,'') /*mobile_phone*/
,case when length(coalesce(p1.mobile_number,p0.mobile_number))>1 then '1' else 0 end /*mobile_phone_data_ind*/
,case when coalesce(p1.mobile_number,p0.mobile_number) ~ '^1[3-9]\d{9}$' then '1'
else '0' end /*mobile_phone_availability*/
,coalesce(p1.full_name,p0.full_name,'') /*full_name*/
,coalesce(p1.prov_name,p0.prov_name) /*prov_name*/
,COALESCE(p0.create_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*create_time*/
,coalesce(p1.wechat_id,p0.wechat_id) /*wechat_id*/
,COALESCE(p0.last_update_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*update_time*/
,0 /*Etl_Batch_No*/
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_First_Dt*/
,:ETLJOB /*Etl_Job*/
,current_timestamp(0) /*Etl_Proc_Dt*/
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_Tx_Dt*/
,Substr('t01_scrm_contact_his',1,3) /*Src_Sysname*/
,'t01_scrm_contact_his' /*Src_Table*/
FROM :PDMDB.t01_scrm_contact_his p0
LEFT JOIN (select distinct on (scrm_leads_id) * from p20_pdm.t01_scrm_contact_update tscu
order by scrm_leads_id,update_time desc) p1
ON p0 .scrm_leads_id =p1 .scrm_leads_id
;
/*将不同数据插入到临时表 */
;INSERT INTO d_scrm_contact_agi_INS (
city_name /*城市*/
@ -169,7 +169,7 @@ where p1.scrm_leads_id is null
,email /*邮箱*/
,email_data_ind /*邮箱数据标志*/
,email_availability /*邮箱有效性*/
,mobile_number /*手机号码*/
,mobile_phone /*手机号码*/
,mobile_phone_data_ind /*手机号数据标志*/
,mobile_phone_availability /*手机号数据有效性*/
,full_name /*姓名*/
@ -193,7 +193,7 @@ where p1.scrm_leads_id is null
,P1.email /*邮箱*/
,P1.email_data_ind /*邮箱数据标志*/
,P1.email_availability /*邮箱有效性*/
,P1.mobile_number /*手机号码*/
,P1.mobile_phone /*手机号码*/
,P1.mobile_phone_data_ind /*手机号数据标志*/
,P1.mobile_phone_availability /*手机号数据有效性*/
,P1.full_name /*姓名*/
@ -217,7 +217,7 @@ ON P1.city_name = P2.city_name
AND P1.email = P2.email
AND P1.email_data_ind = P2.email_data_ind
AND P1.email_availability = P2.email_availability
AND P1.mobile_number = P2.mobile_number
AND P1.mobile_phone = P2.mobile_phone
AND P1.mobile_phone_data_ind = P2.mobile_phone_data_ind
AND P1.mobile_phone_availability = P2.mobile_phone_availability
AND P1.full_name = P2.full_name
@ -232,7 +232,7 @@ WHERE P2.city_name IS NULL
OR P2.email IS NULL
OR P2.email_data_ind IS NULL
OR P2.email_availability IS NULL
OR P2.mobile_number IS NULL
OR P2.mobile_phone IS NULL
OR P2.mobile_phone_data_ind IS NULL
OR P2.mobile_phone_availability IS NULL
OR P2.full_name IS NULL
@ -250,7 +250,7 @@ WHERE P2.city_name IS NULL
,email /*邮箱*/
,email_data_ind /*邮箱数据标志*/
,email_availability /*邮箱有效性*/
,mobile_number /*手机号码*/
,mobile_phone /*手机号码*/
,mobile_phone_data_ind /*手机号数据标志*/
,mobile_phone_availability /*手机号数据有效性*/
,full_name /*姓名*/
@ -274,7 +274,7 @@ SELECT
,P1.email /*邮箱*/
,P1.email_data_ind /*邮箱数据标志*/
,P1.email_availability /*邮箱有效性*/
,P1.mobile_number /*手机号码*/
,P1.mobile_phone /*手机号码*/
,P1.mobile_phone_data_ind /*手机号数据标志*/
,P1.mobile_phone_availability /*手机号数据有效性*/
,P1.full_name /*姓名*/
@ -300,7 +300,7 @@ DO UPDATE SET
,email=excluded.email
,email_data_ind=excluded.email_data_ind
,email_availability=excluded.email_availability
,mobile_number=excluded.mobile_number
,mobile_phone=excluded.mobile_phone
,mobile_phone_data_ind=excluded.mobile_phone_data_ind
,mobile_phone_availability=excluded.mobile_phone_availability
,full_name=excluded.full_name

View File

@ -4,18 +4,17 @@
/*Brilliance stems from wisdoms. */
/*************Head Section**************************************************************************/
/*Script Use: Periodically load data to :cust_contact_info(客户联系信息) */
/*Create Date:2024-05-13 13:59:03 */
/*Create Date:2024-06-04 16:44:29 */
/*SDM Developed By: dev */
/*SDM Developed Date: 2024-01-19 */
/*SDM Checked By: dev */
/*SDM Checked Date: 2024-05-13 */
/*SDM Checked Date: 2024-06-04 */
/*Script Developed By: dev */
/*Script Checked By: dev */
/*Source table 1: :PDMDB.t01_crm_account */
/*Source table 2: :PDMDB.t00_china_city_info */
/*Source table 3: p30_common.cust_contact_mapping */
/*Source table 4: :PDMDB.t01_crm_cust_ccp */
/*Source table 5: :PDMDB.t00_country_info */
/*Source table 4: :PDMDB.t00_country_info */
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
/*Target Table:cust_contact_info */
/*ETL Job Name:cust_contact_info */
@ -210,8 +209,6 @@ LEFT JOIN :PDMDB.t00_country_info p3
ON upper(p1.country)=upper(p3.country_en_name)
LEFT JOIN :PDMDB.t00_country_info p4
ON upper(p1.country)=upper(p4.country_cd)
LEFT JOIN :PDMDB.t01_crm_cust_ccp p5
ON p1.crm_contact =p5.crm_contact_account
LEFT JOIN :PDMDB.t01_crm_account p6
ON p1.crm_account =p6.accountnumber