|
|
|
using System;
|
|
|
|
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;
|
|
|
|
using Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent.Incoming;
|
|
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts;
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.InjectionMoldingTaskAgent;
|
|
|
|
|
|
|
|
public class InjectionMoldingTaskIncomingBackgroundWorker : AsyncPeriodicBackgroundWorkerBase
|
|
|
|
{
|
|
|
|
private readonly string Incoming = "视觉接收";
|
|
|
|
|
|
|
|
private readonly IOptions<InjectionMoldingTaskOptions> _options;
|
|
|
|
|
|
|
|
public InjectionMoldingTaskIncomingBackgroundWorker(
|
|
|
|
AbpAsyncTimer timer,
|
|
|
|
IOptions<InjectionMoldingTaskOptions> options,
|
|
|
|
IServiceScopeFactory serviceScopeFactory
|
|
|
|
) : base(timer, serviceScopeFactory)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_options = options;
|
|
|
|
#if DEBUG
|
|
|
|
_options.Value.AutoRemote.TimeCycle = 1;
|
|
|
|
_options.Value.AutoRemote.Interval = 2;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
Timer.Period = options.Value.AutoRemote.TimeCycle * 60 * 1000; //default 10 minutes
|
|
|
|
}
|
|
|
|
|
|
|
|
[UnitOfWork]
|
|
|
|
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
|
|
|
|
{
|
|
|
|
Logger.LogInformation($"开始: 执行 {Incoming}");
|
|
|
|
var configManager = workerContext.ServiceProvider.GetRequiredService<IInterfaceConfigManager>();
|
|
|
|
var confitem = await configManager.GetInterfaceConfig("SJ-IN").ConfigureAwait(false);
|
|
|
|
if (confitem == null)
|
|
|
|
{
|
|
|
|
if (!_options.Value.IncomingOptions.Active)
|
|
|
|
{
|
|
|
|
Logger.LogInformation($"{Incoming} 已关闭没有执行!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!confitem.Active)
|
|
|
|
{
|
|
|
|
Logger.LogInformation($"{Incoming} 已关闭没有执行!");
|
|
|
|
if (confitem.Status == 0)
|
|
|
|
{
|
|
|
|
await configManager.UpsertStatusAsync("SJ-IN").ConfigureAwait(false);
|
|
|
|
Logger.LogInformation($"{Incoming} 运行已结束,更新接口运行状态!");
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Logger.LogInformation($"注塑任务");//缴库
|
|
|
|
var reader = workerContext.ServiceProvider.GetService<InjectionMoldingRequestReader>();
|
|
|
|
await reader.ReadAsync().ConfigureAwait(false);
|
|
|
|
Logger.LogInformation($"提交: 执行 {Incoming}");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|