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);
|
||||
plateDOS.add(plateDO);
|
||||
orderModelDOS.add(
|
||||
OrderModelDO.builder()
|
||||
.orderId(orderId)
|
||||
.plateId(plateDO.getId())
|
||||
.contourDetail(e.getContourDetail())
|
||||
.pointDetail(e.getPointDetail())
|
||||
.holeDetail(e.getHoleDetail())
|
||||
.rawPointDetail(e.getRawPointDetail())
|
||||
.sideHoleDetail(e.getSideHoleDetail())
|
||||
.sideModelDetail(e.getSideModelDetail())
|
||||
.build());
|
||||
OrderModelDO.builder()
|
||||
.orderId(orderId)
|
||||
.plateId(plateDO.getId())
|
||||
.contourDetail(e.getContourDetail())
|
||||
.pointDetail(e.getPointDetail())
|
||||
.holeDetail(e.getHoleDetail())
|
||||
.rawPointDetail(e.getRawPointDetail())
|
||||
.sideHoleDetail(e.getSideHoleDetail())
|
||||
.sideModelDetail(e.getSideModelDetail())
|
||||
.build());
|
||||
} else {
|
||||
OrderPartsDO orderPartsDO = OrderPartsDO.builder()
|
||||
.id(identifierGenerator.nextId(null).longValue())
|
||||
@@ -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