From 9f7c61b0b0620b50ca2ba7fd57e17fd673fc71de Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 19 Jul 2023 16:05:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E9=99=A4=E9=83=A8=E5=88=86warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsSetSortingService.cs | 19 +++++++++++++------ .../WmsSignForDeliveryService.cs | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs index a2a3af29..c0483adf 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSetSortingService.cs @@ -64,10 +64,14 @@ namespace Tnb.WarehouseMgr { await _db.Ado.BeginTranAsync(); - var singleSorting = setSortings[^setSortings.Count]; - var curCarry = await _db.Queryable().SingleAsync(it => it.id == singleSorting.carry_id); - var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation); - if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); + var singleSorting = new WmsSetsortingH(); + if (setSortings?.Count > 0) + { + singleSorting = setSortings[0]; + var curCarry = await _db.Queryable().SingleAsync(it => it.id == singleSorting.carry_id); + var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, endLocation); + if (!isMatch) throw new AppFriendlyException("库位与载具规格不匹配", 500); + } if (setSortings?.Count > 0 && !onFlag) { @@ -132,7 +136,7 @@ namespace Tnb.WarehouseMgr carryMats = carryMats.OrderBy(o => o.create_time).GroupBy(g => new { g.carry_id, g.material_id, g.code_batch }) .Select(x => { - WmsCarryMat? carryMat = x.FirstOrDefault(); + WmsCarryMat carryMat = new(); carryMat.need_qty = x.Sum(d => d.need_qty); return carryMat; }) @@ -205,7 +209,10 @@ namespace Tnb.WarehouseMgr if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - locIds.AddRange(points.Select(x => x.location_id).ToList()!); + if (points?.Count> 0) + { + locIds.AddRange(points.Select(x => x.location_id).ToList()!); + } //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) if (points?.Count > 0) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs index f9d0b86a..6cb7f10d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSignForDeliveryService.cs @@ -76,7 +76,7 @@ namespace Tnb.WarehouseMgr } if (carry != null) { - if (carry!.location_id!.IsNotEmptyOrNull()) + if (carry?.location_id?.IsNotEmptyOrNull() ?? false) { var loc = await _db.Queryable().SingleAsync(it => it.id == carry.location_id); loc.is_use = ((int)EnumCarryStatus.空闲).ToString(); @@ -139,7 +139,7 @@ namespace Tnb.WarehouseMgr } catch (Exception) { - isSuccessFul= false; + isSuccessFul = false; } return isSuccessFul; }