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. 140
      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;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -35,4 +36,5 @@ public interface IDeliverNoteAppService :
Task<IActionResult> ExportForRAWAsync(SfsExportRequestInput requestInput); Task<IActionResult> ExportForRAWAsync(SfsExportRequestInput requestInput);
Task SumPrintAsync(string number); 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; namespace Win_in.Sfs.Wms.Store.Application;
using Volo.Abp.ObjectMapping;
using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts;
using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain;
@ -50,7 +51,20 @@ public class DeliverNoteAppService :
var dto = ObjectMapper.Map<DeliverNote, DeliverNoteDTO>(entity); var dto = ObjectMapper.Map<DeliverNote, DeliverNoteDTO>(entity);
return dto; 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>
/// 新增接口 /// 新增接口
/// </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) public virtual async Task<List<DeliverRequestDTO>> HandleListAsync(List<Guid> ids)
{ {
var entitys = await _repository.GetListAsync(r=> ids.Contains(r.Id),true).ConfigureAwait(false); var entitys = await _repository.GetListAsync(r=> ids.Contains(r.Id),true).ConfigureAwait(false);
if (entitys.Select(r => r.CustomerCode).Distinct().Count()>1) //if (entitys.Select(r => r.CustomerCode).Distinct().Count()>1)
{ //{
throw new UserFriendlyException($"所选申请涉及多个客户不能创建为一个发货单,请重新选择!"); // throw new UserFriendlyException($"所选申请涉及多个客户不能创建为一个发货单,请重新选择!");
} //}
Check.NotNull(entitys, typeof(DeliverRequest).Name); Check.NotNull(entitys, typeof(DeliverRequest).Name);
var result = await _deliverRequestManager.HandleListAsync(entitys).ConfigureAwait(false); var result = await _deliverRequestManager.HandleListAsync(entitys).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<DeliverRequest>, List<DeliverRequestDTO>>(entitys); var dtos = ObjectMapper.Map<List<DeliverRequest>, List<DeliverRequestDTO>>(entitys);

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

@ -119,97 +119,95 @@ public class DeliverRequestEventHandler
//东阳特殊逻辑 //东阳特殊逻辑
if (entitys.First().DirectCreateNote) if (entitys.First().DirectCreateNote)
{ {
var noteCreateInput = await BuildDeliverNoteAsync(entitys).ConfigureAwait(false); var noteCreateInputs = await BuildDeliverNotesAsync(entitys).ConfigureAwait(false);
await _deliverNoteApp.CreateAsync(noteCreateInput).ConfigureAwait(false); await _deliverNoteApp.CreateManyAsync(noteCreateInputs).ConfigureAwait(false);
} }
} }
#region 私有 #region 私有
private async Task<DeliverNoteEditInput> BuildDeliverNoteAsync(List<DeliverRequest> requests) private async Task<List<DeliverNoteEditInput>> BuildDeliverNotesAsync(List<DeliverRequest> requests)
{ {
var transactionType = await TransactionTypeAclService List<DeliverNoteEditInput> createInputs = new List<DeliverNoteEditInput>();
.GetByTransTypeAsync(EnumTransType.Deliver, EnumTransSubType.None).ConfigureAwait(false); var transactionType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Deliver, EnumTransSubType.None).ConfigureAwait(false);
foreach (var request in requests)
if (requests.First().DeliverRequestType == EnumDeliverRequestType.Normal)
{
transactionType = await TransactionTypeAclService.GetByTransTypeAsync(
EnumTransType.Deliver,
EnumTransSubType.Deliver_Standard).ConfigureAwait(false);
}
else if (requests.First().DeliverRequestType == EnumDeliverRequestType.FIS)
{ {
transactionType = await TransactionTypeAclService.GetByTransTypeAsync( if (request.DeliverRequestType == EnumDeliverRequestType.Normal)
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)
{ {
throw new UserFriendlyException($"储位 {detail.AreaCode} 未找到对应的成品库和半成品库。"); transactionType = await TransactionTypeAclService.GetByTransTypeAsync(
EnumTransType.Deliver,
EnumTransSubType.Deliver_Standard).ConfigureAwait(false);
} }
else if (request.DeliverRequestType == EnumDeliverRequestType.FIS)
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)
{ {
throw new UserFriendlyException($"ERP料号 {detail.ItemCode} 库存余额 {sumQty} 小于 {detail.Qty}。"); transactionType = await TransactionTypeAclService.GetByTransTypeAsync(
EnumTransType.Deliver,
EnumTransSubType.Deliver_FIS).ConfigureAwait(false);
} }
oldBalances.AddRange(balances); var createInput = ObjectMapper.Map<DeliverRequest, DeliverNoteEditInput>(request);
foreach (var balance in balances) 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); toLocation = await LocationAclService.GetByCodeAsync(customerAddress.LocationCode).ConfigureAwait(false);
var item = await ItemBasicAclService.GetByCodeAsync(balance.ItemCode).ConfigureAwait(false); Check.NotNull(toLocation, $"客户库位 {customerAddress.LocationCode} 不存在");
}
if (item != null) 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) var balances = await _balanceAppService.GetRecommendBalancesByLocationsExpectOldBalancesAsync(
{ new RecommendBalanceRequestInput
inputDetail.ToLocationCode = toLocation.Code; {
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; var item = await ItemBasicAclService.GetByCodeAsync(balance.ItemCode).ConfigureAwait(false);
inputDetail.MesDeliveryNo = detail.MesDeliveryNo;
inputDetail.IdentityNo = detail.IdentityNo; if (item != null)
inputDetail.MesDeliveryPlan = detail.MesDeliveryPlan; {
createInput.Details.Add(inputDetail); 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) private async Task<DeliverNoteEditInput> BuildDeliverNoteAsync(DeliverRequest request)
{ {

Loading…
Cancel
Save