diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index bb4e1fd1..d94ee447 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -251,14 +251,13 @@ namespace Tnb.WarehouseMgr { var moveNum = itGroup.First().move_num; var items = itGroup.Adapt>(); - - items.ForEach(x => SnowflakeIdHelper.NextId()); items.ForEach(x => { + x.id = SnowflakeIdHelper.NextId(); x.status = WmsWareHouseConst.TASK_BILL_STATUS_DZX_ID; x.bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_TASK_EXECUTE_ENCODE).GetAwaiter().GetResult(); }); - var areaPreTasks = itGroup.ToList(); + if (moveNum == 1) { items.ForEach(x => @@ -269,6 +268,7 @@ namespace Tnb.WarehouseMgr } else if (moveNum > 1) { + var areaPreTasks = itGroup.ToList(); //搬运数量==预任务数,可以生成任务执行,为任务链 if (moveNum == areaPreTasks.Count) { @@ -387,15 +387,17 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(it => new WmsDistaskH { status = WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID }).Where(it => input.disTaskIds.Contains(it.id)).ExecuteCommandAsync(); //清空载具库位数据 - var carryIds = await _db.Queryable().Where(it => input.disTaskIds.Contains(it.id)).Select(it => it.carry_id).ToListAsync(); - if (carryIds?.Count > 0) + var carryAndLocIds = await _db.Queryable().Where(it => input.disTaskIds.Contains(it.id)).Select(it => new { it.carry_id, it.startlocation_id }).ToListAsync(); + if (carryAndLocIds?.Count > 0) { + var carryIds = carryAndLocIds.Select(x => x.carry_id).ToList(); await _db.Updateable().SetColumns(it => new WmsCarryH { location_id = null, location_code = null }).Where(it => carryIds.Contains(it.id)).ExecuteCommandAsync(); } - var startLocationIds = await _db.Queryable().Where(it => input.disTaskIds.Contains(it.id)).Select(it => it.startlocation_id).ToListAsync(); + //var startLocationIds = await _db.Queryable().Where(it => input.disTaskIds.Contains(it.id)).Select(it => it.startlocation_id).ToListAsync(); //更新起始库位,状态改为空闲、锁定状态,未锁定 - if (startLocationIds?.Count > 0) + if (carryAndLocIds?.Count > 0) { + var startLocationIds = carryAndLocIds.Select(x => x.startlocation_id).ToList(); await _db.Updateable().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.空闲).ToString(), is_lock = 0 }).Where(it => startLocationIds.Contains(it.id)).ExecuteCommandAsync(); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs index a2c1a441..e1b6088f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAInStockService.cs @@ -99,34 +99,37 @@ namespace Tnb.WarehouseMgr { var points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); //根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序) + if (points?.Count <= 2) throw new AppFriendlyException("该路径不存在", 500); if (points?.Count > 0) { - 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(); 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 = input.data[nameof(WmsPretaskH.biz_type)]?.ToString()!; - preTask.task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID; - preTask.carry_id = input.data[nameof(preTask.carry_id)]?.ToString()!; - preTask.carry_code = input.data[nameof(preTask.carry_code)]?.ToString()!; - preTask.area_id = sPoint?.area_id!; - preTask.area_code = it.Key; - preTask.require_id = input.data[nameof(WmsHandleH.require_id)].ToString(); - preTask.require_code = input.data[nameof(WmsHandleH.require_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 = input.data[nameof(WmsPretaskH.biz_type)]?.ToString() ?? "", + task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID, + carry_id = input.data[nameof(preTask.carry_id)]?.ToString() ?? "", + carry_code = input.data[nameof(preTask.carry_code)]?.ToString() ?? "", + area_id = sPoint?.area_id ?? "", + area_code = it.Key, + require_id = input.data[nameof(WmsHandleH.require_id)].ToString(), + require_code = input.data[nameof(WmsHandleH.require_code)]?.ToString(), + create_id = _userManager.UserId, + create_time = DateTime.Now, + }; + return preTask; }).ToList(); //生成预任务条码信息 @@ -297,7 +300,7 @@ namespace Tnb.WarehouseMgr } } await _db.Updateable(instockDetails).ExecuteCommandAsync(); - var allInstockDetails = await _db.Queryable().Where(it=>it.bill_id ==input.requireId).ToListAsync(); + var allInstockDetails = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); if (allInstockDetails.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) { await _db.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandAsync();