|
|
@ -17,6 +17,7 @@ using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
|
namespace Win_in.Sfs.Wms.Store.Application; |
|
|
|
|
|
|
|
using System.Linq; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Win_in.Sfs.Basedata.Application; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
|
|
|
@ -65,45 +66,76 @@ public class PutawayNoteAppService : |
|
|
|
//[Authorize(PutawayNotePermissions.Create)]
|
|
|
|
public override async Task<PutawayNoteDTO> CreateAsync(PutawayNoteEditInput input) |
|
|
|
{ |
|
|
|
foreach (var detail in input.Details) |
|
|
|
var inputSplits = new List<PutawayNoteEditInput>(); |
|
|
|
var resultPutawayNote=new List<PutawayNote>(); |
|
|
|
|
|
|
|
//先获取所有的箱码
|
|
|
|
var selectPackingCode=input.Details.Select(p => p.ToPackingCode); |
|
|
|
var splitPackingRecList = await _splitPackingRecAppService.GetListByToPackingCode(selectPackingCode.ToList()).ConfigureAwait(false); |
|
|
|
//按照不同的条件分组
|
|
|
|
var group= splitPackingRecList.GroupBy(p => new { |
|
|
|
p.SupplierCode,p.AsnNumber,p.PoNumber |
|
|
|
}); |
|
|
|
foreach (var groupWhere in group) |
|
|
|
{ |
|
|
|
var isClosed = await _purchaseOrderManager.CheckIsCloseAsync(input.Number, input.SupplierCode, detail.ItemCode).ConfigureAwait(false); |
|
|
|
if (isClosed) |
|
|
|
var tempEditInput = new PutawayNoteEditInput(); |
|
|
|
tempEditInput.Details = new List<PutawayNoteDetailInput>(); |
|
|
|
tempEditInput.SupplierCode = groupWhere.First().SupplierCode; |
|
|
|
tempEditInput.AsnNumber = groupWhere.First().AsnNumber; |
|
|
|
tempEditInput.InspectNumber = string.Empty; |
|
|
|
tempEditInput.JobNumber = string.Empty; |
|
|
|
tempEditInput.ProductReceiptNumber = string.Empty; |
|
|
|
tempEditInput.PurchaseReceiptRequestNumber = string.Empty; |
|
|
|
tempEditInput.Type = EnumPutawayType.PurchasePutaway; |
|
|
|
foreach (var packingCode in groupWhere) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"物品名称【{detail.ItemCode}】的订单明细行以关闭无法执行采购上架!"); |
|
|
|
var detailInput=input.Details.First(p => p.ToPackingCode == packingCode.ToPackingCode); |
|
|
|
tempEditInput.Details.Add(detailInput); |
|
|
|
} |
|
|
|
var item = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
if (!item.CanMake) |
|
|
|
inputSplits.Add(tempEditInput); |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var inputSplit in inputSplits) |
|
|
|
{ |
|
|
|
foreach (var detail in inputSplit.Details) |
|
|
|
{ |
|
|
|
var isprice = await _purchasePriceSheetAppService.CheckPurPriceAsync(input.SupplierCode, detail.ItemCode).ConfigureAwait(false); |
|
|
|
if (isprice) |
|
|
|
var isClosed = await _purchaseOrderManager.CheckIsCloseAsync(inputSplit.Number, inputSplit.SupplierCode, detail.ItemCode).ConfigureAwait(false); |
|
|
|
if (isClosed) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"供应商【{input.SupplierCode}】物品名称【{detail.ItemCode}】无采购价格无法执行采购上架!"); |
|
|
|
throw new UserFriendlyException($"物品名称【{detail.ItemCode}】的订单明细行以关闭无法执行采购上架!"); |
|
|
|
} |
|
|
|
} |
|
|
|
var erpLocationItem = await _erpLocationItemAppService.CheckItemErpLocationIsAvailable(detail.ItemCode, detail.ToLocationErpCode).ConfigureAwait(false); |
|
|
|
var item = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
if (!item.CanMake) |
|
|
|
{ |
|
|
|
var isprice = await _purchasePriceSheetAppService.CheckPurPriceAsync(inputSplit.SupplierCode, detail.ItemCode).ConfigureAwait(false); |
|
|
|
if (isprice) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"供应商【{inputSplit.SupplierCode}】物品名称【{detail.ItemCode}】无采购价格无法执行采购上架!"); |
|
|
|
} |
|
|
|
} |
|
|
|
var erpLocationItem = await _erpLocationItemAppService.CheckItemErpLocationIsAvailable(detail.ItemCode, detail.ToLocationErpCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
if (erpLocationItem == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"未找到物品【{detail.ItemCode}】与ERP储位【{detail.ToLocationErpCode}】的开账信息"); |
|
|
|
} |
|
|
|
var purchasereDetail = await _purchaseReceiptNoteAppService |
|
|
|
.GetDetailByItemAndPackingAsync(detail.ItemCode, detail.ToPackingCode).ConfigureAwait(false); |
|
|
|
if (purchasereDetail != null) |
|
|
|
{ |
|
|
|
var inspectJobDto = await _inspectJobAppService |
|
|
|
.GetInspectNoteDetailByPackingCodeAsync(detail.ToPackingCode).ConfigureAwait(false); |
|
|
|
if (inspectJobDto.JobStatus != EnumJobStatus.Done) |
|
|
|
if (erpLocationItem == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"包含【{detail.ToPackingCode}】箱码的报检单,尚未完成质检"); |
|
|
|
throw new UserFriendlyException($"未找到物品【{detail.ItemCode}】与ERP储位【{detail.ToLocationErpCode}】的开账信息"); |
|
|
|
} |
|
|
|
var purchasereDetail = await _purchaseReceiptNoteAppService |
|
|
|
.GetDetailByItemAndPackingAsync(detail.ItemCode, detail.ToPackingCode).ConfigureAwait(false); |
|
|
|
if (purchasereDetail != null) |
|
|
|
{ |
|
|
|
var inspectJobDto = await _inspectJobAppService |
|
|
|
.GetInspectNoteDetailByPackingCodeAsync(detail.ToPackingCode).ConfigureAwait(false); |
|
|
|
if (inspectJobDto.JobStatus != EnumJobStatus.Done) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"包含【{detail.ToPackingCode}】箱码的报检单,尚未完成质检"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
var entity = ObjectMapper.Map<PutawayNoteEditInput, PutawayNote>(inputSplit); |
|
|
|
resultPutawayNote.Add( await _putawayNoteManager.CreateByPurchaseAsync(entity).ConfigureAwait(false)); |
|
|
|
} |
|
|
|
|
|
|
|
var entity = ObjectMapper.Map<PutawayNoteEditInput, PutawayNote>(input); |
|
|
|
var result = await _putawayNoteManager.CreateByPurchaseAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dto = ObjectMapper.Map<PutawayNote, PutawayNoteDTO>(result); |
|
|
|
var dto = ObjectMapper.Map<PutawayNote, PutawayNoteDTO>(resultPutawayNote.First()); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|