From cf3050083e157819b94781d0445547ffc73e21f2 Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期五, 28 十一月 2025 21:17:28 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs"
index 9b4fc91..c284b28 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs"
@@ -22,6 +22,8 @@
//using WIDESEA_Core.HostedService;
using WIDESEA_Core.Middlewares;
using WIDESEA_WMSServer.Filter;
+using Quartz;
+using WIDESEA_WMSServer.Jobs;
var builder = WebApplication.CreateBuilder(args);
@@ -146,10 +148,35 @@
client.Timeout = TimeSpan.FromSeconds(30);
});
+
+builder.Services.AddQuartz(q =>
+{
+
+ var jobKey = new JobKey("ErpJob");
+ q.AddJob<ErpJob>(opts => opts.WithIdentity(jobKey));
+
+ // 添加触发器 - 每天10:00, 14:00, 20:00执行
+ q.AddTrigger(opts => opts
+ .ForJob(jobKey)
+ .WithIdentity("ErpJob-trigger")
+ .WithCronSchedule("0 0 10,14,20 * * ?"));
+
+ var inventoryLockJobKey = new JobKey("InventoryLockJob");
+ q.AddJob<InventoryLockJob>(opts => opts.WithIdentity(inventoryLockJobKey));
+
+ q.AddTrigger(opts => opts
+ .ForJob(inventoryLockJobKey)
+ .WithIdentity("InventoryLockJob-trigger")
+ .WithCronSchedule("0 0/10 * * * ?")); // 每10分钟执行一次
+
+});
+
+
+builder.Services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
var app = builder.Build();
-// 3、配置中间件
+
app.UseMiniProfiler();//性能分析器
app.ConfigureApplication();//配置文件
app.UseApplicationSetup();//启动配置
--
Gitblit v1.9.3