| | |
| | | using Yw.Hydro; |
| | | using Yw.Ahart; |
| | | using Yw.Hydro; |
| | | using Yw.Model; |
| | | |
| | | namespace Yw.WinFrmUI |
| | |
| | | //visual.DbLocked = matching.DbLocked; |
| | | //visual.DbId = matching.DbId; |
| | | //visual.ModelType = matching.ModelType; |
| | | //if (matching.TranslationType.HasValue) |
| | | //{ |
| | | // visual.TranslationType = HydroTranslationTypeEnumHelper.GetTranslationTypeName(matching.TranslationType.Value); |
| | | //} |
| | | //visual.Material = matching.Material; |
| | | //visual.Diameter = matching.Diameter; |
| | | //visual.StartDiameter = matching.StartDiameter; |
| | | //visual.EndDiameter = matching.EndDiameter; |
| | | //visual.Roughness = matching.Roughness; |
| | |
| | | propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改"); |
| | | } |
| | | visual.DbId = matching.MatchingDbId; |
| | | result = true; |
| | | } |
| | | if (matching.MatchingTranslationType.HasValue) |
| | | { |
| | | var translationType = HydroTranslationTypeEnumHelper.GetTranslationTypeName(matching.MatchingTranslationType.Value); |
| | | if (visual.TranslationType != translationType) |
| | | { |
| | | changeHelper?.Append(visual, eChangeType.Update); |
| | | propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.TranslationType), ePropStatus.Normal, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改"); |
| | | } |
| | | visual.TranslationType = translationType; |
| | | result = true; |
| | | } |
| | | if (!string.IsNullOrEmpty(matching.MatchingMaterial)) |
| | |
| | | /// <summary> |
| | | /// 应用 |
| | | /// </summary> |
| | | public static bool Apply(HydroValveViewModel visualViewModel, HydroValveMatchingViewModel matching) |
| | | public static bool Apply |
| | | ( |
| | | HydroValveViewModel visualViewModel, |
| | | HydroValveMatchingViewModel matching, |
| | | HydroChangeHelper changeHelper = null, |
| | | HydroPropStatusHelper propStatusHelper = null |
| | | ) |
| | | { |
| | | var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching); |
| | | var bol = Apply(visualViewModel.HydroInfo, visualViewModel.Vmo, matching, changeHelper, propStatusHelper); |
| | | visualViewModel.UpdateProperty(); |
| | | return bol; |
| | | } |
| | |
| | | /// <summary> |
| | | /// 应用 |
| | | /// </summary> |
| | | public static bool Apply(Yw.Model.HydroModelInfo hydroInfo, Yw.Model.HydroValveInfo visual, HydroValveMatchingViewModel matching) |
| | | public static bool Apply |
| | | ( |
| | | Yw.Model.HydroModelInfo hydroInfo, |
| | | Yw.Model.HydroValveInfo visual, |
| | | HydroValveMatchingViewModel matching, |
| | | HydroChangeHelper changeHelper = null, |
| | | HydroPropStatusHelper propStatusHelper = null |
| | | ) |
| | | { |
| | | if (hydroInfo == 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; |
| | | //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 (!string.IsNullOrEmpty(matching.MatchingModelType)) |
| | | { |
| | | if (visual.ModelType != matching.MatchingModelType) |
| | | { |
| | | changeHelper?.Append(visual, eChangeType.Update); |
| | | propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.ModelType), ePropStatus.Matching, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改"); |
| | | } |
| | | visual.ModelType = matching.MatchingModelType; |
| | | result = true; |
| | | } |
| | | if (!string.IsNullOrEmpty(matching.MatchingDbId)) |
| | | { |
| | | if (visual.DbId != matching.MatchingDbId) |
| | | { |
| | | changeHelper?.Append(visual, eChangeType.Update); |
| | | propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.DbId), ePropStatus.Matching, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改"); |
| | | } |
| | | visual.DbId = matching.MatchingDbId; |
| | | result = true; |
| | | } |
| | | if (!string.IsNullOrEmpty(matching.MatchingMaterial)) |
| | | { |
| | | if (visual.Material != matching.MatchingMaterial) |
| | | { |
| | | changeHelper?.Append(visual, eChangeType.Update); |
| | | propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Material), ePropStatus.Matching, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改"); |
| | | } |
| | | visual.Material = matching.MatchingMaterial; |
| | | result = true; |
| | | } |
| | | if (matching.MatchingDiameter.HasValue) |
| | | { |
| | | if (visual.Diameter != matching.MatchingDiameter.Value) |
| | | { |
| | | changeHelper?.Append(visual, eChangeType.Update); |
| | | propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.Diameter), ePropStatus.Matching, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改"); |
| | | } |
| | | visual.Diameter = matching.MatchingDiameter.Value; |
| | | result = true; |
| | | } |
| | | if (matching.MatchingMinorLoss.HasValue) |
| | | { |
| | | if (visual.MinorLoss != matching.MatchingMinorLoss.Value) |
| | | { |
| | | changeHelper?.Append(visual, eChangeType.Update); |
| | | propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.MinorLoss), ePropStatus.Matching, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改"); |
| | | } |
| | | visual.MinorLoss = matching.MatchingMinorLoss.Value; |
| | | result = true; |
| | | } |
| | | if (matching.MatchingValveType.HasValue) |
| | | if (!string.IsNullOrEmpty(matching.MatchingCurveDbId)) |
| | | { |
| | | visual.ValveType = HydroValveTypeEnumHelper.GetValveTypeCode(matching.MatchingValveType.Value); |
| | | result = true; |
| | | } |
| | | switch (visual.ValveType) |
| | | { |
| | | case Yw.Hydro.ValveType.PSV: |
| | | //开度损失曲线 |
| | | var curveol = hydroInfo.Curves?.Find(x => x.Code == visual.CurveOL); |
| | | 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 = string.Empty; |
| | | curveol.DbLocked = false; |
| | | curveol.DbId = matching.MatchingCurveDbId; |
| | | curveol.CurveType = Yw.WinFrmUI.HydroCurveType.CurveOL; |
| | | curveol.CurveFactor = null; |
| | | curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); |
| | | if (hydroInfo.Curves == null) |
| | | { |
| | | if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) |
| | | { |
| | | //visual.ValveSetting = matching.MatchingValveSetting; |
| | | //result = true; |
| | | } |
| | | hydroInfo.Curves = new List<Yw.Model.HydroCurveInfo>(); |
| | | } |
| | | break; |
| | | case Yw.Hydro.ValveType.PBV: |
| | | hydroInfo.Curves.Add(curveol); |
| | | visual.CurveOL = curveol.Code; |
| | | changeHelper?.Append(curveol, eChangeType.Add); |
| | | changeHelper?.Append(visual, eChangeType.Update); |
| | | propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurveOL), ePropStatus.Matching, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改"); |
| | | result = true; |
| | | } |
| | | else |
| | | { |
| | | if (!curveol.DbLocked) |
| | | { |
| | | if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) |
| | | { |
| | | //visual.ValveSetting = matching.MatchingValveSetting; |
| | | result = true; |
| | | } |
| | | curveol.DbId = matching.MatchingCurveDbId; |
| | | curveol.CurveData = matching.MatchingCurveOL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); |
| | | changeHelper?.Append(curveol, eChangeType.Update); |
| | | result = true; |
| | | } |
| | | break; |
| | | case Yw.Hydro.ValveType.PRV: |
| | | { |
| | | if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) |
| | | { |
| | | //visual.ValveSetting = matching.MatchingValveSetting; |
| | | result = true; |
| | | } |
| | | } |
| | | break; |
| | | case Yw.Hydro.ValveType.FCV: |
| | | { |
| | | if (!string.IsNullOrEmpty(matching.MatchingValveSetting)) |
| | | { |
| | | //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.CurveType = Yw.WinFrmUI.HydroCurveType.CurveOL; |
| | | // 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.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQL; |
| | | // curveql.CurveData = matching.MatchingCurveQL?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); |
| | | // result = true; |
| | | // } |
| | | //} |
| | | } |
| | | } |
| | | break; |
| | | case Yw.Hydro.ValveType.CV: |
| | | { |
| | | } |
| | | |
| | | //水头损失曲线 |
| | | if (matching.MatchingCurvesQL != null && matching.MatchingCurvesQL.Count > 0) |
| | | { |
| | | if (visual.CurvesQL == null) |
| | | { |
| | | visual.CurvesQL = new List<string>(); |
| | | } |
| | | break; |
| | | var curvesql = new List<string>(); |
| | | var matchingCurvesQL = matching.MatchingCurvesQL.OrderBy(x => x.CurveFactor).ToList(); |
| | | foreach (var matchingCurveQL in matchingCurvesQL) |
| | | { |
| | | var curveql = hydroInfo.Curves?.Find(x => visual.CurvesQL.Contains(x.Code) && x.CurveFactor.HasValue && x.CurveFactor.Value == matchingCurveQL.CurveFactor); |
| | | 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 = string.Empty; |
| | | curveql.DbLocked = false; |
| | | curveql.DbId = matching.MatchingCurveDbId; |
| | | curveql.CurveType = Yw.WinFrmUI.HydroCurveType.CurveQL; |
| | | curveql.CurveFactor = matchingCurveQL.CurveFactor; |
| | | curveql.CurveData = matchingCurveQL.CurveData?.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); |
| | | changeHelper?.Append(curveql, eChangeType.Add); |
| | | result = true; |
| | | } |
| | | else |
| | | { |
| | | if (!curveql.DbLocked) |
| | | { |
| | | curveql.DbId = matching.MatchingCurveDbId; |
| | | curveql.CurveFactor = matchingCurveQL.CurveFactor; |
| | | curveql.CurveData = matchingCurveQL.CurveData?.Select(x => new Yw.Model.Hydro.CurvePoint(x.X, x.Y)).ToList(); |
| | | changeHelper?.Append(curveql, eChangeType.Update); |
| | | result = true; |
| | | } |
| | | } |
| | | curvesql.Add(curveql.Code); |
| | | } |
| | | visual.CurvesQL = curvesql; |
| | | changeHelper?.Append(visual, eChangeType.Update); |
| | | propStatusHelper?.UpdatePropStatus(visual.Code, nameof(visual.CurvesQL), ePropStatus.Matching, $"{DateTime.Now.ToStandardString()}通过产品配置匹配修改"); |
| | | } |
| | | } |
| | | } |
| | | return result; |