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.
|
|
|
|
using Entity.Ammeter;
|
|
|
|
|
using Entity.Api.Resp;
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
using Microsoft.Data.SqlClient;
|
|
|
|
|
using Repository.Ammeter;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace Service.Ammeter;
|
|
|
|
|
|
|
|
|
|
[Scope("SingleInstance")]
|
|
|
|
|
public class EmeterEnergyService : BaseServices<EmeterEnergy>
|
|
|
|
|
{
|
|
|
|
|
public EmeterEnergyService(EmeterEnergyRepository service)
|
|
|
|
|
{
|
|
|
|
|
this.BaseDal = service;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取直流电表实时数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<EmeterEnergy>> GetEnergyMeterRealTime(string endTime)
|
|
|
|
|
{
|
|
|
|
|
// 将传入的时间参数转换为DateTime类型
|
|
|
|
|
DateTime endDateTime = DateTime.Parse(endTime);
|
|
|
|
|
|
|
|
|
|
// 根据传入的时间参数计算1分钟的时间
|
|
|
|
|
DateTime startDateTime = endDateTime.AddMinutes(-1);
|
|
|
|
|
|
|
|
|
|
List<EmeterEnergy> list = await this.BaseDal.QueryListByClauseAsync(i => i.UploadTime>=startDateTime);
|
|
|
|
|
|
|
|
|
|
return list
|
|
|
|
|
.GroupBy(e => e.Code)
|
|
|
|
|
.Select(g => g.OrderByDescending(e => e.UploadTime).First())
|
|
|
|
|
.ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|