You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.7 KiB
46 lines
1.7 KiB
using System.Collections.Generic;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using Win_in.Sfs.Wms.DataExchange.Domain;
|
|
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp;
|
|
|
|
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Outgoing;
|
|
|
|
public class ProductReceiptNoteWriter : IWriter
|
|
{
|
|
private readonly IProductReceiptNoteManager _productReceiptNoteManager;
|
|
private readonly IOutgoingToExternalManager _outgoingToExternalManager;
|
|
|
|
public ProductReceiptNoteWriter(
|
|
IProductReceiptNoteManager productReceiptNoteManager
|
|
, IOutgoingToExternalManager outgoingToExternalManager)
|
|
{
|
|
_productReceiptNoteManager = productReceiptNoteManager;
|
|
_outgoingToExternalManager = outgoingToExternalManager;
|
|
}
|
|
|
|
public virtual async Task WriteAsync(List<OutgoingToExternal> outgoingDataList)
|
|
{
|
|
var returnNotes = await BuildProductReceiptNoteAsync(outgoingDataList).ConfigureAwait(false);
|
|
//写ProductReceiptNote数据到EOS
|
|
await _productReceiptNoteManager.PostListAsync(returnNotes).ConfigureAwait(false);
|
|
|
|
await _outgoingToExternalManager.ArchiveManyAsync(outgoingDataList).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
private static async Task<List<ProductReceiptNote>> BuildProductReceiptNoteAsync(List<OutgoingToExternal> outgoingData)
|
|
{
|
|
await Task.CompletedTask.ConfigureAwait(false);
|
|
var returnNoteList = new List<ProductReceiptNote>();
|
|
foreach (var outgoingToExternal in outgoingData)
|
|
{
|
|
var receipt =
|
|
JsonSerializer.Deserialize<ProductReceiptNote>(outgoingToExternal.DestinationDataContent);
|
|
|
|
returnNoteList.Add(receipt);
|
|
}
|
|
return returnNoteList;
|
|
}
|
|
|
|
}
|
|
|