From 83751b84ce45df8348569fc2b7296ecc602ec98e Mon Sep 17 00:00:00 2001 From: tq <1916474859@qq,com> Date: Fri, 7 Jun 2024 08:53:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=83=E5=A4=A9=E7=94=B5=E8=83=BD=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Service/Ammeter/EmeterDayEnergyService.cs | 19 +++++++ .../Station/BatteryOpModelDetailService.cs | 56 +++++++++++++++++++ Service/System/SysUserService.cs | 2 +- .../Controllers/Ammeter/AmmeterController.cs | 11 +++- 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 Service/Station/BatteryOpModelDetailService.cs diff --git a/Service/Ammeter/EmeterDayEnergyService.cs b/Service/Ammeter/EmeterDayEnergyService.cs index 0f2966b..b6771af 100644 --- a/Service/Ammeter/EmeterDayEnergyService.cs +++ b/Service/Ammeter/EmeterDayEnergyService.cs @@ -3,6 +3,7 @@ using Entity.Dto.Req; using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Entity; using Repository.Ammeter; +using SqlSugar; namespace Service.Ammeter { @@ -28,5 +29,23 @@ namespace Service.Ammeter 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; + } } } diff --git a/Service/Station/BatteryOpModelDetailService.cs b/Service/Station/BatteryOpModelDetailService.cs new file mode 100644 index 0000000..90ad997 --- /dev/null +++ b/Service/Station/BatteryOpModelDetailService.cs @@ -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 +{ + private BatteryOpModelDetailRepository _batteryOpModelDetailRepository; + + + public BatteryOpModelDetailService(BatteryOpModelDetailRepository dal) + { + _batteryOpModelDetailRepository = dal; + BaseDal = dal; + } + /// + /// 电池运营模型详情分页列表 🔖 + /// + /// + /// + public async Task> Page(PageBatteryOpModelDetailReq input) + { + RefAsync 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() + { + PageNum = input.PageNum, + PageSize = input.PageSize, + ToTal = total, + Rows = items, + }; + } + /// + /// 删除电池运营模型 🔖 + /// + /// + /// + public virtual async Task DeleteBatteryOpModelDetail(DeleteBatteryOpModelDetailReq input) + { + var user = await _batteryOpModelDetailRepository.QueryByClauseAsync(u => u.Id == input.Id); + if (user == null) + throw new ArgumentException($"电池运营模型不存在"); + return await _batteryOpModelDetailRepository.DeleteAsync(user); + } +} \ No newline at end of file diff --git a/Service/System/SysUserService.cs b/Service/System/SysUserService.cs index 54a4812..08f122f 100644 --- a/Service/System/SysUserService.cs +++ b/Service/System/SysUserService.cs @@ -44,7 +44,7 @@ namespace Service.System entity => true, false, entity => true, !string.IsNullOrEmpty(input.Account), u => u.Account == input.Account, !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() { diff --git a/WebStarter/Controllers/Ammeter/AmmeterController.cs b/WebStarter/Controllers/Ammeter/AmmeterController.cs index cae730e..b84187a 100644 --- a/WebStarter/Controllers/Ammeter/AmmeterController.cs +++ b/WebStarter/Controllers/Ammeter/AmmeterController.cs @@ -38,7 +38,16 @@ namespace WebStarter.Controllers.Ammeter _emeterMinutesEnergyChangeService = emeterMinutesEnergyChangeService; _equipInfoService = equipInfoService; } - + /// + /// 七天电表用量 + /// + /// + /// + [HttpGet("SevenDaysElectricalEnergy")] + public async Task>> SevenDaysElectricalEnergy() + { + return Result>.Success(await _emeterDayEnergyService.SevenDaysElectricalEnergy()); + } #region 统计分析/电能表累计值信息