This commit is contained in:
tongfei
2023-11-16 17:37:39 +08:00
3 changed files with 58 additions and 14 deletions

View File

@@ -3606,6 +3606,11 @@
出库任务单Id 出库任务单Id
</summary> </summary>
</member> </member>
<member name="P:WMS.Web.Core.Dto.OutStock.SaveOutStockRequest.Method">
<summary>
出库方式 必填1-box按箱2-product按产品
</summary>
</member>
<member name="P:WMS.Web.Core.Dto.OutStock.SaveOutStockDetailsRequest.MaterialId"> <member name="P:WMS.Web.Core.Dto.OutStock.SaveOutStockDetailsRequest.MaterialId">
<summary> <summary>
物料Id 物料Id

View File

@@ -15,6 +15,11 @@ namespace WMS.Web.Core.Dto.OutStock
///</summary> ///</summary>
[Required(ErrorMessage = "出库单不能为空")] [Required(ErrorMessage = "出库单不能为空")]
public int TaskId { get; set; } public int TaskId { get; set; }
/// <summary>
/// 出库方式 必填1-box按箱2-product按产品
/// </summary>
[Required(ErrorMessage = "出库方式不能为空")]
public int Method { get; set; }
public List<SaveOutStockDetailsRequest> Details { get; set; } = new List<SaveOutStockDetailsRequest>(); public List<SaveOutStockDetailsRequest> Details { get; set; } = new List<SaveOutStockDetailsRequest>();
} }

View File

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