using Yw.Model;
|
|
namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
/// 资产匹配辅助类
|
/// </summary>
|
public class HydroMatchingHelper
|
{
|
|
#region 创建
|
|
/// <summary>
|
/// 创建自动匹配ViewModel
|
/// </summary>
|
public static HydroMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuVisualResultList = null)
|
{
|
#region 初始化字典
|
|
Dictionary<string, HydroCalcuVisualResult> dict = null;
|
if (allCalcuVisualResultList != null && allCalcuVisualResultList.Count > 0)
|
{
|
dict = new Dictionary<string, HydroCalcuVisualResult>();
|
allCalcuVisualResultList.ForEach(x => dict.Add(x.Code, x));
|
}
|
|
#endregion
|
|
#region 获取计算结果方法
|
|
HydroCalcuVisualResult getCalcuVisualResult(string code)
|
{
|
if (dict == null)
|
{
|
return default;
|
}
|
if (dict.ContainsKey(code))
|
{
|
return dict[code];
|
}
|
return default;
|
}
|
|
#endregion
|
|
var vm = new HydroMatchingViewModel();
|
|
#region 水池
|
|
var tanks = hydroInfo.GetAllTanks();
|
vm.Tanks = tanks?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList();
|
|
#endregion
|
|
#region 闷头
|
|
vm.Bluntheads = hydroInfo.Bluntheads?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList();
|
|
#endregion
|
|
#region 弯头
|
|
vm.Elbows = hydroInfo.Elbows?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList();
|
|
#endregion
|
|
#region 三通
|
|
vm.Threelinks = hydroInfo.Threelinks?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList();
|
|
#endregion
|
|
#region 四通
|
|
vm.Fourlinks = hydroInfo.Fourlinks?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList();
|
|
#endregion
|
|
#region 喷嘴
|
|
vm.Nozzles = hydroInfo.Nozzles?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList();
|
|
#endregion
|
|
#region 消火栓
|
|
vm.Hydrants = hydroInfo.Hydrants?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList();
|
|
#endregion
|
|
#region 水表
|
|
vm.Meters = hydroInfo.Meters?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList();
|
|
#endregion
|
|
#region 流量计
|
|
vm.Flowmeters = hydroInfo.Flowmeters?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuFlowmeterResult)).ToList();
|
|
#endregion
|
|
#region 压力表
|
|
vm.Pressmeters = hydroInfo.Pressmeters?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuPressmeterResult)).ToList();
|
|
#endregion
|
|
#region 管道
|
|
vm.Pipes = hydroInfo.Pipes?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList();
|
|
#endregion
|
|
#region 过渡件
|
|
vm.Translations = hydroInfo.Translations?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList();
|
|
#endregion
|
|
#region 水泵
|
|
vm.Pumps = hydroInfo.Pumps?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuPumpResult)).ToList();
|
|
#endregion
|
|
#region 阀门
|
|
vm.Valves = hydroInfo.Valves?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList();
|
|
#endregion
|
|
#region 换热器
|
|
vm.Exchangers = hydroInfo.Exchangers?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList();
|
|
#endregion
|
|
#region 压缩机
|
|
vm.Compressors = hydroInfo.Compressors?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList();
|
|
#endregion
|
|
return vm;
|
|
}
|
|
public static HydroMatchingViewModel Create(List<HydroVisualViewModel> allVisualList)
|
{
|
return default;
|
}
|
|
#region 水池
|
|
/// <summary>
|
/// 创建水池自动匹配ViewModel
|
/// </summary>
|
public static HydroTankMatchingViewModel Create(HydroTankInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroTankMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建水池自动匹配ViewModel
|
/// </summary>
|
public static HydroTankMatchingViewModel Create(HydroTankViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroTankMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 闷头
|
|
/// <summary>
|
/// 创建闷头自动匹配ViewModel
|
/// </summary>
|
public static HydroBluntheadMatchingViewModel Create(HydroBluntheadInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroBluntheadMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建闷头自动匹配ViewModel
|
/// </summary>
|
public static HydroBluntheadMatchingViewModel Create(HydroBluntheadViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroBluntheadMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 弯头
|
|
/// <summary>
|
/// 创建弯头自动匹配ViewModel
|
/// </summary>
|
public static HydroElbowMatchingViewModel Create(HydroElbowInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroElbowMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建弯头自动匹配ViewModel
|
/// </summary>
|
public static HydroElbowMatchingViewModel Create(HydroElbowViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroElbowMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 三通
|
|
/// <summary>
|
/// 创建三通自动匹配ViewModel
|
/// </summary>
|
public static HydroThreelinkMatchingViewModel Create(HydroThreelinkInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroThreelinkMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建三通自动匹配ViewModel
|
/// </summary>
|
public static HydroThreelinkMatchingViewModel Create(HydroThreelinkViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroThreelinkMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 四通
|
|
/// <summary>
|
/// 创建四通自动匹配ViewModel
|
/// </summary>
|
public static HydroFourlinkMatchingViewModel Create(HydroFourlinkInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroFourlinkMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建四通自动匹配ViewModel
|
/// </summary>
|
public static HydroFourlinkMatchingViewModel Create(HydroFourlinkViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroFourlinkMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 喷头
|
|
/// <summary>
|
/// 创建喷头自动匹配ViewModel
|
/// </summary>
|
public static HydroNozzleMatchingViewModel Create(HydroNozzleInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroNozzleMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建喷头自动匹配ViewModel
|
/// </summary>
|
public static HydroNozzleMatchingViewModel Create(HydroNozzleViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroNozzleMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 消火栓
|
|
/// <summary>
|
/// 创建消火栓自动匹配ViewModel
|
/// </summary>
|
public static HydroHydrantMatchingViewModel Create(HydroHydrantInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroHydrantMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建消火栓自动匹配ViewModel
|
/// </summary>
|
public static HydroHydrantMatchingViewModel Create(HydroHydrantViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroHydrantMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 水表
|
|
/// <summary>
|
/// 创建水表自动匹配ViewModel
|
/// </summary>
|
public static HydroMeterMatchingViewModel Create(HydroMeterInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuNodeResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroMeterMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建水表自动匹配ViewModel
|
/// </summary>
|
public static HydroMeterMatchingViewModel Create(HydroMeterViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroMeterMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 流量计
|
|
/// <summary>
|
/// 创建流量计自动匹配ViewModel
|
/// </summary>
|
public static HydroFlowmeterMatchingViewModel Create(HydroFlowmeterInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuFlowmeterResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroFlowmeterMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建流量计自动匹配ViewModel
|
/// </summary>
|
public static HydroFlowmeterMatchingViewModel Create(HydroFlowmeterViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroFlowmeterMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 压力表
|
|
/// <summary>
|
/// 创建压力表自动匹配ViewModel
|
/// </summary>
|
public static HydroPressmeterMatchingViewModel Create(HydroPressmeterInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuPressmeterResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroPressmeterMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建压力表自动匹配ViewModel
|
/// </summary>
|
public static HydroPressmeterMatchingViewModel Create(HydroPressmeterViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroPressmeterMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 管道
|
|
/// <summary>
|
/// 创建管道自动匹配ViewModel
|
/// </summary>
|
public static HydroPipeMatchingViewModel Create(HydroPipeInfo pipeInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null)
|
{
|
if (pipeInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroPipeMatchingViewModel(pipeInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建管道自动匹配ViewModel
|
/// </summary>
|
public static HydroPipeMatchingViewModel Create(HydroPipeViewModel pipeViewModel)
|
{
|
if (pipeViewModel == null)
|
{
|
return default;
|
}
|
return new HydroPipeMatchingViewModel(pipeViewModel);
|
}
|
|
#endregion
|
|
#region 过渡件
|
|
/// <summary>
|
/// 创建过渡件自动匹配ViewModel
|
/// </summary>
|
public static HydroTranslationMatchingViewModel Create(HydroTranslationInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroTranslationMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建过渡件自动匹配ViewModel
|
/// </summary>
|
public static HydroTranslationMatchingViewModel Create(HydroTranslationViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroTranslationMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 水泵
|
|
/// <summary>
|
/// 创建水泵自动匹配ViewModel
|
/// </summary>
|
public static HydroPumpMatchingViewModel Create(HydroPumpInfo pumpInfo, HydroModelInfo hydroInfo, HydroCalcuPumpResult calcuResult = null)
|
{
|
if (pumpInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroPumpMatchingViewModel(pumpInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建水泵自动匹配ViewModel
|
/// </summary>
|
public static HydroPumpMatchingViewModel Create(HydroPumpViewModel pumpViewModel)
|
{
|
if (pumpViewModel == null)
|
{
|
return default;
|
}
|
return new HydroPumpMatchingViewModel(pumpViewModel);
|
}
|
|
#endregion
|
|
#region 阀门
|
|
/// <summary>
|
/// 创建阀门自动匹配ViewModel
|
/// </summary>
|
public static HydroValveMatchingViewModel Create(HydroValveInfo valveInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null)
|
{
|
if (valveInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroValveMatchingViewModel(valveInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建阀门自动匹配ViewModel
|
/// </summary>
|
public static HydroValveMatchingViewModel Create(HydroValveViewModel valveViewModel)
|
{
|
if (valveViewModel == null)
|
{
|
return default;
|
}
|
return new HydroValveMatchingViewModel(valveViewModel);
|
}
|
|
#endregion
|
|
#region 换热器
|
|
/// <summary>
|
/// 创建换热器自动匹配ViewModel
|
/// </summary>
|
public static HydroExchangerMatchingViewModel Create(HydroExchangerInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroExchangerMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建换热器自动匹配ViewModel
|
/// </summary>
|
public static HydroExchangerMatchingViewModel Create(HydroExchangerViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroExchangerMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#region 压缩机
|
|
/// <summary>
|
/// 创建压缩机自动匹配ViewModel
|
/// </summary>
|
public static HydroCompressorMatchingViewModel Create(HydroCompressorInfo parterInfo, HydroModelInfo hydroInfo, HydroCalcuLinkResult calcuResult = null)
|
{
|
if (parterInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroCompressorMatchingViewModel(parterInfo, hydroInfo, calcuResult);
|
}
|
|
/// <summary>
|
/// 创建压缩机自动匹配ViewModel
|
/// </summary>
|
public static HydroCompressorMatchingViewModel Create(HydroCompressorViewModel parterViewModel)
|
{
|
if (parterViewModel == null)
|
{
|
return default;
|
}
|
return new HydroCompressorMatchingViewModel(parterViewModel);
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 应用
|
|
///// <summary>
|
///// 应用资产自动匹配ViewModel
|
///// </summary>
|
//public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, AssetsMatchingViewModel output)
|
//{
|
// if (hydroInfo == null)
|
// {
|
// return false;
|
// }
|
// if (output == null)
|
// {
|
// return false;
|
// }
|
|
// bool result = false;
|
|
// //水泵
|
// output.PumpMatchingList?.ForEach(x =>
|
// {
|
// if (Apply(hydroInfo, x))
|
// {
|
// result = true;
|
// }
|
// });
|
|
// //阀门
|
// output.ValveMatchingList?.ForEach(x =>
|
// {
|
// if (Apply(hydroInfo, x))
|
// {
|
// result = true;
|
// }
|
// });
|
|
// //管道
|
// output.PipeMatchingList?.ForEach(x =>
|
// {
|
// if (Apply(hydroInfo, x))
|
// {
|
// result = true;
|
// }
|
// });
|
|
// //弯头
|
// output.ElbowMatchingList?.ForEach(x =>
|
// {
|
// if (Apply(hydroInfo, x))
|
// {
|
// result = true;
|
// }
|
// });
|
|
// //三通
|
// output.ThreelinkMatchingList?.ForEach(x =>
|
// {
|
// if (Apply(hydroInfo, x))
|
// {
|
// result = true;
|
// }
|
// });
|
|
// //四通
|
// output.FourlinkMatchingList?.ForEach(x =>
|
// {
|
// if (Apply(hydroInfo, x))
|
// {
|
// result = true;
|
// }
|
// });
|
|
// return result;
|
//}
|
|
///// <summary>
|
///// 应用泵自动匹配ViewModel
|
///// </summary>
|
//public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, PumpMatchingViewModel matching)
|
//{
|
// if (hydroInfo == null)
|
// {
|
// return false;
|
// }
|
// if (matching == null)
|
// {
|
// return false;
|
// }
|
|
// bool result = false;
|
|
// var pump = hydroInfo.Pumps?.Find(x => x.Code == matching.Code);
|
// if (pump != null)
|
// {
|
// pump.DbLocked = matching.DbLocked;
|
// pump.ModelType = matching.ModelType;
|
// pump.RatedP = matching.RatedP;
|
// pump.RatedQ = matching.RatedQ;
|
// pump.RatedH = matching.RatedH;
|
// pump.RatedN = matching.RatedN;
|
// pump.RatedHz = matching.RatedHz;
|
// pump.SpeedRatio = Math.Round(matching.CurrentHz / matching.RatedHz, 1);
|
|
// if (!pump.DbLocked)
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
// {
|
// pump.ModelType = matching.MatchingModelType;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
// {
|
// pump.DbId = matching.MatchingDbId;
|
// }
|
// if (matching.MatchingRatedP.HasValue)
|
// {
|
// pump.RatedP = matching.MatchingRatedP.Value;
|
// }
|
// if (matching.MatchingRatedQ.HasValue)
|
// {
|
// pump.RatedQ = matching.MatchingRatedQ.Value;
|
// }
|
// if (matching.MatchingRatedH.HasValue)
|
// {
|
// pump.RatedH = matching.MatchingRatedH.Value;
|
// }
|
// if (matching.MatchingRatedN.HasValue)
|
// {
|
// pump.RatedN = matching.MatchingRatedN.Value;
|
// }
|
|
// if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
|
// {
|
// //流量扬程曲线
|
// var curveqh = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQH);
|
// if (curveqh == null)
|
// {
|
// curveqh = new Yw.Model.HydroCurveInfo();
|
// curveqh.Catalog = Yw.Hydro.ParterCatalog.Curve;
|
// curveqh.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
|
// curveqh.Name = "匹配";
|
// curveqh.ModelType = string.Empty;
|
// curveqh.DbLocked = false;
|
// curveqh.DbId = matching.MatchingCurveDbId;
|
// curveqh.CurveType = Yw.WinFrmUI.HydroCurve.PumpQH;
|
// curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// if (hydroInfo.Curves == null)
|
// {
|
// hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
|
// }
|
// hydroInfo.Curves.Add(curveqh);
|
// pump.CurveQH = curveqh.Code;
|
// }
|
// else
|
// {
|
// if (!curveqh.DbLocked)
|
// {
|
// curveqh.DbId = matching.MatchingCurveDbId;
|
// curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// }
|
// }
|
|
// //流量功率曲线
|
// var curveqp = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQP);
|
// if (curveqp == null)
|
// {
|
// curveqp = new Yw.Model.HydroCurveInfo();
|
// curveqp.Catalog = Yw.Hydro.ParterCatalog.Curve;
|
// curveqp.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
|
// curveqp.Name = "匹配";
|
// curveqp.ModelType = string.Empty;
|
// curveqp.DbLocked = false;
|
// curveqp.DbId = matching.MatchingCurveDbId;
|
// curveqp.CurveType = Yw.WinFrmUI.HydroCurve.PumpQP;
|
// curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// if (hydroInfo.Curves == null)
|
// {
|
// hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
|
// }
|
// hydroInfo.Curves.Add(curveqp);
|
// pump.CurveQP = curveqp.Code;
|
// }
|
// else
|
// {
|
// if (!curveqp.DbLocked)
|
// {
|
// curveqp.DbId = matching.MatchingCurveDbId;
|
// curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// }
|
// }
|
|
// //流量效率曲线
|
// var curveqe = hydroInfo.Curves?.Find(x => x.Code == pump.CurveQE);
|
// if (curveqe == null)
|
// {
|
// curveqe = new Yw.Model.HydroCurveInfo();
|
// curveqe.Catalog = Yw.Hydro.ParterCatalog.Curve;
|
// curveqe.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
|
// curveqe.Name = "匹配";
|
// curveqe.ModelType = string.Empty;
|
// curveqe.DbLocked = false;
|
// curveqe.DbId = matching.MatchingCurveDbId;
|
// curveqe.CurveType = Yw.WinFrmUI.HydroCurve.PumpQE;
|
// curveqe.CurveData = matching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// if (hydroInfo.Curves == null)
|
// {
|
// hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
|
// }
|
// hydroInfo.Curves.Add(curveqe);
|
// pump.CurveQE = curveqe.Code;
|
// }
|
// else
|
// {
|
// if (!curveqe.DbLocked)
|
// {
|
// curveqe.DbId = matching.MatchingCurveDbId;
|
// curveqe.CurveData = matching.MatchingCurveQE?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// }
|
// }
|
|
// }
|
|
// result = true;
|
// }
|
// }
|
|
// return result;
|
//}
|
|
///// <summary>
|
///// 应用阀门自动匹配ViewModel
|
///// </summary>
|
//public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, ValveMatchingViewModel matching)
|
//{
|
// if (hydroInfo == null)
|
// {
|
// return false;
|
// }
|
// if (matching == null)
|
// {
|
// return false;
|
// }
|
|
// bool result = false;
|
|
// var valve = hydroInfo.Valves?.Find(x => x.Code == matching.Code);
|
// if (valve != null)
|
// {
|
// valve.DbLocked = matching.DbLocked;
|
// valve.ModelType = matching.ModelType;
|
// valve.Material = matching.Material;
|
// valve.Diameter = matching.Diameter;
|
// valve.MinorLoss = matching.MinorLoss;
|
// switch (matching.ValveType)
|
// {
|
// case HStation.Assets.eValveType.PBV: valve.ValveType = Yw.Hydro.ValveType.PBV; break;
|
// case HStation.Assets.eValveType.PRV: valve.ValveType = Yw.Hydro.ValveType.PRV; break;
|
// case HStation.Assets.eValveType.PSV: valve.ValveType = Yw.Hydro.ValveType.PSV; break;
|
// case HStation.Assets.eValveType.TCV: valve.ValveType = Yw.Hydro.ValveType.TCV; break;
|
// case HStation.Assets.eValveType.FCV: valve.ValveType = Yw.Hydro.ValveType.FCV; break;
|
// case HStation.Assets.eValveType.GPV: valve.ValveType = Yw.Hydro.ValveType.GPV; break;
|
// case HStation.Assets.eValveType.CV: valve.ValveType = Yw.Hydro.ValveType.CV; break;
|
// default: break;
|
// }
|
// valve.ValveSetting = matching.ValveSetting;
|
|
// if (!valve.DbLocked)
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
// {
|
// valve.DbId = matching.MatchingDbId;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
// {
|
// valve.ModelType = matching.MatchingModelType;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
// {
|
// valve.Material = matching.MatchingMaterial;
|
// }
|
// if (matching.MatchingDiameter.HasValue)
|
// {
|
// valve.Diameter = matching.MatchingDiameter.Value;
|
// }
|
// if (matching.MatchingMinorLoss.HasValue)
|
// {
|
// valve.MinorLoss = matching.MatchingMinorLoss.Value;
|
// }
|
// if (matching.MatchingValveType.HasValue)
|
// {
|
// switch (matching.MatchingValveType.Value)
|
// {
|
// case HStation.Assets.eValveType.PBV: valve.ValveType = Yw.Hydro.ValveType.PBV; break;
|
// case HStation.Assets.eValveType.PRV: valve.ValveType = Yw.Hydro.ValveType.PRV; break;
|
// case HStation.Assets.eValveType.PSV: valve.ValveType = Yw.Hydro.ValveType.PSV; break;
|
// case HStation.Assets.eValveType.TCV: valve.ValveType = Yw.Hydro.ValveType.TCV; break;
|
// case HStation.Assets.eValveType.FCV: valve.ValveType = Yw.Hydro.ValveType.FCV; break;
|
// case HStation.Assets.eValveType.GPV: valve.ValveType = Yw.Hydro.ValveType.GPV; break;
|
// case HStation.Assets.eValveType.CV: valve.ValveType = Yw.Hydro.ValveType.CV; break;
|
// default: break;
|
// }
|
// }
|
// switch (valve.ValveType)
|
// {
|
// case Yw.Hydro.ValveType.PSV:
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
|
// {
|
// valve.ValveSetting = matching.MatchingValveSetting;
|
// }
|
// }
|
// break;
|
// case Yw.Hydro.ValveType.PBV:
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
|
// {
|
// valve.ValveSetting = matching.MatchingValveSetting;
|
// }
|
// }
|
// break;
|
// case Yw.Hydro.ValveType.PRV:
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
|
// {
|
// valve.ValveSetting = matching.MatchingValveSetting;
|
// }
|
// }
|
// break;
|
// case Yw.Hydro.ValveType.FCV:
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
|
// {
|
// valve.ValveSetting = matching.MatchingValveSetting;
|
// }
|
// }
|
// break;
|
// case Yw.Hydro.ValveType.TCV:
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
|
// {
|
// //阀门开度损失系数曲线
|
// var curveol = hydroInfo.Curves?.Find(x => x.Code == valve.ValveSetting);
|
// if (curveol == null)
|
// {
|
// curveol = new Yw.Model.HydroCurveInfo();
|
// curveol.Catalog = Yw.Hydro.ParterCatalog.Curve;
|
// curveol.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
|
// curveol.Name = "匹配";
|
// curveol.ModelType = valve.ModelType;
|
// curveol.DbLocked = false;
|
// curveol.DbId = matching.MatchingCurveDbId;
|
// curveol.CurveType = Yw.WinFrmUI.HydroCurve.ValveOL;
|
// curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// if (hydroInfo.Curves == null)
|
// {
|
// hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
|
// }
|
// hydroInfo.Curves.Add(curveol);
|
// valve.ValveSetting = curveol.Code;
|
// }
|
// else
|
// {
|
// if (!curveol.DbLocked)
|
// {
|
// curveol.DbId = matching.MatchingCurveDbId;
|
// curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// }
|
// }
|
// }
|
// }
|
// break;
|
// case Yw.Hydro.ValveType.GPV:
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
|
// {
|
// //阀门开度损失系数曲线
|
// var curveql = hydroInfo.Curves?.Find(x => x.Code == valve.ValveSetting);
|
// if (curveql == null)
|
// {
|
// curveql = new Yw.Model.HydroCurveInfo();
|
// curveql.Catalog = Yw.Hydro.ParterCatalog.Curve;
|
// curveql.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
|
// curveql.Name = "匹配";
|
// curveql.ModelType = valve.ModelType;
|
// curveql.DbLocked = false;
|
// curveql.DbId = matching.MatchingCurveDbId;
|
// curveql.CurveType = Yw.WinFrmUI.HydroCurve.ValveOL;
|
// curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// if (hydroInfo.Curves == null)
|
// {
|
// hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>();
|
// }
|
// hydroInfo.Curves.Add(curveql);
|
// valve.ValveSetting = curveql.Code;
|
// }
|
// else
|
// {
|
// if (!curveql.DbLocked)
|
// {
|
// curveql.DbId = matching.MatchingCurveDbId;
|
// curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
// }
|
// }
|
// }
|
// }
|
// break;
|
// case Yw.Hydro.ValveType.CV:
|
// {
|
|
// }
|
// break;
|
// }
|
|
// result = true;
|
// }
|
// }
|
// return result;
|
//}
|
|
///// <summary>
|
///// 应用管道自动匹配ViewModel
|
///// </summary>
|
//public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, PipeMatchingViewModel matching)
|
//{
|
// if (hydroInfo == null)
|
// {
|
// return false;
|
// }
|
// if (matching == null)
|
// {
|
// return false;
|
// }
|
|
// bool result = false;
|
|
// var pipe = hydroInfo.Pipes?.Find(x => x.Code == matching.Code);
|
// if (pipe != null)
|
// {
|
// pipe.DbLocked = matching.DbLocked;
|
// pipe.ModelType = matching.ModelType;
|
// pipe.Diameter = matching.Diameter;
|
// pipe.Material = matching.Material;
|
// pipe.Roughness = matching.Roughness;
|
// pipe.MinorLoss = matching.MinorLoss;
|
|
// if (!pipe.DbLocked)
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
// {
|
// pipe.ModelType = matching.MatchingModelType;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
// {
|
// pipe.DbId = matching.MatchingDbId;
|
// }
|
// if (matching.MatchingDiameter.HasValue)
|
// {
|
// pipe.Diameter = matching.MatchingDiameter.Value;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
// {
|
// pipe.Material = matching.MatchingMaterial;
|
// }
|
// if (matching.MatchingRoughness.HasValue)
|
// {
|
// pipe.Roughness = matching.MatchingRoughness.Value;
|
// }
|
// if (matching.MatchingMinorLoss.HasValue)
|
// {
|
// pipe.MinorLoss = matching.MatchingMinorLoss.Value;
|
// }
|
|
// result = true;
|
// }
|
// }
|
// return result;
|
//}
|
|
///// <summary>
|
///// 应用弯头自动匹配ViewModel
|
///// </summary>
|
//public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, ElbowMatchingViewModel matching)
|
//{
|
// if (hydroInfo == null)
|
// {
|
// return false;
|
// }
|
// if (matching == null)
|
// {
|
// return false;
|
// }
|
|
// bool result = false;
|
|
// var elbow = hydroInfo.Elbows?.Find(x => x.Code == matching.Code);
|
// if (elbow != null)
|
// {
|
// elbow.DbLocked = matching.DbLocked;
|
// elbow.ModelType = matching.ModelType;
|
// elbow.Caliber = matching.Caliber;
|
// elbow.Material = matching.Material;
|
// elbow.MinorLoss = matching.MinorLoss;
|
|
// if (!elbow.DbLocked)
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
// {
|
// elbow.ModelType = matching.MatchingModelType;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
// {
|
// elbow.DbId = matching.MatchingDbId;
|
// }
|
// if (matching.MatchingCaliber.HasValue)
|
// {
|
// elbow.Caliber = matching.MatchingCaliber.Value;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
// {
|
// elbow.Material = matching.MatchingMaterial;
|
// }
|
// if (matching.MatchingMinorLoss.HasValue)
|
// {
|
// elbow.MinorLoss = matching.MatchingMinorLoss.Value;
|
// }
|
|
// result = true;
|
// }
|
// }
|
// return result;
|
//}
|
|
///// <summary>
|
///// 应用三通自动匹配ViewModel
|
///// </summary>
|
//public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, ThreelinkMatchingViewModel matching)
|
//{
|
// if (hydroInfo == null)
|
// {
|
// return false;
|
// }
|
// if (matching == null)
|
// {
|
// return false;
|
// }
|
|
// bool result = false;
|
|
// var threelink = hydroInfo.Threelinks?.Find(x => x.Code == matching.Code);
|
// if (threelink != null)
|
// {
|
// threelink.DbLocked = matching.DbLocked;
|
// threelink.ModelType = matching.ModelType;
|
// threelink.Caliber = matching.Caliber;
|
// threelink.Material = matching.Material;
|
// threelink.MinorLoss = matching.MinorLoss;
|
|
// if (!threelink.DbLocked)
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
// {
|
// threelink.ModelType = matching.MatchingModelType;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
// {
|
// threelink.DbId = matching.MatchingDbId;
|
// }
|
// if (matching.MatchingCaliber.HasValue)
|
// {
|
// threelink.Caliber = matching.MatchingCaliber.Value;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
// {
|
// threelink.Material = matching.MatchingMaterial;
|
// }
|
// if (matching.MatchingMinorLoss.HasValue)
|
// {
|
// threelink.MinorLoss = matching.MatchingMinorLoss.Value;
|
// }
|
|
// result = true;
|
// }
|
// }
|
// return result;
|
//}
|
|
///// <summary>
|
///// 应用四通自动匹配ViewModel
|
///// </summary>
|
//public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, FourlinkMatchingViewModel matching)
|
//{
|
// if (hydroInfo == null)
|
// {
|
// return false;
|
// }
|
// if (matching == null)
|
// {
|
// return false;
|
// }
|
|
// bool result = false;
|
|
// var fourlink = hydroInfo.Fourlinks?.Find(x => x.Code == matching.Code);
|
// if (fourlink != null)
|
// {
|
// fourlink.DbLocked = matching.DbLocked;
|
// fourlink.ModelType = matching.ModelType;
|
// fourlink.Caliber = matching.Caliber;
|
// fourlink.Material = matching.Material;
|
// fourlink.MinorLoss = matching.MinorLoss;
|
|
// if (!fourlink.DbLocked)
|
// {
|
// if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
// {
|
// fourlink.ModelType = matching.MatchingModelType;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
// {
|
// fourlink.DbId = matching.MatchingDbId;
|
// }
|
// if (matching.MatchingCaliber.HasValue)
|
// {
|
// fourlink.Caliber = matching.MatchingCaliber.Value;
|
// }
|
// if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
// {
|
// fourlink.Material = matching.MatchingMaterial;
|
// }
|
// if (matching.MatchingMinorLoss.HasValue)
|
// {
|
// fourlink.MinorLoss = matching.MatchingMinorLoss.Value;
|
// }
|
|
// result = true;
|
// }
|
// }
|
// return result;
|
//}
|
|
#endregion
|
|
|
|
}
|
}
|