diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index de713b5a..2bf0f988 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -104,7 +104,8 @@ namespace Tnb.WarehouseMgr //根据每个载具的起始库位做路径运算 if (carrys?.Count > 0) { - for (int i = 0; i < setQty.qty; i++) + int min = (carrys.Count > setQty.qty) ? setQty.qty : carrys.Count; + for (int i = 0; i < min; i++) { sPoint = await _db.Queryable().FirstAsync(it => it.location_id == carrys[i].location_id); @@ -121,26 +122,29 @@ namespace Tnb.WarehouseMgr 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 = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; - preTask.carry_id = carrys![i].id; - preTask.carry_code = carrys![i].carry_code; - preTask.area_id = sPoint?.area_id!; - preTask.area_code = it.Key; - preTask.require_id = input.data["ReturnIdentity"].ToString(); - preTask.require_code = input.data[nameof(preTask.bill_code)]?.ToString()!; - preTask.create_id = _userManager.UserId; - preTask.create_time = DateTime.Now; + WmsPretaskH preTask = new() + { + org_id = _userManager.User.OrganizeId, + startlocation_id = sPoint?.location_id!, + startlocation_code = sPoint?.location_code!, + endlocation_id = ePoint?.location_id!, + endlocation_code = ePoint?.location_code!, + start_floor = sPoint?.floor.ToString(), + end_floor = ePoint?.floor.ToString(), + bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(), + status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID, + biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID, + task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID, + carry_id = carrys![i].id, + carry_code = carrys![i].carry_code, + area_id = sPoint?.area_id!, + area_code = it.Key, + require_id = input.data["ReturnIdentity"].ToString(), + require_code = input.data[nameof(preTask.bill_code)]?.ToString()!, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; + return preTask; }).ToList(); //更新页面 @@ -153,24 +157,28 @@ namespace Tnb.WarehouseMgr } if (isOk) { - var preTaskUpInput = new GenPreTaskUpInput(); - preTaskUpInput.RquireId = input.data["ReturnIdentity"].ToString()!; - preTaskUpInput.CarryId = carrys![i].id; - preTaskUpInput.CarryStartLocationId = points!.FirstOrDefault()!.location_id!; - preTaskUpInput.CarryStartLocationCode = points!.FirstOrDefault()!.location_code!; - preTaskUpInput.LocationIds = points!.Select(x => x.location_id).ToList()!; + GenPreTaskUpInput preTaskUpInput = new() + { + RquireId = input.data["ReturnIdentity"].ToString()!, + CarryId = carrys![i].id, + CarryStartLocationId = points!.FirstOrDefault()!.location_id!, + CarryStartLocationCode = points!.FirstOrDefault()!.location_code!, + LocationIds = points!.Select(x => x.location_id).ToList()! + }; //更新明细表 - WmsEmptyOutstockD wmsEmptyOutstockD = new(); - wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId(); - wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId; - wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; - wmsEmptyOutstockD.location_id = ePoint.location_id!; - wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_ON_ID; - wmsEmptyOutstockD.carry_id = carrys[i].id; - wmsEmptyOutstockD.carry_code = carrys[i].carry_code; - wmsEmptyOutstockD.create_id = _userManager.UserId; - wmsEmptyOutstockD.create_time = DateTime.Now; + WmsEmptyOutstockD wmsEmptyOutstockD = new() + { + id = SnowflakeIdHelper.NextId(), + bill_id = preTaskUpInput.RquireId, + biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID, + location_id = ePoint.location_id!, + status = WmsWareHouseConst.BILLSTATUS_ON_ID, + carry_id = carrys[i].id, + carry_code = carrys[i].carry_code, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; await _db.Insertable(wmsEmptyOutstockD) .ExecuteCommandAsync();