24 changed files with 32557 additions and 39 deletions
@ -1,16 +0,0 @@ |
|||||
using System.ComponentModel.DataAnnotations; |
|
||||
|
|
||||
namespace Win_in.Sfs.Basedata.Domain.Shared; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// 生产线类型
|
|
||||
/// </summary>
|
|
||||
public enum EnumProductionLineType |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// 空枚举
|
|
||||
/// </summary>
|
|
||||
[Display(Name = "空")] |
|
||||
None = 0, |
|
||||
|
|
||||
} |
|
@ -0,0 +1,23 @@ |
|||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
|
||||
|
namespace Win_in.Sfs.Shared.Domain.Shared; |
||||
|
|
||||
|
public enum EnumProductionLineType |
||||
|
{ |
||||
|
None = 0, |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 注塑
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "注塑")] Injection = 1, |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 喷涂
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "喷涂")] Coating = 2, |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 装配
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "装配")] Assemble = 3 |
||||
|
} |
File diff suppressed because it is too large
@ -0,0 +1,91 @@ |
|||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Migrations |
||||
|
{ |
||||
|
public partial class Update_KittingPackagingNoteV3 : Migration |
||||
|
{ |
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "KittingNumber", |
||||
|
table: "Store_ChassisOperationSequence"); |
||||
|
|
||||
|
migrationBuilder.RenameColumn( |
||||
|
name: "ChassisSortNumber", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail", |
||||
|
newName: "ChassisNumber"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "ItemCode", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail", |
||||
|
type: "nvarchar(64)", |
||||
|
maxLength: 64, |
||||
|
nullable: false, |
||||
|
defaultValue: ""); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "ItemDesc1", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail", |
||||
|
type: "nvarchar(64)", |
||||
|
maxLength: 64, |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "ItemDesc2", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail", |
||||
|
type: "nvarchar(64)", |
||||
|
maxLength: 64, |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "ItemName", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail", |
||||
|
type: "nvarchar(64)", |
||||
|
maxLength: 64, |
||||
|
nullable: true); |
||||
|
|
||||
|
migrationBuilder.AddColumn<long>( |
||||
|
name: "ChassisSortNumber", |
||||
|
table: "Store_ChassisOperationSequence", |
||||
|
type: "bigint", |
||||
|
nullable: false, |
||||
|
defaultValue: 0L); |
||||
|
} |
||||
|
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "ItemCode", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "ItemDesc1", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "ItemDesc2", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "ItemName", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail"); |
||||
|
|
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "ChassisSortNumber", |
||||
|
table: "Store_ChassisOperationSequence"); |
||||
|
|
||||
|
migrationBuilder.RenameColumn( |
||||
|
name: "ChassisNumber", |
||||
|
table: "Store_KittingPackagingNoteChassisDetail", |
||||
|
newName: "ChassisSortNumber"); |
||||
|
|
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "KittingNumber", |
||||
|
table: "Store_ChassisOperationSequence", |
||||
|
type: "nvarchar(max)", |
||||
|
nullable: true); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,149 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text.Json; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.EventBus; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Win_in.Sfs.Basedata.Application.Contracts; |
||||
|
using Win_in.Sfs.Basedata.Domain; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
using Win_in.Sfs.Shared.Event; |
||||
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
using Win_in.Sfs.Wms.Store.Event.Transaction; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Event.Transactions; |
||||
|
|
||||
|
public class KittingPackagingNoteEventHandler |
||||
|
: StoreInventoryEventHandlerBase |
||||
|
, ILocalEventHandler<SfsCreatedEntityEventData<KittingPackagingNote>> |
||||
|
, ILocalEventHandler<SfsCreatedEntityEventData<List<KittingPackagingNote>>> |
||||
|
{ |
||||
|
private readonly IProductionLineAppService _productionLineAppService; |
||||
|
private readonly IProductionLineItemAppService _productionLineItemAppService; |
||||
|
private readonly ILocationAppService _locationAppService; |
||||
|
|
||||
|
public KittingPackagingNoteEventHandler( |
||||
|
IProductionLineAppService productionLineAppService, ILocationAppService locationAppService, IProductionLineItemAppService productionLineItemAppService) |
||||
|
{ |
||||
|
_productionLineAppService = productionLineAppService; |
||||
|
_locationAppService = locationAppService; |
||||
|
_productionLineItemAppService = productionLineItemAppService; |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<KittingPackagingNote> eventData) |
||||
|
{ |
||||
|
var entity = eventData.Entity; |
||||
|
var transferLogEditInputs = await BuildTransferLogsAsync(entity).ConfigureAwait(false); |
||||
|
await TransferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<KittingPackagingNote>> eventData) |
||||
|
{ |
||||
|
var entities = eventData.Entity; |
||||
|
var transferLogCreateInputs = new List<TransferLogEditInput>(); |
||||
|
foreach (var entitie in entities) |
||||
|
{ |
||||
|
transferLogCreateInputs.AddRange(await BuildTransferLogsAsync(entitie).ConfigureAwait(false)); |
||||
|
} |
||||
|
|
||||
|
await TransferLogAppService.AddManyAsync(transferLogCreateInputs).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 构造库移DTO
|
||||
|
/// </summary>
|
||||
|
/// <param name="kittingPackagingNote"></param>
|
||||
|
/// <returns></returns>
|
||||
|
private async Task<List<TransferLogEditInput>> BuildTransferLogsAsync(KittingPackagingNote kittingPackagingNote) |
||||
|
{ |
||||
|
var transferLogCreateInputs = new List<TransferLogEditInput>(); |
||||
|
//获取生产线和 生产线零件关系 用来下面找装配的线边做查询
|
||||
|
var productionLineList = await _productionLineAppService.GetByLocationCodeAsync(EnumProductionLineType.Assemble) |
||||
|
.ConfigureAwait(false); |
||||
|
var productionItemList = new List<ProductionLineItemDTO>(); |
||||
|
foreach (var productionLineDto in productionLineList) |
||||
|
{ |
||||
|
productionItemList.AddRange(await _productionLineItemAppService.GetByProductLineCodeAsync(productionLineDto.Code).ConfigureAwait(false)); |
||||
|
} |
||||
|
|
||||
|
//Kitting线边库位
|
||||
|
var kittingLocation = |
||||
|
await LocationAclService.GetFirstByTypeAsync(EnumLocationType.KittingWip).ConfigureAwait(false); |
||||
|
|
||||
|
foreach (var detail in kittingPackagingNote.Details.Where(detail => detail.Qty != 0)) |
||||
|
{ |
||||
|
var productionLineItemDtos= productionItemList.FirstOrDefault(p => p.ItemCode == detail.ItemCode); |
||||
|
if (productionLineItemDtos == null) |
||||
|
{ |
||||
|
var strProductionLine = string.Empty; |
||||
|
productionLineList.ForEach(dto => strProductionLine += " " + dto.Code); |
||||
|
throw new UserFriendlyException($"没有在 生产线代码列表中找到【{strProductionLine}】物料代码【{detail.ItemCode}】的配置"); |
||||
|
} |
||||
|
|
||||
|
var list = JsonSerializer.Deserialize<List<string>>(productionLineItemDtos.WipLocationCodeListJson); |
||||
|
if (list == null || list.Count < 1) |
||||
|
{ |
||||
|
throw new UserFriendlyException($"没有在 生产线代码【{productionLineItemDtos.ProdLineCode}】物料代码【{detail.ItemCode}】中配置线边库位"); |
||||
|
} |
||||
|
|
||||
|
var assembleFirstLocationCode = list.First(); |
||||
|
var assembleLocation = |
||||
|
await _locationAppService.GetByCodeAsync(assembleFirstLocationCode).ConfigureAwait(false); |
||||
|
|
||||
|
var transferLogEditInput = transferLogCreateInputs.FirstOrDefault(p => p.ItemCode == detail.ItemCode); |
||||
|
if (transferLogEditInput != null) |
||||
|
{ |
||||
|
transferLogEditInput.Qty += detail.Qty; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
var transferLog = new TransferLogEditInput(); |
||||
|
transferLog.TransType = EnumTransType.Transfer; |
||||
|
var itemBasicDto = await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
||||
|
|
||||
|
transferLog.ItemCode = detail.ItemCode; |
||||
|
transferLog.ItemDesc1 = detail.ItemDesc1; |
||||
|
transferLog.ItemDesc2 = detail.ItemDesc2; |
||||
|
transferLog.ItemName = detail.ItemName; |
||||
|
transferLog.Qty = detail.Qty; |
||||
|
transferLog.ArriveDate = DateTime.Now; |
||||
|
transferLog.ExpireDate = DateTime.Now; |
||||
|
transferLog.ProduceDate = DateTime.Now; |
||||
|
transferLog.StdPackQty = itemBasicDto.StdPackQty; |
||||
|
transferLog.Uom = itemBasicDto.BasicUom; |
||||
|
|
||||
|
transferLog.ToLocationCode = assembleLocation.Code; |
||||
|
transferLog.ToWarehouseCode = assembleLocation.WarehouseCode; |
||||
|
transferLog.ToLocationErpCode = assembleLocation.ErpLocationCode; |
||||
|
transferLog.ToLocationArea = assembleLocation.AreaCode; |
||||
|
transferLog.ToLocationGroup = assembleLocation.LocationGroupCode; |
||||
|
transferLog.ToContainerCode = string.Empty; |
||||
|
transferLog.ToPackingCode = string.Empty; |
||||
|
transferLog.ToLot = string.Empty; |
||||
|
transferLog.ToStatus = EnumInventoryStatus.OK; |
||||
|
|
||||
|
transferLog.FromLocationCode = kittingLocation.Code; |
||||
|
transferLog.FromWarehouseCode = kittingLocation.WarehouseCode; |
||||
|
transferLog.FromLocationErpCode = kittingLocation.ErpLocationCode; |
||||
|
transferLog.FromLocationArea = kittingLocation.AreaCode; |
||||
|
transferLog.FromLocationGroup = kittingLocation.LocationGroupCode; |
||||
|
transferLog.FromContainerCode = string.Empty; |
||||
|
transferLog.FromPackingCode = string.Empty; |
||||
|
transferLog.FromLot = string.Empty; |
||||
|
transferLog.FromStatus = EnumInventoryStatus.OK; |
||||
|
|
||||
|
transferLog.Worker = kittingPackagingNote.Worker; |
||||
|
transferLog.DocNumber = kittingPackagingNote.Number; |
||||
|
|
||||
|
transferLogCreateInputs.Add(transferLog); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return transferLogCreateInputs; |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue