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 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> BuildProductReceiptNoteAsync(List outgoingData) { await Task.CompletedTask.ConfigureAwait(false); var returnNoteList = new List(); foreach (var outgoingToExternal in outgoingData) { var receipt = JsonSerializer.Deserialize(outgoingToExternal.DestinationDataContent); returnNoteList.Add(receipt); } return returnNoteList; } }