From 405427b6f430f58f84ebc6bd4f9c35ae85031620 Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Tue, 2 Apr 2024 11:06:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BA=93=E5=AD=98=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Enums/Inventory/EnumTransSubType.cs | 9 + .../Enums/Store/Types/EnumMesType.cs | 13 ++ .../Notes/MesNotes/DTOs/MesNoteDTO.cs | 8 +- .../Notes/MesNotes/Inputs/MesNoteEditInput.cs | 11 +- .../MesNotes/Inputs/MesNoteImportInput.cs | 4 +- .../Notes/MesNotes/MesNote.cs | 3 +- ...MesNoteDbContextModelCreatingExtensions.cs | 2 +- .../CoatingIssueNoteEventHandler.cs | 159 ++++++++++++++++++ 8 files changed, 196 insertions(+), 13 deletions(-) create mode 100644 be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumMesType.cs create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CoatingIssueNoteEventHandler.cs diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs index 57d1e43cd..2ca7b36ab 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs @@ -198,4 +198,13 @@ public enum EnumTransSubType /// [Display(Name = "导入盘点计划")] ExcelInCountPlan = 6002, + [Display(Name = "MES冻结")] + MesFreeze = 10001, + [Display(Name = "MES解冻")] + MesUnFreeze = 10002, + [Display(Name = "MES不合格")] + MesUnQualified = 10003 + + + } diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumMesType.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumMesType.cs new file mode 100644 index 000000000..da72d0acb --- /dev/null +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/Types/EnumMesType.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Types; +public enum EnumMesType +{ + MesFreeze=10001, + MesUnFreeze=10002, + MesUnQualified=10003 +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs index 06a7a4a5e..24ca29a90 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/DTOs/MesNoteDTO.cs @@ -12,15 +12,15 @@ public class MesNoteDTO : SfsStoreDTOBase, IHasNumber public string JobNumber { get; set; } /// - /// 报废类型 + /// 类型 /// - [Display(Name = "报废类型")] + [Display(Name = "类型")] public string Type { get; set; } /// - /// 报废请求单号 + /// 请求单号 /// - [Display(Name = "报废请求单号")] + [Display(Name = "请求单号")] public string ScrapRequestNumber { get; set; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs index 8f36d14c6..ee271489d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteEditInput.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Types; namespace Win_in.Sfs.Wms.Store.Application.Contracts; @@ -16,20 +17,20 @@ public class MesNoteEditInput : SfsStoreCreateOrUpdateInputBase /// /// 报废记录号 /// - [Display(Name = "报废记录号")] + [Display(Name = "记录号")] [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] public string Number { get; set; } /// - /// 报废请求单号 + /// 请求单号 /// - [Display(Name = "报废请求单号")] - public string ScrapRequestNumber { get; set; } + [Display(Name = "请求单号")] + public string MesRequestNumber { get; set; } /// /// 报废类型 /// - [Display(Name = "报废类型")] + [Display(Name = "类型")] public string Type { get; set; } /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteImportInput.cs index 138e02958..5a56ab8c6 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteImportInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/MesNotes/Inputs/MesNoteImportInput.cs @@ -14,7 +14,7 @@ public class MesNoteImportInput : SfsStoreImportInputBase /// /// 报废请求单号 /// - [Display(Name = "报废请求单号")] - public string ScrapRequestNumber { get; set; } + [Display(Name = "请求单号")] + public string MesRequestNumber { get; set; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs index 22b6cae8b..8f08e2041 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/MesNotes/MesNote.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Win_in.Sfs.Shared.Domain.Entities; +using Win_in.Sfs.Shared.Domain.Shared.Enums.Store.Types; namespace Win_in.Sfs.Wms.Store.Domain; @@ -18,7 +19,7 @@ public class MesNote : SfsStoreAggregateRootBase, IHasJobNumber /// 报废请求单号 /// [IgnoreUpdate] - public string ScrapRequestNumber { get; set; } + public string MesRequestNumber { get; set; } /// /// Mes类型 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/MesNotes/MesNoteDbContextModelCreatingExtensions.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/MesNotes/MesNoteDbContextModelCreatingExtensions.cs index 27a3b4842..38d31326e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/MesNotes/MesNoteDbContextModelCreatingExtensions.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Notes/MesNotes/MesNoteDbContextModelCreatingExtensions.cs @@ -20,7 +20,7 @@ public static class MesNoteDbContextModelCreatingExtensions //Properties b.Property(q => q.Type).HasMaxLength(SfsPropertyConst.CodeLength); - b.Property(q => q.ScrapRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength); + b.Property(q => q.MesRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength); //Relations b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CoatingIssueNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CoatingIssueNoteEventHandler.cs new file mode 100644 index 000000000..e6c6f076d --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CoatingIssueNoteEventHandler.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.EventBus; +using Volo.Abp.Uow; +using Win_in.Sfs.Basedata.Application.Contracts; +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; +using Win_in.Sfs.Wms.Store.Notes.IssueNotes; + +namespace Win_in.Sfs.Wms.Store.Event.Transactions; + +public class CoatingIssueNoteEventHandler + : StoreInventoryEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> + , ILocalEventHandler> +{ + private const EnumTransType TransType = EnumTransType.Issue; + + private readonly ILocationAppService _locationAppService; + + public CoatingIssueNoteEventHandler(ILocationAppService locationAppService) + { + _locationAppService = locationAppService; + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + var transferLogs = new List(); + var route = entity.UseOnTheWayLocation + ? EnumTransferRoute.SourceToOnTheWay + : EnumTransferRoute.SourceToDestination; + transferLogs.AddRange(await BuildTransferLogsAsync(entity, route).ConfigureAwait(false)); + + //如果是mes拉动 先发到在途 + if (entity.RequestType == EnumMaterialRequestType.Issue_WIP.ToString()) + { + route = EnumTransferRoute.SourceToOnTheWay; + } + + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entities = eventData.Entity; + var transferLogs = new List(); + //如果要做库存事务汇总,可以修改此处 + foreach (var CoatingIssueNote in entities) + { + var route = CoatingIssueNote.UseOnTheWayLocation + ? EnumTransferRoute.SourceToOnTheWay + : EnumTransferRoute.SourceToDestination; + transferLogs.AddRange(await BuildTransferLogsAsync(CoatingIssueNote, route).ConfigureAwait(false)); + } + + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + } + + [UnitOfWork] + + public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData eventData) + { + var entity = eventData.Entity; + + var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination).ConfigureAwait(false); + await AddTransferLogsAsync(inputList).ConfigureAwait(false); + } + + private async Task AddTransferLogsAsync(List inputList) + { + var transferLogs = new List(); + + transferLogs.AddRange(inputList); + + await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + + } + + private async Task> BuildTransferLogsAsync(CoatingIssueNote CoatingIssueNote, EnumTransferRoute route) + { + var transferLogs = new List(); + foreach (var detail in CoatingIssueNote.Details.Where(detail => detail.Qty != 0)) + { + var transferLog = ObjectMapper.Map(detail); + + LocationDTO fromLocationDTO = null; + LocationDTO toLocationDTO = null; + + if (CoatingIssueNote.UseOnTheWayLocation) + { + var location = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + switch (route) + { + case EnumTransferRoute.SourceToOnTheWay: + fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); + + toLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + break; + case EnumTransferRoute.OnTheWayToDestination: + fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + + toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); + + await RemovePackingCodeAndContainerCodeAndLotAsync(transferLog).ConfigureAwait(false); + break; + case EnumTransferRoute.SourceToDestination: + default: + throw new ArgumentOutOfRangeException(nameof(route), route, null); + } + } + else + { + fromLocationDTO = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); + toLocationDTO = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); + } + + transferLog.FromLocationCode = fromLocationDTO.Code; + transferLog.FromLocationArea = fromLocationDTO.AreaCode; + transferLog.FromLocationErpCode = fromLocationDTO.ErpLocationCode; + transferLog.FromLocationGroup = fromLocationDTO.LocationGroupCode; + + transferLog.ToLocationCode = toLocationDTO.Code; + transferLog.ToLocationArea = toLocationDTO.AreaCode; + transferLog.ToLocationErpCode = toLocationDTO.ErpLocationCode; + transferLog.ToLocationGroup = toLocationDTO.LocationGroupCode; + transferLog.TransSubType = Enum.Parse(CoatingIssueNote.RequestType); + transferLog.TransType = TransType; + transferLog.DocNumber = CoatingIssueNote.Number; + transferLog.JobNumber = CoatingIssueNote.JobNumber; + + transferLogs.Add(transferLog); + } + + return transferLogs; + } + + private async Task RemovePackingCodeAndContainerCodeAndLotAsync(TransferLogEditInput transferLogCreateInput) + { + transferLogCreateInput.ToPackingCode = ""; + transferLogCreateInput.ToLot = ""; + transferLogCreateInput.ToContainerCode = ""; + + transferLogCreateInput.FromPackingCode = ""; + transferLogCreateInput.FromLot = ""; + transferLogCreateInput.FromContainerCode = ""; + + + } + +}