From eb46dc0e3c6ccb3456612b9c1a547cab15322862 Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Mon, 6 May 2024 11:51:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B3=A8=E5=A1=91=E5=8F=91?= =?UTF-8?q?=E6=96=99=E8=AE=B0=E5=BD=95TYRP=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExchangeDatas/EnumExchangeDataType.cs | 7 +- .../InjectionIssueNoteEventHandler.cs | 106 ++++++++++++++++++ 2 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/InjectionIssueNoteEventHandler.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 b22c253d6..d8caaf8c1 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 @@ -32,5 +32,10 @@ public enum EnumExchangeDataType //回收料调整 Item_Transform = 28, //半成品上架 - SemiPutaway = 29 + SemiPutaway = 29, + /// + /// 注塑发料 + /// + InjectionIssue=30, + } 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 new file mode 100644 index 000000000..ec0b619ef --- /dev/null +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/InjectionIssueNoteEventHandler.cs @@ -0,0 +1,106 @@ +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; + +namespace Win_in.Sfs.Wms.Store.Event.DataExchanges; + +/// +/// 注塑发料记录传给TYRP +/// +public class InjectionIssueNoteEventHandler + : StoreDataExchangeEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> +{ + + private const EnumExchangeDataType ExchangeDataType = EnumExchangeDataType.InjectionIssue; + + [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); + } + } + +}