Browse Source

update

master
wanggang 1 year ago
parent
commit
85c9585ef7
  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. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  4. 32
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAsyncBalanceService.cs
  5. 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 = {
title: "发运主类型",
type: "string",
type: "number",
input: "select",
options: [
{ value: 0, label: "无" },

10
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",

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.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<VmiLog>(data).Where(o => o.Item2.Count == 0).ToList();
var tupleList = this.ImportInternal<VmiLog>(data);
if (tupleList.Any(o => o.Item2.Count > 0))
{
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.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<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)
{
this._serviceProvider = serviceProvider;
this._logger = logger;
LinqToDBForEFTools.Initialize();
}
/// <summary>
@ -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<IConfiguration>().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();
}

2
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);
});

Loading…
Cancel
Save