using DevExpress.XtraSpreadsheet.Model.CopyOperation;
|
using System.Windows.Media.Imaging;
|
using Yw.DAL.Basic;
|
using Yw.EPAnet;
|
using Yw.Hydro;
|
using Yw.Model;
|
|
namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
/// 资产匹配辅助类
|
/// </summary>
|
public class HydroMatchingHelper
|
{
|
|
#region 创建
|
|
/// <summary>
|
/// 创建
|
/// </summary>
|
public static HydroMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo)
|
{
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
|
var vm = new HydroMatchingViewModel();
|
|
#region 水池
|
|
var tanks = hydroInfo.GetAllTanks();
|
vm.Tanks = tanks?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 闷头
|
|
vm.Bluntheads = hydroInfo.Bluntheads?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 弯头
|
|
vm.Elbows = hydroInfo.Elbows?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 三通
|
|
vm.Threelinks = hydroInfo.Threelinks?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 四通
|
|
vm.Fourlinks = hydroInfo.Fourlinks?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 喷嘴
|
|
vm.Nozzles = hydroInfo.Nozzles?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 消火栓
|
|
vm.Hydrants = hydroInfo.Hydrants?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 冷却塔
|
|
vm.Coolings = hydroInfo.Coolings?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 水表
|
|
vm.Meters = hydroInfo.Meters?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 流量计
|
|
vm.Flowmeters = hydroInfo.Flowmeters?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 压力表
|
|
vm.Pressmeters = hydroInfo.Pressmeters?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 管道
|
|
vm.Pipes = hydroInfo.Pipes?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 过渡件
|
|
vm.Translations = hydroInfo.Translations?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 水泵
|
|
vm.Pumps = hydroInfo.Pumps?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 阀门
|
|
vm.Valves = hydroInfo.Valves?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 换热器
|
|
vm.Exchangers = hydroInfo.Exchangers?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
#region 压缩机
|
|
vm.Compressors = hydroInfo.Compressors?.Select(x => Create(x, hydroInfo)).ToList();
|
|
#endregion
|
|
return vm;
|
}
|
|
#region 水池
|
|
/// <summary>
|
/// 创建水池自动匹配ViewModel
|
/// </summary>
|
public static HydroTankMatchingViewModel Create(HydroTankInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroTankMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建水池自动匹配ViewModel
|
/// </summary>
|
public static HydroTankMatchingViewModel Create(HydroTankViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroTankMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 闷头
|
|
/// <summary>
|
/// 创建闷头自动匹配ViewModel
|
/// </summary>
|
public static HydroBluntheadMatchingViewModel Create(HydroBluntheadInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroBluntheadMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建闷头自动匹配ViewModel
|
/// </summary>
|
public static HydroBluntheadMatchingViewModel Create(HydroBluntheadViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroBluntheadMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 弯头
|
|
/// <summary>
|
/// 创建弯头自动匹配ViewModel
|
/// </summary>
|
public static HydroElbowMatchingViewModel Create(HydroElbowInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroElbowMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建弯头自动匹配ViewModel
|
/// </summary>
|
public static HydroElbowMatchingViewModel Create(HydroElbowViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroElbowMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 三通
|
|
/// <summary>
|
/// 创建三通自动匹配ViewModel
|
/// </summary>
|
public static HydroThreelinkMatchingViewModel Create(HydroThreelinkInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroThreelinkMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建三通自动匹配ViewModel
|
/// </summary>
|
public static HydroThreelinkMatchingViewModel Create(HydroThreelinkViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroThreelinkMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 四通
|
|
/// <summary>
|
/// 创建四通自动匹配ViewModel
|
/// </summary>
|
public static HydroFourlinkMatchingViewModel Create(HydroFourlinkInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroFourlinkMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建四通自动匹配ViewModel
|
/// </summary>
|
public static HydroFourlinkMatchingViewModel Create(HydroFourlinkViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroFourlinkMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 喷头
|
|
/// <summary>
|
/// 创建喷头自动匹配ViewModel
|
/// </summary>
|
public static HydroNozzleMatchingViewModel Create(HydroNozzleInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroNozzleMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建喷头自动匹配ViewModel
|
/// </summary>
|
public static HydroNozzleMatchingViewModel Create(HydroNozzleViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroNozzleMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 消火栓
|
|
/// <summary>
|
/// 创建消火栓自动匹配ViewModel
|
/// </summary>
|
public static HydroHydrantMatchingViewModel Create(HydroHydrantInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroHydrantMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建消火栓自动匹配ViewModel
|
/// </summary>
|
public static HydroHydrantMatchingViewModel Create(HydroHydrantViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroHydrantMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 冷却塔
|
|
/// <summary>
|
/// 创建冷却塔自动匹配ViewModel
|
/// </summary>
|
public static HydroCoolingMatchingViewModel Create(HydroCoolingInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroCoolingMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建冷却塔自动匹配ViewModel
|
/// </summary>
|
public static HydroCoolingMatchingViewModel Create(HydroCoolingViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroCoolingMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 水表
|
|
/// <summary>
|
/// 创建水表自动匹配ViewModel
|
/// </summary>
|
public static HydroMeterMatchingViewModel Create(HydroMeterInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroMeterMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建水表自动匹配ViewModel
|
/// </summary>
|
public static HydroMeterMatchingViewModel Create(HydroMeterViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroMeterMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 流量计
|
|
/// <summary>
|
/// 创建流量计自动匹配ViewModel
|
/// </summary>
|
public static HydroFlowmeterMatchingViewModel Create(HydroFlowmeterInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroFlowmeterMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建流量计自动匹配ViewModel
|
/// </summary>
|
public static HydroFlowmeterMatchingViewModel Create(HydroFlowmeterViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroFlowmeterMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 压力表
|
|
/// <summary>
|
/// 创建压力表自动匹配ViewModel
|
/// </summary>
|
public static HydroPressmeterMatchingViewModel Create(HydroPressmeterInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroPressmeterMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建压力表自动匹配ViewModel
|
/// </summary>
|
public static HydroPressmeterMatchingViewModel Create(HydroPressmeterViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroPressmeterMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 管道
|
|
/// <summary>
|
/// 创建管道自动匹配ViewModel
|
/// </summary>
|
public static HydroPipeMatchingViewModel Create(HydroPipeInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroPipeMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建管道自动匹配ViewModel
|
/// </summary>
|
public static HydroPipeMatchingViewModel Create(HydroPipeViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroPipeMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 过渡件
|
|
/// <summary>
|
/// 创建过渡件自动匹配ViewModel
|
/// </summary>
|
public static HydroTranslationMatchingViewModel Create(HydroTranslationInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroTranslationMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建过渡件自动匹配ViewModel
|
/// </summary>
|
public static HydroTranslationMatchingViewModel Create(HydroTranslationViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroTranslationMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 水泵
|
|
/// <summary>
|
/// 创建水泵自动匹配ViewModel
|
/// </summary>
|
public static HydroPumpMatchingViewModel Create(HydroPumpInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroPumpMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建水泵自动匹配ViewModel
|
/// </summary>
|
public static HydroPumpMatchingViewModel Create(HydroPumpViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroPumpMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 阀门
|
|
/// <summary>
|
/// 创建阀门自动匹配ViewModel
|
/// </summary>
|
public static HydroValveMatchingViewModel Create(HydroValveInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroValveMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建阀门自动匹配ViewModel
|
/// </summary>
|
public static HydroValveMatchingViewModel Create(HydroValveViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroValveMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 换热器
|
|
/// <summary>
|
/// 创建换热器自动匹配ViewModel
|
/// </summary>
|
public static HydroExchangerMatchingViewModel Create(HydroExchangerInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroExchangerMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建换热器自动匹配ViewModel
|
/// </summary>
|
public static HydroExchangerMatchingViewModel Create(HydroExchangerViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroExchangerMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#region 压缩机
|
|
/// <summary>
|
/// 创建压缩机自动匹配ViewModel
|
/// </summary>
|
public static HydroCompressorMatchingViewModel Create(HydroCompressorInfo visualInfo, HydroModelInfo hydroInfo)
|
{
|
if (visualInfo == null)
|
{
|
return default;
|
}
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
return new HydroCompressorMatchingViewModel(visualInfo, hydroInfo);
|
}
|
|
/// <summary>
|
/// 创建压缩机自动匹配ViewModel
|
/// </summary>
|
public static HydroCompressorMatchingViewModel Create(HydroCompressorViewModel visualViewModel)
|
{
|
if (visualViewModel == null)
|
{
|
return default;
|
}
|
return new HydroCompressorMatchingViewModel(visualViewModel);
|
}
|
|
#endregion
|
|
#endregion
|
|
#region 应用
|
|
/// <summary>
|
/// 应用自动匹配ViewModel
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, HydroMatchingViewModel matchingInfo)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (matchingInfo == null)
|
{
|
return false;
|
}
|
|
bool result = false;
|
|
#region 水池
|
|
var allTanks = hydroInfo.GetAllTanks();
|
if (allTanks != null && allTanks.Count > 0)
|
{
|
if (matchingInfo.Tanks != null && matchingInfo.Tanks.Count > 0)
|
{
|
allTanks.ForEach(x =>
|
{
|
var matching = matchingInfo.Tanks.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
|
}
|
|
#endregion
|
|
#region 闷头
|
|
if (hydroInfo.Bluntheads != null && hydroInfo.Bluntheads.Count > 0)
|
{
|
if (matchingInfo.Bluntheads != null && matchingInfo.Bluntheads.Count > 0)
|
{
|
hydroInfo.Bluntheads.ForEach(x =>
|
{
|
var matching = matchingInfo.Bluntheads.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 弯头
|
|
if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0)
|
{
|
if (matchingInfo.Elbows != null && matchingInfo.Elbows.Count > 0)
|
{
|
hydroInfo.Elbows.ForEach(x =>
|
{
|
var matching = matchingInfo.Elbows.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 三通
|
|
if (hydroInfo.Threelinks != null && hydroInfo.Threelinks.Count > 0)
|
{
|
if (matchingInfo.Threelinks != null && matchingInfo.Threelinks.Count > 0)
|
{
|
hydroInfo.Threelinks.ForEach(x =>
|
{
|
var matching = matchingInfo.Threelinks.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 四通
|
|
if (hydroInfo.Fourlinks != null && hydroInfo.Fourlinks.Count > 0)
|
{
|
if (matchingInfo.Fourlinks != null && matchingInfo.Fourlinks.Count > 0)
|
{
|
hydroInfo.Fourlinks.ForEach(x =>
|
{
|
var matching = matchingInfo.Fourlinks.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 喷头
|
|
if (hydroInfo.Nozzles != null && hydroInfo.Nozzles.Count > 0)
|
{
|
if (matchingInfo.Nozzles != null && matchingInfo.Nozzles.Count > 0)
|
{
|
hydroInfo.Nozzles.ForEach(x =>
|
{
|
var matching = matchingInfo.Nozzles.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 消火栓
|
|
if (hydroInfo.Hydrants != null && hydroInfo.Hydrants.Count > 0)
|
{
|
if (matchingInfo.Hydrants != null && matchingInfo.Hydrants.Count > 0)
|
{
|
hydroInfo.Hydrants.ForEach(x =>
|
{
|
var matching = matchingInfo.Hydrants.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 消火栓
|
|
if (hydroInfo.Coolings != null && hydroInfo.Coolings.Count > 0)
|
{
|
if (matchingInfo.Coolings != null && matchingInfo.Coolings.Count > 0)
|
{
|
hydroInfo.Coolings.ForEach(x =>
|
{
|
var matching = matchingInfo.Coolings.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 水表
|
|
if (hydroInfo.Meters != null && hydroInfo.Meters.Count > 0)
|
{
|
if (matchingInfo.Meters != null && matchingInfo.Meters.Count > 0)
|
{
|
hydroInfo.Meters.ForEach(x =>
|
{
|
var matching = matchingInfo.Meters.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 流量计
|
|
if (hydroInfo.Flowmeters != null && hydroInfo.Flowmeters.Count > 0)
|
{
|
if (matchingInfo.Flowmeters != null && matchingInfo.Flowmeters.Count > 0)
|
{
|
hydroInfo.Flowmeters.ForEach(x =>
|
{
|
var matching = matchingInfo.Flowmeters.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 压力表
|
|
if (hydroInfo.Pressmeters != null && hydroInfo.Pressmeters.Count > 0)
|
{
|
if (matchingInfo.Pressmeters != null && matchingInfo.Pressmeters.Count > 0)
|
{
|
hydroInfo.Pressmeters.ForEach(x =>
|
{
|
var matching = matchingInfo.Pressmeters.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 管道
|
|
if (hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0)
|
{
|
if (matchingInfo.Pipes != null && matchingInfo.Pipes.Count > 0)
|
{
|
hydroInfo.Pipes.ForEach(x =>
|
{
|
var matching = matchingInfo.Pipes.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 过渡件
|
|
if (hydroInfo.Translations != null && hydroInfo.Translations.Count > 0)
|
{
|
if (matchingInfo.Translations != null && matchingInfo.Translations.Count > 0)
|
{
|
hydroInfo.Translations.ForEach(x =>
|
{
|
var matching = matchingInfo.Translations.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 水泵
|
|
if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
|
{
|
if (matchingInfo.Pumps != null && matchingInfo.Pumps.Count > 0)
|
{
|
hydroInfo.Pumps.ForEach(x =>
|
{
|
var matching = matchingInfo.Pumps.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 阀门
|
|
if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0)
|
{
|
if (matchingInfo.Valves != null && matchingInfo.Valves.Count > 0)
|
{
|
hydroInfo.Valves.ForEach(x =>
|
{
|
var matching = matchingInfo.Valves.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 换热器
|
|
if (hydroInfo.Exchangers != null && hydroInfo.Exchangers.Count > 0)
|
{
|
if (matchingInfo.Exchangers != null && matchingInfo.Exchangers.Count > 0)
|
{
|
hydroInfo.Exchangers.ForEach(x =>
|
{
|
var matching = matchingInfo.Exchangers.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
#region 空压机
|
|
if (hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0)
|
{
|
if (matchingInfo.Compressors != null && matchingInfo.Compressors.Count > 0)
|
{
|
hydroInfo.Compressors.ForEach(x =>
|
{
|
var matching = matchingInfo.Compressors.Find(t => t.Code == x.Code);
|
if (Apply(hydroInfo, x, matching))
|
{
|
result = true;
|
}
|
});
|
}
|
}
|
|
#endregion
|
|
return result;
|
}
|
|
#region 水池
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroTankViewModel visualViewModel, HydroTankMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroTankInfo visual, HydroTankMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.MinLevel = matching.MinLevel;
|
visual.MaxLevel = matching.MaxLevel;
|
visual.DN = matching.DN;
|
visual.MinVol = matching.MinVol;
|
visual.OverFlow = matching.OverFlow;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingMinLevel.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.MinLevel), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.MinLevel = matching.MatchingMinLevel.Value;
|
result = true;
|
}
|
if (matching.MatchingMaxLevel.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.MaxLevel), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.MaxLevel = matching.MatchingMaxLevel.Value;
|
result = true;
|
}
|
if (matching.MatchingDN.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.DN), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.DN = matching.MatchingDN.Value;
|
result = true;
|
}
|
if (matching.MatchingMinVol.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.MinVol), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.MinVol = matching.MatchingMinVol.Value;
|
result = true;
|
}
|
if (matching.MatchingOverFlow.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.OverFlow), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.OverFlow = matching.MatchingOverFlow.Value;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
|
{
|
var curvevol = hydroInfo.Curves?.Find(x => x.Code == visual.VolCurve);
|
if (curvevol == null)
|
{
|
curvevol = new Yw.Model.HydroCurveInfo();
|
curvevol.Catalog = Yw.Hydro.ParterCatalog.Curve;
|
curvevol.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
|
curvevol.Name = "匹配";
|
curvevol.ModelType = string.Empty;
|
curvevol.DbLocked = false;
|
curvevol.DbId = matching.MatchingCurveDbId;
|
curvevol.CurveType = Yw.WinFrmUI.HydroCurveType.CurveVol;
|
curvevol.CurveData = matching.MatchingVolCurve?.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(curvevol);
|
visual.VolCurve = curvevol.Code;
|
result = true;
|
}
|
else
|
{
|
if (!curvevol.DbLocked)
|
{
|
curvevol.DbId = matching.MatchingCurveDbId;
|
curvevol.CurveData = matching.MatchingVolCurve?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
result = true;
|
}
|
}
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 闷头
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroBluntheadViewModel visualViewModel, HydroBluntheadMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroBluntheadInfo visual, HydroBluntheadMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Caliber = matching.Caliber;
|
visual.Material = matching.Material;
|
visual.MinorLoss = matching.MinorLoss;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingCaliber.HasValue)
|
{
|
visual.Caliber = matching.MatchingCaliber.Value;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 弯头
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroElbowViewModel visualViewModel, HydroElbowMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroElbowInfo visual, HydroElbowMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Caliber = matching.Caliber;
|
visual.Material = matching.Material;
|
visual.MinorLoss = matching.MinorLoss;
|
visual.BendingAngle = matching.BendingAngle;
|
if (matching.ElbowType.HasValue)
|
{
|
visual.ElbowType = HydroElbowTypeEnumHelper.GetElbowTypeName(matching.ElbowType.Value);
|
}
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingCaliber.HasValue)
|
{
|
visual.Caliber = matching.MatchingCaliber.Value;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
if (matching.MatchingBendingAngle.HasValue)
|
{
|
visual.BendingAngle = matching.MatchingBendingAngle.Value;
|
result = true;
|
}
|
if (matching.MatchingElbowType.HasValue)
|
{
|
visual.ElbowType = HydroElbowTypeEnumHelper.GetElbowTypeName(matching.MatchingElbowType.Value);
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 三通
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroThreelinkViewModel visualViewModel, HydroThreelinkMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroThreelinkInfo visual, HydroThreelinkMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Caliber = matching.Caliber;
|
visual.Material = matching.Material;
|
visual.MinorLoss = matching.MinorLoss;
|
visual.RunningThroughLoss = matching.RunningThroughLoss;
|
visual.BranchThroughLoss = matching.BranchThroughLoss;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingCaliber.HasValue)
|
{
|
visual.Caliber = matching.MatchingCaliber.Value;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
if (matching.MatchingRunningThroughLoss.HasValue)
|
{
|
visual.RunningThroughLoss = matching.MatchingRunningThroughLoss.Value;
|
result = true;
|
}
|
if (matching.MatchingBranchThroughLoss.HasValue)
|
{
|
visual.BranchThroughLoss = matching.MatchingBranchThroughLoss.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 四通
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroFourlinkViewModel visualViewModel, HydroFourlinkMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroFourlinkInfo visual, HydroFourlinkMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Caliber = matching.Caliber;
|
visual.Material = matching.Material;
|
visual.MinorLoss = matching.MinorLoss;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingCaliber.HasValue)
|
{
|
visual.Caliber = matching.MatchingCaliber.Value;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 喷头
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroNozzleViewModel visualViewModel, HydroNozzleMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroNozzleInfo visual, HydroNozzleMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Material = matching.Material;
|
visual.Caliber = matching.Caliber;
|
visual.MinorLoss = matching.MinorLoss;
|
visual.Coefficient = matching.Coefficient;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingCaliber.HasValue)
|
{
|
visual.Caliber = matching.MatchingCaliber.Value;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
if (matching.MatchingCoefficient.HasValue)
|
{
|
visual.Coefficient = matching.MatchingCoefficient.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 消火栓
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroHydrantViewModel visualViewModel, HydroHydrantMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroHydrantInfo visual, HydroHydrantMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Material = matching.Material;
|
visual.Caliber = matching.Caliber;
|
visual.MinorLoss = matching.MinorLoss;
|
visual.Coefficient = matching.Coefficient;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingCaliber.HasValue)
|
{
|
visual.Caliber = matching.MatchingCaliber.Value;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
if (matching.MatchingCoefficient.HasValue)
|
{
|
visual.Coefficient = matching.MatchingCoefficient.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 冷却塔
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroCoolingViewModel visualViewModel, HydroCoolingMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroCoolingInfo visual, HydroCoolingMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Material = matching.Material;
|
visual.Caliber = matching.Caliber;
|
visual.MinorLoss = matching.MinorLoss;
|
visual.Coefficient = matching.Coefficient;
|
visual.LowerLimit = matching.LowerLimit;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.ModelType}");
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.DbId}");
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingCaliber.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.Caliber), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.Caliber}");
|
visual.Caliber = matching.MatchingCaliber.Value;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.UpdatePropStatus(nameof(visual.Material), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.Material}");
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.MinorLoss), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.MinorLoss}");
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
if (matching.MatchingCoefficient.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.Coefficient), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.Coefficient}");
|
visual.Coefficient = matching.MatchingCoefficient.Value;
|
result = true;
|
}
|
if (matching.MatchingLowerLimit.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.LowerLimit), ePropStatus.Matching, $"通过基础数据匹配修复,原数据:{visual.LowerLimit}");
|
visual.LowerLimit = matching.MatchingLowerLimit.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 水表
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroMeterViewModel visualViewModel, HydroMeterMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroMeterInfo visual, HydroMeterMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.MinorLoss = matching.MinorLoss;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 流量计
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroFlowmeterViewModel visualViewModel, HydroFlowmeterMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroFlowmeterInfo visual, HydroFlowmeterMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.MinorLoss = matching.MinorLoss;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 压力表
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroPressmeterViewModel visualViewModel, HydroPressmeterMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPressmeterInfo visual, HydroPressmeterMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.MinorLoss = matching.MinorLoss;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 管道
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroPipeViewModel visualViewModel, HydroPipeMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPipeInfo visual, HydroPipeMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Material = matching.Material;
|
visual.Diameter = matching.Diameter;
|
visual.Roughness = matching.Roughness;
|
visual.MinorLoss = matching.MinorLoss;
|
|
bool result = false;
|
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingDiameter.HasValue)
|
{
|
visual.Diameter = matching.MatchingDiameter.Value;
|
result = true;
|
}
|
if (matching.MatchingRoughness.HasValue)
|
{
|
visual.Roughness = matching.MatchingRoughness.Value;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 过渡件
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroTranslationViewModel visualViewModel, HydroTranslationMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroTranslationInfo visual, HydroTranslationMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Material = matching.Material;
|
visual.Diameter = matching.Diameter;
|
visual.StartDiameter = matching.StartDiameter;
|
visual.EndDiameter = matching.EndDiameter;
|
visual.Roughness = matching.Roughness;
|
visual.MinorLoss = matching.MinorLoss;
|
|
bool result = false;
|
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingDiameter.HasValue)
|
{
|
visual.Diameter = matching.MatchingDiameter.Value;
|
result = true;
|
}
|
if (matching.MatchingStartDiameter.HasValue)
|
{
|
visual.StartDiameter = matching.MatchingStartDiameter.Value;
|
result = true;
|
}
|
if (matching.MatchingEndDiameter.HasValue)
|
{
|
visual.EndDiameter = matching.MatchingEndDiameter.Value;
|
result = true;
|
}
|
if (matching.MatchingRoughness.HasValue)
|
{
|
visual.Roughness = matching.MatchingRoughness.Value;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 水泵
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroPumpViewModel visualViewModel, HydroPumpMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroPumpInfo visual, HydroPumpMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.RatedQ = matching.RatedQ;
|
visual.RatedH = matching.RatedH;
|
visual.RatedP = matching.RatedP;
|
visual.RatedN = matching.RatedN;
|
visual.RatedHz = matching.RatedHz;
|
visual.SpeedRatio = matching.CurrentHz / visual.RatedHz;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, $"通过基础数据匹配修复,原始数据:{visual.ModelType}");
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, $"通过基础数据匹配修复,原始数据:{visual.DbId}");
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (matching.MatchingRatedQ.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.RatedQ), ePropStatus.Matching, $"通过基础数据匹配修复,原始数据:{visual.RatedQ}");
|
visual.RatedQ = matching.MatchingRatedQ.Value;
|
result = true;
|
}
|
if (matching.MatchingRatedH.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.RatedH), ePropStatus.Matching, $"通过基础数据匹配修复,原始数据:{visual.RatedH}");
|
visual.RatedH = matching.MatchingRatedH.Value;
|
result = true;
|
}
|
if (matching.MatchingRatedP.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.RatedP), ePropStatus.Matching, $"通过基础数据匹配修复,原始数据:{visual.RatedP}");
|
visual.RatedP = matching.MatchingRatedP.Value;
|
result = true;
|
}
|
if (matching.MatchingRatedN.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.RatedN), ePropStatus.Matching, $"通过基础数据匹配修复,原始数据:{visual.RatedN}");
|
visual.RatedN = matching.MatchingRatedN.Value;
|
result = true;
|
}
|
if (matching.MatchingRatedHz.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.RatedHz), ePropStatus.Matching, $"通过基础数据匹配修复,原始数据:{visual.RatedHz}");
|
visual.RatedHz = matching.MatchingRatedHz.Value;
|
result = true;
|
}
|
if (matching.MatchingCurrentHz.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.SpeedRatio), ePropStatus.Matching, $"通过基础数据匹配修复,原始数据:{visual.SpeedRatio}");
|
visual.SpeedRatio = matching.MatchingCurrentHz.Value / visual.RatedHz;
|
result = true;
|
}
|
|
if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
|
{
|
//流量扬程曲线
|
var curveqh = hydroInfo.Curves?.Find(x => x.Code == visual.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.HydroCurveType.CurveQH;
|
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);
|
visual.UpdatePropStatus(nameof(visual.CurveQH), ePropStatus.Matching, $"通过基础数据匹配修复");
|
visual.CurveQH = curveqh.Code;
|
result = true;
|
}
|
else
|
{
|
if (!curveqh.DbLocked)
|
{
|
curveqh.DbId = matching.MatchingCurveDbId;
|
curveqh.CurveData = matching.MatchingCurveQH?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
result = true;
|
}
|
}
|
|
//流量功率曲线
|
var curveqp = hydroInfo.Curves?.Find(x => x.Code == visual.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.HydroCurveType.CurveQP;
|
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);
|
visual.UpdatePropStatus(nameof(visual.CurveQP), ePropStatus.Matching, $"通过基础数据匹配修复");
|
visual.CurveQP = curveqp.Code;
|
result = true;
|
}
|
else
|
{
|
if (!curveqp.DbLocked)
|
{
|
curveqp.DbId = matching.MatchingCurveDbId;
|
curveqp.CurveData = matching.MatchingCurveQP?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
result = true;
|
}
|
}
|
|
//流量效率曲线
|
var curveqe = hydroInfo.Curves?.Find(x => x.Code == visual.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.HydroCurveType.CurveQE;
|
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);
|
visual.UpdatePropStatus(nameof(visual.CurveQE), ePropStatus.Matching, $"通过基础数据匹配修复");
|
visual.CurveQE = curveqe.Code;
|
result = true;
|
}
|
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;
|
}
|
|
#endregion
|
|
#region 阀门
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroValveViewModel visualViewModel, HydroValveMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroValveInfo visual, HydroValveMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Material = matching.Material;
|
visual.Diameter = matching.Diameter;
|
visual.MinorLoss = matching.MinorLoss;
|
visual.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.ValveType);
|
visual.ValveSetting = matching.ValveSetting;
|
|
bool result = false;
|
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.UpdatePropStatus(nameof(visual.Material), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingDiameter.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.Diameter), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.Diameter = matching.MatchingDiameter.Value;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.MinorLoss), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
if (matching.MatchingValveType.HasValue)
|
{
|
visual.UpdatePropStatus(nameof(visual.ValveType), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.MatchingValveType.Value);
|
result = true;
|
}
|
switch (visual.ValveType)
|
{
|
case Yw.Hydro.ValveType.PSV:
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
|
{
|
visual.UpdatePropStatus(nameof(visual.ValveSetting), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.ValveSetting = matching.MatchingValveSetting;
|
result = true;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.PBV:
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
|
{
|
visual.UpdatePropStatus(nameof(visual.ValveSetting), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.ValveSetting = matching.MatchingValveSetting;
|
result = true;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.PRV:
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
|
{
|
visual.UpdatePropStatus(nameof(visual.ValveSetting), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.ValveSetting = matching.MatchingValveSetting;
|
result = true;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.FCV:
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingValveSetting))
|
{
|
visual.UpdatePropStatus(nameof(visual.ValveSetting), ePropStatus.Matching, "通过基础数据匹配修复");
|
visual.ValveSetting = matching.MatchingValveSetting;
|
result = true;
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.TCV:
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
|
{
|
//阀门开度损失系数曲线
|
var curveol = hydroInfo.Curves?.Find(x => x.Code == visual.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 = visual.ModelType;
|
curveol.DbLocked = false;
|
curveol.DbId = matching.MatchingCurveDbId;
|
curveol.CurveType = Yw.WinFrmUI.HydroCurveType.CurveOL;
|
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);
|
visual.ValveSetting = curveol.Code;
|
result = true;
|
}
|
else
|
{
|
if (!curveol.DbLocked)
|
{
|
curveol.DbId = matching.MatchingCurveDbId;
|
curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
result = true;
|
}
|
}
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.GPV:
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
|
{
|
//水头损失曲线
|
var curveql = hydroInfo.Curves?.Find(x => x.Code == visual.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 = visual.ModelType;
|
curveql.DbLocked = false;
|
curveql.DbId = matching.MatchingCurveDbId;
|
curveql.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQL;
|
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);
|
visual.ValveSetting = curveql.Code;
|
result = true;
|
}
|
else
|
{
|
if (!curveql.DbLocked)
|
{
|
curveql.DbId = matching.MatchingCurveDbId;
|
curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
result = true;
|
}
|
}
|
}
|
}
|
break;
|
case Yw.Hydro.ValveType.CV:
|
{
|
|
}
|
break;
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 换热器
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroExchangerViewModel visualViewModel, HydroExchangerMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroExchangerInfo visual, HydroExchangerMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Material = matching.Material;
|
visual.Diameter = matching.Diameter;
|
visual.MinorLoss = matching.MinorLoss;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
result = true;
|
}
|
if (matching.MatchingDiameter.HasValue)
|
{
|
visual.Diameter = matching.MatchingDiameter.Value;
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
result = true;
|
}
|
|
if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
|
{
|
var curvevql = hydroInfo.Curves?.Find(x => x.Code == visual.CurveQL);
|
if (curvevql == null)
|
{
|
curvevql = new Yw.Model.HydroCurveInfo();
|
curvevql.Catalog = Yw.Hydro.ParterCatalog.Curve;
|
curvevql.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
|
curvevql.Name = "匹配";
|
curvevql.ModelType = string.Empty;
|
curvevql.DbLocked = false;
|
curvevql.DbId = matching.MatchingCurveDbId;
|
curvevql.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQL;
|
curvevql.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(curvevql);
|
visual.CurveQL = curvevql.Code;
|
result = true;
|
}
|
else
|
{
|
if (!curvevql.DbLocked)
|
{
|
curvevql.DbId = matching.MatchingCurveDbId;
|
curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
result = true;
|
}
|
}
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#region 空压机
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(HydroCompressorViewModel visualViewModel, HydroCompressorMatchingViewModel matching)
|
{
|
var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching);
|
visualViewModel.UpdateProperty();
|
return bol;
|
}
|
|
/// <summary>
|
/// 应用
|
/// </summary>
|
public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroCompressorInfo visual, HydroCompressorMatchingViewModel matching)
|
{
|
if (hydroInfo == null)
|
{
|
return false;
|
}
|
if (visual == null)
|
{
|
return false;
|
}
|
if (matching == null)
|
{
|
return false;
|
}
|
visual.Name = matching.Name;
|
visual.DbLocked = matching.DbLocked;
|
visual.DbId = matching.DbId;
|
visual.ModelType = matching.ModelType;
|
visual.Material = matching.Material;
|
visual.Diameter = matching.Diameter;
|
visual.MinorLoss = matching.MinorLoss;
|
|
bool result = false;
|
if (!visual.DbLocked)
|
{
|
if (!string.IsNullOrEmpty(matching.MatchingModelType))
|
{
|
visual.ModelType = matching.MatchingModelType;
|
visual.UpdatePropStatus(nameof(visual.ModelType), ePropStatus.Matching, "通过基础数据匹配修复");
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingDbId))
|
{
|
visual.DbId = matching.MatchingDbId;
|
visual.UpdatePropStatus(nameof(visual.DbId), ePropStatus.Matching, "通过基础数据匹配修复");
|
result = true;
|
}
|
if (!string.IsNullOrEmpty(matching.MatchingMaterial))
|
{
|
visual.Material = matching.MatchingMaterial;
|
visual.UpdatePropStatus(nameof(visual.Material), ePropStatus.Matching, "通过基础数据匹配修复");
|
result = true;
|
}
|
if (matching.MatchingDiameter.HasValue)
|
{
|
visual.Diameter = matching.MatchingDiameter.Value;
|
visual.UpdatePropStatus(nameof(visual.Diameter), ePropStatus.Matching, "通过基础数据匹配修复");
|
result = true;
|
}
|
if (matching.MatchingMinorLoss.HasValue)
|
{
|
visual.MinorLoss = matching.MatchingMinorLoss.Value;
|
visual.UpdatePropStatus(nameof(visual.MinorLoss), ePropStatus.Matching, "通过基础数据匹配修复");
|
result = true;
|
}
|
|
if (!string.IsNullOrEmpty(matching.MatchingCurveDbId))
|
{
|
var curvevql = hydroInfo.Curves?.Find(x => x.Code == visual.CurveQL);
|
if (curvevql == null)
|
{
|
curvevql = new Yw.Model.HydroCurveInfo();
|
curvevql.Catalog = Yw.Hydro.ParterCatalog.Curve;
|
curvevql.Code = Yw.Untity.UniqueHelper.CreateFromFirst("curve", hydroInfo.GetAllParterCodes());
|
curvevql.Name = "匹配";
|
curvevql.ModelType = string.Empty;
|
curvevql.DbLocked = false;
|
curvevql.DbId = matching.MatchingCurveDbId;
|
curvevql.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQL;
|
curvevql.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(curvevql);
|
visual.CurveQL = curvevql.Code;
|
result = true;
|
}
|
else
|
{
|
if (!curvevql.DbLocked)
|
{
|
curvevql.DbId = matching.MatchingCurveDbId;
|
curvevql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList();
|
result = true;
|
}
|
}
|
}
|
}
|
return result;
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
}
|
}
|