导入功能优化不同数据量插入语句

This commit is contained in:
FanLian
2023-09-08 08:18:50 +08:00
parent 86e981835f
commit 7f7234edb1
3 changed files with 49 additions and 6 deletions

View File

@@ -10,6 +10,7 @@ using JNPF.FriendlyException;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDev;
using Mapster;
using NPOI.SS.Formula;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
@@ -80,6 +81,20 @@ namespace Tnb.WarehouseMgr
x.modify_id = null;
x.modify_time = null;
});
if (points.Count > 1000)
{
await _db.Fastest<WmsPointH>().BulkCopyAsync(points);
}
else if (points.Count > 400)
{
_db.Utilities.PageEach(points, 100, async pageList => {
await _db.Insertable(pageList).ExecuteCommandAsync();
});
}
else
{
row = await _db.Insertable(points).ExecuteCommandAsync();
}
row = await _db.Insertable(points).ExecuteCommandAsync();
}
catch (Exception ex)