This commit is contained in:
tongfei
2023-11-01 09:20:02 +08:00
17 changed files with 319 additions and 136 deletions

View File

@@ -1,7 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using WMS.Web.Core;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Values;
namespace WMS.Web.Domain.Entitys
{
@@ -11,12 +15,12 @@ namespace WMS.Web.Domain.Entitys
[Serializable]
[Table("t_ops_box")]
public class Box
public class Box : EntityBase
{
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
public override int Id { get; set; }
/// <summary>
/// 对应老OPS的箱ID
@@ -37,5 +41,41 @@ namespace WMS.Web.Domain.Entitys
/// 明细
/// </summary>
public List<BoxDetails> Details = new List<BoxDetails>();
//移出
public Result Out(List<(int MaterialId, decimal Qty, List<string> SerialNumbers)> list)
{
foreach(var l in list)
{
var d = this.Details.FirstOrDefault(f => f.MaterialId == l.MaterialId);
if (d == null) return Result.ReFailure(ResultCodes.BoxMateriaNoData);
d.Qty = d.Qty - l.Qty;
if (d.Qty <= 0) this.Details.Remove(d);
foreach (var s in l.SerialNumbers) d.SerialNumbers.Remove(s);
}
return Result.ReSuccess();
}
//移入
public Result In(List<(int MaterialId, decimal Qty, List<string> SerialNumbers)> list)
{
foreach (var l in list)
{
var d = this.Details.FirstOrDefault(f => f.MaterialId == l.MaterialId);
if (d == null)
{
this.Details.Add(new BoxDetails()
{
MaterialId = l.MaterialId,
Qty=l.Qty,
SerialNumbers=l.SerialNumbers
});
continue;
}
d.Qty = d.Qty + l.Qty;
d.SerialNumbers.AddRange(l.SerialNumbers);
}
return Result.ReSuccess();
}
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using WMS.Web.Core;
namespace WMS.Web.Domain.Entitys
{
@@ -11,12 +12,12 @@ namespace WMS.Web.Domain.Entitys
[Serializable]
[Table("t_ops_box_details")]
public class BoxDetails
public class BoxDetails : EntityBase
{
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
public override int Id { get; set; }
/// <summary>
/// 单据头ID
@@ -37,6 +38,6 @@ namespace WMS.Web.Domain.Entitys
/// <summary>
/// 序列号集
/// </summary>
public string SerialNumbers { get; set; }
public List<string> SerialNumbers { get; set; } = new List<string>();
}
}

View File

@@ -25,36 +25,26 @@ namespace WMS.Web.Domain.Entitys
[Column("MaterialId")]
public int MaterialId { get; set; }
/// <summary>
/// 仓库Id
/// </summary>
[Column("StockId")]
public int StockId { get; set; }
/// <summary>
/// 序列号
/// </summary>
[Column("SerialNumbers")]
public string SerialNumbers { get; set; }
public List<string> SerialNumbers { get; set; } = new List<string>();
/// <summary>
/// 原箱子ID
/// </summary>
[Column("SrcBoxId")]
public int SrcBoxId { get; set; }
/// <summary>
/// 数量
///</summary>
[Column("Qty")]
public decimal Qty { get; set; }
/// <summary>
/// 目标箱子ID
/// </summary>
[Column("DestBoxId")]
public int DestBoxId { get; set; }
/// <summary>
/// 原仓位ID
/// </summary>
[Column("SrcSubStockId")]
public int SrcSubStockId { get; set; }
/// <summary>
/// 目标仓位ID
/// </summary>
[Column("DestSubStockId")]
public int DestSubStockId { get; set; }
/// <summary>
/// 操作人
/// </summary>
[Column("CreatorId")]
@@ -68,8 +58,16 @@ namespace WMS.Web.Domain.Entitys
/// 创建
/// </summary>
/// <param name="creatorId"></param>
public void Create(int creatorId)
/// <param name="qty"></param>
/// <param name="materialId"></param>
/// <param name="serialNumbers"></param>
public void Create(int creatorId,decimal qty,int materialId, List<string> serialNumbers,int srcBoxId,int destBoxId)
{
this.SrcBoxId = srcBoxId;
this.DestBoxId = destBoxId;
this.SerialNumbers = serialNumbers;
this.MaterialId = materialId;
this.Qty = qty;
this.CreatorId = creatorId;
this.CreateTime = DateTime.Now;
}