From 874c11ec8e38782f6b6e09265b34a9e9a0f8c87c Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 30 Oct 2024 08:59:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8A=95=E6=96=99=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index b5bbe325..0732bbeb 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -341,20 +341,24 @@ namespace Tnb.WarehouseMgr { Logger.LogInformation($"【CarryCodeUnbindWithoutTran】不使用事务"); } - int row = await db.Deleteable().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync(); - //isOk = row > 0; - //if (!isOk) - //{ - // throw new Exception($"料架id{input.carry_id}载具解绑失败"); - //} - Logger.LogInformation($"【CarryUnbindWithoutTran】料架{carry.carry_code}已解绑,解绑条数{row}"); - - - if (tranFlag) + if (await db.Queryable().Where(r => r.carry_id == input.carry_id).AnyAsync()) { - Logger.LogInformation($"【CarryUnbindWithoutTran】提交事务"); - await db.Ado.CommitTranAsync(); + int row = await db.Deleteable().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync(); + //isOk = row > 0; + + //if (!isOk) + //{ + // throw new Exception($"料架id{input.carry_id}载具解绑失败"); + //} + Logger.LogInformation($"【CarryUnbindWithoutTran】料架{carry.carry_code}已解绑,解绑条数{row}"); + + + if (tranFlag) + { + Logger.LogInformation($"【CarryUnbindWithoutTran】提交事务"); + await db.Ado.CommitTranAsync(); + } } } else @@ -416,19 +420,23 @@ namespace Tnb.WarehouseMgr { Logger.LogInformation($"【CarryCodeUnbindWithoutTran】不使用事务"); } - int row = await db.Deleteable().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync(); - if (tranFlag) - { - Logger.LogInformation($"【CarryCodeUnbindWithoutTran】提交事务"); - await db.Ado.CommitTranAsync(); - } - isOk = row > 0; - Logger.LogInformation($"【CarryCodeUnbindWithoutTran】载具{carry.carry_code}已解绑,解绑条数{row}"); - //if (!isOk) - //{ - // throw Oops.Oh(ErrorCode.COM1001); - //} + if (await db.Queryable().Where(r => r.carry_id == input.carry_id).AnyAsync()) + { + int row = await db.Deleteable().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync(); + if (tranFlag) + { + Logger.LogInformation($"【CarryCodeUnbindWithoutTran】提交事务"); + await db.Ado.CommitTranAsync(); + } + isOk = row > 0; + + Logger.LogInformation($"【CarryCodeUnbindWithoutTran】载具{carry.carry_code}已解绑,解绑条数{row}"); + //if (!isOk) + //{ + // throw Oops.Oh(ErrorCode.COM1001); + //} + } } else {