对接及时库存
This commit is contained in:
@@ -133,50 +133,13 @@ namespace WMS.Web.Domain.Services
|
||||
outd.SerialNumbers.AddRange(dtoDetails.SelectMany(s => s.SerialNumbers));
|
||||
entity.Details.Add(outd);
|
||||
}
|
||||
entity.Create(loginInfo.UserInfo.StaffId, outStockTask,dto.Method);
|
||||
|
||||
#region 组装库存dto
|
||||
List<BoxInventoryGenerateDto> inventoryList = new List<BoxInventoryGenerateDto>();
|
||||
var boxIds = dto.Details.GroupBy(g => g.BoxId).Select(s => s.Key).ToList();
|
||||
foreach (var boxId in boxIds)
|
||||
{
|
||||
var inventoryDetail = dto.Details.Where(w => w.BoxId == boxId).Select(s => new BoxInventoryGenerateDetailsDto()
|
||||
{
|
||||
MaterialId = s.MaterialId,
|
||||
Qty = s.Qty,
|
||||
SerialNumbers = s.SerialNumbers
|
||||
}).ToList();
|
||||
BoxInventoryGenerateDto inventory = new BoxInventoryGenerateDto()
|
||||
{
|
||||
BoxId = boxId,
|
||||
InventoryInOutMethod = dto.Method,
|
||||
StockCode = outStockTask.StockCode,
|
||||
SubStockId = dto.Details.FirstOrDefault(f => f.BoxId == boxId)?.SubStockId ?? 0,// outStockTask.Details.First().SubStockId,
|
||||
Details = inventoryDetail
|
||||
};
|
||||
inventoryList.Add(inventory);
|
||||
}
|
||||
|
||||
List<InventoryInOutDetailsGenerateDto> generateList = dto.Details.Select(s => new InventoryInOutDetailsGenerateDto()
|
||||
{
|
||||
BoxId = s.BoxId,
|
||||
InventoryInOutType = 2,
|
||||
OrderBillNo = outStockTask.BillNo,
|
||||
Qty = s.Qty,
|
||||
StockCode = outStockTask.StockCode,
|
||||
MaterialId = s.MaterialId,
|
||||
SubStockId = s.SubStockId,
|
||||
OrgCode = outStockTask.OrgCode,
|
||||
OrderType = 1,
|
||||
}).ToList();
|
||||
#endregion
|
||||
entity.Create(loginInfo.UserInfo.StaffId, outStockTask, dto.Method);
|
||||
|
||||
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)
|
||||
{
|
||||
entity = await _outStockRepositories.Add(entity, false);
|
||||
@@ -192,11 +155,11 @@ namespace WMS.Web.Domain.Services
|
||||
var res_change = await _serialNumberService.OutStock(entity, loginInfo, false);
|
||||
if (!res_change.IsSuccess) res_Rollback = res_change;
|
||||
}
|
||||
//if (res_Rollback.IsSuccess)
|
||||
//{
|
||||
// res_Inventory = await _inventoryInOutDetailsService.GenerateInOrOutDetails(generateList, false);
|
||||
// if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
|
||||
//}
|
||||
if (res_Rollback.IsSuccess)
|
||||
{
|
||||
var res_Inventory = await _boxInventoryService.GenerateOutStockBox(entity, false);
|
||||
if (!res_Inventory.IsSuccess) res_Rollback = res_Inventory;
|
||||
}
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(res_Rollback.IsSuccess ? false : true, _transaction);
|
||||
if (!res_Rollback.IsSuccess) return res_Rollback;
|
||||
|
||||
Reference in New Issue
Block a user