using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using WMS.Web.Core; using WMS.Web.Domain.Values; namespace WMS.Web.Domain.Entitys { /// /// erp入库任务表 /// [Serializable] [Table("t_erp_instock_task")] public class InStockTask : EntityBase { /// /// ID /// public override int Id { get; set; } /// /// 单据编号 /// public string BillNo { get; set; } /// /// 来源单号 /// public string SourceBillNo { get; set; } /// /// 入库状态 /// public InstockStatus Status { get; set; } /// /// 入库类型 /// public InstockType Type { get; set; } /// /// 收货人 /// public int? ReceiverId { get; set; } /// /// 收货时间 /// public DateTime? ReceiveTime { get; set; } /// /// 上架人 /// public int? ShelferId { get; set; } /// /// 入库时间(上架时间) /// public DateTime? ShelfTime { get; set; } /// /// 创建时间(erp那边的创建时间) /// public DateTime CreateTime { get; set; } /// /// 作废人 /// public int? RepealerId { get; set; } /// /// 作废时间 /// public DateTime? RepealTime { get; set; } /// /// 明细 /// public List Details { get; set; } /// /// 创建 /// /// /// /// public void Create(InstockType type,string sourceBillNo, DateTime createTime) { if (type == InstockType.Purchase) this.Status = InstockStatus.Wait; else this.Status = InstockStatus.WaitInStock; this.Type = type; this.SourceBillNo = sourceBillNo; this.CreateTime = createTime; } /// /// 作废 /// public void Repeal(int repealerId) { this.Status = InstockStatus.Repeal; this.RepealerId = repealerId; this.RepealTime= DateTime.Now; } /// /// 创建订单号 /// /// public void MakeBillNo(int newId) { //生成订单号 var length = newId.ToString().Length; if (length >= 8) { this.BillNo = $"RKRW{newId.ToString()}"; } else { var needLength = 8 - length; var needStr = ""; for (int i = 0; i < needLength; i++) { needStr += "0"; } this.BillNo = "RKRW" + needStr + newId.ToString(); } } /// /// 收货 /// /// public void Receive(int creatorId) { this.Status = InstockStatus.WaitInStock; this.ReceiverId = creatorId; this.ReceiveTime = DateTime.Now; } /// /// 上架 /// /// public void Shelf(int creatorId) { //明细中:所有的应入数量之和 var totalAccruedQty= this.Details.Sum(x => x.AccruedQty); //明细中:所有的收货数量之和 var totalReceiveQty = this.Details.Sum(x => x.ReceiveQty); if (totalAccruedQty == totalReceiveQty) this.Status = InstockStatus.Already; else this.Status = InstockStatus.Part; this.ShelferId = creatorId; this.ShelfTime = DateTime.Now; } /// /// 非采购上架 /// /// public void NoPurchaseShelf(int creatorId) { //明细中:所有的应入数量之和 var totalAccruedQty = this.Details.Sum(x => x.AccruedQty); //明细中:所有的收货数量之和 var totalReceiveQty = this.Details.Sum(x => x.ReceiveQty); if (totalAccruedQty == totalReceiveQty) this.Status = InstockStatus.Already; else this.Status = InstockStatus.Part; this.ReceiverId = creatorId; this.ReceiveTime = DateTime.Now; this.ShelferId = creatorId; this.ShelfTime = DateTime.Now; } } }