From 85c9585ef7423fd596389c3d6ca26981839519db Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Sat, 2 Sep 2023 16:24:19 +0800 Subject: [PATCH 1/2] update --- .../wwwroot/models/_options.js | 2 +- .../wwwroot/models/vmi/vmi.js | 10 +++--- .../Entities/BQ/VmiAppService.cs | 3 +- .../Entities/BQ/VmiAsyncBalanceService.cs | 32 ++++++------------- ...AccountDbContextModelCreatingExtensions.cs | 2 +- 5 files changed, 18 insertions(+), 31 deletions(-) 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); }); From 14ee8156f4e7ba63c91a8bc21f69a14f3a7c7924 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Sat, 2 Sep 2023 16:48:09 +0800 Subject: [PATCH 2/2] update --- .../host/SettleAccount.HttpApi.Host/wwwroot/router/business.js | 2 +- .../wwwroot/views/settle/inventory.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js index 34436ccb..5b690d69 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js @@ -121,7 +121,7 @@ function createVmiOutCheckList(path, business, client, title = "寄售库库存 component: "/settle/inventory", children: [ createButton("query", "title=查询&isTop=true"), - createButton("compare", "title=扣减审核通过&isTop=true"), + createButton("approval", "title=扣减审核通过&isTop=true"), createButton("export", "title=导出&isTop=true&pattern=paged"), ], }; diff --git a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js index 1567947e..ad8cdf2a 100644 --- a/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js +++ b/code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js @@ -26,7 +26,7 @@ export default { : item.path === "reject" ? `确认退回选中的${rows.length}行数据吗?` : `确认选中的${rows.length}行数据客户已收票吗?`; - const data = item.path === "approval" ? rows.map((o) => o.invbillNum) : item.path === "reject" ? rows[0]["invGroupNum"] : rows.map((o) => o.invbillNum); + const data = item.path === "approval" ? rows.map((o) => o.billNum) : item.path === "reject" ? rows[0]["invGroupNum"] : rows.map((o) => o.invbillNum); const url = item.path === "approval" ? config.edit.approvalUrl : item.path === "reject" ? config.edit.rejectUrl : config.edit.receivedUrl; await appListRef.value.onClick(async () => await request(url, data, { method: "POST" }), message, true); }