17 changed files with 347 additions and 3 deletions
@ -0,0 +1,12 @@ |
|||
using Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp.Bases; |
|||
using Win_in.Sfs.Wms.DataExchange.Dapper.Fawtyg.Tyrp; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.LinqToDB.Fawtyg.Tyrp.ErpLocationItems; |
|||
public class ErpLocationItemLinq2DbRepository : Linq2DbCrudRepository<locdout>, IErpLocationItemLinq2DbRepository |
|||
{ |
|||
public ErpLocationItemLinq2DbRepository(TyrpDb tyrpDb) : base(tyrpDb) |
|||
{ |
|||
|
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Services; |
|||
|
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
public class ErpLocationItemManager : DomainService, IErpLocationItemManager |
|||
{ |
|||
private readonly IErpLocationItemLinq2DbRepository _repository; |
|||
|
|||
public ErpLocationItemManager(IErpLocationItemLinq2DbRepository repository) |
|||
{ |
|||
_repository = repository; |
|||
} |
|||
public virtual async Task<List<locdout>> GetToBeProcessedListAsync() |
|||
{ |
|||
var locdouts = await _repository.GetListAsync().ConfigureAwait(false); |
|||
return locdouts.ToList(); |
|||
|
|||
} |
|||
} |
@ -0,0 +1,6 @@ |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
public interface IErpLocationItemLinq2DbRepository : ILinq2DbRepository<locdout> |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,8 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
public interface IErpLocationItemManager |
|||
{ |
|||
Task<List<locdout>> GetToBeProcessedListAsync(); |
|||
} |
@ -0,0 +1,25 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
public class locdout : Entity |
|||
{ |
|||
/// <summary>
|
|||
/// 储位
|
|||
/// </summary>
|
|||
public string locdout_loc { get; set; } |
|||
/// <summary>
|
|||
/// 零件
|
|||
/// </summary>
|
|||
public string locdout_part { get; set; } |
|||
|
|||
|
|||
public override object[] GetKeys() |
|||
{ |
|||
return new object[] { locdout_loc, locdout_part }; |
|||
} |
|||
} |
@ -0,0 +1,76 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text.Json; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Logging; |
|||
using Volo.Abp.Guids; |
|||
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.ErpLocationItem; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Incoming; |
|||
|
|||
|
|||
public class ErpLocationItemConverter : IIncomingConverter |
|||
{ |
|||
private readonly IIncomingToWmsManager _incomingToWmsManager; |
|||
private readonly IObjectMapper _objectMapper; |
|||
private readonly ILogger<ErpLocationItemConverter> _logger; |
|||
private readonly IGuidGenerator _guidGenerator; |
|||
private readonly IIncomingFromExternalManager _incomingFromExternalManager; |
|||
|
|||
public ErpLocationItemConverter( |
|||
IIncomingToWmsManager incomingToWmsManager, |
|||
IObjectMapper objectMapper, |
|||
ILogger<ErpLocationItemConverter> logger, |
|||
IGuidGenerator guidGenerator |
|||
, |
|||
IIncomingFromExternalManager incomingFromExternalManager |
|||
|
|||
) |
|||
{ |
|||
_incomingToWmsManager = incomingToWmsManager; |
|||
_objectMapper = objectMapper; |
|||
_logger = logger; |
|||
_guidGenerator = guidGenerator; |
|||
_incomingFromExternalManager = incomingFromExternalManager; |
|||
} |
|||
public virtual async Task ConvertAsync(List<IncomingFromExternal> incomingFromExternalList) |
|||
{ |
|||
if (!incomingFromExternalList.Any()) |
|||
{ |
|||
_logger.LogInformation("无开账数据转换"); |
|||
return; |
|||
} |
|||
var incomingToWmsDataList = await BuildIncomingToWmsOfPurchaseOrderAsync(incomingFromExternalList).ConfigureAwait(false); |
|||
await _incomingToWmsManager.CreateBulkAsync(incomingToWmsDataList).ConfigureAwait(false); |
|||
//归档
|
|||
await _incomingFromExternalManager.ArchiveManyAsync(incomingFromExternalList).ConfigureAwait(false); |
|||
|
|||
} |
|||
private async Task<List<IncomingToWms>> BuildIncomingToWmsOfPurchaseOrderAsync(List<IncomingFromExternal> incomingDataList) |
|||
{ |
|||
await Task.CompletedTask.ConfigureAwait(false); |
|||
var incomingToWmsList = new List<IncomingToWms>(); |
|||
var groups = incomingDataList.GroupBy(p => p.SourceDataGroupCode); |
|||
foreach (var group in groups) |
|||
{ |
|||
var first = group.First(); |
|||
var incomingToWms = new IncomingToWms() |
|||
{ |
|||
DataType = first.DataType, |
|||
DataAction = first.DataAction, |
|||
SourceSystem = first.SourceSystem, |
|||
DataIdentityCode = first.SourceDataGroupCode, |
|||
}; |
|||
incomingToWms.SetId(_guidGenerator.Create()); |
|||
incomingToWms.SetEffectiveDate(first.EffectiveDate); |
|||
var exchangeErpLocationItem = JsonSerializer.Deserialize<ErpLocationItemExchangeDto>(first.DestinationDataContent); |
|||
var wmsErpLocationItem = _objectMapper.Map<ErpLocationItemExchangeDto, ErpLocationItemEditInput>(exchangeErpLocationItem); |
|||
incomingToWms.DataContent = JsonSerializer.Serialize(wmsErpLocationItem); |
|||
incomingToWmsList.Add(incomingToWms); |
|||
} |
|||
return incomingToWmsList; |
|||
} |
|||
} |
@ -0,0 +1,109 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text.Json; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Logging; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.ObjectMapping; |
|||
using Win_in.Sfs.Basedata.Application.Contracts; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Fawtyg.Tyrp; |
|||
using Win_in.Sfs.Wms.DataExchange.Domain.Shared; |
|||
using Win_in.Sfs.Wms.DataExchange.WMS.ErpLocationItem; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.TyrpAgent.Incoming; |
|||
|
|||
public class ErpLocationItemReader : IReader |
|||
{ |
|||
private readonly IErpLocationItemManager _ilocdoutManager; |
|||
private readonly IIncomingFromExternalManager _incomingFromExternalManager; |
|||
private readonly ILogger<ErpLocationItemReader> _logger; |
|||
private readonly IGuidGenerator _guidGenerator; |
|||
private readonly IConfiguration _configuration; |
|||
public ErpLocationItemReader( |
|||
IErpLocationItemManager ilocdoutManager |
|||
, IIncomingFromExternalManager incomingFromExternalManager |
|||
, IGuidGenerator guidGenerator |
|||
, ILogger<ErpLocationItemReader> logger |
|||
, IConfiguration configuration |
|||
) |
|||
{ |
|||
_guidGenerator = guidGenerator; |
|||
_configuration = configuration; |
|||
_ilocdoutManager = ilocdoutManager; |
|||
_incomingFromExternalManager = incomingFromExternalManager; |
|||
_logger = logger; |
|||
} |
|||
|
|||
public virtual async Task<List<IncomingFromExternal>> ReadAsync() |
|||
{ |
|||
//从Tyrp读取待处理locdout
|
|||
var toBeProcessedIssue = await _ilocdoutManager.GetToBeProcessedListAsync().ConfigureAwait(false); |
|||
if (!toBeProcessedIssue.Any()) |
|||
{ |
|||
_logger.LogInformation("未读到EOS开账数据"); |
|||
return new List<IncomingFromExternal>(); |
|||
} |
|||
//locdout逐一转换为locdout
|
|||
var incomingDataList = BuildIncomingFromExternalFromBomAsync(toBeProcessedIssue); |
|||
await _incomingFromExternalManager.CreateBulkAsync(incomingDataList).ConfigureAwait(false); |
|||
return incomingDataList; |
|||
} |
|||
private List<IncomingFromExternal> BuildIncomingFromExternalFromBomAsync(List<locdout> toBeProcessedIssue) |
|||
{ |
|||
var incomingDataList = new List<IncomingFromExternal>(); |
|||
foreach (var locdout in toBeProcessedIssue) |
|||
{ |
|||
var incomingData = BuildIncomingFromExternal(locdout); |
|||
|
|||
incomingData.SetEffectiveDate(DateTime.Now); |
|||
|
|||
try |
|||
{ |
|||
var bm = BuildScrapNoteOrderExchangeMes(locdout); |
|||
incomingData.DestinationDataContent = JsonSerializer.Serialize(bm); |
|||
incomingData.SetId(_guidGenerator.Create()); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
incomingData.SetError(EnumExchangeDataErrorCode.Exception, ex.Message, ex.ToString()); |
|||
} |
|||
|
|||
incomingDataList.Add(incomingData); |
|||
|
|||
} |
|||
return incomingDataList; |
|||
} |
|||
private IncomingFromExternal BuildIncomingFromExternal(locdout locdout) |
|||
{ |
|||
var incomingData = new IncomingFromExternal() |
|||
{ |
|||
|
|||
DataType = EnumIncomingDataType.ErpLocationItem.ToString(), |
|||
DataAction = EnumExchangeDataAction.Add, |
|||
SourceSystem = EnumSystemType.ERP.ToString(), |
|||
SourceDataId = locdout.locdout_loc, |
|||
SourceDataGroupCode = locdout.locdout_loc, |
|||
SourceDataDetailCode = locdout.locdout_part, |
|||
SourceDataContent = JsonSerializer.Serialize(locdout), |
|||
WriteTime = DateTime.Now, |
|||
Writer = nameof(TyrpIncomingBackgroundWorker), |
|||
DestinationSystem = EnumSystemType.ERP.ToString(), |
|||
}; |
|||
return incomingData; |
|||
} |
|||
|
|||
private static ErpLocationItemExchangeDto BuildScrapNoteOrderExchangeMes(locdout locdout) |
|||
{ |
|||
|
|||
var cust = new ErpLocationItemExchangeDto() |
|||
{ |
|||
ErpLocationCode = locdout.locdout_loc, |
|||
ItemCode = locdout.locdout_part, |
|||
}; |
|||
|
|||
return cust; |
|||
} |
|||
} |
@ -0,0 +1,23 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Win_in.Sfs.Shared.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.DataExchange.WMS.ErpLocationItem; |
|||
public class ErpLocationItemExchangeDto |
|||
{ |
|||
/// <summary>
|
|||
/// 储位代码
|
|||
/// </summary>
|
|||
|
|||
[Display(Name = "储位代码")] |
|||
[Required(ErrorMessage = "{0}是必填项")] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string ErpLocationCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 物品代码
|
|||
/// </summary>
|
|||
[Display(Name = "物品代码")] |
|||
[Required(ErrorMessage = "{0}是必填项")] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string ItemCode { get; set; } |
|||
} |
@ -0,0 +1,23 @@ |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Win_in.Sfs.Basedata.Domain.Shared; |
|||
using Win_in.Sfs.Shared.Domain; |
|||
|
|||
namespace Win_in.Sfs.Basedata.Application.Contracts; |
|||
public class ErpLocationItemEditInput : SfsBaseDataCreateOrUpdateInputBase |
|||
{ |
|||
/// <summary>
|
|||
/// 储位代码
|
|||
/// </summary>
|
|||
[Display(Name = "储位代码")] |
|||
[Required(ErrorMessage = "{0}是必填项")] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string ErpLoactionCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 物料代码
|
|||
/// </summary>
|
|||
[Display(Name = "物料代码")] |
|||
[StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] |
|||
public string ItemCode { get; set; } |
|||
|
|||
} |
Loading…
Reference in new issue