diff --git a/src/WMS.Web.Domain/Entitys/TakeStock.cs b/src/WMS.Web.Domain/Entitys/TakeStock.cs index 497f2c8e..353aff6c 100644 --- a/src/WMS.Web.Domain/Entitys/TakeStock.cs +++ b/src/WMS.Web.Domain/Entitys/TakeStock.cs @@ -52,5 +52,27 @@ namespace WMS.Web.Domain.Entitys this.CreatorId = creatorId; this.Date = DateTime.Now; } + /// + /// 生成单据号 + /// + public void GenerateNo() + { + //用户手动输入了 就不自动生成了 + if (!string.IsNullOrEmpty(this.BillNo)) return; + + if (this.Id.ToString().Length >= 8) + { + this.BillNo = "PD" + this.Id.ToString(); + return; + } + + string idStr = this.Id.ToString(); + while (true) + { + idStr = "0" + idStr; + if (idStr.Length >= 8) break; + } + this.BillNo = "PD" + idStr; + } } } diff --git a/src/WMS.Web.Repositories/TakeStockRepositories.cs b/src/WMS.Web.Repositories/TakeStockRepositories.cs index 1b4cf13b..73215d98 100644 --- a/src/WMS.Web.Repositories/TakeStockRepositories.cs +++ b/src/WMS.Web.Repositories/TakeStockRepositories.cs @@ -52,11 +52,11 @@ namespace WMS.Web.Repositories await _context.TakeStock.AddAsync(entity); await _context.SaveChangesAsync(); - //if (string.IsNullOrEmpty(entity.OutSourcFeedNo)) - //{ - // entity.GenerateNo(); - // await _context.SaveChangesAsync(); - //} + if (string.IsNullOrEmpty(entity.BillNo)) + { + entity.GenerateNo(); + await _context.SaveChangesAsync(); + } if (_transaction != null) _transaction.Commit();