From 5aed4189a4577f67bab57beb8515f64ae7159b88 Mon Sep 17 00:00:00 2001 From: FanLian Date: Thu, 13 Jul 2023 10:26:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8A=A5=E9=94=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WmsEmptyInstockService.cs | 8 +- .../WmsEmptyOutstockService .cs | 53 +++++---- .../Tnb.WarehouseMgr/WmskittingOutService.cs | 112 ++++++++++-------- 3 files changed, 96 insertions(+), 77 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs index 214de6c5..820e6316 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyInstockService.cs @@ -87,10 +87,10 @@ namespace Tnb.WarehouseMgr if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); + if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) - if (points?.Count > 0) + else { - if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => { var sPoint = it.FirstOrDefault(); @@ -153,6 +153,10 @@ namespace Tnb.WarehouseMgr } } + else + { + throw new AppFriendlyException("起始库位不可用或无可用的目标库位",500); + } await _db.Ado.CommitTranAsync(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index 2a9c81be..a2282770 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -89,25 +89,23 @@ namespace Tnb.WarehouseMgr WmsPointH? ePoint = null; if (input.data.ContainsKey(nameof(WmsPointH.location_id))) { - ePoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString()); + ePoint = await _db.Queryable().FirstAsync(it => it.location_id == input.data[nameof(WmsPointH.location_id)].ToString() && it.is_lock == 0); } - int i = 0; - - //根据每个载具的起始库位做路径运算 - for (i = 0; i < setQty.qty; i++) + for (int i = 0; i < setQty.qty; i++) { - if (carrys?.Count > 0) + { sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carrys[i].location_id); + } var isOk = false; if (sPoint != null && ePoint != null) { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); + if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) - if (points?.Count > 0) + else { - if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => { var sPoint = it.FirstOrDefault(); @@ -142,7 +140,6 @@ namespace Tnb.WarehouseMgr preTasks[^1].is_sign = 0; // 修改最后一个元素的是否签收值 } isOk = await _wareHouseService.GenPreTask(preTasks, null!); - } if (isOk) { @@ -174,6 +171,10 @@ namespace Tnb.WarehouseMgr it => new BasLocation { is_lock = 1 }); } } + else + { + throw new AppFriendlyException("无可出库的空载具或目标库位不存在或者目标库位被锁", 500); + } } @@ -226,24 +227,24 @@ namespace Tnb.WarehouseMgr if (input.IsNull()) throw new ArgumentNullException("input"); try { - var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code); - var dic = new Dictionary(); - dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(); - dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id; - dic[nameof(WmsEmptyOutstockH.location_id)] = location.id; - dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id; - dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult(); - dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID; - dic[nameof(WmsEmptyOutstockH.qty)] = input.qty; - dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id; - dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now; + var location = await _db.Queryable().SingleAsync(it => it.location_code == input.location_code); + var dic = new Dictionary(); + dic[nameof(WmsEmptyOutstockH.id)] = SnowflakeIdHelper.NextId(); + dic[nameof(WmsEmptyOutstockH.org_id)] = input.org_id; + dic[nameof(WmsEmptyOutstockH.location_id)] = location.id; + dic[nameof(WmsEmptyOutstockH.carrystd_id)] = input.carrystd_id; + dic[nameof(WmsEmptyOutstockH.bill_code)] = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_EMPTYOUTSTK_ENCODE).GetAwaiter().GetResult(); + dic[nameof(WmsEmptyOutstockH.status)] = WmsWareHouseConst.BILLSTATUS_ADD_ID; + dic[nameof(WmsEmptyOutstockH.qty)] = input.qty; + dic[nameof(WmsEmptyOutstockH.biz_type)] = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; + dic[nameof(WmsEmptyOutstockH.create_id)] = input.create_id; + dic[nameof(WmsEmptyOutstockH.create_time)] = DateTime.Now; - VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput - { - data = dic, - }; - await PDAWmsEmptyOut(visualDevModelDataCrInput); + VisualDevModelDataCrInput visualDevModelDataCrInput = new VisualDevModelDataCrInput + { + data = dic, + }; + await PDAWmsEmptyOut(visualDevModelDataCrInput); } catch (Exception ex) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs index c78ddf5f..36733438 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs @@ -132,71 +132,85 @@ namespace Tnb.WarehouseMgr public async Task KittingOutByIsToBeShipped() { - var kittingOuts = await _db.Queryable() - .Where(a => a.status == WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID) - .OrderBy(a => a.seq) - .ToListAsync(); - if (kittingOuts?.Count > 0) + try { - var grpList = kittingOuts.GroupBy(g => g.location_id).ToList(); - foreach (var koGrp in grpList) + var kittingOuts = await _db.Queryable() + .Where(a => a.status == WmsWareHouseConst.BILLSTATUS_TOBESHIPPED_ID) + .OrderBy(a => a.seq) + .ToListAsync(); + if (kittingOuts?.Count > 0) { - var locs = await _db.Queryable().Where(it => it.id == koGrp.Key && it.is_use == ((int)EnumCarryStatus.空闲).ToString() && it.is_lock == 0).ToListAsync(); - if (locs?.Count > 0) + var grpList = kittingOuts.GroupBy(g => g.location_id).ToList(); + foreach (var koGrp in grpList) { - - var arr = koGrp.ToArray(); - var ko = arr[^arr.Length]; - var carry = await _db.Queryable().SingleAsync(it => it.id == ko.carry_id); - if (carry != null) + var locs = await _db.Queryable().Where(it => it.id == koGrp.Key && it.is_use == ((int)EnumCarryStatus.空闲).ToString() && it.is_lock == 0).ToListAsync(); + if (locs?.Count > 0) { - WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); - WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == ko.location_id); - if (sPoint != null && ePoint != null) + var arr = koGrp.ToArray(); + var ko = arr[^arr.Length]; + var carry = await _db.Queryable().SingleAsync(it => it.id == ko.carry_id); + if (carry != null) { - var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id); - if (points?.Count > 0) + WmsPointH sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carry.location_id); + WmsPointH ePoint = await _db.Queryable().FirstAsync(it => it.location_id == ko.location_id); + if (sPoint != null && ePoint != null) { + var points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id); if (points.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); - var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => + if (points?.Count > 0) { - var sPoint = it.FirstOrDefault(); - var ePoint = it.LastOrDefault(); + var preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it => + { + var sPoint = it.FirstOrDefault(); + var ePoint = it.LastOrDefault(); - WmsPretaskH preTask = new(); - preTask.org_id = _userManager.User.OrganizeId; - preTask.startlocation_id = sPoint?.location_id!; - preTask.startlocation_code = sPoint?.location_code!; - preTask.endlocation_id = ePoint?.location_id!; - preTask.endlocation_code = ePoint?.location_code!; - preTask.start_floor = sPoint?.floor.ToString(); - preTask.end_floor = ePoint?.floor.ToString(); - preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); - preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; - preTask.biz_type = ko.biz_type; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; - preTask.carry_id = ko!.carry_id!; - preTask.carry_code = ko!.carry_code!; - preTask.area_id = sPoint?.area_id!; - preTask.area_code = it.Key; - preTask.require_id = ko.id; - preTask.require_code = ko.bill_code; - preTask.create_id = _userManager.UserId; - preTask.create_time = DateTime.Now; - return preTask; - }).ToList(); - await _warehouseService.GenPreTask(preTasks, null!); - var subCarrys = await _db.Queryable().Where(it => it.carry_id == ko.carry_id).ToListAsync(); - var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList(); - GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List { carry.location_id!, ko.location_id! } }; - await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.齐套).ToString() }, it => new BasLocation { is_lock = 1 }); + WmsPretaskH preTask = new(); + preTask.org_id = _userManager.User.OrganizeId; + preTask.startlocation_id = sPoint?.location_id!; + preTask.startlocation_code = sPoint?.location_code!; + preTask.endlocation_id = ePoint?.location_id!; + preTask.endlocation_code = ePoint?.location_code!; + preTask.start_floor = sPoint?.floor.ToString(); + preTask.end_floor = ePoint?.floor.ToString(); + preTask.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(); + preTask.status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID; + preTask.biz_type = ko.biz_type; + preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; + preTask.carry_id = ko!.carry_id!; + preTask.carry_code = ko!.carry_code!; + preTask.area_id = sPoint?.area_id!; + preTask.area_code = it.Key; + preTask.require_id = ko.id; + preTask.require_code = ko.bill_code; + preTask.create_id = _userManager.UserId; + preTask.create_time = DateTime.Now; + return preTask; + }).ToList(); + await _warehouseService.GenPreTask(preTasks, null!); + var subCarrys = await _db.Queryable().Where(it => it.carry_id == ko.carry_id).ToListAsync(); + var carryIds = subCarrys.Select(x => x.carry_id).Concat(new[] { ko.carry_id }).Distinct().ToList(); + GenPreTaskUpInput genPreTaskInput = new() { CarryIds = carryIds!, LocationIds = new List { carry.location_id!, ko.location_id! } }; + await _warehouseService.GenInStockTaskHandleAfter(genPreTaskInput, it => new WmsCarryH { is_lock = 1, carry_status = ((int)EnumCarryStatus.齐套).ToString() }, it => new BasLocation { is_lock = 1 }); + } } } + else + { + throw new AppFriendlyException("无可用的载具", 500); + } + } + else + { + throw new AppFriendlyException("无可用的库位", 500); } } } } + catch (Exception) + { + throw; + } } public override async Task ModifyAsync(WareHouseUpInput input)