|
|
|
@ -175,6 +175,13 @@ public class VaaSyncService { |
|
|
|
} |
|
|
|
logger.info("【设备】获取到 {} 条录音记录", records.size()); |
|
|
|
|
|
|
|
// 批量查询已存在的call_record_id(一次查询代替N次,防重复性能优化)
|
|
|
|
String startTimeStr = DateUtil.formatDate(lastSyncTime, "yyyy-MM-dd HH:mm:ss"); |
|
|
|
String endTimeStr = DateUtil.formatDate(now, "yyyy-MM-dd HH:mm:ss"); |
|
|
|
Set<String> existingIds = new HashSet<>(callRecordMapper.selectExistingCallRecordIds( |
|
|
|
deviceNo, startTimeStr, endTimeStr)); |
|
|
|
logger.debug("【设备】已存在 {} 条通话记录,将跳过", existingIds.size()); |
|
|
|
|
|
|
|
// 步骤5:逐条处理录音
|
|
|
|
int successCount = 0; |
|
|
|
int failCount = 0; |
|
|
|
@ -184,7 +191,7 @@ public class VaaSyncService { |
|
|
|
JSONObject rec = records.getJSONObject(i); |
|
|
|
try { |
|
|
|
Date callTime = processSingleRecord(rec, deviceNo, cityName, cityCode, orgCode, |
|
|
|
deviceHost, authToken, extNumbers); |
|
|
|
deviceHost, authToken, extNumbers, existingIds); |
|
|
|
if (callTime != null) { |
|
|
|
successCount++; |
|
|
|
if (latestCallTime == null || callTime.after(latestCallTime)) { |
|
|
|
@ -212,7 +219,8 @@ public class VaaSyncService { |
|
|
|
*/ |
|
|
|
private Date processSingleRecord(JSONObject rec, String deviceNo, String cityName, |
|
|
|
String cityCode, String orgCode, String deviceHost, |
|
|
|
String authToken, Map<String, String> extNumbers) throws Exception { |
|
|
|
String authToken, Map<String, String> extNumbers, |
|
|
|
Set<String> existingIds) throws Exception { |
|
|
|
// 解析录音信息
|
|
|
|
String recordId = RecordParser.parseRecordId(rec); |
|
|
|
String filePath = RecordParser.parseFilePath(rec); |
|
|
|
@ -231,9 +239,9 @@ public class VaaSyncService { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
// 防重复:根据 device_no + record_id 判断
|
|
|
|
// 防重复:内存中比对已存在的call_record_id(一次查询代替N次)
|
|
|
|
String callRecordId = deviceNo + "_" + recordId; |
|
|
|
if (callRecordMapper.selectByCallRecordId(callRecordId) != null) { |
|
|
|
if (existingIds.contains(callRecordId)) { |
|
|
|
logger.debug("【录音】已存在,跳过: {}", callRecordId); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|