diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index ca7bfdfa..14189516 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -84,7 +84,14 @@ /// 成品库出库暂存区 /// public const string REGION_CPOutstockCache_ID = "35948525263893"; - + /// + /// 成品库区 + /// + public const string REGION_CPOutstock_ID = "28598002137877"; + /// + /// 成品库人工出库区 + /// + public const string REGION_CP‌Manual‌Outstock_ID = "36539312699413"; /// /// 长管出库 /// @@ -188,7 +195,6 @@ /// public const string PRETASK_BILL_STATUS_CANCEL_ID = "26126842129701"; - // /// /// 任务单据状态-待执行Id /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSignAllInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSignAllInput.cs new file mode 100644 index 00000000..fbb329bd --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSignAllInput.cs @@ -0,0 +1,13 @@ +namespace Tnb.WarehouseMgr.Entities.Dto +{ + /// + /// 库房业务更新输入参数 + /// + public class FinishproductOutstockSignAllInput + { + /// + /// 区域 + /// + public string? region_id { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSignInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSignInput.cs index 43cf8a79..9e964929 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSignInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSignInput.cs @@ -3,11 +3,11 @@ /// /// 库房业务更新输入参数 /// - public class FinishproductOutstockSortInput + public class FinishproductOutstockSignInput { /// - /// 分拣任务id + /// 载具编号 /// - public string? source_id { get; set; } + public string? carry_code { get; set; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSortInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSortInput.cs index 9e964929..43cf8a79 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSortInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSortInput.cs @@ -3,11 +3,11 @@ /// /// 库房业务更新输入参数 /// - public class FinishproductOutstockSignInput + public class FinishproductOutstockSortInput { /// - /// 载具编号 + /// 分拣任务id /// - public string? carry_code { get; set; } + public string? source_id { get; set; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SaleReleaseDistributeInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SaleReleaseDistributeInput.cs index 58231e60..cf13d52c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SaleReleaseDistributeInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SaleReleaseDistributeInput.cs @@ -21,5 +21,9 @@ /// 来源单据id /// public string? source_id { get; set; } + /// + /// 是否发到人工出库区 + /// + public bool isManual { get; set; } = false; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsTransferOutstockInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsTransferOutstockInput.cs index 95ca57bf..9017a6a0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsTransferOutstockInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/WmsTransferOutstockInput.cs @@ -20,5 +20,10 @@ /// 来源单据id /// public string? source_id { get; set; } + + /// + /// 是否发到人工出库区 + /// + public bool isManual { get; set; } = false; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs index 24e2d0cf..45635c93 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs @@ -555,16 +555,16 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException($@"子表主键不能为空!", 500); } - var wmsPurchaseOrdersDistinct = input.details.Select(r => new - { - material_id = r.material_code, - code_batch = r.code_batch, - }).Distinct(); - if (wmsPurchaseOrdersDistinct.Count() < input.details.Count) - { - _LoggerErp2Mes.LogWarning($@"【OutsourceOrderInput】表体存在物料和批号重复的明细!"); - throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); - } + //var wmsPurchaseOrdersDistinct = input.details.Select(r => new + //{ + // material_id = r.material_code, + // code_batch = r.code_batch, + //}).Distinct(); + //if (wmsPurchaseOrdersDistinct.Count() < input.details.Count) + //{ + // _LoggerErp2Mes.LogWarning($@"【OutsourceOrderInput】表体存在物料和批号重复的明细!"); + // throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); + //} await db.Ado.BeginTranAsync(); @@ -757,16 +757,16 @@ namespace Tnb.WarehouseMgr } - var wmsMaterialTransferdsDistinct = input.details.Select(r => new - { - material_id = r.material_code, - code_batch = r.code_batch, - }).Distinct(); - if (wmsMaterialTransferdsDistinct.Count() < input.details.Count) - { - _LoggerErp2Mes.LogWarning($@"【MaterialTransfer】表体存在物料和批号重复的明细!"); - throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); - } + //var wmsMaterialTransferdsDistinct = input.details.Select(r => new + //{ + // material_id = r.material_code, + // code_batch = r.code_batch, + //}).Distinct(); + //if (wmsMaterialTransferdsDistinct.Count() < input.details.Count) + //{ + // _LoggerErp2Mes.LogWarning($@"【MaterialTransfer】表体存在物料和批号重复的明细!"); + // throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); + //} await db.Ado.BeginTranAsync(); @@ -1125,16 +1125,16 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException($@"子表主键不能为空!", 500); } - var wmsPurchaseOrdersDistinct = input.details.Select(r => new - { - material_id = r.material_code, - code_batch = r.code_batch, - }).Distinct(); - if (wmsPurchaseOrdersDistinct.Count() < input.details.Count) - { - _LoggerErp2Mes.LogWarning($@"【TransferOutstock】表体存在物料和批号重复的明细!"); - throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); - } + //var wmsPurchaseOrdersDistinct = input.details.Select(r => new + //{ + // material_id = r.material_code, + // code_batch = r.code_batch, + //}).Distinct(); + //if (wmsPurchaseOrdersDistinct.Count() < input.details.Count) + //{ + // _LoggerErp2Mes.LogWarning($@"【TransferOutstock】表体存在物料和批号重复的明细!"); + // throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); + //} await db.Ado.BeginTranAsync(); string Code = ""; switch (warehouse_instock.id) @@ -1454,16 +1454,16 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException($@"子表主键不能为空!", 500); } - var wmsTransferOrdersDistinct = input.details.Select(r => new - { - material_id = r.material_code, - code_batch = r.code_batch, - }).Distinct(); - if (wmsTransferOrdersDistinct.Count() < input.details.Count) - { - _LoggerErp2Mes.LogWarning($@"【TransferOrder】表体存在物料和批号重复的明细!"); - throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); - } + //var wmsTransferOrdersDistinct = input.details.Select(r => new + //{ + // material_id = r.material_code, + // code_batch = r.code_batch, + //}).Distinct(); + //if (wmsTransferOrdersDistinct.Count() < input.details.Count) + //{ + // _LoggerErp2Mes.LogWarning($@"【TransferOrder】表体存在物料和批号重复的明细!"); + // throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); + //} await db.Ado.BeginTranAsync(); @@ -1489,9 +1489,8 @@ namespace Tnb.WarehouseMgr _LoggerErp2Mes.LogWarning($@"【TransferOutstock】表头明细中组织{input.instockorg_id}在wms系统中未找到!"); throw new AppFriendlyException($@"表头明细中组织{input.instockorg_id}在wms系统中未找到!", 500); } - var _erpExtendField = await db.Queryable().InnerJoin((a, b) => a.table_id == b.Id) - .Where((a, b) => a.transaction_type_id == input.transaction_type).Select((a, b) => b).FirstAsync(); + .Where((a, b) => b.EnCode == input.transaction_type).Select((a, b) => b).FirstAsync(); if (_erpExtendField != null) { wmsTransferOrderH.transaction_type = _erpExtendField.EnCode; @@ -1774,16 +1773,16 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException($@"子表主键不能为空!", 500); } - var wmsRawmatOutstocksDistinct = input.details.Select(r => new - { - material_id = r.material_code, - code_batch = r.code_batch, - }).Distinct(); - if (wmsRawmatOutstocksDistinct.Count() < input.details.Count) - { - _LoggerErp2Mes.LogWarning($@"【RawmatOutstock】表体存在物料和批号重复的明细!"); - throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); - } + //var wmsRawmatOutstocksDistinct = input.details.Select(r => new + //{ + // material_id = r.material_code, + // code_batch = r.code_batch, + //}).Distinct(); + //if (wmsRawmatOutstocksDistinct.Count() < input.details.Count) + //{ + // _LoggerErp2Mes.LogWarning($@"【RawmatOutstock】表体存在物料和批号重复的明细!"); + // throw new AppFriendlyException($@"表体存在物料和批号重复的明细!", 500); + //} await db.Ado.BeginTranAsync(); // 判断是否重复传输 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 11b628ee..6542ea92 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -465,7 +465,8 @@ namespace Tnb.WarehouseMgr .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch) .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification) .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no) - .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id); + .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id) + .AndIF(!string.IsNullOrEmpty(input.Region_id), (a, b, c) => c.region_id == input.Region_id); Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace() ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString() : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs index 5572056a..e3eef7ff 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs @@ -59,7 +59,7 @@ namespace Tnb.WarehouseMgr .LeftJoin((a, b, c, d) => d.id == b.carrystd_id) .LeftJoin((a, b, c, d, e) => e.carry_id == b.id) .LeftJoin((a, b, c, d, e, f) => f.id == e.material_id) - .Where((a, b, c, d, e) => a.is_type == ((int)EnumLocationType.存储库位).ToString() && a.is_use == "1" + .Where((a, b, c, d, e) => a.is_type == ((int)EnumLocationType.存储库位).ToString() && ((!string.IsNullOrEmpty(b.carry_code) && b.carry_status != "0" && b.carry_status != "6") || string.IsNullOrEmpty(b.carry_code))) .WhereIF(!string.IsNullOrEmpty(warehouse_id), (a, b, c, d) => c.id == warehouse_id) .WhereIF(!string.IsNullOrEmpty(carry_code), (a, b, c, d) => b.carry_code.Contains(carry_code)) @@ -101,7 +101,7 @@ namespace Tnb.WarehouseMgr .InnerJoin((a, b, c, d, e, f) => f.carry_id == e.membercarry_id) .InnerJoin((a, b, c, d, e, f, g) => g.id == f.material_id) .InnerJoin((a, b, c, d, e, f, g, h) => h.id == e.membercarry_id) - .Where((a, b, c, d, e) => a.is_type == ((int)EnumLocationType.存储库位).ToString() && a.is_use == "1" && b.carry_status != "0" && b.carry_status != "6") + .Where((a, b, c, d, e) => a.is_type == ((int)EnumLocationType.存储库位).ToString() && b.carry_status != "0" && b.carry_status != "6") .WhereIF(!string.IsNullOrEmpty(warehouse_id), (a, b, c, d) => c.id == warehouse_id) .WhereIF(!string.IsNullOrEmpty(carry_code), (a, b, c, d, e, f, g, h) => b.carry_code.Contains(carry_code)|| h.carry_code.Contains(carry_code)) .WhereIF(!string.IsNullOrEmpty(material_code), (a, b, c, d, e, f, g) => g.code.Contains(material_code)) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs index 8d57848e..152af89f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs @@ -464,6 +464,22 @@ namespace Tnb.WarehouseMgr return await ToApiResult(HttpStatusCode.OK, "成功"); } + /// + /// 盘点签收(全部签收) + /// + /// + /// + [HttpPost, NonUnify, AllowAnonymous] + public async Task FinishproductOutstockSignAll(FinishproductOutstockSignAllInput input) + { + Logger.LogInformation($"【FinishproductOutstockSign】载具签收 {input.region_id}"); + if (string.IsNullOrEmpty(input.region_id)) + { + throw new AppFriendlyException("请选择区域", 500); + } + + return await ToApiResult(HttpStatusCode.OK, "成功"); + } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsSaleReleaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsSaleReleaseService.cs index c44298dd..6340fd1e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsSaleReleaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsSaleReleaseService.cs @@ -163,8 +163,8 @@ namespace Tnb.WarehouseMgr await s_taskExecuteSemaphore.WaitAsync(); await _db.Ado.BeginTranAsync(); //入库取终点 //出库起点 - OutStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, material_id = wmsOutstockD.material_id, qty = input.qty, code_batch = wmsOutstockD.code_batch }; - List> items = await _wareHouseService.OutStockStrategy_saleRelease(inStockStrategyInput); + OutStockStrategyQuery outStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, material_id = wmsOutstockD.material_id, qty = input.qty, code_batch = wmsOutstockD.code_batch, Region_id = WmsWareHouseConst.REGION_CPOutstock_ID }; + List> items = await _wareHouseService.OutStockStrategy_saleRelease(outStockStrategyInput); decimal canOutstockQty = items.Sum(r => r.Item3.codeqty).ParseToDecimal(); if (canOutstockQty < input.qty) @@ -178,11 +178,27 @@ namespace Tnb.WarehouseMgr Logger.LogInformation($"【Distribute】 预计生成{items_pretask.Count}条预任务"); - List endLocations = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").ToListAsync(); - - if (endLocations.Count < items_pretask.Count) + List endLocations = null; + // 自动发货 + if (!input.isManual) { - throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500); + endLocations = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").ToListAsync(); + + if (endLocations.Count < items_pretask.Count) + { + throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500); + } + } + //人工发货 + else + { + InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = items_pretask.Count, Region_id = WmsWareHouseConst.REGION_CPManualOutstock_ID }; + endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); + + if (endLocations.Count < items_pretask.Count) + { + throw new AppFriendlyException("三楼人工出库区没有足够的未锁定且空闲的出库工位", 500); + } } @@ -193,8 +209,30 @@ namespace Tnb.WarehouseMgr WmsCarryCode carryCode = item.Item3; BasLocation startLocation = item.Item4; // 根据一楼工位任务数平均分配任务 确定一楼工位 - BasLocation endLocation = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync(); + BasLocation endLocation = null; + // 自动发货 + if (!input.isManual) + { + endLocation = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync(); + + if (endLocation == null) + { + throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500); + } + } + //人工发货 + else + { + InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = 1, Region_id = WmsWareHouseConst.REGION_CPManualOutstock_ID }; + endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); + + if (endLocations.Count < 1) + { + throw new AppFriendlyException("三楼人工出库区没有足够的未锁定且空闲的出库工位", 500); + } + endLocation = endLocations[0]; + } if (endLocation == null) { throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500); @@ -220,7 +258,6 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException($"库位{endLocation.location_code}未在点位表中维护对应点位", 500); } - string endLocationId = endLocation.id; // 在线开发 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferOutstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferOutstockService.cs index 33e8b40c..bf3b1818 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferOutstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferOutstockService.cs @@ -94,8 +94,8 @@ namespace Tnb.WarehouseMgr await s_taskExecuteSemaphore.WaitAsync(); await _db.Ado.BeginTranAsync(); //入库取终点 //出库起点 - OutStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, material_id = wmsOutstockD.material_id, qty = input.qty, code_batch = wmsOutstockD.pi_code }; - List> items = await _wareHouseService.OutStockStrategy_saleRelease(inStockStrategyInput); + OutStockStrategyQuery outStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, material_id = wmsOutstockD.material_id, qty = input.qty, code_batch = wmsOutstockD.pi_code, Region_id = WmsWareHouseConst.REGION_CPOutstock_ID }; + List> items = await _wareHouseService.OutStockStrategy_saleRelease(outStockStrategyInput); decimal canOutstockQty = items.Sum(r => r.Item3.codeqty).ParseToDecimal(); if (canOutstockQty < input.qty) @@ -108,14 +108,28 @@ namespace Tnb.WarehouseMgr Logger.LogInformation($"【Distribute】 预计生成{items_pretask.Count}条预任务"); - - List endLocations = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").ToListAsync(); - - if (endLocations.Count < items_pretask.Count) + List endLocations = null; + // 自动发货 + if (!input.isManual) { - throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500); - } + endLocations = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").ToListAsync(); + if (endLocations.Count < items_pretask.Count) + { + throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500); + } + } + //人工发货 + else + { + InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = items_pretask.Count, Region_id = WmsWareHouseConst.REGION_CPManualOutstock_ID }; + endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); + + if (endLocations.Count < items_pretask.Count) + { + throw new AppFriendlyException("三楼人工出库区没有足够的未锁定且空闲的出库工位", 500); + } + } // 预任务逻辑 foreach (Tuple item in items_pretask) @@ -124,12 +138,31 @@ namespace Tnb.WarehouseMgr WmsCarryCode carryCode = item.Item3; BasLocation startLocation = item.Item4; // 根据一楼工位任务数平均分配任务 确定一楼工位 - BasLocation endLocation = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync(); - if (endLocation == null) + BasLocation endLocation = null; + // 自动发货 + if (!input.isManual) { - throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500); + endLocation = await _db.Queryable().Where(r => _wareHouseService.GetFloor1OutstockLocation().Contains(r.id) && r.is_lock == 0 && r.is_use == "0").OrderBy("is_lock, task_nums, location_code").FirstAsync(); + + if (endLocation == null) + { + throw new AppFriendlyException("一楼没有足够的未锁定且空闲的出库工位", 500); + } } + //人工发货 + else + { + InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_CP_ID, Size = 1, Region_id = WmsWareHouseConst.REGION_CPManualOutstock_ID }; + endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); + + if (endLocations.Count < 1) + { + throw new AppFriendlyException("三楼人工出库区没有足够的未锁定且空闲的出库工位", 500); + } + endLocation = endLocations[0]; + } + WmsPointH sPoint = null!; WmsPointH ePoint = null!;