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.

39 lines
1.3 KiB

using Entity.Ammeter;
using HybirdFrameworkCore.Autofac.Attribute;
5 months ago
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using Repository.Ammeter;
6 months ago
using SqlSugar;
namespace Service.Ammeter;
[Scope("SingleInstance")]
public class EmeterEnergyChangeService : BaseServices<EmeterEnergyChange>
{
private readonly EmeterEnergyChangeRepository _emeterEnergyChangeRep;
public EmeterEnergyChangeService(EmeterEnergyChangeRepository emeterEnergyChangeRep)
{
_emeterEnergyChangeRep = emeterEnergyChangeRep;
5 months ago
BaseDal = emeterEnergyChangeRep;
}
/// <summary>
/// 获取交流电表实时数据
/// </summary>
/// <returns></returns>
6 months ago
public async Task<List<EmeterEnergyChange>> GetEnergyMeterRealTime(string endTime)
{
6 months ago
// 将传入的时间参数转换为DateTime类型
DateTime endDateTime = DateTime.Parse(endTime);
6 months ago
// 根据传入的时间参数计算1分钟的时间
DateTime startDateTime = endDateTime.AddMinutes(-1);
6 months ago
6 months ago
List<EmeterEnergyChange> list = await _emeterEnergyChangeRep.QueryListByClauseAsync(i => i.UploadTime>=startDateTime);
return list
.GroupBy(e => e.Code)
.Select(g => g.OrderByDescending(e => e.UploadTime).First())
.ToList();
}
}