diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js index ac2a6a15..d4216156 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js @@ -49,7 +49,7 @@ const transType = { const deliverBillType = { title: "发运主类型", - type: "string", + type: "number", input: "select", options: [ { value: 0, label: "无" }, diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js index dfdc4206..a6eb138c 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js @@ -30,12 +30,12 @@ function useSchema() { title: "数量", type: "string", input: "number", + rules: [ + { + required: true, + }, + ], }, - rules: [ - { - required: true, - }, - ], billTime: { title: "发运日期", type: "string", 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 e5790713..2c8bc2ff 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 @@ -113,7 +113,6 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran db.Set().Add(snapshot); db.SaveChanges(); db.Database.ExecuteSqlRaw($"select * into {table} from Set_VmiBalance;"); - db.Database.ExecuteSqlRaw($"create clustered index IX_{table}_BillTime on {table} (Id)"); db.Database.ExecuteSqlRaw($"alter table {table} add constraint PK_{table} primary key (Id);"); snapshot.End = DateTime.Now; transaction.Commit(); @@ -388,7 +387,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran var file = files.FirstOrDefault(); await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); var data = ms.ToArray(); - var tupleList = this.ImportInternal(data).Where(o => o.Item2.Count == 0).ToList(); + var tupleList = this.ImportInternal(data); if (tupleList.Any(o => o.Item2.Count > 0)) { using var workbook = new XLWorkbook(new MemoryStream(data)); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs index e348cb00..3e792ab2 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs @@ -7,6 +7,7 @@ using System.Text.Json; using System.Threading; using System.Threading.Tasks; using EFCore.BulkExtensions; +using LinqToDB.EntityFrameworkCore; using Magicodes.ExporterAndImporter.Core.Extension; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -30,12 +31,13 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi { private readonly IServiceProvider _serviceProvider; private readonly ILogger _logger; - private static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1); + private static readonly SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1); public VmiAsyncBalanceService(IServiceProvider serviceProvider, ILogger logger) { this._serviceProvider = serviceProvider; this._logger = logger; + LinqToDBForEFTools.Initialize(); } /// @@ -66,7 +68,7 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi private async Task InvokeInternal(IServiceProvider serviceProvider) { - var batchSize = 1000; + var batchSize = 10000; var fetchSize = 0; var connectionString = serviceProvider.GetRequiredService().GetConnectionString("SettleAccountService"); for (var i = 0; i < 1000; i++) @@ -121,8 +123,6 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi { command.CommandText = $"select * into {table} from Set_VmiLog where 1=0;"; command.ExecuteNonQuery(); - command.CommandText = $"create clustered index IX_{table}_ChangedTime on {table} (ChangedTime);"; - command.ExecuteNonQuery(); command.CommandText = $"alter table {table} add constraint PK_{table} primary key (Id);"; command.ExecuteNonQuery(); } @@ -231,15 +231,12 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi } //更新事务分表 - //foreach (var item in tables) - //{ - // var logs = list.Where(o => o.Table == item).Select(o => o.Log).ToList(); - // var xxx= logs.Select(o=>o.Id).Distinct().ToList(); - // await context.BulkInsertAsync(logs, new BulkConfig - // { - // CustomDestinationTableName = item, - // }).ConfigureAwait(false); - //} + foreach (var item in tables) + { + var logs = list.Where(o => o.Table == item).Select(o => o.Log).ToList(); + //await context.BulkInsertAsync(logs, new BulkConfig { CustomDestinationTableName = item, }).ConfigureAwait(false); + await context.BulkCopyAsync(new LinqToDB.Data.BulkCopyOptions { TableName = item }, logs).ConfigureAwait(false); + } //批量更新消息 await context.BulkUpdateAsync(messages, new BulkConfig { @@ -248,19 +245,10 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi //批量插入负库存补货记录 await context.BulkInsertAsync(vmiReplenishedList).ConfigureAwait(false); //批量插入库存余额 - var addList = balanceList.Where(o => o.Item2 == 1 && o.Item1.Qty != decimal.Zero).Select(o => o.Item1).ToList(); - var test0 = addList.Count; - var test1 = addList.Select(o => o.Id).Distinct().Count(); await context.BulkInsertAsync(balanceList.Where(o => o.Item2 == 1 && o.Item1.Qty != decimal.Zero).Select(o => o.Item1).ToList()).ConfigureAwait(false); //批量更新库存余额 - var updateList = balanceList.Where(o => o.Item2 == 2 && o.Item1.Qty != decimal.Zero).Select(o => o.Item1).ToList(); - var test20 = updateList.Count; - var test21 = updateList.Select(o => o.Id).Distinct().Count(); await context.BulkUpdateAsync(balanceList.Where(o => o.Item2 == 2 && o.Item1.Qty != decimal.Zero).Select(o => o.Item1).ToList()).ConfigureAwait(false); //批量删除库存余额 - var deleteList = balanceList.Where(o => o.Item2 == 2 && o.Item1.Qty == decimal.Zero).Select(o => o.Item1).ToList(); - var test30 = addList.Count; - var test31 = addList.Select(o => o.Id).Distinct().Count(); await context.BulkDeleteAsync(balanceList.Where(o => o.Item2 == 2 && o.Item1.Qty == decimal.Zero).Select(o => o.Item1).ToList()).ConfigureAwait(false); transaction.Commit(); } diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs index eb86e8c8..ff8d2d72 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs @@ -1334,7 +1334,7 @@ namespace Win.Sfs.SettleAccount b.ConfigureByConvention(); b.Property(o => o.ChangedTime).HasDefaultValueSql("getdate()").ValueGeneratedOnAdd().Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); b.Property(o => o.CreatedTime).HasDefaultValueSql("getdate()").ValueGeneratedOnAdd().Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); - b.Property(o => o.UpdatedTime).HasDefaultValueSql("getdate()").ValueGeneratedOnAddOrUpdate().Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); + //b.Property(o => o.UpdatedTime).HasDefaultValueSql("getdate()").ValueGeneratedOnAddOrUpdate().Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); b.Property(o => o.RealPartCode).HasMaxLength(50); });