通话记录数据清洗

This commit is contained in:
wong
2025-08-12 16:58:00 +08:00
parent 14c882ff08
commit c847eff9fc
2 changed files with 40 additions and 0 deletions

View File

@@ -56,6 +56,7 @@ class SyncWechatDataToCkbTask extends Command
$this->syncWechatFriendToTrafficPoolBatch($ChuKeBaoAdapter); $this->syncWechatFriendToTrafficPoolBatch($ChuKeBaoAdapter);
$this->syncTrafficSourceUser($ChuKeBaoAdapter); $this->syncTrafficSourceUser($ChuKeBaoAdapter);
$this->syncTrafficSourceGroup($ChuKeBaoAdapter); $this->syncTrafficSourceGroup($ChuKeBaoAdapter);
$this->syncCallRecording($ChuKeBaoAdapter);
$output->writeln("同步任务 sync_wechat_to_ckb 已结束"); $output->writeln("同步任务 sync_wechat_to_ckb 已结束");
return true; return true;
@@ -118,6 +119,10 @@ class SyncWechatDataToCkbTask extends Command
{ {
return $ChuKeBaoAdapter->syncWechatGroupCustomer(); return $ChuKeBaoAdapter->syncWechatGroupCustomer();
} }
protected function syncCallRecording(ChuKeBaoAdapter $ChuKeBaoAdapter)
{
return $ChuKeBaoAdapter->syncCallRecording();
}
} }

View File

@@ -1488,4 +1488,39 @@ class Adapter implements WeChatServiceInterface
} }
public function syncCallRecording()
{
$sql = "insert into ck_call_recording(`id`,`phone`,`isCallOut`,`companyId`,`callType`,`beginTime`,`endTime`,`createTime`)
SELECT
c.id id,
c.phone phone,
c.isCallOut isCallOut,
a.departmentId companyId,
c.callType callType,
c.beginTime beginTime,
c.endTime endTime,
c.callBeginTime createTime
FROM
s2_call_recording c
LEFT JOIN s2_company_account a ON c.deviceOwnerId = a.id
ORDER BY c.id DESC
LIMIT ?, ?
ON DUPLICATE KEY UPDATE
id=VALUES(id),
phone=VALUES(phone),
isCallOut=VALUES(isCallOut),
companyId=VALUES(companyId)";
$offset = 0;
$limit = 2000;
$usleepTime = 50000;
do {
$affected = Db::execute($sql, [$offset, $limit]);
$offset += $limit;
if ($affected > 0) {
usleep($usleepTime);
}
} while ($affected > 0);
}
} }