diff --git a/dev/workflow/TK_Cust/smart_ccc_dynamic_email/smartccc工单信息集成/f_ccc_work_ticket_integ_agi.sql b/dev/workflow/TK_Cust/smart_ccc_dynamic_email/smartccc工单信息集成/f_ccc_work_ticket_integ_agi.sql index d01abf3..1a0dc7b 100644 --- a/dev/workflow/TK_Cust/smart_ccc_dynamic_email/smartccc工单信息集成/f_ccc_work_ticket_integ_agi.sql +++ b/dev/workflow/TK_Cust/smart_ccc_dynamic_email/smartccc工单信息集成/f_ccc_work_ticket_integ_agi.sql @@ -4,16 +4,17 @@ /*Brilliance stems from wisdoms. */ /*************Head Section**************************************************************************/ /*Script Use: Periodically load data to :f_ccc_work_ticket_integ(smartccc工单信息集成) */ -/*Create Date:2024-12-12 11:47:33 */ +/*Create Date:2024-12-31 16:49:33 */ /*SDM Developed By: dev */ /*SDM Developed Date: 2024-07-09 */ /*SDM Checked By: dev */ -/*SDM Checked Date: 2024-12-12 */ +/*SDM Checked Date: 2024-12-31 */ /*Script Developed By: dev */ /*Script Checked By: dev */ -/*Source table 1: :PDMDB.t01_ccc_cust_info */ -/*Source table 2: :PDMDB.t00_china_city_info */ -/*Source table 3: :PDMDB.t01_ccc_work_ticket_info */ +/*Source table 1: :PDMDB.t00_china_city_postnum */ +/*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 */ /*Job Type: Inbound transform (Tier 1 to Tier 2) */ /*Target Table:f_ccc_work_ticket_integ */ /*ETL Job Name:f_ccc_work_ticket_integ */ @@ -117,14 +118,14 @@ 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((SELECT jsonb_extract_path_text(j, 'value') + , coalesce(p3.city,(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,'') /*STATE_COUNTY_LOCATION*/ + ,coalesce(p2.prov_name,p3.province,'') /*STATE_COUNTY_LOCATION*/ ,'CN' /*COUNTRY_CODE*/ - ,coalesce(p2.postalcode,'') /*POSTAL_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*/ ,coalesce(p1.email,'') /*EMAIL_ADDRESS*/ ,'YES' /*REQUEST_A_DEMO*/ @@ -224,6 +225,16 @@ 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') + 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)>0 then 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 + 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' ;