add workflow 天润Smart-ccc会话数据,dev
This commit is contained in:
parent
870803e6ad
commit
c0369ff3ff
|
@ -2,10 +2,13 @@
|
||||||
DROP TABLE IF EXISTS p60_mart.cust_chat_record_info;
|
DROP TABLE IF EXISTS p60_mart.cust_chat_record_info;
|
||||||
CREATE TABLE IF NOT EXISTS p60_mart.cust_chat_record_info (
|
CREATE TABLE IF NOT EXISTS p60_mart.cust_chat_record_info (
|
||||||
chat_unique_id VARCHAR(50)
|
chat_unique_id VARCHAR(50)
|
||||||
|
, platform_name varchar(50)
|
||||||
, contact_channel VARCHAR(10)
|
, contact_channel VARCHAR(10)
|
||||||
, contact_app_id VARCHAR(50)
|
, contact_app_id VARCHAR(50)
|
||||||
, app_name VARCHAR(50)
|
, app_name VARCHAR(50)
|
||||||
, queue_name VARCHAR(10)
|
, group_name varchar(50)
|
||||||
|
, queue_name VARCHAR(100)
|
||||||
|
, service_name varchar(50)
|
||||||
, start_time timestamp(0)
|
, start_time timestamp(0)
|
||||||
, end_time timestamp(0)
|
, end_time timestamp(0)
|
||||||
, chat_duration_in_seconds int4
|
, chat_duration_in_seconds int4
|
||||||
|
@ -17,6 +20,9 @@ CREATE TABLE IF NOT EXISTS p60_mart.cust_chat_record_info (
|
||||||
, visitor_mobile varchar(20)
|
, visitor_mobile varchar(20)
|
||||||
, visitor_email varchar(100)
|
, visitor_email varchar(100)
|
||||||
, visitor_company varchar(50)
|
, visitor_company varchar(50)
|
||||||
|
, tag_1 varchar(100)
|
||||||
|
, tag_2 varchar(100)
|
||||||
|
, tag_3 varchar(100)
|
||||||
, Etl_Batch_No varchar(50)
|
, Etl_Batch_No varchar(50)
|
||||||
, Etl_First_Dt timestamp(0)
|
, Etl_First_Dt timestamp(0)
|
||||||
, Etl_Job varchar(200)
|
, Etl_Job varchar(200)
|
||||||
|
@ -28,10 +34,13 @@ CREATE TABLE IF NOT EXISTS p60_mart.cust_chat_record_info (
|
||||||
);
|
);
|
||||||
|
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.chat_unique_id IS '在线客服会话ID';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.chat_unique_id IS '在线客服会话ID';
|
||||||
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.platform_name IS '平台';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.contact_channel IS '接入渠道';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.contact_channel IS '接入渠道';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.contact_app_id IS '接入号ID';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.contact_app_id IS '接入号ID';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.app_name IS '接入号名称';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.app_name IS '接入号名称';
|
||||||
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.group_name IS '分组';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.queue_name IS '队列名称';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.queue_name IS '队列名称';
|
||||||
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.service_name IS '服务';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.start_time IS '会话开始时间戳';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.start_time IS '会话开始时间戳';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.end_time IS '会话结束时间戳';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.end_time IS '会话结束时间戳';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.chat_duration_in_seconds IS '会话持续时间';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.chat_duration_in_seconds IS '会话持续时间';
|
||||||
|
@ -43,6 +52,9 @@ CREATE TABLE IF NOT EXISTS p60_mart.cust_chat_record_info (
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.visitor_mobile IS '访客手机';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.visitor_mobile IS '访客手机';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.visitor_email IS '访客邮箱';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.visitor_email IS '访客邮箱';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.visitor_company IS '访客公司';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.visitor_company IS '访客公司';
|
||||||
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.tag_1 IS '标签1';
|
||||||
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.tag_2 IS '标签2';
|
||||||
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.tag_3 IS '标签3';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Etl_Batch_No IS '作业批次号';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Etl_Batch_No IS '作业批次号';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Etl_First_Dt IS '最初入库时间';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Etl_First_Dt IS '最初入库时间';
|
||||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Etl_Job IS '作业名称';
|
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Etl_Job IS '作业名称';
|
||||||
|
|
|
@ -4,16 +4,19 @@
|
||||||
/*Brilliance stems from wisdoms. */
|
/*Brilliance stems from wisdoms. */
|
||||||
/*************Head Section**************************************************************************/
|
/*************Head Section**************************************************************************/
|
||||||
/*Script Use: Periodically load data to :cust_chat_record_info(ccc客户会话记录信息) */
|
/*Script Use: Periodically load data to :cust_chat_record_info(ccc客户会话记录信息) */
|
||||||
/*Create Date:2024-08-14 16:19:43 */
|
/*Create Date:2024-08-20 17:51:48 */
|
||||||
/*SDM Developed By: dev */
|
/*SDM Developed By: dev */
|
||||||
/*SDM Developed Date: 2024-08-14 */
|
/*SDM Developed Date: 2024-08-14 */
|
||||||
/*SDM Checked By: dev */
|
/*SDM Checked By: dev */
|
||||||
/*SDM Checked Date: 2024-08-14 */
|
/*SDM Checked Date: 2024-08-20 */
|
||||||
/*Script Developed By: dev */
|
/*Script Developed By: dev */
|
||||||
/*Script Checked By: dev */
|
/*Script Checked By: dev */
|
||||||
/*Source table 1: :COMMDB.select replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') as visitor_id ,row_number() over(partition by replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') order by id desc) rn ,* from p30_common.d_ccc_cust_info dcci
|
/*Source table 1: :COMMDB.cust_leads_detail */
|
||||||
|
/*Source table 2: :COMMDB.select replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') as visitor_id ,row_number() over(partition by replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') order by id desc) rn ,* from p30_common.d_ccc_cust_info dcci
|
||||||
where visitor_ids <>''*/
|
where visitor_ids <>''*/
|
||||||
/*Source table 2: :COMMDB.cust_chat_ccc_record */
|
/*Source table 3: :PDMDB.t01_livechat_record */
|
||||||
|
/*Source table 4: :PDMDB.t99_ccc_code */
|
||||||
|
/*Source table 5: :COMMDB.cust_chat_ccc_record */
|
||||||
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
||||||
/*Target Table:cust_chat_record_info */
|
/*Target Table:cust_chat_record_info */
|
||||||
/*ETL Job Name:cust_chat_record_info */
|
/*ETL Job Name:cust_chat_record_info */
|
||||||
|
@ -45,10 +48,13 @@ ON COMMIT PRESERVE ROWS;
|
||||||
/*****************************************************************************************************/
|
/*****************************************************************************************************/
|
||||||
INSERT INTO cust_chat_record_info_agi_CUR_I (
|
INSERT INTO cust_chat_record_info_agi_CUR_I (
|
||||||
chat_unique_id /*在线客服会话ID*/
|
chat_unique_id /*在线客服会话ID*/
|
||||||
|
,platform_name /*平台*/
|
||||||
,contact_channel /*接入渠道*/
|
,contact_channel /*接入渠道*/
|
||||||
,contact_app_id /*接入号ID*/
|
,contact_app_id /*接入号ID*/
|
||||||
,app_name /*接入号名称*/
|
,app_name /*接入号名称*/
|
||||||
|
,group_name /*分组*/
|
||||||
,queue_name /*队列名称*/
|
,queue_name /*队列名称*/
|
||||||
|
,service_name /*服务*/
|
||||||
,start_time /*会话开始时间戳*/
|
,start_time /*会话开始时间戳*/
|
||||||
,end_time /*会话结束时间戳*/
|
,end_time /*会话结束时间戳*/
|
||||||
,chat_duration_in_seconds /*会话持续时间*/
|
,chat_duration_in_seconds /*会话持续时间*/
|
||||||
|
@ -60,6 +66,9 @@ INSERT INTO cust_chat_record_info_agi_CUR_I (
|
||||||
,visitor_mobile /*访客手机*/
|
,visitor_mobile /*访客手机*/
|
||||||
,visitor_email /*访客邮箱*/
|
,visitor_email /*访客邮箱*/
|
||||||
,visitor_company /*访客公司*/
|
,visitor_company /*访客公司*/
|
||||||
|
,tag_1 /*标签1*/
|
||||||
|
,tag_2 /*标签2*/
|
||||||
|
,tag_3 /*标签3*/
|
||||||
,Etl_Batch_No /*作业批次号*/
|
,Etl_Batch_No /*作业批次号*/
|
||||||
,Etl_First_Dt /*最初入库时间*/
|
,Etl_First_Dt /*最初入库时间*/
|
||||||
,Etl_Job /*作业名称*/
|
,Etl_Job /*作业名称*/
|
||||||
|
@ -70,10 +79,19 @@ INSERT INTO cust_chat_record_info_agi_CUR_I (
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
COALESCE(TRIM(p0.chat_unique_id),'') /*chat_unique_id*/
|
COALESCE(TRIM(p0.chat_unique_id),'') /*chat_unique_id*/
|
||||||
,COALESCE(TRIM(p0.contact_channel),'') /*contact_channel*/
|
,'Smart CCC' /*platform_name*/
|
||||||
|
,coalesce(p2.data_detail,'') /*contact_channel*/
|
||||||
,COALESCE(TRIM(p0.contact_app_id),'') /*contact_app_id*/
|
,COALESCE(TRIM(p0.contact_app_id),'') /*contact_app_id*/
|
||||||
,COALESCE(TRIM(p0.app_name),'') /*app_name*/
|
,COALESCE(TRIM(p0.app_name),'') /*app_name*/
|
||||||
|
,case when app_name ='TW官网' then 'TW' when app_name='CN官网' then 'CN' else '企微客服' end /*group_name*/
|
||||||
,COALESCE(TRIM(p0.queue_name),'') /*queue_name*/
|
,COALESCE(TRIM(p0.queue_name),'') /*queue_name*/
|
||||||
|
,case when p0.queue_name in ('选型报价','选型报价统计') then '产品报价'
|
||||||
|
when p0.queue_name in ('售前技术','售后技术','技术支持统计') then '技术支持'
|
||||||
|
when p0.queue_name in ('保内维修','保外维修与计理','维修计量统计') then '维修与校准'
|
||||||
|
when p0.queue_name in ('其他咨询','其他支持统计') then '其他'
|
||||||
|
when p0.queue_name in ('Joe','Kuang_Chun','Lily','Susan','Tina_Zhang') then '企微客服'
|
||||||
|
when p0.queue_name ='TW销售服务' then 'TW销售服务'
|
||||||
|
else p0.queue_name end /*service_name*/
|
||||||
,COALESCE(p0.start_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*start_time*/
|
,COALESCE(p0.start_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*start_time*/
|
||||||
,COALESCE(p0.end_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*end_time*/
|
,COALESCE(p0.end_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*end_time*/
|
||||||
,COALESCE(p0.chat_duration_in_seconds,0) /*chat_duration_in_seconds*/
|
,COALESCE(p0.chat_duration_in_seconds,0) /*chat_duration_in_seconds*/
|
||||||
|
@ -85,6 +103,9 @@ SELECT
|
||||||
,coalesce(p1.tel,'') /*visitor_mobile*/
|
,coalesce(p1.tel,'') /*visitor_mobile*/
|
||||||
,coalesce(p1.email,'') /*visitor_email*/
|
,coalesce(p1.email,'') /*visitor_email*/
|
||||||
,coalesce(p1.company,'') /*visitor_company*/
|
,coalesce(p1.company,'') /*visitor_company*/
|
||||||
|
,'' /*tag_1*/
|
||||||
|
,'' /*tag_2*/
|
||||||
|
,'' /*tag_3*/
|
||||||
,0 /*Etl_Batch_No*/
|
,0 /*Etl_Batch_No*/
|
||||||
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_First_Dt*/
|
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_First_Dt*/
|
||||||
,:ETLJOB /*Etl_Job*/
|
,:ETLJOB /*Etl_Job*/
|
||||||
|
@ -98,16 +119,97 @@ LEFT JOIN (select replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','')
|
||||||
where visitor_ids <>'') p1
|
where visitor_ids <>'') p1
|
||||||
ON p0 .visitor_id =p1 .visitor_id
|
ON p0 .visitor_id =p1 .visitor_id
|
||||||
and p1.rn=1
|
and p1.rn=1
|
||||||
|
LEFT JOIN :PDMDB.t99_ccc_code p2
|
||||||
|
ON p2.code_type ='chat_contact_channel'
|
||||||
|
and p0.contact_channel =p2.data_code
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************************************/
|
||||||
|
/* GROUP 2:Source Table:cust_leads_detail*************************************************************/
|
||||||
|
/*****************************************************************************************************/
|
||||||
|
|
||||||
|
INSERT INTO cust_chat_record_info_agi_CUR_I (
|
||||||
|
chat_unique_id /*在线客服会话ID*/
|
||||||
|
,platform_name /*平台*/
|
||||||
|
,contact_channel /*接入渠道*/
|
||||||
|
,contact_app_id /*接入号ID*/
|
||||||
|
,app_name /*接入号名称*/
|
||||||
|
,group_name /*分组*/
|
||||||
|
,queue_name /*队列名称*/
|
||||||
|
,service_name /*服务*/
|
||||||
|
,start_time /*会话开始时间戳*/
|
||||||
|
,end_time /*会话结束时间戳*/
|
||||||
|
,chat_duration_in_seconds /*会话持续时间*/
|
||||||
|
,queue_time /*排队时长*/
|
||||||
|
,referer_url /*来源页*/
|
||||||
|
,first_visit_page_url /*着陆页*/
|
||||||
|
,visitor_id /*访客ID*/
|
||||||
|
,visitor_name /*访客姓名*/
|
||||||
|
,visitor_mobile /*访客手机*/
|
||||||
|
,visitor_email /*访客邮箱*/
|
||||||
|
,visitor_company /*访客公司*/
|
||||||
|
,tag_1 /*标签1*/
|
||||||
|
,tag_2 /*标签2*/
|
||||||
|
,tag_3 /*标签3*/
|
||||||
|
,Etl_Batch_No /*作业批次号*/
|
||||||
|
,Etl_First_Dt /*最初入库时间*/
|
||||||
|
,Etl_Job /*作业名称*/
|
||||||
|
,Etl_Proc_Dt /*本次入库时间*/
|
||||||
|
,Etl_Tx_Dt /*作业运行时间*/
|
||||||
|
,Src_Sysname /*来源系统*/
|
||||||
|
,Src_Table /*来源表*/
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
p0.contact_account /*chat_unique_id*/
|
||||||
|
,'LiveChat' /*platform_name*/
|
||||||
|
,'' /*contact_channel*/
|
||||||
|
,'' /*contact_app_id*/
|
||||||
|
,p1.group_name /*app_name*/
|
||||||
|
,p1.group_name /*group_name*/
|
||||||
|
,p1.pre_chat_service /*queue_name*/
|
||||||
|
,p0."event" /*service_name*/
|
||||||
|
,p1.chat_creation_time /*start_time*/
|
||||||
|
,p1.chat_start_time + interval '1second' * p1.chat_duration /*end_time*/
|
||||||
|
,p1.chat_duration /*chat_duration_in_seconds*/
|
||||||
|
,p1.queue_duration /*queue_time*/
|
||||||
|
,p1.chat_referrer_url /*referer_url*/
|
||||||
|
,p1.chat_start_url /*first_visit_page_url*/
|
||||||
|
,p1.visitor_livechat_id /*visitor_id*/
|
||||||
|
,p1.pre_chat_name /*visitor_name*/
|
||||||
|
,p1.pre_chat_contact /*visitor_mobile*/
|
||||||
|
,p1.pre_chat_email /*visitor_email*/
|
||||||
|
,p1.pre_chat_company /*visitor_company*/
|
||||||
|
,p1.tag_1 /*tag_1*/
|
||||||
|
,p1.tag_2 /*tag_2*/
|
||||||
|
,p1.tag_3 /*tag_3*/
|
||||||
|
,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('cust_leads_detail',1,3) /*Src_Sysname*/
|
||||||
|
,'cust_leads_detail' /*Src_Table*/
|
||||||
|
|
||||||
|
FROM :COMMDB.cust_leads_detail p0
|
||||||
|
LEFT JOIN :PDMDB.t01_livechat_record p1
|
||||||
|
ON p0.contact_account =p1.livechat_leads_id
|
||||||
|
where contact_channel ='Chat'
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*将不同数据插入到临时表 */
|
/*将不同数据插入到临时表 */
|
||||||
;INSERT INTO cust_chat_record_info_agi_INS (
|
;INSERT INTO cust_chat_record_info_agi_INS (
|
||||||
contact_channel /*接入渠道*/
|
platform_name /*平台*/
|
||||||
|
,contact_channel /*接入渠道*/
|
||||||
,contact_app_id /*接入号ID*/
|
,contact_app_id /*接入号ID*/
|
||||||
,app_name /*接入号名称*/
|
,app_name /*接入号名称*/
|
||||||
|
,group_name /*分组*/
|
||||||
,queue_name /*队列名称*/
|
,queue_name /*队列名称*/
|
||||||
|
,service_name /*服务*/
|
||||||
,start_time /*会话开始时间戳*/
|
,start_time /*会话开始时间戳*/
|
||||||
,end_time /*会话结束时间戳*/
|
,end_time /*会话结束时间戳*/
|
||||||
,chat_duration_in_seconds /*会话持续时间*/
|
,chat_duration_in_seconds /*会话持续时间*/
|
||||||
|
@ -119,6 +221,9 @@ and p1.rn=1
|
||||||
,visitor_mobile /*访客手机*/
|
,visitor_mobile /*访客手机*/
|
||||||
,visitor_email /*访客邮箱*/
|
,visitor_email /*访客邮箱*/
|
||||||
,visitor_company /*访客公司*/
|
,visitor_company /*访客公司*/
|
||||||
|
,tag_1 /*标签1*/
|
||||||
|
,tag_2 /*标签2*/
|
||||||
|
,tag_3 /*标签3*/
|
||||||
,chat_unique_id /*在线客服会话ID*/
|
,chat_unique_id /*在线客服会话ID*/
|
||||||
,Etl_Batch_No /*作业批次号*/
|
,Etl_Batch_No /*作业批次号*/
|
||||||
,Etl_First_Dt /*最初入库时间*/
|
,Etl_First_Dt /*最初入库时间*/
|
||||||
|
@ -130,10 +235,13 @@ and p1.rn=1
|
||||||
|
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
P1.contact_channel /*接入渠道*/
|
P1.platform_name /*平台*/
|
||||||
|
,P1.contact_channel /*接入渠道*/
|
||||||
,P1.contact_app_id /*接入号ID*/
|
,P1.contact_app_id /*接入号ID*/
|
||||||
,P1.app_name /*接入号名称*/
|
,P1.app_name /*接入号名称*/
|
||||||
|
,P1.group_name /*分组*/
|
||||||
,P1.queue_name /*队列名称*/
|
,P1.queue_name /*队列名称*/
|
||||||
|
,P1.service_name /*服务*/
|
||||||
,P1.start_time /*会话开始时间戳*/
|
,P1.start_time /*会话开始时间戳*/
|
||||||
,P1.end_time /*会话结束时间戳*/
|
,P1.end_time /*会话结束时间戳*/
|
||||||
,P1.chat_duration_in_seconds /*会话持续时间*/
|
,P1.chat_duration_in_seconds /*会话持续时间*/
|
||||||
|
@ -145,6 +253,9 @@ and p1.rn=1
|
||||||
,P1.visitor_mobile /*访客手机*/
|
,P1.visitor_mobile /*访客手机*/
|
||||||
,P1.visitor_email /*访客邮箱*/
|
,P1.visitor_email /*访客邮箱*/
|
||||||
,P1.visitor_company /*访客公司*/
|
,P1.visitor_company /*访客公司*/
|
||||||
|
,P1.tag_1 /*标签1*/
|
||||||
|
,P1.tag_2 /*标签2*/
|
||||||
|
,P1.tag_3 /*标签3*/
|
||||||
,P1.chat_unique_id /*在线客服会话ID*/
|
,P1.chat_unique_id /*在线客服会话ID*/
|
||||||
,P1.Etl_Batch_No /*作业批次号*/
|
,P1.Etl_Batch_No /*作业批次号*/
|
||||||
,P1.Etl_First_Dt /*最初入库时间*/
|
,P1.Etl_First_Dt /*最初入库时间*/
|
||||||
|
@ -156,10 +267,13 @@ and p1.rn=1
|
||||||
|
|
||||||
FROM cust_chat_record_info_agi_CUR_I P1
|
FROM cust_chat_record_info_agi_CUR_I P1
|
||||||
LEFT JOIN :MARTDB.cust_chat_record_info P2
|
LEFT JOIN :MARTDB.cust_chat_record_info P2
|
||||||
ON P1.contact_channel = P2.contact_channel
|
ON P1.platform_name = P2.platform_name
|
||||||
|
AND P1.contact_channel = P2.contact_channel
|
||||||
AND P1.contact_app_id = P2.contact_app_id
|
AND P1.contact_app_id = P2.contact_app_id
|
||||||
AND P1.app_name = P2.app_name
|
AND P1.app_name = P2.app_name
|
||||||
|
AND P1.group_name = P2.group_name
|
||||||
AND P1.queue_name = P2.queue_name
|
AND P1.queue_name = P2.queue_name
|
||||||
|
AND P1.service_name = P2.service_name
|
||||||
AND P1.start_time = P2.start_time
|
AND P1.start_time = P2.start_time
|
||||||
AND P1.end_time = P2.end_time
|
AND P1.end_time = P2.end_time
|
||||||
AND P1.chat_duration_in_seconds = P2.chat_duration_in_seconds
|
AND P1.chat_duration_in_seconds = P2.chat_duration_in_seconds
|
||||||
|
@ -171,12 +285,18 @@ ON P1.contact_channel = P2.contact_channel
|
||||||
AND P1.visitor_mobile = P2.visitor_mobile
|
AND P1.visitor_mobile = P2.visitor_mobile
|
||||||
AND P1.visitor_email = P2.visitor_email
|
AND P1.visitor_email = P2.visitor_email
|
||||||
AND P1.visitor_company = P2.visitor_company
|
AND P1.visitor_company = P2.visitor_company
|
||||||
|
AND P1.tag_1 = P2.tag_1
|
||||||
|
AND P1.tag_2 = P2.tag_2
|
||||||
|
AND P1.tag_3 = P2.tag_3
|
||||||
AND P1.chat_unique_id = P2.chat_unique_id
|
AND P1.chat_unique_id = P2.chat_unique_id
|
||||||
|
|
||||||
WHERE P2.contact_channel IS NULL
|
WHERE P2.platform_name IS NULL
|
||||||
|
OR P2.contact_channel IS NULL
|
||||||
OR P2.contact_app_id IS NULL
|
OR P2.contact_app_id IS NULL
|
||||||
OR P2.app_name IS NULL
|
OR P2.app_name IS NULL
|
||||||
|
OR P2.group_name IS NULL
|
||||||
OR P2.queue_name IS NULL
|
OR P2.queue_name IS NULL
|
||||||
|
OR P2.service_name IS NULL
|
||||||
OR P2.start_time IS NULL
|
OR P2.start_time IS NULL
|
||||||
OR P2.end_time IS NULL
|
OR P2.end_time IS NULL
|
||||||
OR P2.chat_duration_in_seconds IS NULL
|
OR P2.chat_duration_in_seconds IS NULL
|
||||||
|
@ -188,15 +308,21 @@ WHERE P2.contact_channel IS NULL
|
||||||
OR P2.visitor_mobile IS NULL
|
OR P2.visitor_mobile IS NULL
|
||||||
OR P2.visitor_email IS NULL
|
OR P2.visitor_email IS NULL
|
||||||
OR P2.visitor_company IS NULL
|
OR P2.visitor_company IS NULL
|
||||||
|
OR P2.tag_1 IS NULL
|
||||||
|
OR P2.tag_2 IS NULL
|
||||||
|
OR P2.tag_3 IS NULL
|
||||||
OR P2.chat_unique_id IS NULL
|
OR P2.chat_unique_id IS NULL
|
||||||
|
|
||||||
;
|
;
|
||||||
/*将新增数据插入到目标表 */
|
/*将新增数据插入到目标表 */
|
||||||
;INSERT INTO :MARTDB.cust_chat_record_info (
|
;INSERT INTO :MARTDB.cust_chat_record_info (
|
||||||
contact_channel /*接入渠道*/
|
platform_name /*平台*/
|
||||||
|
,contact_channel /*接入渠道*/
|
||||||
,contact_app_id /*接入号ID*/
|
,contact_app_id /*接入号ID*/
|
||||||
,app_name /*接入号名称*/
|
,app_name /*接入号名称*/
|
||||||
|
,group_name /*分组*/
|
||||||
,queue_name /*队列名称*/
|
,queue_name /*队列名称*/
|
||||||
|
,service_name /*服务*/
|
||||||
,start_time /*会话开始时间戳*/
|
,start_time /*会话开始时间戳*/
|
||||||
,end_time /*会话结束时间戳*/
|
,end_time /*会话结束时间戳*/
|
||||||
,chat_duration_in_seconds /*会话持续时间*/
|
,chat_duration_in_seconds /*会话持续时间*/
|
||||||
|
@ -208,6 +334,9 @@ WHERE P2.contact_channel IS NULL
|
||||||
,visitor_mobile /*访客手机*/
|
,visitor_mobile /*访客手机*/
|
||||||
,visitor_email /*访客邮箱*/
|
,visitor_email /*访客邮箱*/
|
||||||
,visitor_company /*访客公司*/
|
,visitor_company /*访客公司*/
|
||||||
|
,tag_1 /*标签1*/
|
||||||
|
,tag_2 /*标签2*/
|
||||||
|
,tag_3 /*标签3*/
|
||||||
,chat_unique_id /*在线客服会话ID*/
|
,chat_unique_id /*在线客服会话ID*/
|
||||||
,Etl_Batch_No /*作业批次号*/
|
,Etl_Batch_No /*作业批次号*/
|
||||||
,Etl_First_Dt /*最初入库时间*/
|
,Etl_First_Dt /*最初入库时间*/
|
||||||
|
@ -219,10 +348,13 @@ WHERE P2.contact_channel IS NULL
|
||||||
|
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
P1.contact_channel /*接入渠道*/
|
P1.platform_name /*平台*/
|
||||||
|
,P1.contact_channel /*接入渠道*/
|
||||||
,P1.contact_app_id /*接入号ID*/
|
,P1.contact_app_id /*接入号ID*/
|
||||||
,P1.app_name /*接入号名称*/
|
,P1.app_name /*接入号名称*/
|
||||||
|
,P1.group_name /*分组*/
|
||||||
,P1.queue_name /*队列名称*/
|
,P1.queue_name /*队列名称*/
|
||||||
|
,P1.service_name /*服务*/
|
||||||
,P1.start_time /*会话开始时间戳*/
|
,P1.start_time /*会话开始时间戳*/
|
||||||
,P1.end_time /*会话结束时间戳*/
|
,P1.end_time /*会话结束时间戳*/
|
||||||
,P1.chat_duration_in_seconds /*会话持续时间*/
|
,P1.chat_duration_in_seconds /*会话持续时间*/
|
||||||
|
@ -234,6 +366,9 @@ SELECT
|
||||||
,P1.visitor_mobile /*访客手机*/
|
,P1.visitor_mobile /*访客手机*/
|
||||||
,P1.visitor_email /*访客邮箱*/
|
,P1.visitor_email /*访客邮箱*/
|
||||||
,P1.visitor_company /*访客公司*/
|
,P1.visitor_company /*访客公司*/
|
||||||
|
,P1.tag_1 /*标签1*/
|
||||||
|
,P1.tag_2 /*标签2*/
|
||||||
|
,P1.tag_3 /*标签3*/
|
||||||
,P1.chat_unique_id /*在线客服会话ID*/
|
,P1.chat_unique_id /*在线客服会话ID*/
|
||||||
,P1.Etl_Batch_No /*作业批次号*/
|
,P1.Etl_Batch_No /*作业批次号*/
|
||||||
,P1.Etl_First_Dt /*最初入库时间*/
|
,P1.Etl_First_Dt /*最初入库时间*/
|
||||||
|
@ -247,10 +382,13 @@ FROM cust_chat_record_info_agi_INS P1
|
||||||
ON CONFLICT ( chat_unique_id)
|
ON CONFLICT ( chat_unique_id)
|
||||||
DO UPDATE SET
|
DO UPDATE SET
|
||||||
chat_unique_id=excluded.chat_unique_id
|
chat_unique_id=excluded.chat_unique_id
|
||||||
|
,platform_name=excluded.platform_name
|
||||||
,contact_channel=excluded.contact_channel
|
,contact_channel=excluded.contact_channel
|
||||||
,contact_app_id=excluded.contact_app_id
|
,contact_app_id=excluded.contact_app_id
|
||||||
,app_name=excluded.app_name
|
,app_name=excluded.app_name
|
||||||
|
,group_name=excluded.group_name
|
||||||
,queue_name=excluded.queue_name
|
,queue_name=excluded.queue_name
|
||||||
|
,service_name=excluded.service_name
|
||||||
,start_time=excluded.start_time
|
,start_time=excluded.start_time
|
||||||
,end_time=excluded.end_time
|
,end_time=excluded.end_time
|
||||||
,chat_duration_in_seconds=excluded.chat_duration_in_seconds
|
,chat_duration_in_seconds=excluded.chat_duration_in_seconds
|
||||||
|
@ -262,6 +400,9 @@ DO UPDATE SET
|
||||||
,visitor_mobile=excluded.visitor_mobile
|
,visitor_mobile=excluded.visitor_mobile
|
||||||
,visitor_email=excluded.visitor_email
|
,visitor_email=excluded.visitor_email
|
||||||
,visitor_company=excluded.visitor_company
|
,visitor_company=excluded.visitor_company
|
||||||
|
,tag_1=excluded.tag_1
|
||||||
|
,tag_2=excluded.tag_2
|
||||||
|
,tag_3=excluded.tag_3
|
||||||
,Etl_Batch_No=excluded.Etl_Batch_No
|
,Etl_Batch_No=excluded.Etl_Batch_No
|
||||||
,Etl_First_Dt=excluded.Etl_First_Dt
|
,Etl_First_Dt=excluded.Etl_First_Dt
|
||||||
,Etl_Job=excluded.Etl_Job
|
,Etl_Job=excluded.Etl_Job
|
||||||
|
|
Loading…
Reference in New Issue