定时器执行
This commit is contained in:
@@ -34,16 +34,16 @@ namespace WMS.Web.Api.Controllers
|
||||
private readonly IProductInventoryRepositories _repositories;
|
||||
private readonly QiniuOptions _option;
|
||||
private readonly IExportExcelService _exportExcelService;
|
||||
private readonly IProductInventoryService _roductInventoryService;
|
||||
private readonly IProductInventoryService _productInventoryService;
|
||||
public ProductInventoryController(ILoginService loginService, IBasicsRepositories basicsRepositories,
|
||||
IProductInventoryRepositories repositories, IOptions<QiniuOptions> option,
|
||||
IExportExcelService exportExcelServic, IProductInventoryService roductInventoryService) {
|
||||
IExportExcelService exportExcelServic, IProductInventoryService productInventoryService) {
|
||||
_loginService = loginService;
|
||||
_basicsRepositories = basicsRepositories;
|
||||
_repositories = repositories;
|
||||
_option = option?.Value;
|
||||
_exportExcelService = exportExcelServic;
|
||||
_roductInventoryService = roductInventoryService;
|
||||
_productInventoryService = productInventoryService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -116,7 +116,7 @@ namespace WMS.Web.Api.Controllers
|
||||
if (loginInfo == null || loginInfo.UserInfo == null)
|
||||
return Result.ReFailure(ResultCodes.Token_Invalid_Error);
|
||||
|
||||
return await _roductInventoryService.Refresh();
|
||||
return await _productInventoryService.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5043,6 +5043,13 @@
|
||||
<param name="context"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:WMS.Web.Domain.QuartzJob.InventoryQuartzJob.Execute(Quartz.IJobExecutionContext)">
|
||||
<summary>
|
||||
执行方法
|
||||
</summary>
|
||||
<param name="context"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:WMS.Web.Domain.QuartzJob.MaterialsQuartzJob">
|
||||
<summary>
|
||||
物料同步执行定时任务
|
||||
|
||||
46
src/WMS.Web.Domain/QuartzJob/InventoryQuartzJob.cs
Normal file
46
src/WMS.Web.Domain/QuartzJob/InventoryQuartzJob.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WMS.Web.Domain.IService;
|
||||
|
||||
namespace WMS.Web.Domain.QuartzJob
|
||||
{
|
||||
//成品即时库存
|
||||
public class InventoryQuartzJob : IJob
|
||||
{
|
||||
private readonly ILogger<InventoryQuartzJob> _logger;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly IProductInventoryService _productInventoryService;
|
||||
|
||||
public InventoryQuartzJob(ILogger<InventoryQuartzJob> logger,
|
||||
IServiceScopeFactory serviceScopeFactory, IProductInventoryService productInventoryService)
|
||||
{
|
||||
this._logger = logger;
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_productInventoryService = productInventoryService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行方法
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DateTime.Now.Hour < 8 || DateTime.Now.Hour > 20) return;
|
||||
var result = await _productInventoryService.Refresh();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogInformation($"同步成品即时库存:定时任务执行失败->{ex.Message}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,6 +203,7 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
Services.AddTransient<MaterialsQuartzJob>();//添加注入定时服务
|
||||
Services.AddTransient<ErpDeleteQuartzJob>();//添加注入定时服务
|
||||
//Services.AddTransient<OrderContractQuartzJob>();//添加注入定时服务
|
||||
Services.AddTransient<InventoryQuartzJob>();//添加注入定时服务
|
||||
Services.AddQuartz(q =>
|
||||
{
|
||||
q.UsePersistentStore(x =>
|
||||
@@ -301,6 +302,18 @@ namespace WMS.Web.Repositories.DependencyInjection
|
||||
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
|
||||
.WithDescription("ErpDeleteQuartzJobTriggerDecs"));
|
||||
#endregion
|
||||
|
||||
#region 成品即时库存
|
||||
var jobKey_Inventory = new JobKey("InventoryQuartzJob", options.QuartzJobValue);
|
||||
q.AddJob<InventoryQuartzJob>(jobKey, j => j.WithDescription("InventoryQuartzJob"));
|
||||
q.AddTrigger(t => t
|
||||
.WithIdentity("InventoryQuartzJobTrigger")
|
||||
.ForJob(jobKey)
|
||||
.StartNow()
|
||||
.WithCronSchedule(options.JobStartExpre)
|
||||
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
|
||||
.WithDescription("InventoryQuartzJobTriggerDecs"));
|
||||
#endregion
|
||||
});
|
||||
//.net core核心托管-添加Quartz服务器
|
||||
Services.AddQuartzServer(options =>
|
||||
|
||||
Reference in New Issue
Block a user