七天电能统计

master
tq 6 months ago
parent 666510a316
commit 83751b84ce

@ -3,6 +3,7 @@ using Entity.Dto.Req;
using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity; using HybirdFrameworkCore.Entity;
using Repository.Ammeter; using Repository.Ammeter;
using SqlSugar;
namespace Service.Ammeter namespace Service.Ammeter
{ {
@ -28,5 +29,23 @@ namespace Service.Ammeter
else else
return PageResult<EmeterDayEnergy>.ConvertPage(this.BaseDal.QueryIPageByCause(queryPageModel1, null)); return PageResult<EmeterDayEnergy>.ConvertPage(this.BaseDal.QueryIPageByCause(queryPageModel1, null));
} }
/// <summary>
/// 七天电能统计
/// </summary>
/// <returns></returns>
public async Task<List<EmeterDayEnergy>> SevenDaysElectricalEnergy()
{
DateTime sevenDaysAgo = DateTime.Today.AddDays(-7);
List<EmeterDayEnergy> 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;
}
} }
} }

@ -0,0 +1,56 @@
using Entity.DbModel.Station;
using Entity.Dto.Req;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Entity;
using Repository.Station;
using SqlSugar;
namespace Service.Station;
[Scope("SingleInstance")]
public class BatteryOpModelDetailService: BaseServices<BatteryOpModelDetail>
{
private BatteryOpModelDetailRepository _batteryOpModelDetailRepository;
public BatteryOpModelDetailService(BatteryOpModelDetailRepository dal)
{
_batteryOpModelDetailRepository = dal;
BaseDal = dal;
}
/// <summary>
/// 电池运营模型详情分页列表 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<PageResult<BatteryOpModelDetail>> Page(PageBatteryOpModelDetailReq input)
{
RefAsync<int> total = 0;
var items = await _batteryOpModelDetailRepository.QueryPageAsync(
entity => true,
false, entity => true,
false, entity => true,
!string.IsNullOrEmpty(input.BatteryType), u => u.BatteryType == input.BatteryType,
u => u.CreatedTime, input.PageNum, input.PageSize, total
);
return new PageResult<BatteryOpModelDetail>()
{
PageNum = input.PageNum,
PageSize = input.PageSize,
ToTal = total,
Rows = items,
};
}
/// <summary>
/// 删除电池运营模型 🔖
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public virtual async Task<bool> DeleteBatteryOpModelDetail(DeleteBatteryOpModelDetailReq input)
{
var user = await _batteryOpModelDetailRepository.QueryByClauseAsync(u => u.Id == input.Id);
if (user == null)
throw new ArgumentException($"电池运营模型不存在");
return await _batteryOpModelDetailRepository.DeleteAsync(user);
}
}

@ -44,7 +44,7 @@ namespace Service.System
entity => true, false, entity => true, entity => true, false, entity => true,
!string.IsNullOrEmpty(input.Account), u => u.Account == input.Account, !string.IsNullOrEmpty(input.Account), u => u.Account == input.Account,
!string.IsNullOrEmpty(input.RealName), u => u.RealName == input.RealName, !string.IsNullOrEmpty(input.RealName), u => u.RealName == input.RealName,
u => u.CreateTime, input.PageNum, input.PageNum, total u => u.CreateTime, input.PageNum, input.PageSize, total
); );
return new PageResult<SysUser>() return new PageResult<SysUser>()
{ {

@ -38,7 +38,16 @@ namespace WebStarter.Controllers.Ammeter
_emeterMinutesEnergyChangeService = emeterMinutesEnergyChangeService; _emeterMinutesEnergyChangeService = emeterMinutesEnergyChangeService;
_equipInfoService = equipInfoService; _equipInfoService = equipInfoService;
} }
/// <summary>
/// 七天电表用量
/// </summary>
/// <param name="Code"></param>
/// <returns></returns>
[HttpGet("SevenDaysElectricalEnergy")]
public async Task<Result<List<EmeterDayEnergy>>> SevenDaysElectricalEnergy()
{
return Result<List<EmeterDayEnergy>>.Success(await _emeterDayEnergyService.SevenDaysElectricalEnergy());
}
#region 统计分析/电能表累计值信息 #region 统计分析/电能表累计值信息

Loading…
Cancel
Save