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.
110 lines
4.6 KiB
110 lines
4.6 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.ObjectMapping;
|
|
using Win_in.Sfs.Wms.DataExchange.Domain;
|
|
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.EOS;
|
|
using Win_in.Sfs.Wms.DataExchange.Domain.Shared;
|
|
using Win_in.Sfs.Wms.DataExchange.WMS.PurchaseReceipt;
|
|
using Win_in.Sfs.Wms.DataExchange.WMS.PutawayNote;
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts;
|
|
|
|
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent;
|
|
|
|
public class ArriveConverter : IOutgoingConverter
|
|
{
|
|
private readonly IOutgoingFromWmsManager _outgoingFromWmsManager;
|
|
private readonly IOutgoingToExternalManager _outgoingToExternalManager;
|
|
private readonly ISupplierAsnAppService _supplierAsnAppService;
|
|
private readonly IObjectMapper _objectMapper;
|
|
|
|
|
|
public ArriveConverter(
|
|
IOutgoingFromWmsManager outgoingFromWmsManager
|
|
, IOutgoingToExternalManager outgoingToExternalManager
|
|
, ISupplierAsnAppService supplierAsnAppService
|
|
, IObjectMapper objectMapper
|
|
)
|
|
{
|
|
_outgoingFromWmsManager = outgoingFromWmsManager;
|
|
_outgoingToExternalManager = outgoingToExternalManager;
|
|
_supplierAsnAppService = supplierAsnAppService;
|
|
_objectMapper = objectMapper;
|
|
}
|
|
|
|
public virtual async Task<List<OutgoingToExternal>> ConvertAsync()
|
|
{
|
|
var outgoingToExternalList = new List<OutgoingToExternal>();
|
|
|
|
var outgoingFromWmsList = await _outgoingFromWmsManager.GetToBeProcessedListAsync(EnumOutgoingDataType.Putaway, EnumSystemType.EOS).ConfigureAwait(false);
|
|
|
|
foreach (var outgoingFromWms in outgoingFromWmsList)
|
|
{
|
|
var wmsReceipt = JsonSerializer.Deserialize<PutawayNoteDTO>(outgoingFromWms.DataContent);
|
|
foreach (var detail in wmsReceipt.Details)
|
|
{
|
|
var outgoingToExternal = new OutgoingToExternal()
|
|
{
|
|
DataType = outgoingFromWms.DataType,
|
|
DataAction = outgoingFromWms.DataAction,
|
|
SourceSystem = EnumSystemType.WMS.ToString(),
|
|
SourceDataId = detail.Id.ToString(),
|
|
SourceDataGroupCode = wmsReceipt.Number,
|
|
SourceDataDetailCode = detail.ToPackingCode,
|
|
Writer = nameof(EosOutgoingBackgroundWorker),
|
|
DestinationSystem = EnumSystemType.EOS.ToString(),
|
|
DestinationDataId = "",
|
|
};
|
|
outgoingToExternal.SetEffectiveDate(outgoingFromWms.EffectiveDate);
|
|
|
|
var exchangeReceipt = await BuildPutawayExchangeDtoAsync(wmsReceipt, detail).ConfigureAwait(false);
|
|
outgoingToExternal.SourceDataContent = JsonSerializer.Serialize(exchangeReceipt);
|
|
var arrive = BuildArrive(exchangeReceipt);
|
|
outgoingToExternal.DestinationDataContent = JsonSerializer.Serialize(arrive);
|
|
|
|
outgoingToExternalList.Add(outgoingToExternal);
|
|
}
|
|
}
|
|
|
|
await _outgoingToExternalManager.CreateManyAsync(outgoingToExternalList).ConfigureAwait(false);
|
|
//将outgoingFromWms数据归档
|
|
await _outgoingFromWmsManager.ArchiveManyAsync(outgoingFromWmsList).ConfigureAwait(false);
|
|
return outgoingToExternalList;
|
|
}
|
|
|
|
private ArriveNote BuildArrive(PutawayNoteExchangeDto exchangeReceipt)
|
|
{
|
|
var detail = exchangeReceipt.Detail;
|
|
var arrive = new ArriveNote()
|
|
{
|
|
PlanBillNo = detail.PoNumber,
|
|
ShipBillNo = detail.AsnNumber,
|
|
DocNo = exchangeReceipt.Number,
|
|
DetailMatNo = detail.ToPackingCode,
|
|
ERP = detail.ItemCode,
|
|
Qty = detail.ShippedQty,
|
|
HgQty = detail.Qty,
|
|
ProductDate = detail.ProduceDate,
|
|
ProductBatch = detail.ToLot,
|
|
Loc = detail.ToLocationErpCode,
|
|
ShipDate = detail.ShipDate,
|
|
ShipBillState = 0,
|
|
SupplierCode = detail.SupplierCode,
|
|
PlanUserCode = detail.PlanUserCode,//筹措员
|
|
EosState = 0,
|
|
// EosDate = DateTime.MinValue,
|
|
WmsDate = DateTime.Now,
|
|
Remark = detail.Remark
|
|
};
|
|
return arrive;
|
|
}
|
|
|
|
private Task<PutawayNoteExchangeDto> BuildPutawayExchangeDtoAsync(PutawayNoteDTO wmsReceipt, PutawayNoteDetailDTO wmsReceiptDetail)
|
|
{
|
|
var exchangeReceipt = _objectMapper.Map<PutawayNoteDTO, PutawayNoteExchangeDto>(wmsReceipt);
|
|
var exchangeReceiptDetail = _objectMapper.Map<PutawayNoteDetailDTO, PutawayNoteDetailExchangeDto>(wmsReceiptDetail);
|
|
exchangeReceipt.Detail = exchangeReceiptDetail;
|
|
return Task.FromResult(exchangeReceipt);
|
|
}
|
|
}
|
|
|