Browse Source

解决insertOrUpdateBatch批量插入或者更新无数据报错的问题

develop
xiepufeng 6 months ago
parent
commit
7e815b73dc
  1. 3
      zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java
  2. 3
      zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java
  3. 5
      zc-business/src/main/java/com/zc/business/statistics/handler/TrafficGantryMetricsStatistics.java
  4. 5
      zc-business/src/main/java/com/zc/business/statistics/handler/TrafficGantryStatistics.java

3
zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java

@ -141,6 +141,9 @@ public class DcGantryStatisticsDataImpl extends ServiceImpl<DcGantryStatisticsDa
* 然后分别计算每个门架的统计信息并将这些统计信息添加到每日交通门架指标统计缓存中
*/
private void recoveryHourlyCache(List<DcGantryStatisticsData> dcGantryStatisticsDataList) {
if (dcGantryStatisticsDataList == null || dcGantryStatisticsDataList.isEmpty()) {
return;
}
dcGantryStatisticsDataMapper.insertOrUpdateBatch(dcGantryStatisticsDataList);
}

3
zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java

@ -168,6 +168,9 @@ public class IDcGantryMetricsStatisticsDataServiceImpl
* 然后分别计算每个门架的统计信息并将这些统计信息添加到每日交通门架指标统计缓存中
*/
private void recoveryHourlyCache(List<DcGantryMetricsStatisticsData> gantryMetricsStatisticsDataList) {
if (gantryMetricsStatisticsDataList == null || gantryMetricsStatisticsDataList.isEmpty()) {
return;
}
gantryMetricsStatisticsDataMapper.insertOrUpdateBatch(gantryMetricsStatisticsDataList);
}

5
zc-business/src/main/java/com/zc/business/statistics/handler/TrafficGantryMetricsStatistics.java

@ -46,6 +46,11 @@ public class TrafficGantryMetricsStatistics {
public void performHourlyCleanupAndPersist() {
List<DcGantryMetricsStatisticsData> lastHourData = dcGantryMetricsStatisticsDataService.lastHourData();
if (lastHourData == null || lastHourData.isEmpty()) {
return;
}
// 数据库批量插入最近一小时的数据
dcGantryMetricsStatisticsDataMapper.insertOrUpdateBatch(lastHourData);

5
zc-business/src/main/java/com/zc/business/statistics/handler/TrafficGantryStatistics.java

@ -45,6 +45,11 @@ public class TrafficGantryStatistics {
public void performHourlyCleanupAndPersist() {
List<DcGantryStatisticsData> lastHourData = dcGantryStatisticsDataService.lastHourData();
if (lastHourData == null || lastHourData.isEmpty()) {
return;
}
// 数据库批量插入最近一小时的数据
dcGantryStatisticsDataMapper.insertOrUpdateBatch(lastHourData);

Loading…
Cancel
Save