diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js index 431d1dcc..b91785ba 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js @@ -17,7 +17,7 @@ export default { const url = config.edit.addUrl; if (item.path === "add") { const invbillNum = rows[0].billNum; - await appListRef.value.onClick(async () => await request(url, { invbillNum }, { method: "POST" }, true), `确认为${invbillNum}创建发票?`, true); + await appListRef.value.onClick(async () => await request(url, invbillNum, { method: "POST" }, true), `确认为${invbillNum}创建发票?`, true); } }; return { appListRef, config, onCommand }; diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs index de58062b..089f72f0 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs @@ -9,6 +9,7 @@ using System.Reflection; using System.Threading; using System.Threading.Tasks; using ClosedXML.Excel; +using LinqToDB.Data; using LinqToDB.EntityFrameworkCore; using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core.Extension; @@ -72,6 +73,40 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen LinqToDBForEFTools.Initialize(); } + [HttpPost] + public async Task Test(List logs, int size = 1000) + { + using var scope = this._serviceProvider.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + using var dc = db.CreateLinqToDBConnection(); + dc.BeginTransaction(); + try + { + //var skip = 0; + //var count = logs.Count; + //while (count > 0) + //{ + // var batchSize = count > size ? size : count; + // var tempLogs = logs.Skip(skip).Take(batchSize); + // var tempMessages = tempLogs.Select(o => new VmiMessage { Message = JsonSerializer.Serialize(o) }); + // await dc.BulkCopyAsync(new BulkCopyOptions { TableName = "Set_VmiLog" }, tempLogs).ConfigureAwait(false); + // await dc.BulkCopyAsync(new BulkCopyOptions { TableName = "Set_VmiMessage" }, tempMessages).ConfigureAwait(false); + // count -= batchSize; + // skip += batchSize; + //} + await dc.BulkCopyAsync(new BulkCopyOptions { TableName = "Set_VmiMessage", MaxBatchSize = 1 }, new List { + new VmiMessage(Guid.NewGuid()) { Message="1" }, + new VmiMessage(Guid.NewGuid()) { Message="2" } + }).ConfigureAwait(false); + dc.Transaction.Commit(); + } + catch + { + dc.Transaction.Rollback(); + throw; + } + } + /// /// Excel 转 JSON /// @@ -125,11 +160,12 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen using var transaction = db.Database.BeginTransaction(); try { - var table = $"Set_VmiBalance_{DateTime.Now.ToString("yyyy_mm_dd_hh_mm_ss")}"; + var time = DateTime.Now.ToString("yyyy_mm_dd_hh_mm_ss"); + var table = $"Set_VmiBalance_{time}"; var snapshot = db.Set().Where(o => o.Name == table).FirstOrDefault(); if (snapshot == null) { - snapshot = new VmiSnapshot { Name = table, Path = table }; + snapshot = new VmiSnapshot { Name = time, Path = table }; db.Set().Add(snapshot); db.SaveChanges(); var result = db.Database.ExecuteSqlRaw($"select * into {table} from Set_VmiBalance;"); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs index 06590a3a..84bc8953 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs @@ -8,15 +8,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi; /// /// 寄售库存操作记录 /// -public class VmiLog : BasicAggregateRoot +public class VmiLog : Entity { public VmiLog() { } - public VmiLog(Guid id) + public VmiLog(Guid id):base(id) { - this.Id = id; } [Display(Name = "库存事务分类", Order = 0)]