This commit is contained in:
2024-10-10 16:36:47 +08:00
parent 88d83e46d3
commit 8049743296
3 changed files with 255 additions and 211 deletions

View File

@@ -1,4 +1,4 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Enums;
using JNPF.Common.Security;
@@ -332,7 +332,15 @@ namespace Tnb.WarehouseMgr
//VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYUNBIND_ID, true);
//await _runService.Create(templateEntity, visualDevModelCrInput);
if (tranFlag) await db.Ado.BeginTranAsync();
if (tranFlag)
{
Logger.LogInformation($"【CarryUnbindWithoutTran】开始事务");
await db.Ado.BeginTranAsync();
}
else
{
Logger.LogInformation($"【CarryCodeUnbindWithoutTran】不使用事务");
}
int row = await db.Deleteable<WmsCarryD>().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync();
//isOk = row > 0;
@@ -341,9 +349,13 @@ namespace Tnb.WarehouseMgr
// throw new Exception($"料架id{input.carry_id}载具解绑失败");
//}
Logger.LogInformation($"【CarryUnbindWithoutTran】料架{carry.carry_code}已解绑,解绑条数{row}");
if (tranFlag) await db.Ado.CommitTranAsync();
if (tranFlag)
{
Logger.LogInformation($"【CarryUnbindWithoutTran】提交事务");
await db.Ado.CommitTranAsync();
}
}
else
{
@@ -357,7 +369,11 @@ namespace Tnb.WarehouseMgr
{
Logger.LogError($"【CarryUnbindWithoutTran】 {ex.Message}");
Logger.LogError($"【CarryUnbindWithoutTran】 {ex.StackTrace}");
if (tranFlag) await db.Ado.RollbackTranAsync();
if (tranFlag)
{
Logger.LogInformation($"【CarryUnbindWithoutTran】回滚事务");
await db.Ado.RollbackTranAsync();
}
throw Oops.Bah(ex.Message);
}
@@ -391,9 +407,21 @@ namespace Tnb.WarehouseMgr
WmsCarryH? carry = await db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
if (carry != null)
{
if (tranFlag) await db.Ado.BeginTranAsync();
if (tranFlag)
{
Logger.LogInformation($"【CarryCodeUnbindWithoutTran】开始事务");
await db.Ado.BeginTranAsync();
}
else
{
Logger.LogInformation($"【CarryCodeUnbindWithoutTran】不使用事务");
}
int row = await db.Deleteable<WmsCarryCode>().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync();
if (tranFlag) await db.Ado.CommitTranAsync();
if (tranFlag)
{
Logger.LogInformation($"【CarryCodeUnbindWithoutTran】提交事务");
await db.Ado.CommitTranAsync();
}
isOk = row > 0;
Logger.LogInformation($"【CarryCodeUnbindWithoutTran】载具{carry.carry_code}已解绑,解绑条数{row}");
@@ -414,7 +442,11 @@ namespace Tnb.WarehouseMgr
{
Logger.LogError($"【CarryCodeUnbindWithoutTran】 {ex.Message}");
Logger.LogError($"【CarryCodeUnbindWithoutTran】 {ex.StackTrace}");
if (tranFlag) await db.Ado.RollbackTranAsync();
if (tranFlag)
{
Logger.LogInformation($"【CarryCodeUnbindWithoutTran】回滚事务");
await db.Ado.RollbackTranAsync();
}
throw Oops.Bah(ex.Message);
}
return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功");