电表部分

master
CZ 6 months ago
parent 920d8ecdd9
commit e8137456c9

@ -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
{
/// <summary>
/// 电表按天上传数据
/// </summary>
[SugarTable("emeter_day_energy")]
public partial class EmeterDayEnergy
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public long Id { get; set; }
/// <summary>
/// 电表编码
/// </summary>
[SugarColumn(ColumnName = "code")]
public string Mn { get; set; }
/// <summary>
/// 天变化值 千瓦时
/// </summary>
[SugarColumn(ColumnName = "value")]
public float Dv { get; set; }
/// <summary>
/// 时间
/// </summary>
[SugarColumn(ColumnName = "st")]
public DateTime St { get; set; }
/// <summary>
/// 时间
/// </summary>
[SugarColumn(ColumnName = "et")]
public DateTime Et { get; set; }
}
}

@ -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
{
/// <summary>
/// 电表一小时统计一次数据
/// </summary>
[SugarTable("emeter_hour_energy")]
public partial class EmeterHourEnergy
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public long Id { get; set; }
/// <summary>
/// 电表编码
/// </summary>
[SugarColumn(ColumnName = "code")]
public string Mn { get; set; }
/// <summary>
/// 小时变化值 千瓦时
/// </summary>
[SugarColumn(ColumnName = "value")]
public float Hv { get; set; }
/// <summary>
/// 时间
/// </summary>
[SugarColumn(ColumnName = "st")]
public DateTime St { get; set; }
/// <summary>
/// 时间
/// </summary>
[SugarColumn(ColumnName = "et")]
public DateTime Et { get; set; }
}
}

@ -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
{
/// <summary>
/// 电表15分钟保存一次数据
/// </summary>
[SugarTable("emeter_minutes_energy")]
public partial class EmeterMinutesEnergy
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
public long Id { get; set; }
/// <summary>
/// 电表编码
/// </summary>
[SugarColumn(ColumnName = "code")]
public string Mn { get; set; }
/// <summary>
/// 千瓦时
/// </summary>
[SugarColumn(ColumnName = "value")]
public float Value { get; set; }
/// <summary>
/// 时间
/// </summary>
[SugarColumn(ColumnName = "time")]
public DateTime Time { get; set; }
}
}

@ -0,0 +1,15 @@

using Entity.Ammeter;
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
namespace Repository.Ammeter
{
[Scope("SingleInstance")]
public class EmeterDayEnergyRepository : BaseRepository<EmeterDayEnergy>
{
public EmeterDayEnergyRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
}
}

@ -0,0 +1,15 @@

using Entity.Ammeter;
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
namespace Repository.Ammeter
{
[Scope("SingleInstance")]
public class EmeterHourEnergyRepository : BaseRepository<EmeterHourEnergy>
{
public EmeterHourEnergyRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
}
}

@ -0,0 +1,14 @@
using Entity.Ammeter;
using HybirdFrameworkCore.Autofac.Attribute;
using SqlSugar;
namespace Repository.Ammeter
{
[Scope("SingleInstance")]
public class EmeterMinutesEnergyRepository : BaseRepository<EmeterMinutesEnergy>
{
public EmeterMinutesEnergyRepository(ISqlSugarClient sqlSugar) : base(sqlSugar)
{
}
}
}

@ -0,0 +1,19 @@
using Entity.Ammeter;
using HybirdFrameworkCore.Autofac.Attribute;
using Repository.Ammeter;
namespace Service.Ammeter
{
/// <summary>
///
/// </summary>
[Scope("SingleInstance")]
public class EmeterDayEnergyService : BaseServices<EmeterDayEnergy>
{
private EmeterDayEnergyRepository _service;
public EmeterDayEnergyService(EmeterDayEnergyRepository service)
{
_service = service;
}
}
}

@ -0,0 +1,19 @@
using Entity.Ammeter;
using HybirdFrameworkCore.Autofac.Attribute;
using Repository.Ammeter;
namespace Service.Ammeter
{
/// <summary>
///
/// </summary>
[Scope("SingleInstance")]
public class EmeterHourEnergyService: BaseServices<EmeterHourEnergy>
{
private readonly EmeterHourEnergyRepository _service;
public EmeterHourEnergyService(EmeterHourEnergyRepository service)
{
_service = service;
}
}
}

@ -0,0 +1,19 @@
using Entity.Ammeter;
using HybirdFrameworkCore.Autofac.Attribute;
using Repository.Ammeter;
namespace Service.Ammeter
{
/// <summary>
///
/// </summary>
[Scope("SingleInstance")]
public class EmeterMinutesEnergyService: BaseServices<EmeterMinutesEnergy>
{
private readonly EmeterMinutesEnergyRepository _service;
public EmeterMinutesEnergyService(EmeterMinutesEnergyRepository service)
{
_service = service;
}
}
}

@ -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
{
/// <summary>
/// 4.2.10.1 换电站充电机数据上报
/// </summary>
public class ChargerDataReport
{
}
}

@ -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 统计分析/电能表累计值信息
/// <summary>
/// 统计分析/电能表累计值信息
/// </summary>
[HttpGet("TEgEmeterTotalEnergyValue")]
public async Task<Result<List<EmeterMinutesEnergy>>> GetNewEmeterMinutesEnergy()
{
return Result<List<EmeterMinutesEnergy>>.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;"));
}
///// <summary>
///// 统计分析/电能表变化值信息
///// </summary>
//[HttpGet("TEgEmeterTotalEnergyValue{id}")]
//public Result<List<EmeterMinutesEnergy>> DeleteOneEmeterMinutesEnergy(long id)
//{
// return Result<List<EmeterMinutesEnergy>>.Success(_emeterMin.QueryListByClause(i => i.Mn == code));
//}
///// <summary>
///// 统计分析/电能表变化值信息
///// </summary>
//[HttpGet("/TEgEmeterTotalEnergyValue/BatchDelete")]
//public Result<List<EmeterMinutesEnergy>> DeleteMoreEmeterMinutesEnergy(int[] ids)
//{
// return Result<List<EmeterMinutesEnergy>>.Success(_emeterMin.QueryListByClause(i => i.Mn == code));
//}
#endregion
#region 统计分析/电能表小时能耗值
/// <summary>
/// 统计分析/电能表变化值信息
/// </summary>
[HttpGet("TEgEmeterHourEnergyValue")]
public Result<List<EmeterHourEnergy>> GetEmeterHourEnergy()
{
return Result<List<EmeterHourEnergy>>.Success(_emeterHour.Query());
}
/// <summary>
/// 小时--删除
/// </summary>
[HttpGet("TEgEmeterTotalEnergyValue{id}")]
public Result<bool> DeleteEmeterHourEnergy(long id)
{
return Result<bool>.Success(_emeterHour.DeleteById(id));
}
/// <summary>
/// 小时--批量删除
/// </summary>
[HttpGet("TEgEmeterTotalEnergyValue/BatchDelete")]
public Result<bool> DeleteListEmeterHourEnergy(int[] ids)
{
return Result<bool>.Success(_emeterHour.DeleteByIds(ids));
}
#endregion
#region 统计分析/电能表每天能耗值
/// <summary>
/// 统计分析/电能表变化值信息
/// </summary>
[HttpGet("TEgEmeterHourEnergyValue")]
public Result<List<EmeterDayEnergy>> GetEmeterDayEnergy()
{
return Result<List<EmeterDayEnergy>>.Success(_emeterDay.Query());
}
/// <summary>
/// 小时--删除
/// </summary>
[HttpGet("TEgEmeterTotalEnergyValue{id}")]
public Result<bool> DeleteEmeterDayEnergy(long id)
{
return Result<bool>.Success(_emeterDay.DeleteById(id));
}
/// <summary>
/// 小时--批量删除
/// </summary>
[HttpGet("TEgEmeterTotalEnergyValue/BatchDelete")]
public Result<bool> DeleteListEmeterDayEnergy(int[] ids)
{
return Result<bool>.Success(_emeterDay.DeleteByIds(ids));
}
#endregion
#region 统计分析/电能表变化值信息
#endregion
}
}
Loading…
Cancel
Save