From 8f4f65f67b001e2c99266368ba427ba6c764510f Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 20 Jun 2023 14:49:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A9=BA=E8=BD=BD=E5=85=B7=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=8B=E5=8A=A1=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WmsEmptyOutstockService .cs | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs index 428a03a2..d6beff87 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs @@ -186,16 +186,28 @@ namespace Tnb.WarehouseMgr public async override Task ModifyAsync(WareHouseUpInput input) { if (input == null) throw new ArgumentNullException(nameof(input)); - //根据载具更新明细表状态 - var isOk = await _db.Updateable().SetColumns(it => new WmsEmptyOutstockD { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.bill_id == input.requireId && input.carryIds.Contains(it.carry_id)).ExecuteCommandHasChangeAsync(); - - var emptyCarrys = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); - // 判断所有明细是否都完成 - if (emptyCarrys?.Count > 0 && emptyCarrys.All(x => x.status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) + try { - await _db.Updateable().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); + await _db.Ado.BeginTranAsync(); + + //根据载具更新明细表状态 + var isOk = await _db.Updateable().SetColumns(it => new WmsEmptyOutstockD { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.bill_id == input.requireId && input.carryIds.Contains(it.carry_id)).ExecuteCommandHasChangeAsync(); + + var emptyCarrys = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); + // 判断所有明细是否都完成 + if (emptyCarrys?.Count > 0 && emptyCarrys.All(x => x.status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) + { + isOk = await _db.Updateable().SetColumns(it => new WmsEmptyOutstockH { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); + } + if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + + await _db.Ado.CommitTranAsync(); + } + catch (Exception) + { + await _db.Ado.RollbackTranAsync(); + throw; } - if (!isOk) throw Oops.Oh(ErrorCode.COM1001); } } }