This commit is contained in:
tongfei
2023-11-17 15:55:15 +08:00
2 changed files with 46 additions and 28 deletions

View File

@@ -93,25 +93,33 @@ namespace WMS.Web.Domain.Services
IDbContextTransaction _transaction = null;
if (isTransaction)
_transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
Result res_Rollback = Result.ReSuccess();
bool isSuccess = true;
var res_Inventory = await _boxInventoryService.GenerateChangeBox(inventoryList, false);
if (!res_Inventory.IsSuccess) isRollback = true;
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
if (res_Rollback.IsSuccess)
{
isSuccess = await _changeBoxRecordRepositories.AddRange(list, false);
if (!isSuccess) isRollback = true;
if (!isSuccess) res_Rollback=Result.ReFailure(ResultCodes.DateWriteError);
}
if (res_Rollback.IsSuccess)
{
var res_change = await _serialNumberService.ChangeBox(list, loginInfo, false);
if (!res_change.IsSuccess) isRollback = true;
if (!res_change.IsSuccess) res_Rollback = res_change;
}
if (res_Rollback.IsSuccess)
{
isSuccess = await _boxRepositories.EditEntityList(boxList, false);
if (!isSuccess) isRollback = true;
if (!isSuccess) res_Rollback= Result.ReFailure(ResultCodes.DateWriteError);
}
//提交事务
if (isTransaction)
{
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction);
if (!res_Rollback.IsSuccess) return res_Rollback;
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
}
return Result.ReSuccess();
}
/// <summary>
@@ -135,19 +143,28 @@ namespace WMS.Web.Domain.Services
inventoryList.ForEach(f => f.InventoryInOutType = IsUp == true ? 1 : 2);
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
bool isSuccess = true;
Result res_Rollback = Result.ReSuccess();
var res_Inventory = await _boxInventoryService.GenerateMoveBox(inventoryList, false);
if (!res_Inventory.IsSuccess) isRollback = true;
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
if (res_Rollback.IsSuccess)
{
isSuccess = await _moveBoxRecordRepositories.AddRange(entityList, false);
if (!isSuccess) isRollback = true;
if (!isSuccess) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
}
if (res_Rollback.IsSuccess)
{
var res_change = await _serialNumberService.MoveBox(entityList, loginInfo, false);
if (!res_change.IsSuccess) isRollback = true;
if (!res_change.IsSuccess) res_Rollback = res_change;
}
//提交事务
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction);
if (!res_Rollback.IsSuccess) return res_Rollback;
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);
return Result.ReSuccess();
}
}

View File

@@ -123,28 +123,29 @@ namespace WMS.Web.Domain.Services
#endregion
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
bool isRollback = false;
Result res_Rollback = Result.ReSuccess();
bool isSuccess = true;
//修改库存
var res_Inventory = await _boxInventoryService.HandlBoxInventory(inventoryList, false);
if (!res_Inventory.IsSuccess) isRollback = true;
if (!isRollback)
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
if (res_Rollback.IsSuccess)
{
entity = await _outStockRepositories.Add(entity, false);
if (entity == null) isRollback = true;
if (entity == null) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
}
if (!isRollback)
if (res_Rollback.IsSuccess)
{
outStockTask = await _outStockTaskRepositories.Edit(outStockTask, false);
if (outStockTask == null) isRollback = true;
if (outStockTask == null) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
}
if (!isRollback)
if (res_Rollback.IsSuccess)
{
var res_change = await _serialNumberService.OutStock(entity, loginInfo, false);
if (!res_change.IsSuccess) isRollback = true;
if (!res_change.IsSuccess) res_Rollback = res_change;
}
//提交事务
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction);
if (!res_Rollback.IsSuccess) return res_Rollback;
if (!isSuccess)
return Result.ReFailure(ResultCodes.DateWriteError);