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:
+42
-19
@@ -237,16 +237,16 @@ public class OrderInputProcessor {
|
|||||||
orderItemDO.setType(1);
|
orderItemDO.setType(1);
|
||||||
plateDOS.add(plateDO);
|
plateDOS.add(plateDO);
|
||||||
orderModelDOS.add(
|
orderModelDOS.add(
|
||||||
OrderModelDO.builder()
|
OrderModelDO.builder()
|
||||||
.orderId(orderId)
|
.orderId(orderId)
|
||||||
.plateId(plateDO.getId())
|
.plateId(plateDO.getId())
|
||||||
.contourDetail(e.getContourDetail())
|
.contourDetail(e.getContourDetail())
|
||||||
.pointDetail(e.getPointDetail())
|
.pointDetail(e.getPointDetail())
|
||||||
.holeDetail(e.getHoleDetail())
|
.holeDetail(e.getHoleDetail())
|
||||||
.rawPointDetail(e.getRawPointDetail())
|
.rawPointDetail(e.getRawPointDetail())
|
||||||
.sideHoleDetail(e.getSideHoleDetail())
|
.sideHoleDetail(e.getSideHoleDetail())
|
||||||
.sideModelDetail(e.getSideModelDetail())
|
.sideModelDetail(e.getSideModelDetail())
|
||||||
.build());
|
.build());
|
||||||
} else {
|
} else {
|
||||||
OrderPartsDO orderPartsDO = OrderPartsDO.builder()
|
OrderPartsDO orderPartsDO = OrderPartsDO.builder()
|
||||||
.id(identifierGenerator.nextId(null).longValue())
|
.id(identifierGenerator.nextId(null).longValue())
|
||||||
@@ -295,13 +295,36 @@ public class OrderInputProcessor {
|
|||||||
public void batchInsert(Collection<RawGoodsDO> rawGoodsDOS, Collection<OrderBodyDO> orderBodyDOS,
|
public void batchInsert(Collection<RawGoodsDO> rawGoodsDOS, Collection<OrderBodyDO> orderBodyDOS,
|
||||||
Collection<OrderGroupDO> orderGroupDOS, Collection<OrderPartsDO> orderPartsDOS,
|
Collection<OrderGroupDO> orderGroupDOS, Collection<OrderPartsDO> orderPartsDOS,
|
||||||
Collection<PlateDO> plateDOS, Collection<OrderModuleExtraDO> orderModuleExtraDOS, Collection<OrderItemDO> itemDOS) {
|
Collection<PlateDO> plateDOS, Collection<OrderModuleExtraDO> orderModuleExtraDOS, Collection<OrderItemDO> itemDOS) {
|
||||||
rawGoodsMapper.insertBatch(rawGoodsDOS);
|
|
||||||
orderBodyMapper.insertBatch(orderBodyDOS);
|
for (int i = 0; i < rawGoodsDOS.size(); i += 1000) {
|
||||||
orderGroupMapper.insertBatch(orderGroupDOS);
|
rawGoodsMapper.insertBatch(rawGoodsDOS.stream().skip(i).limit(1000).collect(Collectors.toList()));
|
||||||
orderPartsMapper.insertBatch(orderPartsDOS);
|
}
|
||||||
plateMapper.insertBatch(plateDOS);
|
for (int i = 0; i < orderBodyDOS.size(); i += 1000) {
|
||||||
orderModuleExtraMapper.insertBatch(orderModuleExtraDOS);
|
orderBodyMapper.insertBatch(orderBodyDOS.stream().skip(i).limit(1000).collect(Collectors.toList()));
|
||||||
orderItemMapper.insertBatch(itemDOS);
|
}
|
||||||
|
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 {
|
try {
|
||||||
BulkResponse bulkResponse = esDocumentService.bulkCreate(ORDER_PLATE_MODEL, orderModelDOs);
|
BulkResponse bulkResponse = esDocumentService.bulkCreate(ORDER_PLATE_MODEL, orderModelDOs);
|
||||||
boolean errors = bulkResponse.errors();
|
boolean errors = bulkResponse.errors();
|
||||||
if(errors) {
|
if (errors) {
|
||||||
log.error(bulkResponse.items().toString());
|
log.error(bulkResponse.items().toString());
|
||||||
throw new ServiceException(500,"未知异常");
|
throw new ServiceException(500, "未知异常");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user