Browse Source

寄售库库存候选键改为唯一索引,添加快照备份锁,添加出入库重试

master
wanggang 1 year ago
parent
commit
43b0027cc6
  1. 229
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  2. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj
  3. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiBalance.cs
  4. 17
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  5. 5349
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230809035500_vmi11.Designer.cs
  6. 186
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230809035500_vmi11.cs
  7. 28
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

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

@ -6,6 +6,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using System.Reflection; using System.Reflection;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using ClosedXML.Excel; using ClosedXML.Excel;
using LinqToDB.Data; using LinqToDB.Data;
@ -23,7 +24,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Extensions;
using Omu.ValueInjecter; using Omu.ValueInjecter;
using SettleAccount.Domain.BQ; using Polly;
using SettleAccount.Job.SignalR; using SettleAccount.Job.SignalR;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
@ -55,6 +56,7 @@ public interface IVmiService : IApplicationService, ITransientDependency, IJobSe
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class VmiAppService : ApplicationService, IVmiService, IJobService, ITransientDependency public class VmiAppService : ApplicationService, IVmiService, IJobService, ITransientDependency
{ {
public static SemaphoreSlim backupLock = new SemaphoreSlim(1);
private readonly IConfiguration _cfg; private readonly IConfiguration _cfg;
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly INormalEfCoreRepository<VmiBalance, Guid> _balanceRepository; private readonly INormalEfCoreRepository<VmiBalance, Guid> _balanceRepository;
@ -130,48 +132,60 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
/// </summary> /// </summary>
[NonAction] [NonAction]
[DisableValidation] [DisableValidation]
public virtual Task Invoke(IServiceProvider serviceProvider) public virtual async Task Invoke(IServiceProvider serviceProvider)
{ {
//this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", ""); await backupLock.WaitAsync().ConfigureAwait(false);
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi")); try
var date = DateTime.Now.ToString("yyyyMMddHHmmss");
var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db";
using var dbContext = new VmiSqliteContext(connectionString);
if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated())
{ {
var query = serviceProvider.GetRequiredService<SettleAccountDbContext>().Set<VmiBalance>().AsNoTracking(); //this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", "");
var list = new List<VmiBalance>(); Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/files/vmi"));
using var dc = dbContext.CreateLinqToDBConnection(); var date = DateTime.Now.ToString("yyyyMMddHHmmss");
dc.BeginTransaction(); var connectionString = $"Data Source=wwwroot/files/vmi/{date}.db";
try using var dbContext = new VmiSqliteContext(connectionString);
if (!dbContext.GetService<IRelationalDatabaseCreator>().Exists() && dbContext.Database.EnsureCreated())
{ {
foreach (var item in query) var query = serviceProvider.GetRequiredService<SettleAccountDbContext>().Set<VmiBalance>().AsNoTracking();
var list = new List<VmiBalance>();
using var dc = dbContext.CreateLinqToDBConnection();
dc.BeginTransaction();
try
{ {
item.BackupTime = DateTime.Now; var now = DateTime.Now;
list.Add(item); var table = "VmiBalance";
if (list.Count == 10000) foreach (var item in query)
{
item.BackupTime = now;
list.Add(item);
if (list.Count == 10000)
{
//dbContext.Set<VmiBalance>().AddRange(list);
await dc.BulkCopyAsync(new BulkCopyOptions { TableName = table }, list).ConfigureAwait(false);
list.Clear();
}
}
if (list.Count > 0)
{ {
//dbContext.Set<VmiBalance>().AddRange(list); await dc.BulkCopyAsync(new BulkCopyOptions { TableName = table }, list).ConfigureAwait(false);
dc.BulkCopy(new BulkCopyOptions { TableName = "VmiBalance" }, list);
list.Clear();
} }
dc.Transaction.Commit();
var snapshot = new VmiSnapshot { Name = date, Path = connectionString };
await _snapshotRepository.InsertAsync(snapshot).ConfigureAwait(false);
} }
if (list.Count > 0) catch
{ {
dc.BulkCopy(new BulkCopyOptions { TableName = "VmiBalance" }, list); dc.Transaction.Rollback();
throw;
} }
dc.Transaction.Commit();
var snapshot = new VmiSnapshot { Name = date, Path = connectionString };
this._snapshotRepository.InsertAsync(snapshot).Wait();
}
catch
{
dc.Transaction.Rollback();
throw;
} }
} }
//this._hubContext.Clients.All.ServerToClient("JobItem", "refresh", ""); catch
return Task.CompletedTask; {
throw;
}
finally
{
backupLock.Release();
}
} }
/// <summary> /// <summary>
@ -191,58 +205,63 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
/// <summary> /// <summary>
/// 发运入库\反结入库\调整入库 /// 发运入库\反结入库\调整入库
/// </summary> /// </summary>
/// <param name="logType"></param> /// <param name="logType">库存事务类型</param>
/// <param name="changedNumber"></param> /// <param name="changedNumber">关联单号</param>
/// <param name="data"></param> /// <param name="data">入库数据</param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task In(VmiLogType logType, string changedNumber, VmiBalance data) public async Task In(VmiLogType logType, string changedNumber, VmiBalance data)
{ {
var balance = this._balanceRepository.FirstOrDefault(o => o.BillType == data.BillType && await Policy.Handle<Exception>().WaitAndRetryAsync(5, o => TimeSpan.FromSeconds(o), (e, i) =>
{
Console.WriteLine($"入库类型:{logType.GetDisplayName()},重试次数:{i},异常信息:{e.Message}");
}).ExecuteAsync(async () =>
{
using var scope = _serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
var balance = db.Set<VmiBalance>().FirstOrDefault(o => o.BillType == data.BillType &&
o.PartCode == data.PartCode && o.PartCode == data.PartCode &&
o.VinCode == data.VinCode && o.VinCode == data.VinCode &&
o.ErpToLoc == data.ErpToLoc && o.ErpToLoc == data.ErpToLoc &&
o.OrderNum == data.OrderNum); o.OrderNum == data.OrderNum);
var log = new VmiLog var log = new VmiLog
{
LogType = logType,
ChangedType = VmiType.In,
ChangedNumber = changedNumber,
ChangedTime = DateTime.Now,
ChangedBy = _currentUser.UserName,
ChangedQty = data.Qty,
};
log.InjectFrom(data);
if (balance == null)
{
balance = new VmiBalance();
balance.InjectFrom(data);
// 初始化库存
balance.Qty = data.Qty;
balance.SetId();
await _balanceRepository.InsertAsync(balance).ConfigureAwait(false);
}
else
{
var qty = balance.Qty + data.Qty;
balance.InjectFrom(data);
// 加库存
balance.Qty = qty;
if (balance.Qty == decimal.Zero)
{ {
await this._balanceRepository.DeleteAsync(balance).ConfigureAwait(false); LogType = logType,
} ChangedType = VmiType.In,
else ChangedNumber = changedNumber,
ChangedTime = DateTime.Now,
ChangedBy = _currentUser.UserName,
ChangedQty = data.Qty,
};
log.InjectFrom(data);
if (balance == null)
{ {
await this._balanceRepository.UpdateAsync(balance).ConfigureAwait(false); balance = new VmiBalance(GuidGenerator.Create());
balance.InjectFrom(data);
// 初始化库存
balance.Qty = data.Qty;
balance.SetId(GuidGenerator.Create());
await db.Set<VmiBalance>().AddAsync(balance).ConfigureAwait(false);
} }
if (logType == VmiLogType.Type100 && balance.Qty < decimal.Zero && data.Qty > 0) else
{ {
log.IsReplenished = true; var qty = balance.Qty + data.Qty;
balance.InjectFrom(data);
// 加库存
balance.Qty = qty;
if (balance.Qty == decimal.Zero)
{
db.Set<VmiBalance>().Remove(balance);
}
if (logType == VmiLogType.Type100 && balance.Qty < decimal.Zero && data.Qty > 0)
{
log.IsReplenished = true;
}
} }
} await db.Set<VmiLog>().AddAsync(log).ConfigureAwait(false);
await _logRepository.InsertAsync(log).ConfigureAwait(false); await db.SaveChangesAsync().ConfigureAwait(false);
}).ConfigureAwait(false);
} }
/// <summary> /// <summary>
@ -255,48 +274,48 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
[HttpPost] [HttpPost]
public async Task Out(VmiLogType logType, string changedNumber, VmiLog data) public async Task Out(VmiLogType logType, string changedNumber, VmiLog data)
{ {
var balance = this._balanceRepository.FirstOrDefault(o => o.BillType == data.BillType && await Policy.Handle<Exception>().WaitAndRetryAsync(5, o => TimeSpan.FromSeconds(o), (e, i) =>
o.PartCode == data.PartCode &&
o.VinCode == data.VinCode &&
o.ErpToLoc == data.ErpToLoc &&
o.OrderNum == data.OrderNum);
var log = new VmiLog
{ {
LogType = logType, Console.WriteLine($"出库类型:{logType.GetDisplayName()},重试次数:{i},异常信息:{e.Message}");
ChangedType = VmiType.Out, }).ExecuteAsync(async () =>
ChangedNumber = changedNumber,
};
log.InjectFrom(data);
log.LogType = logType;
log.ChangedType = VmiType.Out;
log.ChangedTime = DateTime.Now;
log.ChangedBy = _currentUser.UserName;
log.ChangedQty = data.Qty;
if (balance == null)
{ {
balance = new VmiBalance(); using var scope = _serviceProvider.CreateScope();
balance.InjectFrom(data); var db = scope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
// 负库存 var balance = db.Set<VmiBalance>().FirstOrDefault(o => o.BillType == data.BillType && o.PartCode == data.PartCode && o.VinCode == data.VinCode && o.ErpToLoc == data.ErpToLoc && o.OrderNum == data.OrderNum);
balance.Qty = -data.Qty; var log = new VmiLog
balance.SetId();
await _balanceRepository.InsertAsync(balance).ConfigureAwait(false);
}
else
{
// 减库存
balance.Qty -= data.Qty; ;
if (balance.Qty == decimal.Zero)
{ {
await this._balanceRepository.DeleteAsync(balance).ConfigureAwait(false); LogType = logType,
ChangedType = VmiType.Out,
ChangedNumber = changedNumber,
};
log.InjectFrom(data);
log.LogType = logType;
log.ChangedType = VmiType.Out;
log.ChangedTime = DateTime.Now;
log.ChangedBy = _currentUser.UserName;
log.ChangedQty = data.Qty;
if (balance == null)
{
balance = new VmiBalance();
balance.InjectFrom(data);
// 负库存
balance.Qty = -data.Qty;
balance.SetId(GuidGenerator.Create());
await db.Set<VmiBalance>().AddAsync(balance).ConfigureAwait(false);
} }
else else
{ {
await this._balanceRepository.UpdateAsync(balance).ConfigureAwait(false); // 减库存
balance.Qty -= data.Qty; ;
if (balance.Qty == decimal.Zero)
{
db.Set<VmiBalance>().Remove(balance);
}
} }
} await db.Set<VmiLog>().AddAsync(log).ConfigureAwait(false);
await _logRepository.InsertAsync(log).ConfigureAwait(false); await db.SaveChangesAsync().ConfigureAwait(false);
}).ConfigureAwait(false);
} }
/// <summary> /// <summary>

1
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj

@ -126,6 +126,7 @@
<PackageReference Include="InfluxDB.LineProtocol" Version="1.1.1" /> <PackageReference Include="InfluxDB.LineProtocol" Version="1.1.1" />
<PackageReference Include="linq2db.EntityFrameworkCore" Version="5.17.0" /> <PackageReference Include="linq2db.EntityFrameworkCore" Version="5.17.0" />
<PackageReference Include="NPOI" Version="2.5.4" /> <PackageReference Include="NPOI" Version="2.5.4" />
<PackageReference Include="Polly" Version="7.2.4" />
<PackageReference Include="Riven.CodeArts.Db.Influx17x" Version="0.1.0" /> <PackageReference Include="Riven.CodeArts.Db.Influx17x" Version="0.1.0" />
<PackageReference Include="Shouldly" Version="4.0.3" /> <PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.94" /> <PackageReference Include="SqlSugarCore" Version="5.1.4.94" />

7
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiBalance.cs

@ -18,6 +18,11 @@ public class VmiBalance : BasicAggregateRoot<Guid>, IHasConcurrencyStamp
ConcurrencyStamp = Guid.NewGuid().ToString("N"); ConcurrencyStamp = Guid.NewGuid().ToString("N");
} }
public VmiBalance(Guid id) : base(id)
{
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}
/// <summary> /// <summary>
/// LU零件号 /// LU零件号
/// </summary> /// </summary>
@ -87,7 +92,7 @@ public class VmiBalance : BasicAggregateRoot<Guid>, IHasConcurrencyStamp
public string ConcurrencyStamp { get; set; } public string ConcurrencyStamp { get; set; }
public DateTime? BackupTime { get; set; } public DateTime? BackupTime { get; set; }
public VmiBalance SetId() public VmiBalance SetId(Guid guid)
{ {
var data = new { BillType, PartCode, VinCode, ErpToLoc, OrderNum }; var data = new { BillType, PartCode, VinCode, ErpToLoc, OrderNum };
var json = JsonSerializer.Serialize(data); var json = JsonSerializer.Serialize(data);

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

@ -1,5 +1,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling; using Volo.Abp.EntityFrameworkCore.Modeling;
@ -1212,12 +1213,11 @@ namespace Win.Sfs.SettleAccount
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50); b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
}); });
} }
private static void ConfigureBBAC_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) private static void ConfigureBBAC_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{ {
builder.Entity<BBAC_PD>(b => builder.Entity<BBAC_PD>(b =>
{ {
b.ToTable($"{options.TablePrefix}_BBAC_PD", options.Schema); b.ToTable($"{options.TablePrefix}_BBAC_PD", options.Schema);
b.ConfigureByConvention(); b.ConfigureByConvention();
@ -1231,10 +1231,8 @@ namespace Win.Sfs.SettleAccount
private static void ConfigureHBPO_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) private static void ConfigureHBPO_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{ {
builder.Entity<HBPO_PD>(b => builder.Entity<HBPO_PD>(b =>
{ {
b.ToTable($"{options.TablePrefix}_HBPO_PD", options.Schema); b.ToTable($"{options.TablePrefix}_HBPO_PD", options.Schema);
b.ConfigureByConvention(); b.ConfigureByConvention();
@ -1245,12 +1243,11 @@ namespace Win.Sfs.SettleAccount
b.Property(x => x.ConcurrencyStamp).HasMaxLength(50); b.Property(x => x.ConcurrencyStamp).HasMaxLength(50);
}); });
} }
private static void ConfigurePUB_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) private static void ConfigurePUB_PD(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{ {
builder.Entity<PUB_PD>(b => builder.Entity<PUB_PD>(b =>
{ {
b.ToTable($"{options.TablePrefix}_PUB_PD", options.Schema); b.ToTable($"{options.TablePrefix}_PUB_PD", options.Schema);
b.ConfigureByConvention(); b.ConfigureByConvention();
@ -1262,8 +1259,6 @@ namespace Win.Sfs.SettleAccount
}); });
} }
private static void ConfigureBBAC_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) private static void ConfigureBBAC_ADJ_DETAIL(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{ {
//builder.Entity<BBAC_ADJ_DETAIL>(b => //builder.Entity<BBAC_ADJ_DETAIL>(b =>
@ -1315,13 +1310,13 @@ namespace Win.Sfs.SettleAccount
// b.HasIndex(o => o.Name).IsUnique(); // b.HasIndex(o => o.Name).IsUnique();
//}); //});
builder.Entity<VmiBalance>((Action<Microsoft.EntityFrameworkCore.Metadata.Builders.EntityTypeBuilder<VmiBalance>>)(b => builder.Entity((Action<EntityTypeBuilder<VmiBalance>>)(b =>
{ {
b.ToTable($"{options.TablePrefix}_VmiBalance", options.Schema); b.ToTable($"{options.TablePrefix}_VmiBalance", options.Schema);
b.ConfigureByConvention(); b.ConfigureByConvention();
b.HasAlternateKey(o => (new { o.BillType, o.PartCode, o.VinCode, o.ErpToLoc, o.OrderNum })); b.HasIndex(o => (new { o.BillType, o.PartCode, o.VinCode, o.ErpToLoc, o.OrderNum })).IsUnique();
})); }));
builder.Entity<VmiBalance>().HasData(new VmiBalance { BillType = EnumDeliverBjBmpBillType.JIS件, PartCode = "PartCode", VinCode = "VinCode", ErpToLoc = "ErpToLoc", OrderNum = "OrderNum" }.SetId()); builder.Entity<VmiBalance>().HasData(new VmiBalance(Guid.NewGuid()) { BillType = EnumDeliverBjBmpBillType.JIS件, PartCode = "PartCode", VinCode = "VinCode", ErpToLoc = "ErpToLoc", OrderNum = "OrderNum" });
builder.Entity<VmiLog>(b => builder.Entity<VmiLog>(b =>
{ {

5349
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230809035500_vmi11.Designer.cs

File diff suppressed because it is too large

186
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230809035500_vmi11.cs

@ -0,0 +1,186 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi11 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropUniqueConstraint(
name: "AK_Set_VmiBalance_BillType_PartCode_VinCode_ErpToLoc_OrderNum",
table: "Set_VmiBalance");
migrationBuilder.AlterColumn<string>(
name: "VinCode",
table: "Set_VmiBalance",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn<string>(
name: "PartCode",
table: "Set_VmiBalance",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn<string>(
name: "OrderNum",
table: "Set_VmiBalance",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AlterColumn<string>(
name: "ErpToLoc",
table: "Set_VmiBalance",
type: "nvarchar(450)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)");
migrationBuilder.AddColumn<int>(
name: "BillType",
table: "Set_PUB_SE_DETAIL",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "DeliverBillType",
table: "Set_PUB_SE_DETAIL",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "DeliverSubBillType",
table: "Set_PUB_SE_DETAIL",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "ProType",
table: "Set_PUB_SE_DETAIL",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "SubBillType",
table: "Set_PUB_SE_DETAIL",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "TransType",
table: "Set_PUB_SE_DETAIL",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.UpdateData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"),
column: "ConcurrencyStamp",
value: "4affb77e506d43dda8bc322162fcb335");
migrationBuilder.CreateIndex(
name: "IX_Set_VmiBalance_BillType_PartCode_VinCode_ErpToLoc_OrderNum",
table: "Set_VmiBalance",
columns: new[] { "BillType", "PartCode", "VinCode", "ErpToLoc", "OrderNum" },
unique: true,
filter: "[PartCode] IS NOT NULL AND [VinCode] IS NOT NULL AND [ErpToLoc] IS NOT NULL AND [OrderNum] IS NOT NULL");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Set_VmiBalance_BillType_PartCode_VinCode_ErpToLoc_OrderNum",
table: "Set_VmiBalance");
migrationBuilder.DropColumn(
name: "BillType",
table: "Set_PUB_SE_DETAIL");
migrationBuilder.DropColumn(
name: "DeliverBillType",
table: "Set_PUB_SE_DETAIL");
migrationBuilder.DropColumn(
name: "DeliverSubBillType",
table: "Set_PUB_SE_DETAIL");
migrationBuilder.DropColumn(
name: "ProType",
table: "Set_PUB_SE_DETAIL");
migrationBuilder.DropColumn(
name: "SubBillType",
table: "Set_PUB_SE_DETAIL");
migrationBuilder.DropColumn(
name: "TransType",
table: "Set_PUB_SE_DETAIL");
migrationBuilder.AlterColumn<string>(
name: "VinCode",
table: "Set_VmiBalance",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "PartCode",
table: "Set_VmiBalance",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "OrderNum",
table: "Set_VmiBalance",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ErpToLoc",
table: "Set_VmiBalance",
type: "nvarchar(450)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldNullable: true);
migrationBuilder.AddUniqueConstraint(
name: "AK_Set_VmiBalance_BillType_PartCode_VinCode_ErpToLoc_OrderNum",
table: "Set_VmiBalance",
columns: new[] { "BillType", "PartCode", "VinCode", "ErpToLoc", "OrderNum" });
migrationBuilder.UpdateData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"),
column: "ConcurrencyStamp",
value: "7ee5d3ed981d4f87963af8b5654cd9df");
}
}
}

28
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

@ -3350,6 +3350,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<DateTime>("BillTime") b.Property<DateTime>("BillTime")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int>("BillType")
.HasColumnType("int");
b.Property<int>("BusinessType") b.Property<int>("BusinessType")
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("int"); .HasColumnType("int");
@ -3379,6 +3382,12 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasColumnName("DeletionTime"); .HasColumnName("DeletionTime");
b.Property<int>("DeliverBillType")
.HasColumnType("int");
b.Property<int>("DeliverSubBillType")
.HasColumnType("int");
b.Property<string>("DeliveryHose") b.Property<string>("DeliveryHose")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@ -3451,6 +3460,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("PartCode") b.Property<string>("PartCode")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int>("ProType")
.HasColumnType("int");
b.Property<decimal>("Qty") b.Property<decimal>("Qty")
.HasColumnType("decimal(18,2)"); .HasColumnType("decimal(18,2)");
@ -3460,6 +3472,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<DateTime>("ShippingDate") b.Property<DateTime>("ShippingDate")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int>("SubBillType")
.HasColumnType("int");
b.Property<string>("ToErpLocCode") b.Property<string>("ToErpLocCode")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@ -3469,6 +3484,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("ToLocCode") b.Property<string>("ToLocCode")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<int>("TransType")
.HasColumnType("int");
b.Property<int>("Version") b.Property<int>("Version")
.HasColumnType("int"); .HasColumnType("int");
@ -4271,18 +4289,15 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<string>("ErpToLoc") b.Property<string>("ErpToLoc")
.IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("nvarchar(450)");
b.Property<string>("MatchNumber") b.Property<string>("MatchNumber")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("OrderNum") b.Property<string>("OrderNum")
.IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("nvarchar(450)");
b.Property<string>("PartCode") b.Property<string>("PartCode")
.IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("nvarchar(450)");
b.Property<string>("PjsNum") b.Property<string>("PjsNum")
@ -4307,7 +4322,6 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("VinCode") b.Property<string>("VinCode")
.IsRequired()
.HasColumnType("nvarchar(450)"); .HasColumnType("nvarchar(450)");
b.Property<string>("factory") b.Property<string>("factory")
@ -4315,7 +4329,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasAlternateKey("BillType", "PartCode", "VinCode", "ErpToLoc", "OrderNum"); b.HasIndex("BillType", "PartCode", "VinCode", "ErpToLoc", "OrderNum")
.IsUnique()
.HasFilter("[PartCode] IS NOT NULL AND [VinCode] IS NOT NULL AND [ErpToLoc] IS NOT NULL AND [OrderNum] IS NOT NULL");
b.ToTable("Set_VmiBalance"); b.ToTable("Set_VmiBalance");
@ -4325,7 +4341,7 @@ namespace Win.Sfs.SettleAccount.Migrations
Id = new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"), Id = new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"),
BillTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), BillTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
BillType = 1, BillType = 1,
ConcurrencyStamp = "7ee5d3ed981d4f87963af8b5654cd9df", ConcurrencyStamp = "4affb77e506d43dda8bc322162fcb335",
DeliverTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), DeliverTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
ErpToLoc = "ErpToLoc", ErpToLoc = "ErpToLoc",
OrderNum = "OrderNum", OrderNum = "OrderNum",

Loading…
Cancel
Save