出库任务合并和作废
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
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
|
||||
@@ -12,7 +14,7 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[Table("t_erp_outstock_task")]
|
||||
public class OutStockTask: EntityBase
|
||||
public class OutStockTask : EntityBase
|
||||
{
|
||||
public OutStockTask() { }
|
||||
/// <summary>
|
||||
@@ -49,5 +51,46 @@ namespace WMS.Web.Domain.Entitys
|
||||
/// 明细
|
||||
/// </summary>
|
||||
public List<OutStockTaskDetails> Details = new List<OutStockTaskDetails>();
|
||||
|
||||
/// <summary>
|
||||
/// 作废
|
||||
/// </summary>
|
||||
public void Repeal(int creatorId)
|
||||
{
|
||||
this.OperatorId = creatorId;
|
||||
this.OperateTime = DateTime.Now;
|
||||
this.Status = OutStockStatus.Repeal;
|
||||
}
|
||||
/// <summary>
|
||||
/// 合并
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="creatorId"></param>
|
||||
/// <returns></returns>
|
||||
public Result Merge(List<OutStockTask> list, int creatorId)
|
||||
{
|
||||
// 符合合并数据逻辑:出库状态为”待拣货”+出库类型为:销售出库+发货组织一致+收货客户一致+发货仓库一致
|
||||
if (list.Where(w => w.Status != OutStockStatus.Wait).Any()) return Result.ReFailure(ResultCodes.MergeStatusError);
|
||||
if (list.Where(w => w.Type != OrderType.Sal_Out).Any()) return Result.ReFailure(ResultCodes.MergeStatusError);
|
||||
|
||||
var details = list.SelectMany(s => s.Details).ToList();
|
||||
if (details.GroupBy(g => g.DeliveryOrgId).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError);
|
||||
if (details.GroupBy(g => g.ReceiptCustomerId).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError);
|
||||
if (details.GroupBy(g => g.StockId).Count() > 1) return Result.ReFailure(ResultCodes.MergeStatusError);
|
||||
|
||||
//清空数据绑定
|
||||
foreach (var d in details)
|
||||
{
|
||||
d.Id = 0;
|
||||
d.Fid = 0;
|
||||
}
|
||||
this.OperatorId = creatorId;
|
||||
this.OperateTime = DateTime.Now;
|
||||
this.Status = OutStockStatus.Wait;
|
||||
this.Type = OrderType.Sal_Out;
|
||||
this.Details = details;
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user