using Entity.Ammeter;
using Entity.Dto.Req;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Ammeter;
using Service.Station;
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/{Code}")]
public async Task>> GetNewEmeterMinutesEnergy(string Code)
{
return Result>.Success(await _emeterMinutesEnergyService.SqlQueryable(
"SELECT t1.* \r\n" +
"FROM " +"( \r\n SELECT code, MAX(time) AS latest_time \r\n " +
"FROM emeter_minutes_energy \r\n"+" Where code==" + Code+"+ 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));
}
///
/// 删除电能表累计值信息
///
[HttpPost("TEgEmeterTotalEnergyValue/BatchDelete")]
public Result DeleteMoreEmeterMinutesEnergy(int[] ids)
{
return Result.Success(_emeterMinutesEnergyService.DeleteByIds(ids));
}
#endregion
#region 统计分析/电能表变化值信息
///
/// 统计分析/电能表变化值信息
///
[HttpPost("TEgEmeterRealEnergyValue")]
public async Task> GetEmeterMinutesEnergyChange([FromBody] PageAmmeterReq queryPageModel)
{
return await _emeterMinutesEnergyChangeService.Page(queryPageModel);
}
///
/// 删除电能表变化值信息
///
[HttpGet("TEgEmeterRealEnergyValue/{id}")]
public Result DeleteEmeterMinutesEnergyChange(long id)
{
return Result.Success(_emeterMinutesEnergyChangeService.DeleteById(id));
}
///
/// 批量删除电能表变化值信息
///
[HttpPost("TEgEmeterRealEnergyValue/BatchDelete")]
public Result DeleteEmeterMinutesEnergyChange(int[] ids)
{
return Result.Success(_emeterMinutesEnergyChangeService.DeleteByIds(ids));
}
#endregion
#region 统计分析/电能表小时能耗值
///
/// 统计分析/电能表小时能耗值
///
[HttpPost("TEgEmeterHourEnergyValue")]
public async Task> GetEmeterHourEnergy([FromBody] PageAmmeterReq queryPageModel)
{
return await _emeterHourEnergyService.Page(queryPageModel);
}
///
/// 删除电能表小时能耗值
///
[HttpGet("TEgEmeterHourEnergyValue/{id}")]
public Result DeleteEmeterHourEnergy(long id)
{
return Result.Success(_emeterHourEnergyService.DeleteById(id));
}
///
/// 批量删除电能表小时能耗值
///
[HttpPost("TEgEmeterHourEnergyValue/BatchDelete")]
public Result DeleteListEmeterHourEnergy(int[] ids)
{
return Result.Success(_emeterHourEnergyService.DeleteByIds(ids));
}
#endregion
#region 统计分析/电能表每天能耗值
///
/// 统计分析/电能表每天能耗值
///
[HttpPost("TEgEmeterDayEnergyValue")]
public async Task> GetEmeterDayEnergy([FromBody] PageAmmeterReq queryPageModel)
{
return await _emeterDayEnergyService.Page(queryPageModel);
}
///
/// 删除电能表每天能耗值
///
[HttpGet("TEgEmeterDayEnergyValue/{id}")]
public Result DeleteEmeterDayEnergy(long id)
{
return Result.Success(_emeterDayEnergyService.DeleteById(id));
}
///
/// 批量删除电能表每天能耗值
///
[HttpPost("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);
}
//TODO::过滤,确保编码相同只出现一次
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);
}
//TODO::过滤,确保编码相同只出现一次
return Result>.Success(_emeterMinutesEnergyService.QueryListByClause(i => strings.Contains(i.Code)).ToList());
}
#endregion
}
}