From cfbf6a81c8f24ad37d64ac464f8a9b637d91b91a Mon Sep 17 00:00:00 2001 From: hehaibing-1996 Date: Wed, 27 Nov 2024 17:38:01 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E5=88=B7=E6=96=B0=E5=BA=93?= =?UTF-8?q?=E4=BD=8D=E6=98=BE=E7=A4=BA=E5=BA=93=E5=AD=98=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2.增加任务物料唯一码的保存 --- WCS.BLL/DbModels/Task/CurrentTask.cs | 6 +++ WCS.BLL/DbModels/Task/FinishedTask.cs | 6 +++ WCS.BLL/DbModels/Task/UploadedTask.cs | 6 +++ WCS.BLL/Services/IService/IMXL4Service.cs | 2 + WCS.BLL/Services/Service/MXL4Service.cs | 40 +++++++++++++++++++ .../ApiModel/MXL4/RefreshInventoryRequest.cs | 15 +++++++ WCS.WebApi/Controllers/MXL4Controller.cs | 31 ++++++++++++++ 7 files changed, 106 insertions(+) create mode 100644 WCS.Model/ApiModel/MXL4/RefreshInventoryRequest.cs diff --git a/WCS.BLL/DbModels/Task/CurrentTask.cs b/WCS.BLL/DbModels/Task/CurrentTask.cs index 6bc009b..0c07f31 100644 --- a/WCS.BLL/DbModels/Task/CurrentTask.cs +++ b/WCS.BLL/DbModels/Task/CurrentTask.cs @@ -93,6 +93,12 @@ namespace WCS.BLL.DbModels [SugarColumn(ColumnName = "mat_batch", Length = 150, IsNullable = true, ColumnDescription = "物料批次")] public string MatBatch { get; set; } + /// + /// 物料SN 物料唯一码 + /// + [SugarColumn(ColumnName = "mat_sn", Length = 150, IsNullable = true, ColumnDescription = "物料SN物料唯一码")] + public string MatSN { get; set; } + /// /// 物料数量 /// diff --git a/WCS.BLL/DbModels/Task/FinishedTask.cs b/WCS.BLL/DbModels/Task/FinishedTask.cs index c3a7e59..e19c8ee 100644 --- a/WCS.BLL/DbModels/Task/FinishedTask.cs +++ b/WCS.BLL/DbModels/Task/FinishedTask.cs @@ -92,6 +92,12 @@ namespace WCS.BLL.DbModels [SugarColumn(ColumnName = "mat_batch", Length = 150, IsNullable = true, ColumnDescription = "物料批次")] public string MatBatch { get; set; } + /// + /// 物料SN 物料唯一码 + /// + [SugarColumn(ColumnName = "mat_sn", Length = 150, IsNullable = true, ColumnDescription = "物料SN物料唯一码")] + public string MatSN { get; set; } + /// /// 物料数量 /// diff --git a/WCS.BLL/DbModels/Task/UploadedTask.cs b/WCS.BLL/DbModels/Task/UploadedTask.cs index f6b7ebd..db68862 100644 --- a/WCS.BLL/DbModels/Task/UploadedTask.cs +++ b/WCS.BLL/DbModels/Task/UploadedTask.cs @@ -92,6 +92,12 @@ namespace WCS.BLL.DbModels [SugarColumn(ColumnName = "mat_batch", Length = 150, IsNullable = true, ColumnDescription = "物料批次")] public string MatBatch { get; set; } + /// + /// 物料SN 物料唯一码 + /// + [SugarColumn(ColumnName = "mat_sn", Length = 150, IsNullable = true, ColumnDescription = "物料SN物料唯一码")] + public string MatSN { get; set; } + /// /// 物料数量 /// diff --git a/WCS.BLL/Services/IService/IMXL4Service.cs b/WCS.BLL/Services/IService/IMXL4Service.cs index 08e9a61..480f64e 100644 --- a/WCS.BLL/Services/IService/IMXL4Service.cs +++ b/WCS.BLL/Services/IService/IMXL4Service.cs @@ -16,5 +16,7 @@ namespace WCS.BLL.Services.IService public interface IMXL4Service { public Task> sysOrderMXL4(SysOrderMXL4Request request); + + public Task refreshInventoryRequest(RefreshInventoryRequest request); } } diff --git a/WCS.BLL/Services/Service/MXL4Service.cs b/WCS.BLL/Services/Service/MXL4Service.cs index 2834501..4d4bb0d 100644 --- a/WCS.BLL/Services/Service/MXL4Service.cs +++ b/WCS.BLL/Services/Service/MXL4Service.cs @@ -122,5 +122,45 @@ namespace WCS.BLL.Services.Service }; } } + + public async Task refreshInventoryRequest(RefreshInventoryRequest request) + { + try + { + //第一步:校验库位在数据库中是否都存在 + var storeCodeList = request.StoreCodes.Distinct() + .ToList(); + var stores = DbHelp.db.Queryable() + .LeftJoin((si, sti) => si.ShelfTypeId == sti.Id) + .Where((si, sti) => sti.ShelfTypeName == "液晶货架") + .Where((si, sti) => storeCodeList.Contains(si.StoreCode)) + .Select((st, sti) => st) + .ToList(); + if (stores.Count < storeCodeList.Count) + { + var storeCodesInDB = stores.Select(t => t.StoreCode).ToList(); + storeCodeList.RemoveAll(t => storeCodesInDB.Contains(t)); + return new ResponseCommon + { + Code = 200, + Message = $"操作失败:库位【{string.Join(",", storeCodeList)}】不存在!", + }; + } + //向WMS系统获取对应库位最新的库存信息、更新至电子标签 + return new ResponseCommon + { + Code = 200, + Message = "success" + }; + } + catch (Exception ex) + { + return new ResponseCommon + { + Code = 200, + Message = "操作失败:" + ex.Message, + }; + } + } } } diff --git a/WCS.Model/ApiModel/MXL4/RefreshInventoryRequest.cs b/WCS.Model/ApiModel/MXL4/RefreshInventoryRequest.cs new file mode 100644 index 0000000..fb35274 --- /dev/null +++ b/WCS.Model/ApiModel/MXL4/RefreshInventoryRequest.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; +using WCS.BLL.DbModels.Task; + +namespace WCS.Model.ApiModel.MXL4 +{ + /// + /// 刷新库位库存显示信息请求实体 + /// + public class RefreshInventoryRequest : RequestBase + { + public List StoreCodes { get; set; } + } +} diff --git a/WCS.WebApi/Controllers/MXL4Controller.cs b/WCS.WebApi/Controllers/MXL4Controller.cs index baa4203..722c56c 100644 --- a/WCS.WebApi/Controllers/MXL4Controller.cs +++ b/WCS.WebApi/Controllers/MXL4Controller.cs @@ -45,5 +45,36 @@ namespace WCS.WebApi.Controllers } } + /// + /// 刷新库存信息 当上游系统入库后可以调用此接口对硬件显示的库存信息进行刷新 + /// + /// + /// + [Route("refreshInventory")] + [HttpPost(Name = "refreshInventory")] + public async Task refreshInventory(RefreshInventoryRequest request) + { + try + { + //校验传入的参数 + if (request.StoreCodes == null || request.StoreCodes.Count == 0) + { + return new ResponseCommon() + { + Code = 201, + Message = "操作失败:缺少需要刷新的库位!", + }; + } + return await _mxl4Service.refreshInventoryRequest(request); + } + catch (Exception ex) + { + return new ResponseCommon() + { + Code = 300, + Message = "操作失败:" + ex.Message, + }; + } + } } }