add workflow 天润Smart-ccc工单数据,dev
This commit is contained in:
		
							parent
							
								
									f621db7287
								
							
						
					
					
						commit
						efd40acc35
					
				|  | @ -4,7 +4,7 @@ | |||
| /*Brilliance stems from wisdoms.                                                                   */ | ||||
| /*************Head Section**************************************************************************/ | ||||
| /*Script Use: Periodically load data to :f_ccc_work_ticket_integ(smartccc工单信息集成)             */ | ||||
| /*Create Date:2024-08-02 11:15:00                                                                  */ | ||||
| /*Create Date:2024-08-02 17:35:46                                                                  */ | ||||
| /*SDM Developed By: dev                                                                            */ | ||||
| /*SDM Developed Date: 2024-07-09                                                                   */ | ||||
| /*SDM Checked By: dev                                                                              */ | ||||
|  | @ -98,10 +98,11 @@ INSERT INTO f_ccc_work_ticket_integ_agi_CUR_I ( | |||
|            ,Etl_Batch_No                            /*作业批次号*/ | ||||
|         ) | ||||
| SELECT | ||||
|          coalesce(case when p1."source" ='在线咨询' then '401890X401890' | ||||
|          case when coalesce(p0.start_form::json->>'formName','') ='选型报价_Outbound' then '44962X449662'  | ||||
|         else coalesce(case when p1."source" ='在线咨询' then '401890X401890' | ||||
|       when p1."source" ='接口创建' then '445769X445769' | ||||
|       when p1."source" ='呼叫中心' then '305972X317938' | ||||
|       else '401890X401890' end,'')        /*PEXTENSION_CODE*/ | ||||
|       else '401890X401890' end,'') end        /*PEXTENSION_CODE*/ | ||||
|         ,coalesce(p1."source",'')                                  /*PEXTENSION*/ | ||||
|         ,COALESCE(TRIM(CAST(p0.customer_name AS varchar(20))),'')        /*LAST_NAME*/ | ||||
|         ,coalesce(p0.id,'')                                        /*SUFFIX*/ | ||||
|  | @ -113,9 +114,11 @@ SELECT | |||
|    WHERE jsonb_extract_path_text(j, 'name') = '职位'),'')        /*JOB_TITLE*/ | ||||
|         ,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'),'')         /*CITY*/ | ||||
|         ,coalesce(p2.prov_name,'')                                 /*STATE_COUNTY_LOCATION*/ | ||||
|         ,'CN'                                                      /*COUNTRY_CODE*/ | ||||
|         ,case when p0.state_selected = 'TW_leads' then 'TW' else 'CN' end        /*COUNTRY_CODE*/ | ||||
|         ,coalesce(p2.postalcode,'')                                /*POSTAL_CODE*/ | ||||
|         ,coalesce(replace(replace(replace(split_part(p1.tel,',',1),'"',''),'[',''),']',''),'')        /*CONTACT_MOBILE_NUMBER*/ | ||||
|         ,coalesce(p1.email,'')                                     /*EMAIL_ADDRESS*/ | ||||
|  | @ -123,11 +126,23 @@ SELECT | |||
|         ,'YES'                                                     /*REQUEST_A_QUOTE*/ | ||||
|         ,'YES'                                                     /*HAMCAM*/ | ||||
|         ,4                                                         /*PURCHASE_INTENT*/ | ||||
|         ,coalesce('L - mql '||(SELECT jsonb_extract_path_text(field, 'value') AS value_298245 | ||||
|         ,'L - mql '||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),'')        /*COMMENTS*/ | ||||
| WHERE jsonb_extract_path_text(field, 'id')::int = 298246),'')||' 预算情况:'||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 = 303805),' None ')||';决策权确认:'||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 = 303806),' None ')||';计划购买时间:'||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 = 298249),' None ')||';'        /*COMMENTS*/ | ||||
|         ,coalesce((SELECT jsonb_extract_path_text(field, 'value') AS value_297729 | ||||
| FROM ( | ||||
|   SELECT jsonb_array_elements(p0.start_form::jsonb->'fields') AS field | ||||
|  | @ -147,7 +162,7 @@ WHERE jsonb_extract_path_text(field, 'id')::int = 297730),'')        /*CCP_APP_0 | |||
| FROM ( | ||||
|   SELECT jsonb_array_elements(p0.start_form::jsonb->'fields') AS field | ||||
| ) AS t | ||||
| WHERE jsonb_extract_path_text(field, 'id')::int = 298300),'')        /*LEAD_PRODUCTS_01_5*/ | ||||
| WHERE jsonb_extract_path_text(field, 'id')::int = 299137),'')        /*LEAD_PRODUCTS_01_5*/ | ||||
|         ,'YES'                                                     /*PERMISSION_PHONE*/ | ||||
|         ,p0.create_time                                            /*PERMISSION_PHONE_DATE*/ | ||||
|         ,'YES'                                                     /*PERMISSION_EMAIL*/ | ||||
|  | @ -183,10 +198,16 @@ FROM :PDMDB.t01_ccc_work_ticket_info  p0 | |||
| LEFT JOIN :PDMDB.t01_ccc_cust_info  p1 | ||||
|         ON p0.customer_id =p1.id | ||||
| LEFT JOIN :PDMDB.t00_china_city_info  p2 | ||||
|         ON p2.city_name  like 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  | ||||
|    WHERE jsonb_extract_path_text(j, 'id') = '297755'),'')::text||'%' | ||||
| where p0 .state_selected ='Leads' | ||||
|    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','TWleads') | ||||
| 
 | ||||
| ; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue