From 20bb9d96e3ef802b96222daabc5258c14ad57768 Mon Sep 17 00:00:00 2001 From: tongfei <244188119@qq.com> Date: Sat, 11 Nov 2023 17:55:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=BA=E5=85=A5=E5=BA=93=E5=9B=9E=E9=80=80?= =?UTF-8?q?=E5=8A=A0=E5=8D=95=E6=8D=AE=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WMS.Web.Api/wwwroot/WMS.Web.Domain.xml | 10 +++++++ src/WMS.Web.Domain/Entitys/BackRecord.cs | 29 ++++++++++++++++++- .../BackRecordRepositories.cs | 6 ++++ 3 files changed, 44 insertions(+), 1 deletion(-) 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;