This commit is contained in:
tongfei
2023-11-23 16:03:34 +08:00
2 changed files with 11 additions and 28 deletions

View File

@@ -12,7 +12,7 @@ namespace WMS.Web.Domain.Mappers
/// <summary>
/// 箱信息
/// </summary>
public class BoxMapper : Profile
public class BoxMapper : Profile
{
public BoxMapper()
{
@@ -22,6 +22,10 @@ namespace WMS.Web.Domain.Mappers
CreateMap<OpsBoxResponse, Box>();
CreateMap<OpsBoxDetailsResponse, BoxDetails>();
CreateMap<BoxInventoryResponse, BoxResponse>()
.ForMember(x => x.Id, ops => ops.MapFrom(x => x.BoxId));
CreateMap<BoxInventoryDetailsResponse, BoxDetailResponse>();
CreateMap<BoxInventoryResponse, OpsBoxResponse>();
CreateMap<BoxInventoryDetailsResponse, OpsBoxDetailsResponse>();
}

View File

@@ -71,41 +71,20 @@ namespace WMS.Web.Domain.Services
entity.StockCode = subStock?.StockCode;
}
#region dto
List<BoxInventoryGenerateDto> inventoryList = new List<BoxInventoryGenerateDto>();
foreach (var entity in list)
{
var inventoryDetail = new List<BoxInventoryGenerateDetailsDto>()
{
new BoxInventoryGenerateDetailsDto()
{
MaterialId=entity.MaterialId,
Qty=entity.FinalQty
}
};
BoxInventoryGenerateDto inventory = new BoxInventoryGenerateDto()
{
BoxId = entity.BoxId,
InventoryInOutMethod = 2,//盘点单按产品修改库存
InventoryInOutType = entity.ResultType == TakeStockType.Profit ? 1 : 2,
StockCode = entity.StockCode,
SubStockId = entity.SubStockId,
Details = inventoryDetail
};
inventoryList.Add(inventory);
}
#endregion
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
Result res_Rollback = Result.ReSuccess();
bool isSuccess = true;
var res_Inventory = await _boxInventoryService.HandlBoxInventory(inventoryList, false);
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
if (res_Rollback.IsSuccess)
{
isSuccess = await _takeStockRepositories.AddRange(list, false);
if (!isSuccess) res_Rollback = Result.ReFailure(ResultCodes.DateWriteError);
}
if(res_Rollback.IsSuccess)
{
var res_Inventory = await _boxInventoryService.GenerateTakeBox(list, false);
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
}
//提交事务
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction);