From 854bc18d442630c541ddd80016c82dcb9bfe90f1 Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Mon, 6 May 2024 13:44:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B6=82=E8=A3=85=E5=8F=91?= =?UTF-8?q?=E6=96=99TYRP=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExchangeDatas/EnumExchangeDataType.cs | 4 + .../CoatingIssueNoteEventHandler.cs | 107 ++++++++++++++++++ .../InjectionIssueNoteEventHandler.cs | 2 +- .../ThirdLocationNoteEventHandler.cs | 3 +- 4 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/CoatingIssueNoteEventHandler.cs diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/ExchangeDatas/EnumExchangeDataType.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/ExchangeDatas/EnumExchangeDataType.cs index d8caaf8c1..e1aee60b2 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/ExchangeDatas/EnumExchangeDataType.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/ExchangeDatas/EnumExchangeDataType.cs @@ -37,5 +37,9 @@ public enum EnumExchangeDataType /// 注塑发料 /// InjectionIssue=30, + /// + /// 涂装发料 + /// + CoatingIssue=31, } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/CoatingIssueNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/CoatingIssueNoteEventHandler.cs new file mode 100644 index 000000000..de0a95320 --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/CoatingIssueNoteEventHandler.cs @@ -0,0 +1,107 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.EventBus; +using Volo.Abp.Uow; +using Win_in.Sfs.Shared.Domain; +using Win_in.Sfs.Shared.Event; +using Win_in.Sfs.Wms.Store.Application.Contracts; +using Win_in.Sfs.Wms.Store.Domain; +using Win_in.Sfs.Wms.Store.Notes.IssueNotes; + +namespace Win_in.Sfs.Wms.Store.Event.DataExchanges; + +/// +/// 涂装发料记录传给TYRP(线边领料单) +/// +public class CoatingIssueNoteEventHandler + : StoreDataExchangeEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> +{ + + private const EnumExchangeDataType ExchangeDataType = EnumExchangeDataType.CoatingIssue; + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + await AddExchangeDataAsync(entity).ConfigureAwait(false); + } + + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entities = eventData.Entity; + await AddExchangeDataAsync(entities).ConfigureAwait(false); + } + + protected override async Task AddExchangeDataAsync(List entities) + { + var dtos = ObjectMapper.Map, List>(entities); + foreach (var detail in dtos.SelectMany(dto => dto.Details)) + { + if (string.IsNullOrEmpty(detail.HandledFromLocationErpCode)) + { + var location = await LocationAclService.GetByCodeAsync(detail.HandledFromLocationCode).ConfigureAwait(false); + if (location != null) + { + detail.HandledFromLocationErpCode = location.ErpLocationCode; + detail.HandledFromLocationGroup = location.LocationGroupCode; + detail.HandledFromLocationArea = location.AreaCode; + + if (string.IsNullOrEmpty(detail.HandledFromWarehouseCode)) + { + detail.HandledFromWarehouseCode = location.WarehouseCode; + } + } + } + + if (string.IsNullOrEmpty(detail.HandledToLocationErpCode)) + { + var location = await LocationAclService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); + if (location != null) + { + detail.HandledToLocationErpCode = location.ErpLocationCode; + detail.HandledToLocationGroup = location.LocationGroupCode; + detail.HandledToLocationArea = location.AreaCode; + + if (string.IsNullOrEmpty(detail.HandledToWarehouseCode)) + { + detail.HandledToWarehouseCode = location.WarehouseCode; + } + } + } + + } + + var toErpDto = new List(); + foreach (var item in dtos) + { + if (item.Details != null && item.Details.Count != 0) + { + toErpDto.Add(item); + } + } + + //2023-12-6要求同储位不传入接口 按历史规则 + var result = new List(); + foreach (var injectionIssueNoteDto in toErpDto) + { + injectionIssueNoteDto.Details.RemoveAll(p => p.HandledFromLocationErpCode == p.HandledToLocationErpCode); + if (injectionIssueNoteDto.Details.Count > 0) + { + result.Add(injectionIssueNoteDto); + } + } + + if (result.Count > 0) + { + var exchangeDataerp = + await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, ExchangeDataType, result) + .ConfigureAwait(false); + await AddManyAsync(exchangeDataerp).ConfigureAwait(false); + } + } + +} diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/InjectionIssueNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/InjectionIssueNoteEventHandler.cs index ec0b619ef..f5e09482f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/InjectionIssueNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/InjectionIssueNoteEventHandler.cs @@ -11,7 +11,7 @@ using Win_in.Sfs.Wms.Store.Domain; namespace Win_in.Sfs.Wms.Store.Event.DataExchanges; /// -/// 注塑发料记录传给TYRP +/// 注塑发料记录传给TYRP(线边领料单) /// public class InjectionIssueNoteEventHandler : StoreDataExchangeEventHandlerBase diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/ThirdLocationNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/ThirdLocationNoteEventHandler.cs index abd58f12a..7adb5dde4 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/ThirdLocationNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/ThirdLocationNoteEventHandler.cs @@ -32,10 +32,9 @@ namespace Win_in.Sfs.Wms.Store.Event.DataExchanges await AddExchangeDataAsync(entity).ConfigureAwait(false); } - protected override async Task AddExchangeDataAsync(List entities) { - var dtos = ObjectMapper.Map, List>(entities); + var dtos = ObjectMapper.Map, List>(entities); var exchangeData = await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, EnumExchangeDataType.Transfer, dtos).ConfigureAwait(false); await AddManyAsync(exchangeData).ConfigureAwait(false);