通话记录数据清洗

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

@@ -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);
}
}