You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
2.1 KiB

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;
/// <summary>
/// 分钟统计
/// </summary>
[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<EmeterEnergy> emeterEnergies = EmeterEnergyRepository.QueryListByClause(i =>
dateTime.Equals(i.UploadTime.ToString("yyyy-MM-dd HH:mm")), "upload_time desc");
List<EmeterEnergyChange> emeterEnergiesChange = EmeterEnergyChangeRepository.QueryListByClause(i =>
dateTime.Equals(i.UploadTime.ToString("yyyy-MM-dd HH:mm")), "upload_time desc");
if (emeterEnergies.Count > 0)
{
Dictionary<string, List<EmeterEnergy>> 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<string, List<EmeterEnergyChange>> dictionaryChange =
emeterEnergiesChange.GroupBy(i => i.Code).ToDictionary(i => i.Key, i => i.ToList());
}*/
return Task.CompletedTask;
}
protected override string Cron()
{
return "0 0/1 * * * ?";
}
}