Browse Source

更新寄售库存实体和接口

master
wanggang 1 year ago
parent
commit
b17c5ef1bd
  1. 93
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  2. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiBalance.cs
  3. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiLog.cs
  4. 27
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiType.cs
  5. 5048
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807054442_vmi9.Designer.cs
  6. 62
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807054442_vmi9.cs
  7. 19
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

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

@ -43,9 +43,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ;
public interface IVmiService : IApplicationService, ITransientDependency, IJobService public interface IVmiService : IApplicationService, ITransientDependency, IJobService
{ {
void Change(VmiLogType logType, VmiLog data); Task In(VmiLogType logType, string changedNumber, VmiBalance data);
void UnDo(string groupId); Task Out(VmiLogType logType, string changedNumber, VmiLog data);
Task UnDo(string groupId);
} }
[AllowAnonymous] [AllowAnonymous]
@ -141,6 +143,7 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
{ {
foreach (var item in query) foreach (var item in query)
{ {
item.BackupTime = DateTime.Now;
list.Add(item); list.Add(item);
if (list.Count == 10000) if (list.Count == 10000)
{ {
@ -167,17 +170,29 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
return Task.CompletedTask; return Task.CompletedTask;
} }
public void In(VmiLogType logType, VmiBalance data) /// <summary>
/// 发运入库\反结入库\调整入库
/// </summary>
/// <param name="logType"></param>
/// <param name="changedNumber"></param>
/// <param name="data"></param>
/// <returns></returns>
public async Task In(VmiLogType logType, string changedNumber, VmiBalance data)
{ {
var balance = this._balanceRepository.FirstOrDefault(o => o.BillType == data.BillType && var balance = this._balanceRepository.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, ChangedTime = DateTime.Now,
ChangedBy = _currentUser.UserName, ChangedBy = _currentUser.UserName,
ChangedQty = data.Qty,
}; };
log.InjectFrom(data); log.InjectFrom(data);
if (balance == null) if (balance == null)
@ -185,51 +200,60 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
balance = new VmiBalance(); balance = new VmiBalance();
balance.InjectFrom(data); balance.InjectFrom(data);
balance.SetId(); balance.SetId();
this._balanceRepository.InsertAsync(balance).Wait(); await _balanceRepository.InsertAsync(balance).ConfigureAwait(false);
} }
else else
{ {
var qty = balance.Qty + data.Qty;
balance.InjectFrom(data); balance.InjectFrom(data);
balance.Qty = qty;
this._balanceRepository.UpdateAsync(balance).Wait(); this._balanceRepository.UpdateAsync(balance).Wait();
} }
await _logRepository.InsertAsync(log).ConfigureAwait(false);
} }
/// <summary> /// <summary>
/// 出入 /// 结算出库\退货出库\调整出
/// </summary> /// </summary>
[HttpPost] /// <param name="logType"></param>
[UnitOfWork] /// <param name="changedNumber"></param>
public void Change(VmiLogType logType, VmiLog data) /// <param name="data"></param>
/// <returns></returns>
public async Task Out(VmiLogType logType, string changedNumber, VmiLog data)
{ {
var balance = this._balanceRepository.FirstOrDefault(o => o.BillType == data.BillType && var balance = this._balanceRepository.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
{ {
ChangedTime = DateTime.Now, LogType = logType,
ChangedBy = _currentUser.UserName, ChangedType = VmiType.Out,
ChangedNumber = changedNumber,
}; };
log.InjectFrom(data); log.InjectFrom(data);
log.InjectFrom(balance); log.LogType = logType;
log.ChangedType = VmiType.Out;
log.ChangedTime = DateTime.Now;
log.ChangedBy = _currentUser.UserName;
log.ChangedQty = data.Qty;
if (balance == null) if (balance == null)
{ {
balance = new VmiBalance(); balance = new VmiBalance();
balance.InjectFrom(data); balance.InjectFrom(data);
balance.Qty = data.Count;
balance.SetId(); balance.SetId();
this._balanceRepository.InsertAsync(balance).Wait(); await _balanceRepository.InsertAsync(balance).ConfigureAwait(false);
} }
else else
{ {
var value = balance.Qty + data.Count; var qty = balance.Qty - data.Qty;
balance.InjectFrom(data); balance.Qty = qty;
balance.Qty = value;
this._balanceRepository.UpdateAsync(balance).Wait(); this._balanceRepository.UpdateAsync(balance).Wait();
} }
this._logRepository.InsertAsync(log); await _logRepository.InsertAsync(log).ConfigureAwait(false);
new InfluxHelper(_cfg).Insert(log);
} }
/// <summary> /// <summary>
@ -237,15 +261,34 @@ public class VmiAppService : ApplicationService, IVmiService, IJobService, ITran
/// </summary> /// </summary>
[NonAction] [NonAction]
[UnitOfWork] [UnitOfWork]
public void UnDo(string groupId) public async Task UnDo(string groupId)
{
var logList = this._logRepository.Where(o => o.GroupId == groupId).AsNoTracking().OrderBy(o => o.ChangedTime);
foreach (var item in logList)
{
var balance = this._balanceRepository.FirstOrDefault(o => o.BillType == item.BillType &&
o.PartCode == item.PartCode &&
o.VinCode == item.VinCode &&
o.ErpToLoc == item.ErpToLoc &&
o.OrderNum == item.OrderNum);
if (balance == null)
{ {
var logs = this._logRepository.Where(o => o.GroupId == groupId).AsNoTracking().OrderBy(o => o.ChangedTime); balance = new VmiBalance();
foreach (var item in logs) balance.InjectFrom(item);
await _balanceRepository.InsertAsync(balance).ConfigureAwait(false);
}
else
{ {
//var balance = this._balanceRepository.FirstOrDefault(o => o.ErpToLoc == item.ErpToLoc&& o.PartCode == item. && o.LU == item.LogType); balance.Qty += item.ChangedQty;
//var log = new VmiLog(); this._balanceRepository.UpdateAsync(balance).Wait();
//log.InjectFrom(item); }
//log.CreatedTime = item.CreatedTime; var log = new VmiLog();
log.InjectFrom(item);
log.LogType = VmiLogType.Type300;
log.ChangedType = VmiType.In;
log.ChangedTime = DateTime.Now;
log.ChangedBy = _currentUser.UserName;
await _logRepository.InsertAsync(log).ConfigureAwait(false);
} }
} }

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

@ -11,8 +11,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Vmi;
/// <summary> /// <summary>
/// ERP库位+零件号+生产码 /// ERP库位+零件号+生产码
/// </summary> /// </summary>
public class VmiBalance : BasicAggregateRoot<Guid> public class VmiBalance : BasicAggregateRoot<Guid>, IHasConcurrencyStamp
{ {
public VmiBalance()
{
ConcurrencyStamp = Guid.NewGuid().ToString("N");
}
/// <summary> /// <summary>
/// LU零件号 /// LU零件号
/// </summary> /// </summary>
@ -73,9 +78,15 @@ public class VmiBalance : BasicAggregateRoot<Guid>
[Display(Name = "发货子类型")] [Display(Name = "发货子类型")]
public EnumDeliverSubBillType SubBillType { get; set; } public EnumDeliverSubBillType SubBillType { get; set; }
[Display(Name = "WMS实发生产码")]
public string RealCode { get; set; }
[Display(Name = "备注")] [Display(Name = "备注")]
public string ReMark { get; set; } public string ReMark { get; set; }
public string ConcurrencyStamp { get; set; }
public DateTime? BackupTime { get; set; }
public VmiBalance SetId() public VmiBalance SetId()
{ {
var data = new { BillType, PartCode, VinCode, ErpToLoc, OrderNum }; var data = new { BillType, PartCode, VinCode, ErpToLoc, OrderNum };

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

@ -30,7 +30,7 @@ public class VmiLog : BasicAggregateRoot<Guid>
public VmiLogType LogType { get; set; } public VmiLogType LogType { get; set; }
[Display(Name = "库存变动")] [Display(Name = "库存变动")]
public decimal Count { get; set; } public decimal ChangedQty { get; set; }
[Display(Name = "变动单号")] [Display(Name = "变动单号")]
public string ChangedNumber { get; set; } public string ChangedNumber { get; set; }
@ -58,9 +58,6 @@ public class VmiLog : BasicAggregateRoot<Guid>
//[Display(Name = "结算客户零件号")] //[Display(Name = "结算客户零件号")]
//public string CustomerPartCode { get; set; } //public string CustomerPartCode { get; set; }
[Display(Name = "WMS实发生产码")]
public string RealCode { get; set; }
//[Display(Name = "EDI订单生产码")] //[Display(Name = "EDI订单生产码")]
//public string VinCode { get; set; } //public string VinCode { get; set; }
@ -71,6 +68,9 @@ public class VmiLog : BasicAggregateRoot<Guid>
#region 库存备份 #region 库存备份
/// <summary>
/// LU零件号
/// </summary>
[Display(Name = "LU零件号")] [Display(Name = "LU零件号")]
public string PartCode { get; set; } public string PartCode { get; set; }
@ -98,6 +98,9 @@ public class VmiLog : BasicAggregateRoot<Guid>
[Display(Name = "订单日期")] [Display(Name = "订单日期")]
public DateTime DeliverTime { get; set; } public DateTime DeliverTime { get; set; }
/// <summary>
/// ERP库位
/// </summary>
[Display(Name = "ERP库位")] [Display(Name = "ERP库位")]
public string ErpToLoc { get; set; } public string ErpToLoc { get; set; }
@ -125,6 +128,9 @@ public class VmiLog : BasicAggregateRoot<Guid>
[Display(Name = "发货子类型")] [Display(Name = "发货子类型")]
public EnumDeliverSubBillType SubBillType { get; set; } public EnumDeliverSubBillType SubBillType { get; set; }
[Display(Name = "WMS实发生产码")]
public string RealCode { get; set; }
[Display(Name = "备注")] [Display(Name = "备注")]
public string ReMark { get; set; } public string ReMark { get; set; }

27
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/VmiType.cs

@ -20,18 +20,39 @@ public enum VmiType
public enum VmiLogType public enum VmiLogType
{ {
/// <summary>
/// 发运入库
/// </summary>
[Display(Name = "发运入库")] [Display(Name = "发运入库")]
Type100 = 100, Type100 = 100,
/// <summary>
/// 结算出库
/// </summary>
[Display(Name = "结算出库")] [Display(Name = "结算出库")]
Type200 = 200, Type200 = 200,
[Display(Name = "客户退货")] /// <summary>
/// 反结入库
/// </summary>
[Display(Name = "反结入库")]
Type300 = 300, Type300 = 300,
[Display(Name = "调整入库")] /// <summary>
/// 退货出库
/// </summary>
[Display(Name = "退货出库")]
Type400 = 400, Type400 = 400,
[Display(Name = "调整出库")] /// <summary>
/// 调整入库
/// </summary>
[Display(Name = "调整入库")]
Type500 = 500, Type500 = 500,
/// <summary>
/// 调整出库
/// </summary>
[Display(Name = "调整出库")]
Type600 = 600,
} }

5048
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807054442_vmi9.Designer.cs

File diff suppressed because it is too large

62
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230807054442_vmi9.cs

@ -0,0 +1,62 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi9 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Count",
table: "Set_VmiLog",
newName: "ChangedQty");
migrationBuilder.AddColumn<DateTime>(
name: "BackupTime",
table: "Set_VmiBalance",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ConcurrencyStamp",
table: "Set_VmiBalance",
type: "nvarchar(40)",
maxLength: 40,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "RealCode",
table: "Set_VmiBalance",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.UpdateData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("ea936b34-ecd0-7dbd-85a9-57cd8b730873"),
column: "ConcurrencyStamp",
value: "887ca64c266c48ac82dca90534f64225");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "BackupTime",
table: "Set_VmiBalance");
migrationBuilder.DropColumn(
name: "ConcurrencyStamp",
table: "Set_VmiBalance");
migrationBuilder.DropColumn(
name: "RealCode",
table: "Set_VmiBalance");
migrationBuilder.RenameColumn(
name: "ChangedQty",
table: "Set_VmiLog",
newName: "Count");
}
}
}

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

@ -3958,6 +3958,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<DateTime?>("BackupTime")
.HasColumnType("datetime2");
b.Property<DateTime>("BillTime") b.Property<DateTime>("BillTime")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
@ -3967,6 +3970,12 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("CodeType") b.Property<string>("CodeType")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<string>("Configcode") b.Property<string>("Configcode")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@ -4000,6 +4009,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("ReMark") b.Property<string>("ReMark")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("RealCode")
.HasColumnType("nvarchar(max)");
b.Property<string>("Seq") b.Property<string>("Seq")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@ -4028,6 +4040,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 = "887ca64c266c48ac82dca90534f64225",
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",
@ -4056,6 +4069,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("ChangedNumber") b.Property<string>("ChangedNumber")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<decimal>("ChangedQty")
.HasColumnType("decimal(18,2)");
b.Property<DateTime>("ChangedTime") b.Property<DateTime>("ChangedTime")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
@ -4068,9 +4084,6 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("Configcode") b.Property<string>("Configcode")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<decimal>("Count")
.HasColumnType("decimal(18,2)");
b.Property<string>("CustomerPartCode") b.Property<string>("CustomerPartCode")
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");

Loading…
Cancel
Save