Browse Source

提交版本

dev_DY_CC
赵新宇 5 months ago
parent
commit
7bc9ab4f26
  1. 28
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/UnplannedReceiptNoteEventHandler.cs

28
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/DataExchanges/UnplannedReceiptNoteEventHandler.cs

@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Drawing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.EventBus;
using Volo.Abp.Uow;
using Win_in.Sfs.Shared.Event;
@ -20,12 +23,12 @@ public class UnplannedReceiptNoteEventHandler
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<UnplannedReceiptNote> eventData)
{
var entity = eventData.Entity;
var copy= CopyEntity(entity);
if(entity.Details!=null && entity.Details.Count>0)
{
await AddExchangeDataAsync(entity).ConfigureAwait(false);
await AddExchangeDataAsync(copy).ConfigureAwait(false);
}
}
[UnitOfWork]
@ -38,16 +41,17 @@ public class UnplannedReceiptNoteEventHandler
{
if (entity.Details != null && entity.Details.Count > 0)
{
notelist.Add(entity);
var copy=CopyEntity(entity);
notelist.Add(copy);
}
}
await AddExchangeDataAsync(notelist).ConfigureAwait(false);
}
protected override async Task AddExchangeDataAsync(List<UnplannedReceiptNote> entities)
{
var dtos = ObjectMapper.Map<List<UnplannedReceiptNote>, List<UnplannedReceiptNoteDTO>>(entities);
foreach (var detail in dtos.SelectMany(dto => dto.Details))
{
@ -56,5 +60,21 @@ public class UnplannedReceiptNoteEventHandler
var exchangeData = await BuildExchangeDataAsync(StoreEventConsts.WMS, StoreEventConsts.ERP, ExchangeDataType, dtos).ConfigureAwait(false);
await AddManyAsync(exchangeData).ConfigureAwait(false);
}
private UnplannedReceiptNote CopyEntity(UnplannedReceiptNote p_note)
{
var json = System.Text.Json.JsonSerializer.Serialize(p_note);
var copy = System.Text.Json.JsonSerializer.Deserialize<UnplannedReceiptNote>(json);
copy.Qty =-Math.Abs(p_note.Qty);
foreach (var detail in copy.Details)
{
detail.Qty = detail.Qty != 0 ? -Math.Abs(detail.Qty) : 0;
detail.HandledQty = detail.HandledQty != 0 ? -Math.Abs(detail.HandledQty) : 0;
detail.RecommendQty= detail.RecommendQty != 0 ? -Math.Abs(detail.RecommendQty) : 0;
}
return copy;
}
}

Loading…
Cancel
Save