add workflow 天润dynamic邮件同步,dev

This commit is contained in:
root 2024-12-31 17:34:42 +08:00
parent d144a95b1a
commit df1d2f5eb3
1 changed files with 19 additions and 8 deletions

View File

@ -4,16 +4,17 @@
/*Brilliance stems from wisdoms. */ /*Brilliance stems from wisdoms. */
/*************Head Section**************************************************************************/ /*************Head Section**************************************************************************/
/*Script Use: Periodically load data to :f_ccc_work_ticket_integ(smartccc工单信息集成) */ /*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 By: dev */
/*SDM Developed Date: 2024-07-09 */ /*SDM Developed Date: 2024-07-09 */
/*SDM Checked By: dev */ /*SDM Checked By: dev */
/*SDM Checked Date: 2024-12-12 */ /*SDM Checked Date: 2024-12-31 */
/*Script Developed By: dev */ /*Script Developed By: dev */
/*Script Checked By: dev */ /*Script Checked By: dev */
/*Source table 1: :PDMDB.t01_ccc_cust_info */ /*Source table 1: :PDMDB.t00_china_city_postnum */
/*Source table 2: :PDMDB.t00_china_city_info */ /*Source table 2: :PDMDB.t01_ccc_cust_info */
/*Source table 3: :PDMDB.t01_ccc_work_ticket_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) */ /*Job Type: Inbound transform (Tier 1 to Tier 2) */
/*Target Table:f_ccc_work_ticket_integ */ /*Target Table:f_ccc_work_ticket_integ */
/*ETL Job Name: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') ,coalesce((SELECT jsonb_extract_path_text(j, 'value')
FROM jsonb_array_elements(p1.customize::jsonb) j FROM jsonb_array_elements(p1.customize::jsonb) j
WHERE jsonb_extract_path_text(j, 'name') = '职位'),'') /*JOB_TITLE*/ 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 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') 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 FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j
WHERE jsonb_extract_path_text(j, 'id') = '297755'),'') /*CITY*/ 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*/ ,'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(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*/ ,coalesce(p1.email,'') /*EMAIL_ADDRESS*/
,'YES' /*REQUEST_A_DEMO*/ ,'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') 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 FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j
WHERE jsonb_extract_path_text(j, 'id') = '297755'),'')::text||'%' else '' end 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' where p0.state_selected in ('Leads') and p0.update_time >= current_date - interval '7 days'
; ;