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 { /// /// wms出库单 /// [Serializable] [Table("t_wms_outstock")] public class OutStock : EntityBase { public OutStock() { } /// /// 主键 订单编号 /// [Column("Id")] public override int Id { get; set; } /// /// 任务单ID /// [Column("TaskId")] public int TaskId { get; set; } /// /// 单据编号 /// [Column("BillNo")] public string BillNo { get; set; } /// /// 单据类型 /// [Column("Type")] public OutStockType Type { get; set; } = OutStockType.Sal; /// /// 发货组织 /// [Column("DeliveryOrgId")] public int DeliveryOrgId { get; set; } /// /// 收货客户 /// [Column("ReceiptCustomerId")] public int ReceiptCustomerId { get; set; } /// /// 创建人 /// [Column("CreatorId")] public int CreatorId { get; set; } /// /// 操作人 /// [Column("OperateId")] public int OperateId { get; set; } /// /// 创建时间(出库时间) /// [Column("CreateTime")] public DateTime CreateTime { get; set; } = DateTime.Now; /// /// 同步成功或者失败 null 就是未同步 /// [Column("SuccessSync")] public bool? SuccessSync { get; set; } /// /// 同步成功失败的源订单号 /// [Column("SuccessSyncFail")] public List SuccessSyncFail { get; set; }=new List(); /// /// 同步时间 /// [Column("SyncTime")] public DateTime? SyncTime { get; set; } /// /// 备注 /// [Column("Remark")] public string Remark { get; set; } /// /// 明细 /// public List Details = new List(); /// /// 创建 /// /// public void Create(int creatorId, OutStockTask task) { this.TaskId = task.Id; this.Type = task.Type; this.DeliveryOrgId = task.DeliveryOrgId; this.ReceiptCustomerId = task.ReceiptCustomerId; this.CreatorId = creatorId; this.CreateTime = DateTime.Now; } /// /// 同步金蝶 /// /// public void Sync(List sourcBilNos, bool isSuccess, int operateId, string remark) { SuccessSyncFail.AddRange(sourcBilNos); SuccessSyncFail.Distinct(); this.SuccessSync = isSuccess; this.Remark = remark; this.OperateId = operateId; this.SyncTime = DateTime.Now; } /// /// 生成单据号 /// public void GenerateNo() { //用户手动输入了 就不自动生成了 if (!string.IsNullOrEmpty(this.BillNo)) return; if (this.Id.ToString().Length >= 8) { this.BillNo = "CK" + this.Id.ToString(); return; } string idStr = this.Id.ToString(); while (true) { idStr = "0" + idStr; if (idStr.Length >= 8) break; } this.BillNo = "CK" + idStr; } } }