You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
4.6 KiB

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
}
}