mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
优化批量入库方法,按1000条批量入库
This commit is contained in:
+32
-9
@@ -295,13 +295,36 @@ public class OrderInputProcessor {
|
||||
public void batchInsert(Collection<RawGoodsDO> rawGoodsDOS, Collection<OrderBodyDO> orderBodyDOS,
|
||||
Collection<OrderGroupDO> orderGroupDOS, Collection<OrderPartsDO> orderPartsDOS,
|
||||
Collection<PlateDO> plateDOS, Collection<OrderModuleExtraDO> orderModuleExtraDOS, Collection<OrderItemDO> itemDOS) {
|
||||
rawGoodsMapper.insertBatch(rawGoodsDOS);
|
||||
orderBodyMapper.insertBatch(orderBodyDOS);
|
||||
orderGroupMapper.insertBatch(orderGroupDOS);
|
||||
orderPartsMapper.insertBatch(orderPartsDOS);
|
||||
plateMapper.insertBatch(plateDOS);
|
||||
orderModuleExtraMapper.insertBatch(orderModuleExtraDOS);
|
||||
orderItemMapper.insertBatch(itemDOS);
|
||||
|
||||
for (int i = 0; i < rawGoodsDOS.size(); i += 1000) {
|
||||
rawGoodsMapper.insertBatch(rawGoodsDOS.stream().skip(i).limit(1000).collect(Collectors.toList()));
|
||||
}
|
||||
for (int i = 0; i < orderBodyDOS.size(); i += 1000) {
|
||||
orderBodyMapper.insertBatch(orderBodyDOS.stream().skip(i).limit(1000).collect(Collectors.toList()));
|
||||
}
|
||||
for (int i = 0; i < orderGroupDOS.size(); i += 1000) {
|
||||
orderGroupMapper.insertBatch(orderGroupDOS.stream().skip(i).limit(1000).collect(Collectors.toList()));
|
||||
}
|
||||
for (int i = 0; i < orderPartsDOS.size(); i += 1000) {
|
||||
orderPartsMapper.insertBatch(orderPartsDOS.stream().skip(i).limit(1000).collect(Collectors.toList()));
|
||||
}
|
||||
for (int i = 0; i < plateDOS.size(); i += 1000) {
|
||||
plateMapper.insertBatch(plateDOS.stream().skip(i).limit(1000).collect(Collectors.toList()));
|
||||
}
|
||||
for (int i = 0; i < orderModuleExtraDOS.size(); i += 1000) {
|
||||
orderModuleExtraMapper.insertBatch(orderModuleExtraDOS.stream().skip(i).limit(1000).collect(Collectors.toList()));
|
||||
}
|
||||
for (int i = 0; i < itemDOS.size(); i += 1000) {
|
||||
orderItemMapper.insertBatch(itemDOS.stream().skip(i).limit(1000).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
//rawGoodsMapper.insertBatch(rawGoodsDOS);
|
||||
//orderBodyMapper.insertBatch(orderBodyDOS);
|
||||
//orderGroupMapper.insertBatch(orderGroupDOS);
|
||||
//orderPartsMapper.insertBatch(orderPartsDOS);
|
||||
//plateMapper.insertBatch(plateDOS);
|
||||
//orderModuleExtraMapper.insertBatch(orderModuleExtraDOS);
|
||||
//orderItemMapper.insertBatch(itemDOS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,9 +336,9 @@ public class OrderInputProcessor {
|
||||
try {
|
||||
BulkResponse bulkResponse = esDocumentService.bulkCreate(ORDER_PLATE_MODEL, orderModelDOs);
|
||||
boolean errors = bulkResponse.errors();
|
||||
if(errors) {
|
||||
if (errors) {
|
||||
log.error(bulkResponse.items().toString());
|
||||
throw new ServiceException(500,"未知异常");
|
||||
throw new ServiceException(500, "未知异常");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user