|
|
@@ -430,10 +430,12 @@ public class DataSyncService { |
|
|
|
// 获取PostgreSQL中最大的node_time(数据库层面) |
|
|
|
java.util.Date maxNodeTime = onceWeighingPostgreSQLRepository.findMaxNodeTime(); |
|
|
|
if (maxNodeTime == null) { |
|
|
|
System.out.println("现在表里没有数据,将同步全量数据"); |
|
|
|
return syncOnceAllData(); |
|
|
|
} |
|
|
|
// 数据库层面过滤增量数据 |
|
|
|
List<com.example.webapi.entity.OnceWeighing> incrementalRecords = onceWeighingRepository.findByNodeTimeAfter(maxNodeTime); |
|
|
|
System.out.println("找到需要同步的OnceWeighing数据条数为" + incrementalRecords.size()); |
|
|
|
int successCount = 0; |
|
|
|
for (com.example.webapi.entity.OnceWeighing source : incrementalRecords) { |
|
|
|
try { |
|
|
@@ -451,6 +453,7 @@ public class DataSyncService { |
|
|
|
System.err.println("同步记录失败,NODEID: " + source.getNodeId() + ", 错误: " + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
System.out.println("成功同步了OnceWeighing数据条数为" + successCount); |
|
|
|
return successCount; |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|