出库修改库存
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Core.Dto;
|
||||
using WMS.Web.Core.Dto.Erp;
|
||||
using WMS.Web.Core.Dto.Inventory;
|
||||
using WMS.Web.Core.Dto.Login;
|
||||
using WMS.Web.Core.Dto.OutStock;
|
||||
using WMS.Web.Core.Dto.TakeStock;
|
||||
@@ -34,10 +35,12 @@ namespace WMS.Web.Domain.Services
|
||||
private readonly IOutStockTaskService _outStockTaskService;
|
||||
private readonly IErpService _erpService;
|
||||
private readonly ISerialNumberService _serialNumberService;
|
||||
private readonly IBoxInventoryService _boxInventoryService;
|
||||
public OutStockService(IMapper mapper, ILoginService loginService,
|
||||
IBasicsRepositories transactionRepositories,
|
||||
IOutStockRepositories outStockRepositories, IOutStockTaskRepositories outStockTaskRepositories,
|
||||
IOutStockTaskService outStockTaskService, IErpService erpService, ISerialNumberService serialNumberService)
|
||||
IOutStockTaskService outStockTaskService, IErpService erpService, ISerialNumberService serialNumberService,
|
||||
IBoxInventoryService boxInventoryService)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_loginService = loginService;
|
||||
@@ -47,6 +50,7 @@ namespace WMS.Web.Domain.Services
|
||||
_outStockTaskService = outStockTaskService;
|
||||
_erpService = erpService;
|
||||
_serialNumberService = serialNumberService;
|
||||
_boxInventoryService = boxInventoryService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 出库单
|
||||
@@ -95,21 +99,50 @@ namespace WMS.Web.Domain.Services
|
||||
}
|
||||
entity.Create(loginInfo.UserInfo.StaffId, outStockTask);
|
||||
|
||||
|
||||
//需要填写序列号
|
||||
//需要修改库存
|
||||
//需要同步金蝶
|
||||
#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.Details.First().StockCode,
|
||||
SubStockId = outStockTask.Details.First().SubStockId,
|
||||
Details = inventoryDetail
|
||||
};
|
||||
inventoryList.Add(inventory);
|
||||
}
|
||||
#endregion
|
||||
|
||||
IDbContextTransaction _transaction = _transactionRepositories.GetTransaction();
|
||||
bool isRollback = false;
|
||||
bool isSuccess = true;
|
||||
entity = await _outStockRepositories.Add(entity, false);
|
||||
|
||||
if (entity == null) isRollback = true;
|
||||
outStockTask = await _outStockTaskRepositories.Edit(outStockTask, false);
|
||||
if (outStockTask == null) isRollback = true;
|
||||
var res_change = await _serialNumberService.OutStock(entity, loginInfo, false);
|
||||
if (!res_change.IsSuccess) isRollback = true;
|
||||
//修改库存
|
||||
var res_Inventory = await _boxInventoryService.HandlBoxInventory(inventoryList, false);
|
||||
if (!res_Inventory.IsSuccess) isRollback = true;
|
||||
if (!isRollback)
|
||||
{
|
||||
entity = await _outStockRepositories.Add(entity, false);
|
||||
if (entity == null) isRollback = true;
|
||||
}
|
||||
if (!isRollback)
|
||||
{
|
||||
outStockTask = await _outStockTaskRepositories.Edit(outStockTask, false);
|
||||
if (outStockTask == null) isRollback = true;
|
||||
}
|
||||
if (!isRollback)
|
||||
{
|
||||
var res_change = await _serialNumberService.OutStock(entity, loginInfo, false);
|
||||
if (!res_change.IsSuccess) isRollback = true;
|
||||
}
|
||||
//提交事务
|
||||
isSuccess = _transactionRepositories.CommitTransaction(isRollback, _transaction);
|
||||
if (!isSuccess)
|
||||
@@ -134,10 +167,11 @@ namespace WMS.Web.Domain.Services
|
||||
foreach (var s in failList)
|
||||
{
|
||||
var erp_details = entity.Details.SelectMany(s => s.ErpDetails).Select(s => s.Erp_DetailId).ToList();
|
||||
var erpDto = new ErpPushDto() {
|
||||
var erpDto = new ErpPushDto()
|
||||
{
|
||||
FormId = FormIdParam.SAL_DELIVERYNOTICE.ToString(),
|
||||
Numbers = new List<string>() { s },
|
||||
Type="",
|
||||
Type = "",
|
||||
DetailsId = string.Join(",", erp_details)
|
||||
};
|
||||
//下推金蝶
|
||||
|
||||
Reference in New Issue
Block a user