|
|
@ -1,26 +1,20 @@ |
|
|
|
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.Data; |
|
|
|
using Volo.Abp.EventBus; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
using Win_in.Sfs.Basedata.Domain; |
|
|
|
using Win_in.Sfs.Label.Application.Contracts; |
|
|
|
using Win_in.Sfs.Label.Domain.Shared; |
|
|
|
using Win_in.Sfs.Shared.Domain; |
|
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
|
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; |
|
|
|
|
|
|
@ -67,7 +61,10 @@ public class PurchaseOrderEventHandler |
|
|
|
{ |
|
|
|
var entity = eventData.Entity; |
|
|
|
|
|
|
|
await CreateSupplierAsnAsync(entity).ConfigureAwait(false); |
|
|
|
if (entity.Remark != "接口数据") |
|
|
|
{ |
|
|
|
await CreateSupplierAsnAsync(entity).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//批量创建
|
|
|
@ -78,7 +75,10 @@ public class PurchaseOrderEventHandler |
|
|
|
|
|
|
|
foreach (var entity in entities) |
|
|
|
{ |
|
|
|
await CreateSupplierAsnAsync(entity).ConfigureAwait(false); |
|
|
|
if (entity.Remark != "接口数据") |
|
|
|
{ |
|
|
|
await CreateSupplierAsnAsync(entity).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -95,18 +95,25 @@ public class PurchaseOrderEventHandler |
|
|
|
//构造供应商到货DTO
|
|
|
|
private async Task<SupplierAsnEditInput> BuildSupplierAsnAsync(PurchaseOrder purchaseOrder) |
|
|
|
{ |
|
|
|
var supplierAsnEditInput= ObjectMapper.Map<PurchaseOrder, SupplierAsnEditInput>(purchaseOrder); |
|
|
|
supplierAsnEditInput.Details = new EditableList<SupplierAsnDetailInput>();//导入的是采购订单 所以下面要根据标包计算 拆成多个发货单
|
|
|
|
var supplierAsnEditInput = ObjectMapper.Map<PurchaseOrder, SupplierAsnEditInput>(purchaseOrder); |
|
|
|
supplierAsnEditInput.Details = new EditableList<SupplierAsnDetailInput>(); //导入的是采购订单 所以下面要根据标包计算 拆成多个发货单
|
|
|
|
|
|
|
|
//所有的物品Code
|
|
|
|
var itemCodes = purchaseOrder.Details.GroupBy(p =>new{ p.ItemCode,p.Lot}).Select(p => p.Key.ItemCode); |
|
|
|
var itemCodes = purchaseOrder.Details.GroupBy(p => new { p.ItemCode, p.Lot }).Select(p => p.Key.ItemCode); |
|
|
|
|
|
|
|
//收货口
|
|
|
|
var dock = await _dockAppService.GetAllListByFilterAsync( |
|
|
|
new SfsBaseDataRequestInputBase() { Condition = new Condition() { Filters = new List<Filter>() }, 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); |
|
|
|
|
|
|
|
//供应商窗口
|
|
|
|
var supplierTimeWindowDtos = await _supplierTimeWindowAppService.GetListBySupplierCodeAsync(purchaseOrder.SupplierCode).ConfigureAwait(false); |
|
|
|
var supplierTimeWindowDtos = await _supplierTimeWindowAppService |
|
|
|
.GetListBySupplierCodeAsync(purchaseOrder.SupplierCode).ConfigureAwait(false); |
|
|
|
if (!supplierTimeWindowDtos.Any()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"供应商窗口【{purchaseOrder.SupplierCode}】没设置"); |
|
|
@ -114,21 +121,22 @@ public class PurchaseOrderEventHandler |
|
|
|
|
|
|
|
//一次性返回所有物品信息
|
|
|
|
var itemBasicDtos = await _itemBasicAppService.GetByCodesAsync(itemCodes).ConfigureAwait(false); |
|
|
|
var ItemPacks = new List<ItemPackDTO>();//一次性返回所有物品包装信息
|
|
|
|
var supplierItemDtos = new List<SupplierItemDTO>();//一次性返回所有供应商物品信息
|
|
|
|
var ItemPacks = new List<ItemPackDTO>(); //一次性返回所有物品包装信息
|
|
|
|
var supplierItemDtos = new List<SupplierItemDTO>(); //一次性返回所有供应商物品信息
|
|
|
|
|
|
|
|
//供应商信息
|
|
|
|
var supplierDto =await _supplierAppService.GetByCodeAsync(purchaseOrder.SupplierCode).ConfigureAwait(false); |
|
|
|
var supplierDto = await _supplierAppService.GetByCodeAsync(purchaseOrder.SupplierCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
//所有的标签
|
|
|
|
List<InventoryLabelEditInput> inventoryLabelEditInputs = new List<InventoryLabelEditInput>(); |
|
|
|
var inventoryLabelEditInputs = new List<InventoryLabelEditInput>(); |
|
|
|
|
|
|
|
foreach (var itemCode in itemCodes)//查询
|
|
|
|
foreach (var itemCode in itemCodes) //查询
|
|
|
|
{ |
|
|
|
//var itemPackDtos = await _itemPackAppService.GetListByItemCodeAsync(itemCode).ConfigureAwait(false);
|
|
|
|
//var itemPackDto = itemPackDtos.First();
|
|
|
|
//ItemPacks.Add(itemPackDto);
|
|
|
|
var supplierItem = await _supplierItemAppService.GetBySupplierCodeAndItemCodeAsync(purchaseOrder.SupplierCode, itemCode).ConfigureAwait(false); |
|
|
|
var supplierItem = await _supplierItemAppService |
|
|
|
.GetBySupplierCodeAndItemCodeAsync(purchaseOrder.SupplierCode, itemCode).ConfigureAwait(false); |
|
|
|
supplierItemDtos.Add(supplierItem); |
|
|
|
} |
|
|
|
|
|
|
@ -142,8 +150,8 @@ public class PurchaseOrderEventHandler |
|
|
|
|
|
|
|
//日期 //todo 这几个日期 有点问题
|
|
|
|
supplierAsnEditInput.ShipDate = purchaseOrder.OrderDate; |
|
|
|
supplierAsnEditInput.PlanArriveDate= purchaseOrder.Details.First().PlanArriveDate; |
|
|
|
supplierAsnEditInput.Ctype= purchaseOrder.Details.First().Ctype; |
|
|
|
supplierAsnEditInput.PlanArriveDate = purchaseOrder.Details.First().PlanArriveDate; |
|
|
|
supplierAsnEditInput.Ctype = purchaseOrder.Details.First().Ctype; |
|
|
|
supplierAsnEditInput.PlanUserCode = purchaseOrder.Details.First().PlanUserCode; |
|
|
|
|
|
|
|
//新到货
|
|
|
@ -156,21 +164,31 @@ public class PurchaseOrderEventHandler |
|
|
|
supplierAsnEditInput.CreateType = EnumSupplierAsnCreateType.Import; |
|
|
|
|
|
|
|
//供应商时间窗口
|
|
|
|
var dayOfWeek = new List<string>() { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; |
|
|
|
var chineseWeek= dayOfWeek[Clock.Now.DayOfWeek.GetHashCode()]; //中文星期
|
|
|
|
var dateTimeWindowDto=supplierTimeWindowDtos.FirstOrDefault(p => p.Week == chineseWeek); |
|
|
|
var dayOfWeek = new List<string> |
|
|
|
{ |
|
|
|
"星期日", |
|
|
|
"星期一", |
|
|
|
"星期二", |
|
|
|
"星期三", |
|
|
|
"星期四", |
|
|
|
"星期五", |
|
|
|
"星期六" |
|
|
|
}; |
|
|
|
var chineseWeek = dayOfWeek[Clock.Now.DayOfWeek.GetHashCode()]; //中文星期
|
|
|
|
var dateTimeWindowDto = supplierTimeWindowDtos.FirstOrDefault(p => p.Week == chineseWeek); |
|
|
|
if (dateTimeWindowDto == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"供应商时间窗口当前时间【{chineseWeek}】不存在"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
supplierAsnEditInput.TimeWindow = dateTimeWindowDto.TimeSlot; |
|
|
|
|
|
|
|
//生效日期
|
|
|
|
supplierAsnEditInput.ActiveDate = Clock.Now; |
|
|
|
|
|
|
|
//发货单号
|
|
|
|
supplierAsnEditInput.Number = await _supplierAsnAppService.GenerateSupplierAsnNumberAsync(supplierAsnEditInput.ActiveDate).ConfigureAwait(false); |
|
|
|
supplierAsnEditInput.Number = await _supplierAsnAppService |
|
|
|
.GenerateSupplierAsnNumberAsync(supplierAsnEditInput.ActiveDate).ConfigureAwait(false); |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
@ -182,7 +200,7 @@ public class PurchaseOrderEventHandler |
|
|
|
|
|
|
|
//todo 一个物品多个包装?怎么取值
|
|
|
|
//标包数
|
|
|
|
var itemPackDto = itemBasicDtos.First(p=>p.Code== purchaseOrderDetaildetail.ItemCode).StdPackQty; |
|
|
|
var itemPackDto = itemBasicDtos.First(p => p.Code == purchaseOrderDetaildetail.ItemCode).StdPackQty; |
|
|
|
|
|
|
|
//总箱数
|
|
|
|
var itemPackingCount = (int)(itemQty / itemPackDto); |
|
|
@ -200,7 +218,7 @@ public class PurchaseOrderEventHandler |
|
|
|
|
|
|
|
//添加物品信息
|
|
|
|
var itemBasicDto = itemBasicDtos.First(p => p.Code == purchaseOrderDetaildetail.ItemCode); |
|
|
|
|
|
|
|
|
|
|
|
//供应商物品
|
|
|
|
var supplierItemDto = supplierItemDtos.First(p => |
|
|
|
p.ItemCode == purchaseOrderDetaildetail.ItemCode && p.SupplierCode == purchaseOrder.SupplierCode); |
|
|
@ -212,7 +230,8 @@ public class PurchaseOrderEventHandler |
|
|
|
|
|
|
|
for (var i = 0; i < itemPackingCount; i++) |
|
|
|
{ |
|
|
|
var supplierAsnDetailInput = ObjectMapper.Map<PurchaseOrderDetail, SupplierAsnDetailInput>(purchaseOrderDetaildetail); |
|
|
|
var supplierAsnDetailInput = |
|
|
|
ObjectMapper.Map<PurchaseOrderDetail, SupplierAsnDetailInput>(purchaseOrderDetaildetail); |
|
|
|
//添加箱码
|
|
|
|
var pakcingCode = generateManyAsync.First(); |
|
|
|
supplierAsnDetailInput.PackingCode = pakcingCode; |
|
|
@ -237,11 +256,12 @@ public class PurchaseOrderEventHandler |
|
|
|
supplierAsnDetailInput.RecommendErpCode = purchaseOrderDetaildetail.LocationErpCode; |
|
|
|
|
|
|
|
supplierAsnDetailInput.PoNumber = purchaseOrder.Number; |
|
|
|
supplierAsnDetailInput.Qty = itemQty>itemPackDto ? itemPackDto : itemQty; |
|
|
|
supplierAsnDetailInput.Qty = itemQty > itemPackDto ? itemPackDto : itemQty; |
|
|
|
|
|
|
|
itemQty-=itemPackDto; |
|
|
|
itemQty -= itemPackDto; |
|
|
|
|
|
|
|
var InventoryLabelEditInput = await BuildInventoryLabelEditInputAsync(supplierAsnEditInput, supplierAsnDetailInput, supplierDto, itemBasicDto, supplierItemDto).ConfigureAwait(false); |
|
|
|
var InventoryLabelEditInput = await BuildInventoryLabelEditInputAsync(supplierAsnEditInput, |
|
|
|
supplierAsnDetailInput, supplierDto, itemBasicDto, supplierItemDto).ConfigureAwait(false); |
|
|
|
inventoryLabelEditInputs.Add(InventoryLabelEditInput); |
|
|
|
|
|
|
|
supplierAsnEditInput.Details.Add(supplierAsnDetailInput); |
|
|
@ -256,7 +276,7 @@ public class PurchaseOrderEventHandler |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建 构造标签
|
|
|
|
/// 创建 构造标签
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="supplierAsn"></param>
|
|
|
|
/// <param name="supplierAsnDetail"></param>
|
|
|
@ -303,7 +323,7 @@ public class PurchaseOrderEventHandler |
|
|
|
inputLabel.RecommendLocationCode = supplierAsnDetail.RecommendErpCode; |
|
|
|
inputLabel.Remark = supplierAsnDetail.Remark; |
|
|
|
inputLabel.Code = supplierAsnDetail.PackingCode; |
|
|
|
inputLabel.PlanArriveDate=supplierAsn.PlanArriveDate; |
|
|
|
inputLabel.PlanArriveDate = supplierAsn.PlanArriveDate; |
|
|
|
|
|
|
|
inputLabel.Qty = supplierAsnDetail.Qty; |
|
|
|
inputLabel.Uom = supplierAsnDetail.Uom; |
|
|
@ -314,13 +334,13 @@ public class PurchaseOrderEventHandler |
|
|
|
inputLabel.ItemDesc2 = itemBasicDto.Desc2; |
|
|
|
|
|
|
|
inputLabel.ExpireDate = DateTime.Now.AddDays(itemBasicDto.GetValidateDays()); |
|
|
|
|
|
|
|
|
|
|
|
inputLabel.ExtraProperties = new ExtraPropertyDictionary(); |
|
|
|
inputLabel.LabelStatus = LabelStatus.Enable; |
|
|
|
|
|
|
|
|
|
|
|
inputLabel.Specifications = itemBasicDto.Color; |
|
|
|
inputLabel.StdPackQty = itemBasicDto.StdPackQty; |
|
|
|
|
|
|
|
|
|
|
|
inputLabel.SupplierItemCode = supplierItemDto.SupplierItemCode; |
|
|
|
inputLabel.SupplierItemName = supplierItemDto.ItemName; |
|
|
|
inputLabel.SupplierName = supplierDto.Name; |
|
|
@ -329,7 +349,7 @@ public class PurchaseOrderEventHandler |
|
|
|
inputLabel.ProdLine = string.Empty; |
|
|
|
inputLabel.QLevel = string.Empty; |
|
|
|
inputLabel.QualityFile = string.Empty; |
|
|
|
|
|
|
|
|
|
|
|
inputLabel.Shift = string.Empty; |
|
|
|
inputLabel.ContainerCode = string.Empty; |
|
|
|
|
|
|
|