add workflow 天润Smart-ccc会话数据,dev
This commit is contained in:
parent
d096304976
commit
1fccca35fa
|
@ -0,0 +1,116 @@
|
|||
|
||||
DROP TABLE IF EXISTS p30_common.cust_chat_ccc_record;
|
||||
CREATE TABLE IF NOT EXISTS p30_common.cust_chat_ccc_record (
|
||||
chat_unique_id VARCHAR(50)
|
||||
, contact_channel VARCHAR(10)
|
||||
, contact_app_id VARCHAR(50)
|
||||
, app_name VARCHAR(50)
|
||||
, visitor_id VARCHAR(50)
|
||||
, robot_id VARCHAR(10)
|
||||
, robot_name VARCHAR(10)
|
||||
, robot_start_time timestamp(0)
|
||||
, robot_end_time timestamp(0)
|
||||
, queue_no VARCHAR(10)
|
||||
, queue_name VARCHAR(10)
|
||||
, client_no VARCHAR(10)
|
||||
, client_name VARCHAR(10)
|
||||
, chat_duration_type VARCHAR(10)
|
||||
, close_status VARCHAR(10)
|
||||
, close_reason VARCHAR(10)
|
||||
, open_type VARCHAR(10)
|
||||
, first_response_duration int4
|
||||
, start_time timestamp(0)
|
||||
, end_time timestamp(0)
|
||||
, chat_duration_in_seconds int
|
||||
, queue_time int4
|
||||
, join_queue_time timestamp(0)
|
||||
, bridge_time timestamp(0)
|
||||
, session_type VARCHAR(10)
|
||||
, chat_valid_session VARCHAR(10)
|
||||
, comment_session VARCHAR(10)
|
||||
, invitation_initiator VARCHAR(10)
|
||||
, satisfaction_keys VARCHAR(10)
|
||||
, satisfaction_remark VARCHAR(10)
|
||||
, visitor_ip VARCHAR(20)
|
||||
, visitor_region VARCHAR(20)
|
||||
, chat_times int4
|
||||
, invited_times int4
|
||||
, search_word VARCHAR(20)
|
||||
, operating_system VARCHAR(50)
|
||||
, browser VARCHAR(50)
|
||||
, referer_url text
|
||||
, first_visit_page_url text
|
||||
, initiation_page_url text
|
||||
, visit_tracks text
|
||||
, visitor_extra_info text
|
||||
, device_type VARCHAR(20)
|
||||
, contact_app_type VARCHAR(10)
|
||||
, visitor_province VARCHAR(10)
|
||||
, visitor_city VARCHAR(10)
|
||||
, referer_name text
|
||||
, Etl_Batch_No varchar(50)
|
||||
, Etl_First_Dt timestamp(0)
|
||||
, Etl_Job varchar(200)
|
||||
, Etl_Proc_Dt timestamp(0)
|
||||
, Etl_Tx_Dt timestamp(0)
|
||||
, Src_Sysname varchar(50)
|
||||
, Src_Table varchar(50)
|
||||
,primary key( chat_unique_id )
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.chat_unique_id IS '在线客服会话ID';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.contact_channel IS '接入渠道';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.contact_app_id IS '接入号ID';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.app_name IS '接入号名称';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.visitor_id IS '访客ID';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.robot_id IS '机器人客服ID';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.robot_name IS '机器人客服名称';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.robot_start_time IS '机器人客服接入会话时间戳';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.robot_end_time IS '机器人客服结束会话时间戳';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.queue_no IS '接入队列号';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.queue_name IS '队列名称';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.client_no IS '接待座席号';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.client_name IS '座席名称';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.chat_duration_type IS '接待类型';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.close_status IS '会话结束时状态';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.close_reason IS '会话结束原因';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.open_type IS '会话发起方式';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.first_response_duration IS '座席首次响应时长';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.start_time IS '会话开始时间戳';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.end_time IS '会话结束时间戳';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.chat_duration_in_seconds IS '会话持续时间';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.queue_time IS '排队时长';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.join_queue_time IS '接入队列时间戳';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.bridge_time IS '座席接入时间戳';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.session_type IS '会话是否有人工客服接入';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.chat_valid_session IS '是否是有效会话';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.comment_session IS '是否是通过留言发起的会话';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.invitation_initiator IS '满意度评价发起方式';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.satisfaction_keys IS '满意度评价';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.satisfaction_remark IS '满意度评价备注';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.visitor_ip IS '访客IP';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.visitor_region IS '访问地区';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.chat_times IS '会话次数';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.invited_times IS '被邀请次数';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.search_word IS '搜索词,通过对来源页解析,获取搜索参数参数。';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.operating_system IS '操作系统';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.browser IS '浏览器型号';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.referer_url IS '来源页';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.first_visit_page_url IS '着陆页';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.initiation_page_url IS '会话发起页';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.visit_tracks IS '浏览轨迹';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.visitor_extra_info IS '访客自定义参数';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.device_type IS '访客设备类型';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.contact_app_type IS '接入渠道类型';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.visitor_province IS '访客会话时所在省份';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.visitor_city IS '访客会话时所在城市';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.referer_name IS '访客来源';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.Etl_Batch_No IS '作业批次号';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.Etl_First_Dt IS '最初入库时间';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.Etl_Job IS '作业名称';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.Etl_Proc_Dt IS '本次入库时间';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.Etl_Tx_Dt IS '作业运行时间';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.Src_Sysname IS '来源系统';
|
||||
COMMENT ON COLUMN p30_common.cust_chat_ccc_record.Src_Table IS '来源表';
|
||||
|
||||
COMMENT ON TABLE p30_common.cust_chat_ccc_record IS 'ccc-chat记录';
|
|
@ -0,0 +1,550 @@
|
|||
/***************************************************************************************************/
|
||||
/*script in Sql, generate by SdmCreateScript 2020(by Qihang Feng, QF255001@TERADATA.COM) */
|
||||
/*VERSION 01.10 revised on 2020-08-25 */
|
||||
/*Brilliance stems from wisdoms. */
|
||||
/*************Head Section**************************************************************************/
|
||||
/*Script Use: Periodically load data to :cust_chat_ccc_record(ccc-chat记录) */
|
||||
/*Create Date:2024-08-14 14:01:25 */
|
||||
/*SDM Developed By: dev */
|
||||
/*SDM Developed Date: 2024-08-14 */
|
||||
/*SDM Checked By: dev */
|
||||
/*SDM Checked Date: 2024-08-14 */
|
||||
/*Script Developed By: dev */
|
||||
/*Script Checked By: dev */
|
||||
/*Source table 1: :PDMDB.t01_ccc_chat_record */
|
||||
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
||||
/*Target Table:cust_chat_ccc_record */
|
||||
/*ETL Job Name:cust_chat_ccc_record */
|
||||
/*ETL Frequency:Daily */
|
||||
/*ETL Policy:F2 */
|
||||
/********************************************************************************************/
|
||||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载当前数据 */
|
||||
CREATE TEMPORARY TABLE cust_chat_ccc_record_agi_CUR_I
|
||||
( LIKE :COMMDB.cust_chat_ccc_record)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载不同数据 */
|
||||
CREATE TEMPORARY TABLE cust_chat_ccc_record_agi_INS
|
||||
( LIKE :COMMDB.cust_chat_ccc_record)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/* GROUP 1:Source Table:t01_ccc_chat_record***********************************************************/
|
||||
/*****************************************************************************************************/
|
||||
INSERT INTO cust_chat_ccc_record_agi_CUR_I (
|
||||
chat_unique_id /*在线客服会话ID*/
|
||||
,contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
,visitor_id /*访客ID*/
|
||||
,robot_id /*机器人客服ID*/
|
||||
,robot_name /*机器人客服名称*/
|
||||
,robot_start_time /*机器人客服接入会话时间戳*/
|
||||
,robot_end_time /*机器人客服结束会话时间戳*/
|
||||
,queue_no /*接入队列号*/
|
||||
,queue_name /*队列名称*/
|
||||
,client_no /*接待座席号*/
|
||||
,client_name /*座席名称*/
|
||||
,chat_duration_type /*接待类型*/
|
||||
,close_status /*会话结束时状态*/
|
||||
,close_reason /*会话结束原因*/
|
||||
,open_type /*会话发起方式*/
|
||||
,first_response_duration /*座席首次响应时长*/
|
||||
,start_time /*会话开始时间戳*/
|
||||
,end_time /*会话结束时间戳*/
|
||||
,chat_duration_in_seconds /*会话持续时间*/
|
||||
,queue_time /*排队时长*/
|
||||
,join_queue_time /*接入队列时间戳*/
|
||||
,bridge_time /*座席接入时间戳*/
|
||||
,session_type /*会话是否有人工客服接入*/
|
||||
,chat_valid_session /*是否是有效会话*/
|
||||
,comment_session /*是否是通过留言发起的会话*/
|
||||
,invitation_initiator /*满意度评价发起方式*/
|
||||
,satisfaction_keys /*满意度评价*/
|
||||
,satisfaction_remark /*满意度评价备注*/
|
||||
,visitor_ip /*访客IP*/
|
||||
,visitor_region /*访问地区*/
|
||||
,chat_times /*会话次数*/
|
||||
,invited_times /*被邀请次数*/
|
||||
,search_word /*搜索词,通过对来源页解析,获取搜索参数参数。*/
|
||||
,operating_system /*操作系统*/
|
||||
,browser /*浏览器型号*/
|
||||
,referer_url /*来源页*/
|
||||
,first_visit_page_url /*着陆页*/
|
||||
,initiation_page_url /*会话发起页*/
|
||||
,visit_tracks /*浏览轨迹*/
|
||||
,visitor_extra_info /*访客自定义参数*/
|
||||
,device_type /*访客设备类型*/
|
||||
,contact_app_type /*接入渠道类型*/
|
||||
,visitor_province /*访客会话时所在省份*/
|
||||
,visitor_city /*访客会话时所在城市*/
|
||||
,referer_name /*访客来源*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
)
|
||||
SELECT
|
||||
COALESCE(TRIM(p0.chat_unique_id),'') /*chat_unique_id*/
|
||||
,COALESCE(TRIM(p0.contact_channel),'') /*contact_channel*/
|
||||
,COALESCE(TRIM(p0.contact_app_id),'') /*contact_app_id*/
|
||||
,COALESCE(TRIM(p0.app_namecontact_),'') /*app_name*/
|
||||
,COALESCE(TRIM(p0.visitor_id),'') /*visitor_id*/
|
||||
,COALESCE(TRIM(p0.robot_id),'') /*robot_id*/
|
||||
,COALESCE(TRIM(p0.robot_name),'') /*robot_name*/
|
||||
,COALESCE(p0.robot_start_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*robot_start_time*/
|
||||
,COALESCE(p0.robot_end_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*robot_end_time*/
|
||||
,COALESCE(TRIM(p0.queue_no),'') /*queue_no*/
|
||||
,COALESCE(TRIM(p0.queue_name),'') /*queue_name*/
|
||||
,COALESCE(TRIM(p0.client_no),'') /*client_no*/
|
||||
,COALESCE(TRIM(p0.client_name),'') /*client_name*/
|
||||
,COALESCE(TRIM(p0.chat_duration_type),'') /*chat_duration_type*/
|
||||
,COALESCE(TRIM(p0.close_status),'') /*close_status*/
|
||||
,COALESCE(TRIM(p0.close_reason),'') /*close_reason*/
|
||||
,COALESCE(TRIM(p0.open_type),'') /*open_type*/
|
||||
,COALESCE(p0.first_response_duration,0) /*first_response_duration*/
|
||||
,COALESCE(p0.start_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*start_time*/
|
||||
,COALESCE(p0.end_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*end_time*/
|
||||
,EXTRACT(EPOCH FROM (end_time - start_time)) /*chat_duration_in_seconds*/
|
||||
,COALESCE(p0.queue_time,0) /*queue_time*/
|
||||
,COALESCE(p0.join_queue_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*join_queue_time*/
|
||||
,COALESCE(p0.bridge_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*bridge_time*/
|
||||
,COALESCE(TRIM(p0.session_type),'') /*session_type*/
|
||||
,COALESCE(TRIM(p0.chat_valid_session),'') /*chat_valid_session*/
|
||||
,COALESCE(TRIM(p0.comment_session),'') /*comment_session*/
|
||||
,COALESCE(TRIM(p0.invitation_initiator),'') /*invitation_initiator*/
|
||||
,COALESCE(TRIM(p0.satisfaction_keys),'') /*satisfaction_keys*/
|
||||
,COALESCE(TRIM(p0.satisfaction_remark),'') /*satisfaction_remark*/
|
||||
,COALESCE(TRIM(p0.visitor_ip),'') /*visitor_ip*/
|
||||
,COALESCE(TRIM(p0.visitor_region),'') /*visitor_region*/
|
||||
,COALESCE(p0.chat_times,0) /*chat_times*/
|
||||
,COALESCE(p0.invited_times,0) /*invited_times*/
|
||||
,COALESCE(TRIM(p0.search_word),'') /*search_word*/
|
||||
,COALESCE(TRIM(p0.operating_system),'') /*operating_system*/
|
||||
,COALESCE(TRIM(p0.browser),'') /*browser*/
|
||||
,COALESCE(TRIM(p0.referer_url),'') /*referer_url*/
|
||||
,COALESCE(TRIM(p0.first_visit_page_url),'') /*first_visit_page_url*/
|
||||
,COALESCE(TRIM(p0.initiation_page_url),'') /*initiation_page_url*/
|
||||
,COALESCE(TRIM(p0.visit_tracks),'') /*visit_tracks*/
|
||||
,COALESCE(TRIM(p0.visitor_extra_info),'') /*visitor_extra_info*/
|
||||
,COALESCE(TRIM(p0.device_type),'') /*device_type*/
|
||||
,COALESCE(TRIM(p0.contact_app_type),'') /*contact_app_type*/
|
||||
,COALESCE(TRIM(p0.visitor_province),'') /*visitor_province*/
|
||||
,COALESCE(TRIM(p0.visitor_city),'') /*visitor_city*/
|
||||
,COALESCE(TRIM(p0.referer_name),'') /*referer_name*/
|
||||
,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_ccc_chat_record',1,3) /*Src_Sysname*/
|
||||
,'t01_ccc_chat_record' /*Src_Table*/
|
||||
|
||||
FROM :PDMDB.t01_ccc_chat_record p0
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*将不同数据插入到临时表 */
|
||||
;INSERT INTO cust_chat_ccc_record_agi_INS (
|
||||
contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
,visitor_id /*访客ID*/
|
||||
,robot_id /*机器人客服ID*/
|
||||
,robot_name /*机器人客服名称*/
|
||||
,robot_start_time /*机器人客服接入会话时间戳*/
|
||||
,robot_end_time /*机器人客服结束会话时间戳*/
|
||||
,queue_no /*接入队列号*/
|
||||
,queue_name /*队列名称*/
|
||||
,client_no /*接待座席号*/
|
||||
,client_name /*座席名称*/
|
||||
,chat_duration_type /*接待类型*/
|
||||
,close_status /*会话结束时状态*/
|
||||
,close_reason /*会话结束原因*/
|
||||
,open_type /*会话发起方式*/
|
||||
,first_response_duration /*座席首次响应时长*/
|
||||
,start_time /*会话开始时间戳*/
|
||||
,end_time /*会话结束时间戳*/
|
||||
,chat_duration_in_seconds /*会话持续时间*/
|
||||
,queue_time /*排队时长*/
|
||||
,join_queue_time /*接入队列时间戳*/
|
||||
,bridge_time /*座席接入时间戳*/
|
||||
,session_type /*会话是否有人工客服接入*/
|
||||
,chat_valid_session /*是否是有效会话*/
|
||||
,comment_session /*是否是通过留言发起的会话*/
|
||||
,invitation_initiator /*满意度评价发起方式*/
|
||||
,satisfaction_keys /*满意度评价*/
|
||||
,satisfaction_remark /*满意度评价备注*/
|
||||
,visitor_ip /*访客IP*/
|
||||
,visitor_region /*访问地区*/
|
||||
,chat_times /*会话次数*/
|
||||
,invited_times /*被邀请次数*/
|
||||
,search_word /*搜索词,通过对来源页解析,获取搜索参数参数。*/
|
||||
,operating_system /*操作系统*/
|
||||
,browser /*浏览器型号*/
|
||||
,referer_url /*来源页*/
|
||||
,first_visit_page_url /*着陆页*/
|
||||
,initiation_page_url /*会话发起页*/
|
||||
,visit_tracks /*浏览轨迹*/
|
||||
,visitor_extra_info /*访客自定义参数*/
|
||||
,device_type /*访客设备类型*/
|
||||
,contact_app_type /*接入渠道类型*/
|
||||
,visitor_province /*访客会话时所在省份*/
|
||||
,visitor_city /*访客会话时所在城市*/
|
||||
,referer_name /*访客来源*/
|
||||
,chat_unique_id /*在线客服会话ID*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.contact_channel /*接入渠道*/
|
||||
,P1.contact_app_id /*接入号ID*/
|
||||
,P1.app_name /*接入号名称*/
|
||||
,P1.visitor_id /*访客ID*/
|
||||
,P1.robot_id /*机器人客服ID*/
|
||||
,P1.robot_name /*机器人客服名称*/
|
||||
,P1.robot_start_time /*机器人客服接入会话时间戳*/
|
||||
,P1.robot_end_time /*机器人客服结束会话时间戳*/
|
||||
,P1.queue_no /*接入队列号*/
|
||||
,P1.queue_name /*队列名称*/
|
||||
,P1.client_no /*接待座席号*/
|
||||
,P1.client_name /*座席名称*/
|
||||
,P1.chat_duration_type /*接待类型*/
|
||||
,P1.close_status /*会话结束时状态*/
|
||||
,P1.close_reason /*会话结束原因*/
|
||||
,P1.open_type /*会话发起方式*/
|
||||
,P1.first_response_duration /*座席首次响应时长*/
|
||||
,P1.start_time /*会话开始时间戳*/
|
||||
,P1.end_time /*会话结束时间戳*/
|
||||
,P1.chat_duration_in_seconds /*会话持续时间*/
|
||||
,P1.queue_time /*排队时长*/
|
||||
,P1.join_queue_time /*接入队列时间戳*/
|
||||
,P1.bridge_time /*座席接入时间戳*/
|
||||
,P1.session_type /*会话是否有人工客服接入*/
|
||||
,P1.chat_valid_session /*是否是有效会话*/
|
||||
,P1.comment_session /*是否是通过留言发起的会话*/
|
||||
,P1.invitation_initiator /*满意度评价发起方式*/
|
||||
,P1.satisfaction_keys /*满意度评价*/
|
||||
,P1.satisfaction_remark /*满意度评价备注*/
|
||||
,P1.visitor_ip /*访客IP*/
|
||||
,P1.visitor_region /*访问地区*/
|
||||
,P1.chat_times /*会话次数*/
|
||||
,P1.invited_times /*被邀请次数*/
|
||||
,P1.search_word /*搜索词,通过对来源页解析,获取搜索参数参数。*/
|
||||
,P1.operating_system /*操作系统*/
|
||||
,P1.browser /*浏览器型号*/
|
||||
,P1.referer_url /*来源页*/
|
||||
,P1.first_visit_page_url /*着陆页*/
|
||||
,P1.initiation_page_url /*会话发起页*/
|
||||
,P1.visit_tracks /*浏览轨迹*/
|
||||
,P1.visitor_extra_info /*访客自定义参数*/
|
||||
,P1.device_type /*访客设备类型*/
|
||||
,P1.contact_app_type /*接入渠道类型*/
|
||||
,P1.visitor_province /*访客会话时所在省份*/
|
||||
,P1.visitor_city /*访客会话时所在城市*/
|
||||
,P1.referer_name /*访客来源*/
|
||||
,P1.chat_unique_id /*在线客服会话ID*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM cust_chat_ccc_record_agi_CUR_I P1
|
||||
LEFT JOIN :COMMDB.cust_chat_ccc_record P2
|
||||
ON P1.contact_channel = P2.contact_channel
|
||||
AND P1.contact_app_id = P2.contact_app_id
|
||||
AND P1.app_name = P2.app_name
|
||||
AND P1.visitor_id = P2.visitor_id
|
||||
AND P1.robot_id = P2.robot_id
|
||||
AND P1.robot_name = P2.robot_name
|
||||
AND P1.robot_start_time = P2.robot_start_time
|
||||
AND P1.robot_end_time = P2.robot_end_time
|
||||
AND P1.queue_no = P2.queue_no
|
||||
AND P1.queue_name = P2.queue_name
|
||||
AND P1.client_no = P2.client_no
|
||||
AND P1.client_name = P2.client_name
|
||||
AND P1.chat_duration_type = P2.chat_duration_type
|
||||
AND P1.close_status = P2.close_status
|
||||
AND P1.close_reason = P2.close_reason
|
||||
AND P1.open_type = P2.open_type
|
||||
AND P1.first_response_duration = P2.first_response_duration
|
||||
AND P1.start_time = P2.start_time
|
||||
AND P1.end_time = P2.end_time
|
||||
AND P1.chat_duration_in_seconds = P2.chat_duration_in_seconds
|
||||
AND P1.queue_time = P2.queue_time
|
||||
AND P1.join_queue_time = P2.join_queue_time
|
||||
AND P1.bridge_time = P2.bridge_time
|
||||
AND P1.session_type = P2.session_type
|
||||
AND P1.chat_valid_session = P2.chat_valid_session
|
||||
AND P1.comment_session = P2.comment_session
|
||||
AND P1.invitation_initiator = P2.invitation_initiator
|
||||
AND P1.satisfaction_keys = P2.satisfaction_keys
|
||||
AND P1.satisfaction_remark = P2.satisfaction_remark
|
||||
AND P1.visitor_ip = P2.visitor_ip
|
||||
AND P1.visitor_region = P2.visitor_region
|
||||
AND P1.chat_times = P2.chat_times
|
||||
AND P1.invited_times = P2.invited_times
|
||||
AND P1.search_word = P2.search_word
|
||||
AND P1.operating_system = P2.operating_system
|
||||
AND P1.browser = P2.browser
|
||||
AND P1.referer_url = P2.referer_url
|
||||
AND P1.first_visit_page_url = P2.first_visit_page_url
|
||||
AND P1.initiation_page_url = P2.initiation_page_url
|
||||
AND P1.visit_tracks = P2.visit_tracks
|
||||
AND P1.visitor_extra_info = P2.visitor_extra_info
|
||||
AND P1.device_type = P2.device_type
|
||||
AND P1.contact_app_type = P2.contact_app_type
|
||||
AND P1.visitor_province = P2.visitor_province
|
||||
AND P1.visitor_city = P2.visitor_city
|
||||
AND P1.referer_name = P2.referer_name
|
||||
AND P1.chat_unique_id = P2.chat_unique_id
|
||||
|
||||
WHERE P2.contact_channel IS NULL
|
||||
OR P2.contact_app_id IS NULL
|
||||
OR P2.app_name IS NULL
|
||||
OR P2.visitor_id IS NULL
|
||||
OR P2.robot_id IS NULL
|
||||
OR P2.robot_name IS NULL
|
||||
OR P2.robot_start_time IS NULL
|
||||
OR P2.robot_end_time IS NULL
|
||||
OR P2.queue_no IS NULL
|
||||
OR P2.queue_name IS NULL
|
||||
OR P2.client_no IS NULL
|
||||
OR P2.client_name IS NULL
|
||||
OR P2.chat_duration_type IS NULL
|
||||
OR P2.close_status IS NULL
|
||||
OR P2.close_reason IS NULL
|
||||
OR P2.open_type IS NULL
|
||||
OR P2.first_response_duration IS NULL
|
||||
OR P2.start_time IS NULL
|
||||
OR P2.end_time IS NULL
|
||||
OR P2.chat_duration_in_seconds IS NULL
|
||||
OR P2.queue_time IS NULL
|
||||
OR P2.join_queue_time IS NULL
|
||||
OR P2.bridge_time IS NULL
|
||||
OR P2.session_type IS NULL
|
||||
OR P2.chat_valid_session IS NULL
|
||||
OR P2.comment_session IS NULL
|
||||
OR P2.invitation_initiator IS NULL
|
||||
OR P2.satisfaction_keys IS NULL
|
||||
OR P2.satisfaction_remark IS NULL
|
||||
OR P2.visitor_ip IS NULL
|
||||
OR P2.visitor_region IS NULL
|
||||
OR P2.chat_times IS NULL
|
||||
OR P2.invited_times IS NULL
|
||||
OR P2.search_word IS NULL
|
||||
OR P2.operating_system IS NULL
|
||||
OR P2.browser IS NULL
|
||||
OR P2.referer_url IS NULL
|
||||
OR P2.first_visit_page_url IS NULL
|
||||
OR P2.initiation_page_url IS NULL
|
||||
OR P2.visit_tracks IS NULL
|
||||
OR P2.visitor_extra_info IS NULL
|
||||
OR P2.device_type IS NULL
|
||||
OR P2.contact_app_type IS NULL
|
||||
OR P2.visitor_province IS NULL
|
||||
OR P2.visitor_city IS NULL
|
||||
OR P2.referer_name IS NULL
|
||||
OR P2.chat_unique_id IS NULL
|
||||
|
||||
;
|
||||
/*将新增数据插入到目标表 */
|
||||
;INSERT INTO :COMMDB.cust_chat_ccc_record (
|
||||
contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
,visitor_id /*访客ID*/
|
||||
,robot_id /*机器人客服ID*/
|
||||
,robot_name /*机器人客服名称*/
|
||||
,robot_start_time /*机器人客服接入会话时间戳*/
|
||||
,robot_end_time /*机器人客服结束会话时间戳*/
|
||||
,queue_no /*接入队列号*/
|
||||
,queue_name /*队列名称*/
|
||||
,client_no /*接待座席号*/
|
||||
,client_name /*座席名称*/
|
||||
,chat_duration_type /*接待类型*/
|
||||
,close_status /*会话结束时状态*/
|
||||
,close_reason /*会话结束原因*/
|
||||
,open_type /*会话发起方式*/
|
||||
,first_response_duration /*座席首次响应时长*/
|
||||
,start_time /*会话开始时间戳*/
|
||||
,end_time /*会话结束时间戳*/
|
||||
,chat_duration_in_seconds /*会话持续时间*/
|
||||
,queue_time /*排队时长*/
|
||||
,join_queue_time /*接入队列时间戳*/
|
||||
,bridge_time /*座席接入时间戳*/
|
||||
,session_type /*会话是否有人工客服接入*/
|
||||
,chat_valid_session /*是否是有效会话*/
|
||||
,comment_session /*是否是通过留言发起的会话*/
|
||||
,invitation_initiator /*满意度评价发起方式*/
|
||||
,satisfaction_keys /*满意度评价*/
|
||||
,satisfaction_remark /*满意度评价备注*/
|
||||
,visitor_ip /*访客IP*/
|
||||
,visitor_region /*访问地区*/
|
||||
,chat_times /*会话次数*/
|
||||
,invited_times /*被邀请次数*/
|
||||
,search_word /*搜索词,通过对来源页解析,获取搜索参数参数。*/
|
||||
,operating_system /*操作系统*/
|
||||
,browser /*浏览器型号*/
|
||||
,referer_url /*来源页*/
|
||||
,first_visit_page_url /*着陆页*/
|
||||
,initiation_page_url /*会话发起页*/
|
||||
,visit_tracks /*浏览轨迹*/
|
||||
,visitor_extra_info /*访客自定义参数*/
|
||||
,device_type /*访客设备类型*/
|
||||
,contact_app_type /*接入渠道类型*/
|
||||
,visitor_province /*访客会话时所在省份*/
|
||||
,visitor_city /*访客会话时所在城市*/
|
||||
,referer_name /*访客来源*/
|
||||
,chat_unique_id /*在线客服会话ID*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.contact_channel /*接入渠道*/
|
||||
,P1.contact_app_id /*接入号ID*/
|
||||
,P1.app_name /*接入号名称*/
|
||||
,P1.visitor_id /*访客ID*/
|
||||
,P1.robot_id /*机器人客服ID*/
|
||||
,P1.robot_name /*机器人客服名称*/
|
||||
,P1.robot_start_time /*机器人客服接入会话时间戳*/
|
||||
,P1.robot_end_time /*机器人客服结束会话时间戳*/
|
||||
,P1.queue_no /*接入队列号*/
|
||||
,P1.queue_name /*队列名称*/
|
||||
,P1.client_no /*接待座席号*/
|
||||
,P1.client_name /*座席名称*/
|
||||
,P1.chat_duration_type /*接待类型*/
|
||||
,P1.close_status /*会话结束时状态*/
|
||||
,P1.close_reason /*会话结束原因*/
|
||||
,P1.open_type /*会话发起方式*/
|
||||
,P1.first_response_duration /*座席首次响应时长*/
|
||||
,P1.start_time /*会话开始时间戳*/
|
||||
,P1.end_time /*会话结束时间戳*/
|
||||
,P1.chat_duration_in_seconds /*会话持续时间*/
|
||||
,P1.queue_time /*排队时长*/
|
||||
,P1.join_queue_time /*接入队列时间戳*/
|
||||
,P1.bridge_time /*座席接入时间戳*/
|
||||
,P1.session_type /*会话是否有人工客服接入*/
|
||||
,P1.chat_valid_session /*是否是有效会话*/
|
||||
,P1.comment_session /*是否是通过留言发起的会话*/
|
||||
,P1.invitation_initiator /*满意度评价发起方式*/
|
||||
,P1.satisfaction_keys /*满意度评价*/
|
||||
,P1.satisfaction_remark /*满意度评价备注*/
|
||||
,P1.visitor_ip /*访客IP*/
|
||||
,P1.visitor_region /*访问地区*/
|
||||
,P1.chat_times /*会话次数*/
|
||||
,P1.invited_times /*被邀请次数*/
|
||||
,P1.search_word /*搜索词,通过对来源页解析,获取搜索参数参数。*/
|
||||
,P1.operating_system /*操作系统*/
|
||||
,P1.browser /*浏览器型号*/
|
||||
,P1.referer_url /*来源页*/
|
||||
,P1.first_visit_page_url /*着陆页*/
|
||||
,P1.initiation_page_url /*会话发起页*/
|
||||
,P1.visit_tracks /*浏览轨迹*/
|
||||
,P1.visitor_extra_info /*访客自定义参数*/
|
||||
,P1.device_type /*访客设备类型*/
|
||||
,P1.contact_app_type /*接入渠道类型*/
|
||||
,P1.visitor_province /*访客会话时所在省份*/
|
||||
,P1.visitor_city /*访客会话时所在城市*/
|
||||
,P1.referer_name /*访客来源*/
|
||||
,P1.chat_unique_id /*在线客服会话ID*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM cust_chat_ccc_record_agi_INS P1
|
||||
ON CONFLICT ( chat_unique_id)
|
||||
DO UPDATE SET
|
||||
chat_unique_id=excluded.chat_unique_id
|
||||
,contact_channel=excluded.contact_channel
|
||||
,contact_app_id=excluded.contact_app_id
|
||||
,app_name=excluded.app_name
|
||||
,visitor_id=excluded.visitor_id
|
||||
,robot_id=excluded.robot_id
|
||||
,robot_name=excluded.robot_name
|
||||
,robot_start_time=excluded.robot_start_time
|
||||
,robot_end_time=excluded.robot_end_time
|
||||
,queue_no=excluded.queue_no
|
||||
,queue_name=excluded.queue_name
|
||||
,client_no=excluded.client_no
|
||||
,client_name=excluded.client_name
|
||||
,chat_duration_type=excluded.chat_duration_type
|
||||
,close_status=excluded.close_status
|
||||
,close_reason=excluded.close_reason
|
||||
,open_type=excluded.open_type
|
||||
,first_response_duration=excluded.first_response_duration
|
||||
,start_time=excluded.start_time
|
||||
,end_time=excluded.end_time
|
||||
,chat_duration_in_seconds=excluded.chat_duration_in_seconds
|
||||
,queue_time=excluded.queue_time
|
||||
,join_queue_time=excluded.join_queue_time
|
||||
,bridge_time=excluded.bridge_time
|
||||
,session_type=excluded.session_type
|
||||
,chat_valid_session=excluded.chat_valid_session
|
||||
,comment_session=excluded.comment_session
|
||||
,invitation_initiator=excluded.invitation_initiator
|
||||
,satisfaction_keys=excluded.satisfaction_keys
|
||||
,satisfaction_remark=excluded.satisfaction_remark
|
||||
,visitor_ip=excluded.visitor_ip
|
||||
,visitor_region=excluded.visitor_region
|
||||
,chat_times=excluded.chat_times
|
||||
,invited_times=excluded.invited_times
|
||||
,search_word=excluded.search_word
|
||||
,operating_system=excluded.operating_system
|
||||
,browser=excluded.browser
|
||||
,referer_url=excluded.referer_url
|
||||
,first_visit_page_url=excluded.first_visit_page_url
|
||||
,initiation_page_url=excluded.initiation_page_url
|
||||
,visit_tracks=excluded.visit_tracks
|
||||
,visitor_extra_info=excluded.visitor_extra_info
|
||||
,device_type=excluded.device_type
|
||||
,contact_app_type=excluded.contact_app_type
|
||||
,visitor_province=excluded.visitor_province
|
||||
,visitor_city=excluded.visitor_city
|
||||
,referer_name=excluded.referer_name
|
||||
,Etl_Batch_No=excluded.Etl_Batch_No
|
||||
,Etl_First_Dt=excluded.Etl_First_Dt
|
||||
,Etl_Job=excluded.Etl_Job
|
||||
,Etl_Proc_Dt=excluded.Etl_Proc_Dt
|
||||
,Etl_Tx_Dt=excluded.Etl_Tx_Dt
|
||||
,Src_Sysname=excluded.Src_Sysname
|
||||
,Src_Table=excluded.Src_Table
|
||||
|
||||
|
||||
;
|
||||
/*****程序结束退出 */
|
||||
\q
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
DROP TABLE IF EXISTS p60_mart.cust_chat_record_info;
|
||||
CREATE TABLE IF NOT EXISTS p60_mart.cust_chat_record_info (
|
||||
chat_unique_id VARCHAR(50)
|
||||
, contact_channel VARCHAR(10)
|
||||
, contact_app_id VARCHAR(50)
|
||||
, app_name VARCHAR(50)
|
||||
, queue_name VARCHAR(10)
|
||||
, start_time timestamp(0)
|
||||
, end_time timestamp(0)
|
||||
, chat_duration_in_seconds int4
|
||||
, queue_time int4
|
||||
, referer_url text
|
||||
, first_visit_page_url text
|
||||
, visitor_id VARCHAR(50)
|
||||
, visitor_name varchar(50)
|
||||
, visitor_mobile varchar(20)
|
||||
, visitor_email varchar(50)
|
||||
, visitor_company varchar(50)
|
||||
, Etl_Batch_No varchar(50)
|
||||
, Etl_First_Dt timestamp(0)
|
||||
, Etl_Job varchar(200)
|
||||
, Etl_Proc_Dt timestamp(0)
|
||||
, Etl_Tx_Dt timestamp(0)
|
||||
, Src_Sysname varchar(50)
|
||||
, Src_Table varchar(50)
|
||||
,primary key( chat_unique_id )
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.chat_unique_id IS '在线客服会话ID';
|
||||
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.app_name IS '接入号名称';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.queue_name 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.chat_duration_in_seconds IS '会话持续时间';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.queue_time IS '排队时长';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.referer_url IS '来源页';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.first_visit_page_url IS '着陆页';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.visitor_id IS '访客ID';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.visitor_name 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_company 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_Job IS '作业名称';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Etl_Proc_Dt IS '本次入库时间';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Etl_Tx_Dt IS '作业运行时间';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Src_Sysname IS '来源系统';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.Src_Table IS '来源表';
|
||||
|
||||
COMMENT ON TABLE p60_mart.cust_chat_record_info IS 'ccc客户会话记录信息';
|
|
@ -0,0 +1,276 @@
|
|||
/***************************************************************************************************/
|
||||
/*script in Sql, generate by SdmCreateScript 2020(by Qihang Feng, QF255001@TERADATA.COM) */
|
||||
/*VERSION 01.10 revised on 2020-08-25 */
|
||||
/*Brilliance stems from wisdoms. */
|
||||
/*************Head Section**************************************************************************/
|
||||
/*Script Use: Periodically load data to :cust_chat_record_info(ccc客户会话记录信息) */
|
||||
/*Create Date:2024-08-14 14:33:46 */
|
||||
/*SDM Developed By: dev */
|
||||
/*SDM Developed Date: 2024-08-14 */
|
||||
/*SDM Checked By: dev */
|
||||
/*SDM Checked Date: 2024-08-14 */
|
||||
/*Script Developed By: dev */
|
||||
/*Script Checked By: dev */
|
||||
/*Source table 1: :COMMDB.select replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') as visitor_id ,* from p30_common.d_ccc_cust_info dcci
|
||||
where visitor_ids <>''*/
|
||||
/*Source table 2: :COMMDB.cust_chat_ccc_record */
|
||||
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
||||
/*Target Table:cust_chat_record_info */
|
||||
/*ETL Job Name:cust_chat_record_info */
|
||||
/*ETL Frequency:Daily */
|
||||
/*ETL Policy:F2 */
|
||||
/********************************************************************************************/
|
||||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载当前数据 */
|
||||
CREATE TEMPORARY TABLE cust_chat_record_info_agi_CUR_I
|
||||
( LIKE :MARTDB.cust_chat_record_info)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载不同数据 */
|
||||
CREATE TEMPORARY TABLE cust_chat_record_info_agi_INS
|
||||
( LIKE :MARTDB.cust_chat_record_info)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/* GROUP 1:Source Table:cust_chat_ccc_record**********************************************************/
|
||||
/*****************************************************************************************************/
|
||||
INSERT INTO cust_chat_record_info_agi_CUR_I (
|
||||
chat_unique_id /*在线客服会话ID*/
|
||||
,contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
,queue_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 /*访客公司*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
)
|
||||
SELECT
|
||||
COALESCE(TRIM(p0.chat_unique_id),'') /*chat_unique_id*/
|
||||
,COALESCE(TRIM(p0.contact_channel),'') /*contact_channel*/
|
||||
,COALESCE(TRIM(p0.contact_app_id),'') /*contact_app_id*/
|
||||
,COALESCE(TRIM(p0.app_name),'') /*app_name*/
|
||||
,COALESCE(TRIM(p0.queue_name),'') /*queue_name*/
|
||||
,COALESCE(p0.start_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*start_time*/
|
||||
,COALESCE(p0.end_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*end_time*/
|
||||
,COALESCE(p0.chat_duration_in_seconds,0) /*chat_duration_in_seconds*/
|
||||
,COALESCE(p0.queue_time,0) /*queue_time*/
|
||||
,COALESCE(TRIM(p0.referer_url),'') /*referer_url*/
|
||||
,COALESCE(TRIM(p0.first_visit_page_url),'') /*first_visit_page_url*/
|
||||
,COALESCE(TRIM(p0.visitor_id),'') /*visitor_id*/
|
||||
,coalesce(p1.name,'') /*visitor_name*/
|
||||
,coalesce(p1.tel,'') /*visitor_mobile*/
|
||||
,coalesce(p1.email,'') /*visitor_email*/
|
||||
,coalesce(p1.company,'') /*visitor_company*/
|
||||
,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_chat_ccc_record',1,3) /*Src_Sysname*/
|
||||
,'cust_chat_ccc_record' /*Src_Table*/
|
||||
|
||||
FROM :COMMDB.cust_chat_ccc_record p0
|
||||
LEFT JOIN (select replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') as visitor_id ,* from p30_common.d_ccc_cust_info dcci
|
||||
where visitor_ids <>'') p1
|
||||
ON p0 .visitor_id =p1 .visitor_id
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*将不同数据插入到临时表 */
|
||||
;INSERT INTO cust_chat_record_info_agi_INS (
|
||||
contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
,queue_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 /*访客公司*/
|
||||
,chat_unique_id /*在线客服会话ID*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.contact_channel /*接入渠道*/
|
||||
,P1.contact_app_id /*接入号ID*/
|
||||
,P1.app_name /*接入号名称*/
|
||||
,P1.queue_name /*队列名称*/
|
||||
,P1.start_time /*会话开始时间戳*/
|
||||
,P1.end_time /*会话结束时间戳*/
|
||||
,P1.chat_duration_in_seconds /*会话持续时间*/
|
||||
,P1.queue_time /*排队时长*/
|
||||
,P1.referer_url /*来源页*/
|
||||
,P1.first_visit_page_url /*着陆页*/
|
||||
,P1.visitor_id /*访客ID*/
|
||||
,P1.visitor_name /*访客姓名*/
|
||||
,P1.visitor_mobile /*访客手机*/
|
||||
,P1.visitor_email /*访客邮箱*/
|
||||
,P1.visitor_company /*访客公司*/
|
||||
,P1.chat_unique_id /*在线客服会话ID*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM cust_chat_record_info_agi_CUR_I P1
|
||||
LEFT JOIN :MARTDB.cust_chat_record_info P2
|
||||
ON P1.contact_channel = P2.contact_channel
|
||||
AND P1.contact_app_id = P2.contact_app_id
|
||||
AND P1.app_name = P2.app_name
|
||||
AND P1.queue_name = P2.queue_name
|
||||
AND P1.start_time = P2.start_time
|
||||
AND P1.end_time = P2.end_time
|
||||
AND P1.chat_duration_in_seconds = P2.chat_duration_in_seconds
|
||||
AND P1.queue_time = P2.queue_time
|
||||
AND P1.referer_url = P2.referer_url
|
||||
AND P1.first_visit_page_url = P2.first_visit_page_url
|
||||
AND P1.visitor_id = P2.visitor_id
|
||||
AND P1.visitor_name = P2.visitor_name
|
||||
AND P1.visitor_mobile = P2.visitor_mobile
|
||||
AND P1.visitor_email = P2.visitor_email
|
||||
AND P1.visitor_company = P2.visitor_company
|
||||
AND P1.chat_unique_id = P2.chat_unique_id
|
||||
|
||||
WHERE P2.contact_channel IS NULL
|
||||
OR P2.contact_app_id IS NULL
|
||||
OR P2.app_name IS NULL
|
||||
OR P2.queue_name IS NULL
|
||||
OR P2.start_time IS NULL
|
||||
OR P2.end_time IS NULL
|
||||
OR P2.chat_duration_in_seconds IS NULL
|
||||
OR P2.queue_time IS NULL
|
||||
OR P2.referer_url IS NULL
|
||||
OR P2.first_visit_page_url IS NULL
|
||||
OR P2.visitor_id IS NULL
|
||||
OR P2.visitor_name IS NULL
|
||||
OR P2.visitor_mobile IS NULL
|
||||
OR P2.visitor_email IS NULL
|
||||
OR P2.visitor_company IS NULL
|
||||
OR P2.chat_unique_id IS NULL
|
||||
|
||||
;
|
||||
/*将新增数据插入到目标表 */
|
||||
;INSERT INTO :MARTDB.cust_chat_record_info (
|
||||
contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
,queue_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 /*访客公司*/
|
||||
,chat_unique_id /*在线客服会话ID*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.contact_channel /*接入渠道*/
|
||||
,P1.contact_app_id /*接入号ID*/
|
||||
,P1.app_name /*接入号名称*/
|
||||
,P1.queue_name /*队列名称*/
|
||||
,P1.start_time /*会话开始时间戳*/
|
||||
,P1.end_time /*会话结束时间戳*/
|
||||
,P1.chat_duration_in_seconds /*会话持续时间*/
|
||||
,P1.queue_time /*排队时长*/
|
||||
,P1.referer_url /*来源页*/
|
||||
,P1.first_visit_page_url /*着陆页*/
|
||||
,P1.visitor_id /*访客ID*/
|
||||
,P1.visitor_name /*访客姓名*/
|
||||
,P1.visitor_mobile /*访客手机*/
|
||||
,P1.visitor_email /*访客邮箱*/
|
||||
,P1.visitor_company /*访客公司*/
|
||||
,P1.chat_unique_id /*在线客服会话ID*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM cust_chat_record_info_agi_INS P1
|
||||
ON CONFLICT ( chat_unique_id)
|
||||
DO UPDATE SET
|
||||
chat_unique_id=excluded.chat_unique_id
|
||||
,contact_channel=excluded.contact_channel
|
||||
,contact_app_id=excluded.contact_app_id
|
||||
,app_name=excluded.app_name
|
||||
,queue_name=excluded.queue_name
|
||||
,start_time=excluded.start_time
|
||||
,end_time=excluded.end_time
|
||||
,chat_duration_in_seconds=excluded.chat_duration_in_seconds
|
||||
,queue_time=excluded.queue_time
|
||||
,referer_url=excluded.referer_url
|
||||
,first_visit_page_url=excluded.first_visit_page_url
|
||||
,visitor_id=excluded.visitor_id
|
||||
,visitor_name=excluded.visitor_name
|
||||
,visitor_mobile=excluded.visitor_mobile
|
||||
,visitor_email=excluded.visitor_email
|
||||
,visitor_company=excluded.visitor_company
|
||||
,Etl_Batch_No=excluded.Etl_Batch_No
|
||||
,Etl_First_Dt=excluded.Etl_First_Dt
|
||||
,Etl_Job=excluded.Etl_Job
|
||||
,Etl_Proc_Dt=excluded.Etl_Proc_Dt
|
||||
,Etl_Tx_Dt=excluded.Etl_Tx_Dt
|
||||
,Src_Sysname=excluded.Src_Sysname
|
||||
,Src_Table=excluded.Src_Table
|
||||
|
||||
|
||||
;
|
||||
/*****程序结束退出 */
|
||||
\q
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
DROP TABLE IF EXISTS p30_common.d_ccc_cust_info;
|
||||
CREATE TABLE IF NOT EXISTS p30_common.d_ccc_cust_info (
|
||||
id VARCHAR(10)
|
||||
, name VARCHAR(20)
|
||||
, sex VARCHAR(10)
|
||||
, tel text
|
||||
, email VARCHAR(100)
|
||||
, address text
|
||||
, prov varchar(10)
|
||||
, city varchar(20)
|
||||
, industry varchar(50)
|
||||
, company varchar(50)
|
||||
, app varchar(50)
|
||||
, level VARCHAR(10)
|
||||
, share_type VARCHAR(10)
|
||||
, share VARCHAR(10)
|
||||
, remark text
|
||||
, source VARCHAR(10)
|
||||
, last_contact_time timestamp(0)
|
||||
, last_contact_type VARCHAR(10)
|
||||
, create_time timestamp(0)
|
||||
, update_time timestamp(0)
|
||||
, visitor_ids text
|
||||
, external_id VARCHAR(100)
|
||||
, phase_id VARCHAR(10)
|
||||
, phase_reason_id VARCHAR(10)
|
||||
, promote_source VARCHAR(20)
|
||||
, Etl_Batch_No varchar(50)
|
||||
, Etl_First_Dt timestamp(0)
|
||||
, Etl_Job varchar(200)
|
||||
, Etl_Proc_Dt timestamp(0)
|
||||
, Etl_Tx_Dt timestamp(0)
|
||||
, Src_Sysname varchar(50)
|
||||
, Src_Table varchar(50)
|
||||
,primary key( id )
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.id IS '客户资料id';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.name IS '客户名称';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.sex IS '客户性别';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.tel IS '客户号码';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.email IS '邮箱';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.address IS '地址';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.prov IS '省份';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.city IS '城市';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.industry IS '行业';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.company IS '公司';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.app IS '应用';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.level IS '客户等级';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.share_type IS '归属类型,0:全体共享、1:员工组共享、2:员工私有、3:无归属';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.share IS '客户归属';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.remark IS '备注';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.source IS '客户来源';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.last_contact_time IS '最后一次联系时间';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.last_contact_type IS '最后一次联系类型';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.create_time IS '创建时间';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.update_time IS '更新时间';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.visitor_ids IS '访客ids';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.external_id IS '外部企业客户ID (第三方平台 ID)';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.phase_id IS '客户阶段id';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.phase_reason_id IS '阶段原因id';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.promote_source IS '推广来源';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.Etl_Batch_No IS '作业批次号';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.Etl_First_Dt IS '最初入库时间';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.Etl_Job IS '作业名称';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.Etl_Proc_Dt IS '本次入库时间';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.Etl_Tx_Dt IS '作业运行时间';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.Src_Sysname IS '来源系统';
|
||||
COMMENT ON COLUMN p30_common.d_ccc_cust_info.Src_Table IS '来源表';
|
||||
|
||||
COMMENT ON TABLE p30_common.d_ccc_cust_info IS 'ccc客户信息';
|
|
@ -0,0 +1,362 @@
|
|||
/***************************************************************************************************/
|
||||
/*script in Sql, generate by SdmCreateScript 2020(by Qihang Feng, QF255001@TERADATA.COM) */
|
||||
/*VERSION 01.10 revised on 2020-08-25 */
|
||||
/*Brilliance stems from wisdoms. */
|
||||
/*************Head Section**************************************************************************/
|
||||
/*Script Use: Periodically load data to :d_ccc_cust_info(ccc客户信息) */
|
||||
/*Create Date:2024-08-01 10:57:52 */
|
||||
/*SDM Developed By: dev */
|
||||
/*SDM Developed Date: 2024-08-01 */
|
||||
/*SDM Checked By: dev */
|
||||
/*SDM Checked Date: 2024-08-01 */
|
||||
/*Script Developed By: dev */
|
||||
/*Script Checked By: dev */
|
||||
/*Source table 1: :PDMDB.t01_ccc_cust_info */
|
||||
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
||||
/*Target Table:d_ccc_cust_info */
|
||||
/*ETL Job Name:d_ccc_cust_info */
|
||||
/*ETL Frequency:Daily */
|
||||
/*ETL Policy:F2 */
|
||||
/********************************************************************************************/
|
||||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载当前数据 */
|
||||
CREATE TEMPORARY TABLE d_ccc_cust_info_agi_CUR_I
|
||||
( LIKE :COMMDB.d_ccc_cust_info)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载不同数据 */
|
||||
CREATE TEMPORARY TABLE d_ccc_cust_info_agi_INS
|
||||
( LIKE :COMMDB.d_ccc_cust_info)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/* GROUP 1:Source Table:t01_ccc_cust_info*************************************************************/
|
||||
/*****************************************************************************************************/
|
||||
INSERT INTO d_ccc_cust_info_agi_CUR_I (
|
||||
id /*客户资料id*/
|
||||
,name /*客户名称*/
|
||||
,sex /*客户性别*/
|
||||
,tel /*客户号码*/
|
||||
,email /*邮箱*/
|
||||
,address /*地址*/
|
||||
,prov /*省份*/
|
||||
,city /*城市*/
|
||||
,industry /*行业*/
|
||||
,company /*公司*/
|
||||
,app /*应用*/
|
||||
,level /*客户等级*/
|
||||
,share_type /*归属类型,0:全体共享、1:员工组共享、2:员工私有、3:无归属*/
|
||||
,share /*客户归属*/
|
||||
,remark /*备注*/
|
||||
,source /*客户来源*/
|
||||
,last_contact_time /*最后一次联系时间*/
|
||||
,last_contact_type /*最后一次联系类型*/
|
||||
,create_time /*创建时间*/
|
||||
,update_time /*更新时间*/
|
||||
,visitor_ids /*访客ids*/
|
||||
,external_id /*外部企业客户ID (第三方平台 ID)*/
|
||||
,phase_id /*客户阶段id*/
|
||||
,phase_reason_id /*阶段原因id*/
|
||||
,promote_source /*推广来源*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
)
|
||||
SELECT
|
||||
COALESCE(TRIM(p0.id),'') /*id*/
|
||||
,COALESCE(TRIM(p0.name),'') /*name*/
|
||||
,COALESCE(TRIM(p0.sex),'') /*sex*/
|
||||
,coalesce(replace(replace(replace(replace(split_part(p0.tel,',',1),'"',''),'[',''),']',''),'null',''),'') /*tel*/
|
||||
,COALESCE(TRIM(p0.email),'') /*email*/
|
||||
,COALESCE(TRIM(p0.address),'') /*address*/
|
||||
,coalesce((SELECT jsonb_extract_path_text(j, 'value')
|
||||
FROM jsonb_array_elements(p0.customize::jsonb) j
|
||||
WHERE jsonb_extract_path_text(j, 'name') = '省份'),'') /*prov*/
|
||||
,coalesce((SELECT jsonb_extract_path_text(j, 'value')
|
||||
FROM jsonb_array_elements(p0.customize::jsonb) j
|
||||
WHERE jsonb_extract_path_text(j, 'name') = '城市'),'') /*city*/
|
||||
,coalesce((SELECT jsonb_extract_path_text(j, 'value')
|
||||
FROM jsonb_array_elements(p0.customize::jsonb) j
|
||||
WHERE jsonb_extract_path_text(j, 'name') = '行业'),'') /*industry*/
|
||||
,coalesce((SELECT jsonb_extract_path_text(j, 'value')
|
||||
FROM jsonb_array_elements(p0.customize::jsonb) j
|
||||
WHERE jsonb_extract_path_text(j, 'name') = '公司名称'),'') /*company*/
|
||||
,coalesce((SELECT jsonb_extract_path_text(j, 'value')
|
||||
FROM jsonb_array_elements(p0.customize::jsonb) j
|
||||
WHERE jsonb_extract_path_text(j, 'name') = '应用'),'') /*app*/
|
||||
,COALESCE(TRIM(p0.level),'') /*level*/
|
||||
,COALESCE(TRIM(p0.share_type),'') /*share_type*/
|
||||
,COALESCE(TRIM(p0.share),'') /*share*/
|
||||
,COALESCE(TRIM(p0.remark),'') /*remark*/
|
||||
,COALESCE(TRIM(p0.source),'') /*source*/
|
||||
,COALESCE(p0.last_contact_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*last_contact_time*/
|
||||
,COALESCE(TRIM(p0.last_contact_type),'') /*last_contact_type*/
|
||||
,COALESCE(p0.create_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*create_time*/
|
||||
,COALESCE(p0.update_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*update_time*/
|
||||
,COALESCE(TRIM(p0.visitor_ids),'') /*visitor_ids*/
|
||||
,COALESCE(TRIM(p0.external_id),'') /*external_id*/
|
||||
,COALESCE(TRIM(p0.phase_id),'') /*phase_id*/
|
||||
,COALESCE(TRIM(p0.phase_reason_id),'') /*phase_reason_id*/
|
||||
,COALESCE(TRIM(p0.promote_source),'') /*promote_source*/
|
||||
,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_ccc_cust_info',1,3) /*Src_Sysname*/
|
||||
,'t01_ccc_cust_info' /*Src_Table*/
|
||||
|
||||
FROM :PDMDB.t01_ccc_cust_info p0
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*将不同数据插入到临时表 */
|
||||
;INSERT INTO d_ccc_cust_info_agi_INS (
|
||||
name /*客户名称*/
|
||||
,sex /*客户性别*/
|
||||
,tel /*客户号码*/
|
||||
,email /*邮箱*/
|
||||
,address /*地址*/
|
||||
,prov /*省份*/
|
||||
,city /*城市*/
|
||||
,industry /*行业*/
|
||||
,company /*公司*/
|
||||
,app /*应用*/
|
||||
,level /*客户等级*/
|
||||
,share_type /*归属类型,0:全体共享、1:员工组共享、2:员工私有、3:无归属*/
|
||||
,share /*客户归属*/
|
||||
,remark /*备注*/
|
||||
,source /*客户来源*/
|
||||
,last_contact_time /*最后一次联系时间*/
|
||||
,last_contact_type /*最后一次联系类型*/
|
||||
,create_time /*创建时间*/
|
||||
,update_time /*更新时间*/
|
||||
,visitor_ids /*访客ids*/
|
||||
,external_id /*外部企业客户ID (第三方平台 ID)*/
|
||||
,phase_id /*客户阶段id*/
|
||||
,phase_reason_id /*阶段原因id*/
|
||||
,promote_source /*推广来源*/
|
||||
,id /*客户资料id*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.name /*客户名称*/
|
||||
,P1.sex /*客户性别*/
|
||||
,P1.tel /*客户号码*/
|
||||
,P1.email /*邮箱*/
|
||||
,P1.address /*地址*/
|
||||
,P1.prov /*省份*/
|
||||
,P1.city /*城市*/
|
||||
,P1.industry /*行业*/
|
||||
,P1.company /*公司*/
|
||||
,P1.app /*应用*/
|
||||
,P1.level /*客户等级*/
|
||||
,P1.share_type /*归属类型,0:全体共享、1:员工组共享、2:员工私有、3:无归属*/
|
||||
,P1.share /*客户归属*/
|
||||
,P1.remark /*备注*/
|
||||
,P1.source /*客户来源*/
|
||||
,P1.last_contact_time /*最后一次联系时间*/
|
||||
,P1.last_contact_type /*最后一次联系类型*/
|
||||
,P1.create_time /*创建时间*/
|
||||
,P1.update_time /*更新时间*/
|
||||
,P1.visitor_ids /*访客ids*/
|
||||
,P1.external_id /*外部企业客户ID (第三方平台 ID)*/
|
||||
,P1.phase_id /*客户阶段id*/
|
||||
,P1.phase_reason_id /*阶段原因id*/
|
||||
,P1.promote_source /*推广来源*/
|
||||
,P1.id /*客户资料id*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM d_ccc_cust_info_agi_CUR_I P1
|
||||
LEFT JOIN :COMMDB.d_ccc_cust_info P2
|
||||
ON P1.name = P2.name
|
||||
AND P1.sex = P2.sex
|
||||
AND P1.tel = P2.tel
|
||||
AND P1.email = P2.email
|
||||
AND P1.address = P2.address
|
||||
AND P1.prov = P2.prov
|
||||
AND P1.city = P2.city
|
||||
AND P1.industry = P2.industry
|
||||
AND P1.company = P2.company
|
||||
AND P1.app = P2.app
|
||||
AND P1.level = P2.level
|
||||
AND P1.share_type = P2.share_type
|
||||
AND P1.share = P2.share
|
||||
AND P1.remark = P2.remark
|
||||
AND P1.source = P2.source
|
||||
AND P1.last_contact_time = P2.last_contact_time
|
||||
AND P1.last_contact_type = P2.last_contact_type
|
||||
AND P1.create_time = P2.create_time
|
||||
AND P1.update_time = P2.update_time
|
||||
AND P1.visitor_ids = P2.visitor_ids
|
||||
AND P1.external_id = P2.external_id
|
||||
AND P1.phase_id = P2.phase_id
|
||||
AND P1.phase_reason_id = P2.phase_reason_id
|
||||
AND P1.promote_source = P2.promote_source
|
||||
AND P1.id = P2.id
|
||||
|
||||
WHERE P2.name IS NULL
|
||||
OR P2.sex IS NULL
|
||||
OR P2.tel IS NULL
|
||||
OR P2.email IS NULL
|
||||
OR P2.address IS NULL
|
||||
OR P2.prov IS NULL
|
||||
OR P2.city IS NULL
|
||||
OR P2.industry IS NULL
|
||||
OR P2.company IS NULL
|
||||
OR P2.app IS NULL
|
||||
OR P2.level IS NULL
|
||||
OR P2.share_type IS NULL
|
||||
OR P2.share IS NULL
|
||||
OR P2.remark IS NULL
|
||||
OR P2.source IS NULL
|
||||
OR P2.last_contact_time IS NULL
|
||||
OR P2.last_contact_type IS NULL
|
||||
OR P2.create_time IS NULL
|
||||
OR P2.update_time IS NULL
|
||||
OR P2.visitor_ids IS NULL
|
||||
OR P2.external_id IS NULL
|
||||
OR P2.phase_id IS NULL
|
||||
OR P2.phase_reason_id IS NULL
|
||||
OR P2.promote_source IS NULL
|
||||
OR P2.id IS NULL
|
||||
|
||||
;
|
||||
/*将新增数据插入到目标表 */
|
||||
;INSERT INTO :COMMDB.d_ccc_cust_info (
|
||||
name /*客户名称*/
|
||||
,sex /*客户性别*/
|
||||
,tel /*客户号码*/
|
||||
,email /*邮箱*/
|
||||
,address /*地址*/
|
||||
,prov /*省份*/
|
||||
,city /*城市*/
|
||||
,industry /*行业*/
|
||||
,company /*公司*/
|
||||
,app /*应用*/
|
||||
,level /*客户等级*/
|
||||
,share_type /*归属类型,0:全体共享、1:员工组共享、2:员工私有、3:无归属*/
|
||||
,share /*客户归属*/
|
||||
,remark /*备注*/
|
||||
,source /*客户来源*/
|
||||
,last_contact_time /*最后一次联系时间*/
|
||||
,last_contact_type /*最后一次联系类型*/
|
||||
,create_time /*创建时间*/
|
||||
,update_time /*更新时间*/
|
||||
,visitor_ids /*访客ids*/
|
||||
,external_id /*外部企业客户ID (第三方平台 ID)*/
|
||||
,phase_id /*客户阶段id*/
|
||||
,phase_reason_id /*阶段原因id*/
|
||||
,promote_source /*推广来源*/
|
||||
,id /*客户资料id*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.name /*客户名称*/
|
||||
,P1.sex /*客户性别*/
|
||||
,P1.tel /*客户号码*/
|
||||
,P1.email /*邮箱*/
|
||||
,P1.address /*地址*/
|
||||
,P1.prov /*省份*/
|
||||
,P1.city /*城市*/
|
||||
,P1.industry /*行业*/
|
||||
,P1.company /*公司*/
|
||||
,P1.app /*应用*/
|
||||
,P1.level /*客户等级*/
|
||||
,P1.share_type /*归属类型,0:全体共享、1:员工组共享、2:员工私有、3:无归属*/
|
||||
,P1.share /*客户归属*/
|
||||
,P1.remark /*备注*/
|
||||
,P1.source /*客户来源*/
|
||||
,P1.last_contact_time /*最后一次联系时间*/
|
||||
,P1.last_contact_type /*最后一次联系类型*/
|
||||
,P1.create_time /*创建时间*/
|
||||
,P1.update_time /*更新时间*/
|
||||
,P1.visitor_ids /*访客ids*/
|
||||
,P1.external_id /*外部企业客户ID (第三方平台 ID)*/
|
||||
,P1.phase_id /*客户阶段id*/
|
||||
,P1.phase_reason_id /*阶段原因id*/
|
||||
,P1.promote_source /*推广来源*/
|
||||
,P1.id /*客户资料id*/
|
||||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
,P1.Etl_Tx_Dt /*作业运行时间*/
|
||||
,P1.Src_Sysname /*来源系统*/
|
||||
,P1.Src_Table /*来源表*/
|
||||
|
||||
FROM d_ccc_cust_info_agi_INS P1
|
||||
ON CONFLICT ( id)
|
||||
DO UPDATE SET
|
||||
id=excluded.id
|
||||
,name=excluded.name
|
||||
,sex=excluded.sex
|
||||
,tel=excluded.tel
|
||||
,email=excluded.email
|
||||
,address=excluded.address
|
||||
,prov=excluded.prov
|
||||
,city=excluded.city
|
||||
,industry=excluded.industry
|
||||
,company=excluded.company
|
||||
,app=excluded.app
|
||||
,level=excluded.level
|
||||
,share_type=excluded.share_type
|
||||
,share=excluded.share
|
||||
,remark=excluded.remark
|
||||
,source=excluded.source
|
||||
,last_contact_time=excluded.last_contact_time
|
||||
,last_contact_type=excluded.last_contact_type
|
||||
,create_time=excluded.create_time
|
||||
,update_time=excluded.update_time
|
||||
,visitor_ids=excluded.visitor_ids
|
||||
,external_id=excluded.external_id
|
||||
,phase_id=excluded.phase_id
|
||||
,phase_reason_id=excluded.phase_reason_id
|
||||
,promote_source=excluded.promote_source
|
||||
,Etl_Batch_No=excluded.Etl_Batch_No
|
||||
,Etl_First_Dt=excluded.Etl_First_Dt
|
||||
,Etl_Job=excluded.Etl_Job
|
||||
,Etl_Proc_Dt=excluded.Etl_Proc_Dt
|
||||
,Etl_Tx_Dt=excluded.Etl_Tx_Dt
|
||||
,Src_Sysname=excluded.Src_Sysname
|
||||
,Src_Table=excluded.Src_Table
|
||||
|
||||
|
||||
;
|
||||
/*****程序结束退出 */
|
||||
\q
|
||||
|
|
@ -91,8 +91,36 @@ params={'my_param':"t01_ccc_chat_message_detail_agi"},
|
|||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
d_ccc_cust_info = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='d_ccc_cust_info',
|
||||
command='/data/airflow/etl/COM/run_psql.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"d_ccc_cust_info_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
cust_chat_ccc_record = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='cust_chat_ccc_record',
|
||||
command='/data/airflow/etl/COM/run_psql.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"cust_chat_ccc_record_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
cust_chat_record_info = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='cust_chat_record_info',
|
||||
command='/data/airflow/etl/MART/run_psql.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"cust_chat_record_info_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
chat_records_load >> tr_chat_records_2337
|
||||
chat_records_load >> tr_chat_messages_4800
|
||||
tr_chat_records_2337 >> t01_ccc_chat_record
|
||||
tr_chat_messages_4800 >> t01_ccc_chat_message_detail
|
||||
t01_ccc_chat_message_detail >> task_failed
|
||||
t01_ccc_chat_record >> d_ccc_cust_info
|
||||
t01_ccc_chat_record >> cust_chat_ccc_record
|
||||
d_ccc_cust_info >> cust_chat_record_info
|
||||
cust_chat_ccc_record >> cust_chat_record_info
|
||||
cust_chat_record_info >> task_failed
|
||||
|
|
Loading…
Reference in New Issue