From a3596e4e5bcf82df7ad05321b705232bc969f28b Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 10 Oct 2024 09:06:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=BD=E5=85=B7=E8=A7=A3=E7=BB=91=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=8A=A0=E4=BA=862=E4=B8=AA=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E4=BA=8B=E5=8A=A1=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PrdMaterialReceiptService.cs | 6 +- .../IWmsCarryUnbindService.cs | 15 +- .../Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 132 ++++++++++++++++++ 3 files changed, 149 insertions(+), 4 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index 8902bb16..5120d04a 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -736,7 +736,7 @@ namespace Tnb.ProductionMgr } else { - Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbind(new CarryCodeUnbindInput() + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbindWithoutTran(new CarryCodeUnbindInput() { carry_id = detail.member_carry_id },db); @@ -752,7 +752,7 @@ namespace Tnb.ProductionMgr if (carry.carrystd_id == WmsWareHouseConst.CARRY_ZYXCSTD_ID || carry.carrystd_id == WmsWareHouseConst.CARRY_ZYLJSTD_ID) { - Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbind(new CarryCodeUnbindInput() + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbindWithoutTran(new CarryCodeUnbindInput() { carry_id = carry.id },db); @@ -772,7 +772,7 @@ namespace Tnb.ProductionMgr if (carry.carrystd_id==WmsWareHouseConst.CARRY_LXSTD_ID || carry.carrystd_id==WmsWareHouseConst.CARRY_LJSTD_ID) { - Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsCarryUnbindService.CarryUnbind(new CarryBindInput() + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsCarryUnbindService.CarryUnbindWithoutTran(new CarryBindInput() { org = prdFeedingH.org_id, create_id = prdFeedingH.create_id, diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryUnbindService.cs index 406d2fcd..d66a19a0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryUnbindService.cs @@ -14,6 +14,19 @@ namespace Tnb.WarehouseMgr.Interfaces Task CarryCodeUnbind(CarryCodeUnbindInput input, ISqlSugarClient dbConn = null); Task CarryCodeUnbindCode(CarryCodeUnbindCodeInput input, ISqlSugarClient dbConn = null); - + /// + /// WmsCarryD解绑 传dbConn方法不控制事务 不传dbConn则方法自带事务 + /// + /// + /// + /// + Task CarryUnbindWithoutTran(CarryBindInput input, ISqlSugarClient dbConn = null); + /// + /// WmsCarryCode解绑 传dbConn方法不控制事务 不传dbConn则方法自带事务 + /// + /// + /// + /// + Task CarryCodeUnbindWithoutTran(CarryCodeUnbindInput input, ISqlSugarClient dbConn = null); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index 15787604..08dca023 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -287,5 +287,137 @@ namespace Tnb.WarehouseMgr } return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功"); } + + public async Task CarryUnbindWithoutTran(CarryBindInput input, ISqlSugarClient dbConn = null) + { + bool isOk = false; + + ISqlSugarClient db = null; + bool tranFlag = true; + + if (dbConn == null) + { + db = _db; + } + else + { + tranFlag = false; + db = dbConn; + } + + try + { + if (input == null) + { + throw new ArgumentNullException(nameof(input)); + } + + WmsCarryH? carry = await db.Queryable().SingleAsync(it => it.id == input.carry_id); + if (carry != null) + { + + // 插入子载具绑定记录 + //VisualDevModelDataCrInput visualDevModelCrInput = new() { data = new Dictionary() }; + //visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_id)] = input.carry_id; + //visualDevModelCrInput.data[nameof(WmsCarrybindH.carry_code)] = input.carry_code; + //visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_id)] = input.membercarry_id; + //visualDevModelCrInput.data[nameof(WmsCarrybindH.membercarry_code)] = input.membercarry_code; + //visualDevModelCrInput.data[nameof(WmsCarrybindH.type)] = 0; + //visualDevModelCrInput.data[nameof(WmsCarrybindH.carrystd_id)] = carry.carrystd_id; + //if (!string.IsNullOrEmpty(input.create_id)) + // visualDevModelCrInput.data[nameof(WmsCarrybindH.create_id)] = input.create_id; + + //visualDevModelCrInput.data[nameof(WmsCarrybindH.create_time)] = DateTime.Now; + //visualDevModelCrInput.data[nameof(WmsCarrybindH.loc)] = 1; + //VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSCARRYUNBIND_ID, true); + //await _runService.Create(templateEntity, visualDevModelCrInput); + + if (tranFlag) await db.Ado.BeginTranAsync(); + 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) await db.Ado.CommitTranAsync(); + } + else + { + if (carry == null) + { + throw new AppFriendlyException("没有可用的主载具", 500); + } + } + } + catch (Exception ex) + { + Logger.LogError($"【CarryUnbindWithoutTran】 {ex.Message}"); + Logger.LogError($"【CarryUnbindWithoutTran】 {ex.StackTrace}"); + if (tranFlag) await db.Ado.RollbackTranAsync(); + throw Oops.Bah(ex.Message); + } + + return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功"); + } + + public async Task CarryCodeUnbindWithoutTran(CarryCodeUnbindInput input, ISqlSugarClient dbConn = null) + { + bool isOk = false; + + ISqlSugarClient db = null; + bool tranFlag = true; + + if (dbConn == null) + { + db = _db; + } + else + { + tranFlag = false; + db = dbConn; + } + + try + { + if (input == null) + { + throw new ArgumentNullException(nameof(input)); + } + + WmsCarryH? carry = await db.Queryable().SingleAsync(it => it.id == input.carry_id); + if (carry != null) + { + if (tranFlag) await db.Ado.BeginTranAsync(); + int row = await db.Deleteable().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync(); + if (tranFlag) await db.Ado.CommitTranAsync(); + isOk = row > 0; + + Logger.LogInformation($"【CarryCodeUnbindWithoutTran】载具{carry.carry_code}已解绑,解绑条数{row}"); + //if (!isOk) + //{ + // throw Oops.Oh(ErrorCode.COM1001); + //} + } + else + { + if (carry == null) + { + throw new AppFriendlyException("没有可用的主载具", 500); + } + } + } + catch (Exception ex) + { + Logger.LogError($"【CarryCodeUnbindWithoutTran】 {ex.Message}"); + Logger.LogError($"【CarryCodeUnbindWithoutTran】 {ex.StackTrace}"); + if (tranFlag) await db.Ado.RollbackTranAsync(); + throw Oops.Bah(ex.Message); + } + return await ToApiResult(JNPF.Common.Enums.HttpStatusCode.OK, "成功"); + } } }