2025-06-12 17:55:19 +08:00
|
|
|
|
using JiShe.ServicePro.Core;
|
|
|
|
|
|
using JiShe.ServicePro.DeviceManagement.Meters;
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
2025-06-12 17:56:24 +08:00
|
|
|
|
namespace JiShe.IoT.Jobs.ToMysql
|
2025-06-12 17:55:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 批量同步 水表 watermeter 数据到mysql
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class BathSyncWatermeterDataToMysqlJob : SystemBackGroundWorkService
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly ILogger<BathSyncWatermeterDataToMysqlJob> _logger;
|
|
|
|
|
|
public readonly MeterAppService _meterAppService;
|
|
|
|
|
|
public BathSyncWatermeterDataToMysqlJob(ILogger<BathSyncWatermeterDataToMysqlJob> logger, MeterAppService meterAppService) : base(logger)
|
|
|
|
|
|
{
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
|
_meterAppService = meterAppService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 定时执行
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
protected override Task DoWorkAsync(CancellationToken cancellationToken)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _meterAppService.BathSyncWatermeterDataAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override TimeSpan GetInterval()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 每隔3小时执行一次
|
|
|
|
|
|
return TimeSpan.FromHours(3);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|