Browse Source

update

master
wanggang 1 year ago
parent
commit
0bad3839cd
  1. 2
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/wwwroot/views/settle/usable.js
  2. 40
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  3. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs

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

@ -17,7 +17,7 @@ export default {
const url = config.edit.addUrl; const url = config.edit.addUrl;
if (item.path === "add") { if (item.path === "add") {
const invbillNum = rows[0].billNum; 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 }; return { appListRef, config, onCommand };

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

@ -9,6 +9,7 @@ using System.Reflection;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using ClosedXML.Excel; using ClosedXML.Excel;
using LinqToDB.Data;
using LinqToDB.EntityFrameworkCore; using LinqToDB.EntityFrameworkCore;
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core.Extension; using Magicodes.ExporterAndImporter.Core.Extension;
@ -72,6 +73,40 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
LinqToDBForEFTools.Initialize(); LinqToDBForEFTools.Initialize();
} }
[HttpPost]
public async Task Test(List<VmiLog> logs, int size = 1000)
{
using var scope = this._serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
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<VmiMessage> {
new VmiMessage(Guid.NewGuid()) { Message="1" },
new VmiMessage(Guid.NewGuid()) { Message="2" }
}).ConfigureAwait(false);
dc.Transaction.Commit();
}
catch
{
dc.Transaction.Rollback();
throw;
}
}
/// <summary> /// <summary>
/// Excel 转 JSON /// Excel 转 JSON
/// </summary> /// </summary>
@ -125,11 +160,12 @@ public class VmiAppService : ApplicationService, IJobService, ITransientDependen
using var transaction = db.Database.BeginTransaction(); using var transaction = db.Database.BeginTransaction();
try 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<VmiSnapshot>().Where(o => o.Name == table).FirstOrDefault(); var snapshot = db.Set<VmiSnapshot>().Where(o => o.Name == table).FirstOrDefault();
if (snapshot == null) if (snapshot == null)
{ {
snapshot = new VmiSnapshot { Name = table, Path = table }; snapshot = new VmiSnapshot { Name = time, Path = table };
db.Set<VmiSnapshot>().Add(snapshot); db.Set<VmiSnapshot>().Add(snapshot);
db.SaveChanges(); db.SaveChanges();
var result = db.Database.ExecuteSqlRaw($"select * into {table} from Set_VmiBalance;"); var result = db.Database.ExecuteSqlRaw($"select * into {table} from Set_VmiBalance;");

5
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs

@ -8,15 +8,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi;
/// <summary> /// <summary>
/// 寄售库存操作记录 /// 寄售库存操作记录
/// </summary> /// </summary>
public class VmiLog : BasicAggregateRoot<Guid> public class VmiLog : Entity<Guid>
{ {
public VmiLog() public VmiLog()
{ {
} }
public VmiLog(Guid id) public VmiLog(Guid id):base(id)
{ {
this.Id = id;
} }
[Display(Name = "库存事务分类", Order = 0)] [Display(Name = "库存事务分类", Order = 0)]

Loading…
Cancel
Save