| xqd
@@ -50,16 +50,23 @@ if __name__ == '__main__':
|
|
|
last_id = mysql_cur.fetchone()
|
|
|
last_id = last_id['cdr_id'] if last_id else 0
|
|
|
# 获取要同步的通话详单
|
|
|
- postgres_cur.execute("""select caller,start_time,end_time,record_path,hangup_dispostion,call_id,id,term_status,intention from ai_cdr where id > %s order by id asc""",
|
|
|
+ postgres_cur.execute("""select caller,start_time,end_time,record_path,hangup_dispostion,call_id,id,term_status,intention,task_id from ai_cdr where id > %s order by id asc""",
|
|
|
([last_id]))
|
|
|
call_records = postgres_cur.fetchall()
|
|
|
|
|
|
for call_record in call_records:
|
|
|
+
|
|
|
+ postgres_cur.execute("""select tk_name from ai_task where id = %s""",
|
|
|
+ ([call_record[9]]))
|
|
|
+ task_name = postgres_cur.fetchone()
|
|
|
+ tk_id = call_record[9]
|
|
|
+ task_name = task_name['tk_name'] if task_name else '任务' + str(tk_id)
|
|
|
+
|
|
|
record_path = ip+':8088/recordings/'+call_record[3]
|
|
|
mysql_cur.execute(
|
|
|
- """insert into call_records(phone, start_time, end_time, record_path, hangup_dispostion, call_id, cdr_id, term_status,intention, ip) value (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
|
|
+ """insert into call_records(phone, start_time, end_time, record_path, hangup_dispostion, call_id, cdr_id, term_status,intention, ip,tag) value (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
|
|
|
(call_record[0], call_record[1], call_record[2], record_path,
|
|
|
- call_record[4], call_record[5], call_record[6], call_record[7], call_record[8], ip)
|
|
|
+ call_record[4], call_record[5], call_record[6], call_record[7], call_record[8], ip,task_name)
|
|
|
)
|
|
|
mysql_conn.commit()
|
|
|
|