Browse Source

交通流数据防止数据量太大,每次一万条分批执行

develop
lau572 4 months ago
parent
commit
9150c5b67b
  1. 9
      zc-business/src/main/java/com/zc/business/service/impl/DcGantryStatisticsDataImpl.java
  2. 9
      zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java

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

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.ServiceException;
import com.zc.business.domain.DcGantryMetricsStatisticsData;
import com.zc.business.domain.DcGantryStatisticsData;
import com.zc.business.domain.OdsTollEtctuData;
import com.zc.business.enums.TrafficDataPeriodTypeEnum;
@ -144,7 +145,13 @@ public class DcGantryStatisticsDataImpl extends ServiceImpl<DcGantryStatisticsDa
if (dcGantryStatisticsDataList == null || dcGantryStatisticsDataList.isEmpty()) {
return;
}
dcGantryStatisticsDataMapper.insertOrUpdateBatch(dcGantryStatisticsDataList);
//防止数据量太大,每次一万条分批执行
for (int i = 0; i < dcGantryStatisticsDataList.size(); i+=10000) {
int end = Math.min(i + 10000, dcGantryStatisticsDataList.size());
List<DcGantryStatisticsData> batchList = dcGantryStatisticsDataList.subList(i, end);
dcGantryStatisticsDataMapper.insertOrUpdateBatch(batchList);
}
}
/**

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

@ -409,7 +409,14 @@ public class IDcGantryMetricsStatisticsDataServiceImpl
if (gantryMetricsStatisticsDataList == null || gantryMetricsStatisticsDataList.isEmpty()) {
return;
}
gantryMetricsStatisticsDataMapper.insertOrUpdateBatch(gantryMetricsStatisticsDataList);
//防止数据量太大,每次一万条分批执行
for (int i = 0; i < gantryMetricsStatisticsDataList.size(); i+=10000) {
int end = Math.min(i + 10000, gantryMetricsStatisticsDataList.size());
List<DcGantryMetricsStatisticsData> batchList = gantryMetricsStatisticsDataList.subList(i, end);
gantryMetricsStatisticsDataMapper.insertOrUpdateBatch(batchList);
}
}
/**

Loading…
Cancel
Save