add workflow 天润Smart-ccc通话记录,dev
This commit is contained in:
parent
7eaf36667e
commit
7343dd43ca
|
@ -48,7 +48,7 @@ CREATE TABLE IF NOT EXISTS p20_pdm.t01_ccc_ib_record (
|
|||
, Src_Sysname varchar(50)
|
||||
, Src_Table varchar(50)
|
||||
, Etl_Batch_No varchar(50)
|
||||
,primary key( ib_unique_id )
|
||||
,primary key( ib_unique_id,call_id )
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN p20_pdm.t01_ccc_ib_record.ib_unique_id IS '呼入通话ID';
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/*Brilliance stems from wisdoms. */
|
||||
/*************Head Section**************************************************************************/
|
||||
/*Script Use: Periodically load data to :t01_ccc_ib_record(smartccc呼入记录) */
|
||||
/*Create Date:2024-08-20 19:11:55 */
|
||||
/*Create Date:2024-08-20 19:21:04 */
|
||||
/*SDM Developed By: dev */
|
||||
/*SDM Developed Date: 2024-07-19 */
|
||||
/*SDM Checked By: dev */
|
||||
|
@ -93,7 +93,7 @@ INSERT INTO t01_ccc_ib_record_agi_CUR_I (
|
|||
)
|
||||
SELECT
|
||||
COALESCE(TRIM(CAST(p0.main_unique_id AS varchar(50))),'') /*ib_unique_id*/
|
||||
,COALESCE(TRIM(CAST(p0.call_id AS varchar(50))),'') /*call_id*/
|
||||
,coalesce(p1.call_id,p0.call_id,'') /*call_id*/
|
||||
,COALESCE(TRIM(CAST(p0.customer_number AS varchar(20))),'') /*customer_number*/
|
||||
,COALESCE(TRIM(CAST(p0.customer_number_encrypt AS varchar(50))),'') /*customer_number_encrypt*/
|
||||
,COALESCE(TRIM(CAST(p0.customer_province AS varchar(20))),'') /*customer_province*/
|
||||
|
@ -120,16 +120,16 @@ SELECT
|
|||
,COALESCE(TRIM(CAST(p0.agent_answer_in_time AS varchar(20))),'') /*agent_answer_in_time*/
|
||||
,COALESCE(TRIM(CAST(p0.evaluation AS varchar(20))),'') /*evaluation*/
|
||||
,COALESCE(TRIM(p0.user_field),'') /*user_field*/
|
||||
,to_timestamp(p0.start_time::bigint/1000)::timestamp(0) /*start_time*/
|
||||
,to_timestamp(p1.ring_time::bigint/1000)::timestamp(0) /*ring_time*/
|
||||
,p1.ib_ringing_duration /*ib_ringing_duration*/
|
||||
,to_timestamp(p0.end_time::bigint/1000)::timestamp(0) /*end_time*/
|
||||
,to_timestamp(p1.answer_time::bigint/1000)::timestamp(0) /*answer_time*/
|
||||
,to_timestamp(p1.offhook_time::bigint/1000)::timestamp(0) /*offhook_time*/
|
||||
,to_timestamp(p0.bridge_time::bigint/1000)::timestamp(0) /*bridge_time*/
|
||||
,to_timestamp(p0.start_time::bigint)::timestamp(0) /*start_time*/
|
||||
,to_timestamp(p1.ring_time::bigint)::timestamp(0) /*ring_time*/
|
||||
,p1.ib_ringing_duration::int /*ib_ringing_duration*/
|
||||
,to_timestamp(p0.end_time::bigint)::timestamp(0) /*end_time*/
|
||||
,to_timestamp(p1.answer_time::bigint)::timestamp(0) /*answer_time*/
|
||||
,to_timestamp(p1.offhook_time::bigint)::timestamp(0) /*offhook_time*/
|
||||
,to_timestamp(p0.bridge_time::bigint)::timestamp(0) /*bridge_time*/
|
||||
,COALESCE(CAST(p0.bridge_duration AS int),0) /*bridge_duration*/
|
||||
,COALESCE(CAST(p0.total_duration AS int),0) /*total_duration*/
|
||||
,to_timestamp(p0.first_join_queue_time::bigint/1000)::timestamp(0) /*first_join_queue_time*/
|
||||
,to_timestamp(p0.first_join_queue_time::bigint)::timestamp(0) /*first_join_queue_time*/
|
||||
,COALESCE(CAST(p0.say_voice_duration AS int),0) /*say_voice_duration*/
|
||||
,COALESCE(TRIM(p0.mark_data),'') /*mark_data*/
|
||||
,TO_DATE(:TXDATE,'YYYYMMDD') /*Etl_First_Dt*/
|
||||
|
@ -149,8 +149,7 @@ LEFT JOIN :SADB.s98_s_tr_cc_cdr_ib_agent_list p1
|
|||
|
||||
/*将不同数据插入到临时表 */
|
||||
;INSERT INTO t01_ccc_ib_record_agi_INS (
|
||||
call_id /*CallID*/
|
||||
,customer_number /*客户号码*/
|
||||
customer_number /*客户号码*/
|
||||
,customer_number_encrypt /*客户号码加密串*/
|
||||
,customer_province /*客户省份*/
|
||||
,customer_city /*客户城市*/
|
||||
|
@ -189,6 +188,7 @@ LEFT JOIN :SADB.s98_s_tr_cc_cdr_ib_agent_list p1
|
|||
,say_voice_duration /*语音播报时长*/
|
||||
,mark_data /*备注*/
|
||||
,ib_unique_id /*呼入通话ID*/
|
||||
,call_id /*CallID*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
|
@ -199,8 +199,7 @@ LEFT JOIN :SADB.s98_s_tr_cc_cdr_ib_agent_list p1
|
|||
|
||||
)
|
||||
SELECT
|
||||
P1.call_id /*CallID*/
|
||||
,P1.customer_number /*客户号码*/
|
||||
P1.customer_number /*客户号码*/
|
||||
,P1.customer_number_encrypt /*客户号码加密串*/
|
||||
,P1.customer_province /*客户省份*/
|
||||
,P1.customer_city /*客户城市*/
|
||||
|
@ -239,6 +238,7 @@ LEFT JOIN :SADB.s98_s_tr_cc_cdr_ib_agent_list p1
|
|||
,P1.say_voice_duration /*语音播报时长*/
|
||||
,P1.mark_data /*备注*/
|
||||
,P1.ib_unique_id /*呼入通话ID*/
|
||||
,P1.call_id /*CallID*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
|
@ -249,8 +249,7 @@ LEFT JOIN :SADB.s98_s_tr_cc_cdr_ib_agent_list p1
|
|||
|
||||
FROM t01_ccc_ib_record_agi_CUR_I P1
|
||||
LEFT JOIN :PDMDB.t01_ccc_ib_record P2
|
||||
ON P1.call_id = P2.call_id
|
||||
AND P1.customer_number = P2.customer_number
|
||||
ON P1.customer_number = P2.customer_number
|
||||
AND P1.customer_number_encrypt = P2.customer_number_encrypt
|
||||
AND P1.customer_province = P2.customer_province
|
||||
AND P1.customer_city = P2.customer_city
|
||||
|
@ -289,9 +288,9 @@ ON P1.call_id = P2.call_id
|
|||
AND P1.say_voice_duration = P2.say_voice_duration
|
||||
AND P1.mark_data = P2.mark_data
|
||||
AND P1.ib_unique_id = P2.ib_unique_id
|
||||
AND P1.call_id = P2.call_id
|
||||
|
||||
WHERE P2.call_id IS NULL
|
||||
OR P2.customer_number IS NULL
|
||||
WHERE P2.customer_number IS NULL
|
||||
OR P2.customer_number_encrypt IS NULL
|
||||
OR P2.customer_province IS NULL
|
||||
OR P2.customer_city IS NULL
|
||||
|
@ -330,12 +329,12 @@ WHERE P2.call_id IS NULL
|
|||
OR P2.say_voice_duration IS NULL
|
||||
OR P2.mark_data IS NULL
|
||||
OR P2.ib_unique_id IS NULL
|
||||
OR P2.call_id IS NULL
|
||||
|
||||
;
|
||||
/*将新增数据插入到目标表 */
|
||||
;INSERT INTO :PDMDB.t01_ccc_ib_record (
|
||||
call_id /*CallID*/
|
||||
,customer_number /*客户号码*/
|
||||
customer_number /*客户号码*/
|
||||
,customer_number_encrypt /*客户号码加密串*/
|
||||
,customer_province /*客户省份*/
|
||||
,customer_city /*客户城市*/
|
||||
|
@ -374,6 +373,7 @@ WHERE P2.call_id IS NULL
|
|||
,say_voice_duration /*语音播报时长*/
|
||||
,mark_data /*备注*/
|
||||
,ib_unique_id /*呼入通话ID*/
|
||||
,call_id /*CallID*/
|
||||
,Etl_First_Dt /*最初入库时间*/
|
||||
,Etl_Job /*作业名称*/
|
||||
,Etl_Proc_Dt /*本次入库时间*/
|
||||
|
@ -384,8 +384,7 @@ WHERE P2.call_id IS NULL
|
|||
|
||||
)
|
||||
SELECT
|
||||
P1.call_id /*CallID*/
|
||||
,P1.customer_number /*客户号码*/
|
||||
P1.customer_number /*客户号码*/
|
||||
,P1.customer_number_encrypt /*客户号码加密串*/
|
||||
,P1.customer_province /*客户省份*/
|
||||
,P1.customer_city /*客户城市*/
|
||||
|
@ -424,6 +423,7 @@ SELECT
|
|||
,P1.say_voice_duration /*语音播报时长*/
|
||||
,P1.mark_data /*备注*/
|
||||
,P1.ib_unique_id /*呼入通话ID*/
|
||||
,P1.call_id /*CallID*/
|
||||
,P1.Etl_First_Dt /*最初入库时间*/
|
||||
,P1.Etl_Job /*作业名称*/
|
||||
,P1.Etl_Proc_Dt /*本次入库时间*/
|
||||
|
@ -433,7 +433,7 @@ SELECT
|
|||
,P1.Etl_Batch_No /*作业批次号*/
|
||||
|
||||
FROM t01_ccc_ib_record_agi_INS P1
|
||||
ON CONFLICT ( ib_unique_id)
|
||||
ON CONFLICT ( ib_unique_id,call_id)
|
||||
DO UPDATE SET
|
||||
ib_unique_id=excluded.ib_unique_id
|
||||
,call_id=excluded.call_id
|
||||
|
|
Loading…
Reference in New Issue