add workflow 天润Smart-ccc通话记录,dev

This commit is contained in:
root 2024-10-18 18:08:09 +08:00
parent e6115414dc
commit 031556c243
2 changed files with 29 additions and 11 deletions

View File

@ -3,6 +3,7 @@ DROP TABLE IF EXISTS p30_common.cust_call_ccc_record;
CREATE TABLE IF NOT EXISTS p30_common.cust_call_ccc_record ( CREATE TABLE IF NOT EXISTS p30_common.cust_call_ccc_record (
unique_id VARCHAR(50) unique_id VARCHAR(50)
, call_id VARCHAR(50) , call_id VARCHAR(50)
, ccc_contact_id varchar(50)
, customer_number VARCHAR(20) , customer_number VARCHAR(20)
, customer_province VARCHAR(20) , customer_province VARCHAR(20)
, customer_city VARCHAR(20) , customer_city VARCHAR(20)
@ -43,6 +44,7 @@ CREATE TABLE IF NOT EXISTS p30_common.cust_call_ccc_record (
COMMENT ON COLUMN p30_common.cust_call_ccc_record.unique_id IS '呼入通话ID'; COMMENT ON COLUMN p30_common.cust_call_ccc_record.unique_id IS '呼入通话ID';
COMMENT ON COLUMN p30_common.cust_call_ccc_record.call_id IS 'CallID'; COMMENT ON COLUMN p30_common.cust_call_ccc_record.call_id IS 'CallID';
COMMENT ON COLUMN p30_common.cust_call_ccc_record.ccc_contact_id IS 'ccc联系方式编号';
COMMENT ON COLUMN p30_common.cust_call_ccc_record.customer_number IS '客户号码'; COMMENT ON COLUMN p30_common.cust_call_ccc_record.customer_number IS '客户号码';
COMMENT ON COLUMN p30_common.cust_call_ccc_record.customer_province IS '客户省份'; COMMENT ON COLUMN p30_common.cust_call_ccc_record.customer_province IS '客户省份';
COMMENT ON COLUMN p30_common.cust_call_ccc_record.customer_city IS '客户城市'; COMMENT ON COLUMN p30_common.cust_call_ccc_record.customer_city IS '客户城市';

View File

@ -4,15 +4,17 @@
/*Brilliance stems from wisdoms. */ /*Brilliance stems from wisdoms. */
/*************Head Section**************************************************************************/ /*************Head Section**************************************************************************/
/*Script Use: Periodically load data to :cust_call_ccc_record(ccc通话记录) */ /*Script Use: Periodically load data to :cust_call_ccc_record(ccc通话记录) */
/*Create Date:2024-08-30 10:00:22 */ /*Create Date:2024-09-18 18:59:25 */
/*SDM Developed By: dev */ /*SDM Developed By: dev */
/*SDM Developed Date: 2024-08-22 */ /*SDM Developed Date: 2024-08-22 */
/*SDM Checked By: dev */ /*SDM Checked By: dev */
/*SDM Checked Date: 2024-08-30 */ /*SDM Checked Date: 2024-09-18 */
/*Script Developed By: dev */ /*Script Developed By: dev */
/*Script Checked By: dev */ /*Script Checked By: dev */
/*Source table 1: :PDMDB.t01_ccc_ob_record */ /*Source table 1: :PDMDB.t01_ccc_ob_record */
/*Source table 2: :PDMDB.t01_ccc_ib_record */ /*Source table 2: :PDMDB.t01_ccc_ib_record */
/*Source table 3: :COMMDB.select distinct on (tel) * from p30_common.d_ccc_cust_info
where tel<>'' */
/*Job Type: Inbound transform (Tier 1 to Tier 2) */ /*Job Type: Inbound transform (Tier 1 to Tier 2) */
/*Target Table:cust_call_ccc_record */ /*Target Table:cust_call_ccc_record */
/*ETL Job Name:cust_call_ccc_record */ /*ETL Job Name:cust_call_ccc_record */
@ -45,6 +47,7 @@ ON COMMIT PRESERVE ROWS;
INSERT INTO cust_call_ccc_record_agi_CUR_I ( INSERT INTO cust_call_ccc_record_agi_CUR_I (
unique_id /*呼入通话ID*/ unique_id /*呼入通话ID*/
,call_id /*CallID*/ ,call_id /*CallID*/
,ccc_contact_id /*ccc联系方式编号*/
,customer_number /*客户号码*/ ,customer_number /*客户号码*/
,customer_province /*客户省份*/ ,customer_province /*客户省份*/
,customer_city /*客户城市*/ ,customer_city /*客户城市*/
@ -84,13 +87,14 @@ INSERT INTO cust_call_ccc_record_agi_CUR_I (
SELECT SELECT
COALESCE(TRIM(p0.ib_unique_id),'') /*unique_id*/ COALESCE(TRIM(p0.ib_unique_id),'') /*unique_id*/
,COALESCE(TRIM(p0.call_id),'') /*call_id*/ ,COALESCE(TRIM(p0.call_id),'') /*call_id*/
,coalesce(p1.id,'') /*ccc_contact_id*/
,COALESCE(TRIM(p0.customer_number),'') /*customer_number*/ ,COALESCE(TRIM(p0.customer_number),'') /*customer_number*/
,COALESCE(TRIM(p0.customer_province),'') /*customer_province*/ ,COALESCE(TRIM(p0.customer_province),'') /*customer_province*/
,COALESCE(TRIM(p0.customer_city),'') /*customer_city*/ ,COALESCE(TRIM(p0.customer_city),'') /*customer_city*/
,COALESCE(TRIM(p0.first_call_number),'') /*call_number*/ ,COALESCE(TRIM(p0.first_call_number),'') /*call_number*/
,COALESCE(TRIM(p0.first_call_cno),'') /*call_cno*/ ,COALESCE(TRIM(p0.first_call_cno),'') /*call_cno*/
,COALESCE(TRIM(p0.first_call_cname),'') /*call_cname*/ ,COALESCE(TRIM(p0.first_call_cname),'') /*call_cname*/
,COALESCE(TRIM(p0.first_call_qname),'') /*call_qname*/ ,'' /*call_qname*/
,'InBound' /*call_source_type*/ ,'InBound' /*call_source_type*/
,COALESCE(TRIM(p0.call_type),'') /*call_type*/ ,COALESCE(TRIM(p0.call_type),'') /*call_type*/
,'' /*call_type_desc*/ ,'' /*call_type_desc*/
@ -98,10 +102,10 @@ SELECT
,COALESCE(TRIM(p0.ib_status),'') /*call_status*/ ,COALESCE(TRIM(p0.ib_status),'') /*call_status*/
,COALESCE(TRIM(p0.ib_result),'') /*call_result*/ ,COALESCE(TRIM(p0.ib_result),'') /*call_result*/
,COALESCE(TRIM(p0.webrtc_call_id),'') /*webrtc_call_id*/ ,COALESCE(TRIM(p0.webrtc_call_id),'') /*webrtc_call_id*/
,COALESCE(TRIM(p0.hotline_name),'') /*hotline_name*/ ,'' /*hotline_name*/
,COALESCE(TRIM(p0.on_hook_source),'') /*on_hook_source*/ ,COALESCE(TRIM(p0.on_hook_source),'') /*on_hook_source*/
,COALESCE(TRIM(p0.investigation_keys),'') /*investigation_keys*/ ,COALESCE(TRIM(p0.investigation_keys),'') /*investigation_keys*/
,COALESCE(TRIM(p0.agent_answer_in_time),'') /*agent_answer_in_time*/ ,'' /*agent_answer_in_time*/
,COALESCE(TRIM(p0.evaluation),'') /*evaluation*/ ,COALESCE(TRIM(p0.evaluation),'') /*evaluation*/
,COALESCE(p0.start_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*start_time*/ ,COALESCE(p0.start_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*start_time*/
,COALESCE(p0.ring_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*ring_time*/ ,COALESCE(p0.ring_time,TO_TIMESTAMP(:NULLDATE,'YYYYMMDD')) /*ring_time*/
@ -121,6 +125,9 @@ SELECT
,'t01_ccc_ib_record' /*Src_Table*/ ,'t01_ccc_ib_record' /*Src_Table*/
FROM :PDMDB.t01_ccc_ib_record p0 FROM :PDMDB.t01_ccc_ib_record p0
LEFT JOIN (select distinct on (tel) * from p30_common.d_ccc_cust_info
where tel<>'') p1
ON p0.customer_number =p1.tel
; ;
@ -131,6 +138,7 @@ FROM :PDMDB.t01_ccc_ib_record p0
INSERT INTO cust_call_ccc_record_agi_CUR_I ( INSERT INTO cust_call_ccc_record_agi_CUR_I (
unique_id /*呼入通话ID*/ unique_id /*呼入通话ID*/
,call_id /*CallID*/ ,call_id /*CallID*/
,ccc_contact_id /*ccc联系方式编号*/
,customer_number /*客户号码*/ ,customer_number /*客户号码*/
,customer_province /*客户省份*/ ,customer_province /*客户省份*/
,customer_city /*客户城市*/ ,customer_city /*客户城市*/
@ -170,6 +178,7 @@ INSERT INTO cust_call_ccc_record_agi_CUR_I (
SELECT SELECT
COALESCE(TRIM(p0.ob_unique_id),'') /*unique_id*/ COALESCE(TRIM(p0.ob_unique_id),'') /*unique_id*/
,COALESCE(TRIM(p0.call_id),'') /*call_id*/ ,COALESCE(TRIM(p0.call_id),'') /*call_id*/
,'' /*ccc_contact_id*/
,COALESCE(TRIM(p0.customer_number),'') /*customer_number*/ ,COALESCE(TRIM(p0.customer_number),'') /*customer_number*/
,COALESCE(TRIM(p0.customer_province),'') /*customer_province*/ ,COALESCE(TRIM(p0.customer_province),'') /*customer_province*/
,COALESCE(TRIM(p0.customer_city),'') /*customer_city*/ ,COALESCE(TRIM(p0.customer_city),'') /*customer_city*/
@ -213,7 +222,8 @@ FROM :PDMDB.t01_ccc_ob_record p0
/*将不同数据插入到临时表 */ /*将不同数据插入到临时表 */
;INSERT INTO cust_call_ccc_record_agi_INS ( ;INSERT INTO cust_call_ccc_record_agi_INS (
customer_number /*客户号码*/ ccc_contact_id /*ccc联系方式编号*/
,customer_number /*客户号码*/
,customer_province /*客户省份*/ ,customer_province /*客户省份*/
,customer_city /*客户城市*/ ,customer_city /*客户城市*/
,call_number /*座席电话*/ ,call_number /*座席电话*/
@ -253,7 +263,8 @@ FROM :PDMDB.t01_ccc_ob_record p0
) )
SELECT SELECT
P1.customer_number /*客户号码*/ P1.ccc_contact_id /*ccc联系方式编号*/
,P1.customer_number /*客户号码*/
,P1.customer_province /*客户省份*/ ,P1.customer_province /*客户省份*/
,P1.customer_city /*客户城市*/ ,P1.customer_city /*客户城市*/
,P1.call_number /*座席电话*/ ,P1.call_number /*座席电话*/
@ -293,7 +304,8 @@ FROM :PDMDB.t01_ccc_ob_record p0
FROM cust_call_ccc_record_agi_CUR_I P1 FROM cust_call_ccc_record_agi_CUR_I P1
LEFT JOIN :COMMDB.cust_call_ccc_record P2 LEFT JOIN :COMMDB.cust_call_ccc_record P2
ON P1.customer_number = P2.customer_number ON P1.ccc_contact_id = P2.ccc_contact_id
AND P1.customer_number = P2.customer_number
AND P1.customer_province = P2.customer_province AND P1.customer_province = P2.customer_province
AND P1.customer_city = P2.customer_city AND P1.customer_city = P2.customer_city
AND P1.call_number = P2.call_number AND P1.call_number = P2.call_number
@ -324,7 +336,8 @@ ON P1.customer_number = P2.customer_number
AND P1.unique_id = P2.unique_id AND P1.unique_id = P2.unique_id
AND P1.call_id = P2.call_id AND P1.call_id = P2.call_id
WHERE P2.customer_number IS NULL WHERE P2.ccc_contact_id IS NULL
OR P2.customer_number IS NULL
OR P2.customer_province IS NULL OR P2.customer_province IS NULL
OR P2.customer_city IS NULL OR P2.customer_city IS NULL
OR P2.call_number IS NULL OR P2.call_number IS NULL
@ -358,7 +371,8 @@ WHERE P2.customer_number IS NULL
; ;
/*将新增数据插入到目标表 */ /*将新增数据插入到目标表 */
;INSERT INTO :COMMDB.cust_call_ccc_record ( ;INSERT INTO :COMMDB.cust_call_ccc_record (
customer_number /*客户号码*/ ccc_contact_id /*ccc联系方式编号*/
,customer_number /*客户号码*/
,customer_province /*客户省份*/ ,customer_province /*客户省份*/
,customer_city /*客户城市*/ ,customer_city /*客户城市*/
,call_number /*座席电话*/ ,call_number /*座席电话*/
@ -398,7 +412,8 @@ WHERE P2.customer_number IS NULL
) )
SELECT SELECT
P1.customer_number /*客户号码*/ P1.ccc_contact_id /*ccc联系方式编号*/
,P1.customer_number /*客户号码*/
,P1.customer_province /*客户省份*/ ,P1.customer_province /*客户省份*/
,P1.customer_city /*客户城市*/ ,P1.customer_city /*客户城市*/
,P1.call_number /*座席电话*/ ,P1.call_number /*座席电话*/
@ -441,6 +456,7 @@ ON CONFLICT ( unique_id,call_id)
DO UPDATE SET DO UPDATE SET
unique_id=excluded.unique_id unique_id=excluded.unique_id
,call_id=excluded.call_id ,call_id=excluded.call_id
,ccc_contact_id=excluded.ccc_contact_id
,customer_number=excluded.customer_number ,customer_number=excluded.customer_number
,customer_province=excluded.customer_province ,customer_province=excluded.customer_province
,customer_city=excluded.customer_city ,customer_city=excluded.customer_city