修复bug

This commit is contained in:
18942506660
2023-11-15 14:24:31 +08:00
parent 73589f0dc3
commit 79f57894fa
3 changed files with 21 additions and 10 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;
@@ -148,27 +149,36 @@ namespace WMS.Web.Domain.Entitys
/// <returns></returns>
public Result Merge(List<OutStockTask> list, int creatorId)
{
if (list.Count() <= 1) return Result.ReFailure(ResultCodes.MergeNumberError);
// 符合合并数据逻辑:出库状态为”待拣货”+出库类型为:销售出库+发货组织一致+收货客户一致+发货仓库一致
if (list.Where(w => w.Status != OutStockStatus.Wait).Any()) return Result.ReFailure(ResultCodes.MergeStatusError);
if (list.Where(w => w.Type != OutStockType.Sal).Any()) return Result.ReFailure(ResultCodes.MergeStatusError);
if (list.GroupBy(g => g.DeliveryOrgId).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError);
if (list.GroupBy(g => g.ReceiptCustomerId).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError);
var details = list.SelectMany(s => s.Details).ToList();
if (details.GroupBy(g => g.StockCode).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError);
List<OutStockTaskDetails> details_new = new List<OutStockTaskDetails>();
//清空数据绑定
foreach (var d in details)
{
d.Id = 0;
d.Fid = 0;
var detail_new = details_new.FirstOrDefault(f => f.MaterialId == d.MaterialId);
if (detail_new != null)
{
detail_new.AccruedQty += d.AccruedQty;//应出数量累加
detail_new.SaleBillNos.AddRange(d.SaleBillNos);
detail_new.SourceBillNos.AddRange(d.SourceBillNos);
}
else
details_new.Add(d);
}
this.OperatorId = creatorId;
this.OperateTime = DateTime.Now;
this.Status = OutStockStatus.Wait;
this.Type = OutStockType.Sal;
this.Details = details;
this.Details = details_new;
return Result.ReSuccess();
}