using Entity.Ammeter; using Entity.Dto.Req; using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Entity; using Repository.Ammeter; using SqlSugar; namespace Service.Ammeter { /// /// /// [Scope("SingleInstance")] public class EmeterDayEnergyService : BaseServices { public EmeterDayEnergyService(EmeterDayEnergyRepository service) { this.BaseDal = service; } public async Task> Page(PageAmmeterReq queryPageModel) { QueryPageModel queryPageModel1 = new QueryPageModel { PageNum = queryPageModel.PageNum, PageSize = queryPageModel.PageSize, }; if (!string.IsNullOrEmpty(queryPageModel.Code)) return PageResult.ConvertPage(this.BaseDal.QueryIPageByCause(queryPageModel1, u => u.Code == queryPageModel.Code)); else return PageResult.ConvertPage(this.BaseDal.QueryIPageByCause(queryPageModel1, null)); } /// /// 七天电能统计 /// /// public async Task> SevenDaysElectricalEnergy() { DateTime sevenDaysAgo = DateTime.Today.AddDays(-7); List result = this.BaseDal.Queryable() .Where(e => e.Et >= sevenDaysAgo) .GroupBy(e => e.Code) .Select(e => new EmeterDayEnergy { Code = e.Code, Value = SqlFunc.AggregateSum(e.Value) }).ToList(); return result; } } }