feat: Implement scheduled tasks management and budget archiving functionality
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 6s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 6s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
- Added BudgetArchiveJob for monthly budget archiving. - Created BudgetArchive entity and BudgetArchiveRepository for managing archived budgets. - Introduced JobController for handling job execution, pausing, and resuming. - Developed ScheduledTasksView for displaying and managing scheduled tasks in the frontend. - Updated PeriodicBillJob to improve scope handling. - Enhanced OpenAiService with increased HTTP timeout. - Added archiveBudgets API endpoint for archiving budgets by year and month. - Refactored BudgetController to utilize new repository patterns and improved error handling. - Introduced rich-content styles for better rendering of HTML content in Vue components. - Updated various Vue components to support rich HTML content display.
This commit is contained in:
42
Service/Jobs/BudgetArchiveJob.cs
Normal file
42
Service/Jobs/BudgetArchiveJob.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Quartz;
|
||||
|
||||
namespace Service.Jobs;
|
||||
|
||||
/// <summary>
|
||||
/// 预算归档定时任务
|
||||
/// </summary>
|
||||
[DisallowConcurrentExecution]
|
||||
public class BudgetArchiveJob(
|
||||
IServiceProvider serviceProvider,
|
||||
ILogger<BudgetArchiveJob> logger) : IJob
|
||||
{
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.LogInformation("开始执行预算归档任务");
|
||||
|
||||
// 每个月1号执行,归档上个月的数据
|
||||
var targetDate = DateTime.Now.AddMonths(-1);
|
||||
var year = targetDate.Year;
|
||||
var month = targetDate.Month;
|
||||
|
||||
using var scope = serviceProvider.CreateScope();
|
||||
var budgetService = scope.ServiceProvider.GetRequiredService<IBudgetService>();
|
||||
var result = await budgetService.ArchiveBudgetsAsync(year, month);
|
||||
|
||||
if (string.IsNullOrEmpty(result))
|
||||
{
|
||||
logger.LogInformation("归档 {Year}年{Month}月 预算任务执行成功", year, month);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.LogWarning("归档 {Year}年{Month}月 预算任务提示: {Result}", year, month, result);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "预算归档任务执行出错");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user