Browse Source

成品发运修改

dev_DY_CC
lvzb 11 months ago
parent
commit
af5f739091
  1. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/DeliverNotes/IDeliverNoteAppService.cs
  2. 14
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/DeliverNotes/DeliverNoteAppService.cs
  3. 8
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs
  4. 142
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/DeliverRequestEventHandler.cs

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/DeliverNotes/IDeliverNoteAppService.cs

@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
@ -35,4 +36,5 @@ public interface IDeliverNoteAppService :
Task<IActionResult> ExportForRAWAsync(SfsExportRequestInput requestInput);
Task SumPrintAsync(string number);
Task<List<DeliverNoteDTO>> CreateManyAsync(List<DeliverNoteEditInput> inputs);
}

14
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/DeliverNotes/DeliverNoteAppService.cs

@ -13,6 +13,7 @@ using Win_in.Sfs.Wms.Store.Domain.Shared;
namespace Win_in.Sfs.Wms.Store.Application;
using Volo.Abp.ObjectMapping;
using Win_in.Sfs.Shared.Application.Contracts;
using Win_in.Sfs.Shared.Domain;
@ -50,7 +51,20 @@ public class DeliverNoteAppService :
var dto = ObjectMapper.Map<DeliverNote, DeliverNoteDTO>(entity);
return dto;
}
/// <summary>
/// 新增接口
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("create-many")]
public async Task<List<DeliverNoteDTO>> CreateManyAsync(List<DeliverNoteEditInput> inputs)
{
var entitys = ObjectMapper.Map<List<DeliverNoteEditInput>, List<DeliverNote>>(inputs);
await _deliverNoteManager.CreateManyAsync(entitys).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<DeliverNote>, List<DeliverNoteDTO>>(entitys);
return dtos;
}
/// <summary>
/// 新增接口
/// </summary>

8
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs

@ -163,10 +163,10 @@ IItemBasicAppService itemBasicAppService)
public virtual async Task<List<DeliverRequestDTO>> HandleListAsync(List<Guid> ids)
{
var entitys = await _repository.GetListAsync(r=> ids.Contains(r.Id),true).ConfigureAwait(false);
if (entitys.Select(r => r.CustomerCode).Distinct().Count()>1)
{
throw new UserFriendlyException($"所选申请涉及多个客户不能创建为一个发货单,请重新选择!");
}
//if (entitys.Select(r => r.CustomerCode).Distinct().Count()>1)
//{
// throw new UserFriendlyException($"所选申请涉及多个客户不能创建为一个发货单,请重新选择!");
//}
Check.NotNull(entitys, typeof(DeliverRequest).Name);
var result = await _deliverRequestManager.HandleListAsync(entitys).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<DeliverRequest>, List<DeliverRequestDTO>>(entitys);

142
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/DeliverRequestEventHandler.cs

@ -119,98 +119,96 @@ public class DeliverRequestEventHandler
//东阳特殊逻辑
if (entitys.First().DirectCreateNote)
{
var noteCreateInput = await BuildDeliverNoteAsync(entitys).ConfigureAwait(false);
await _deliverNoteApp.CreateAsync(noteCreateInput).ConfigureAwait(false);
var noteCreateInputs = await BuildDeliverNotesAsync(entitys).ConfigureAwait(false);
await _deliverNoteApp.CreateManyAsync(noteCreateInputs).ConfigureAwait(false);
}
}
#region 私有
private async Task<DeliverNoteEditInput> BuildDeliverNoteAsync(List<DeliverRequest> requests)
private async Task<List<DeliverNoteEditInput>> BuildDeliverNotesAsync(List<DeliverRequest> requests)
{
var transactionType = await TransactionTypeAclService
.GetByTransTypeAsync(EnumTransType.Deliver, EnumTransSubType.None).ConfigureAwait(false);
if (requests.First().DeliverRequestType == EnumDeliverRequestType.Normal)
{
transactionType = await TransactionTypeAclService.GetByTransTypeAsync(
EnumTransType.Deliver,
EnumTransSubType.Deliver_Standard).ConfigureAwait(false);
}
else if (requests.First().DeliverRequestType == EnumDeliverRequestType.FIS)
List<DeliverNoteEditInput> createInputs = new List<DeliverNoteEditInput>();
var transactionType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Deliver, EnumTransSubType.None).ConfigureAwait(false);
foreach (var request in requests)
{
transactionType = await TransactionTypeAclService.GetByTransTypeAsync(
EnumTransType.Deliver,
EnumTransSubType.Deliver_FIS).ConfigureAwait(false);
}
var createInput = ObjectMapper.Map<DeliverRequest, DeliverNoteEditInput>(requests.First());
var customerAddress =
(await _customerAddressApp.GetByCustomerCodeAsync(createInput.CustomerCode).ConfigureAwait(false))
.FirstOrDefault();
LocationDTO toLocation = null;
if (customerAddress != null && !string.IsNullOrEmpty(customerAddress.LocationCode))
{
toLocation = await LocationAclService.GetByCodeAsync(customerAddress.LocationCode).ConfigureAwait(false);
Check.NotNull(toLocation, $"客户库位 {customerAddress.LocationCode} 不存在");
}
createInput.Details = new List<DeliverNoteDetailInput>();
List<BalanceDTO> oldBalances = new List<BalanceDTO>();
foreach (var detail in requests.SelectMany(r=>r.Details))
{
var locations = await _locationAppService.GetListByTypesAndErpCodeAsync(transactionType.OutLocationTypes, detail.AreaCode).ConfigureAwait(false);
if (locations.Count <= 0)
if (request.DeliverRequestType == EnumDeliverRequestType.Normal)
{
throw new UserFriendlyException($"储位 {detail.AreaCode} 未找到对应的成品库和半成品库。");
transactionType = await TransactionTypeAclService.GetByTransTypeAsync(
EnumTransType.Deliver,
EnumTransSubType.Deliver_Standard).ConfigureAwait(false);
}
var balances = await _balanceAppService.GetRecommendBalancesByLocationsExpectOldBalancesAsync(
new RecommendBalanceRequestInput
{
ItemCode = detail.ItemCode,
Qty = detail.Qty,
Locations = locations.Select(r => r.Code).ToList(),
Statuses = transactionType.OutInventoryStatuses,
OldBalances=oldBalances,
}).ConfigureAwait(false);
var sumQty = balances.Sum(t => t.Qty);
if (sumQty < detail.Qty)
else if (request.DeliverRequestType == EnumDeliverRequestType.FIS)
{
throw new UserFriendlyException($"ERP料号 {detail.ItemCode} 库存余额 {sumQty} 小于 {detail.Qty}。");
transactionType = await TransactionTypeAclService.GetByTransTypeAsync(
EnumTransType.Deliver,
EnumTransSubType.Deliver_FIS).ConfigureAwait(false);
}
oldBalances.AddRange(balances);
foreach (var balance in balances)
var createInput = ObjectMapper.Map<DeliverRequest, DeliverNoteEditInput>(request);
var customerAddress = (await _customerAddressApp.GetByCustomerCodeAsync(createInput.CustomerCode).ConfigureAwait(false)).FirstOrDefault();
LocationDTO toLocation = null;
if (customerAddress != null && !string.IsNullOrEmpty(customerAddress.LocationCode))
{
var inputDetail = ObjectMapper.Map<BalanceDTO, DeliverNoteDetailInput>(balance);
var item = await ItemBasicAclService.GetByCodeAsync(balance.ItemCode).ConfigureAwait(false);
toLocation = await LocationAclService.GetByCodeAsync(customerAddress.LocationCode).ConfigureAwait(false);
if (item != null)
Check.NotNull(toLocation, $"客户库位 {customerAddress.LocationCode} 不存在");
}
createInput.Details = new List<DeliverNoteDetailInput>();
List<BalanceDTO> oldBalances = new List<BalanceDTO>();
foreach (var detail in request.Details)
{
var locations = await _locationAppService.GetListByTypesAndErpCodeAsync(transactionType.OutLocationTypes, detail.AreaCode).ConfigureAwait(false);
if (locations.Count <= 0)
{
inputDetail.StdPackQty = item.StdPackQty;
throw new UserFriendlyException($"储位 {detail.AreaCode} 未找到对应的成品库和半成品库。");
}
if (toLocation != null)
{
inputDetail.ToLocationCode = toLocation.Code;
var balances = await _balanceAppService.GetRecommendBalancesByLocationsExpectOldBalancesAsync(
new RecommendBalanceRequestInput
{
ItemCode = detail.ItemCode,
Qty = detail.Qty,
Locations = locations.Select(r => r.Code).ToList(),
Statuses = transactionType.OutInventoryStatuses,
OldBalances = oldBalances,
}).ConfigureAwait(false);
inputDetail.ToLocationErpCode = toLocation.ErpLocationCode;
var sumQty = balances.Sum(t => t.Qty);
if (sumQty < detail.Qty)
{
throw new UserFriendlyException($"ERP料号 {detail.ItemCode} 库存余额 {sumQty} 小于 {detail.Qty}。");
}
oldBalances.AddRange(balances);
foreach (var balance in balances)
{
var inputDetail = ObjectMapper.Map<BalanceDTO, DeliverNoteDetailInput>(balance);
inputDetail.ExtraProperties = detail.ExtraProperties;
inputDetail.MesDeliveryNo = detail.MesDeliveryNo;
inputDetail.IdentityNo = detail.IdentityNo;
inputDetail.MesDeliveryPlan = detail.MesDeliveryPlan;
createInput.Details.Add(inputDetail);
var item = await ItemBasicAclService.GetByCodeAsync(balance.ItemCode).ConfigureAwait(false);
if (item != null)
{
inputDetail.StdPackQty = item.StdPackQty;
}
if (toLocation != null)
{
inputDetail.ToLocationCode = toLocation.Code;
inputDetail.ToLocationErpCode = toLocation.ErpLocationCode;
}
inputDetail.ExtraProperties = detail.ExtraProperties;
inputDetail.MesDeliveryNo = detail.MesDeliveryNo;
inputDetail.IdentityNo = detail.IdentityNo;
inputDetail.MesDeliveryPlan = detail.MesDeliveryPlan;
createInput.Details.Add(inputDetail);
}
}
createInputs.Add(createInput);
}
return createInput;
}
return createInputs;
}
private async Task<DeliverNoteEditInput> BuildDeliverNoteAsync(DeliverRequest request)
{
var transactionType = await TransactionTypeAclService

Loading…
Cancel
Save