From f814583a0e738619759555df28233e4dded5e45a Mon Sep 17 00:00:00 2001 From: majian <780924089@qq.com> Date: Thu, 25 Jul 2024 17:02:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=9F=E6=9D=90=E6=96=99=E4=BB=93=E5=86=85?= =?UTF-8?q?=E8=BD=AC=E7=A7=BB=E3=80=81=E5=87=BA=E5=85=A5=E5=BA=93=E7=AD=96?= =?UTF-8?q?=E7=95=A5=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/WmsWareHouseConst.cs | 5 +++ .../Dto/Queries/OutStockStrategyQuery.cs | 3 ++ .../IWareHouseService.cs | 7 --- .../Tnb.WarehouseMgr/DeviceProviderService.cs | 2 +- .../Tnb.WarehouseMgr/WareHouseService.cs | 45 ------------------- .../WmsMaterialTransferService.cs | 18 +++++--- 6 files changed, 20 insertions(+), 60 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index a9da74b0..f98efeda 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -542,5 +542,10 @@ /// 原材料仓内转移策略 /// public const string POLICY_YCLINSTOCK = "WISP202407250001"; + + /// + /// 原材料仓出库策略 + /// + public const string POLICY_YCLOUTSTOCK = "WOSP202407250002"; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/OutStockStrategyQuery.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/OutStockStrategyQuery.cs index 0fd9cc59..99e2c9ae 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/OutStockStrategyQuery.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/OutStockStrategyQuery.cs @@ -49,5 +49,8 @@ // 是否过滤载具占用状态 public bool filter_carry_status { get; set; } = true; + + // 策略编号 + public string PolicyCode { get; set; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs index 25efa97f..09289694 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs @@ -40,13 +40,6 @@ namespace Tnb.WarehouseMgr.Interfaces /// Task> OutStockStrategy([FromQuery] OutStockStrategyQuery input); /// - /// 原材料仓出库策略 - /// - /// - /// - /// - Task> OutStockStrategyYCL([FromQuery] OutStockStrategyQuery input); - /// /// 缓存仓出库策略 /// /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs index a5b4e024..65ce09b7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs @@ -344,7 +344,7 @@ namespace Tnb.WarehouseMgr { Logger.Error($"【UnloadConfirm】 根据参数,sourceName:{input.sourceName},taskCode:{input.taskCode},未找到匹配的电梯任务"); } - if (s_elevatorMap.TryGetValue(elevator.device_id, out object? elevatorCode)) + if (elevator != null && s_elevatorMap.TryGetValue(elevator.device_id, out object? elevatorCode)) { if (!TimedTaskBackgroundService.elevatorStatus[elevatorCode.ToString()]) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 005854d2..ad46c634 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -485,51 +485,6 @@ namespace Tnb.WarehouseMgr return input.Size > 0 ? items.Take(input.Size).ToList() : items; } - /// - /// 原材料仓出库策略 - /// - /// - /// - /// - public async Task> OutStockStrategyYCL([FromQuery] OutStockStrategyQuery input) - { - Expressionable whereExprable = Expressionable.Create() - .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0) - .And((a, b, c) => !string.IsNullOrEmpty(a.location_id)) - .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString()) - .And((a, b, c) => a.out_status == "0") - .And((a, b, c) => c.wh_id == input.warehouse_id) - .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id) - .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); - Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace() - ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString() - : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString(); - _ = whereExprable.And(carryStatusFilterExp); - Expression> whereExpr = whereExprable.ToExpression(); - - SqlSugarClient cyDb = _db.CopyNew(); - WmsInstockPolicies policy = await cyDb.Queryable().Where(it => it.status == 1).FirstAsync(); - if (policy == null) - { - throw new AppFriendlyException("没有可用策略", 500); - } - - List items = await cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id) - .LeftJoin((a, b, c) => a.location_id == c.id) - .Where(whereExpr) - //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty()) - .OrderBy(policy.policy) - - .Select() - .ToListAsync(); - - items = items.DistinctBy(r => r.id).ToList(); - return input.Size > 0 ? items.Take(input.Size).ToList() : items; - } - /// /// 缓存仓出库策略 /// diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs index d73a7347..0833d66f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsMaterialTransferService.cs @@ -219,15 +219,18 @@ namespace Tnb.WarehouseMgr throw new AppFriendlyException("批号不可为空", 500); } - //入库取终点 //出库起点 - OutStockStrategyQuery inStockStrategyInput = new() + OutStockStrategyQuery outStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID, material_id = input.material_id, code_batch = input.code_batch, - Size = input.palletCount + Size = input.palletCount, + Region_id = WmsWareHouseConst.REGION_Purchase_ID, + PolicyCode = WmsWareHouseConst.POLICY_YCLOUTSTOCK, + AvoidBusyPassage = true }; - List items = await _wareHouseService.OutStockStrategyYCL(inStockStrategyInput); + + List items = await _wareHouseService.OutStockStrategy(outStockStrategyInput); decimal qty = _db.Queryable().Where(r => items.Select(a => a.id).Contains(r.carry_id) && r.material_id == input.material_id && r.code_batch == input.code_batch).Sum(r => r.codeqty); @@ -332,9 +335,10 @@ namespace Tnb.WarehouseMgr await _db.Ado.BeginTranAsync(); - //入库取终点 //出库起点 - OutStockStrategyQuery inStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID, material_id = wmsMaterialTransferD.material_id, code_batch = input.code_batch, Size = input.palletCount }; - List items = await _wareHouseService.OutStockStrategyYCL(inStockStrategyInput); + OutStockStrategyQuery outStockStrategyInput = new() { warehouse_id = WmsWareHouseConst.WAREHOUSE_YCL_ID, material_id = wmsMaterialTransferD.material_id, + code_batch = input.code_batch, Size = input.palletCount,Region_id = WmsWareHouseConst.REGION_Purchase_ID,PolicyCode = WmsWareHouseConst.POLICY_YCLOUTSTOCK, + AvoidBusyPassage = true}; + List items = await _wareHouseService.OutStockStrategy(outStockStrategyInput); if (items.Count == 0) {