|
|
@ -1,7 +1,10 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Net.Http; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Castle.Components.DictionaryAdapter; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.EventBus; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
@ -13,6 +16,8 @@ using Win_in.Sfs.Shared.Event; |
|
|
|
using Win_in.Sfs.Wms.Inventory.Domain.Acl.ItemBasic; |
|
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
|
using static Win_in.Sfs.Wms.Store.Domain.Shared.StoreSettings; |
|
|
|
using SupplierAsn = Win_in.Sfs.Wms.Store.Domain.SupplierAsn; |
|
|
|
|
|
|
|
namespace Win_in.Sfs.Wms.Store.Event.Orders; |
|
|
|
|
|
|
@ -27,13 +32,19 @@ public class PurchaseOrderEventHandler |
|
|
|
private readonly IItemPackAppService _itemPackAppService; |
|
|
|
private readonly ISupplierItemAppService _supplierItemAppService; |
|
|
|
private readonly IDockAppService _dockAppService; |
|
|
|
private readonly IInventoryLabelAppService _inventoryLabelAppService; |
|
|
|
private readonly ISupplierAppService _supplierAppService; |
|
|
|
|
|
|
|
|
|
|
|
public PurchaseOrderEventHandler(ISupplierAsnAppService supplierAsnAppService, |
|
|
|
ILabelDefinitionAppService labelDefinitionAppService, |
|
|
|
IItemBasicAppService itemBasicAppService, |
|
|
|
IItemPackAppService itemPackAppService, |
|
|
|
ISupplierItemAppService supplierItemAppService, |
|
|
|
IDockAppService dockAppService) |
|
|
|
IDockAppService dockAppService, |
|
|
|
IInventoryLabelAppService inventoryLabelAppService, |
|
|
|
IPurchaseOrderManager purchaseOrderManager, |
|
|
|
ISupplierAppService supplierAppService) |
|
|
|
{ |
|
|
|
_supplierAsnAppService = supplierAsnAppService; |
|
|
|
_labelDefinitionAppService = labelDefinitionAppService; |
|
|
@ -41,6 +52,8 @@ public class PurchaseOrderEventHandler |
|
|
|
_itemPackAppService = itemPackAppService; |
|
|
|
_supplierItemAppService = supplierItemAppService; |
|
|
|
_dockAppService = dockAppService; |
|
|
|
_inventoryLabelAppService = inventoryLabelAppService; |
|
|
|
_supplierAppService = supplierAppService; |
|
|
|
} |
|
|
|
|
|
|
|
//创建采购订单
|
|
|
@ -81,7 +94,7 @@ public class PurchaseOrderEventHandler |
|
|
|
|
|
|
|
//收货口 //todo 处理有问题是否要和供应商关联
|
|
|
|
var dock = await _dockAppService.GetAllListByFilterAsync( |
|
|
|
new SfsBaseDataRequestInputBase() { Condition = new Condition(), MaxResultCount = 99, SkipCount = 0, Sorting = string.Empty }, true).ConfigureAwait(false); |
|
|
|
new SfsBaseDataRequestInputBase() { Condition = new Condition(){Filters = new List<Filter>()}, MaxResultCount = 99, SkipCount = 0, Sorting = string.Empty }, true).ConfigureAwait(false); |
|
|
|
supplierAsnEditInput.DockCode = dock.First().Code; |
|
|
|
|
|
|
|
//要货单号
|
|
|
@ -90,10 +103,8 @@ public class PurchaseOrderEventHandler |
|
|
|
//生效日期
|
|
|
|
supplierAsnEditInput.ActiveDate = Clock.Now; |
|
|
|
|
|
|
|
//一次性返回所有箱码
|
|
|
|
var generateManyAsync =await _labelDefinitionAppService |
|
|
|
.GenerateManyAsync(EnumLabelType.PurchaseLabel.ToString(), Clock.Now.ToString(SharedConst.TimeFormat), |
|
|
|
supplierAsnEditInput.Details.Count).ConfigureAwait(false); |
|
|
|
//发货单号
|
|
|
|
supplierAsnEditInput.Number = await _supplierAsnAppService.GenerateSupplierAsnNumberAsync(supplierAsnEditInput.ActiveDate).ConfigureAwait(false); |
|
|
|
|
|
|
|
//所有的物品Code
|
|
|
|
var itemCodes = purchaseOrder.Details.GroupBy(p => p.ItemCode).Select(p => p.Key); |
|
|
@ -103,6 +114,11 @@ public class PurchaseOrderEventHandler |
|
|
|
var ItemPacks = new List<ItemPackDTO>();//一次性返回所有物品包装信息
|
|
|
|
var supplierItemDtos = new List<SupplierItemDTO>();//一次性返回所有供应商物品信息
|
|
|
|
|
|
|
|
//一次性返回所有箱码
|
|
|
|
var generateManyAsync = await _labelDefinitionAppService |
|
|
|
.GenerateManyAsync(EnumLabelType.PurchaseLabel.ToString(), Clock.Now.ToString(SharedConst.TimeFormat), |
|
|
|
supplierAsnEditInput.Details.Count).ConfigureAwait(false); |
|
|
|
|
|
|
|
foreach (var itemCode in itemCodes)//查询
|
|
|
|
{ |
|
|
|
var itemPackDtos = await _itemPackAppService.GetListByItemCodeAsync(itemCode).ConfigureAwait(false); |
|
|
@ -137,8 +153,95 @@ public class PurchaseOrderEventHandler |
|
|
|
detail.SupplierPackUom= supplierItemDto.SupplierPackUom; |
|
|
|
}); |
|
|
|
|
|
|
|
//赋值箱码 创建箱码
|
|
|
|
var supplierDto= await _supplierAppService.GetByCodeAsync(supplierAsnEditInput.SupplierCode).ConfigureAwait(false); |
|
|
|
await CreateLabelAsync(supplierAsnEditInput, supplierDto,itemBasicDtos,supplierItemDtos).ConfigureAwait(false); |
|
|
|
|
|
|
|
return supplierAsnEditInput; |
|
|
|
} |
|
|
|
|
|
|
|
//创建 发货标签
|
|
|
|
private async Task CreateLabelAsync(SupplierAsnEditInput supplierAsnEditInput, SupplierDTO supplierDtos, |
|
|
|
List<ItemBasicDTO> itemBasicDtos, List<SupplierItemDTO> supplierItemDtos) |
|
|
|
{ |
|
|
|
var inventoryLabelDtos = new List<InventoryLabelEditInput>(); |
|
|
|
|
|
|
|
foreach (var supplierAsnDetail in supplierAsnEditInput.Details) |
|
|
|
{ |
|
|
|
var supplierDto= supplierDtos; |
|
|
|
var itemBasicDto = itemBasicDtos.First(p => p.Code == supplierAsnDetail.ItemCode); |
|
|
|
var supplierItemDto= supplierItemDtos.First(p => |
|
|
|
p.ItemCode == supplierAsnDetail.ItemCode && p.SupplierCode == supplierAsnEditInput.SupplierCode); |
|
|
|
|
|
|
|
var inputLabel = await BuildInventoryLabelCreateInputAsync(supplierAsnEditInput, supplierAsnDetail,supplierDto, itemBasicDto,supplierItemDto).ConfigureAwait(false); |
|
|
|
inventoryLabelDtos.Add(inputLabel); |
|
|
|
await _inventoryLabelAppService.CreateAsync(inputLabel).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//构造 采购标签
|
|
|
|
private async Task<InventoryLabelEditInput> BuildInventoryLabelCreateInputAsync(SupplierAsnEditInput supplierAsn, |
|
|
|
SupplierAsnDetailInput supplierAsnDetail, |
|
|
|
SupplierDTO supplierDto, |
|
|
|
ItemBasicDTO itemBasicDto, |
|
|
|
SupplierItemDTO supplierItemDto |
|
|
|
) |
|
|
|
{ |
|
|
|
if (itemBasicDto == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{supplierAsnDetail.ItemCode}物品信息为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (supplierDto == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (supplierItemDto == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商零件或{supplierItemDto.ItemCode}物品信息为空"); |
|
|
|
} |
|
|
|
|
|
|
|
var inputLabel = new InventoryLabelEditInput() |
|
|
|
{ |
|
|
|
LabelType = EnumLabelType.PurchaseLabel, |
|
|
|
ArriveDate = DateTime.Now, |
|
|
|
Qty = supplierAsnDetail.Qty, |
|
|
|
PoNumber = supplierAsnDetail.PoNumber, |
|
|
|
Uom = supplierAsnDetail.Uom, |
|
|
|
ItemDesc2 = itemBasicDto.Desc2, |
|
|
|
AsnNumber = supplierAsn.Number, |
|
|
|
ItemCode = supplierAsnDetail.ItemCode, |
|
|
|
ItemName = supplierAsnDetail.ItemName, |
|
|
|
ItemDesc1 = itemBasicDto.Desc1, |
|
|
|
SupplierBatch = supplierAsnDetail.SupplierBatch, |
|
|
|
ProduceDate = supplierAsnDetail.ProduceDate, |
|
|
|
ExpireDate = DateTime.Now.AddDays(itemBasicDto.GetValidateDays()), |
|
|
|
FullBarcodeString = supplierAsnDetail.PackingCode, |
|
|
|
ExtraProperties = { }, |
|
|
|
LabelStatus = LabelStatus.Enable, |
|
|
|
LocationErpCode = supplierAsnDetail.RecommendErpCode, |
|
|
|
Lot = supplierAsnDetail.Lot, |
|
|
|
RecommendLocationCode = supplierAsnDetail.RecommendErpCode, |
|
|
|
Remark = supplierAsnDetail.Remark, |
|
|
|
Specifications = itemBasicDto.Color, |
|
|
|
StdPackQty = supplierAsnDetail.StdPackQty, |
|
|
|
SupplierCode = supplierAsn.SupplierCode, |
|
|
|
SupplierItemCode = supplierItemDto.SupplierItemCode, |
|
|
|
SupplierItemName = supplierItemDto.ItemName, |
|
|
|
SupplierName = supplierDto.Name, |
|
|
|
SupplierSimpleName = supplierDto.ShortName, |
|
|
|
Team = null, |
|
|
|
ProdLine = null, |
|
|
|
QLevel = null, |
|
|
|
QualityFile = null, |
|
|
|
RpNumber = null, |
|
|
|
Shift = null, |
|
|
|
ContainerCode = null, |
|
|
|
Code = supplierAsnDetail.PackingCode |
|
|
|
}; |
|
|
|
return inputLabel; |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|