add workflow 天润Smart-ccc会话数据,dev
This commit is contained in:
parent
8d1a4021f0
commit
aa9a7fc1f7
|
@ -0,0 +1,48 @@
|
|||
|
||||
DROP TABLE IF EXISTS p20_pdm.t01_ccc_chat_message_detail;
|
||||
CREATE TABLE IF NOT EXISTS p20_pdm.t01_ccc_chat_message_detail (
|
||||
message_unique_id varchar(50)
|
||||
, chat_unique_id varchar(50)
|
||||
, sender_id varchar(50)
|
||||
, sender_name varchar(50)
|
||||
, sender_type varchar(10)
|
||||
, message_type varchar(10)
|
||||
, content text
|
||||
, file_address text
|
||||
, file_name varchar(100)
|
||||
, file_url text
|
||||
, send_status varchar(10)
|
||||
, sensitive_word text
|
||||
, create_time timestamp(0)
|
||||
, 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( message_unique_id )
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.message_unique_id IS ' 消息编号';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.chat_unique_id IS '在线客服会话ID';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.sender_id IS '消息发送方ID';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.sender_name IS '消息发送方名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.sender_type IS '消息发送方类型';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.message_type IS '消息类型';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.content IS '消息内容';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.file_address IS '文件的地址';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.file_name IS '文件名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.file_url IS '文件访问路径';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.send_status IS '消息发送状态';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.sensitive_word IS '敏感词';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.create_time IS '消息创建时间戳';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.Etl_Batch_No IS '作业批次号';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.Etl_First_Dt IS '最初入库时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.Etl_Job IS '作业名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.Etl_Proc_Dt IS '本次入库时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.Etl_Tx_Dt IS '作业运行时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.Src_Sysname IS '来源系统';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_message_detail.Src_Table IS '来源表';
|
||||
|
||||
COMMENT ON TABLE p20_pdm.t01_ccc_chat_message_detail IS 'smartccc会话消息详情';
|
|
@ -0,0 +1,244 @@
|
|||
/***************************************************************************************************/
|
||||
/*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 :t01_ccc_chat_message_detail(smartccc会话消息详情) */
|
||||
/*Create Date:2024-07-19 15:52:26 */
|
||||
/*SDM Developed By: dev */
|
||||
/*SDM Developed Date: 2024-07-19 */
|
||||
/*SDM Checked By: dev */
|
||||
/*SDM Checked Date: 2024-07-19 */
|
||||
/*Script Developed By: dev */
|
||||
/*Script Checked By: dev */
|
||||
/*Source table 1: p10_sa.s98_s_tr_chat_messages */
|
||||
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
||||
/*Target Table:t01_ccc_chat_message_detail */
|
||||
/*ETL Job Name:t01_ccc_chat_message_detail */
|
||||
/*ETL Frequency:Daily */
|
||||
/*ETL Policy:F2 */
|
||||
/********************************************************************************************/
|
||||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载当前数据 */
|
||||
CREATE TEMPORARY TABLE t01_ccc_chat_message_detail_agi_CUR_I
|
||||
( LIKE :PDMDB.t01_ccc_chat_message_detail)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载不同数据 */
|
||||
CREATE TEMPORARY TABLE t01_ccc_chat_message_detail_agi_INS
|
||||
( LIKE :PDMDB.t01_ccc_chat_message_detail)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/* GROUP 1:Source Table:s98_s_tr_chat_messages********************************************************/
|
||||
/*****************************************************************************************************/
|
||||
INSERT INTO t01_ccc_chat_message_detail_agi_CUR_I (
|
||||
message_unique_id /* 消息编号*/
|
||||
,chat_unique_id /*在线客服会话ID*/
|
||||
,sender_id /*消息发送方ID*/
|
||||
,sender_name /*消息发送方名称*/
|
||||
,sender_type /*消息发送方类型*/
|
||||
,message_type /*消息类型*/
|
||||
,content /*消息内容*/
|
||||
,file_address /*文件的地址*/
|
||||
,file_name /*文件名称*/
|
||||
,file_url /*文件访问路径*/
|
||||
,send_status /*消息发送状态*/
|
||||
,sensitive_word /*敏感词*/
|
||||
,create_time /*消息创建时间戳*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
)
|
||||
SELECT
|
||||
COALESCE(TRIM(CAST(p0.unique_id AS varchar(50))),'') /*message_unique_id*/
|
||||
,COALESCE(TRIM(CAST(p0.main_unique_id AS varchar(50))),'') /*chat_unique_id*/
|
||||
,COALESCE(TRIM(CAST(p0.sender_id AS varchar(50))),'') /*sender_id*/
|
||||
,COALESCE(TRIM(CAST(p0.sender_name AS varchar(50))),'') /*sender_name*/
|
||||
,COALESCE(TRIM(CAST(p0.sender_type AS varchar(10))),'') /*sender_type*/
|
||||
,COALESCE(TRIM(CAST(p0.message_type AS varchar(10))),'') /*message_type*/
|
||||
,COALESCE(TRIM(p0.content),'') /*content*/
|
||||
,COALESCE(TRIM(p0.file_key),'') /*file_address*/
|
||||
,COALESCE(TRIM(CAST(p0.file_name AS varchar(100))),'') /*file_name*/
|
||||
,COALESCE(TRIM(p0.file_url),'') /*file_url*/
|
||||
,COALESCE(TRIM(CAST(p0.send_status AS varchar(10))),'') /*send_status*/
|
||||
,COALESCE(TRIM(p0.sensitive_word),'') /*sensitive_word*/
|
||||
,to_timestamp(p0.create_time::bigint/1000)::timestamp(0) /*create_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('s98_s_tr_chat_messages',1,3) /*Src_Sysname*/
|
||||
,'s98_s_tr_chat_messages' /*Src_Table*/
|
||||
|
||||
FROM p10_sa.s98_s_tr_chat_messages p0
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*将不同数据插入到临时表 */
|
||||
;INSERT INTO t01_ccc_chat_message_detail_agi_INS (
|
||||
chat_unique_id /*在线客服会话ID*/
|
||||
,sender_id /*消息发送方ID*/
|
||||
,sender_name /*消息发送方名称*/
|
||||
,sender_type /*消息发送方类型*/
|
||||
,message_type /*消息类型*/
|
||||
,content /*消息内容*/
|
||||
,file_address /*文件的地址*/
|
||||
,file_name /*文件名称*/
|
||||
,file_url /*文件访问路径*/
|
||||
,send_status /*消息发送状态*/
|
||||
,sensitive_word /*敏感词*/
|
||||
,create_time /*消息创建时间戳*/
|
||||
,message_unique_id /* 消息编号*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.chat_unique_id /*在线客服会话ID*/
|
||||
,P1.sender_id /*消息发送方ID*/
|
||||
,P1.sender_name /*消息发送方名称*/
|
||||
,P1.sender_type /*消息发送方类型*/
|
||||
,P1.message_type /*消息类型*/
|
||||
,P1.content /*消息内容*/
|
||||
,P1.file_address /*文件的地址*/
|
||||
,P1.file_name /*文件名称*/
|
||||
,P1.file_url /*文件访问路径*/
|
||||
,P1.send_status /*消息发送状态*/
|
||||
,P1.sensitive_word /*敏感词*/
|
||||
,P1.create_time /*消息创建时间戳*/
|
||||
,P1.message_unique_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 t01_ccc_chat_message_detail_agi_CUR_I P1
|
||||
LEFT JOIN :PDMDB.t01_ccc_chat_message_detail P2
|
||||
ON P1.chat_unique_id = P2.chat_unique_id
|
||||
AND P1.sender_id = P2.sender_id
|
||||
AND P1.sender_name = P2.sender_name
|
||||
AND P1.sender_type = P2.sender_type
|
||||
AND P1.message_type = P2.message_type
|
||||
AND P1.content = P2.content
|
||||
AND P1.file_address = P2.file_address
|
||||
AND P1.file_name = P2.file_name
|
||||
AND P1.file_url = P2.file_url
|
||||
AND P1.send_status = P2.send_status
|
||||
AND P1.sensitive_word = P2.sensitive_word
|
||||
AND P1.create_time = P2.create_time
|
||||
AND P1.message_unique_id = P2.message_unique_id
|
||||
|
||||
WHERE P2.chat_unique_id IS NULL
|
||||
OR P2.sender_id IS NULL
|
||||
OR P2.sender_name IS NULL
|
||||
OR P2.sender_type IS NULL
|
||||
OR P2.message_type IS NULL
|
||||
OR P2.content IS NULL
|
||||
OR P2.file_address IS NULL
|
||||
OR P2.file_name IS NULL
|
||||
OR P2.file_url IS NULL
|
||||
OR P2.send_status IS NULL
|
||||
OR P2.sensitive_word IS NULL
|
||||
OR P2.create_time IS NULL
|
||||
OR P2.message_unique_id IS NULL
|
||||
|
||||
;
|
||||
/*将新增数据插入到目标表 */
|
||||
;INSERT INTO :PDMDB.t01_ccc_chat_message_detail (
|
||||
chat_unique_id /*在线客服会话ID*/
|
||||
,sender_id /*消息发送方ID*/
|
||||
,sender_name /*消息发送方名称*/
|
||||
,sender_type /*消息发送方类型*/
|
||||
,message_type /*消息类型*/
|
||||
,content /*消息内容*/
|
||||
,file_address /*文件的地址*/
|
||||
,file_name /*文件名称*/
|
||||
,file_url /*文件访问路径*/
|
||||
,send_status /*消息发送状态*/
|
||||
,sensitive_word /*敏感词*/
|
||||
,create_time /*消息创建时间戳*/
|
||||
,message_unique_id /* 消息编号*/
|
||||
,Etl_Batch_No /*作业批次号*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
,Etl_Tx_Dt /*作业运行时间*/
|
||||
,Src_Sysname /*来源系统*/
|
||||
,Src_Table /*来源表*/
|
||||
|
||||
)
|
||||
SELECT
|
||||
P1.chat_unique_id /*在线客服会话ID*/
|
||||
,P1.sender_id /*消息发送方ID*/
|
||||
,P1.sender_name /*消息发送方名称*/
|
||||
,P1.sender_type /*消息发送方类型*/
|
||||
,P1.message_type /*消息类型*/
|
||||
,P1.content /*消息内容*/
|
||||
,P1.file_address /*文件的地址*/
|
||||
,P1.file_name /*文件名称*/
|
||||
,P1.file_url /*文件访问路径*/
|
||||
,P1.send_status /*消息发送状态*/
|
||||
,P1.sensitive_word /*敏感词*/
|
||||
,P1.create_time /*消息创建时间戳*/
|
||||
,P1.message_unique_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 t01_ccc_chat_message_detail_agi_INS P1
|
||||
ON CONFLICT ( message_unique_id)
|
||||
DO UPDATE SET
|
||||
message_unique_id=excluded.message_unique_id
|
||||
,chat_unique_id=excluded.chat_unique_id
|
||||
,sender_id=excluded.sender_id
|
||||
,sender_name=excluded.sender_name
|
||||
,sender_type=excluded.sender_type
|
||||
,message_type=excluded.message_type
|
||||
,content=excluded.content
|
||||
,file_address=excluded.file_address
|
||||
,file_name=excluded.file_name
|
||||
,file_url=excluded.file_url
|
||||
,send_status=excluded.send_status
|
||||
,sensitive_word=excluded.sensitive_word
|
||||
,create_time=excluded.create_time
|
||||
,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,116 @@
|
|||
|
||||
DROP TABLE IF EXISTS p20_pdm.t01_ccc_chat_record;
|
||||
CREATE TABLE IF NOT EXISTS p20_pdm.t01_ccc_chat_record (
|
||||
chat_unique_id varchar(50)
|
||||
, contact_channel varchar(10)
|
||||
, contact_app_id varchar(50)
|
||||
, app_namecontact_ varchar(50)
|
||||
, visitor_id varchar(50)
|
||||
, visitor_name 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 int
|
||||
, start_time timestamp(0)
|
||||
, end_time timestamp(0)
|
||||
, queue_time int
|
||||
, 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 int
|
||||
, invited_times int
|
||||
, 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 p20_pdm.t01_ccc_chat_record.chat_unique_id IS '在线客服会话ID';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.contact_channel IS '接入渠道';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.contact_app_id IS '接入号ID';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.app_namecontact_ IS '接入号名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.visitor_id IS '访客ID';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.visitor_name IS '访客姓名';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.robot_id IS '机器人客服ID';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.robot_name IS '机器人客服名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.robot_start_time IS '机器人客服接入会话时间戳';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.robot_end_time IS '机器人客服结束会话时间戳';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.queue_no IS '接入队列号';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.queue_name IS '队列名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.client_no IS '接待座席号';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.client_name IS '座席名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.chat_duration_type IS '接待类型';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.close_status IS '会话结束时状态';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.close_reason IS '会话结束原因';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.open_type IS '会话发起方式';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.first_response_duration IS '座席首次响应时长';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.start_time IS '会话开始时间戳';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.end_time IS '会话结束时间戳';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.queue_time IS '排队时长';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.join_queue_time IS '接入队列时间戳';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.bridge_time IS '座席接入时间戳';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.session_type IS '会话是否有人工客服接入';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.chat_valid_session IS '是否是有效会话';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.comment_session IS '是否是通过留言发起的会话';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.invitation_initiator IS '满意度评价发起方式';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.satisfaction_keys IS '满意度评价';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.satisfaction_remark IS '满意度评价备注';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.visitor_ip IS '访客IP';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.visitor_region IS '访问地区';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.chat_times IS '会话次数';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.invited_times IS '被邀请次数';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.search_word IS '搜索词,通过对来源页解析,获取搜索参数参数。';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.operating_system IS '操作系统';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.browser IS '浏览器型号';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.referer_url IS '来源页';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.first_visit_page_url IS '着陆页';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.initiation_page_url IS '会话发起页';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.visit_tracks IS '浏览轨迹';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.visitor_extra_info IS '访客自定义参数';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.device_type IS '访客设备类型';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.contact_app_type IS '接入渠道类型';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.visitor_province IS '访客会话时所在省份';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.visitor_city IS '访客会话时所在城市';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.referer_name IS '访客来源';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.Etl_Batch_No IS '作业批次号';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.Etl_First_Dt IS '最初入库时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.Etl_Job IS '作业名称';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.Etl_Proc_Dt IS '本次入库时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.Etl_Tx_Dt IS '作业运行时间';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.Src_Sysname IS '来源系统';
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_chat_record.Src_Table IS '来源表';
|
||||
|
||||
COMMENT ON TABLE p20_pdm.t01_ccc_chat_record IS 'smartccc会话记录';
|
|
@ -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 :t01_ccc_chat_record(smartccc会话记录) */
|
||||
/*Create Date:2024-07-19 10:30:29 */
|
||||
/*SDM Developed By: dev */
|
||||
/*SDM Developed Date: 2024-07-18 */
|
||||
/*SDM Checked By: dev */
|
||||
/*SDM Checked Date: 2024-07-19 */
|
||||
/*Script Developed By: dev */
|
||||
/*Script Checked By: dev */
|
||||
/*Source table 1: p10_sa.s98_s_tr_chat_records */
|
||||
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
||||
/*Target Table:t01_ccc_chat_record */
|
||||
/*ETL Job Name:t01_ccc_chat_record */
|
||||
/*ETL Frequency:Daily */
|
||||
/*ETL Policy:F2 */
|
||||
/********************************************************************************************/
|
||||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载当前数据 */
|
||||
CREATE TEMPORARY TABLE t01_ccc_chat_record_agi_CUR_I
|
||||
( LIKE :PDMDB.t01_ccc_chat_record)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
|
||||
/*创建临时表加载不同数据 */
|
||||
CREATE TEMPORARY TABLE t01_ccc_chat_record_agi_INS
|
||||
( LIKE :PDMDB.t01_ccc_chat_record)
|
||||
ON COMMIT PRESERVE ROWS;
|
||||
|
||||
|
||||
/*****************************************************************************************************/
|
||||
/* GROUP 1:Source Table:s98_s_tr_chat_records*********************************************************/
|
||||
/*****************************************************************************************************/
|
||||
INSERT INTO t01_ccc_chat_record_agi_CUR_I (
|
||||
chat_unique_id /*在线客服会话ID*/
|
||||
,contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_namecontact_ /*接入号名称*/
|
||||
,visitor_id /*访客ID*/
|
||||
,visitor_name /*访客姓名*/
|
||||
,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 /*会话结束时间戳*/
|
||||
,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(CAST(p0.main_unique_id AS varchar(50))),'') /*chat_unique_id*/
|
||||
,COALESCE(TRIM(CAST(p0.contact_type AS varchar(10))),'') /*contact_channel*/
|
||||
,COALESCE(TRIM(CAST(p0.app_id AS varchar(50))),'') /*contact_app_id*/
|
||||
,COALESCE(TRIM(CAST(p0.app_name AS varchar(50))),'') /*app_namecontact_*/
|
||||
,COALESCE(TRIM(CAST(p0.visitor_id AS varchar(50))),'') /*visitor_id*/
|
||||
,COALESCE(TRIM(CAST(p0.visitor_name AS varchar(50))),'') /*visitor_name*/
|
||||
,COALESCE(TRIM(CAST(p0.robot_id AS varchar(10))),'') /*robot_id*/
|
||||
,COALESCE(TRIM(CAST(p0.robot_name AS varchar(10))),'') /*robot_name*/
|
||||
,to_timestamp(p0.robot_start_time::bigint/1000)::timestamp(0) /*robot_start_time*/
|
||||
,to_timestamp(p0.robot_end_time::bigint/1000)::timestamp(0) /*robot_end_time*/
|
||||
,COALESCE(TRIM(CAST(p0.qno AS varchar(10))),'') /*queue_no*/
|
||||
,COALESCE(TRIM(CAST(p0.qname AS varchar(10))),'') /*queue_name*/
|
||||
,COALESCE(TRIM(CAST(p0.cno AS varchar(10))),'') /*client_no*/
|
||||
,COALESCE(TRIM(CAST(p0.client_name AS varchar(10))),'') /*client_name*/
|
||||
,COALESCE(TRIM(CAST(p0.chat_duration_type AS varchar(10))),'') /*chat_duration_type*/
|
||||
,COALESCE(TRIM(CAST(p0.close_status AS varchar(10))),'') /*close_status*/
|
||||
,COALESCE(TRIM(CAST(p0.close_reason AS varchar(10))),'') /*close_reason*/
|
||||
,COALESCE(TRIM(CAST(p0.open_type AS varchar(10))),'') /*open_type*/
|
||||
,COALESCE(CAST(p0.first_response_duration AS int),0) /*first_response_duration*/
|
||||
,to_timestamp(p0.start_time::bigint/1000)::timestamp(0) /*start_time*/
|
||||
,to_timestamp(p0.end_time::bigint/1000)::timestamp(0) /*end_time*/
|
||||
,COALESCE(CAST(p0.queue_time AS int),0) /*queue_time*/
|
||||
,to_timestamp(p0.join_queue_time::bigint/1000)::timestamp(0) /*join_queue_time*/
|
||||
,to_timestamp(p0.bridge_time::bigint/1000)::timestamp(0) /*bridge_time*/
|
||||
,COALESCE(TRIM(CAST(p0.session_type AS varchar(10))),'') /*session_type*/
|
||||
,COALESCE(TRIM(CAST(p0.chat_valid_session AS varchar(10))),'') /*chat_valid_session*/
|
||||
,COALESCE(TRIM(CAST(p0.comment_session AS varchar(10))),'') /*comment_session*/
|
||||
,COALESCE(TRIM(CAST(p0.invitation_initiator AS varchar(10))),'') /*invitation_initiator*/
|
||||
,COALESCE(TRIM(CAST(p0.keys AS varchar(10))),'') /*satisfaction_keys*/
|
||||
,COALESCE(TRIM(CAST(p0.remark AS varchar(10))),'') /*satisfaction_remark*/
|
||||
,COALESCE(TRIM(CAST(p0.ip AS varchar(20))),'') /*visitor_ip*/
|
||||
,COALESCE(TRIM(CAST(p0.customer_region AS varchar(20))),'') /*visitor_region*/
|
||||
,COALESCE(CAST(p0.chat_times AS int),0) /*chat_times*/
|
||||
,COALESCE(CAST(p0.invited_times AS int),0) /*invited_times*/
|
||||
,COALESCE(TRIM(CAST(p0.search_word AS varchar(20))),'') /*search_word*/
|
||||
,COALESCE(TRIM(CAST(p0.operating_system AS varchar(50))),'') /*operating_system*/
|
||||
,COALESCE(TRIM(CAST(p0.browser AS varchar(50))),'') /*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(CAST(p0.device_type AS varchar(20))),'') /*device_type*/
|
||||
,COALESCE(TRIM(CAST(p0.app_type AS varchar(10))),'') /*contact_app_type*/
|
||||
,COALESCE(TRIM(CAST(p0.province AS varchar(10))),'') /*visitor_province*/
|
||||
,COALESCE(TRIM(CAST(p0.city AS varchar(10))),'') /*visitor_city*/
|
||||
,COALESCE(TRIM(p0.referrer_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('s98_s_tr_chat_records',1,3) /*Src_Sysname*/
|
||||
,'s98_s_tr_chat_records' /*Src_Table*/
|
||||
|
||||
FROM p10_sa.s98_s_tr_chat_records p0
|
||||
;
|
||||
|
||||
|
||||
|
||||
/*将不同数据插入到临时表 */
|
||||
;INSERT INTO t01_ccc_chat_record_agi_INS (
|
||||
contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_namecontact_ /*接入号名称*/
|
||||
,visitor_id /*访客ID*/
|
||||
,visitor_name /*访客姓名*/
|
||||
,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 /*会话结束时间戳*/
|
||||
,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_namecontact_ /*接入号名称*/
|
||||
,P1.visitor_id /*访客ID*/
|
||||
,P1.visitor_name /*访客姓名*/
|
||||
,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.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 t01_ccc_chat_record_agi_CUR_I P1
|
||||
LEFT JOIN :PDMDB.t01_ccc_chat_record P2
|
||||
ON P1.contact_channel = P2.contact_channel
|
||||
AND P1.contact_app_id = P2.contact_app_id
|
||||
AND P1.app_namecontact_ = P2.app_namecontact_
|
||||
AND P1.visitor_id = P2.visitor_id
|
||||
AND P1.visitor_name = P2.visitor_name
|
||||
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.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_namecontact_ IS NULL
|
||||
OR P2.visitor_id IS NULL
|
||||
OR P2.visitor_name 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.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 :PDMDB.t01_ccc_chat_record (
|
||||
contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_namecontact_ /*接入号名称*/
|
||||
,visitor_id /*访客ID*/
|
||||
,visitor_name /*访客姓名*/
|
||||
,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 /*会话结束时间戳*/
|
||||
,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_namecontact_ /*接入号名称*/
|
||||
,P1.visitor_id /*访客ID*/
|
||||
,P1.visitor_name /*访客姓名*/
|
||||
,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.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 t01_ccc_chat_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_namecontact_=excluded.app_namecontact_
|
||||
,visitor_id=excluded.visitor_id
|
||||
,visitor_name=excluded.visitor_name
|
||||
,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
|
||||
,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
|
||||
|
|
@ -24,7 +24,7 @@ default_args = {
|
|||
}
|
||||
|
||||
dag = DAG('wf_dag_smart_ccc_chat', default_args=default_args,
|
||||
schedule_interval="59 0-23/1 * * *",
|
||||
schedule_interval="0 0-23/1 * * *",
|
||||
catchup=False,
|
||||
dagrun_timeout=timedelta(minutes=160),
|
||||
max_active_runs=3)
|
||||
|
@ -37,7 +37,7 @@ task_failed = EmailOperator (
|
|||
cc=[""],
|
||||
subject="smart_ccc_chat_failed",
|
||||
html_content='<h3>您好,smart_ccc_chat作业失败,请及时处理" </h3>')
|
||||
|
||||
|
||||
chat_records_feign = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='chat_records_feign',
|
||||
|
@ -56,7 +56,7 @@ retries=3,
|
|||
dag=dag)
|
||||
|
||||
chat_records_feign >> chat_records_load
|
||||
|
||||
|
||||
tr_chat_messages_4800 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='tr_chat_messages_4800',
|
||||
|
@ -65,7 +65,7 @@ params={'my_param':"S98_S_tr_chat_messages"},
|
|||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
|
||||
tr_chat_records_2337 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='tr_chat_records_2337',
|
||||
|
@ -74,8 +74,45 @@ params={'my_param':"S98_S_tr_chat_records"},
|
|||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
chat_messages_feign = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='chat_messages_feign',
|
||||
command='python3 /data/airflow/etl/API/chat_messages_feign.py',
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
chat_records_load >> tr_chat_records_2337
|
||||
chat_records_load >> tr_chat_messages_4800
|
||||
tr_chat_messages_4800 >> task_failed
|
||||
tr_chat_records_2337 >> task_failed
|
||||
chat_messages_load = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='chat_messages_load',
|
||||
command='/data/airflow/etl/API/run_psql.sh {{ ds_nodash }} {{params.my_param }}',
|
||||
params={'my_param':"chat_messages_load"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
chat_messages_feign >> chat_messages_load
|
||||
|
||||
t01_ccc_chat_record = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t01_ccc_chat_record',
|
||||
command='/data/airflow/etl/PDM/run_psql.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t01_ccc_chat_record_agi"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
t01_ccc_chat_message_detail = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='t01_ccc_chat_message_detail',
|
||||
command='/data/airflow/etl/PDM/run_psql.sh {{ ds_nodash }} {{params.my_param}} >>/data/airflow/logs/run_tpt_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"t01_ccc_chat_message_detail_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
|
||||
chat_messages_load >> task_failed
|
||||
|
|
Loading…
Reference in New Issue