学 赵 1 year ago
parent
commit
75747dfd12
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js
  2. 10
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js
  3. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/router/business.js
  4. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js
  5. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  6. 32
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs
  7. 2
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/_options.js

@ -49,7 +49,7 @@ const transType = {
const deliverBillType = { const deliverBillType = {
title: "发运主类型", title: "发运主类型",
type: "string", type: "number",
input: "select", input: "select",
options: [ options: [
{ value: 0, label: "无" }, { value: 0, label: "无" },

10
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/models/vmi/vmi.js

@ -30,12 +30,12 @@ function useSchema() {
title: "数量", title: "数量",
type: "string", type: "string",
input: "number", input: "number",
rules: [
{
required: true,
},
],
}, },
rules: [
{
required: true,
},
],
billTime: { billTime: {
title: "发运日期", title: "发运日期",
type: "string", type: "string",

2
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", component: "/settle/inventory",
children: [ children: [
createButton("query", "title=查询&isTop=true"), createButton("query", "title=查询&isTop=true"),
createButton("compare", "title=扣减审核通过&isTop=true"), createButton("approval", "title=扣减审核通过&isTop=true"),
createButton("export", "title=导出&isTop=true&pattern=paged"), createButton("export", "title=导出&isTop=true&pattern=paged"),
], ],
}; };

2
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/inventory.js

@ -26,7 +26,7 @@ export default {
: item.path === "reject" : item.path === "reject"
? `确认退回选中的${rows.length}行数据吗?` ? `确认退回选中的${rows.length}行数据吗?`
: `确认选中的${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; 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); await appListRef.value.onClick(async () => await request(url, data, { method: "POST" }), message, true);
} }

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -113,7 +113,6 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
db.Set<VmiSnapshot>().Add(snapshot); db.Set<VmiSnapshot>().Add(snapshot);
db.SaveChanges(); db.SaveChanges();
db.Database.ExecuteSqlRaw($"select * into {table} from Set_VmiBalance;"); 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);"); db.Database.ExecuteSqlRaw($"alter table {table} add constraint PK_{table} primary key (Id);");
snapshot.End = DateTime.Now; snapshot.End = DateTime.Now;
transaction.Commit(); transaction.Commit();
@ -388,7 +387,7 @@ public class VmiAppService : Controller, IApplicationService, IJobService, ITran
var file = files.FirstOrDefault(); var file = files.FirstOrDefault();
await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false); await file.OpenReadStream().CopyToAsync(ms).ConfigureAwait(false);
var data = ms.ToArray(); var data = ms.ToArray();
var tupleList = this.ImportInternal<VmiLog>(data).Where(o => o.Item2.Count == 0).ToList(); var tupleList = this.ImportInternal<VmiLog>(data);
if (tupleList.Any(o => o.Item2.Count > 0)) if (tupleList.Any(o => o.Item2.Count > 0))
{ {
using var workbook = new XLWorkbook(new MemoryStream(data)); using var workbook = new XLWorkbook(new MemoryStream(data));

32
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;
using System.Threading.Tasks; using System.Threading.Tasks;
using EFCore.BulkExtensions; using EFCore.BulkExtensions;
using LinqToDB.EntityFrameworkCore;
using Magicodes.ExporterAndImporter.Core.Extension; using Magicodes.ExporterAndImporter.Core.Extension;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -30,12 +31,13 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
{ {
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly ILogger<VmiAsyncBalanceService> _logger; private readonly ILogger<VmiAsyncBalanceService> _logger;
private static SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1); private static readonly SemaphoreSlim semaphoreSlim = new SemaphoreSlim(1, 1);
public VmiAsyncBalanceService(IServiceProvider serviceProvider, ILogger<VmiAsyncBalanceService> logger) public VmiAsyncBalanceService(IServiceProvider serviceProvider, ILogger<VmiAsyncBalanceService> logger)
{ {
this._serviceProvider = serviceProvider; this._serviceProvider = serviceProvider;
this._logger = logger; this._logger = logger;
LinqToDBForEFTools.Initialize();
} }
/// <summary> /// <summary>
@ -66,7 +68,7 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
private async Task InvokeInternal(IServiceProvider serviceProvider) private async Task InvokeInternal(IServiceProvider serviceProvider)
{ {
var batchSize = 1000; var batchSize = 10000;
var fetchSize = 0; var fetchSize = 0;
var connectionString = serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService"); var connectionString = serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
for (var i = 0; i < 1000; i++) 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.CommandText = $"select * into {table} from Set_VmiLog where 1=0;";
command.ExecuteNonQuery(); 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.CommandText = $"alter table {table} add constraint PK_{table} primary key (Id);";
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
@ -231,15 +231,12 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
} }
//更新事务分表 //更新事务分表
//foreach (var item in tables) foreach (var item in tables)
//{ {
// var logs = list.Where(o => o.Table == item).Select(o => o.Log).ToList(); 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);
// await context.BulkInsertAsync(logs, new BulkConfig await context.BulkCopyAsync(new LinqToDB.Data.BulkCopyOptions { TableName = item }, logs).ConfigureAwait(false);
// { }
// CustomDestinationTableName = item,
// }).ConfigureAwait(false);
//}
//批量更新消息 //批量更新消息
await context.BulkUpdateAsync(messages, new BulkConfig await context.BulkUpdateAsync(messages, new BulkConfig
{ {
@ -248,19 +245,10 @@ public class VmiAsyncBalanceService : Controller, IApplicationService, IJobServi
//批量插入负库存补货记录 //批量插入负库存补货记录
await context.BulkInsertAsync(vmiReplenishedList).ConfigureAwait(false); 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); 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); 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); await context.BulkDeleteAsync(balanceList.Where(o => o.Item2 == 2 && o.Item1.Qty == decimal.Zero).Select(o => o.Item1).ToList()).ConfigureAwait(false);
transaction.Commit(); transaction.Commit();
} }

2
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

@ -1334,7 +1334,7 @@ namespace Win.Sfs.SettleAccount
b.ConfigureByConvention(); b.ConfigureByConvention();
b.Property(o => o.ChangedTime).HasDefaultValueSql("getdate()").ValueGeneratedOnAdd().Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); 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.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); b.Property(o => o.RealPartCode).HasMaxLength(50);
}); });

Loading…
Cancel
Save