add workflow 天润Smart-ccc通话记录,dev
This commit is contained in:
parent
2a860b137d
commit
88451a1d54
dev/workflow/TK_Cust/smart_ccc_cdr
tr_cc_cdr_ib_agent_list
tr_cc_cdr_ib_list
tr_cc_cdr_ob_detail
tr_cc_cdr_ob_list
天润Smart-ccc通话记录
查询外呼记录列表
查询外呼记录详情
查询客户来电记录列表
查询座席接听记录列表
|
@ -0,0 +1,146 @@
|
|||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
delete from p10_sa.S98_S_tr_cc_cdr_ib_agent_list
|
||||
;
|
||||
insert into p10_sa.S98_S_tr_cc_cdr_ib_agent_list
|
||||
( unique_id
|
||||
, main_unique_id
|
||||
, qno
|
||||
, qname
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, bridge_status
|
||||
, bridge_status_detail
|
||||
, sip_cause_desc
|
||||
, on_hook_source
|
||||
, agent_answer_in_time
|
||||
, detail_call_type
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, record_file
|
||||
, start_time
|
||||
, ring_time
|
||||
, ib_ringing_duration
|
||||
, answer_time
|
||||
, offhook_time
|
||||
, say_voice_duration
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, customer_city
|
||||
, hotline
|
||||
, hotline_name
|
||||
, remember
|
||||
, etl_tx_dt )
|
||||
select
|
||||
unique_id
|
||||
, main_unique_id
|
||||
, qno
|
||||
, qname
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, bridge_status
|
||||
, bridge_status_detail
|
||||
, sip_cause_desc
|
||||
, on_hook_source
|
||||
, agent_answer_in_time
|
||||
, detail_call_type
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, record_file
|
||||
, start_time
|
||||
, ring_time
|
||||
, ib_ringing_duration
|
||||
, answer_time
|
||||
, offhook_time
|
||||
, say_voice_duration
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, customer_city
|
||||
, hotline
|
||||
, hotline_name
|
||||
, remember
|
||||
, etl_tx_dt
|
||||
from p00_tal.S98_S_tr_cc_cdr_ib_agent_list
|
||||
;
|
||||
delete from p12_sfull.S98_S_tr_cc_cdr_ib_agent_list where unique_id in (select unique_id from p10_sa.S98_S_tr_cc_cdr_ib_agent_list)
|
||||
;
|
||||
;
|
||||
insert into p12_sfull.S98_S_tr_cc_cdr_ib_agent_list
|
||||
( unique_id
|
||||
, main_unique_id
|
||||
, qno
|
||||
, qname
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, bridge_status
|
||||
, bridge_status_detail
|
||||
, sip_cause_desc
|
||||
, on_hook_source
|
||||
, agent_answer_in_time
|
||||
, detail_call_type
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, record_file
|
||||
, start_time
|
||||
, ring_time
|
||||
, ib_ringing_duration
|
||||
, answer_time
|
||||
, offhook_time
|
||||
, say_voice_duration
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, customer_city
|
||||
, hotline
|
||||
, hotline_name
|
||||
, remember
|
||||
, etl_tx_dt )
|
||||
select
|
||||
unique_id
|
||||
, main_unique_id
|
||||
, qno
|
||||
, qname
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, bridge_status
|
||||
, bridge_status_detail
|
||||
, sip_cause_desc
|
||||
, on_hook_source
|
||||
, agent_answer_in_time
|
||||
, detail_call_type
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, record_file
|
||||
, start_time
|
||||
, ring_time
|
||||
, ib_ringing_duration
|
||||
, answer_time
|
||||
, offhook_time
|
||||
, say_voice_duration
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, customer_city
|
||||
, hotline
|
||||
, hotline_name
|
||||
, remember
|
||||
, etl_tx_dt
|
||||
from p10_sa.S98_S_tr_cc_cdr_ib_agent_list
|
||||
;
|
||||
\q
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
CREATE FOREIGN TABLE if not exists p00_tal.S98_S_tr_cc_cdr_ib_agent_list (
|
||||
unique_id TEXT
|
||||
, main_unique_id TEXT
|
||||
, qno TEXT
|
||||
, qname TEXT
|
||||
, cno TEXT
|
||||
, client_name TEXT
|
||||
, client_number TEXT
|
||||
, bridge_status TEXT
|
||||
, bridge_status_detail TEXT
|
||||
, sip_cause_desc TEXT
|
||||
, on_hook_source TEXT
|
||||
, agent_answer_in_time TEXT
|
||||
, detail_call_type TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, record_file TEXT
|
||||
, start_time TEXT
|
||||
, ring_time TEXT
|
||||
, ib_ringing_duration TEXT
|
||||
, answer_time TEXT
|
||||
, offhook_time TEXT
|
||||
, say_voice_duration TEXT
|
||||
, end_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, customer_number TEXT
|
||||
, customer_number_encrypt TEXT
|
||||
, customer_province TEXT
|
||||
, customer_city TEXT
|
||||
, hotline TEXT
|
||||
, hotline_name TEXT
|
||||
, remember TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
)
|
||||
|
||||
|
||||
SERVER pgsql_server_S98_S OPTIONS(schema_name 'data_api', table_name 'tr_cc_cdr_ib_agent_list' );
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
|
||||
create table if not exists p10_sa.S98_S_tr_cc_cdr_ib_agent_list (
|
||||
unique_id TEXT
|
||||
, main_unique_id TEXT
|
||||
, qno TEXT
|
||||
, qname TEXT
|
||||
, cno TEXT
|
||||
, client_name TEXT
|
||||
, client_number TEXT
|
||||
, bridge_status TEXT
|
||||
, bridge_status_detail TEXT
|
||||
, sip_cause_desc TEXT
|
||||
, on_hook_source TEXT
|
||||
, agent_answer_in_time TEXT
|
||||
, detail_call_type TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, record_file TEXT
|
||||
, start_time TEXT
|
||||
, ring_time TEXT
|
||||
, ib_ringing_duration TEXT
|
||||
, answer_time TEXT
|
||||
, offhook_time TEXT
|
||||
, say_voice_duration TEXT
|
||||
, end_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, customer_number TEXT
|
||||
, customer_number_encrypt TEXT
|
||||
, customer_province TEXT
|
||||
, customer_city TEXT
|
||||
, hotline TEXT
|
||||
, hotline_name TEXT
|
||||
, remember TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
) ;
|
||||
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.unique_id IS '唯一标识';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.main_unique_id IS '通话ID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.qno IS '来电队列号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.qname IS '来电队列名称';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.cno IS '座席号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.client_name IS '座席名称';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.client_number IS '座席电话';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.bridge_status IS '接听状态';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.bridge_status_detail IS '呼叫结果';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.sip_cause_desc IS '呼叫情况';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.on_hook_source IS '挂断方';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.agent_answer_in_time IS '及时应答';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.detail_call_type IS '呼叫类型';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.call_id IS 'CallID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.webrtc_call_id IS 'WebRTCCallID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.record_file IS '录音文件名';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.start_time IS '开始时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.ring_time IS '振铃时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.ib_ringing_duration IS '振铃时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.answer_time IS '接听时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.offhook_time IS '座席接起时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.say_voice_duration IS '语音播报时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.end_time IS '结束时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.bridge_duration IS '通话时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.customer_number IS '客户号码,带区号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.customer_number_encrypt IS '客户号码加密串';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.customer_province IS '客户号码省份';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.customer_city IS '客户号码城市';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.hotline IS '热线号码';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.hotline_name IS '热线别名';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.remember IS '主叫记忆';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_agent_list.etl_tx_dt IS '';
|
||||
|
||||
COMMENT ON TABLE p10_sa.S98_S_tr_cc_cdr_ib_agent_list IS '座席接听记录列表';
|
||||
|
||||
|
||||
|
||||
create table if not exists p12_sfull.S98_S_tr_cc_cdr_ib_agent_list (
|
||||
unique_id TEXT
|
||||
, main_unique_id TEXT
|
||||
, qno TEXT
|
||||
, qname TEXT
|
||||
, cno TEXT
|
||||
, client_name TEXT
|
||||
, client_number TEXT
|
||||
, bridge_status TEXT
|
||||
, bridge_status_detail TEXT
|
||||
, sip_cause_desc TEXT
|
||||
, on_hook_source TEXT
|
||||
, agent_answer_in_time TEXT
|
||||
, detail_call_type TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, record_file TEXT
|
||||
, start_time TEXT
|
||||
, ring_time TEXT
|
||||
, ib_ringing_duration TEXT
|
||||
, answer_time TEXT
|
||||
, offhook_time TEXT
|
||||
, say_voice_duration TEXT
|
||||
, end_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, customer_number TEXT
|
||||
, customer_number_encrypt TEXT
|
||||
, customer_province TEXT
|
||||
, customer_city TEXT
|
||||
, hotline TEXT
|
||||
, hotline_name TEXT
|
||||
, remember TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
) ;
|
||||
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.unique_id IS '唯一标识';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.main_unique_id IS '通话ID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.qno IS '来电队列号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.qname IS '来电队列名称';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.cno IS '座席号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.client_name IS '座席名称';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.client_number IS '座席电话';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.bridge_status IS '接听状态';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.bridge_status_detail IS '呼叫结果';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.sip_cause_desc IS '呼叫情况';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.on_hook_source IS '挂断方';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.agent_answer_in_time IS '及时应答';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.detail_call_type IS '呼叫类型';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.call_id IS 'CallID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.webrtc_call_id IS 'WebRTCCallID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.record_file IS '录音文件名';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.start_time IS '开始时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.ring_time IS '振铃时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.ib_ringing_duration IS '振铃时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.answer_time IS '接听时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.offhook_time IS '座席接起时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.say_voice_duration IS '语音播报时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.end_time IS '结束时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.bridge_duration IS '通话时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.customer_number IS '客户号码,带区号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.customer_number_encrypt IS '客户号码加密串';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.customer_province IS '客户号码省份';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.customer_city IS '客户号码城市';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.hotline IS '热线号码';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.hotline_name IS '热线别名';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.remember IS '主叫记忆';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_agent_list.etl_tx_dt IS '';
|
||||
|
||||
COMMENT ON TABLE p12_sfull.S98_S_tr_cc_cdr_ib_agent_list IS '座席接听记录列表';
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
delete from p10_sa.S98_S_tr_cc_cdr_ib_list
|
||||
;
|
||||
insert into p10_sa.S98_S_tr_cc_cdr_ib_list
|
||||
( customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, customer_city
|
||||
, first_call_number
|
||||
, first_call_cno
|
||||
, first_call_cname
|
||||
, first_call_qno
|
||||
, first_call_qname
|
||||
, ivr_name
|
||||
, hotline
|
||||
, hotline_name
|
||||
, xnumber
|
||||
, status
|
||||
, status_result
|
||||
, status_robot
|
||||
, main_unique_id
|
||||
, tag_names
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, record_file
|
||||
, on_hook_source
|
||||
, investigation_keys
|
||||
, agent_answer_in_time
|
||||
, evaluation
|
||||
, user_field
|
||||
, start_time
|
||||
, end_time
|
||||
, bridge_time
|
||||
, bridge_duration
|
||||
, total_duration
|
||||
, first_join_queue_time
|
||||
, say_voice_duration
|
||||
, mark_data
|
||||
, etl_tx_dt )
|
||||
select
|
||||
customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, customer_city
|
||||
, first_call_number
|
||||
, first_call_cno
|
||||
, first_call_cname
|
||||
, first_call_qno
|
||||
, first_call_qname
|
||||
, ivr_name
|
||||
, hotline
|
||||
, hotline_name
|
||||
, xnumber
|
||||
, status
|
||||
, status_result
|
||||
, status_robot
|
||||
, main_unique_id
|
||||
, tag_names
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, record_file
|
||||
, on_hook_source
|
||||
, investigation_keys
|
||||
, agent_answer_in_time
|
||||
, evaluation
|
||||
, user_field
|
||||
, start_time
|
||||
, end_time
|
||||
, bridge_time
|
||||
, bridge_duration
|
||||
, total_duration
|
||||
, first_join_queue_time
|
||||
, say_voice_duration
|
||||
, mark_data
|
||||
, etl_tx_dt
|
||||
from p00_tal.S98_S_tr_cc_cdr_ib_list
|
||||
;
|
||||
delete from p12_sfull.S98_S_tr_cc_cdr_ib_list
|
||||
;
|
||||
;
|
||||
insert into p12_sfull.S98_S_tr_cc_cdr_ib_list
|
||||
( customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, customer_city
|
||||
, first_call_number
|
||||
, first_call_cno
|
||||
, first_call_cname
|
||||
, first_call_qno
|
||||
, first_call_qname
|
||||
, ivr_name
|
||||
, hotline
|
||||
, hotline_name
|
||||
, xnumber
|
||||
, status
|
||||
, status_result
|
||||
, status_robot
|
||||
, main_unique_id
|
||||
, tag_names
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, record_file
|
||||
, on_hook_source
|
||||
, investigation_keys
|
||||
, agent_answer_in_time
|
||||
, evaluation
|
||||
, user_field
|
||||
, start_time
|
||||
, end_time
|
||||
, bridge_time
|
||||
, bridge_duration
|
||||
, total_duration
|
||||
, first_join_queue_time
|
||||
, say_voice_duration
|
||||
, mark_data
|
||||
, etl_tx_dt )
|
||||
select
|
||||
customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, customer_city
|
||||
, first_call_number
|
||||
, first_call_cno
|
||||
, first_call_cname
|
||||
, first_call_qno
|
||||
, first_call_qname
|
||||
, ivr_name
|
||||
, hotline
|
||||
, hotline_name
|
||||
, xnumber
|
||||
, status
|
||||
, status_result
|
||||
, status_robot
|
||||
, main_unique_id
|
||||
, tag_names
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, record_file
|
||||
, on_hook_source
|
||||
, investigation_keys
|
||||
, agent_answer_in_time
|
||||
, evaluation
|
||||
, user_field
|
||||
, start_time
|
||||
, end_time
|
||||
, bridge_time
|
||||
, bridge_duration
|
||||
, total_duration
|
||||
, first_join_queue_time
|
||||
, say_voice_duration
|
||||
, mark_data
|
||||
, etl_tx_dt
|
||||
from p10_sa.S98_S_tr_cc_cdr_ib_list
|
||||
;
|
||||
\q
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
CREATE FOREIGN TABLE if not exists p00_tal.S98_S_tr_cc_cdr_ib_list (
|
||||
customer_number TEXT
|
||||
, customer_number_encrypt TEXT
|
||||
, customer_province TEXT
|
||||
, customer_city TEXT
|
||||
, first_call_number TEXT
|
||||
, first_call_cno TEXT
|
||||
, first_call_cname TEXT
|
||||
, first_call_qno TEXT
|
||||
, first_call_qname TEXT
|
||||
, ivr_name TEXT
|
||||
, hotline TEXT
|
||||
, hotline_name TEXT
|
||||
, xnumber TEXT
|
||||
, status TEXT
|
||||
, status_result TEXT
|
||||
, status_robot TEXT
|
||||
, main_unique_id TEXT
|
||||
, tag_names TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, record_file TEXT
|
||||
, on_hook_source TEXT
|
||||
, investigation_keys TEXT
|
||||
, agent_answer_in_time TEXT
|
||||
, evaluation TEXT
|
||||
, user_field TEXT
|
||||
, start_time TEXT
|
||||
, end_time TEXT
|
||||
, bridge_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, total_duration TEXT
|
||||
, first_join_queue_time TEXT
|
||||
, say_voice_duration TEXT
|
||||
, mark_data TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
)
|
||||
|
||||
|
||||
SERVER pgsql_server_S98_S OPTIONS(schema_name 'data_api', table_name 'tr_cc_cdr_ib_list' );
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
|
||||
create table if not exists p10_sa.S98_S_tr_cc_cdr_ib_list (
|
||||
customer_number TEXT
|
||||
, customer_number_encrypt TEXT
|
||||
, customer_province TEXT
|
||||
, customer_city TEXT
|
||||
, first_call_number TEXT
|
||||
, first_call_cno TEXT
|
||||
, first_call_cname TEXT
|
||||
, first_call_qno TEXT
|
||||
, first_call_qname TEXT
|
||||
, ivr_name TEXT
|
||||
, hotline TEXT
|
||||
, hotline_name TEXT
|
||||
, xnumber TEXT
|
||||
, status TEXT
|
||||
, status_result TEXT
|
||||
, status_robot TEXT
|
||||
, main_unique_id TEXT
|
||||
, tag_names TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, record_file TEXT
|
||||
, on_hook_source TEXT
|
||||
, investigation_keys TEXT
|
||||
, agent_answer_in_time TEXT
|
||||
, evaluation TEXT
|
||||
, user_field TEXT
|
||||
, start_time TEXT
|
||||
, end_time TEXT
|
||||
, bridge_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, total_duration TEXT
|
||||
, first_join_queue_time TEXT
|
||||
, say_voice_duration TEXT
|
||||
, mark_data TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
) ;
|
||||
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.customer_number IS '客户号码';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.customer_number_encrypt IS '客户号码加密串';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.customer_province IS '客户号码省份';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.customer_city IS '客户号码城市';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.first_call_number IS '首呼座席电话';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.first_call_cno IS '首呼座席工号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.first_call_cname IS '首呼座席姓名';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.first_call_qno IS '首呼队列号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.first_call_qname IS '首呼队列名称';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.ivr_name IS 'IVR名称';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.hotline IS '热线号码';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.hotline_name IS '热线别名';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.xnumber IS '虚拟号码';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.status IS '接听状态';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.status_result IS '呼叫结果';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.status_robot IS '机器人接听状态';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.main_unique_id IS '通话ID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.tag_names IS '通话标签';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.call_id IS 'CallID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.webrtc_call_id IS 'WebRTCCallID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.record_file IS '录音文件';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.on_hook_source IS '挂断方';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.investigation_keys IS '满意度评价';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.agent_answer_in_time IS '首次及时应答';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.evaluation IS '是否邀评';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.user_field IS '自定义字段';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.start_time IS '开始时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.end_time IS '结束时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.bridge_time IS '首次接听时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.bridge_duration IS '通话时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.total_duration IS '总时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.first_join_queue_time IS '首次进入队列时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.say_voice_duration IS '语音播报时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.mark_data IS '备注';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ib_list.etl_tx_dt IS '';
|
||||
|
||||
COMMENT ON TABLE p10_sa.S98_S_tr_cc_cdr_ib_list IS '客户来电记录列表';
|
||||
|
||||
|
||||
|
||||
create table if not exists p12_sfull.S98_S_tr_cc_cdr_ib_list (
|
||||
customer_number TEXT
|
||||
, customer_number_encrypt TEXT
|
||||
, customer_province TEXT
|
||||
, customer_city TEXT
|
||||
, first_call_number TEXT
|
||||
, first_call_cno TEXT
|
||||
, first_call_cname TEXT
|
||||
, first_call_qno TEXT
|
||||
, first_call_qname TEXT
|
||||
, ivr_name TEXT
|
||||
, hotline TEXT
|
||||
, hotline_name TEXT
|
||||
, xnumber TEXT
|
||||
, status TEXT
|
||||
, status_result TEXT
|
||||
, status_robot TEXT
|
||||
, main_unique_id TEXT
|
||||
, tag_names TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, record_file TEXT
|
||||
, on_hook_source TEXT
|
||||
, investigation_keys TEXT
|
||||
, agent_answer_in_time TEXT
|
||||
, evaluation TEXT
|
||||
, user_field TEXT
|
||||
, start_time TEXT
|
||||
, end_time TEXT
|
||||
, bridge_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, total_duration TEXT
|
||||
, first_join_queue_time TEXT
|
||||
, say_voice_duration TEXT
|
||||
, mark_data TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
) ;
|
||||
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.customer_number IS '客户号码';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.customer_number_encrypt IS '客户号码加密串';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.customer_province IS '客户号码省份';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.customer_city IS '客户号码城市';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.first_call_number IS '首呼座席电话';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.first_call_cno IS '首呼座席工号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.first_call_cname IS '首呼座席姓名';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.first_call_qno IS '首呼队列号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.first_call_qname IS '首呼队列名称';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.ivr_name IS 'IVR名称';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.hotline IS '热线号码';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.hotline_name IS '热线别名';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.xnumber IS '虚拟号码';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.status IS '接听状态';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.status_result IS '呼叫结果';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.status_robot IS '机器人接听状态';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.main_unique_id IS '通话ID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.tag_names IS '通话标签';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.call_id IS 'CallID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.webrtc_call_id IS 'WebRTCCallID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.record_file IS '录音文件';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.on_hook_source IS '挂断方';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.investigation_keys IS '满意度评价';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.agent_answer_in_time IS '首次及时应答';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.evaluation IS '是否邀评';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.user_field IS '自定义字段';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.start_time IS '开始时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.end_time IS '结束时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.bridge_time IS '首次接听时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.bridge_duration IS '通话时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.total_duration IS '总时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.first_join_queue_time IS '首次进入队列时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.say_voice_duration IS '语音播报时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.mark_data IS '备注';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ib_list.etl_tx_dt IS '';
|
||||
|
||||
COMMENT ON TABLE p12_sfull.S98_S_tr_cc_cdr_ib_list IS '客户来电记录列表';
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
delete from p10_sa.S98_S_tr_cc_cdr_ob_detail
|
||||
;
|
||||
insert into p10_sa.S98_S_tr_cc_cdr_ob_detail
|
||||
( cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, callee_ringing_time
|
||||
, answer_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, call_type
|
||||
, call_type_desc
|
||||
, detail_call_type
|
||||
, detail_call_type_desc
|
||||
, ob_sip_cause
|
||||
, sip_cause
|
||||
, sip_cause_desc
|
||||
, record_file
|
||||
, tsi_file
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, main_unique_id
|
||||
, unique_id
|
||||
, etl_tx_dt )
|
||||
select
|
||||
cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, callee_ringing_time
|
||||
, answer_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, call_type
|
||||
, call_type_desc
|
||||
, detail_call_type
|
||||
, detail_call_type_desc
|
||||
, ob_sip_cause
|
||||
, sip_cause
|
||||
, sip_cause_desc
|
||||
, record_file
|
||||
, tsi_file
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, main_unique_id
|
||||
, unique_id
|
||||
, etl_tx_dt
|
||||
from p00_tal.S98_S_tr_cc_cdr_ob_detail
|
||||
;
|
||||
delete from p12_sfull.S98_S_tr_cc_cdr_ob_detail
|
||||
;
|
||||
;
|
||||
insert into p12_sfull.S98_S_tr_cc_cdr_ob_detail
|
||||
( cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, callee_ringing_time
|
||||
, answer_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, call_type
|
||||
, call_type_desc
|
||||
, detail_call_type
|
||||
, detail_call_type_desc
|
||||
, ob_sip_cause
|
||||
, sip_cause
|
||||
, sip_cause_desc
|
||||
, record_file
|
||||
, tsi_file
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, main_unique_id
|
||||
, unique_id
|
||||
, etl_tx_dt )
|
||||
select
|
||||
cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, callee_ringing_time
|
||||
, answer_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, call_type
|
||||
, call_type_desc
|
||||
, detail_call_type
|
||||
, detail_call_type_desc
|
||||
, ob_sip_cause
|
||||
, sip_cause
|
||||
, sip_cause_desc
|
||||
, record_file
|
||||
, tsi_file
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, main_unique_id
|
||||
, unique_id
|
||||
, etl_tx_dt
|
||||
from p10_sa.S98_S_tr_cc_cdr_ob_detail
|
||||
;
|
||||
\q
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
CREATE FOREIGN TABLE if not exists p00_tal.S98_S_tr_cc_cdr_ob_detail (
|
||||
cno TEXT
|
||||
, client_name TEXT
|
||||
, client_number TEXT
|
||||
, start_time TEXT
|
||||
, callee_ringing_time TEXT
|
||||
, answer_time TEXT
|
||||
, end_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, call_type TEXT
|
||||
, call_type_desc TEXT
|
||||
, detail_call_type TEXT
|
||||
, detail_call_type_desc TEXT
|
||||
, ob_sip_cause TEXT
|
||||
, sip_cause TEXT
|
||||
, sip_cause_desc TEXT
|
||||
, record_file TEXT
|
||||
, tsi_file TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, main_unique_id TEXT
|
||||
, unique_id TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
)
|
||||
|
||||
|
||||
SERVER pgsql_server_S98_S OPTIONS(schema_name 'data_api', table_name 'tr_cc_cdr_ob_detail' );
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
|
||||
create table if not exists p10_sa.S98_S_tr_cc_cdr_ob_detail (
|
||||
cno TEXT
|
||||
, client_name TEXT
|
||||
, client_number TEXT
|
||||
, start_time TEXT
|
||||
, callee_ringing_time TEXT
|
||||
, answer_time TEXT
|
||||
, end_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, call_type TEXT
|
||||
, call_type_desc TEXT
|
||||
, detail_call_type TEXT
|
||||
, detail_call_type_desc TEXT
|
||||
, ob_sip_cause TEXT
|
||||
, sip_cause TEXT
|
||||
, sip_cause_desc TEXT
|
||||
, record_file TEXT
|
||||
, tsi_file TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, main_unique_id TEXT
|
||||
, unique_id TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
) ;
|
||||
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.cno IS '座席工号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.client_name IS '座席名称';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.client_number IS '座席电话';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.start_time IS '开始时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.callee_ringing_time IS '客户响铃时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.answer_time IS '客户接听时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.end_time IS '结束时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.bridge_duration IS '通话时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.call_type IS '通话类型';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.call_type_desc IS '通话类型描述';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.detail_call_type IS '呼叫类型';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.detail_call_type_desc IS '呼叫类型描述';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.ob_sip_cause IS '呼叫结果';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.sip_cause IS '呼叫情况';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.sip_cause_desc IS '呼叫情况描述';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.record_file IS '录音';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.tsi_file IS '客户彩铃录音';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.call_id IS 'CallID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.webrtc_call_id IS 'WebRTCCallID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.main_unique_id IS '通话ID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.unique_id IS '通话唯一ID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_detail.etl_tx_dt IS '';
|
||||
|
||||
COMMENT ON TABLE p10_sa.S98_S_tr_cc_cdr_ob_detail IS '外呼记录详情';
|
||||
|
||||
|
||||
|
||||
create table if not exists p12_sfull.S98_S_tr_cc_cdr_ob_detail (
|
||||
cno TEXT
|
||||
, client_name TEXT
|
||||
, client_number TEXT
|
||||
, start_time TEXT
|
||||
, callee_ringing_time TEXT
|
||||
, answer_time TEXT
|
||||
, end_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, call_type TEXT
|
||||
, call_type_desc TEXT
|
||||
, detail_call_type TEXT
|
||||
, detail_call_type_desc TEXT
|
||||
, ob_sip_cause TEXT
|
||||
, sip_cause TEXT
|
||||
, sip_cause_desc TEXT
|
||||
, record_file TEXT
|
||||
, tsi_file TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, main_unique_id TEXT
|
||||
, unique_id TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
) ;
|
||||
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.cno IS '座席工号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.client_name IS '座席名称';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.client_number IS '座席电话';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.start_time IS '开始时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.callee_ringing_time IS '客户响铃时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.answer_time IS '客户接听时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.end_time IS '结束时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.bridge_duration IS '通话时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.call_type IS '通话类型';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.call_type_desc IS '通话类型描述';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.detail_call_type IS '呼叫类型';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.detail_call_type_desc IS '呼叫类型描述';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.ob_sip_cause IS '呼叫结果';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.sip_cause IS '呼叫情况';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.sip_cause_desc IS '呼叫情况描述';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.record_file IS '录音';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.tsi_file IS '客户彩铃录音';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.call_id IS 'CallID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.webrtc_call_id IS 'WebRTCCallID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.main_unique_id IS '通话ID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.unique_id IS '通话唯一ID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_detail.etl_tx_dt IS '';
|
||||
|
||||
COMMENT ON TABLE p12_sfull.S98_S_tr_cc_cdr_ob_detail IS '外呼记录详情';
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
delete from p10_sa.S98_S_tr_cc_cdr_ob_list
|
||||
;
|
||||
insert into p10_sa.S98_S_tr_cc_cdr_ob_list
|
||||
( customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_area
|
||||
, customer_province
|
||||
, customer_city
|
||||
, call_type
|
||||
, call_type_key
|
||||
, left_clid
|
||||
, left_clid_area
|
||||
, left_clid_province
|
||||
, left_clid_city
|
||||
, trunk_group_key
|
||||
, xnumber
|
||||
, xnumber_area
|
||||
, xnumber_province
|
||||
, xnumber_city
|
||||
, status
|
||||
, status_desc
|
||||
, tag_names
|
||||
, main_unique_id
|
||||
, request_unique_id
|
||||
, ob_sip_cause
|
||||
, on_hook_source
|
||||
, record_file
|
||||
, asr_record
|
||||
, evaluation
|
||||
, investigation_keys
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, rtc_uid
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, up_time
|
||||
, callee_ringing_time
|
||||
, bridge_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, total_duration
|
||||
, pre_ring_wait_duration
|
||||
, callee_ringing_duration
|
||||
, ob_wait_duration
|
||||
, task_id
|
||||
, task_name
|
||||
, task_inventory_id
|
||||
, exist_ticket
|
||||
, ticket_ids
|
||||
, exist_business
|
||||
, business_ids
|
||||
, user_field
|
||||
, exist_customer
|
||||
, customer_area_code
|
||||
, customer_post_code
|
||||
, customer_vip
|
||||
, enterprise_id
|
||||
, mark_data
|
||||
, type
|
||||
, etl_tx_dt )
|
||||
select
|
||||
customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_area
|
||||
, customer_province
|
||||
, customer_city
|
||||
, call_type
|
||||
, call_type_key
|
||||
, left_clid
|
||||
, left_clid_area
|
||||
, left_clid_province
|
||||
, left_clid_city
|
||||
, trunk_group_key
|
||||
, xnumber
|
||||
, xnumber_area
|
||||
, xnumber_province
|
||||
, xnumber_city
|
||||
, status
|
||||
, status_desc
|
||||
, tag_names
|
||||
, main_unique_id
|
||||
, request_unique_id
|
||||
, ob_sip_cause
|
||||
, on_hook_source
|
||||
, record_file
|
||||
, asr_record
|
||||
, evaluation
|
||||
, investigation_keys
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, rtc_uid
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, up_time
|
||||
, callee_ringing_time
|
||||
, bridge_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, total_duration
|
||||
, pre_ring_wait_duration
|
||||
, callee_ringing_duration
|
||||
, ob_wait_duration
|
||||
, task_id
|
||||
, task_name
|
||||
, task_inventory_id
|
||||
, exist_ticket
|
||||
, ticket_ids
|
||||
, exist_business
|
||||
, business_ids
|
||||
, user_field
|
||||
, exist_customer
|
||||
, customer_area_code
|
||||
, customer_post_code
|
||||
, customer_vip
|
||||
, enterprise_id
|
||||
, mark_data
|
||||
, type
|
||||
, etl_tx_dt
|
||||
from p00_tal.S98_S_tr_cc_cdr_ob_list
|
||||
;
|
||||
delete from p12_sfull.S98_S_tr_cc_cdr_ob_list
|
||||
;
|
||||
;
|
||||
insert into p12_sfull.S98_S_tr_cc_cdr_ob_list
|
||||
( customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_area
|
||||
, customer_province
|
||||
, customer_city
|
||||
, call_type
|
||||
, call_type_key
|
||||
, left_clid
|
||||
, left_clid_area
|
||||
, left_clid_province
|
||||
, left_clid_city
|
||||
, trunk_group_key
|
||||
, xnumber
|
||||
, xnumber_area
|
||||
, xnumber_province
|
||||
, xnumber_city
|
||||
, status
|
||||
, status_desc
|
||||
, tag_names
|
||||
, main_unique_id
|
||||
, request_unique_id
|
||||
, ob_sip_cause
|
||||
, on_hook_source
|
||||
, record_file
|
||||
, asr_record
|
||||
, evaluation
|
||||
, investigation_keys
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, rtc_uid
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, up_time
|
||||
, callee_ringing_time
|
||||
, bridge_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, total_duration
|
||||
, pre_ring_wait_duration
|
||||
, callee_ringing_duration
|
||||
, ob_wait_duration
|
||||
, task_id
|
||||
, task_name
|
||||
, task_inventory_id
|
||||
, exist_ticket
|
||||
, ticket_ids
|
||||
, exist_business
|
||||
, business_ids
|
||||
, user_field
|
||||
, exist_customer
|
||||
, customer_area_code
|
||||
, customer_post_code
|
||||
, customer_vip
|
||||
, enterprise_id
|
||||
, mark_data
|
||||
, type
|
||||
, etl_tx_dt )
|
||||
select
|
||||
customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_area
|
||||
, customer_province
|
||||
, customer_city
|
||||
, call_type
|
||||
, call_type_key
|
||||
, left_clid
|
||||
, left_clid_area
|
||||
, left_clid_province
|
||||
, left_clid_city
|
||||
, trunk_group_key
|
||||
, xnumber
|
||||
, xnumber_area
|
||||
, xnumber_province
|
||||
, xnumber_city
|
||||
, status
|
||||
, status_desc
|
||||
, tag_names
|
||||
, main_unique_id
|
||||
, request_unique_id
|
||||
, ob_sip_cause
|
||||
, on_hook_source
|
||||
, record_file
|
||||
, asr_record
|
||||
, evaluation
|
||||
, investigation_keys
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, rtc_uid
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, up_time
|
||||
, callee_ringing_time
|
||||
, bridge_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, total_duration
|
||||
, pre_ring_wait_duration
|
||||
, callee_ringing_duration
|
||||
, ob_wait_duration
|
||||
, task_id
|
||||
, task_name
|
||||
, task_inventory_id
|
||||
, exist_ticket
|
||||
, ticket_ids
|
||||
, exist_business
|
||||
, business_ids
|
||||
, user_field
|
||||
, exist_customer
|
||||
, customer_area_code
|
||||
, customer_post_code
|
||||
, customer_vip
|
||||
, enterprise_id
|
||||
, mark_data
|
||||
, type
|
||||
, etl_tx_dt
|
||||
from p10_sa.S98_S_tr_cc_cdr_ob_list
|
||||
;
|
||||
\q
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
CREATE FOREIGN TABLE if not exists p00_tal.S98_S_tr_cc_cdr_ob_list (
|
||||
customer_number TEXT
|
||||
, customer_number_encrypt TEXT
|
||||
, customer_area TEXT
|
||||
, customer_province TEXT
|
||||
, customer_city TEXT
|
||||
, call_type TEXT
|
||||
, call_type_key TEXT
|
||||
, left_clid TEXT
|
||||
, left_clid_area TEXT
|
||||
, left_clid_province TEXT
|
||||
, left_clid_city TEXT
|
||||
, trunk_group_key TEXT
|
||||
, xnumber TEXT
|
||||
, xnumber_area TEXT
|
||||
, xnumber_province TEXT
|
||||
, xnumber_city TEXT
|
||||
, status TEXT
|
||||
, status_desc TEXT
|
||||
, tag_names TEXT
|
||||
, main_unique_id TEXT
|
||||
, request_unique_id TEXT
|
||||
, ob_sip_cause TEXT
|
||||
, on_hook_source TEXT
|
||||
, record_file TEXT
|
||||
, asr_record TEXT
|
||||
, evaluation TEXT
|
||||
, investigation_keys TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, rtc_uid TEXT
|
||||
, cno TEXT
|
||||
, client_name TEXT
|
||||
, client_number TEXT
|
||||
, start_time TEXT
|
||||
, up_time TEXT
|
||||
, callee_ringing_time TEXT
|
||||
, bridge_time TEXT
|
||||
, end_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, total_duration TEXT
|
||||
, pre_ring_wait_duration TEXT
|
||||
, callee_ringing_duration TEXT
|
||||
, ob_wait_duration TEXT
|
||||
, task_id TEXT
|
||||
, task_name TEXT
|
||||
, task_inventory_id TEXT
|
||||
, exist_ticket TEXT
|
||||
, ticket_ids TEXT
|
||||
, exist_business TEXT
|
||||
, business_ids TEXT
|
||||
, user_field TEXT
|
||||
, exist_customer TEXT
|
||||
, customer_area_code TEXT
|
||||
, customer_post_code TEXT
|
||||
, customer_vip TEXT
|
||||
, enterprise_id TEXT
|
||||
, mark_data TEXT
|
||||
, type TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
)
|
||||
|
||||
|
||||
SERVER pgsql_server_S98_S OPTIONS(schema_name 'data_api', table_name 'tr_cc_cdr_ob_list' );
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,251 @@
|
|||
|
||||
create table if not exists p10_sa.S98_S_tr_cc_cdr_ob_list (
|
||||
customer_number TEXT
|
||||
, customer_number_encrypt TEXT
|
||||
, customer_area TEXT
|
||||
, customer_province TEXT
|
||||
, customer_city TEXT
|
||||
, call_type TEXT
|
||||
, call_type_key TEXT
|
||||
, left_clid TEXT
|
||||
, left_clid_area TEXT
|
||||
, left_clid_province TEXT
|
||||
, left_clid_city TEXT
|
||||
, trunk_group_key TEXT
|
||||
, xnumber TEXT
|
||||
, xnumber_area TEXT
|
||||
, xnumber_province TEXT
|
||||
, xnumber_city TEXT
|
||||
, status TEXT
|
||||
, status_desc TEXT
|
||||
, tag_names TEXT
|
||||
, main_unique_id TEXT
|
||||
, request_unique_id TEXT
|
||||
, ob_sip_cause TEXT
|
||||
, on_hook_source TEXT
|
||||
, record_file TEXT
|
||||
, asr_record TEXT
|
||||
, evaluation TEXT
|
||||
, investigation_keys TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, rtc_uid TEXT
|
||||
, cno TEXT
|
||||
, client_name TEXT
|
||||
, client_number TEXT
|
||||
, start_time TEXT
|
||||
, up_time TEXT
|
||||
, callee_ringing_time TEXT
|
||||
, bridge_time TEXT
|
||||
, end_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, total_duration TEXT
|
||||
, pre_ring_wait_duration TEXT
|
||||
, callee_ringing_duration TEXT
|
||||
, ob_wait_duration TEXT
|
||||
, task_id TEXT
|
||||
, task_name TEXT
|
||||
, task_inventory_id TEXT
|
||||
, exist_ticket TEXT
|
||||
, ticket_ids TEXT
|
||||
, exist_business TEXT
|
||||
, business_ids TEXT
|
||||
, user_field TEXT
|
||||
, exist_customer TEXT
|
||||
, customer_area_code TEXT
|
||||
, customer_post_code TEXT
|
||||
, customer_vip TEXT
|
||||
, enterprise_id TEXT
|
||||
, mark_data TEXT
|
||||
, type TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
) ;
|
||||
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.customer_number IS '客户号码';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.customer_number_encrypt IS '客户号码加密串';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.customer_area IS '客户地区,省份/城市';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.customer_province IS '客户号码省份';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.customer_city IS '客户号码城市';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.call_type IS '通话类型';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.call_type_key IS '通话类型Key值';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.left_clid IS '外显号码';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.left_clid_area IS '外显号码归属地区';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.left_clid_province IS '外显号码归属省份';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.left_clid_city IS '外显号码归属城市';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.trunk_group_key IS '中继组号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.xnumber IS '虚拟号码';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.xnumber_area IS '虚拟号码归属地区';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.xnumber_province IS '虚拟号码归属省份';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.xnumber_city IS '虚拟号码归属城市';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.status IS '接听状态值';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.status_desc IS '接听状态描述';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.tag_names IS '通话标签';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.main_unique_id IS '通话ID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.request_unique_id IS '通话唯一ID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.ob_sip_cause IS '呼叫结果';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.on_hook_source IS '挂断方';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.record_file IS '录音文件';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.asr_record IS '转写记录标识 ';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.evaluation IS '是否邀评';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.investigation_keys IS '满意度评价';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.call_id IS 'CallID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.webrtc_call_id IS 'WebRTCCallID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.rtc_uid IS 'RtcUid';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.cno IS '座席工号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.client_name IS '座席名称';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.client_number IS '座席电话';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.start_time IS '开始时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.up_time IS '座席接起时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.callee_ringing_time IS '客户响铃时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.bridge_time IS '客户接听时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.end_time IS '结束时间';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.bridge_duration IS '通话时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.total_duration IS '总时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.pre_ring_wait_duration IS '响铃前等待时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.callee_ringing_duration IS '客户响铃时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.ob_wait_duration IS '外呼等待时长';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.task_id IS '外呼任务id';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.task_name IS '外呼任务名称';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.task_inventory_id IS '外呼任务详情id';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.exist_ticket IS '是否存在工单';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.ticket_ids IS '工单id';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.exist_business IS '是否存在业务记录';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.business_ids IS '业务记录ID';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.user_field IS '自定义字段';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.exist_customer IS '是否存在客户资料';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.customer_area_code IS '客户号码区号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.customer_post_code IS '追加客户邮编';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.customer_vip IS '客户VIP标识';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.enterprise_id IS '企业号';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.mark_data IS '备注';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.type IS 'cdrObAgent';
|
||||
COMMENT ON COLUMN p10_sa.S98_S_tr_cc_cdr_ob_list.etl_tx_dt IS '';
|
||||
|
||||
COMMENT ON TABLE p10_sa.S98_S_tr_cc_cdr_ob_list IS '外呼记录列表';
|
||||
|
||||
|
||||
|
||||
create table if not exists p12_sfull.S98_S_tr_cc_cdr_ob_list (
|
||||
customer_number TEXT
|
||||
, customer_number_encrypt TEXT
|
||||
, customer_area TEXT
|
||||
, customer_province TEXT
|
||||
, customer_city TEXT
|
||||
, call_type TEXT
|
||||
, call_type_key TEXT
|
||||
, left_clid TEXT
|
||||
, left_clid_area TEXT
|
||||
, left_clid_province TEXT
|
||||
, left_clid_city TEXT
|
||||
, trunk_group_key TEXT
|
||||
, xnumber TEXT
|
||||
, xnumber_area TEXT
|
||||
, xnumber_province TEXT
|
||||
, xnumber_city TEXT
|
||||
, status TEXT
|
||||
, status_desc TEXT
|
||||
, tag_names TEXT
|
||||
, main_unique_id TEXT
|
||||
, request_unique_id TEXT
|
||||
, ob_sip_cause TEXT
|
||||
, on_hook_source TEXT
|
||||
, record_file TEXT
|
||||
, asr_record TEXT
|
||||
, evaluation TEXT
|
||||
, investigation_keys TEXT
|
||||
, call_id TEXT
|
||||
, webrtc_call_id TEXT
|
||||
, rtc_uid TEXT
|
||||
, cno TEXT
|
||||
, client_name TEXT
|
||||
, client_number TEXT
|
||||
, start_time TEXT
|
||||
, up_time TEXT
|
||||
, callee_ringing_time TEXT
|
||||
, bridge_time TEXT
|
||||
, end_time TEXT
|
||||
, bridge_duration TEXT
|
||||
, total_duration TEXT
|
||||
, pre_ring_wait_duration TEXT
|
||||
, callee_ringing_duration TEXT
|
||||
, ob_wait_duration TEXT
|
||||
, task_id TEXT
|
||||
, task_name TEXT
|
||||
, task_inventory_id TEXT
|
||||
, exist_ticket TEXT
|
||||
, ticket_ids TEXT
|
||||
, exist_business TEXT
|
||||
, business_ids TEXT
|
||||
, user_field TEXT
|
||||
, exist_customer TEXT
|
||||
, customer_area_code TEXT
|
||||
, customer_post_code TEXT
|
||||
, customer_vip TEXT
|
||||
, enterprise_id TEXT
|
||||
, mark_data TEXT
|
||||
, type TEXT
|
||||
, etl_tx_dt TIMESTAMP
|
||||
) ;
|
||||
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.customer_number IS '客户号码';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.customer_number_encrypt IS '客户号码加密串';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.customer_area IS '客户地区,省份/城市';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.customer_province IS '客户号码省份';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.customer_city IS '客户号码城市';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.call_type IS '通话类型';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.call_type_key IS '通话类型Key值';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.left_clid IS '外显号码';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.left_clid_area IS '外显号码归属地区';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.left_clid_province IS '外显号码归属省份';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.left_clid_city IS '外显号码归属城市';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.trunk_group_key IS '中继组号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.xnumber IS '虚拟号码';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.xnumber_area IS '虚拟号码归属地区';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.xnumber_province IS '虚拟号码归属省份';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.xnumber_city IS '虚拟号码归属城市';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.status IS '接听状态值';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.status_desc IS '接听状态描述';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.tag_names IS '通话标签';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.main_unique_id IS '通话ID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.request_unique_id IS '通话唯一ID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.ob_sip_cause IS '呼叫结果';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.on_hook_source IS '挂断方';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.record_file IS '录音文件';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.asr_record IS '转写记录标识 ';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.evaluation IS '是否邀评';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.investigation_keys IS '满意度评价';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.call_id IS 'CallID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.webrtc_call_id IS 'WebRTCCallID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.rtc_uid IS 'RtcUid';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.cno IS '座席工号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.client_name IS '座席名称';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.client_number IS '座席电话';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.start_time IS '开始时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.up_time IS '座席接起时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.callee_ringing_time IS '客户响铃时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.bridge_time IS '客户接听时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.end_time IS '结束时间';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.bridge_duration IS '通话时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.total_duration IS '总时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.pre_ring_wait_duration IS '响铃前等待时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.callee_ringing_duration IS '客户响铃时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.ob_wait_duration IS '外呼等待时长';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.task_id IS '外呼任务id';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.task_name IS '外呼任务名称';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.task_inventory_id IS '外呼任务详情id';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.exist_ticket IS '是否存在工单';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.ticket_ids IS '工单id';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.exist_business IS '是否存在业务记录';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.business_ids IS '业务记录ID';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.user_field IS '自定义字段';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.exist_customer IS '是否存在客户资料';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.customer_area_code IS '客户号码区号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.customer_post_code IS '追加客户邮编';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.customer_vip IS '客户VIP标识';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.enterprise_id IS '企业号';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.mark_data IS '备注';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.type IS 'cdrObAgent';
|
||||
COMMENT ON COLUMN p12_sfull.S98_S_tr_cc_cdr_ob_list.etl_tx_dt IS '';
|
||||
|
||||
COMMENT ON TABLE p12_sfull.S98_S_tr_cc_cdr_ob_list IS '外呼记录列表';
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
#!/usr/bin/python
|
||||
# -*- encoding=utf-8 -*-
|
||||
from airflow import DAG
|
||||
from datetime import datetime, timedelta
|
||||
from airflow.contrib.hooks.ssh_hook import SSHHook
|
||||
from airflow.contrib.operators.ssh_operator import SSHOperator
|
||||
from airflow.sensors.external_task_sensor import ExternalTaskSensor
|
||||
import json
|
||||
|
||||
from airflow.operators.trigger_dagrun import TriggerDagRunOperator
|
||||
from airflow.operators.email_operator import EmailOperator
|
||||
from airflow.utils.trigger_rule import TriggerRule
|
||||
|
||||
|
||||
sshHook = SSHHook(ssh_conn_id ='ssh_air')
|
||||
default_args = {
|
||||
'owner': 'info@idgvalue.com',
|
||||
'email_on_failure': True,
|
||||
'email_on_retry':True,
|
||||
'start_date': datetime(2024, 1, 1),
|
||||
'depends_on_past': False,
|
||||
'retries': 6,
|
||||
'retry_delay': timedelta(minutes=10),
|
||||
}
|
||||
|
||||
dag = DAG('wf_dag_smart_ccc_cdr', default_args=default_args,
|
||||
schedule_interval="0 0-23/1 * * *",
|
||||
catchup=False,
|
||||
dagrun_timeout=timedelta(minutes=160),
|
||||
max_active_runs=3)
|
||||
|
||||
task_failed = EmailOperator (
|
||||
dag=dag,
|
||||
trigger_rule=TriggerRule.ONE_FAILED,
|
||||
task_id="task_failed",
|
||||
to=["info@idgvalue.com"],
|
||||
cc=[""],
|
||||
subject="smart_ccc_cdr_failed",
|
||||
html_content='<h3>您好,smart_ccc_cdr作业失败,请及时处理" </h3>')
|
||||
|
||||
cc_cdr_ib_list_feign = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='cc_cdr_ib_list_feign',
|
||||
command='python3 /data/airflow/etl/API/cc_cdr_ib_list_feign.py',
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
cc_cdr_ib_list_load = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='cc_cdr_ib_list_load',
|
||||
command='/data/airflow/etl/API/run_psql.sh {{ ds_nodash }} {{params.my_param }}',
|
||||
params={'my_param':"cc_cdr_ib_list_load"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
cc_cdr_ib_list_feign >> cc_cdr_ib_list_load
|
||||
|
||||
cc_cdr_ob_list_feign = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='cc_cdr_ob_list_feign',
|
||||
command='python3 /data/airflow/etl/API/cc_cdr_ob_list_feign.py',
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
cc_cdr_ob_list_load = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='cc_cdr_ob_list_load',
|
||||
command='/data/airflow/etl/API/run_psql.sh {{ ds_nodash }} {{params.my_param }}',
|
||||
params={'my_param':"cc_cdr_ob_list_load"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
cc_cdr_ob_list_feign >> cc_cdr_ob_list_load
|
||||
|
||||
cc_cdr_ib_agent_list_feign = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='cc_cdr_ib_agent_list_feign',
|
||||
command='python3 /data/airflow/etl/API/cc_cdr_ib_agent_list_feign.py',
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
cc_cdr_ib_agent_list_load = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='cc_cdr_ib_agent_list_load',
|
||||
command='/data/airflow/etl/API/run_psql.sh {{ ds_nodash }} {{params.my_param }}',
|
||||
params={'my_param':"cc_cdr_ib_agent_list_load"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
cc_cdr_ib_agent_list_feign >> cc_cdr_ib_agent_list_load
|
||||
|
||||
tr_cc_cdr_ib_agent_list_9092 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='tr_cc_cdr_ib_agent_list_9092',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_tr_cc_cdr_ib_agent_list"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
tr_cc_cdr_ib_list_9521 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='tr_cc_cdr_ib_list_9521',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_tr_cc_cdr_ib_list"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
tr_cc_cdr_ob_detail_5097 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='tr_cc_cdr_ob_detail_5097',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_tr_cc_cdr_ob_detail"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
tr_cc_cdr_ob_list_4070 = SSHOperator(
|
||||
ssh_hook=sshHook,
|
||||
task_id='tr_cc_cdr_ob_list_4070',
|
||||
command='/data/airflow/etl/SA/run_sa.sh {{ ds_nodash }} {{ params.my_param }} >>/data/airflow/logs/run_psql_{{ds_nodash}}.log 2>&1 ',
|
||||
params={'my_param':"S98_S_tr_cc_cdr_ob_list"},
|
||||
depends_on_past=False,
|
||||
retries=3,
|
||||
dag=dag)
|
||||
|
||||
cc_cdr_ib_agent_list_load >> tr_cc_cdr_ib_agent_list_9092
|
||||
cc_cdr_ib_list_load >> tr_cc_cdr_ib_list_9521
|
||||
cc_cdr_ob_list_load >> tr_cc_cdr_ob_list_4070
|
||||
cc_cdr_ob_list_load >> tr_cc_cdr_ob_detail_5097
|
||||
|
||||
tr_cc_cdr_ob_detail_5097 >> task_failed
|
||||
tr_cc_cdr_ob_list_4070 >> task_failed
|
||||
tr_cc_cdr_ib_list_9521 >> task_failed
|
||||
tr_cc_cdr_ib_agent_list_9092 >> task_failed
|
|
@ -0,0 +1,208 @@
|
|||
# coding: utf-8
|
||||
import requests
|
||||
import json
|
||||
import psycopg2
|
||||
import uuid
|
||||
import datetime
|
||||
import time
|
||||
import hashlib
|
||||
import time
|
||||
import hmac
|
||||
import base64
|
||||
import urllib.parse
|
||||
import hashlib
|
||||
from collections import OrderedDict
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
#全局变量,便于参数使用的预设值
|
||||
current_date = datetime.date.today() # 获取当前日期
|
||||
previous_date = current_date - datetime.timedelta(days=1) # 获取前一天日期
|
||||
formatted_current_date = current_date.strftime("%Y-%m-%dT%H:%M:%SZ") # 获取当前日期 - 标准化
|
||||
formatted_previous_date = previous_date.strftime("%Y-%m-%dT%H:%M:%SZ") # 获取前一天日期 - 标准化
|
||||
timestamp = time.time() # 为Unix time,即从"1970-01-01 00:00:00"至今的秒数;
|
||||
sign_version = 'v2' # 签名版本号,固定值v2
|
||||
nonce = str(uuid.uuid4())
|
||||
current_time_utc =( datetime.datetime.now() - datetime.timedelta(hours=8)).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
formatted2_current_date = current_date.strftime("%Y-%m-%d %H:%M:%S") # 获取当前日期 - 标准化
|
||||
formatted2_previous_date = previous_date.strftime("%Y-%m-%d %H:%M:%S") # 获取前一天日期 - 标准化
|
||||
|
||||
def formatted2_previous_hour(h):
|
||||
if h==0:
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
start_of_current_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0)
|
||||
# 减去一个小时,得到前一个小时的开始时间
|
||||
start_of_previous_hour = start_of_current_hour - datetime.timedelta(hours=h)
|
||||
return start_of_previous_hour.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
def previous_hour_timestamp(h):
|
||||
if h==0:
|
||||
return int(time.time())
|
||||
start_of_current_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0)
|
||||
# 减去一个小时,得到前一个小时的开始时间
|
||||
start_of_previous_hour = start_of_current_hour - datetime.timedelta(hours=h)
|
||||
return int(start_of_previous_hour.timestamp())
|
||||
|
||||
#计算签名
|
||||
def generate_signature(str, private_key):
|
||||
signature = hmac.new(private_key.encode(), (str).encode(), hashlib.sha1)
|
||||
signature_b64 = base64.b64encode(signature.digest()).decode()
|
||||
return signature_b64
|
||||
|
||||
#构建查询链接
|
||||
def build_query_string(params):
|
||||
# 使用OrderedDict来保持排序
|
||||
sorted_params = OrderedDict(sorted(params.items()))
|
||||
|
||||
# 拼接属性名和属性值,并使用&连接
|
||||
query_string = '&'.join('{}={}'.format(
|
||||
urllib.parse.quote_plus(k),
|
||||
urllib.parse.quote_plus(str(v))
|
||||
) for k, v in sorted_params.items())
|
||||
return query_string
|
||||
|
||||
#计算签名,get请求
|
||||
def request_data_signature_get():
|
||||
print(f'开始请求客服来电记录数据')
|
||||
url='https://api-bj.clink.cn/cc/list_cdr_ob'
|
||||
param={'Timestamp':current_time_utc,'Expires':86400,'startTime':previous_hour_timestamp(1),'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
||||
print(f'param: {param}')
|
||||
url_path = build_query_string(param)
|
||||
url_param = url_path
|
||||
print(f'url_param: {url_param}')
|
||||
url_param = f'GETapi-bj.clink.cn/cc/list_cdr_ob?{url_param}'
|
||||
print(f'待计算字符串: {url_param}')
|
||||
signature= generate_signature(url_param,'5g027B6w06630Y5240c1')
|
||||
print(f'计算签名: {signature}')
|
||||
print(f'编码后签名: {urllib.parse.quote_plus(signature)}')
|
||||
url = f'{url}?{url_path}&Signature={urllib.parse.quote_plus(signature)}'
|
||||
print(f'url: {url}')
|
||||
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
resText = dataReqL.text
|
||||
i = 0
|
||||
while 'error' in resText and i < 5:
|
||||
print(f'请求客服来电记录失败,再次请求第{i+1}次')
|
||||
time.sleep(1)
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
resText = dataReqL.text
|
||||
i = i + 1
|
||||
resD=json.loads(resText)
|
||||
print(f'请求客服来电记录结束')
|
||||
return resD
|
||||
|
||||
def load_data_to_db(dataList):
|
||||
conn = psycopg2.connect(database="dataops_db", user="dbuser_dops", password="MIgTi3jA",host="172.17.0.8", port="5432")
|
||||
print('数据库连接成功')
|
||||
dataId=str(uuid.uuid4())
|
||||
total=len(dataList)
|
||||
print('临时id:'+dataId)
|
||||
json_object = json.dumps(dataList)
|
||||
cur=conn.cursor()
|
||||
sql="update data_api.api_data set is_loaded = '1' where api_id = '3f5c5267f3ec40899b8b11cd592dda25';INSERT INTO data_api.api_data (id,api_id,data,total_num,is_loaded,status,request_tm,execute_tm,remark) values (%s,%s,%s,%s,'0','0',current_timestamp(0),current_timestamp(0),'')"
|
||||
cur.execute(sql,[dataId,'3f5c5267f3ec40899b8b11cd592dda25', json_object, total])
|
||||
conn.commit()
|
||||
cur.close()
|
||||
conn.close()
|
||||
print('加载数据结束:cc_cdr_ob_list:查询外呼记录列表')
|
||||
|
||||
|
||||
#计算签名,get请求
|
||||
def request_detail_signature_get(id):
|
||||
print(f'开始请求外呼详情:{id}')
|
||||
url='https://api-bj.clink.cn/cc/cdr_ob_details'
|
||||
param={'mainUniqueId':id,'Timestamp':current_time_utc,'Expires':86400,'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
||||
print(f'param: {param}')
|
||||
url_path = build_query_string(param)
|
||||
url_param = url_path
|
||||
print(f'url_param: {url_param}')
|
||||
url_param = f'GETapi-bj.clink.cn/cc/cdr_ob_details?{url_param}'
|
||||
print(f'待计算字符串: {url_param}')
|
||||
signature= generate_signature(url_param,'5g027B6w06630Y5240c1')
|
||||
print(f'计算签名: {signature}')
|
||||
print(f'编码后签名: {urllib.parse.quote_plus(signature)}')
|
||||
url = f'{url}?{url_path}&Signature={urllib.parse.quote_plus(signature)}'
|
||||
print(f'url: {url}')
|
||||
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
resText = dataReqL.text
|
||||
i = 0
|
||||
while 'error' in resText and i < 5:
|
||||
print(f'请求客服来电记录失败,再次请求第{i+1}次')
|
||||
time.sleep(1)
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
resText = dataReqL.text
|
||||
i = i + 1
|
||||
resD=json.loads(resText)
|
||||
print(f'请求外呼详情:{id}结束')
|
||||
return resD
|
||||
|
||||
|
||||
def load_detail_data_to_db(ids, dataList):
|
||||
conn = psycopg2.connect(database="dataops_db", user="dbuser_dops", password="MIgTi3jA",host="172.17.0.8", port="5432")
|
||||
print('数据库连接成功')
|
||||
dataId=str(uuid.uuid4())
|
||||
total=len(dataList)
|
||||
print('临时id:'+dataId)
|
||||
json_object = json.dumps(dataList)
|
||||
idstr = ','.join(ids)
|
||||
cur=conn.cursor()
|
||||
sql="update data_api.cc_details_ids_exp set is_loaded = '1' where api_id = '7a38de24858a40ed9837f61ca7f80b08' and id in (%s); INSERT INTO data_api.cc_cdr_ob_details (id,api_id,data,total_num,is_loaded,status,request_tm,execute_tm,remark) values (%s,%s,%s,%s,'0','0',current_timestamp(0),current_timestamp(0),'')"
|
||||
cur.execute(sql,[idstr,dataId,'7a38de24858a40ed9837f61ca7f80b08', json_object, total])
|
||||
conn.commit()
|
||||
cur.close()
|
||||
conn.close()
|
||||
print('加载数据结束:cdr_ob_detail:获取外呼详情')
|
||||
|
||||
def load_detail_exp_to_db(id):
|
||||
try:
|
||||
print(f'添加查询外呼详情异常记录:{id}')
|
||||
conn = psycopg2.connect(database="dataops_db", user="dbuser_dops", password="MIgTi3jA",host="172.17.0.8", port="5432")
|
||||
print('数据库连接成功')
|
||||
dataId=str(uuid.uuid4())
|
||||
print('临时id:'+dataId)
|
||||
cur=conn.cursor()
|
||||
sql=" INSERT INTO data_api.cc_details_ids_exp (id,api_id,is_loaded,status,request_tm,execute_tm,remark) values (%s,%s,'0','0',current_timestamp(0),current_timestamp(0),'')"
|
||||
cur.execute(sql,[id, '7a38de24858a40ed9837f61ca7f80b08'])
|
||||
conn.commit()
|
||||
cur.close()
|
||||
conn.close()
|
||||
print(f'添加查询工单异常记录:{id} 结束')
|
||||
except Exception as e:
|
||||
print(f'添加查询工单异常记录:{id}失败, 错误信息:{e}')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f'{formatted2_previous_hour(0)}开始请求外呼记录列表')
|
||||
resL = request_data_signature_post()
|
||||
print(resL)
|
||||
if 'error' in resL:
|
||||
error = resL['error']
|
||||
print(f'请求外呼记录列表失败,失败原因:{error}')
|
||||
else:
|
||||
dataList = resL['cdrOb']
|
||||
load_data_to_db(dataList)
|
||||
detailDataList = []
|
||||
ids = []
|
||||
for data in dataList:
|
||||
try:
|
||||
id = data['id']
|
||||
resD = request_detail_signature_get(id)
|
||||
#print(f"请求工单详情结束")
|
||||
if 'cdrObDetails' in resD:
|
||||
ids.append(id)
|
||||
dataList = resD['cdrObDetails']
|
||||
# detailDataList.append(dataList)
|
||||
detailDataList = detailDataList + dataList
|
||||
else:
|
||||
error = resD['error']
|
||||
print(f"请求外呼详情(id:{id})失败,错误信息:{error}")
|
||||
load_detail_exp_to_db(id)
|
||||
except Exception as e:
|
||||
print(f'请求外呼详情(id:{id})异常, )异常信息:{e}')
|
||||
load_detail_exp_to_db(data['id'])
|
||||
if len(ids) > 0:
|
||||
ids_str = [str(item) for item in ids]
|
||||
load_detail_data_to_db(ids_str,detailDataList)
|
||||
print(f'{formatted2_previous_hour(0)}请求外呼记录结束')
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
DELETE FROM data_api.tr_cc_cdr_ob_list;
|
||||
|
||||
insert into data_api.tr_cc_cdr_ob_list (
|
||||
customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_area
|
||||
, customer_province
|
||||
, customer_city
|
||||
, call_type
|
||||
, call_type_key
|
||||
, left_clid
|
||||
, left_clid_area
|
||||
, left_clid_province
|
||||
, left_clid_city
|
||||
, trunk_group_key
|
||||
, xnumber
|
||||
, xnumber_area
|
||||
, xnumber_province
|
||||
, xnumber_city
|
||||
, status
|
||||
, status_desc
|
||||
, tag_names
|
||||
, main_unique_id
|
||||
, request_unique_id
|
||||
, ob_sip_cause
|
||||
, on_hook_source
|
||||
, record_file
|
||||
, asr_record
|
||||
, evaluation
|
||||
, investigation_keys
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, rtc_uid
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, up_time
|
||||
, callee_ringing_time
|
||||
, bridge_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, total_duration
|
||||
, pre_ring_wait_duration
|
||||
, callee_ringing_duration
|
||||
, ob_wait_duration
|
||||
, task_id
|
||||
, task_name
|
||||
, task_inventory_id
|
||||
, exist_ticket
|
||||
, ticket_ids
|
||||
, exist_business
|
||||
, business_ids
|
||||
, user_field
|
||||
, exist_customer
|
||||
, customer_area_code
|
||||
, customer_post_code
|
||||
, customer_vip
|
||||
, enterprise_id
|
||||
, mark_data
|
||||
, type
|
||||
,etl_tx_dt
|
||||
)
|
||||
select
|
||||
case when trim(both from customer_number)='' then null else customer_number::text end customer_number
|
||||
, case when trim(both from customer_number_encrypt)='' then null else customer_number_encrypt::text end customer_number_encrypt
|
||||
, case when trim(both from customer_area)='' then null else customer_area::text end customer_area
|
||||
, case when trim(both from customer_province)='' then null else customer_province::text end customer_province
|
||||
, case when trim(both from customer_city)='' then null else customer_city::text end customer_city
|
||||
, case when trim(both from call_type)='' then null else call_type::text end call_type
|
||||
, case when trim(both from call_type_key)='' then null else call_type_key::text end call_type_key
|
||||
, case when trim(both from left_clid)='' then null else left_clid::text end left_clid
|
||||
, case when trim(both from left_clid_area)='' then null else left_clid_area::text end left_clid_area
|
||||
, case when trim(both from left_clid_province)='' then null else left_clid_province::text end left_clid_province
|
||||
, case when trim(both from left_clid_city)='' then null else left_clid_city::text end left_clid_city
|
||||
, case when trim(both from trunk_group_key)='' then null else trunk_group_key::text end trunk_group_key
|
||||
, case when trim(both from xnumber)='' then null else xnumber::text end xnumber
|
||||
, case when trim(both from xnumber_area)='' then null else xnumber_area::text end xnumber_area
|
||||
, case when trim(both from xnumber_province)='' then null else xnumber_province::text end xnumber_province
|
||||
, case when trim(both from xnumber_city)='' then null else xnumber_city::text end xnumber_city
|
||||
, case when trim(both from status)='' then null else status::text end status
|
||||
, case when trim(both from status_desc)='' then null else status_desc::text end status_desc
|
||||
, case when trim(both from tag_names)='' then null else tag_names::text end tag_names
|
||||
, case when trim(both from main_unique_id)='' then null else main_unique_id::text end main_unique_id
|
||||
, case when trim(both from request_unique_id)='' then null else request_unique_id::text end request_unique_id
|
||||
, case when trim(both from ob_sip_cause)='' then null else ob_sip_cause::text end ob_sip_cause
|
||||
, case when trim(both from on_hook_source)='' then null else on_hook_source::text end on_hook_source
|
||||
, case when trim(both from record_file)='' then null else record_file::text end record_file
|
||||
, case when trim(both from asr_record)='' then null else asr_record::text end asr_record
|
||||
, case when trim(both from evaluation)='' then null else evaluation::text end evaluation
|
||||
, case when trim(both from investigation_keys)='' then null else investigation_keys::text end investigation_keys
|
||||
, case when trim(both from call_id)='' then null else call_id::text end call_id
|
||||
, case when trim(both from webrtc_call_id)='' then null else webrtc_call_id::text end webrtc_call_id
|
||||
, case when trim(both from rtc_uid)='' then null else rtc_uid::text end rtc_uid
|
||||
, case when trim(both from cno)='' then null else cno::text end cno
|
||||
, case when trim(both from client_name)='' then null else client_name::text end client_name
|
||||
, case when trim(both from client_number)='' then null else client_number::text end client_number
|
||||
, case when trim(both from start_time)='' then null else start_time::text end start_time
|
||||
, case when trim(both from up_time)='' then null else up_time::text end up_time
|
||||
, case when trim(both from callee_ringing_time)='' then null else callee_ringing_time::text end callee_ringing_time
|
||||
, case when trim(both from bridge_time)='' then null else bridge_time::text end bridge_time
|
||||
, case when trim(both from end_time)='' then null else end_time::text end end_time
|
||||
, case when trim(both from bridge_duration)='' then null else bridge_duration::text end bridge_duration
|
||||
, case when trim(both from total_duration)='' then null else total_duration::text end total_duration
|
||||
, case when trim(both from pre_ring_wait_duration)='' then null else pre_ring_wait_duration::text end pre_ring_wait_duration
|
||||
, case when trim(both from callee_ringing_duration)='' then null else callee_ringing_duration::text end callee_ringing_duration
|
||||
, case when trim(both from ob_wait_duration)='' then null else ob_wait_duration::text end ob_wait_duration
|
||||
, case when trim(both from task_id)='' then null else task_id::text end task_id
|
||||
, case when trim(both from task_name)='' then null else task_name::text end task_name
|
||||
, case when trim(both from task_inventory_id)='' then null else task_inventory_id::text end task_inventory_id
|
||||
, case when trim(both from exist_ticket)='' then null else exist_ticket::text end exist_ticket
|
||||
, case when trim(both from ticket_ids)='' then null else ticket_ids::text end ticket_ids
|
||||
, case when trim(both from exist_business)='' then null else exist_business::text end exist_business
|
||||
, case when trim(both from business_ids)='' then null else business_ids::text end business_ids
|
||||
, case when trim(both from user_field)='' then null else user_field::text end user_field
|
||||
, case when trim(both from exist_customer)='' then null else exist_customer::text end exist_customer
|
||||
, case when trim(both from customer_area_code)='' then null else customer_area_code::text end customer_area_code
|
||||
, case when trim(both from customer_post_code)='' then null else customer_post_code::text end customer_post_code
|
||||
, case when trim(both from customer_vip)='' then null else customer_vip::text end customer_vip
|
||||
, case when trim(both from enterprise_id)='' then null else enterprise_id::text end enterprise_id
|
||||
, case when trim(both from mark_data)='' then null else mark_data::text end mark_data
|
||||
, case when trim(both from type)='' then null else type::text end type
|
||||
,etl_tx_dt
|
||||
from (
|
||||
select
|
||||
(json_array_elements(data::json)::json->>'customerNumber') customer_number
|
||||
, (json_array_elements(data::json)::json->>'customerNumberEncrypt') customer_number_encrypt
|
||||
, (json_array_elements(data::json)::json->>'customerArea') customer_area
|
||||
, (json_array_elements(data::json)::json->>'customerProvince') customer_province
|
||||
, (json_array_elements(data::json)::json->>'customerCity') customer_city
|
||||
, (json_array_elements(data::json)::json->>'callType') call_type
|
||||
, (json_array_elements(data::json)::json->>'callTypeKey') call_type_key
|
||||
, (json_array_elements(data::json)::json->>'leftClid') left_clid
|
||||
, (json_array_elements(data::json)::json->>'leftClidArea') left_clid_area
|
||||
, (json_array_elements(data::json)::json->>'leftClidProvince') left_clid_province
|
||||
, (json_array_elements(data::json)::json->>'leftClidCity') left_clid_city
|
||||
, (json_array_elements(data::json)::json->>'trunkGroupKey') trunk_group_key
|
||||
, (json_array_elements(data::json)::json->>'xnumber') xnumber
|
||||
, (json_array_elements(data::json)::json->>'xnumberArea') xnumber_area
|
||||
, (json_array_elements(data::json)::json->>'xnumberProvince') xnumber_province
|
||||
, (json_array_elements(data::json)::json->>'xnumberCity') xnumber_city
|
||||
, (json_array_elements(data::json)::json->>'status') status
|
||||
, (json_array_elements(data::json)::json->>'statusDesc') status_desc
|
||||
, (json_array_elements(data::json)::json->>'tagNames') tag_names
|
||||
, (json_array_elements(data::json)::json->>'mainUniqueId') main_unique_id
|
||||
, (json_array_elements(data::json)::json->>'requestUniqueId') request_unique_id
|
||||
, (json_array_elements(data::json)::json->>'obSipCause') ob_sip_cause
|
||||
, (json_array_elements(data::json)::json->>'onHookSource') on_hook_source
|
||||
, (json_array_elements(data::json)::json->>'recordFile') record_file
|
||||
, (json_array_elements(data::json)::json->>'asrRecord') asr_record
|
||||
, (json_array_elements(data::json)::json->>'evaluation') evaluation
|
||||
, (json_array_elements(data::json)::json->>'investigationKeys') investigation_keys
|
||||
, (json_array_elements(data::json)::json->>'callId') call_id
|
||||
, (json_array_elements(data::json)::json->>'webrtcCallId') webrtc_call_id
|
||||
, (json_array_elements(data::json)::json->>'rtcUid') rtc_uid
|
||||
, (json_array_elements(data::json)::json->>'cno') cno
|
||||
, (json_array_elements(data::json)::json->>'clientName') client_name
|
||||
, (json_array_elements(data::json)::json->>'clientNumber') client_number
|
||||
, (json_array_elements(data::json)::json->>'startTime') start_time
|
||||
, (json_array_elements(data::json)::json->>'upTime') up_time
|
||||
, (json_array_elements(data::json)::json->>'calleeRingingTime') callee_ringing_time
|
||||
, (json_array_elements(data::json)::json->>'bridgeTime') bridge_time
|
||||
, (json_array_elements(data::json)::json->>'endTime') end_time
|
||||
, (json_array_elements(data::json)::json->>'bridgeDuration') bridge_duration
|
||||
, (json_array_elements(data::json)::json->>'totalDuration') total_duration
|
||||
, (json_array_elements(data::json)::json->>'preRingWaitDuration') pre_ring_wait_duration
|
||||
, (json_array_elements(data::json)::json->>'calleeRingingDuration') callee_ringing_duration
|
||||
, (json_array_elements(data::json)::json->>'obWaitDuration') ob_wait_duration
|
||||
, (json_array_elements(data::json)::json->>'taskId') task_id
|
||||
, (json_array_elements(data::json)::json->>'taskName') task_name
|
||||
, (json_array_elements(data::json)::json->>'taskInventoryId') task_inventory_id
|
||||
, (json_array_elements(data::json)::json->>'existTicket') exist_ticket
|
||||
, (json_array_elements(data::json)::json->>'ticketIds') ticket_ids
|
||||
, (json_array_elements(data::json)::json->>'existBusiness') exist_business
|
||||
, (json_array_elements(data::json)::json->>'businessIds') business_ids
|
||||
, (json_array_elements(data::json)::json->>'userField') user_field
|
||||
, (json_array_elements(data::json)::json->>'existCustomer') exist_customer
|
||||
, (json_array_elements(data::json)::json->>'customerAreaCode') customer_area_code
|
||||
, (json_array_elements(data::json)::json->>'customerPostCode') customer_post_code
|
||||
, (json_array_elements(data::json)::json->>'customerVip') customer_vip
|
||||
, (json_array_elements(data::json)::json->>'enterpriseId') enterprise_id
|
||||
, (json_array_elements(data::json)::json->>'markData') mark_data
|
||||
, (json_array_elements(data::json)::json->>'type') type
|
||||
,CURRENT_TIMESTAMP(0) etl_tx_dt
|
||||
from (select * from data_api.api_data
|
||||
WHERE api_id='3f5c5267f3ec40899b8b11cd592dda25' and is_loaded = '0' order by request_tm desc limit 1) p )p;
|
||||
|
||||
update data_api.api_data
|
||||
set is_loaded = '1' ,
|
||||
status = '1',
|
||||
request_tm = current_timestamp(0)
|
||||
where api_id='3f5c5267f3ec40899b8b11cd592dda25';
|
||||
\q
|
|
@ -0,0 +1,121 @@
|
|||
# coding: utf-8
|
||||
import requests
|
||||
import json
|
||||
import psycopg2
|
||||
import uuid
|
||||
import datetime
|
||||
import time
|
||||
import hashlib
|
||||
import time
|
||||
import hmac
|
||||
import base64
|
||||
import urllib.parse
|
||||
import hashlib
|
||||
from collections import OrderedDict
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
#全局变量,便于参数使用的预设值
|
||||
current_date = datetime.date.today() # 获取当前日期
|
||||
previous_date = current_date - datetime.timedelta(days=1) # 获取前一天日期
|
||||
formatted_current_date = current_date.strftime("%Y-%m-%dT%H:%M:%SZ") # 获取当前日期 - 标准化
|
||||
formatted_previous_date = previous_date.strftime("%Y-%m-%dT%H:%M:%SZ") # 获取前一天日期 - 标准化
|
||||
timestamp = time.time() # 为Unix time,即从"1970-01-01 00:00:00"至今的秒数;
|
||||
sign_version = 'v2' # 签名版本号,固定值v2
|
||||
nonce = str(uuid.uuid4())
|
||||
current_time_utc =( datetime.datetime.now() - datetime.timedelta(hours=8)).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
formatted2_current_date = current_date.strftime("%Y-%m-%d %H:%M:%S") # 获取当前日期 - 标准化
|
||||
formatted2_previous_date = previous_date.strftime("%Y-%m-%d %H:%M:%S") # 获取前一天日期 - 标准化
|
||||
|
||||
def formatted2_previous_hour(h):
|
||||
if h==0:
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
start_of_current_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0)
|
||||
# 减去一个小时,得到前一个小时的开始时间
|
||||
start_of_previous_hour = start_of_current_hour - datetime.timedelta(hours=h)
|
||||
return start_of_previous_hour.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
def previous_hour_timestamp(h):
|
||||
if h==0:
|
||||
return int(time.time())
|
||||
start_of_current_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0)
|
||||
# 减去一个小时,得到前一个小时的开始时间
|
||||
start_of_previous_hour = start_of_current_hour - datetime.timedelta(hours=h)
|
||||
return int(start_of_previous_hour.timestamp())
|
||||
|
||||
#计算签名
|
||||
def generate_signature(str, private_key):
|
||||
signature = hmac.new(private_key.encode(), (str).encode(), hashlib.sha1)
|
||||
signature_b64 = base64.b64encode(signature.digest()).decode()
|
||||
return signature_b64
|
||||
|
||||
#构建查询链接
|
||||
def build_query_string(params):
|
||||
# 使用OrderedDict来保持排序
|
||||
sorted_params = OrderedDict(sorted(params.items()))
|
||||
|
||||
# 拼接属性名和属性值,并使用&连接
|
||||
query_string = '&'.join('{}={}'.format(
|
||||
urllib.parse.quote_plus(k),
|
||||
urllib.parse.quote_plus(str(v))
|
||||
) for k, v in sorted_params.items())
|
||||
return query_string
|
||||
|
||||
|
||||
#计算签名,get请求
|
||||
def request_data_signature_get():
|
||||
print('开始请求数据...')
|
||||
url='https://api-bj.clink.cn/cc/cdr_ob_details'
|
||||
param={'mainUniqueId':'','AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177','Timestamp':current_time_utc,'Expires':Expires,}
|
||||
print(f'param: {param}')
|
||||
paramJson = {"mainUniqueId":"","Timestamp":""}
|
||||
print(f'paramJson: {paramJson}')
|
||||
url_path = build_query_string(param)
|
||||
url_param = build_query_string(param)
|
||||
print(f'url_param: {url_param}')
|
||||
url_param = f'GETapi-bj.clink.cn/cc/cdr_ob_details?{url_param}'
|
||||
print(f'待计算字符串: {url_param}')
|
||||
signature= generate_signature(url_param,'5g027B6w06630Y5240c1')
|
||||
print(f'计算签名: {signature}')
|
||||
print(f'编码后签名: {urllib.parse.quote_plus(signature)}')
|
||||
url = f'{url}?{url_path}&Signature={urllib.parse.quote_plus(signature)}'
|
||||
print(f'url: {url}')
|
||||
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
i = 0
|
||||
while 'error' in dataReqL and i < 5:
|
||||
time.sleep(1)
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
i = i + 1
|
||||
resL=json.loads(dataReqL.text)
|
||||
return resL
|
||||
|
||||
|
||||
|
||||
def load_data_to_db(dataList):
|
||||
conn = psycopg2.connect(database="dataops_db", user="dbuser_dops", password="MIgTi3jA",host="172.17.0.8", port="5432")
|
||||
print('数据库连接成功')
|
||||
dataId=str(uuid.uuid4())
|
||||
total=len(dataList)
|
||||
print('临时id:'+dataId)
|
||||
json_object = json.dumps(dataList)
|
||||
cur=conn.cursor()
|
||||
sql="update data_api.api_data set is_loaded = '1' where api_id = '7a38de24858a40ed9837f61ca7f80b08';INSERT INTO data_api.api_data (id,api_id,data,total_num,is_loaded,status,request_tm,execute_tm,remark) values (%s,%s,%s,%s,'0','0',current_timestamp(0),current_timestamp(0),'')"
|
||||
cur.execute(sql,[dataId,'7a38de24858a40ed9837f61ca7f80b08', json_object, total])
|
||||
conn.commit()
|
||||
cur.close()
|
||||
conn.close()
|
||||
print('加载数据结束:cc_cdr_ob_detail:查询外呼记录详情')
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
resL = request_data_signature_get()
|
||||
print(resL)
|
||||
|
||||
if 'error' in resL:
|
||||
load_error_to_db(resl)
|
||||
load_data_to_db(resL[''cdrObDetails'])
|
|
@ -0,0 +1,87 @@
|
|||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
DELETE FROM data_api.tr_cc_cdr_ob_detail;
|
||||
|
||||
insert into data_api.tr_cc_cdr_ob_detail (
|
||||
cno
|
||||
, client_name
|
||||
, client_number
|
||||
, start_time
|
||||
, callee_ringing_time
|
||||
, answer_time
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, call_type
|
||||
, call_type_desc
|
||||
, detail_call_type
|
||||
, detail_call_type_desc
|
||||
, ob_sip_cause
|
||||
, sip_cause
|
||||
, sip_cause_desc
|
||||
, record_file
|
||||
, tsi_file
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, main_unique_id
|
||||
, unique_id
|
||||
,etl_tx_dt
|
||||
)
|
||||
select
|
||||
case when trim(both from cno)='' then null else cno::text end cno
|
||||
, case when trim(both from client_name)='' then null else client_name::text end client_name
|
||||
, case when trim(both from client_number)='' then null else client_number::text end client_number
|
||||
, case when trim(both from start_time)='' then null else start_time::text end start_time
|
||||
, case when trim(both from callee_ringing_time)='' then null else callee_ringing_time::text end callee_ringing_time
|
||||
, case when trim(both from answer_time)='' then null else answer_time::text end answer_time
|
||||
, case when trim(both from end_time)='' then null else end_time::text end end_time
|
||||
, case when trim(both from bridge_duration)='' then null else bridge_duration::text end bridge_duration
|
||||
, case when trim(both from call_type)='' then null else call_type::text end call_type
|
||||
, case when trim(both from call_type_desc)='' then null else call_type_desc::text end call_type_desc
|
||||
, case when trim(both from detail_call_type)='' then null else detail_call_type::text end detail_call_type
|
||||
, case when trim(both from detail_call_type_desc)='' then null else detail_call_type_desc::text end detail_call_type_desc
|
||||
, case when trim(both from ob_sip_cause)='' then null else ob_sip_cause::text end ob_sip_cause
|
||||
, case when trim(both from sip_cause)='' then null else sip_cause::text end sip_cause
|
||||
, case when trim(both from sip_cause_desc)='' then null else sip_cause_desc::text end sip_cause_desc
|
||||
, case when trim(both from record_file)='' then null else record_file::text end record_file
|
||||
, case when trim(both from tsi_file)='' then null else tsi_file::text end tsi_file
|
||||
, case when trim(both from call_id)='' then null else call_id::text end call_id
|
||||
, case when trim(both from webrtc_call_id)='' then null else webrtc_call_id::text end webrtc_call_id
|
||||
, case when trim(both from main_unique_id)='' then null else main_unique_id::text end main_unique_id
|
||||
, case when trim(both from unique_id)='' then null else unique_id::text end unique_id
|
||||
,etl_tx_dt
|
||||
from (
|
||||
select
|
||||
(json_array_elements(data::json)::json->>'cno') cno
|
||||
, (json_array_elements(data::json)::json->>'clientName') client_name
|
||||
, (json_array_elements(data::json)::json->>'clientNumber') client_number
|
||||
, (json_array_elements(data::json)::json->>'startTime') start_time
|
||||
, (json_array_elements(data::json)::json->>'calleeRingingTime') callee_ringing_time
|
||||
, (json_array_elements(data::json)::json->>'answerTime') answer_time
|
||||
, (json_array_elements(data::json)::json->>'endTime') end_time
|
||||
, (json_array_elements(data::json)::json->>'bridgeDuration') bridge_duration
|
||||
, (json_array_elements(data::json)::json->>'callType') call_type
|
||||
, (json_array_elements(data::json)::json->>'callTypeDesc') call_type_desc
|
||||
, (json_array_elements(data::json)::json->>'detailCallType') detail_call_type
|
||||
, (json_array_elements(data::json)::json->>'detailCallTypeDesc') detail_call_type_desc
|
||||
, (json_array_elements(data::json)::json->>'obSipCause') ob_sip_cause
|
||||
, (json_array_elements(data::json)::json->>'sipCause') sip_cause
|
||||
, (json_array_elements(data::json)::json->>'sipCauseDesc') sip_cause_desc
|
||||
, (json_array_elements(data::json)::json->>'recordFile') record_file
|
||||
, (json_array_elements(data::json)::json->>'tsiFile') tsi_file
|
||||
, (json_array_elements(data::json)::json->>'callId') call_id
|
||||
, (json_array_elements(data::json)::json->>'webrtcCallId') webrtc_call_id
|
||||
, (json_array_elements(data::json)::json->>'mainUniqueId') main_unique_id
|
||||
, (json_array_elements(data::json)::json->>'uniqueId') unique_id
|
||||
,CURRENT_TIMESTAMP(0) etl_tx_dt
|
||||
from (select * from data_api.api_data
|
||||
WHERE api_id='7a38de24858a40ed9837f61ca7f80b08' and is_loaded = '0' order by request_tm desc limit 1) p )p;
|
||||
|
||||
update data_api.api_data
|
||||
set is_loaded = '1' ,
|
||||
status = '1',
|
||||
request_tm = current_timestamp(0)
|
||||
where api_id='7a38de24858a40ed9837f61ca7f80b08';
|
||||
\q
|
|
@ -0,0 +1,121 @@
|
|||
# coding: utf-8
|
||||
import requests
|
||||
import json
|
||||
import psycopg2
|
||||
import uuid
|
||||
import datetime
|
||||
import time
|
||||
import hashlib
|
||||
import time
|
||||
import hmac
|
||||
import base64
|
||||
import urllib.parse
|
||||
import hashlib
|
||||
from collections import OrderedDict
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
#全局变量,便于参数使用的预设值
|
||||
current_date = datetime.date.today() # 获取当前日期
|
||||
previous_date = current_date - datetime.timedelta(days=1) # 获取前一天日期
|
||||
formatted_current_date = current_date.strftime("%Y-%m-%dT%H:%M:%SZ") # 获取当前日期 - 标准化
|
||||
formatted_previous_date = previous_date.strftime("%Y-%m-%dT%H:%M:%SZ") # 获取前一天日期 - 标准化
|
||||
timestamp = time.time() # 为Unix time,即从"1970-01-01 00:00:00"至今的秒数;
|
||||
sign_version = 'v2' # 签名版本号,固定值v2
|
||||
nonce = str(uuid.uuid4())
|
||||
current_time_utc =( datetime.datetime.now() - datetime.timedelta(hours=8)).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
formatted2_current_date = current_date.strftime("%Y-%m-%d %H:%M:%S") # 获取当前日期 - 标准化
|
||||
formatted2_previous_date = previous_date.strftime("%Y-%m-%d %H:%M:%S") # 获取前一天日期 - 标准化
|
||||
|
||||
def formatted2_previous_hour(h):
|
||||
if h==0:
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
start_of_current_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0)
|
||||
# 减去一个小时,得到前一个小时的开始时间
|
||||
start_of_previous_hour = start_of_current_hour - datetime.timedelta(hours=h)
|
||||
return start_of_previous_hour.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
def previous_hour_timestamp(h):
|
||||
if h==0:
|
||||
return int(time.time())
|
||||
start_of_current_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0)
|
||||
# 减去一个小时,得到前一个小时的开始时间
|
||||
start_of_previous_hour = start_of_current_hour - datetime.timedelta(hours=h)
|
||||
return int(start_of_previous_hour.timestamp())
|
||||
|
||||
#计算签名
|
||||
def generate_signature(str, private_key):
|
||||
signature = hmac.new(private_key.encode(), (str).encode(), hashlib.sha1)
|
||||
signature_b64 = base64.b64encode(signature.digest()).decode()
|
||||
return signature_b64
|
||||
|
||||
#构建查询链接
|
||||
def build_query_string(params):
|
||||
# 使用OrderedDict来保持排序
|
||||
sorted_params = OrderedDict(sorted(params.items()))
|
||||
|
||||
# 拼接属性名和属性值,并使用&连接
|
||||
query_string = '&'.join('{}={}'.format(
|
||||
urllib.parse.quote_plus(k),
|
||||
urllib.parse.quote_plus(str(v))
|
||||
) for k, v in sorted_params.items())
|
||||
return query_string
|
||||
|
||||
#计算签名,get请求
|
||||
def request_data_signature_get():
|
||||
print(f'开始请求客服来电记录数据')
|
||||
url='https://api-bj.clink.cn/cc/list_cdr_ib'
|
||||
param={'Timestamp':current_time_utc,'Expires':86400,'startTime':previous_hour_timestamp(1),'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
||||
print(f'param: {param}')
|
||||
url_path = build_query_string(param)
|
||||
url_param = url_path
|
||||
print(f'url_param: {url_param}')
|
||||
url_param = f'GETapi-bj.clink.cn/cc/list_cdr_ib?{url_param}'
|
||||
print(f'待计算字符串: {url_param}')
|
||||
signature= generate_signature(url_param,'5g027B6w06630Y5240c1')
|
||||
print(f'计算签名: {signature}')
|
||||
print(f'编码后签名: {urllib.parse.quote_plus(signature)}')
|
||||
url = f'{url}?{url_path}&Signature={urllib.parse.quote_plus(signature)}'
|
||||
print(f'url: {url}')
|
||||
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
resText = dataReqL.text
|
||||
i = 0
|
||||
while 'error' in resText and i < 5:
|
||||
print(f'请求客服来电记录失败,再次请求第{i+1}次')
|
||||
time.sleep(1)
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
resText = dataReqL.text
|
||||
i = i + 1
|
||||
resD=json.loads(resText)
|
||||
print(f'请求客服来电记录结束')
|
||||
return resD
|
||||
|
||||
|
||||
def load_data_to_db(dataList):
|
||||
conn = psycopg2.connect(database="dataops_db", user="dbuser_dops", password="MIgTi3jA",host="172.17.0.8", port="5432")
|
||||
print('数据库连接成功')
|
||||
dataId=str(uuid.uuid4())
|
||||
total=len(dataList)
|
||||
print('临时id:'+dataId)
|
||||
json_object = json.dumps(dataList)
|
||||
cur=conn.cursor()
|
||||
sql="update data_api.api_data set is_loaded = '1' where api_id = '0be1a203e6e24db88008c5445283cda0';INSERT INTO data_api.api_data (id,api_id,data,total_num,is_loaded,status,request_tm,execute_tm,remark) values (%s,%s,%s,%s,'0','0',current_timestamp(0),current_timestamp(0),'')"
|
||||
cur.execute(sql,[dataId,'0be1a203e6e24db88008c5445283cda0', json_object, total])
|
||||
conn.commit()
|
||||
cur.close()
|
||||
conn.close()
|
||||
print('加载数据结束:cc_cdr_ib_list:查询客户来电记录列表')
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f'{formatted2_previous_hour(0)}开始请求客户来电记录信息')
|
||||
resL = request_data_signature_get()
|
||||
print(resL)
|
||||
if 'error' in resL:
|
||||
error = resL['error']
|
||||
print(f'请求客户来电记录失败,失败原因:{error}')
|
||||
else:
|
||||
dataList = resL['cdrIb']
|
||||
load_data_to_db(dataList)
|
||||
print(f'{formatted2_previous_hour(0)}请求客户来电记录结束')
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
DELETE FROM data_api.tr_cc_cdr_ib_list;
|
||||
|
||||
insert into data_api.tr_cc_cdr_ib_list (
|
||||
agent_answer_in_time
|
||||
, bridge_duration
|
||||
, bridge_time
|
||||
, call_id
|
||||
, customer_city
|
||||
, customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, end_time
|
||||
, evaluation
|
||||
, first_call_cname
|
||||
, first_call_cno
|
||||
, first_call_number
|
||||
, first_call_qname
|
||||
, first_call_qno
|
||||
, first_join_queue_time
|
||||
, hotline
|
||||
, hotline_name
|
||||
, investigation_keys
|
||||
, ivr_name
|
||||
, main_unique_id
|
||||
, on_hook_source
|
||||
, record_file
|
||||
, say_voice_duration
|
||||
, start_time
|
||||
, status
|
||||
, status_result
|
||||
, status_robot
|
||||
, tag_names
|
||||
, total_duration
|
||||
, user_field
|
||||
, webrtc_call_id
|
||||
, xnumber
|
||||
,etl_tx_dt
|
||||
)
|
||||
select
|
||||
case when trim(both from agent_answer_in_time)='' then null else agent_answer_in_time::text end agent_answer_in_time
|
||||
, case when trim(both from bridge_duration)='' then null else bridge_duration::text end bridge_duration
|
||||
, case when trim(both from bridge_time)='' then null else bridge_time::text end bridge_time
|
||||
, case when trim(both from call_id)='' then null else call_id::text end call_id
|
||||
, case when trim(both from customer_city)='' then null else customer_city::text end customer_city
|
||||
, case when trim(both from customer_number)='' then null else customer_number::text end customer_number
|
||||
, case when trim(both from customer_number_encrypt)='' then null else customer_number_encrypt::text end customer_number_encrypt
|
||||
, case when trim(both from customer_province)='' then null else customer_province::text end customer_province
|
||||
, case when trim(both from end_time)='' then null else end_time::text end end_time
|
||||
, case when trim(both from evaluation)='' then null else evaluation::text end evaluation
|
||||
, case when trim(both from first_call_cname)='' then null else first_call_cname::text end first_call_cname
|
||||
, case when trim(both from first_call_cno)='' then null else first_call_cno::text end first_call_cno
|
||||
, case when trim(both from first_call_number)='' then null else first_call_number::text end first_call_number
|
||||
, case when trim(both from first_call_qname)='' then null else first_call_qname::text end first_call_qname
|
||||
, case when trim(both from first_call_qno)='' then null else first_call_qno::text end first_call_qno
|
||||
, case when trim(both from first_join_queue_time)='' then null else first_join_queue_time::text end first_join_queue_time
|
||||
, case when trim(both from hotline)='' then null else hotline::text end hotline
|
||||
, case when trim(both from hotline_name)='' then null else hotline_name::text end hotline_name
|
||||
, case when trim(both from investigation_keys)='' then null else investigation_keys::text end investigation_keys
|
||||
, case when trim(both from ivr_name)='' then null else ivr_name::text end ivr_name
|
||||
, case when trim(both from main_unique_id)='' then null else main_unique_id::text end main_unique_id
|
||||
, case when trim(both from on_hook_source)='' then null else on_hook_source::text end on_hook_source
|
||||
, case when trim(both from record_file)='' then null else record_file::text end record_file
|
||||
, case when trim(both from say_voice_duration)='' then null else say_voice_duration::text end say_voice_duration
|
||||
, case when trim(both from start_time)='' then null else start_time::text end start_time
|
||||
, case when trim(both from status)='' then null else status::text end status
|
||||
, case when trim(both from status_result)='' then null else status_result::text end status_result
|
||||
, case when trim(both from status_robot)='' then null else status_robot::text end status_robot
|
||||
, case when trim(both from tag_names)='' then null else tag_names::text end tag_names
|
||||
, case when trim(both from total_duration)='' then null else total_duration::text end total_duration
|
||||
, case when trim(both from user_field)='' then null else user_field::text end user_field
|
||||
, case when trim(both from webrtc_call_id)='' then null else webrtc_call_id::text end webrtc_call_id
|
||||
, case when trim(both from xnumber)='' then null else xnumber::text end xnumber
|
||||
,etl_tx_dt
|
||||
from (
|
||||
select
|
||||
(json_array_elements(data::json)::json->>'agentAnswerInTime') agent_answer_in_time
|
||||
, (json_array_elements(data::json)::json->>'bridgeDuration') bridge_duration
|
||||
, (json_array_elements(data::json)::json->>'bridgeTime') bridge_time
|
||||
, (json_array_elements(data::json)::json->>'callId') call_id
|
||||
, (json_array_elements(data::json)::json->>'customerCity') customer_city
|
||||
, (json_array_elements(data::json)::json->>'customerNumber') customer_number
|
||||
, (json_array_elements(data::json)::json->>'customerNumberEncrypt') customer_number_encrypt
|
||||
, (json_array_elements(data::json)::json->>'customerProvince') customer_province
|
||||
, (json_array_elements(data::json)::json->>'endTime') end_time
|
||||
, (json_array_elements(data::json)::json->>'evaluation') evaluation
|
||||
, (json_array_elements(data::json)::json->>'firstCallCname') first_call_cname
|
||||
, (json_array_elements(data::json)::json->>'firstCallCno') first_call_cno
|
||||
, (json_array_elements(data::json)::json->>'firstCallNumber') first_call_number
|
||||
, (json_array_elements(data::json)::json->>'firstCallQname') first_call_qname
|
||||
, (json_array_elements(data::json)::json->>'firstCallQno') first_call_qno
|
||||
, (json_array_elements(data::json)::json->>'firstJoinQueueTime') first_join_queue_time
|
||||
, (json_array_elements(data::json)::json->>'hotline') hotline
|
||||
, (json_array_elements(data::json)::json->>'hotlineName') hotline_name
|
||||
, (json_array_elements(data::json)::json->>'investigationKeys') investigation_keys
|
||||
, (json_array_elements(data::json)::json->>'ivrName') ivr_name
|
||||
, (json_array_elements(data::json)::json->>'mainUniqueId') main_unique_id
|
||||
, (json_array_elements(data::json)::json->>'onHookSource') on_hook_source
|
||||
, (json_array_elements(data::json)::json->>'recordFile') record_file
|
||||
, (json_array_elements(data::json)::json->>'sayVoiceDuration') say_voice_duration
|
||||
, (json_array_elements(data::json)::json->>'startTime') start_time
|
||||
, (json_array_elements(data::json)::json->>'status') status
|
||||
, (json_array_elements(data::json)::json->>'statusResult') status_result
|
||||
, (json_array_elements(data::json)::json->>'statusRobot') status_robot
|
||||
, (json_array_elements(data::json)::json->>'tagNames') tag_names
|
||||
, (json_array_elements(data::json)::json->>'totalDuration') total_duration
|
||||
, (json_array_elements(data::json)::json->>'userField') user_field
|
||||
, (json_array_elements(data::json)::json->>'webrtcCallId') webrtc_call_id
|
||||
, (json_array_elements(data::json)::json->>'xnumber') xnumber
|
||||
,CURRENT_TIMESTAMP(0) etl_tx_dt
|
||||
from (select * from data_api.api_data
|
||||
WHERE api_id='0be1a203e6e24db88008c5445283cda0' and is_loaded = '0' order by request_tm desc limit 1) p )p;
|
||||
|
||||
update data_api.api_data
|
||||
set is_loaded = '1' ,
|
||||
status = '1',
|
||||
request_tm = current_timestamp(0)
|
||||
where api_id='0be1a203e6e24db88008c5445283cda0';
|
||||
\q
|
|
@ -0,0 +1,123 @@
|
|||
# coding: utf-8
|
||||
import requests
|
||||
import json
|
||||
import psycopg2
|
||||
import uuid
|
||||
import datetime
|
||||
import time
|
||||
import hashlib
|
||||
import time
|
||||
import hmac
|
||||
import base64
|
||||
import urllib.parse
|
||||
import hashlib
|
||||
from collections import OrderedDict
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
#全局变量,便于参数使用的预设值
|
||||
current_date = datetime.date.today() # 获取当前日期
|
||||
previous_date = current_date - datetime.timedelta(days=1) # 获取前一天日期
|
||||
formatted_current_date = current_date.strftime("%Y-%m-%dT%H:%M:%SZ") # 获取当前日期 - 标准化
|
||||
formatted_previous_date = previous_date.strftime("%Y-%m-%dT%H:%M:%SZ") # 获取前一天日期 - 标准化
|
||||
timestamp = time.time() # 为Unix time,即从"1970-01-01 00:00:00"至今的秒数;
|
||||
sign_version = 'v2' # 签名版本号,固定值v2
|
||||
nonce = str(uuid.uuid4())
|
||||
current_time_utc =( datetime.datetime.now() - datetime.timedelta(hours=8)).strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
formatted2_current_date = current_date.strftime("%Y-%m-%d %H:%M:%S") # 获取当前日期 - 标准化
|
||||
formatted2_previous_date = previous_date.strftime("%Y-%m-%d %H:%M:%S") # 获取前一天日期 - 标准化
|
||||
|
||||
def formatted2_previous_hour(h):
|
||||
if h==0:
|
||||
return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
start_of_current_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0)
|
||||
# 减去一个小时,得到前一个小时的开始时间
|
||||
start_of_previous_hour = start_of_current_hour - datetime.timedelta(hours=h)
|
||||
return start_of_previous_hour.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
def previous_hour_timestamp(h):
|
||||
if h==0:
|
||||
return int(time.time())
|
||||
start_of_current_hour = datetime.datetime.now().replace(minute=0, second=0, microsecond=0)
|
||||
# 减去一个小时,得到前一个小时的开始时间
|
||||
start_of_previous_hour = start_of_current_hour - datetime.timedelta(hours=h)
|
||||
return int(start_of_previous_hour.timestamp())
|
||||
|
||||
#计算签名
|
||||
def generate_signature(str, private_key):
|
||||
signature = hmac.new(private_key.encode(), (str).encode(), hashlib.sha1)
|
||||
signature_b64 = base64.b64encode(signature.digest()).decode()
|
||||
return signature_b64
|
||||
|
||||
#构建查询链接
|
||||
def build_query_string(params):
|
||||
# 使用OrderedDict来保持排序
|
||||
sorted_params = OrderedDict(sorted(params.items()))
|
||||
|
||||
# 拼接属性名和属性值,并使用&连接
|
||||
query_string = '&'.join('{}={}'.format(
|
||||
urllib.parse.quote_plus(k),
|
||||
urllib.parse.quote_plus(str(v))
|
||||
) for k, v in sorted_params.items())
|
||||
return query_string
|
||||
|
||||
#计算签名,get请求
|
||||
def request_data_signature_get():
|
||||
print(f'开始请求座席接听记录数据')
|
||||
url='https://api-bj.clink.cn/cc/list_cdr_ib_agent'
|
||||
param={'Timestamp':current_time_utc,'Expires':86400,'startTime':previous_hour_timestamp(1),'startTimeEnd':previous_hour_timestamp(0),'AccessKeyId':'b17759d3a36fba9a2cf522fbf4cbf177'}
|
||||
print(f'param: {param}')
|
||||
url_path = build_query_string(param)
|
||||
url_param = url_path
|
||||
print(f'url_param: {url_param}')
|
||||
url_param = f'GETapi-bj.clink.cn/cc/list_cdr_ib_agent?{url_param}'
|
||||
print(f'待计算字符串: {url_param}')
|
||||
signature= generate_signature(url_param,'5g027B6w06630Y5240c1')
|
||||
print(f'计算签名: {signature}')
|
||||
print(f'编码后签名: {urllib.parse.quote_plus(signature)}')
|
||||
url = f'{url}?{url_path}&Signature={urllib.parse.quote_plus(signature)}'
|
||||
print(f'url: {url}')
|
||||
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
resText = dataReqL.text
|
||||
i = 0
|
||||
while 'error' in resText and i < 5:
|
||||
print(f'请求座席接听记录失败,再次请求第{i+1}次')
|
||||
time.sleep(1)
|
||||
dataReqL=requests.get(url,headers={},params={})
|
||||
resText = dataReqL.text
|
||||
i = i + 1
|
||||
resD=json.loads(resText)
|
||||
print(f'请求座席接听记录结束')
|
||||
return resD
|
||||
|
||||
|
||||
|
||||
def load_data_to_db(dataList):
|
||||
conn = psycopg2.connect(database="dataops_db", user="dbuser_dops", password="MIgTi3jA",host="172.17.0.8", port="5432")
|
||||
print('数据库连接成功')
|
||||
dataId=str(uuid.uuid4())
|
||||
total=len(dataList)
|
||||
print('临时id:'+dataId)
|
||||
json_object = json.dumps(dataList)
|
||||
cur=conn.cursor()
|
||||
sql="update data_api.api_data set is_loaded = '1' where api_id = 'dd40ad726391416284f2b05254fed7fa';INSERT INTO data_api.api_data (id,api_id,data,total_num,is_loaded,status,request_tm,execute_tm,remark) values (%s,%s,%s,%s,'0','0',current_timestamp(0),current_timestamp(0),'')"
|
||||
cur.execute(sql,[dataId,'dd40ad726391416284f2b05254fed7fa', json_object, total])
|
||||
conn.commit()
|
||||
cur.close()
|
||||
conn.close()
|
||||
print('加载数据结束:cc_cdr_ib_agent_list:查询座席接听记录列表')
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f'{formatted2_previous_hour(0)}开始请求座席接听记录信息')
|
||||
resL = request_data_signature_get()
|
||||
print(resL)
|
||||
if 'error' in resL:
|
||||
error = resL['error']
|
||||
print(f'请求座席接听记录列表失败,失败原因:{error}')
|
||||
else:
|
||||
dataList = resL['cdrIbAgent']
|
||||
load_data_to_db(dataList)
|
||||
print(f'{formatted2_previous_hour(0)}请求座席接听记录结束')
|
|
@ -0,0 +1,117 @@
|
|||
/*******Main Section**************************************************************************/
|
||||
\set ON_ERROR_STOP on
|
||||
\set AUTOCOMMIT on
|
||||
\timing on
|
||||
|
||||
DELETE FROM data_api.tr_cc_cdr_ib_agent_list;
|
||||
|
||||
insert into data_api.tr_cc_cdr_ib_agent_list (
|
||||
unique_id
|
||||
, main_unique_id
|
||||
, qno
|
||||
, qname
|
||||
, cno
|
||||
, client_name
|
||||
, client_number
|
||||
, bridge_status
|
||||
, bridge_status_detail
|
||||
, sip_cause_desc
|
||||
, on_hook_source
|
||||
, agent_answer_in_time
|
||||
, detail_call_type
|
||||
, call_id
|
||||
, webrtc_call_id
|
||||
, record_file
|
||||
, start_time
|
||||
, ring_time
|
||||
, ib_ringing_duration
|
||||
, answer_time
|
||||
, offhook_time
|
||||
, say_voice_duration
|
||||
, end_time
|
||||
, bridge_duration
|
||||
, customer_number
|
||||
, customer_number_encrypt
|
||||
, customer_province
|
||||
, customer_city
|
||||
, hotline
|
||||
, hotline_name
|
||||
, remember
|
||||
,etl_tx_dt
|
||||
)
|
||||
select
|
||||
case when trim(both from unique_id)='' then null else unique_id::text end unique_id
|
||||
, case when trim(both from main_unique_id)='' then null else main_unique_id::text end main_unique_id
|
||||
, case when trim(both from qno)='' then null else qno::text end qno
|
||||
, case when trim(both from qname)='' then null else qname::text end qname
|
||||
, case when trim(both from cno)='' then null else cno::text end cno
|
||||
, case when trim(both from client_name)='' then null else client_name::text end client_name
|
||||
, case when trim(both from client_number)='' then null else client_number::text end client_number
|
||||
, case when trim(both from bridge_status)='' then null else bridge_status::text end bridge_status
|
||||
, case when trim(both from bridge_status_detail)='' then null else bridge_status_detail::text end bridge_status_detail
|
||||
, case when trim(both from sip_cause_desc)='' then null else sip_cause_desc::text end sip_cause_desc
|
||||
, case when trim(both from on_hook_source)='' then null else on_hook_source::text end on_hook_source
|
||||
, case when trim(both from agent_answer_in_time)='' then null else agent_answer_in_time::text end agent_answer_in_time
|
||||
, case when trim(both from detail_call_type)='' then null else detail_call_type::text end detail_call_type
|
||||
, case when trim(both from call_id)='' then null else call_id::text end call_id
|
||||
, case when trim(both from webrtc_call_id)='' then null else webrtc_call_id::text end webrtc_call_id
|
||||
, case when trim(both from record_file)='' then null else record_file::text end record_file
|
||||
, case when trim(both from start_time)='' then null else start_time::text end start_time
|
||||
, case when trim(both from ring_time)='' then null else ring_time::text end ring_time
|
||||
, case when trim(both from ib_ringing_duration)='' then null else ib_ringing_duration::text end ib_ringing_duration
|
||||
, case when trim(both from answer_time)='' then null else answer_time::text end answer_time
|
||||
, case when trim(both from offhook_time)='' then null else offhook_time::text end offhook_time
|
||||
, case when trim(both from say_voice_duration)='' then null else say_voice_duration::text end say_voice_duration
|
||||
, case when trim(both from end_time)='' then null else end_time::text end end_time
|
||||
, case when trim(both from bridge_duration)='' then null else bridge_duration::text end bridge_duration
|
||||
, case when trim(both from customer_number)='' then null else customer_number::text end customer_number
|
||||
, case when trim(both from customer_number_encrypt)='' then null else customer_number_encrypt::text end customer_number_encrypt
|
||||
, case when trim(both from customer_province)='' then null else customer_province::text end customer_province
|
||||
, case when trim(both from customer_city)='' then null else customer_city::text end customer_city
|
||||
, case when trim(both from hotline)='' then null else hotline::text end hotline
|
||||
, case when trim(both from hotline_name)='' then null else hotline_name::text end hotline_name
|
||||
, case when trim(both from remember)='' then null else remember::text end remember
|
||||
,etl_tx_dt
|
||||
from (
|
||||
select
|
||||
(json_array_elements(data::json)::json->>'uniqueId') unique_id
|
||||
, (json_array_elements(data::json)::json->>'mainUniqueId') main_unique_id
|
||||
, (json_array_elements(data::json)::json->>'qno') qno
|
||||
, (json_array_elements(data::json)::json->>'qname') qname
|
||||
, (json_array_elements(data::json)::json->>'cno') cno
|
||||
, (json_array_elements(data::json)::json->>'clientName') client_name
|
||||
, (json_array_elements(data::json)::json->>'clientNumber') client_number
|
||||
, (json_array_elements(data::json)::json->>'bridgeStatus') bridge_status
|
||||
, (json_array_elements(data::json)::json->>'bridgeStatusDetail') bridge_status_detail
|
||||
, (json_array_elements(data::json)::json->>'sipCauseDesc') sip_cause_desc
|
||||
, (json_array_elements(data::json)::json->>'onHookSource') on_hook_source
|
||||
, (json_array_elements(data::json)::json->>'agentAnswerInTime') agent_answer_in_time
|
||||
, (json_array_elements(data::json)::json->>'detailCallType') detail_call_type
|
||||
, (json_array_elements(data::json)::json->>'callId') call_id
|
||||
, (json_array_elements(data::json)::json->>'webrtcCallId') webrtc_call_id
|
||||
, (json_array_elements(data::json)::json->>'recordFile') record_file
|
||||
, (json_array_elements(data::json)::json->>'startTime') start_time
|
||||
, (json_array_elements(data::json)::json->>'ringTime') ring_time
|
||||
, (json_array_elements(data::json)::json->>'ibRingingDuration') ib_ringing_duration
|
||||
, (json_array_elements(data::json)::json->>'answerTime') answer_time
|
||||
, (json_array_elements(data::json)::json->>'offhookTime') offhook_time
|
||||
, (json_array_elements(data::json)::json->>'sayVoiceDuration') say_voice_duration
|
||||
, (json_array_elements(data::json)::json->>'endTime') end_time
|
||||
, (json_array_elements(data::json)::json->>'bridgeDuration') bridge_duration
|
||||
, (json_array_elements(data::json)::json->>'customerNumber') customer_number
|
||||
, (json_array_elements(data::json)::json->>'customerNumberEncrypt') customer_number_encrypt
|
||||
, (json_array_elements(data::json)::json->>'customerProvince') customer_province
|
||||
, (json_array_elements(data::json)::json->>'customerCity') customer_city
|
||||
, (json_array_elements(data::json)::json->>'hotline') hotline
|
||||
, (json_array_elements(data::json)::json->>'hotlineName') hotline_name
|
||||
, (json_array_elements(data::json)::json->>'remember') remember
|
||||
,CURRENT_TIMESTAMP(0) etl_tx_dt
|
||||
from (select * from data_api.api_data
|
||||
WHERE api_id='dd40ad726391416284f2b05254fed7fa' and is_loaded = '0' order by request_tm desc limit 1) p )p;
|
||||
|
||||
update data_api.api_data
|
||||
set is_loaded = '1' ,
|
||||
status = '1',
|
||||
request_tm = current_timestamp(0)
|
||||
where api_id='dd40ad726391416284f2b05254fed7fa';
|
||||
\q
|
Loading…
Reference in New Issue