add workflow 天润Smart-ccc会话数据,dev
This commit is contained in:
parent
9a27152401
commit
0ccf2455ed
|
@ -2,7 +2,7 @@
|
|||
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)
|
||||
, platform_name varchar(50)
|
||||
, chat_channel varchar(50)
|
||||
, contact_channel VARCHAR(10)
|
||||
, contact_app_id VARCHAR(50)
|
||||
, app_name VARCHAR(50)
|
||||
|
@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS p60_mart.cust_chat_record_info (
|
|||
);
|
||||
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.chat_unique_id IS '在线客服会话ID';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.platform_name IS '平台';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.chat_channel IS '平台';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.contact_channel IS '接入渠道';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.contact_app_id IS '接入号ID';
|
||||
COMMENT ON COLUMN p60_mart.cust_chat_record_info.app_name IS '接入号名称';
|
||||
|
|
|
@ -4,19 +4,19 @@
|
|||
/*Brilliance stems from wisdoms. */
|
||||
/*************Head Section**************************************************************************/
|
||||
/*Script Use: Periodically load data to :cust_chat_record_info(ccc客户会话记录信息) */
|
||||
/*Create Date:2024-08-20 19:00:40 */
|
||||
/*Create Date:2024-08-22 15:17:11 */
|
||||
/*SDM Developed By: dev */
|
||||
/*SDM Developed Date: 2024-08-14 */
|
||||
/*SDM Checked By: dev */
|
||||
/*SDM Checked Date: 2024-08-20 */
|
||||
/*SDM Checked Date: 2024-08-22 */
|
||||
/*Script Developed By: dev */
|
||||
/*Script Checked By: dev */
|
||||
/*Source table 1: :COMMDB.cust_leads_detail */
|
||||
/*Source table 2: :COMMDB.select replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') as visitor_id ,row_number() over(partition by replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') order by id desc) rn ,* from p30_common.d_ccc_cust_info dcci
|
||||
/*Source table 1: :COMMDB.select replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') as visitor_id ,row_number() over(partition by replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') order by id desc) rn ,* from p30_common.d_ccc_cust_info dcci
|
||||
where visitor_ids <>''*/
|
||||
/*Source table 3: :PDMDB.t01_livechat_record */
|
||||
/*Source table 4: :PDMDB.t99_ccc_code */
|
||||
/*Source table 5: :COMMDB.cust_chat_ccc_record */
|
||||
/*Source table 2: :PDMDB.t01_livechat_record */
|
||||
/*Source table 3: :PDMDB.t99_ccc_code */
|
||||
/*Source table 4: :COMMDB.cust_chat_ccc_record */
|
||||
/*Source table 5: :COMMDB.cust_leads_detail */
|
||||
/*Job Type: Inbound transform (Tier 1 to Tier 2) */
|
||||
/*Target Table:cust_chat_record_info */
|
||||
/*ETL Job Name:cust_chat_record_info */
|
||||
|
@ -49,7 +49,7 @@ ON COMMIT PRESERVE ROWS;
|
|||
|
||||
INSERT INTO cust_chat_record_info_agi_CUR_I (
|
||||
chat_unique_id /*在线客服会话ID*/
|
||||
,platform_name /*平台*/
|
||||
,chat_channel /*平台*/
|
||||
,contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
|
@ -80,19 +80,18 @@ INSERT INTO cust_chat_record_info_agi_CUR_I (
|
|||
)
|
||||
SELECT
|
||||
COALESCE(TRIM(p0.chat_unique_id),'') /*chat_unique_id*/
|
||||
,'Smart CCC' /*platform_name*/
|
||||
,'Smart CCC' /*chat_channel*/
|
||||
,coalesce(p2.data_detail,'') /*contact_channel*/
|
||||
,COALESCE(TRIM(p0.contact_app_id),'') /*contact_app_id*/
|
||||
,COALESCE(TRIM(p0.app_name),'') /*app_name*/
|
||||
,case when app_name ='TW官网' then 'TW' when app_name='CN官网' then 'CN' else '企微客服' end /*group_name*/
|
||||
,COALESCE(TRIM(CAST(p0.queue_name AS VARCHAR(100))),'') /*queue_name*/
|
||||
,case when p0.queue_name in ('选型报价','选型报价统计') then '产品报价'
|
||||
,case when p0.queue_name in ('选型报价','选型报价统计','TW销售服务') then '产品报价'
|
||||
when p0.queue_name in ('售前技术','售后技术','技术支持统计') then '技术支持'
|
||||
when p0.queue_name in ('保内维修','保外维修与计理','维修计量统计') then '维修与校准'
|
||||
when p0.queue_name in ('保内维修','保外维修与计量','维修计量统计') then '维修与校准'
|
||||
when p0.queue_name in ('其他咨询','其他支持统计') then '其他'
|
||||
when p0.queue_name in ('Joe','Kuang_Chun','Lily','Susan','Tina_Zhang') then '企微客服'
|
||||
when p0.queue_name ='TW销售服务' then 'TW销售服务'
|
||||
else p0.queue_name end /*service_name*/
|
||||
when p0.queue_name in ('Joe','Kuang_Chun','Lily','Susan','Tina_Zhang') then '其他'
|
||||
else '其他' end /*service_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*/
|
||||
|
@ -135,7 +134,7 @@ where p0 .chat_duration_type not in ('9','')
|
|||
|
||||
INSERT INTO cust_chat_record_info_agi_CUR_I (
|
||||
chat_unique_id /*在线客服会话ID*/
|
||||
,platform_name /*平台*/
|
||||
,chat_channel /*平台*/
|
||||
,contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
|
@ -166,7 +165,7 @@ INSERT INTO cust_chat_record_info_agi_CUR_I (
|
|||
)
|
||||
SELECT
|
||||
p0.contact_account /*chat_unique_id*/
|
||||
,'LiveChat' /*platform_name*/
|
||||
,'LiveChat' /*chat_channel*/
|
||||
,'' /*contact_channel*/
|
||||
,'' /*contact_app_id*/
|
||||
,p1.group_name /*app_name*/
|
||||
|
@ -206,7 +205,7 @@ where contact_channel ='Chat'
|
|||
|
||||
/*将不同数据插入到临时表 */
|
||||
;INSERT INTO cust_chat_record_info_agi_INS (
|
||||
platform_name /*平台*/
|
||||
chat_channel /*平台*/
|
||||
,contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
|
@ -238,7 +237,7 @@ where contact_channel ='Chat'
|
|||
|
||||
)
|
||||
SELECT
|
||||
P1.platform_name /*平台*/
|
||||
P1.chat_channel /*平台*/
|
||||
,P1.contact_channel /*接入渠道*/
|
||||
,P1.contact_app_id /*接入号ID*/
|
||||
,P1.app_name /*接入号名称*/
|
||||
|
@ -270,7 +269,7 @@ where contact_channel ='Chat'
|
|||
|
||||
FROM cust_chat_record_info_agi_CUR_I P1
|
||||
LEFT JOIN :MARTDB.cust_chat_record_info P2
|
||||
ON P1.platform_name = P2.platform_name
|
||||
ON P1.chat_channel = P2.chat_channel
|
||||
AND P1.contact_channel = P2.contact_channel
|
||||
AND P1.contact_app_id = P2.contact_app_id
|
||||
AND P1.app_name = P2.app_name
|
||||
|
@ -293,7 +292,7 @@ ON P1.platform_name = P2.platform_name
|
|||
AND P1.tag_3 = P2.tag_3
|
||||
AND P1.chat_unique_id = P2.chat_unique_id
|
||||
|
||||
WHERE P2.platform_name IS NULL
|
||||
WHERE P2.chat_channel IS NULL
|
||||
OR P2.contact_channel IS NULL
|
||||
OR P2.contact_app_id IS NULL
|
||||
OR P2.app_name IS NULL
|
||||
|
@ -319,7 +318,7 @@ WHERE P2.platform_name IS NULL
|
|||
;
|
||||
/*将新增数据插入到目标表 */
|
||||
;INSERT INTO :MARTDB.cust_chat_record_info (
|
||||
platform_name /*平台*/
|
||||
chat_channel /*平台*/
|
||||
,contact_channel /*接入渠道*/
|
||||
,contact_app_id /*接入号ID*/
|
||||
,app_name /*接入号名称*/
|
||||
|
@ -351,7 +350,7 @@ WHERE P2.platform_name IS NULL
|
|||
|
||||
)
|
||||
SELECT
|
||||
P1.platform_name /*平台*/
|
||||
P1.chat_channel /*平台*/
|
||||
,P1.contact_channel /*接入渠道*/
|
||||
,P1.contact_app_id /*接入号ID*/
|
||||
,P1.app_name /*接入号名称*/
|
||||
|
@ -385,7 +384,7 @@ FROM cust_chat_record_info_agi_INS P1
|
|||
ON CONFLICT ( chat_unique_id)
|
||||
DO UPDATE SET
|
||||
chat_unique_id=excluded.chat_unique_id
|
||||
,platform_name=excluded.platform_name
|
||||
,chat_channel=excluded.chat_channel
|
||||
,contact_channel=excluded.contact_channel
|
||||
,contact_app_id=excluded.contact_app_id
|
||||
,app_name=excluded.app_name
|
||||
|
|
Loading…
Reference in New Issue