using JiShe.CollectBus.ScheduledMeterReading;
using JiShe.ServicePro.Core;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace JiShe.CollectBus.Workers
{
    /// <summary>
    /// 定时抄表
    /// </summary>
    /// <param name="scheduledMeterReadingService">抄读服务</param>
    /// <param name="logger"></param>
    public class ScheduledMeterReadingBackGroundWorkService(IScheduledMeterReadingService scheduledMeterReadingService, ILogger<ScheduledMeterReadingBackGroundWorkService> logger) : SystemBackGroundWorkService(logger)
    {
        protected override TimeSpan GetInterval()
        {
            // 返回执行间隔时间
            return TimeSpan.FromSeconds(10);
        }

        protected override async Task DoWorkAsync(CancellationToken cancellationToken)
        {
            // 这里编写具体的后台任务逻辑，例如从数据库中读取数据、发送网络请求等
            // 这里的逻辑会每隔一段时间执行一次，时间间隔由 GetInterval 方法返回的值决定
            Logger.LogWarning($"定时抄读后台任务执行中...{DateTime.Now.ToString()}");
            //await scheduledMeterReadingService.CreateToBeIssueTasks();
        }
    }
}
