diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs index 45198d3f..1b00f2bf 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAEmptyOutstockService .cs @@ -151,7 +151,7 @@ namespace Tnb.WarehouseMgr //更新明细表 WmsEmptyOutstockD wmsEmptyOutstockD = new(); wmsEmptyOutstockD.id = SnowflakeIdHelper.NextId(); - wmsEmptyOutstockD.bill_id = input.data[nameof(WmsEmptyOutstockH.bill_code)]?.ToString()!; + wmsEmptyOutstockD.bill_id = preTaskUpInput.RquireId; wmsEmptyOutstockD.biz_type = WmsWareHouseConst.BIZTYPE_WMSEPTYOUTSTK_ID; wmsEmptyOutstockD.location_id = ePoint.location_id; wmsEmptyOutstockD.status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID; @@ -198,9 +198,29 @@ namespace Tnb.WarehouseMgr public override async Task ModifyAsync(WareHouseUpInput input) { + if (input == null) throw new ArgumentNullException(nameof(input)); - var isOk = await _db.Updateable().SetColumns(it => new WmsEmptyInstock { status = WmsWareHouseConst.BILLSTATUS_COMPLETE_ID }).Where(it => it.id == input.requireId).ExecuteCommandHasChangeAsync(); - if (!isOk) throw Oops.Oh(ErrorCode.COM1001); + //根据载具更新明细表状态 + try + { + 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)) + { + 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; + + } } } }