From 71bb9acd0d6c6f4d890e2423be4591ee41691429 Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Fri, 24 Jan 2025 10:22:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=90=E4=B8=AA=E7=9B=98=E7=82=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DbModels/STZL/MatDetailStocktakingInfo.cs | 2 +- WCS.BLL/Manager/DbInit.cs | 1 + .../Services/IService/IStockTakingService.cs | 2 +- .../Services/Service/StockTakingService.cs | 49 ++++++++++++++++++- .../Stocktaking/StockTakingByIdRequest.cs | 2 +- .../Controllers/PDAStocktakingController.cs | 23 +++++---- 6 files changed, 64 insertions(+), 15 deletions(-) diff --git a/WCS.BLL/DbModels/STZL/MatDetailStocktakingInfo.cs b/WCS.BLL/DbModels/STZL/MatDetailStocktakingInfo.cs index e0b68d1..ee67bb1 100644 --- a/WCS.BLL/DbModels/STZL/MatDetailStocktakingInfo.cs +++ b/WCS.BLL/DbModels/STZL/MatDetailStocktakingInfo.cs @@ -69,7 +69,7 @@ namespace WCS.BLL.DbModels /// 物料规格 /// [SugarColumn(ColumnName = "mat_spec", Length = 150, IsNullable = true, ColumnDescription = "物料规格")] - public string MatSpec { get; set; } + public string? MatSpec { get; set; } /// /// 物料数量(原始数量) diff --git a/WCS.BLL/Manager/DbInit.cs b/WCS.BLL/Manager/DbInit.cs index 7214c14..951050f 100644 --- a/WCS.BLL/Manager/DbInit.cs +++ b/WCS.BLL/Manager/DbInit.cs @@ -72,6 +72,7 @@ namespace WCS.BLL.Manager DbHelp.db.CodeFirst.InitTables(typeof(ShelfInfo), typeof(MatBaseInfo), typeof(ShelfTypeInfo) , typeof(LocationInfo), typeof(LocationAreaInfo), typeof(MatDetailCurrentInfo), typeof(OrderTypeInfo) + , typeof(MatDetailStocktakingInfo) , typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail) , typeof(MatInfo), typeof(StoreInfo) , typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord) diff --git a/WCS.BLL/Services/IService/IStockTakingService.cs b/WCS.BLL/Services/IService/IStockTakingService.cs index 9f748a7..4f1f0e6 100644 --- a/WCS.BLL/Services/IService/IStockTakingService.cs +++ b/WCS.BLL/Services/IService/IStockTakingService.cs @@ -35,7 +35,7 @@ namespace WCS.BLL.Services.IService #region 赛特制冷 - public Task stockTakingById(StockTakingByIdRequest request); + public Task stockTakingById(StockTakingByIdRequest request); #endregion } } diff --git a/WCS.BLL/Services/Service/StockTakingService.cs b/WCS.BLL/Services/Service/StockTakingService.cs index 450b8ba..c6bb7d6 100644 --- a/WCS.BLL/Services/Service/StockTakingService.cs +++ b/WCS.BLL/Services/Service/StockTakingService.cs @@ -1046,12 +1046,57 @@ namespace WCS.BLL.Services.Service #region 赛特制冷 - public async Task stockTakingById(StockTakingByIdRequest request) + public async Task stockTakingById(StockTakingByIdRequest request) { //先查询有无这一条库存记录 - var matDetailCurrentInfo = DbHelp.db.Queryable() + var matDetailCurrentInfo = await DbHelp.db.Queryable() .Where(t => t.Id == request.MatDetailCurrentInfoId) .FirstAsync(); + if (matDetailCurrentInfo == null) + { + return new ResponseCommon() + { + Code = 201, + Message = $"操作失败:所选记录不存在!", + Data = null, + }; + } + + //查询是否已经存在未提交的盘点记录 + var stocktakingInfo = await DbHelp.db.Queryable() + .Where(t => t.MatDetailCurrentId == request.MatDetailCurrentInfoId) + .Where(t => t.StocktakingStatus == StocktakingStatusEnum.未提交) + .FirstAsync(); + //如果存在未提交的盘点记录 将上一次的记录更新即可 + if (stocktakingInfo != null) + { + stocktakingInfo.StocktakingQty = request.StocktakingQty; + stocktakingInfo.StocktakingUser = request.UserName; + stocktakingInfo.StocktakingTime = DateTime.Now; + DbHelp.db.Updateable(stocktakingInfo).ExecuteCommand(); + } + //不存在盘点记录 新增即可 + else + { + stocktakingInfo = new MatDetailStocktakingInfo() + { + MatDetailCurrentId = matDetailCurrentInfo.Id, + ShlefId = matDetailCurrentInfo.ShlefId, + ShelfCode = matDetailCurrentInfo.ShelfCode, + ShelfType = matDetailCurrentInfo.ShelfType, + ShelfArea = "", + MatCode = matDetailCurrentInfo.MatCode, + MatName = matDetailCurrentInfo.MatName, + MatSpec = matDetailCurrentInfo.MatSpec, + MatQty = matDetailCurrentInfo.MatQty, + StocktakingQty = request.StocktakingQty, + MatSupplier = matDetailCurrentInfo.MatSupplier, + StocktakingUser = request.UserName, + StocktakingTime = DateTime.Now, + StocktakingStatus = StocktakingStatusEnum.未提交, + }; + DbHelp.db.Insertable(stocktakingInfo).ExecuteCommand(); + } return new ResponseCommon() { diff --git a/WCS.Model/ApiModel/Stocktaking/StockTakingByIdRequest.cs b/WCS.Model/ApiModel/Stocktaking/StockTakingByIdRequest.cs index bdf5205..d05c6cb 100644 --- a/WCS.Model/ApiModel/Stocktaking/StockTakingByIdRequest.cs +++ b/WCS.Model/ApiModel/Stocktaking/StockTakingByIdRequest.cs @@ -8,6 +8,6 @@ namespace WCS.Model.ApiModel.Stocktaking { public int MatDetailCurrentInfoId { get; set; } - public int MatQty { get; set; } + public int StocktakingQty { get; set; } } } diff --git a/WCS.WebApi/Controllers/PDAStocktakingController.cs b/WCS.WebApi/Controllers/PDAStocktakingController.cs index 6137c38..96e3c84 100644 --- a/WCS.WebApi/Controllers/PDAStocktakingController.cs +++ b/WCS.WebApi/Controllers/PDAStocktakingController.cs @@ -19,11 +19,10 @@ namespace WCS.WebApi.Controllers [Route("[controller]")] public class PDAStocktakingController : ControllerBase { - public IWarningService _warningService { get; set; } - - public PDAStocktakingController(IWarningService warningService) + public IStockTakingService _stockTakingService { get; set; } + public PDAStocktakingController(IStockTakingService stockTakingService) { - _warningService = warningService; + _stockTakingService = stockTakingService; } [Route("stockTakingById")] @@ -44,14 +43,18 @@ namespace WCS.WebApi.Controllers }; } + if (request.StocktakingQty < 0) + { + return new ResponseCommon() + { + Code = 201, + Message = $"操作失败:数量应大于等于0!", + Data = null, + }; + } #endregion - return new ResponseCommon() - { - Code = 200, - Message = "success", - Data = null, - }; + return await _stockTakingService.stockTakingById(request); } catch (Exception ex) {