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.
58 lines
2.3 KiB
58 lines
2.3 KiB
2 years ago
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text.Json;
|
||
|
using System.Threading.Tasks;
|
||
|
using Win_in.Sfs.Wms.DataExchange.Domain;
|
||
|
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp;
|
||
|
using Win_in.Sfs.Wms.DataExchange.Domain.Shared;
|
||
|
|
||
|
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent;
|
||
|
|
||
|
public class PurchaseOrderWriter : IWriter
|
||
|
{
|
||
|
private readonly IScontrolManager _dataInterfaceManager;
|
||
|
private readonly IOutgoingToExternalManager _outgoingToExternalManager;
|
||
|
|
||
|
public PurchaseOrderWriter(
|
||
|
IScontrolManager dataInterfaceManager
|
||
|
, IOutgoingToExternalManager outgoingToExternalManager)
|
||
|
{
|
||
|
_dataInterfaceManager = dataInterfaceManager;
|
||
|
_outgoingToExternalManager = outgoingToExternalManager;
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 写入数据
|
||
|
/// </summary>
|
||
|
/// <param name="outgoingDataList"></param>
|
||
|
/// <returns></returns>
|
||
|
public virtual async Task WriteAsync(List<OutgoingToExternal> outgoingDataList)
|
||
|
{
|
||
|
var dataInterfaceList = new List<Scontrol>();
|
||
|
var dataInterfaceDetailList = new List<Scmsend>();
|
||
|
var groups = outgoingDataList.GroupBy(r => r.SourceDataGroupCode);
|
||
|
foreach (var group in groups)
|
||
|
{
|
||
|
var entitys = group.ToList();
|
||
|
|
||
|
foreach (var entity in entitys)
|
||
|
{
|
||
|
if (entity.TableType == EnumExchangeTableType.MainTable) //主表(MainTable)
|
||
|
{
|
||
|
var receipt = JsonSerializer.Deserialize<Scontrol>(entity.DestinationDataContent);
|
||
|
dataInterfaceList.Add(receipt);
|
||
|
}
|
||
|
else if (entity.TableType == EnumExchangeTableType.DetailTable) // 子表(DetailTable)
|
||
|
{
|
||
|
var receiptDetail = JsonSerializer.Deserialize<Scmsend>(entity.DestinationDataContent);
|
||
|
dataInterfaceDetailList.Add(receiptDetail);
|
||
|
}
|
||
|
}
|
||
|
//dataInterface分主子表分别写入ERP
|
||
|
await _dataInterfaceManager.PostListAsync(dataInterfaceList, dataInterfaceDetailList).ConfigureAwait(false);
|
||
|
}
|
||
|
//将数据归档
|
||
|
await _outgoingToExternalManager.ArchiveManyAsync(outgoingDataList).ConfigureAwait(false);
|
||
|
}
|
||
|
|
||
|
}
|