add workflow 天润Smart-ccc会话数据,dev

This commit is contained in:
root 2025-02-14 09:52:32 +08:00
parent 85f14fa325
commit c16755e544
1 changed files with 20 additions and 20 deletions

View File

@ -1,14 +1,14 @@
/***************************************************************************************************/ /***************************************************************************************************/
/*script in Sql, generate by SdmCreateScript 2020(by Qihang Feng, QF255001@TERADATA.COM) */ /*script in Sql, generate by SdmCreateScript 2024(by IdgValue, qihang.feng@idgvalue.COM) */
/*VERSION 01.10 revised on 2020-08-25 */ /*VERSION 01.10 revised on 2020-08-25 */
/*Brilliance stems from wisdoms. */ /*Brilliance stems from wisdoms. */
/*************Head Section**************************************************************************/ /*************Head Section**************************************************************************/
/*Script Use: Periodically load data to :cust_chat_record_info(ccc客户会话记录信息) */ /*Script Use: Periodically load data to :cust_chat_record_info(ccc客户会话记录信息) */
/*Create Date:2024-10-25 17:45:11 */ /*Create Date:2025-02-14 09:50:04 */
/*SDM Developed By: dev */ /*SDM Developed By: dev */
/*SDM Developed Date: 2024-08-14 */ /*SDM Developed Date: 2024-08-14 */
/*SDM Checked By: dev */ /*SDM Checked By: dev */
/*SDM Checked Date: 2024-10-25 */ /*SDM Checked Date: 2025-02-14 */
/*Script Developed By: dev */ /*Script Developed By: dev */
/*Script Checked By: dev */ /*Script Checked By: dev */
/*Source table 1: :COMMDB.select replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') as visitor_id ,row_number() over(partition by replace(jsonb_array_elements(visitor_ids::jsonb)::text,'"','') order by id desc) rn ,* from p30_common.d_ccc_cust_info dcci /*Source table 1: :COMMDB.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
@ -32,14 +32,14 @@ where visitor_ids <>''*/
/*创建临时表加载当前数据 */ /*创建临时表加载当前数据 */
CREATE TEMPORARY TABLE cust_chat_record_info_agi_CUR_I CREATE TEMPORARY TABLE cust_chat_record_info_agi_CUR_I
( LIKE :MARTDB.cust_chat_record_info) ( LIKE :MART.cust_chat_record_info)
ON COMMIT PRESERVE ROWS; ON COMMIT PRESERVE ROWS;
/*创建临时表加载不同数据 */ /*创建临时表加载不同数据 */
CREATE TEMPORARY TABLE cust_chat_record_info_agi_INS CREATE TEMPORARY TABLE cust_chat_record_info_agi_INS
( LIKE :MARTDB.cust_chat_record_info) ( LIKE :MART.cust_chat_record_info)
ON COMMIT PRESERVE ROWS; ON COMMIT PRESERVE ROWS;
@ -79,26 +79,26 @@ INSERT INTO cust_chat_record_info_agi_CUR_I (
,Src_Table /*来源表*/ ,Src_Table /*来源表*/
) )
SELECT SELECT
COALESCE(TRIM(p0.chat_unique_id),'') /*chat_unique_id*/ p0.contact_account /*chat_unique_id*/
,'Smart CCC' /*chat_channel*/ ,'Smart CCC' /*chat_channel*/
,coalesce(p2.data_detail,'') /*contact_channel*/ ,coalesce(p2.data_detail,'') /*contact_channel*/
,COALESCE(TRIM(p0.contact_app_id),'') /*contact_app_id*/ ,'' /*contact_app_id*/
,COALESCE(TRIM(p0.app_name),'') /*app_name*/ ,p1.group_name /*app_name*/
,case when app_name ='TW官网' then 'TW' when app_name='CN官网' then 'CN' else '企微客服' end /*group_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*/ ,p1.pre_chat_service /*queue_name*/
,case when p0.queue_name in ('选型报价','选型报价统计','TW销售服务','选型报价统计chat') then '产品报价' ,case when p0.queue_name in ('选型报价','选型报价统计','TW销售服务','选型报价统计chat') then '产品报价'
when p0.queue_name in ('售前技术','售后技术','技术支持统计','技术支持统计chat') then '技术支持' when p0.queue_name in ('售前技术','售后技术','技术支持统计','技术支持统计chat') then '技术支持'
when p0.queue_name in ('保内维修','保外维修与计量','维修计量统计','维修计量统计chat') then '维修与校准' when p0.queue_name in ('保内维修','保外维修与计量','维修计量统计','维修计量统计chat') then '维修与校准'
when p0.queue_name in ('其他咨询','其他支持统计','其他支持统计chat') then '其他' when p0.queue_name in ('其他咨询','其他支持统计','其他支持统计chat') then '其他'
when p0.queue_name in ('Joe','Kuang_Chun','Lily','Susan','Tina_Zhang') then '其他' when p0.queue_name in ('Joe','Kuang_Chun','Lily','Susan','Tina_Zhang') then '其他'
else '其他' end /*service_name*/ else '其他' end /*service_name*/
,COALESCE(p0.start_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*start_time*/ ,p1.chat_creation_time /*start_time*/
,COALESCE(p0.end_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*end_time*/ ,p1.chat_start_time + interval '1second' * p1.chat_duration /*end_time*/
,COALESCE(p0.chat_duration_in_seconds,0) /*chat_duration_in_seconds*/ ,p1.chat_duration /*chat_duration_in_seconds*/
,COALESCE(p0.queue_time,0) /*queue_time*/ ,p1.queue_duration /*queue_time*/
,COALESCE(TRIM(p0.referer_url),'') /*referer_url*/ ,p1.chat_referrer_url /*referer_url*/
,COALESCE(TRIM(p0.first_visit_page_url),'') /*first_visit_page_url*/ ,p1.chat_start_url /*first_visit_page_url*/
,COALESCE(TRIM(p0.visitor_id),'') /*visitor_id*/ ,p1.visitor_livechat_id /*visitor_id*/
,coalesce(p1.name,'') /*visitor_name*/ ,coalesce(p1.name,'') /*visitor_name*/
,coalesce(p1.tel,'') /*visitor_mobile*/ ,coalesce(p1.tel,'') /*visitor_mobile*/
,coalesce(p1.email,'') /*visitor_email*/ ,coalesce(p1.email,'') /*visitor_email*/
@ -122,7 +122,7 @@ and p1.rn=1
LEFT JOIN :PDMDB.t99_ccc_code p2 LEFT JOIN :PDMDB.t99_ccc_code p2
ON p2.code_type ='chat_contact_channel' ON p2.code_type ='chat_contact_channel'
and p0.contact_channel =p2.data_code and p0.contact_channel =p2.data_code
where p0 .chat_duration_type not in ('9','')
; ;
@ -268,7 +268,7 @@ where contact_channel ='Chat' and p1.visitor_country_code in ('CN','TW')
,P1.Src_Table /*来源表*/ ,P1.Src_Table /*来源表*/
FROM cust_chat_record_info_agi_CUR_I P1 FROM cust_chat_record_info_agi_CUR_I P1
LEFT JOIN :MARTDB.cust_chat_record_info P2 LEFT JOIN :MART.cust_chat_record_info P2
ON P1.chat_channel = P2.chat_channel ON P1.chat_channel = P2.chat_channel
AND P1.contact_channel = P2.contact_channel AND P1.contact_channel = P2.contact_channel
AND P1.contact_app_id = P2.contact_app_id AND P1.contact_app_id = P2.contact_app_id
@ -317,7 +317,7 @@ WHERE P2.chat_channel IS NULL
; ;
/*将新增数据插入到目标表 */ /*将新增数据插入到目标表 */
;INSERT INTO :MARTDB.cust_chat_record_info ( ;INSERT INTO :MART.cust_chat_record_info (
chat_channel /*平台*/ chat_channel /*平台*/
,contact_channel /*接入渠道*/ ,contact_channel /*接入渠道*/
,contact_app_id /*接入号ID*/ ,contact_app_id /*接入号ID*/