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.
70 lines
2.8 KiB
70 lines
2.8 KiB
1 year ago
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text.Json;
|
||
|
using System.Threading.Tasks;
|
||
|
using Microsoft.Extensions.Logging;
|
||
|
using Volo.Abp.ObjectMapping;
|
||
|
using Win_in.Sfs.Basedata.Application.Contracts;
|
||
|
using Win_in.Sfs.Wms.DataExchange.Domain;
|
||
|
using Win_in.Sfs.Wms.DataExchange.WMS.ErpLocation;
|
||
|
|
||
|
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Incoming;
|
||
|
|
||
|
public class ErpLocationConverter : IIncomingConverter
|
||
|
{
|
||
|
private readonly IIncomingToWmsManager _incomingToWmsManager;
|
||
|
private readonly IObjectMapper _objectMapper;
|
||
|
private readonly ILogger<ErpLocationConverter> _logger;
|
||
|
private readonly IIncomingFromExternalManager _incomingFromExternalManager;
|
||
|
|
||
|
public ErpLocationConverter(
|
||
|
IIncomingToWmsManager incomingToWmsManager
|
||
|
, IObjectMapper objectMapper
|
||
|
, ILogger<ErpLocationConverter> logger,
|
||
|
IIncomingFromExternalManager incomingFromExternalManager)
|
||
|
{
|
||
|
_incomingToWmsManager = incomingToWmsManager;
|
||
|
_objectMapper = objectMapper;
|
||
|
_logger = logger;
|
||
|
_incomingFromExternalManager = incomingFromExternalManager;
|
||
|
}
|
||
|
|
||
|
public virtual async Task ConvertAsync(List<IncomingFromExternal> incomingFromExternalList)
|
||
|
{
|
||
|
if (!incomingFromExternalList.Any())
|
||
|
{
|
||
|
_logger.LogInformation("No ErpLocations");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
//按流水号创建单据
|
||
|
var erpLocationRequestList = await BuildIncomingToWmsOfErpLocationRequestAsync(incomingFromExternalList).ConfigureAwait(false);
|
||
|
await _incomingToWmsManager.CreateManyAsync(erpLocationRequestList).ConfigureAwait(false);
|
||
|
//归档
|
||
|
await _incomingFromExternalManager.ArchiveManyAsync(incomingFromExternalList).ConfigureAwait(false);
|
||
|
}
|
||
|
|
||
|
private async Task<List<IncomingToWms>> BuildIncomingToWmsOfErpLocationRequestAsync(List<IncomingFromExternal> incomingDataList)
|
||
|
{
|
||
|
await Task.CompletedTask.ConfigureAwait(false);
|
||
|
var incomingToWmsList = new List<IncomingToWms>();
|
||
|
foreach (var item in incomingDataList)
|
||
|
{
|
||
|
var incomingToWms = new IncomingToWms()
|
||
|
{
|
||
|
DataType = item.DataType,
|
||
|
DataAction = item.DataAction,
|
||
|
SourceSystem = item.SourceSystem,
|
||
|
DataIdentityCode = item.SourceDataGroupCode,
|
||
|
};
|
||
|
incomingToWms.SetEffectiveDate(item.EffectiveDate);
|
||
|
var exchangeErpLocationRequest = JsonSerializer.Deserialize<ErpLocationExchangeDto>(item.DestinationDataContent);
|
||
|
var wmsErpLocationRequest = _objectMapper.Map<ErpLocationExchangeDto, ErpLocationEditInput>(exchangeErpLocationRequest);
|
||
|
incomingToWms.DataContent = JsonSerializer.Serialize(wmsErpLocationRequest);
|
||
|
incomingToWmsList.Add(incomingToWms);
|
||
|
}
|
||
|
return incomingToWmsList;
|
||
|
}
|
||
|
|
||
|
}
|