省厅位置汇聚处理redis数据入在线库提示唯一索引报错问题
parent
659a894d67
commit
61b89e502b
|
|
@ -45,7 +45,10 @@ public class DeviceRedisServiceImpl implements IDeviceRedisService {
|
|||
// 在插入前对数据进行去重(基于唯一约束)
|
||||
Map<String, DeviceRedis> uniqueMap = new LinkedHashMap<>();
|
||||
for (DeviceRedis device : list) {
|
||||
String key = device.getDeviceCode() + "|" +
|
||||
if ("99".equals(device.getDeviceType())){
|
||||
continue;
|
||||
}
|
||||
String key = device.getDeviceCode() + "|" + device.getDeviceType() + "|" +
|
||||
device.getInfoSource();
|
||||
// 保留最后一次出现的记录(根据业务需求调整)
|
||||
uniqueMap.put(key, device);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#{entity.deviceCode},#{entity.deviceType},#{entity.online},#{entity.zzjgdm},#{entity.gpsTime},#{entity.infoSource}
|
||||
)
|
||||
</foreach>
|
||||
ON conflict(device_code,info_source) do update set
|
||||
ON conflict(device_code,device_type,info_source) do update set
|
||||
(online,zzjgdm,gps_time) =(EXCLUDED.online,EXCLUDED.zzjgdm,EXCLUDED.gps_time)
|
||||
</insert>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue