using Newtonsoft.Json; 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 { /// /// 序列号 /// [Serializable] [Table("t_wms_serialnumbers")] public class SerialNumbers : EntityBase { public SerialNumbers() { } public SerialNumbers(string serialNumber, string materialNumber, int boxId, int opsBoxId, string creator, DateTime? createTime, DateTime? completeCartonTime) { this.SerialNumber = serialNumber; this.MaterialNumber = materialNumber; this.BoxId = boxId; this.OpsBoxId = opsBoxId; this.Creator = creator; this.CreateTime = createTime == null ? DateTime.Now : (DateTime)createTime; this.CompleteCartonTime = completeCartonTime; } /// /// 主键 订单编号 /// [Column("Id")] public override int Id { get; set; } /// /// 序列号 /// [Column("SerialNumber")] public string SerialNumber { get; set; } ///// ///// 物料ID ///// //[Column("MaterialId")] //public int MaterialId { get; set; } /// /// 物料编码 /// [Column("MaterialNumber")] public string MaterialNumber { get; set; } /// /// wms箱ID /// [Column("BoxId")] public int BoxId { get; set; } /// /// 对应老OPS的箱ID /// [Column("OpsBoxId")] public int OpsBoxId { get; set; } /// /// 创建人(老ops过来) /// [Column("Creator")] public string Creator { get; set; } /// /// 创建时间(老ops过来) /// [Column("CreateTime")] public DateTime CreateTime { get; set; } = DateTime.Now; /// /// 完成装箱时间 /// [Column("CompleteCartonTime")] public DateTime? CompleteCartonTime { get; set; } /// /// 出库单对应销售订单号 /// [Column("SalBillNo")] public string SalBillNo { get; set; } /// /// 出库时间 /// [Column("OutStockTime")] public DateTime? OutStockTime { get; set; } /// /// 采购单号 /// [Column("PurchaseBillNo")] public string PurchaseBillNo { get; set; } /// /// 入库时间 /// [Column("InStockTime")] public DateTime? InStockTime { get; set; } /// /// 收货客户 /// [Column("CustomerId")] public int CustomerId { get; set; } = 0; /// /// 操作(绑定箱信息) /// /// 目标箱号 public void Bind(int destBoxId, DateTime completeCartonTime) { this.BoxId = destBoxId; this.CompleteCartonTime = completeCartonTime; } /// /// 解绑 /// public void UnBind() { this.BoxId = 0; } /// /// 出库 /// /// 出库单 public void OutStock(OutStock outStock, string materialNumber) { var outstockDetail = outStock.Details.FirstOrDefault(f => f.MaterialNumber == materialNumber); if (outstockDetail == null) return; //按产品出才解绑 按箱子出不解绑 if (outStock.Method == InventoryInOutMethod.Product) UnBind(); if (outStock.Type == OutStockType.Sal) { this.SalBillNo = JsonConvert.SerializeObject(outstockDetail.ErpDetails.Select(s => s.SaleBillNo).ToList()); this.CustomerId = outStock.ReceiptCustomerId; this.OutStockTime = DateTime.Now; } } /// /// 入库 /// /// 出库单号 public void InStock(string inStockBillNo, InstockType type) { if (type == InstockType.Purchase) { this.PurchaseBillNo = inStockBillNo; this.InStockTime = DateTime.Now; } } } }