From 11ea24c544dea680d016e323ac43ffc38633eb0f Mon Sep 17 00:00:00 2001 From: zgf Date: Thu, 30 Nov 2023 18:44:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B4=AF=E8=AE=A1=E4=B8=8B=E5=8F=91=E5=87=BA?= =?UTF-8?q?=E5=BA=93=E4=BB=BB=E5=8A=A1=EF=BC=8C=20=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=96=99=E5=A1=94=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=E5=8F=AF?= =?UTF-8?q?=E7=94=A8=E5=B1=82=EF=BC=8C=E6=9C=89=E5=B0=B1=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E5=87=BA=E5=BA=93=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../System/Controllers/jobs/SendWmsJob.cs | 64 ++++++++++++------- HHWMS.Web/Models/Shipment/ShipmentDetail.cs | 1 + 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/HHWMS.Web/Areas/System/Controllers/jobs/SendWmsJob.cs b/HHWMS.Web/Areas/System/Controllers/jobs/SendWmsJob.cs index d359bd7..a1cad50 100644 --- a/HHWMS.Web/Areas/System/Controllers/jobs/SendWmsJob.cs +++ b/HHWMS.Web/Areas/System/Controllers/jobs/SendWmsJob.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; @@ -174,11 +175,19 @@ namespace HHWMS.Web && x.Type.Equals(LocationTypeEnum.堆垛机工位)).FirstOrDefault(); var cTask = _unitwork.Find(x => x.ContainerCode == item.Key && x.TaskType == TaskTypeEnum.盘料盒出库).FirstOrDefault(); - if (gLoc != null || cTask != null) + //查找料塔工位 T + var tLoc = _unitwork.Find(x => x.Row == row + && x.Type.Equals(LocationTypeEnum.料塔)) + .FirstOrDefault(); + if(_unitwork.IsExit(x => x.FromLocation.Equals(tLoc.Code))) { - //盘料箱已在堆垛机工位,或者有此料箱的出库任务,直接生成盘料出库任务 + continue; } - else + //if (gLoc != null || cTask != null) + //{ + // //盘料箱已在堆垛机工位,或者有此料箱的出库任务,直接生成盘料出库任务 + //} + if (gLoc == null && cTask == null) { // 盘料箱在库内,工位为空,先生成料盘箱出库任务 @@ -212,14 +221,8 @@ namespace HHWMS.Web } } - if (gLoc != null) + if (gLoc != null || cTask != null) { - //查找料塔工位 T - var tLoc = _unitwork.Find(x => string.IsNullOrEmpty(x.ContainerCode) - && x.Row == row - && x.Type.Equals(LocationTypeEnum.料塔)) - .FirstOrDefault(); - //判断是否存在此托盘的出库任务 var containerTask = _unitwork.Find(x => x.Status < TaskStatusEnum.已下发 && x.ContainerCode == item.Key @@ -231,9 +234,10 @@ namespace HHWMS.Web tLoc = _unitwork.Find(x => x.Code == containerTask.ToLocation && x.Type.Equals(LocationTypeEnum.料塔)) .FirstOrDefault(); + var canUse = CalCanUse(Convert.ToInt32(tLoc.Length), containerTask.ToLocation,_unitwork); foreach (var inventory in item) { - if (tLoc.Height < tLoc.Length) + if (canUse.Length > 0) { // 库存不在已建任务明细中,新增任务明细 if (!containerTask.TaskDetails.Any(x => x.UniqueCode.Equals(inventory.UniqueCode))) @@ -243,24 +247,25 @@ namespace HHWMS.Web UniqueCode = inventory.UniqueCode, Lot = $"{Convert.ToInt32(location.Length)}-{tLoc.Code}", FromLocation = inventory.Lot, - ToLocation = (Convert.ToInt32(tLoc.Height) + 1).ToString(), + ToLocation = canUse.First().ToString(), Status = TaskStatusEnum.待下发, ContainerCode = inventory.ContainerCode, CreateTime = DateTime.Now }); - tLoc.Height += 1; + canUse = canUse.Where(x => x != canUse.First()).ToArray(); } //存在 else { - var i = containerTask.TaskDetails.Where(x => x.Status == TaskStatusEnum.新建 - && x.UniqueCode == inventory.UniqueCode) + var i = containerTask.TaskDetails.Where(x => x.UniqueCode == inventory.UniqueCode) .FirstOrDefault(); - - i.Lot = $"{Convert.ToInt32(location.Length)}-{tLoc.Code}"; - i.ToLocation = (Convert.ToInt32(tLoc.Height) + 1).ToString(); - i.Status = TaskStatusEnum.待下发; - tLoc.Height += 1; + if (string.IsNullOrEmpty(i.ToLocation)) + { + i.Lot = $"{Convert.ToInt32(location.Length)}-{tLoc.Code}"; + i.ToLocation = canUse.First().ToString(); + i.Status = TaskStatusEnum.待下发; + canUse = canUse.Where(x => x != canUse.First()).ToArray(); + } } } else @@ -297,22 +302,23 @@ namespace HHWMS.Web task.ToLocation = tLoc.Code; task.CreateTime = DateTime.Now; task.CreateBy = "wmsjob"; + var canUse = CalCanUse(Convert.ToInt32(tLoc.Length), tLoc.Code, _unitwork); foreach (var inventory in item) { - if (tLoc.Height < tLoc.Length) + if (canUse.Length > 0) { var detail = new TaskDetail { UniqueCode = inventory.UniqueCode, Lot = $"{Convert.ToInt32(location.Length)}-{tLoc.Code}", FromLocation = inventory.Lot, - ToLocation = (Convert.ToInt32(tLoc.Height) + 1).ToString(), + ToLocation = canUse.First().ToString(), Status = TaskStatusEnum.新建, ContainerCode = inventory.ContainerCode, CreateTime = DateTime.Now }; task.TaskDetails.Add(detail); - tLoc.Height += 1; + canUse = canUse.Where(x => x != canUse.First()).ToArray(); } else { @@ -551,5 +557,17 @@ namespace HHWMS.Web } } } + + public int[] CalCanUse(int length, string code, UnitWork _unitwork) + { + var used1 = _unitwork.Find(x => x.LocationCode.Equals(code)) + .Select(x => int.Parse(x.Lot)).ToArray(); + var used2 = _unitwork.Find(x => x.Lot.Contains(code)) + .Select(x => int.Parse(x.ToLocation)).ToArray(); + var used = used1.Union(used2); + var caseList = Enumerable.Range(1, length).ToArray(); + var canUse = caseList.Except(used).ToArray(); + return canUse; + } } } diff --git a/HHWMS.Web/Models/Shipment/ShipmentDetail.cs b/HHWMS.Web/Models/Shipment/ShipmentDetail.cs index 30414e4..4b3be54 100644 --- a/HHWMS.Web/Models/Shipment/ShipmentDetail.cs +++ b/HHWMS.Web/Models/Shipment/ShipmentDetail.cs @@ -26,6 +26,7 @@ namespace HHWMS.Web.Models [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")] public string MaterialCode { get; set; } + [Required] [Display(Name = "Inventory.UniqueCode", Description = "唯一编码")] [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")] public string UniqueCode { get; set; }