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