using Autofac;
using Entity.Ammeter;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Job;
using log4net;
using Repository.Ammeter;
using Repository.System;
namespace Service.Job;
///
/// 分钟统计
///
[Scope]
public class EmeterMinuteJob : AbstrackCronJob
{
private static readonly ILog Log = LogManager.GetLogger(typeof(EmeterMinuteJob));
public EmeterEnergyRepository EmeterEnergyRepository { get; set; }
public EmeterEnergyChangeRepository EmeterEnergyChangeRepository { get; set; }
public EmeterMinutesEnergyRepository EmeterMinutesEnergyRepository { get; set; }
protected override Task Handle()
{
/*var now = DateTime.Now;
Log.Info($"EmeterMinuteJob execute time={now}");
//查询上一分钟的数据
string dateTime = now.AddMinutes(-1).ToString("yyyy-MM-dd HH:mm");
List emeterEnergies = EmeterEnergyRepository.QueryListByClause(i =>
dateTime.Equals(i.UploadTime.ToString("yyyy-MM-dd HH:mm")), "upload_time desc");
List emeterEnergiesChange = EmeterEnergyChangeRepository.QueryListByClause(i =>
dateTime.Equals(i.UploadTime.ToString("yyyy-MM-dd HH:mm")), "upload_time desc");
if (emeterEnergies.Count > 0)
{
Dictionary> dictionary =
emeterEnergies.GroupBy(i => i.Code).ToDictionary(i => i.Key, i => i.ToList());
foreach (var keyValuePair in dictionary)
{
EmeterMinutesEnergy emeterMinutesEnergy = new EmeterMinutesEnergy();
emeterMinutesEnergy.Code = keyValuePair.Key;
emeterMinutesEnergy.Time = dateTime;
}
}
if (emeterEnergiesChange.Count > 0)
{
Dictionary> dictionaryChange =
emeterEnergiesChange.GroupBy(i => i.Code).ToDictionary(i => i.Key, i => i.ToList());
}*/
return Task.CompletedTask;
}
protected override string Cron()
{
return "0 0/1 * * * ?";
}
}