From c4651ce68b11cc0b631a388746648ad6b1c9fd4f Mon Sep 17 00:00:00 2001 From: root Date: Wed, 8 Jan 2025 13:00:30 +0800 Subject: [PATCH] =?UTF-8?q?add=20workflow=20=E5=A4=A9=E6=B6=A6Dynamic?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=91=A8=E4=B8=80=E5=90=8C=E6=AD=A5,dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../f_ccc_work_ticket_integ.sql | 4 ++- .../f_ccc_work_ticket_integ_agi.sql | 31 +++++++++++++------ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/dev/workflow/TK_Cust/dag_email_data_export_monday/smartccc工单信息集成/f_ccc_work_ticket_integ.sql b/dev/workflow/TK_Cust/dag_email_data_export_monday/smartccc工单信息集成/f_ccc_work_ticket_integ.sql index 8a73534..6546da7 100644 --- a/dev/workflow/TK_Cust/dag_email_data_export_monday/smartccc工单信息集成/f_ccc_work_ticket_integ.sql +++ b/dev/workflow/TK_Cust/dag_email_data_export_monday/smartccc工单信息集成/f_ccc_work_ticket_integ.sql @@ -53,7 +53,8 @@ CREATE TABLE IF NOT EXISTS p30_common.f_ccc_work_ticket_integ ( , Etl_Proc_Dt timestamp(0) , Etl_Batch_No varchar(50) , second_mobile_number varchar(20) - , company_phone_number varchar(20) + , company_phone_number varchar(20) + , district varchar(50) ,primary key( SUFFIX ) ); @@ -110,5 +111,6 @@ CREATE TABLE IF NOT EXISTS p30_common.f_ccc_work_ticket_integ ( COMMENT ON COLUMN p30_common.f_ccc_work_ticket_integ.Etl_Batch_No IS '作业批次号'; COMMENT ON COLUMN p30_common.f_ccc_work_ticket_integ.second_mobile_number IS '第二手机号'; COMMENT ON COLUMN p30_common.f_ccc_work_ticket_integ.company_phone_number IS '固话号'; + COMMENT ON COLUMN p30_common.f_ccc_work_ticket_integ.district IS '地区'; COMMENT ON TABLE p30_common.f_ccc_work_ticket_integ IS 'smartccc工单信息集成'; \ No newline at end of file diff --git a/dev/workflow/TK_Cust/dag_email_data_export_monday/smartccc工单信息集成/f_ccc_work_ticket_integ_agi.sql b/dev/workflow/TK_Cust/dag_email_data_export_monday/smartccc工单信息集成/f_ccc_work_ticket_integ_agi.sql index 1a0dc7b..2b46a2f 100644 --- a/dev/workflow/TK_Cust/dag_email_data_export_monday/smartccc工单信息集成/f_ccc_work_ticket_integ_agi.sql +++ b/dev/workflow/TK_Cust/dag_email_data_export_monday/smartccc工单信息集成/f_ccc_work_ticket_integ_agi.sql @@ -4,14 +4,14 @@ /*Brilliance stems from wisdoms. */ /*************Head Section**************************************************************************/ /*Script Use: Periodically load data to :f_ccc_work_ticket_integ(smartccc工单信息集成) */ -/*Create Date:2024-12-31 16:49:33 */ +/*Create Date:2025-01-08 12:35:25 */ /*SDM Developed By: dev */ /*SDM Developed Date: 2024-07-09 */ /*SDM Checked By: dev */ -/*SDM Checked Date: 2024-12-31 */ +/*SDM Checked Date: 2025-01-08 */ /*Script Developed By: dev */ /*Script Checked By: dev */ -/*Source table 1: :PDMDB.t00_china_city_postnum */ +/*Source table 1: :PDMDB.t00_china_city_pnum */ /*Source table 2: :PDMDB.t01_ccc_cust_info */ /*Source table 3: :PDMDB.t00_china_city_info */ /*Source table 4: :PDMDB.t01_ccc_work_ticket_info */ @@ -99,6 +99,7 @@ INSERT INTO f_ccc_work_ticket_integ_agi_CUR_I ( ,Etl_Batch_No /*作业批次号*/ ,second_mobile_number /*第二手机号*/ ,company_phone_number /*固话号*/ + ,district /*地区*/ ) SELECT case when coalesce(p0.start_form::json->>'formName','') ='选型报价_Outbound' then '449662X449662' @@ -118,12 +119,12 @@ SELECT ,coalesce((SELECT jsonb_extract_path_text(j, 'value') FROM jsonb_array_elements(p1.customize::jsonb) j WHERE jsonb_extract_path_text(j, 'name') = '职位'),'') /*JOB_TITLE*/ - , coalesce(p3.city,(SELECT jsonb_extract_path_text(j, 'value') + ,coalesce(p3.city_name,(SELECT jsonb_extract_path_text(j, 'value') FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j WHERE jsonb_extract_path_text(j, 'id') = '304585'),(SELECT jsonb_extract_path_text(j, 'value') FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j - WHERE jsonb_extract_path_text(j, 'id') = '297755'),'') /*CITY*/ - ,coalesce(p2.prov_name,p3.province,'') /*STATE_COUNTY_LOCATION*/ + WHERE jsonb_extract_path_text(j, 'id') = '297755'),'') /*CITY*/ + ,coalesce(p3.prov_name,p2.prov_name,'') /*STATE_COUNTY_LOCATION*/ ,'CN' /*COUNTRY_CODE*/ ,coalesce(p3.postnumber,p2.postalcode,'') /*POSTAL_CODE*/ ,coalesce(find_first_phone_number(replace(replace(replace(p1.tel,'"',''),'[','{'),']','}')::text[]),find_first_not_phone_number(replace(replace(replace(p1.tel,'"',''),'[','{'),']','}')::text[]),'null') /*CONTACT_MOBILE_NUMBER*/ @@ -211,6 +212,7 @@ WHERE jsonb_extract_path_text(field, 'id')::int = 299137),'') /*LEAD_PROD else find_first_phone_number(array_remove(replace(replace(replace(p1.tel,'"',''),'[','{'),']','}')::text[],find_first_phone_number(replace(replace(replace(p1.tel,'"',''),'[','{'),']','}')::text[]))) end /*second_mobile_number*/ ,coalesce(find_first_not_phone_number(replace(replace(replace(p1.tel,'"',''),'[','{'),']','}')::text[]),'') /*company_phone_number*/ + ,coalesce(p3.district,'') /*district*/ FROM :PDMDB.t01_ccc_work_ticket_info p0 LEFT JOIN :PDMDB.t01_ccc_cust_info p1 @@ -225,8 +227,8 @@ LEFT JOIN :PDMDB.t00_china_city_info p2 WHERE jsonb_extract_path_text(j, 'id') = '304585'),(SELECT jsonb_extract_path_text(j, 'value') FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j WHERE jsonb_extract_path_text(j, 'id') = '297755'),'')::text||'%' else '' end -LEFT JOIN :PDMDB.t00_china_city_postnum p3 - ON p3.full_name like case when length(coalesce((SELECT jsonb_extract_path_text(j, 'value') +LEFT JOIN :PDMDB.t00_china_city_pnum p3 + ON p3.full_name = case when length(coalesce((SELECT jsonb_extract_path_text(j, 'value') FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j WHERE jsonb_extract_path_text(j, 'id') = '304585'),(SELECT jsonb_extract_path_text(j, 'value') FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j @@ -234,8 +236,8 @@ LEFT JOIN :PDMDB.t00_china_city_postnum p3 FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j WHERE jsonb_extract_path_text(j, 'id') = '304585'),(SELECT jsonb_extract_path_text(j, 'value') FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j - WHERE jsonb_extract_path_text(j, 'id') = '297755'),'')::text||'%' else '' end -where p0.state_selected in ('Leads') and p0.update_time >= current_date - interval '7 days' + WHERE jsonb_extract_path_text(j, 'id') = '297755'),'')::text else '' end +where p0.state_selected in ('Leads') and p0.update_time >= current_date - interval '7 days' ; @@ -299,6 +301,7 @@ INSERT INTO f_ccc_work_ticket_integ_agi_CUR_I ( ,Etl_Batch_No /*作业批次号*/ ,second_mobile_number /*第二手机号*/ ,company_phone_number /*固话号*/ + ,district /*地区*/ ) SELECT '401890X401890' /*PEXTENSION_CODE*/ @@ -398,6 +401,7 @@ WHERE jsonb_extract_path_text(field, 'id')::int = 299137),'') /*LEAD_PROD ,0 /*Etl_Batch_No*/ ,'' /*second_mobile_number*/ ,'' /*company_phone_number*/ + ,'' /*district*/ FROM :PDMDB.t01_ccc_work_ticket_info p0 LEFT JOIN :PDMDB.t00_china_city_info p2 @@ -457,6 +461,7 @@ where p0 .state_selected ='TW_leads' and p0.update_time >= current_date - interv ,EMAIL_PREFERENCE /*EMAIL_PREFERENCE*/ ,second_mobile_number /*第二手机号*/ ,company_phone_number /*固话号*/ + ,district /*地区*/ ,SUFFIX /*工单ID*/ ,Src_Sysname /*来源系统*/ ,Etl_Job /*作业名称*/ @@ -513,6 +518,7 @@ where p0 .state_selected ='TW_leads' and p0.update_time >= current_date - interv ,P1.EMAIL_PREFERENCE /*EMAIL_PREFERENCE*/ ,P1.second_mobile_number /*第二手机号*/ ,P1.company_phone_number /*固话号*/ + ,P1.district /*地区*/ ,P1.SUFFIX /*工单ID*/ ,P1.Src_Sysname /*来源系统*/ ,P1.Etl_Job /*作业名称*/ @@ -569,6 +575,7 @@ ON P1.PEXTENSION_CODE = P2.PEXTENSION_CODE AND P1.EMAIL_PREFERENCE = P2.EMAIL_PREFERENCE AND P1.second_mobile_number = P2.second_mobile_number AND P1.company_phone_number = P2.company_phone_number + AND P1.district = P2.district AND P1.SUFFIX = P2.SUFFIX WHERE P2.PEXTENSION_CODE IS NULL @@ -616,6 +623,7 @@ WHERE P2.PEXTENSION_CODE IS NULL OR P2.EMAIL_PREFERENCE IS NULL OR P2.second_mobile_number IS NULL OR P2.company_phone_number IS NULL + OR P2.district IS NULL OR P2.SUFFIX IS NULL ; @@ -666,6 +674,7 @@ WHERE P2.PEXTENSION_CODE IS NULL ,EMAIL_PREFERENCE /*EMAIL_PREFERENCE*/ ,second_mobile_number /*第二手机号*/ ,company_phone_number /*固话号*/ + ,district /*地区*/ ,SUFFIX /*工单ID*/ ,Src_Sysname /*来源系统*/ ,Etl_Job /*作业名称*/ @@ -722,6 +731,7 @@ SELECT ,P1.EMAIL_PREFERENCE /*EMAIL_PREFERENCE*/ ,P1.second_mobile_number /*第二手机号*/ ,P1.company_phone_number /*固话号*/ + ,P1.district /*地区*/ ,P1.SUFFIX /*工单ID*/ ,P1.Src_Sysname /*来源系统*/ ,P1.Etl_Job /*作业名称*/ @@ -780,6 +790,7 @@ DO UPDATE SET ,EMAIL_PREFERENCE=excluded.EMAIL_PREFERENCE ,second_mobile_number=excluded.second_mobile_number ,company_phone_number=excluded.company_phone_number + ,district=excluded.district ,Src_Sysname=excluded.Src_Sysname ,Etl_Job=excluded.Etl_Job ,Src_Table=excluded.Src_Table