diff --git a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml index 2d27d07a..a96ccf7f 100644 --- a/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml +++ b/src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml @@ -14,6 +14,11 @@ ID + + + 单据编号 + + 类型:1为入库回退下架,2为出库回退上架 @@ -40,6 +45,11 @@ + + + 生成单据号 + + wms出入库回退记录表 diff --git a/src/WMS.Web.Domain/Entitys/BackRecord.cs b/src/WMS.Web.Domain/Entitys/BackRecord.cs index e98039e5..23af8d73 100644 --- a/src/WMS.Web.Domain/Entitys/BackRecord.cs +++ b/src/WMS.Web.Domain/Entitys/BackRecord.cs @@ -16,7 +16,11 @@ namespace WMS.Web.Domain.Entitys /// /// ID /// - public int Id { get; set; } + public int Id { get; set; } + /// + /// 单据编号 + /// + public string BillNo { get; set; } /// /// 类型:1为入库回退下架,2为出库回退上架 /// @@ -44,5 +48,28 @@ namespace WMS.Web.Domain.Entitys this.CreatorId = creatorId; this.CreateTime = DateTime.Now; } + + /// + /// 生成单据号 + /// + public void GenerateNo() + { + //用户手动输入了 就不自动生成了 + if (!string.IsNullOrEmpty(this.BillNo)) return; + + if (this.Id.ToString().Length >= 8) + { + this.BillNo = "CR" + this.Id.ToString(); + return; + } + + string idStr = this.Id.ToString(); + while (true) + { + idStr = "0" + idStr; + if (idStr.Length >= 8) break; + } + this.BillNo = "CR" + idStr; + } } } diff --git a/src/WMS.Web.Repositories/BackRecordRepositories.cs b/src/WMS.Web.Repositories/BackRecordRepositories.cs index e5be5710..3475cdb3 100644 --- a/src/WMS.Web.Repositories/BackRecordRepositories.cs +++ b/src/WMS.Web.Repositories/BackRecordRepositories.cs @@ -106,6 +106,12 @@ namespace WMS.Web.Repositories { await _context.BackRecord.AddAsync(entity); await _context.SaveChangesAsync(); + if (string.IsNullOrEmpty(entity.BillNo)) + { + entity.GenerateNo(); + await _context.SaveChangesAsync(); + } + if (_transaction != null) _transaction.Commit(); return entity;