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;
|
using System.Text;
|
using IStation.Calculation.Epanet;
|
|
namespace IStation.Application
|
{
|
/// <summary>
|
/// 调度分析(标准版,简易版)
|
/// </summary>
|
[Route("Dispatch/ParallelConnectAnaly/Std")]
|
[NonUnify]
|
[ApiDescriptionSettings("Eta", Name = "并联运行分析", Order = 595)]
|
public class ParallelConnect_StdController : IDynamicApiController
|
{
|
/// <summary>
|
/// 根据扬程计算并联后的流量
|
/// </summary>
|
/// <returns></returns>
|
[Route("CalcFlowByHead@V1.0")]
|
[HttpGet]
|
public IStation.Dto.ApiResult CalcFlowByHead(IStation.Dto.ParallelConnectCalcByHeadInput Request)
|
{
|
if (Request.CorpID <= 0)
|
{
|
return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Error, "CorpID为空");
|
}
|
if (Request.StationID <= 0)
|
{
|
return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Error, "StationID为空");
|
}
|
if (Request.Head <= 0)
|
{
|
return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Error, "Head为空");
|
}
|
IStation.Service.PumpCurve bllCurve = new IStation.Service.PumpCurve();
|
IStation.Service.Product bllProduct = new IStation.Service.Product();
|
|
|
|
List<IStation.Model.CurveExpress> curveListQH = new List<IStation.Model.CurveExpress>();
|
List<IStation.Model.CurveExpress> curveListQP = new List<IStation.Model.CurveExpress>();
|
double r_maxH = double.MaxValue, r_minH = double.MinValue;
|
List<IStation.Dto.DispatchAna.CurveItem> ParallelCurve = new List<IStation.Dto.DispatchAna.CurveItem>();
|
|
foreach (var s in Request.MachineList)
|
{
|
if (s == null)
|
continue;
|
|
var frequence = s.Frequence;
|
if (frequence < 10 || frequence > 55)
|
continue;
|
var machineID = s.MachineID;
|
var product = bllProduct.GetByID(Request.CorpID, machineID);
|
if (product == null)
|
continue;
|
var pump = bllProduct.GetChildPumpByEnginePumpID(Request.CorpID, machineID);
|
if (pump == null)
|
continue;
|
|
var curve_default = bllCurve.GetDefaultWorkingByPumpID(Request.CorpID, pump.ID);
|
//.GetDefaultCurveByPumpID(CorpID, pumpID);
|
if (curve_default == null)
|
continue;
|
if (curve_default.CurveInfo == null)
|
continue;
|
if (frequence > 49.5)
|
{
|
var curve_qh = curve_default.CurveInfo.CurveQH;
|
curve_qh.Max = curve_qh.Max * IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.ExtendMaxRatio;
|
curveListQH.Add(curve_qh);
|
|
var curve_qp = curve_default.CurveInfo.CurveQP;
|
curve_qp.Max = curve_qp.Max * IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.ExtendMaxRatio;
|
curveListQP.Add(curve_qp);
|
}
|
else
|
{
|
var ration = frequence / 50.0;
|
|
var maxCurveQH = IStation.Model.FitCurveHelper.GetFitPointsByExtend(curve_default.CurveInfo.CurveQH,
|
IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.ExtendMaxRatio, 20);
|
var maxCurveQP = IStation.Model.FitCurveHelper.GetFitPointsByExtend(curve_default.CurveInfo.CurveQP,
|
IStation.Calculation.DispatchAna.Common.DispatchAnaGeneralHelper.ExtendMaxRatio, 20);
|
|
List<IStation.Model.CurvePoint> simuPointsQH = new List<IStation.Model.CurvePoint>();
|
foreach (var pt in maxCurveQH)
|
{
|
simuPointsQH.Add(new IStation.Model.CurvePoint(pt.X * ration, pt.Y * ration * ration));
|
}
|
|
List<IStation.Model.CurvePoint> simuPointsQP = new List<IStation.Model.CurvePoint>();
|
foreach (var pt in maxCurveQP)
|
{
|
simuPointsQP.Add(new IStation.Model.CurvePoint(pt.X * ration, pt.Y * ration * ration * ration));
|
}
|
curveListQH.Add(new IStation.Model.CurveExpress(simuPointsQH));
|
curveListQP.Add(new IStation.Model.CurveExpress(simuPointsQP));
|
}
|
double maxH, minH;
|
IStation.Model.FitCurveHelper.GetMinMaxPointY(curveListQH.Last(), out maxH, out minH);
|
r_maxH = Math.Min(r_maxH, maxH);
|
r_minH = Math.Max(r_minH, minH);
|
}
|
|
if (curveListQH.Count < 1)
|
{
|
return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Alert, "不适合并联1");
|
}
|
|
|
if (r_maxH < r_minH)
|
{
|
return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Alert, "不适合并联2");
|
}
|
|
double space_h = (r_maxH - r_minH) / 19;
|
List<IStation.Model.CurvePoint> conne_curve_qp = new List<IStation.Model.CurvePoint>();
|
List<IStation.Model.CurvePoint> conne_curve_qh = new List<IStation.Model.CurvePoint>();
|
for (var h = r_minH; h <= r_maxH; h = h + space_h)
|
{
|
double total_flow = 0;
|
double total_power = 0;
|
|
for (int j = 0; j < curveListQH.Count; j++)
|
{
|
var curveQH = curveListQH[j];
|
var curveQP = curveListQP[j];
|
var pts = IStation.Model.FitCurveHelper.GetInterPointX(curveQH, h);
|
if (pts != null && pts.Count > 0)
|
{
|
var q = pts.Last().X;
|
total_flow += q;
|
total_power += IStation.Model.FitCurveHelper.GetFitPointY(curveQP, q);
|
}
|
}
|
conne_curve_qh.Add(new IStation.Model.CurvePoint(total_flow, h));
|
conne_curve_qp.Add(new IStation.Model.CurvePoint(total_flow, total_power));
|
}
|
|
|
var sectPointQHs = IStation.Model.FitCurveHelper.GetInterPointX(conne_curve_qh, Request.Head);
|
if (sectPointQHs == null || sectPointQHs.Count == 0)
|
{
|
return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Alert, "不适合并联3");
|
}
|
var sect_q = sectPointQHs.Last().X;
|
|
return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Success, String.Format("流量为:{0}", Math.Round(sect_q, 1)));
|
|
}
|
|
|
/// <summary>
|
/// Epanet测试
|
/// </summary>
|
/// <returns></returns>
|
[Route("EpanetDebug@V1.0")]
|
[HttpGet]
|
public IStation.Dto.ApiResult EpanetDebug()
|
{
|
var str = new StringBuilder();
|
try
|
{
|
//方法1
|
//var item = new EpanetMethod1ContextItem();
|
//item.Level = 2.697;
|
//item.Flow1 = 3011;
|
//item.Flow2 = 6;
|
//item.Hz1 = 33;
|
//item.Hz2 = 0;
|
//item.Hz3 = 0;
|
//item.Hz4 = 32;
|
|
|
//var helper = new CalcCxd2();
|
//var list = helper.CalcuPressByLevelAndFlow(item);
|
//var json = JsonHelper.Object2Json(list);
|
//str.AppendLine(json);
|
|
//方法2
|
//var item = new EpanetMethod2ContextItem();
|
//item.Level = 2.697;
|
//item.Press1 = IStation.Formula.CalcuHelper.Mpa2M(0.1124);
|
//item.Press2 = IStation.Formula.CalcuHelper.Mpa2M(0.1199);
|
//item.Hz1 = 33;
|
//item.Hz2 = 0;
|
//item.Hz3 = 0;
|
//item.Hz4 = 32;
|
|
|
//var helper = new CalcCxd();
|
//var list = helper.CalcuFlowByPressAndPumpStatus(item);
|
//var json = JsonHelper.Object2Json(list);
|
//str.AppendLine(json);
|
|
//方法3
|
var item = new EpanetMethod3ContextItem();
|
item.Level = 2.558;
|
item.Flow1 = 2573;
|
item.Flow2 = 0;
|
item.Press1 = 2.929;
|
item.Press2 = 0;
|
item.RunStatus2 = false;
|
item.RunStatus3 = false;
|
|
|
var helper = new CalcCxd2();
|
var list = helper.CalcuPumpStatusByFlowAndPress(item);
|
var json = JsonHelper.Object2Json(list);
|
str.AppendLine(json);
|
}
|
catch (Exception e)
|
{
|
str.AppendLine("输入错误" + e.ToString());
|
}
|
return new IStation.Dto.ApiResult(IStation.Dto.ApiResultCode.Success, str.ToString());
|
|
}
|
}
|
}
|