定时器执行
This commit is contained in:
@@ -34,16 +34,16 @@ namespace WMS.Web.Api.Controllers
|
|||||||
private readonly IProductInventoryRepositories _repositories;
|
private readonly IProductInventoryRepositories _repositories;
|
||||||
private readonly QiniuOptions _option;
|
private readonly QiniuOptions _option;
|
||||||
private readonly IExportExcelService _exportExcelService;
|
private readonly IExportExcelService _exportExcelService;
|
||||||
private readonly IProductInventoryService _roductInventoryService;
|
private readonly IProductInventoryService _productInventoryService;
|
||||||
public ProductInventoryController(ILoginService loginService, IBasicsRepositories basicsRepositories,
|
public ProductInventoryController(ILoginService loginService, IBasicsRepositories basicsRepositories,
|
||||||
IProductInventoryRepositories repositories, IOptions<QiniuOptions> option,
|
IProductInventoryRepositories repositories, IOptions<QiniuOptions> option,
|
||||||
IExportExcelService exportExcelServic, IProductInventoryService roductInventoryService) {
|
IExportExcelService exportExcelServic, IProductInventoryService productInventoryService) {
|
||||||
_loginService = loginService;
|
_loginService = loginService;
|
||||||
_basicsRepositories = basicsRepositories;
|
_basicsRepositories = basicsRepositories;
|
||||||
_repositories = repositories;
|
_repositories = repositories;
|
||||||
_option = option?.Value;
|
_option = option?.Value;
|
||||||
_exportExcelService = exportExcelServic;
|
_exportExcelService = exportExcelServic;
|
||||||
_roductInventoryService = roductInventoryService;
|
_productInventoryService = productInventoryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -116,7 +116,7 @@ namespace WMS.Web.Api.Controllers
|
|||||||
if (loginInfo == null || loginInfo.UserInfo == null)
|
if (loginInfo == null || loginInfo.UserInfo == null)
|
||||||
return Result.ReFailure(ResultCodes.Token_Invalid_Error);
|
return Result.ReFailure(ResultCodes.Token_Invalid_Error);
|
||||||
|
|
||||||
return await _roductInventoryService.Refresh();
|
return await _productInventoryService.Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5043,6 +5043,13 @@
|
|||||||
<param name="context"></param>
|
<param name="context"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</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">
|
<member name="T:WMS.Web.Domain.QuartzJob.MaterialsQuartzJob">
|
||||||
<summary>
|
<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<MaterialsQuartzJob>();//添加注入定时服务
|
||||||
Services.AddTransient<ErpDeleteQuartzJob>();//添加注入定时服务
|
Services.AddTransient<ErpDeleteQuartzJob>();//添加注入定时服务
|
||||||
//Services.AddTransient<OrderContractQuartzJob>();//添加注入定时服务
|
//Services.AddTransient<OrderContractQuartzJob>();//添加注入定时服务
|
||||||
|
Services.AddTransient<InventoryQuartzJob>();//添加注入定时服务
|
||||||
Services.AddQuartz(q =>
|
Services.AddQuartz(q =>
|
||||||
{
|
{
|
||||||
q.UsePersistentStore(x =>
|
q.UsePersistentStore(x =>
|
||||||
@@ -301,6 +302,18 @@ namespace WMS.Web.Repositories.DependencyInjection
|
|||||||
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
|
//.WithCronSchedule(CronScheduleBuilder.DailyAtHourAndMinute(options.JobStartHour[5], options.JobStartMinute[5]))
|
||||||
.WithDescription("ErpDeleteQuartzJobTriggerDecs"));
|
.WithDescription("ErpDeleteQuartzJobTriggerDecs"));
|
||||||
#endregion
|
#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服务器
|
//.net core核心托管-添加Quartz服务器
|
||||||
Services.AddQuartzServer(options =>
|
Services.AddQuartzServer(options =>
|
||||||
|
|||||||
Reference in New Issue
Block a user