add workflow 天润dynamic邮件同步,dev

This commit is contained in:
root 2025-06-19 09:45:36 +08:00
parent d33548654a
commit 7b0f19fd41
2 changed files with 8 additions and 18 deletions

View File

@ -4,11 +4,11 @@
/*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:2025-03-17 14:18:33 */ /*Create Date:2025-04-24 17:00:06 */
/*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: 2025-03-17 */ /*SDM Checked Date: 2025-04-24 */
/*Script Developed By: dev */ /*Script Developed By: dev */
/*Script Checked By: dev */ /*Script Checked By: dev */
/*Source table 1: :PDMDB.t00_china_city_pnum */ /*Source table 1: :PDMDB.t00_china_city_pnum */
@ -123,13 +123,11 @@ SELECT
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') = '317832'),(SELECT jsonb_extract_path_text(j, 'value') WHERE jsonb_extract_path_text(j, 'id') = '317832'),(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') = '317748'),(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*/ WHERE jsonb_extract_path_text(j, 'id') = '297755'),'') /*CITY*/
,coalesce(p3.prov_name,p2.prov_name,'') /*STATE_COUNTY_LOCATION*/ ,coalesce(p3.prov_name,p2.prov_name,'') /*STATE_COUNTY_LOCATION*/
,'CN' /*COUNTRY_CODE*/ ,'CN' /*COUNTRY_CODE*/
,coalesce(p3.postnumber,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*/ ,case when p1.tel<>'' then coalesce(find_first_phone_number(replace(replace(replace(p1.tel,'"',''),'[','{'),']','}')::text[]),find_first_not_phone_number(replace(replace(replace(p1.tel,'"',''),'[','{'),']','}')::text[]),'null') else 'null' end /*CONTACT_MOBILE_NUMBER*/
,coalesce(p1.email,'') /*EMAIL_ADDRESS*/ ,coalesce(p1.email,'') /*EMAIL_ADDRESS*/
,'YES' /*REQUEST_A_DEMO*/ ,'YES' /*REQUEST_A_DEMO*/
,'YES' /*REQUEST_A_QUOTE*/ ,'YES' /*REQUEST_A_QUOTE*/
@ -222,15 +220,11 @@ LEFT JOIN :PDMDB.t01_ccc_cust_info p1
LEFT JOIN :PDMDB.t00_china_city_info p2 LEFT JOIN :PDMDB.t00_china_city_info p2
ON p2.city_name like case when length(coalesce((SELECT jsonb_extract_path_text(j, 'value') ON p2.city_name like case when length(coalesce((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') = '317832'),(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
WHERE jsonb_extract_path_text(j, 'id') = '317748'),(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)>0 then coalesce((SELECT jsonb_extract_path_text(j, 'value') 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 FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j
WHERE jsonb_extract_path_text(j, 'id') = '317832'),(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
WHERE jsonb_extract_path_text(j, 'id') = '317748'),(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_pnum p3 LEFT JOIN :PDMDB.t00_china_city_pnum p3
@ -238,16 +232,12 @@ LEFT JOIN :PDMDB.t00_china_city_pnum p3
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') = '317832'),(SELECT jsonb_extract_path_text(j, 'value') WHERE jsonb_extract_path_text(j, 'id') = '317832'),(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') = '317748'),(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') 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 FROM jsonb_array_elements((p0.start_form::json -> 'fields')::jsonb) j
WHERE jsonb_extract_path_text(j, 'id') = '317832'),(SELECT jsonb_extract_path_text(j, 'value') WHERE jsonb_extract_path_text(j, 'id') = '317832'),(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') = '317748'),(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 jsonb_extract_path_text(j, 'id') = '297755'),'')::text else '' end
where p0.state_selected in ('Leads') and p0.update_time >= current_date - interval '1 days' where p0.state_selected in ('Leads') and p0.update_time >= current_date - interval '7 days'
; ;
@ -418,7 +408,7 @@ LEFT JOIN :PDMDB.t00_china_city_info p2
ON p2.city_name2 like (SELECT jsonb_extract_path_text(j, 'value') ON p2.city_name2 like (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') = '304586')::text||'%' WHERE jsonb_extract_path_text(j, 'id') = '304586')::text||'%'
where p0 .state_selected ='TW_leads' and p0.update_time >= current_date - interval '3 days' where p0 .state_selected ='TW_leads' and p0.update_time >= current_date - interval '7 days'
; ;

View File

@ -24,7 +24,7 @@ default_args = {
} }
dag = DAG('wf_dag_smart_ccc_dynamic_email', default_args=default_args, dag = DAG('wf_dag_smart_ccc_dynamic_email', default_args=default_args,
schedule_interval="5 10,14,18,12,16 * * *", schedule_interval="5 10,14,18,16 * * *",
catchup=False, catchup=False,
dagrun_timeout=timedelta(minutes=160), dagrun_timeout=timedelta(minutes=160),
max_active_runs=3) max_active_runs=3)