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>
|
/// 节能改造
|
/// </summary>
|
[Route("Eta/Analy/Reform")]
|
[ApiDescriptionSettings("Eta", Name = "节能改造", Order = 598)]
|
public class EtaAnalyReform_Controller : IDynamicApiController
|
{
|
/// <summary>
|
/// 获取泵站下面机泵(含曲线信息):能效专用
|
/// </summary>
|
/// <param name="CorpID"></param>
|
/// <param name="StationID"></param>
|
/// <returns></returns>
|
[Route("GetMachineByStationID@V1.0")]
|
[HttpGet]
|
public List<Dto.MachineBaseItem4Reform> GetMachineByStationID(long CorpID,long StationID)
|
{
|
if (CorpID < 1)
|
{
|
throw new Exception("CorpID大于0");
|
}
|
|
if (StationID < 1)
|
{
|
throw new Exception("StationID大于0");
|
}
|
|
var cacheKey = $"MachineList4EnergyAna_{CorpID}_Station_{StationID}";
|
var vm_list = MemoryCacheHelper.GetSet<List<Dto.MachineBaseItem4Reform>>(cacheKey, () =>
|
{
|
List<Dto.MachineBaseItem4Reform> vm_cache_list = new List<Dto.MachineBaseItem4Reform>();
|
//获取机泵列表
|
var enginePumplist = new Service.Product().GetEnginePumpListByBelongTypeAndBelongID(CorpID,ObjectType.Station,StationID);
|
foreach (var enginePump in enginePumplist)
|
{
|
var pump = new Service.Product().GetChildPumpByEnginePumpID(CorpID,enginePump.ID);
|
if (pump == null)
|
continue;
|
|
var curve = new Service.PumpCurveExMapping().GetDefaultWorkingByPumpID(CorpID,pump.ID);
|
|
|
if (curve == null || curve.CurveInfo == null || curve.CurveInfo.CurveQH == null)
|
continue;
|
|
var vm_cache = new Dto.MachineBaseItem4Reform();
|
//pipe_engine_pump, pump, property_list, curve);
|
vm_cache.MachineID = enginePump.ID;
|
vm_cache.MachineName = enginePump.Name;
|
|
vm_cache.PumpID = pump.ID;
|
vm_cache.CurveID = curve.ID;
|
|
vm_cache.PointsQH = IStation.Model.FitCurveHelper.GetFitPoints(curve.CurveInfo.CurveQH, 12);
|
vm_cache.PointsQE = IStation.Model.FitCurveHelper.GetFitPoints(curve.CurveInfo.CurveQE, 12);
|
vm_cache.PointsQP = IStation.Model.FitCurveHelper.GetFitPoints(curve.CurveInfo.CurveQP, 12);
|
|
if (pump.RatedParas != null)
|
{
|
vm_cache.RatedQ = pump.RatedParas.Q;
|
vm_cache.RatedH = pump.RatedParas.H;
|
vm_cache.RatedE = pump.RatedParas.E;
|
vm_cache.RatedP = pump.RatedParas.P;
|
|
vm_cache.Ratedn = pump.RatedParas.N;
|
vm_cache.IsFrequency = pump.RatedParas.IsFrequency;
|
vm_cache.IsSxp = pump.RatedParas.IsSxp;
|
}
|
|
vm_cache.WorkDayInYear = 200;// 每年工作天数(以后来源数据库)
|
vm_cache.WorkHourInDay = 5;//每天平均工作小时(以后来源数据库)
|
vm_cache.ElectricityFees = 1;//电费 (来源配置)
|
|
vm_cache.CurrentWorkFr = 0; //来源数据库( 最近一次的开机频率)
|
vm_cache.CurrentWorkPtQ = 0; //来源数据库( 最近一次的单泵开机流量)
|
vm_cache.CurrentWorkPtH = 0; //来源数据库( 最近一次的单泵开机扬程)
|
vm_cache.CurrentWorkPtE = 0; //来源数据库( 最近一次的单泵开机效率)
|
vm_cache.CurrentWorkPtP = 0; //来源数据库( 最近一次的单泵开机功率)
|
|
vm_cache_list.Add(vm_cache);
|
}
|
return vm_cache_list;
|
}, 12);
|
|
return new List<IStation.Dto.MachineBaseItem4Reform>(vm_list);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="AnaRequest"></param>
|
/// <returns></returns>
|
[Route("GetAnaResult@V1.0")]
|
[HttpPost]
|
public List<Dto.ReformAnaResultItem> GetAnaResult(IStation.Dto.ReformAnaRequest AnaRequest)
|
{
|
if (AnaRequest == null || AnaRequest.CorpID < 1)
|
{
|
throw new Exception("CorpID大于0");
|
}
|
if (AnaRequest.PumpID < 1)
|
{
|
throw new Exception("MachineID大于0");
|
}
|
if (AnaRequest.CurveID < 1)
|
{
|
throw new Exception("CurveID大于0");
|
}
|
var service_curve = new Service.PumpCurveExMapping();
|
var curves = service_curve.GetByCurveID(AnaRequest.CorpID, AnaRequest.CurveID);
|
if (curves == null)
|
{
|
throw new Exception("曲线还未设置");
|
}
|
var curve = curves.Find(x => x.PumpID == AnaRequest.PumpID);
|
if (curve == null || curve.CurveInfo == null || curve.CurveInfo.CurveQH == null)
|
{
|
throw new Exception("曲线还未设置");
|
}
|
|
var fit_point_h = IStation.Model.FitCurveHelper.GetFitPointY(curve.CurveInfo.CurveQH, AnaRequest.TargetQ);
|
|
#region 切割
|
|
var result_cut = new Dto.ReformAnaResultItem();
|
result_cut.Name = "叶轮切割";
|
result_cut.Type = 1;
|
result_cut.WorkPointQ = AnaRequest.TargetQ;
|
result_cut.WorkPointH = AnaRequest.TargetH;
|
result_cut.IsAble = false;
|
if (fit_point_h < AnaRequest.TargetH * 1.05)
|
{//切割 变频都不行
|
result_cut.Note = "当前水泵,无法通过切割的方式,达到理想工况点";
|
result_cut.IsAble = false;
|
}
|
else
|
{
|
double OriginD2 = 100;//计算的是百分率
|
double wrk_d2 = IStation.Common.CutSimuCalculer.GetSimuValue(curve.CurveInfo.CurveQH,
|
new IStation.Model.CurvePoint(AnaRequest.TargetQ, AnaRequest.TargetH), OriginD2, 1.05);
|
|
if (wrk_d2 > 30)
|
{
|
var CurveExpressQH = IStation.Common.CutSimuCalculer.GetSimuPointQH(curve.CurveInfo.CurveQH, OriginD2, wrk_d2);
|
var CurveExpressQE = IStation.Common.CutSimuCalculer.GetSimuPointQE(curve.CurveInfo.CurveQE, OriginD2, wrk_d2);
|
var CurveExpressQP = IStation.Common.CutSimuCalculer.GetSimuPointQP(curve.CurveInfo.CurveQP, OriginD2, wrk_d2);
|
|
result_cut.PointsQH = IStation.Model.FitCurveHelper.GetFitPoints(CurveExpressQH, 12);
|
result_cut.PointsQE = IStation.Model.FitCurveHelper.GetFitPoints(CurveExpressQE, 12);
|
result_cut.PointsQP = IStation.Model.FitCurveHelper.GetFitPoints(CurveExpressQP, 12);
|
|
result_cut.Note = string.Format("切割率 {0:0.0}% ", (1 - wrk_d2 / OriginD2) * 100);
|
|
result_cut.WorkPointE = Math.Round(IStation.Model.FitCurveHelper.GetFitPointY(CurveExpressQE, result_cut.WorkPointQ), 2);
|
result_cut.WorkPointP = Math.Round(IStation.Model.FitCurveHelper.GetFitPointY(CurveExpressQP, result_cut.WorkPointQ), 1);
|
|
result_cut.IsAble = true;
|
result_cut.PerDayPower = Math.Round(result_cut.WorkPointP.Value * AnaRequest.WorkHourInDay, 0);
|
result_cut.PerYearPower = result_cut.PerDayPower * AnaRequest.WorkDayInYear;
|
result_cut.PerYearCost = result_cut.PerYearPower * AnaRequest.ElectricityFees;
|
}
|
else
|
{
|
result_cut.Note = "当前水泵,无法通过切割的方式,达到理想工况点";
|
result_cut.IsAble = false;
|
}
|
}
|
|
|
#endregion
|
|
|
#region 变频
|
var result_speed = new Dto.ReformAnaResultItem();
|
result_speed.Name = "电机变频";
|
result_speed.WorkPointQ = AnaRequest.TargetQ;
|
result_speed.WorkPointH = AnaRequest.TargetH;
|
result_speed.IsAble = false;
|
result_speed.Type = 2;
|
if (fit_point_h < AnaRequest.TargetH * 1.05)
|
{//切割 变频都不行
|
result_speed.Note = "当前水泵,无法通过变频的方式,达到理想工况点";
|
result_speed.IsAble = false;
|
}
|
else
|
{
|
double wrk_hz = IStation.Common.SpeedSimuCalculer.GetSimuValue(curve.CurveInfo.CurveQH,
|
new IStation.Model.CurvePoint(AnaRequest.TargetQ, AnaRequest.TargetH), 50, 1.05);
|
|
if (wrk_hz > 10)
|
{
|
var CurveExpressQH = IStation.Common.SpeedSimuCalculer.GetSimuPointQH(curve.CurveInfo.CurveQH, 50, wrk_hz);
|
var CurveExpressQE = IStation.Common.SpeedSimuCalculer.GetSimuPointQE(curve.CurveInfo.CurveQE, 50, wrk_hz);
|
var CurveExpressQP = IStation.Common.SpeedSimuCalculer.GetSimuPointQP(curve.CurveInfo.CurveQP, 50, wrk_hz);
|
|
result_speed.PointsQH = IStation.Model.FitCurveHelper.GetFitPoints(CurveExpressQH, 12);
|
result_speed.PointsQE = IStation.Model.FitCurveHelper.GetFitPoints(CurveExpressQE, 12);
|
result_speed.PointsQP = IStation.Model.FitCurveHelper.GetFitPoints(CurveExpressQP, 12);
|
|
result_speed.Note = string.Format("变频{0:0.0}HZ ", wrk_hz);
|
|
result_speed.WorkPointE = Math.Round(IStation.Model.FitCurveHelper.GetFitPointY(CurveExpressQE, result_speed.WorkPointQ), 2);
|
result_speed.WorkPointP = Math.Round(IStation.Model.FitCurveHelper.GetFitPointY(CurveExpressQP, result_speed.WorkPointQ), 1);
|
result_speed.IsAble = true;
|
|
result_speed.PerDayPower = Math.Round(result_speed.WorkPointP.Value * AnaRequest.WorkHourInDay, 0);
|
result_speed.PerYearPower = result_speed.PerDayPower * AnaRequest.WorkDayInYear;
|
result_speed.PerYearCost = result_speed.PerYearPower * AnaRequest.ElectricityFees;
|
}
|
else
|
{
|
result_speed.Note = "当前水泵,无法通过变频的方式,达到理想工况点";
|
result_speed.IsAble = false;
|
}
|
}
|
|
|
#endregion
|
|
|
|
|
#region 替换
|
var service_product = new Service.Product();
|
var pump = service_product.GetChildPumpByEnginePumpID(AnaRequest.CorpID, AnaRequest.MachineID);
|
if (pump == null)
|
{
|
throw new Exception("机泵未找到");
|
}
|
IStation.Model.GroupPoint theRepRatedParas = new IStation.Model.GroupPoint();
|
theRepRatedParas.Q = AnaRequest.TargetQ;
|
theRepRatedParas.H = AnaRequest.TargetH;
|
theRepRatedParas.E = 90;
|
if (pump.RatedParas.E > 0)
|
theRepRatedParas.E = pump.RatedParas.E;
|
theRepRatedParas.P = IStation.Common.PumpParaHelper.CalculateP(theRepRatedParas.Q, theRepRatedParas.H, theRepRatedParas.E);
|
|
|
List<IStation.Model.CurvePoint> pointsQH_replace = null;
|
List<IStation.Model.CurvePoint> pointsQE_replace = null;
|
List<IStation.Model.CurvePoint> pointsQP_replace = null;
|
List<IStation.Model.CurvePoint> pointsNPSH_replace = null;
|
|
double ratedn = 960;
|
if (pump.RatedParas.N > 0)
|
ratedn = pump.RatedParas.N;
|
else
|
{
|
var motor = service_product.GetChildMotorByEnginePumpID(AnaRequest.CorpID, AnaRequest.MachineID);
|
if (motor != null && motor.RatedParas != null && motor.RatedParas.N > 10)
|
{
|
ratedn = motor.RatedParas.N;
|
}
|
}
|
|
var RET = IStation.Common.DimensionlessCurvesHelper.CalcPoints(theRepRatedParas, ratedn,
|
ref pointsQH_replace, ref pointsQE_replace, ref pointsQP_replace, ref pointsNPSH_replace, pump.RatedParas.IsSxp, 1);
|
|
|
var result_replace = new Dto.ReformAnaResultItem();
|
result_replace.Name = "换叶轮/换泵";
|
result_replace.IsAble = true;
|
result_replace.Type = 3;
|
|
result_replace.WorkPointQ = AnaRequest.TargetQ;
|
result_replace.WorkPointH = AnaRequest.TargetH;
|
result_replace.PointsQH = pointsQH_replace;
|
result_replace.PointsQE = pointsQE_replace;
|
result_replace.PointsQP = pointsQP_replace;
|
result_replace.Note = "";
|
result_replace.WorkPointE = Math.Round(IStation.Model.FitCurveHelper.GetFitPointY(pointsQE_replace, result_replace.WorkPointQ), 2);
|
result_replace.WorkPointP = Math.Round(IStation.Model.FitCurveHelper.GetFitPointY(pointsQP_replace, result_replace.WorkPointQ), 1);
|
|
|
result_replace.PerDayPower = Math.Round(result_replace.WorkPointP.Value * AnaRequest.WorkHourInDay, 0);
|
result_replace.PerYearPower = result_replace.PerDayPower * AnaRequest.WorkDayInYear;
|
result_replace.PerYearCost = result_replace.PerYearPower * AnaRequest.ElectricityFees;
|
|
#endregion
|
|
|
var vm_list = new List<Dto.ReformAnaResultItem>();
|
vm_list.Add(result_cut);
|
vm_list.Add(result_speed);
|
vm_list.Add(result_replace);
|
|
foreach (var vm in vm_list)
|
{
|
if (vm.IsAble && vm.PerYearPower != null && vm.PerYearCost != null && AnaRequest.CurrentWorkPtP > 0)
|
{
|
var CurrentPerDayPower = Math.Round(AnaRequest.CurrentWorkPtP * AnaRequest.WorkHourInDay, 0);
|
var CurrentPerYearPower = CurrentPerDayPower * AnaRequest.WorkDayInYear;
|
var CurrentPerYearCost = CurrentPerYearPower * AnaRequest.ElectricityFees;
|
|
vm.SavePowerNumber = (CurrentPerYearPower - (double)vm.PerYearPower).ToString("N0");
|
vm.SavePowerCost = (CurrentPerYearCost - (double)vm.PerYearCost).ToString("N0");
|
|
vm.PerYearQ = Math.Round(vm.WorkPointQ * AnaRequest.WorkHourInDay * AnaRequest.WorkDayInYear, 0);
|
vm.CostPerM3 = Math.Round((double)vm.PerYearCost * 1000 / (double)vm.PerYearQ, 1).ToString();
|
}
|
else
|
{
|
vm.SavePowerNumber = "-";
|
vm.SavePowerCost = "-";
|
|
vm.PerYearQ = null;
|
vm.CostPerM3 = null;
|
}
|
}
|
|
|
return new List<Dto.ReformAnaResultItem>(vm_list);
|
}
|
|
}
|
}
|