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; }