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.
75 lines
3.0 KiB
75 lines
3.0 KiB
using System.Threading.Tasks;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
using Volo.Abp.BackgroundWorkers;
|
|
using Volo.Abp.Threading;
|
|
using Volo.Abp.Uow;
|
|
using Win_in.Sfs.Wms.DataExchange.Domain;
|
|
|
|
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.EosAgent;
|
|
|
|
public class EosOutgoingBackgroundWorker : AsyncPeriodicBackgroundWorkerBase
|
|
{
|
|
private readonly string Outgoing = "EOS发送";
|
|
|
|
private readonly IOptions<EosOptions> _options;
|
|
|
|
public EosOutgoingBackgroundWorker(
|
|
AbpAsyncTimer timer
|
|
, IOptions<EosOptions> options
|
|
, IServiceScopeFactory serviceScopeFactory
|
|
) : base(timer, serviceScopeFactory)
|
|
{
|
|
_options = options;
|
|
Timer.Period = options.Value.OutgoingOptions.PeriodSeconds * 1000; //default 10 minutes
|
|
|
|
}
|
|
|
|
[UnitOfWork]
|
|
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
|
|
{
|
|
Logger.LogInformation($"开始: 执行 {Outgoing}");
|
|
|
|
var configManager = workerContext.ServiceProvider.GetRequiredService<IInterfaceConfigManager>();
|
|
var confitem = await configManager.GetInterfaceConfig("EOS-OUT").ConfigureAwait(false);
|
|
if (confitem == null)
|
|
{
|
|
if (!_options.Value.OutgoingOptions.Active)
|
|
{
|
|
Logger.LogInformation($"{Outgoing} 已关闭没有执行!");
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!confitem.Active)
|
|
{
|
|
Logger.LogInformation($"{Outgoing} 已关闭没有执行!");
|
|
if (confitem.Status == 0)
|
|
{
|
|
await configManager.UpsertStatusAsync("EOS-OUT").ConfigureAwait(false);
|
|
Logger.LogInformation($"{Outgoing} 运行已结束,更新接口运行状态!");
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
Logger.LogInformation($"传出 采购上架单");
|
|
var arriveConvert = workerContext.ServiceProvider.GetRequiredService<ArriveConverter>();
|
|
var arriveNoteList = await arriveConvert.ConvertAsync().ConfigureAwait(false);
|
|
var arriveWriter = workerContext.ServiceProvider.GetRequiredService<ArriveNoteWriter>();
|
|
await arriveWriter.WriteAsync(arriveNoteList).ConfigureAwait(false);
|
|
Logger.LogInformation($"处理采购上架单【{arriveNoteList.Count}】条数据");
|
|
|
|
Logger.LogInformation($"传出 采购退货单");
|
|
var returnConvert = workerContext.ServiceProvider.GetRequiredService<ReturnConverter>();
|
|
var returnNoteList = await returnConvert.ConvertAsync().ConfigureAwait(false);
|
|
var returnWriter = workerContext.ServiceProvider.GetRequiredService<ReturnNoteWriter>();
|
|
await returnWriter.WriteAsync(returnNoteList).ConfigureAwait(false);
|
|
Logger.LogInformation($"处理采购退货单【{returnNoteList.Count}】条数据");
|
|
|
|
Logger.LogInformation($"提交: 执行 {Outgoing}");
|
|
}
|
|
|
|
}
|
|
|