From e8137456c931e7e24db9ab43ece3bad2e684e65b Mon Sep 17 00:00:00 2001 From: CZ Date: Fri, 24 May 2024 10:55:23 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E8=A1=A8=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Entity/Ammeter/EmeterDayEnergy.cs | 39 ++++++ Entity/Ammeter/EmeterHourEnergy.cs | 39 ++++++ Entity/Ammeter/EmeterMinutesEnergy.cs | 37 +++++ .../Ammeter/EmeterDayEnergyRepository.cs | 15 ++ .../Ammeter/EmeterHourEnergyRepository.cs | 15 ++ .../Ammeter/EmeterMinutesEnergyRepository.cs | 14 ++ Service/Ammeter/EmeterDayEnergyService.cs | 19 +++ Service/Ammeter/EmeterHourEnergyService.cs | 19 +++ Service/Ammeter/EmeterMinutesEnergyService.cs | 19 +++ .../Cloud/Msg/Host/Req/ChargerDataReport.cs | 16 +++ Service/Service.csproj | 16 +-- .../Controllers/Ammeter/AmmeterController.cs | 132 ++++++++++++++++++ 12 files changed, 372 insertions(+), 8 deletions(-) create mode 100644 Entity/Ammeter/EmeterDayEnergy.cs create mode 100644 Entity/Ammeter/EmeterHourEnergy.cs create mode 100644 Entity/Ammeter/EmeterMinutesEnergy.cs create mode 100644 Repository/Ammeter/EmeterDayEnergyRepository.cs create mode 100644 Repository/Ammeter/EmeterHourEnergyRepository.cs create mode 100644 Repository/Ammeter/EmeterMinutesEnergyRepository.cs create mode 100644 Service/Ammeter/EmeterDayEnergyService.cs create mode 100644 Service/Ammeter/EmeterHourEnergyService.cs create mode 100644 Service/Ammeter/EmeterMinutesEnergyService.cs create mode 100644 Service/Cloud/Msg/Host/Req/ChargerDataReport.cs create mode 100644 WebStarter/Controllers/Ammeter/AmmeterController.cs diff --git a/Entity/Ammeter/EmeterDayEnergy.cs b/Entity/Ammeter/EmeterDayEnergy.cs new file mode 100644 index 0000000..ef13452 --- /dev/null +++ b/Entity/Ammeter/EmeterDayEnergy.cs @@ -0,0 +1,39 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Entity.Ammeter +{ + /// + /// 电表按天上传数据 + /// + [SugarTable("emeter_day_energy")] + public partial class EmeterDayEnergy + { + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")] + public long Id { get; set; } + /// + /// 电表编码 + /// + [SugarColumn(ColumnName = "code")] + public string Mn { get; set; } + /// + /// 天变化值 千瓦时 + /// + [SugarColumn(ColumnName = "value")] + public float Dv { get; set; } + /// + /// 时间 + /// + [SugarColumn(ColumnName = "st")] + public DateTime St { get; set; } + /// + /// 时间 + /// + [SugarColumn(ColumnName = "et")] + public DateTime Et { get; set; } + } +} diff --git a/Entity/Ammeter/EmeterHourEnergy.cs b/Entity/Ammeter/EmeterHourEnergy.cs new file mode 100644 index 0000000..09ad52f --- /dev/null +++ b/Entity/Ammeter/EmeterHourEnergy.cs @@ -0,0 +1,39 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Entity.Ammeter +{ + /// + /// 电表一小时统计一次数据 + /// + [SugarTable("emeter_hour_energy")] + public partial class EmeterHourEnergy + { + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")] + public long Id { get; set; } + /// + /// 电表编码 + /// + [SugarColumn(ColumnName = "code")] + public string Mn { get; set; } + /// + /// 小时变化值 千瓦时 + /// + [SugarColumn(ColumnName = "value")] + public float Hv { get; set; } + /// + /// 时间 + /// + [SugarColumn(ColumnName = "st")] + public DateTime St { get; set; } + /// + /// 时间 + /// + [SugarColumn(ColumnName = "et")] + public DateTime Et { get; set; } + } +} diff --git a/Entity/Ammeter/EmeterMinutesEnergy.cs b/Entity/Ammeter/EmeterMinutesEnergy.cs new file mode 100644 index 0000000..de0890a --- /dev/null +++ b/Entity/Ammeter/EmeterMinutesEnergy.cs @@ -0,0 +1,37 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Entity.Ammeter +{ + /// + /// 电表15分钟保存一次数据 + /// + [SugarTable("emeter_minutes_energy")] + + public partial class EmeterMinutesEnergy + { + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")] + public long Id { get; set; } + /// + /// 电表编码 + /// + [SugarColumn(ColumnName = "code")] + public string Mn { get; set; } + /// + /// 千瓦时 + /// + [SugarColumn(ColumnName = "value")] + public float Value { get; set; } + /// + /// 时间 + /// + [SugarColumn(ColumnName = "time")] + public DateTime Time { get; set; } + + + } +} diff --git a/Repository/Ammeter/EmeterDayEnergyRepository.cs b/Repository/Ammeter/EmeterDayEnergyRepository.cs new file mode 100644 index 0000000..99f427d --- /dev/null +++ b/Repository/Ammeter/EmeterDayEnergyRepository.cs @@ -0,0 +1,15 @@ + +using Entity.Ammeter; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.Ammeter +{ + [Scope("SingleInstance")] + public class EmeterDayEnergyRepository : BaseRepository + { + public EmeterDayEnergyRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + } + } +} diff --git a/Repository/Ammeter/EmeterHourEnergyRepository.cs b/Repository/Ammeter/EmeterHourEnergyRepository.cs new file mode 100644 index 0000000..751cfc0 --- /dev/null +++ b/Repository/Ammeter/EmeterHourEnergyRepository.cs @@ -0,0 +1,15 @@ + +using Entity.Ammeter; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.Ammeter +{ + [Scope("SingleInstance")] + public class EmeterHourEnergyRepository : BaseRepository + { + public EmeterHourEnergyRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + } + } +} diff --git a/Repository/Ammeter/EmeterMinutesEnergyRepository.cs b/Repository/Ammeter/EmeterMinutesEnergyRepository.cs new file mode 100644 index 0000000..11a6ffa --- /dev/null +++ b/Repository/Ammeter/EmeterMinutesEnergyRepository.cs @@ -0,0 +1,14 @@ +using Entity.Ammeter; +using HybirdFrameworkCore.Autofac.Attribute; +using SqlSugar; + +namespace Repository.Ammeter +{ + [Scope("SingleInstance")] + public class EmeterMinutesEnergyRepository : BaseRepository + { + public EmeterMinutesEnergyRepository(ISqlSugarClient sqlSugar) : base(sqlSugar) + { + } + } +} diff --git a/Service/Ammeter/EmeterDayEnergyService.cs b/Service/Ammeter/EmeterDayEnergyService.cs new file mode 100644 index 0000000..689e64f --- /dev/null +++ b/Service/Ammeter/EmeterDayEnergyService.cs @@ -0,0 +1,19 @@ +using Entity.Ammeter; +using HybirdFrameworkCore.Autofac.Attribute; +using Repository.Ammeter; + +namespace Service.Ammeter +{ + /// + /// + /// + [Scope("SingleInstance")] + public class EmeterDayEnergyService : BaseServices + { + private EmeterDayEnergyRepository _service; + public EmeterDayEnergyService(EmeterDayEnergyRepository service) + { + _service = service; + } + } +} diff --git a/Service/Ammeter/EmeterHourEnergyService.cs b/Service/Ammeter/EmeterHourEnergyService.cs new file mode 100644 index 0000000..4dba9f3 --- /dev/null +++ b/Service/Ammeter/EmeterHourEnergyService.cs @@ -0,0 +1,19 @@ +using Entity.Ammeter; +using HybirdFrameworkCore.Autofac.Attribute; +using Repository.Ammeter; + +namespace Service.Ammeter +{ + /// + /// + /// + [Scope("SingleInstance")] + public class EmeterHourEnergyService: BaseServices + { + private readonly EmeterHourEnergyRepository _service; + public EmeterHourEnergyService(EmeterHourEnergyRepository service) + { + _service = service; + } + } +} diff --git a/Service/Ammeter/EmeterMinutesEnergyService.cs b/Service/Ammeter/EmeterMinutesEnergyService.cs new file mode 100644 index 0000000..d5bfdb3 --- /dev/null +++ b/Service/Ammeter/EmeterMinutesEnergyService.cs @@ -0,0 +1,19 @@ +using Entity.Ammeter; +using HybirdFrameworkCore.Autofac.Attribute; +using Repository.Ammeter; + +namespace Service.Ammeter +{ + /// + /// + /// + [Scope("SingleInstance")] + public class EmeterMinutesEnergyService: BaseServices + { + private readonly EmeterMinutesEnergyRepository _service; + public EmeterMinutesEnergyService(EmeterMinutesEnergyRepository service) + { + _service = service; + } + } +} diff --git a/Service/Cloud/Msg/Host/Req/ChargerDataReport.cs b/Service/Cloud/Msg/Host/Req/ChargerDataReport.cs new file mode 100644 index 0000000..8114c41 --- /dev/null +++ b/Service/Cloud/Msg/Host/Req/ChargerDataReport.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Service.Cloud.Msg.Host.Req +{ + /// + /// 4.2.10.1 换电站充电机数据上报 + /// + public class ChargerDataReport + { + + } +} diff --git a/Service/Service.csproj b/Service/Service.csproj index 7f81982..307d034 100644 --- a/Service/Service.csproj +++ b/Service/Service.csproj @@ -16,16 +16,16 @@ - - - - - - - + + + + + + + - + diff --git a/WebStarter/Controllers/Ammeter/AmmeterController.cs b/WebStarter/Controllers/Ammeter/AmmeterController.cs new file mode 100644 index 0000000..af54732 --- /dev/null +++ b/WebStarter/Controllers/Ammeter/AmmeterController.cs @@ -0,0 +1,132 @@ +using Autofac; +using Entity.Ammeter; +using Entity.DbModel; +using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Entity; +using Microsoft.AspNetCore.Mvc; +using Repository.Station; +using Service.Ammeter; +using Service.System; +using System.Collections.Generic; + +namespace WebStarter.Controllers.Ammeter +{ + [ApiController] + [Route("[controller]")] + public class AmmeterController : Controller + { + private EmeterDayEnergyService _emeterDay; + private EmeterHourEnergyService _emeterHour; + private EmeterMinutesEnergyService _emeterMin; + public AmmeterController(EmeterDayEnergyService emeterDay, EmeterHourEnergyService emeterHour, EmeterMinutesEnergyService emeterMin) + { + _emeterDay = emeterDay; + _emeterHour = emeterHour; + _emeterMin = emeterMin; + } + + /* + 统计分析/电能表累计值信息 y + 统计分析/电能表变化值信息 + 统计分析/电能表小时能耗值 y + 统计分析/电能表每天能耗值 y + 统计分析/换电站分时用电统计信息 + 统计分析/换电站每天用电统计信息 + 电能监控/交流电能监控 + 电能监控/直流电能监控 + */ + + #region 统计分析/电能表累计值信息 + + /// + /// 统计分析/电能表累计值信息 + /// + [HttpGet("TEgEmeterTotalEnergyValue")] + public async Task>> GetNewEmeterMinutesEnergy() + { + + return Result>.Success(await _emeterMin.SqlQueryable("SELECT t1.* \r\nFROM ( \r\n SELECT code, MAX(time) AS latest_time \r\n FROM emeter_minutes_energy \r\n GROUP BY code \r\n) AS latest_records \r\nJOIN emeter_minutes_energy t1 ON latest_records.code = t1.code AND latest_records.latest_time = t1.time;")); + } + + ///// + ///// 统计分析/电能表变化值信息 + ///// + //[HttpGet("TEgEmeterTotalEnergyValue{id}")] + //public Result> DeleteOneEmeterMinutesEnergy(long id) + //{ + // return Result>.Success(_emeterMin.QueryListByClause(i => i.Mn == code)); + //} + ///// + ///// 统计分析/电能表变化值信息 + ///// + //[HttpGet("/TEgEmeterTotalEnergyValue/BatchDelete")] + //public Result> DeleteMoreEmeterMinutesEnergy(int[] ids) + //{ + // return Result>.Success(_emeterMin.QueryListByClause(i => i.Mn == code)); + //} + + #endregion + + #region 统计分析/电能表小时能耗值 + /// + /// 统计分析/电能表变化值信息 + /// + [HttpGet("TEgEmeterHourEnergyValue")] + public Result> GetEmeterHourEnergy() + { + return Result>.Success(_emeterHour.Query()); + } + + /// + /// 小时--删除 + /// + [HttpGet("TEgEmeterTotalEnergyValue{id}")] + public Result DeleteEmeterHourEnergy(long id) + { + return Result.Success(_emeterHour.DeleteById(id)); + } + /// + /// 小时--批量删除 + /// + [HttpGet("TEgEmeterTotalEnergyValue/BatchDelete")] + public Result DeleteListEmeterHourEnergy(int[] ids) + { + return Result.Success(_emeterHour.DeleteByIds(ids)); + } + #endregion + + #region 统计分析/电能表每天能耗值 + /// + /// 统计分析/电能表变化值信息 + /// + [HttpGet("TEgEmeterHourEnergyValue")] + public Result> GetEmeterDayEnergy() + { + return Result>.Success(_emeterDay.Query()); + } + + /// + /// 小时--删除 + /// + [HttpGet("TEgEmeterTotalEnergyValue{id}")] + public Result DeleteEmeterDayEnergy(long id) + { + return Result.Success(_emeterDay.DeleteById(id)); + } + /// + /// 小时--批量删除 + /// + [HttpGet("TEgEmeterTotalEnergyValue/BatchDelete")] + public Result DeleteListEmeterDayEnergy(int[] ids) + { + return Result.Success(_emeterDay.DeleteByIds(ids)); + } + #endregion + + #region 统计分析/电能表变化值信息 + + #endregion + + + } +}