Browse Source

id自生成

main
wang 2 weeks ago
parent
commit
c9a19d931d
  1. 4
      src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceDeviceLogMapper.java
  2. 4
      src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceResyncLogMapper.java
  3. 5
      src/main/java/com/threecloud/dataserviceyy/service/VaaSyncService.java
  4. 6
      src/main/resources/mapper/MidVoiceCallRecordMapper.xml

4
src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceDeviceLogMapper.java

@ -14,10 +14,10 @@ public interface MidVoiceDeviceLogMapper {
* 插入设备连接日志 * 插入设备连接日志
*/ */
@Insert("INSERT INTO mid_voice_device_log (" + @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" + "connect_type, connect_status, fail_reason, create_time" +
") VALUES (" + ") VALUES (" +
"#{deviceId}, #{deviceNo}, #{cityCode}, #{cityName}, #{ipAddress}, #{devicePort}, " + "#{id}, #{deviceId}, #{deviceNo}, #{cityCode}, #{cityName}, #{ipAddress}, #{devicePort}, " +
"#{connectType}, #{connectStatus}, #{failReason}, #{createTime}" + "#{connectType}, #{connectStatus}, #{failReason}, #{createTime}" +
")") ")")
int insert(MidVoiceDeviceLog log); int insert(MidVoiceDeviceLog log);

4
src/main/java/com/threecloud/dataserviceyy/mapper/MidVoiceResyncLogMapper.java

@ -14,10 +14,10 @@ public interface MidVoiceResyncLogMapper {
* 插入重新同步操作记录 * 插入重新同步操作记录
*/ */
@Insert("INSERT INTO mid_voice_resync_log (" + @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" + "resync_status, fail_reason, create_time" +
") VALUES (" + ") VALUES (" +
"#{callRecordId}, #{deviceNo}, #{recordingFileName}, #{ossFilePath}, " + "#{id}, #{callRecordId}, #{deviceNo}, #{recordingFileName}, #{ossFilePath}, " +
"#{resyncStatus}, #{failReason}, #{createTime}" + "#{resyncStatus}, #{failReason}, #{createTime}" +
")") ")")
int insert(MidVoiceResyncLog log); int insert(MidVoiceResyncLog log);

5
src/main/java/com/threecloud/dataserviceyy/service/VaaSyncService.java

@ -563,6 +563,8 @@ public class VaaSyncService {
int duration, String channelPhone, String remotePhone, int duration, String channelPhone, String remotePhone,
boolean isOutgoing, boolean isAnswered) { boolean isOutgoing, boolean isAnswered) {
MidVoiceCallRecord record = new MidVoiceCallRecord(); MidVoiceCallRecord record = new MidVoiceCallRecord();
long generatedId = System.currentTimeMillis() * 1000L + (long)(Math.random() * 1000L);
record.setId(generatedId);
record.setCallRecordId(callRecordId); record.setCallRecordId(callRecordId);
record.setDeviceNo(deviceNo); record.setDeviceNo(deviceNo);
record.setCityCode(cityCode); record.setCityCode(cityCode);
@ -610,6 +612,9 @@ public class VaaSyncService {
String connectStatus, String failReason) { String connectStatus, String failReason) {
try { try {
MidVoiceDeviceLog log = new MidVoiceDeviceLog(); MidVoiceDeviceLog log = new MidVoiceDeviceLog();
// 代码生成唯一分布式数值 ID (雪花算法/时间戳+序列号),避免数据库无自增序列导致非空约束报错
long generatedId = System.currentTimeMillis() * 1000L + (long)(Math.random() * 1000L);
log.setId(generatedId);
log.setDeviceId(deviceId); log.setDeviceId(deviceId);
log.setDeviceNo(deviceNo); log.setDeviceNo(deviceNo);
log.setCityCode(cityCode); log.setCityCode(cityCode);

6
src/main/resources/mapper/MidVoiceCallRecordMapper.xml

@ -27,14 +27,14 @@
</resultMap> </resultMap>
<!-- 插入通话记录 --> <!-- 插入通话记录 -->
<insert id="insert" useGeneratedKeys="true" keyProperty="id"> <insert id="insert">
INSERT INTO mid_voice_call_record ( 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, call_start_time, call_end_time, call_duration, call_direction,
device_no, business_scenario, recording_file_name, recording_file_path, device_no, business_scenario, recording_file_name, recording_file_path,
recording_file_size, call_status, fail_reason, remarks, sync_time, create_time, org_code recording_file_size, call_status, fail_reason, remarks, sync_time, create_time, org_code
) VALUES ( ) VALUES (
#{cityCode}, #{cityName}, #{callRecordId}, #{callTel}, #{calledTel}, #{id}, #{cityCode}, #{cityName}, #{callRecordId}, #{callTel}, #{calledTel},
#{callStartTime}, #{callEndTime}, #{callDuration}, #{callDirection}, #{callStartTime}, #{callEndTime}, #{callDuration}, #{callDirection},
#{deviceNo}, #{businessScenario}, #{recordingFileName}, #{recordingFilePath}, #{deviceNo}, #{businessScenario}, #{recordingFileName}, #{recordingFilePath},
#{recordingFileSize}, #{callStatus}, #{failReason}, #{remarks}, NOW(), NOW(), #{orgCode} #{recordingFileSize}, #{callStatus}, #{failReason}, #{remarks}, NOW(), NOW(), #{orgCode}

Loading…
Cancel
Save