diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAOutBaleServiceService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAOutBaleServiceService.cs index c0bac3be..f274f92c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAOutBaleServiceService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAOutBaleServiceService.cs @@ -60,11 +60,12 @@ namespace Tnb.WarehouseMgr try { await _db.Ado.BeginTranAsync(); - - VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTBALEPDA_ID, true); - await _runService.Create(templateEntity, input); //出库取起点 WmsCarryH carry = await _db.Queryable().FirstAsync(it => it.id == input.data[nameof(WmsOutbale.carry_id)].ToString()); + if (carry == null) + { + throw new AppFriendlyException("请选择载具", 500); + } WmsPointH? sPoint = null; WmsPointH? ePoint = null; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) @@ -75,19 +76,26 @@ namespace Tnb.WarehouseMgr { sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); } - + if (sPoint != null && ePoint != null) { - List points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) - if (points?.Count > 0) + var points=new List(); + if (sPoint.area_code != ePoint.area_code) { - + points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); if (points.Count <= 2) { throw new AppFriendlyException("该路径不存在", 500); } - + } + else + { + points.Add(sPoint); + points.Add(ePoint); + } + //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) + if (points?.Count > 0) + { List preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => { WmsPointH? sPoint = it.FirstOrDefault(); @@ -150,7 +158,8 @@ namespace Tnb.WarehouseMgr } } } - + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSOUTBALEPDA_ID, true); + await _runService.Create(templateEntity, input); await _db.Ado.CommitTranAsync(); } catch (Exception)