add workflow 天润Dynamic邮件周一同步,dev

This commit is contained in:
root 2024-12-31 17:31:48 +08:00
parent cf60e82ea0
commit d144a95b1a
1 changed files with 34 additions and 13 deletions
dev/workflow/TK_Cust/dag_email_data_export_monday/smartccc工单信息集成

View File

@ -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-10-17 14:52:27 */
/*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-10-17 */
/*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 */
@ -109,31 +110,37 @@ SELECT
,coalesce(p0.id,'') /*SUFFIX*/
,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') = '297756'),(SELECT jsonb_extract_path_text(j, 'value')
FROM jsonb_array_elements(p1.customize::jsonb) j
WHERE jsonb_extract_path_text(j, 'name') = '公司名称'),'') /*COMPANY_NAME*/
WHERE jsonb_extract_path_text(j, 'id') = '305038'),'')||(case when 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') = '297756'),'') = '' then '' else ',Enduser: '||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') = '297756'),'') end) /*COMPANY_NAME*/
,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*/
,'YES' /*REQUEST_A_QUOTE*/
,'YES' /*HAMCAM*/
,4 /*PURCHASE_INTENT*/
,'L - mql '||coalesce((SELECT jsonb_extract_path_text(field, 'value') AS value_298245
,'L - mql '||case when p0.workflow_name ='CN离线工单_选型报价' then coalesce((SELECT jsonb_extract_path_text(field, 'value') AS value_298245
FROM (
SELECT jsonb_array_elements(p0.start_form::jsonb->'fields') AS field
) AS t
WHERE jsonb_extract_path_text(field, 'id')::int = 298246),'')||' 预算情况:'||coalesce((SELECT jsonb_extract_path_text(field, 'value') AS value_298245
WHERE jsonb_extract_path_text(field, 'id')::int = 297757),'') else coalesce((SELECT jsonb_extract_path_text(field, 'value') AS value_298245
FROM (
SELECT jsonb_array_elements(p0.start_form::jsonb->'fields') AS field
) AS t
WHERE jsonb_extract_path_text(field, 'id')::int = 298246),'') end ||' 预算情况:'||coalesce((SELECT jsonb_extract_path_text(field, 'value') AS value_298245
FROM (
SELECT jsonb_array_elements(p0.start_form::jsonb->'fields') AS field
) AS t
@ -218,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'
;
@ -344,6 +361,10 @@ WHERE jsonb_extract_path_text(field, 'id')::int = 298249),' None ')||';'
FROM (
SELECT jsonb_array_elements(p0.start_form::jsonb->'fields') AS field
) AS t
WHERE jsonb_extract_path_text(field, 'id')::int = 304927),(SELECT jsonb_extract_path_text(field, 'value') AS value_298300
FROM (
SELECT jsonb_array_elements(p0.start_form::jsonb->'fields') AS field
) AS t
WHERE jsonb_extract_path_text(field, 'id')::int = 299137),'') /*LEAD_PRODUCTS_01_5*/
,'YES' /*PERMISSION_PHONE*/
,COALESCE(p0.create_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*PERMISSION_PHONE_DATE*/