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.

215 lines
7.7 KiB

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