From c9a19d931ddc2d37f2481ea6791e19c3a356d53c Mon Sep 17 00:00:00 2001 From: wang Date: Wed, 19 Aug 2026 08:59:12 +0800 Subject: [PATCH] =?UTF-8?q?id=E8=87=AA=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataserviceyy/mapper/MidVoiceDeviceLogMapper.java | 4 ++-- .../dataserviceyy/mapper/MidVoiceResyncLogMapper.java | 4 ++-- .../threecloud/dataserviceyy/service/VaaSyncService.java | 5 +++++ src/main/resources/mapper/MidVoiceCallRecordMapper.xml | 6 +++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceDeviceLogMapper.java b/src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceDeviceLogMapper.java index 3406adc..f4b3d6e 100644 --- a/src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceDeviceLogMapper.java +++ b/src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceDeviceLogMapper.java @@ -14,10 +14,10 @@ public interface MidVoiceDeviceLogMapper { * 插入设备连接日志 */ @Insert("INSERT INTO mid_voice_device_log (" + - "device_id, device_no, city_code, city_name, ip_address, device_port, " + + "id, device_id, device_no, city_code, city_name, ip_address, device_port, " + "connect_type, connect_status, fail_reason, create_time" + ") VALUES (" + - "#{deviceId}, #{deviceNo}, #{cityCode}, #{cityName}, #{ipAddress}, #{devicePort}, " + + "#{id}, #{deviceId}, #{deviceNo}, #{cityCode}, #{cityName}, #{ipAddress}, #{devicePort}, " + "#{connectType}, #{connectStatus}, #{failReason}, #{createTime}" + ")") int insert(MidVoiceDeviceLog log); diff --git a/src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceResyncLogMapper.java b/src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceResyncLogMapper.java index ada6fa7..27b8e07 100644 --- a/src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceResyncLogMapper.java +++ b/src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceResyncLogMapper.java @@ -14,10 +14,10 @@ public interface MidVoiceResyncLogMapper { * 插入重新同步操作记录 */ @Insert("INSERT INTO mid_voice_resync_log (" + - "call_record_id, device_no, recording_file_name, oss_file_path, " + + "id, call_record_id, device_no, recording_file_name, oss_file_path, " + "resync_status, fail_reason, create_time" + ") VALUES (" + - "#{callRecordId}, #{deviceNo}, #{recordingFileName}, #{ossFilePath}, " + + "#{id}, #{callRecordId}, #{deviceNo}, #{recordingFileName}, #{ossFilePath}, " + "#{resyncStatus}, #{failReason}, #{createTime}" + ")") int insert(MidVoiceResyncLog log); diff --git a/src/main/java/com/threecloud/dataserviceyy/service/VaaSyncService.java b/src/main/java/com/threecloud/dataserviceyy/service/VaaSyncService.java index 347c85b..f8c6c36 100644 --- a/src/main/java/com/threecloud/dataserviceyy/service/VaaSyncService.java +++ b/src/main/java/com/threecloud/dataserviceyy/service/VaaSyncService.java @@ -563,6 +563,8 @@ public class VaaSyncService { int duration, String channelPhone, String remotePhone, boolean isOutgoing, boolean isAnswered) { MidVoiceCallRecord record = new MidVoiceCallRecord(); + long generatedId = System.currentTimeMillis() * 1000L + (long)(Math.random() * 1000L); + record.setId(generatedId); record.setCallRecordId(callRecordId); record.setDeviceNo(deviceNo); record.setCityCode(cityCode); @@ -610,6 +612,9 @@ public class VaaSyncService { String connectStatus, String failReason) { try { MidVoiceDeviceLog log = new MidVoiceDeviceLog(); + // 代码生成唯一分布式数值 ID (雪花算法/时间戳+序列号),避免数据库无自增序列导致非空约束报错 + long generatedId = System.currentTimeMillis() * 1000L + (long)(Math.random() * 1000L); + log.setId(generatedId); log.setDeviceId(deviceId); log.setDeviceNo(deviceNo); log.setCityCode(cityCode); diff --git a/src/main/resources/mapper/MidVoiceCallRecordMapper.xml b/src/main/resources/mapper/MidVoiceCallRecordMapper.xml index 25695af..9925e4f 100644 --- a/src/main/resources/mapper/MidVoiceCallRecordMapper.xml +++ b/src/main/resources/mapper/MidVoiceCallRecordMapper.xml @@ -27,14 +27,14 @@ - + INSERT INTO mid_voice_call_record ( - city_code, city_name, call_record_id, call_tel, called_tel, + id, city_code, city_name, call_record_id, call_tel, called_tel, call_start_time, call_end_time, call_duration, call_direction, device_no, business_scenario, recording_file_name, recording_file_path, recording_file_size, call_status, fail_reason, remarks, sync_time, create_time, org_code ) VALUES ( - #{cityCode}, #{cityName}, #{callRecordId}, #{callTel}, #{calledTel}, + #{id}, #{cityCode}, #{cityName}, #{callRecordId}, #{callTel}, #{calledTel}, #{callStartTime}, #{callEndTime}, #{callDuration}, #{callDirection}, #{deviceNo}, #{businessScenario}, #{recordingFileName}, #{recordingFilePath}, #{recordingFileSize}, #{callStatus}, #{failReason}, #{remarks}, NOW(), NOW(), #{orgCode}