改箱调整

This commit is contained in:
18942506660
2023-10-31 16:06:51 +08:00
parent 4e45383532
commit c1c3ec2928
12 changed files with 205 additions and 64 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();
}
}
}