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.Station;
using Service.System;
using System.Collections.Generic;
namespace WebStarter.Controllers.Ammeter
{
///
/// 查询电表信息
///
[ApiController]
[Route("api/[controller]")]
public class AmmeterController : ControllerBase
{
private EmeterDayEnergyService _emeterDayEnergyService;
private EmeterHourEnergyService _emeterHourEnergyService;
private EmeterMinutesEnergyService _emeterMinutesEnergyService;
private EmeterMinutesEnergyChangeService _emeterMinutesEnergyChangeService;
private EquipInfoService _equipInfoService;
///
/// 查询电表信息
///
///
///
///
///
///
public AmmeterController(EmeterDayEnergyService emeterDayEnergyService, EmeterHourEnergyService emeterHourEnergyService,
EmeterMinutesEnergyService emeterMinutesEnergyService, EmeterMinutesEnergyChangeService emeterMinutesEnergyChangeService,
EquipInfoService equipInfoService)
{
_emeterDayEnergyService = emeterDayEnergyService;
_emeterHourEnergyService = emeterHourEnergyService;
_emeterMinutesEnergyService = emeterMinutesEnergyService;
_emeterMinutesEnergyChangeService = emeterMinutesEnergyChangeService;
_equipInfoService = equipInfoService;
}
#region 统计分析/电能表累计值信息
///
/// 统计分析/电能表累计值信息
///
[HttpGet("TEgEmeterTotalEnergyValue")]
public async Task>> GetNewEmeterMinutesEnergy()
{
return Result>.Success(await _emeterMinutesEnergyService.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(_emeterMinutesEnergyService.DeleteById(id));
}
///
/// 删除电能表累计值信息
///
[HttpGet("TEgEmeterTotalEnergyValue/BatchDelete")]
public Result DeleteMoreEmeterMinutesEnergy(int[] ids)
{
return Result.Success(_emeterMinutesEnergyService.DeleteByIds(ids));
}
#endregion
#region 统计分析/电能表变化值信息
///
/// 统计分析/电能表变化值信息
///
[HttpGet("TEgEmeterRealEnergyValue")]
public Result> GetEmeterMinutesEnergyChange()
{
return Result>.Success(_emeterMinutesEnergyChangeService.Query());
}
///
/// 删除电能表变化值信息
///
[HttpGet("TEgEmeterRealEnergyValue{id}")]
public Result DeleteEmeterMinutesEnergyChange(long id)
{
return Result.Success(_emeterMinutesEnergyChangeService.DeleteById(id));
}
///
/// 批量删除电能表变化值信息
///
[HttpGet("TEgEmeterRealEnergyValue/BatchDelete")]
public Result DeleteEmeterMinutesEnergyChange(int[] ids)
{
return Result.Success(_emeterMinutesEnergyChangeService.DeleteByIds(ids));
}
#endregion
#region 统计分析/电能表小时能耗值
///
/// 统计分析/电能表小时能耗值
///
[HttpGet("TEgEmeterHourEnergyValue")]
public Result> GetEmeterHourEnergy()
{
return Result>.Success(_emeterHourEnergyService.Query());
}
///
/// 删除电能表小时能耗值
///
[HttpGet("TEgEmeterHourEnergyValue{id}")]
public Result DeleteEmeterHourEnergy(long id)
{
return Result.Success(_emeterHourEnergyService.DeleteById(id));
}
///
/// 批量删除电能表小时能耗值
///
[HttpGet("TEgEmeterHourEnergyValue/BatchDelete")]
public Result DeleteListEmeterHourEnergy(int[] ids)
{
return Result.Success(_emeterHourEnergyService.DeleteByIds(ids));
}
#endregion
#region 统计分析/电能表每天能耗值
///
/// 统计分析/电能表每天能耗值
///
[HttpGet("TEgEmeterDayEnergyValue")]
public Result> GetEmeterDayEnergy()
{
return Result>.Success(_emeterDayEnergyService.Query());
}
///
/// 删除电能表每天能耗值
///
[HttpGet("TEgEmeterDayEnergyValue{id}")]
public Result DeleteEmeterDayEnergy(long id)
{
return Result.Success(_emeterDayEnergyService.DeleteById(id));
}
///
/// 批量删除电能表每天能耗值
///
[HttpGet("TEgEmeterDayEnergyValue/BatchDelete")]
public Result DeleteListEmeterDayEnergy(int[] ids)
{
return Result.Success(_emeterDayEnergyService.DeleteByIds(ids));
}
#endregion
#region 统计分析/换电站分时用电统计信息
//TODO::
//小时计算总能耗值,小时计算充电能耗值,小时计算换电能耗值,小时计算其他能耗值,开始时间,结束时间
#endregion
#region 统计分析/换电站每天用电统计信息
//TODO::
//每天计算总能耗值,每天计算充电能耗值,每天计算换电能耗值,每天计算其他能耗值,开始时间,结束时间
#endregion
#region 电能监控/交流电能监控
///
/// 电能监控/交流电能监控
///
[HttpGet("ElecMeterParam/GetElecMeterParamValue")]
public Result> GetElecMeterParamValue()
{
var EquipInfo = _equipInfoService.QueryListByClause(i => i.TypeCode == 0);
List strings = new List();
foreach (var kvp in EquipInfo)
{
strings.Add(kvp.Code);
}
return Result>.Success(_emeterMinutesEnergyService.QueryListByClause(i => strings.Contains(i.Code)).ToList());
}
#endregion
#region 电能监控/直流电能监控
///
/// 电能监控/交流电能监控
///
[HttpGet("ManualSwap/GetDcCurrentInfo")]
public Result> GetDcCurrentInfo()
{
var EquipInfo = _equipInfoService.QueryListByClause(i => i.TypeCode == 1);
List strings = new List();
foreach (var kvp in EquipInfo)
{
strings.Add(kvp.Code);
}
return Result>.Success(_emeterMinutesEnergyService.QueryListByClause(i => strings.Contains(i.Code)).ToList());
}
#endregion
}
}