增加箱库存同步箱信息

This commit is contained in:
18942506660
2024-03-06 10:33:14 +08:00
parent 3697fbe196
commit 008640be06
6 changed files with 243 additions and 167 deletions

View File

@@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using WMS.Web.Core;
using WMS.Web.Core.Help;
using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Values;
@@ -129,7 +130,7 @@ namespace WMS.Web.Domain.Entitys
}
else
d.Qty = d.Qty + qty;
return Result.ReSuccess();
}
/// <summary>
@@ -158,6 +159,36 @@ namespace WMS.Web.Domain.Entitys
if (d != null)
d.Qty = (d.Qty - qty) > 0 ? (d.Qty - qty) : 0;
return Result.ReSuccess();
}
/// <summary>
/// 箱库存同步箱信息
/// </summary>
/// <param name="inventory"></param>
/// <returns></returns>
public Result BoxInventory(BoxInventory inventory)
{
var detailClone = this.Details.Clone();
foreach (var d in detailClone)
{
//如果箱信息存在 箱库存不存在 删除箱信息数据
var inventoryDetail = inventory.Details.FirstOrDefault(f => f.MaterialId == d.MaterialId);
if (inventoryDetail == null)
{
var boxDetail = this.Details.FirstOrDefault(f => f.Id == d.Id);
this.Details.Remove(boxDetail);
}
}
//箱库存存在 箱信息不存在 添加
foreach (var d in inventory.Details)
{
var md = this.Details.FirstOrDefault(w => w.MaterialId == d.MaterialId);
if (md == null)
this.Details.Add(new BoxDetails() { MaterialId = d.MaterialId, Qty = md.Qty });
else
md.Qty = d.Qty;
}
return Result.ReSuccess();
}
}