using Microsoft.AspNetCore.Mvc;
|
using System.Net;
|
using System.Net.Http.Headers;
|
using Microsoft.Extensions.Hosting.Internal;
|
using Microsoft.AspNetCore.Http.Extensions;
|
using IStation.Untity;
|
using Furion.DynamicApiController;
|
using System.ComponentModel.DataAnnotations;
|
using Mapster;
|
|
|
|
namespace IStation.Application
|
{
|
/// <summary>
|
/// EtaAnalyDeviation
|
/// </summary>
|
[Route("Eta/Analy/Deviation")]
|
[ApiDescriptionSettings("Eta", Name = "能效偏差分析", Order = 900)]
|
public class EtaAnalyDeviation_Controller : IDynamicApiController
|
{
|
/// <summary>
|
/// 通过 PipeLineID 获取某日偏差内容记录
|
/// </summary>
|
[Route("GetContentByPipeLineIDOfDay@V1.0")]
|
[HttpGet]
|
public List<EtaDeviationDayContent> GetContentByPipeLineIDOfDay
|
(
|
[Required, Range(1, long.MaxValue, ErrorMessage = "CorpID 必须大于0")]
|
long CorpID,
|
[Required, Range(1, long.MaxValue, ErrorMessage = "PipeLineID 必须大于0")]
|
long PipeLineID,
|
[Required]
|
DateTime Day
|
)
|
{
|
var pipeLine = new Service.PipeLine().GetByID(CorpID, PipeLineID);
|
if (pipeLine == null)
|
{
|
throw new Exception("未检索到管路信息");
|
}
|
if (pipeLine.Catalog != IStation.PipeLine.EnginePump)
|
{
|
throw new Exception("未检索到机泵管路信息");
|
}
|
var bindingList = new Service.PipeLineBinding().GetUseByPipeLineID(CorpID, PipeLineID);
|
if (bindingList == null || bindingList.Count < 1)
|
{
|
throw new Exception("未设置管路绑定");
|
}
|
bindingList = bindingList.Where(x => x.BindingType == IStation.ObjectType.Product).ToList();
|
if (bindingList.Count < 1)
|
{
|
throw new Exception("未绑定设备信息");
|
}
|
var productList = new Service.Product().GetByIds(CorpID, bindingList.Select(x => x.BindingID).ToList());
|
if (productList == null || productList.Count < 1)
|
{
|
throw new Exception("未检索到设备信息");
|
}
|
var product = productList.Find(x => x.Catalog == IStation.Product.Catalog_JiBeng);
|
if (product == null)
|
{
|
throw new Exception("未检索到机泵信息");
|
}
|
var pump = new Service.Product().GetChildPumpByEnginePumpID(product.CorpID, product.ID);
|
if (pump == null)
|
{
|
throw new Exception("未检索到泵信息");
|
}
|
var curve = new Service.PumpCurveExMapping().GetDefaultWorkingByPumpID(pump.CorpID, pump.ID);
|
if (curve == null)
|
{
|
throw new Exception("未检索到泵曲线信息");
|
}
|
|
var vmList = new List<EtaDeviationDayContent>();
|
var recordList = new Service.EtaSingleRealRecord().GetRunByObjectOfDay(CorpID, ObjectType.PipeLine, PipeLineID, Day);
|
recordList = recordList?.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList();
|
if (recordList != null && recordList.Count > 0)
|
{
|
foreach (var record in recordList)
|
{
|
var vm = new EtaDeviationDayContent();
|
vm.Time = record.DataTime.ToString("HH:mm:ss");
|
vm.HZr = record.HZa;//新增字段 nsx
|
|
vm.Qr = Math.Round(record.Qa.Value, 2);
|
vm.Hr = Math.Round(record.Ha.Value, 2);
|
vm.Er = Math.Round(record.Ea.Value, 2);
|
vm.Pr = Math.Round(record.Pa.Value, 2);
|
|
if (record.HZa < 49 && record.HZa > 10)
|
{
|
//得到相似换算值
|
double ratio = 50 / record.HZa;
|
vm.Q = Math.Round(record.Qa.Value * ratio, 2);
|
vm.H = Math.Round(record.Ha.Value * ratio * ratio, 2);
|
vm.E = Math.Round(record.Ea.Value, 2);
|
vm.P = Math.Round(record.Pa.Value * ratio * ratio * ratio, 2);
|
}
|
else
|
{
|
vm.Q = Math.Round(record.Qa.Value, 2);
|
vm.H = Math.Round(record.Ha.Value, 2);
|
vm.E = Math.Round(record.Ea.Value, 2);
|
vm.P = Math.Round(record.Pa.Value, 2);
|
}
|
|
double h_rated = curve.CurveInfo.CurveQH.GetFitPointY(vm.Q);
|
double eta_rated = curve.CurveInfo.CurveQE.GetFitPointY(vm.Q);
|
double power_rated = curve.CurveInfo.CurveQP.GetFitPointY(vm.Q);
|
|
vm.DeviateH = (vm.H - h_rated).ToString("0.0");//扬程偏差
|
vm.DeviateE = (vm.E - eta_rated).ToString("0.0");//效率偏差
|
vm.DeviateP = (vm.P - power_rated).ToString("0.0");//功率偏差
|
|
vm.DeviateRatioH = ((vm.H - h_rated) * 100 / h_rated).ToString("0.0");//扬程偏差率
|
vm.DeviateRatioP = ((vm.P - power_rated) * 100 / power_rated).ToString("0.0");//功率偏差率
|
vmList.Add(vm);
|
}
|
|
}
|
|
return vmList;
|
}
|
|
}
|
}
|