ningshuxia
2025-04-16 a67da735b33be01b24845ce03ae7551cf55ddbbc
02-desktop/WinFrmUI/IStation.WinFrmUI.Monitor/03-WorkingConditionAnalysis/05-ModelCorrectionCombine/ModelCorrectionCombinePage.cs
@@ -19,44 +19,44 @@
        public ModelCorrectionCombinePage()
        {
            InitializeComponent();
            this.PageTitle.Caption = "模型修正组合";
            PageTitle.Caption = "模型修正组合";
            this.gridView1.SetNormalView();
            this.gridView2.SetNormalView();
            this.gridView3.SetNormalView();
            gridView1.SetNormalView();
            gridView2.SetNormalView();
            gridView3.SetNormalView();
            this.colHz.Visible = false;
            this.colRpm.Visible = false;
            this.colWaterLevel.Visible = false;
            colHz.Visible = false;
            colRpm.Visible = false;
            colWaterLevel.Visible = false;
            this.repositoryItemDateEdit1.SetOnlyShowYearMonth();
            this.repositoryItemDateEdit2.SetOnlyShowYearMonth();
            this.barEditDateStart.EditValue = new DateTime(2024, 1, 1);
            this.barEditDateEnd.EditValue = new DateTime(2024, 9, 1);
            this.cmbFlag.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            this.barCekUseFlow.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            repositoryItemDateEdit1.SetOnlyShowYearMonth();
            repositoryItemDateEdit2.SetOnlyShowYearMonth();
            barEditDateStart.EditValue = new DateTime(2024, 1, 1);
            barEditDateEnd.EditValue = new DateTime(2024, 9, 1);
            this.stationListCtrl1.FocusedChangedEvent += StationListCtrl1_FocusedChangedEvent;
            this.monitorDataSourcesTreeList1.FocusedChangedEvent += MonitorDataSourcesListCtrl1_FocusedChangedEvent;
            this.timeValueSwiftPlotChartView1.SetTimeAxisX(DevExpress.XtraCharts.DateTimeMeasureUnit.Minute);
            cmbFlag.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            barCekUseFlow.Visibility = DevExpress.XtraBars.BarItemVisibility.Never;
            stationListCtrl1.FocusedChangedEvent += StationListCtrl1_FocusedChangedEvent;
            monitorDataSourcesTreeList1.FocusedChangedEvent += MonitorDataSourcesListCtrl1_FocusedChangedEvent;
            timeValueSwiftPlotChartView1.SetTimeAxisX(DevExpress.XtraCharts.DateTimeMeasureUnit.Minute);
            InitialDiagarm();
        }
        private Series _series_default_head; //
        private Series _series_curve_head; //
        private Series _series_correct_curve_head; // 
        private double _min_flow = 0;
        private double _min_flow = 0;
        private double _max_flow = 100000;
        private double _space_flow = 500;
        private void InitialDiagarm()
        {
            this.chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;//是否在图表上显示图例
            chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;//是否在图表上显示图例
            var diagram = (SwiftPlotDiagram)this.chartControl1.Diagram;
            var diagram = (SwiftPlotDiagram)chartControl1.Diagram;
            diagram.EnableAxisXScrolling = true;//X轴是否允许滚动
            diagram.EnableAxisXZooming = true;//X轴是否允许缩放
            diagram.PaneLayout.Direction = PaneLayoutDirection.Vertical;//窗格的对齐方式 
@@ -135,7 +135,7 @@
        }
        public class ModelDiffViewModel
        {
        {
            [Display(Name = "时间")]
            public DateTime Date { get; set; }
@@ -209,18 +209,18 @@
            public void Round()
            {
                if (this.STDP.HasValue)
                if (STDP.HasValue)
                {
                    this.STDP = Math.Round(this.STDP.Value, 5);
                    STDP = Math.Round(STDP.Value, 5);
                }
                if (this.STDPHead.HasValue)
                if (STDPHead.HasValue)
                {
                    this.STDPHead = Math.Round(this.STDPHead.Value, 5);
                    STDPHead = Math.Round(STDPHead.Value, 5);
                }
            }
        }
        #endregion
@@ -230,12 +230,12 @@
        private List<Model.Equipment<Model.Pump>> _pump_list = null;
        private List<ModelDiffViewModel> _model_diff_vm_list = null;
        private List<ModelCombineViewModel> _model_combine_list=null;
        private List<ModelCombineViewModel> _model_combine_list = null;
        private List<ModelCombineDiffViewModel> _model_combine_diff_vm_list = null;
        private List<PumpViewModel> _pump_vm_list = null;
        private string _model_file = System.IO.Path.Combine
            (Settings.File.RootDirectory, Settings.File.DataFolder, "ch2_v3_20240801(Clear).inp");
            (SettingsD.File.RootDirectory, SettingsD.File.DataFolder, "ch2_v3_20240801(Clear).inp");
        /// <summary>
        /// 清空数据
@@ -245,12 +245,12 @@
            _pump_vm_list = new List<PumpViewModel>();
            _model_diff_vm_list = new List<ModelDiffViewModel>();
            _model_combine_list = new List<ModelCombineViewModel>();
            _model_combine_diff_vm_list=new List<ModelCombineDiffViewModel> ();
            this.cmbFlag.SelectedItem = null;
            this.cmbFlag.Properties.Items.Clear();
            this.modelTimeViewModelBindingSource.DataSource = new List<ModelDiffViewModel>();
            this.modelCombineDiffViewModelBindingSource.DataSource = new List<ModelCombineDiffViewModel>();
            this.pumpViewModelBindingSource.DataSource = new List<PumpViewModel>();
            _model_combine_diff_vm_list = new List<ModelCombineDiffViewModel>();
            cmbFlag.SelectedItem = null;
            cmbFlag.Properties.Items.Clear();
            modelTimeViewModelBindingSource.DataSource = new List<ModelDiffViewModel>();
            modelCombineDiffViewModelBindingSource.DataSource = new List<ModelCombineDiffViewModel>();
            pumpViewModelBindingSource.DataSource = new List<PumpViewModel>();
            ClearChart();
        }
@@ -258,11 +258,11 @@
        private void ClearChart()
        {
            this.chartControl1.BeginInit();
            chartControl1.BeginInit();
            _series_default_head.Points.Clear();
            _series_curve_head.Points.Clear();
            _series_correct_curve_head.Points.Clear();
            this.chartControl1.EndInit();
            chartControl1.EndInit();
        }
        /// <summary>
@@ -270,8 +270,8 @@
        /// </summary>
        public override void InitialDataSource()
        {
            this.stationListCtrl1.SetBindingData();
            this.monitorDataSourcesTreeList1.SetBindingData();
            stationListCtrl1.SetBindingData();
            monitorDataSourcesTreeList1.SetBindingData();
        }
        //泵站变换
@@ -305,15 +305,15 @@
            {
                return;
            }
            if (this.barCekLoad.Checked)
            if (barCekLoad.Checked)
            {
                return;
            }
            var station_index = station.SortCode;
            var dt_start = Convert.ToDateTime(this.barEditDateStart.EditValue);
            var dt_end = Convert.ToDateTime(this.barEditDateEnd.EditValue);
            var dt_start = Convert.ToDateTime(barEditDateStart.EditValue);
            var dt_end = Convert.ToDateTime(barEditDateEnd.EditValue);
            var packets = _bll.Get(monitorDataSources.ID, station.ID);
            packets = packets?.Where(x => (x.Year >= dt_start.Year && x.Year <= dt_end.Year) && (x.Month >= dt_start.Month && x.Month <= dt_end.Month)).ToList();
            if (packets == null || !packets.Any())
@@ -326,7 +326,7 @@
            }
            var flag_pump_dict = _pump_list.ToDictionary(x => x.SortCode, x => x.RatedParas);
            var flag_list = _pump_list.Select(x => x.SortCode).OrderBy(x => x).ToList();
            this.cmbFlag.Properties.Items.AddRange(flag_list);
            cmbFlag.Properties.Items.AddRange(flag_list);
            var record_list = packets.SelectMany(x => x.StationSignalRecords).ToList();
            var root_folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "分析");
@@ -339,7 +339,7 @@
            }
            SetBindingData(_model_file, station.SortCode,flag_pump_dict, record_list, ana_factor_list, this.barCekUseAnalysisFactor.Checked);
            SetBindingData(_model_file, station.SortCode, flag_pump_dict, record_list, ana_factor_list, barCekUseAnalysisFactor.Checked);
        }
@@ -377,8 +377,8 @@
            var curve_point_count = 100;
            var flag_qh_curve_dict = GetFlagCurveDict();
            var pipe_flow_id_list = GlobalHelper.GetPipeFlowIdList(station_index);
            var pipe_pressure_id_list=GlobalHelper.GetPipePressureIdList(station_index);
            var pipe_flow_id_list = GlobalHelperW.GetPipeFlowIdList(station_index);
            var pipe_pressure_id_list = GlobalHelperW.GetPipePressureIdList(station_index);
            var pump_model_mapping_list = AnalysisHelper.GetPumpModelMappingList();
            var model_mapping_list = AnalysisHelper.GetStationMappingList();
@@ -449,9 +449,8 @@
                    continue;
                pattern_id_dict.Add(id, index);
            }
            var run_flags = new List<int>() { 22, 23, 25 };
             
            var vm_list = new List<PumpViewModel>();
            var vm_combine_list = new List<ModelCombineViewModel>();
            var vm_diff_list = new List<ModelDiffViewModel>();
@@ -483,7 +482,7 @@
                }
                var time = station_record.Time.ToString("G");
                var time = station_record.Time.ToString("G");
                var pump_record_list = station_record.PumpSignalRecords;
                var total_flow = station_record.TotalFlow;
                var total_pressure = station_record.TotalPressure;
@@ -509,14 +508,14 @@
                //{
                //    continue;
                //}
                //if (station_record.Time > new DateTime(2024,4,29)&& station_record.Time < new DateTime(2024, 5, 15))
                //{
                //    continue;
                //}
                var pump_run_flags = pump_record_list.Select(x=>x.Flag).OrderBy(x=>x).ToList();
                var pump_run_flags = pump_record_list.Select(x => x.Flag).OrderBy(x => x).ToList();
                if (pump_record_list.Exists(x => x.Flag != 15 && x.Flag != 16 && x.Rpm < 1))
                {
                    continue;
@@ -530,10 +529,10 @@
                if (pump_record_list.Exists(x => x.OutletPressure > 50))
                {
                    continue;
                }
                }
                if (ana_factor_list != null && ana_factor_list.Any() && use_ana_factor)
                {
                {
                    foreach (var pump_record in pump_record_list)
                    {
                        var flag = pump_record.Flag;
@@ -611,7 +610,7 @@
                var vm_combine = new ModelCombineViewModel();
                vm_combine.Time = time;
                vm_combine.RunFlags = IStation.Untity.IntListHelper.ToString(flags);
                vm_combine.ModelDeviation = new  List<Tuple<int, double, double>>();
                vm_combine.ModelDeviation = new List<Tuple<int, double, double>>();
                vm_combine_list.Add(vm_combine);
                foreach (var pump_record in pump_record_list)
@@ -778,26 +777,26 @@
            //SetBindingData(vm_diff_list);
            _model_diff_vm_list = vm_diff_list;
            this.modelTimeViewModelBindingSource.DataSource = _model_diff_vm_list;
            this.modelTimeViewModelBindingSource.ResetBindings(false);
            this.gridView3.BestFitColumns();
            modelTimeViewModelBindingSource.DataSource = _model_diff_vm_list;
            modelTimeViewModelBindingSource.ResetBindings(false);
            gridView3.BestFitColumns();
            _pump_vm_list = vm_list;
            this.pumpViewModelBindingSource.DataSource = vm_list;
            this.pumpViewModelBindingSource.ResetBindings(false);
            this.gridView1.BestFitColumns();
            pumpViewModelBindingSource.DataSource = vm_list;
            pumpViewModelBindingSource.ResetBindings(false);
            gridView1.BestFitColumns();
            _model_combine_diff_vm_list = vm_combine_diff_list;
            this.modelCombineDiffViewModelBindingSource.DataSource = vm_combine_diff_list;
            this.modelCombineDiffViewModelBindingSource.ResetBindings(false);
            this.gridView2.BestFitColumns();
            modelCombineDiffViewModelBindingSource.DataSource = vm_combine_diff_list;
            modelCombineDiffViewModelBindingSource.ResetBindings(false);
            gridView2.BestFitColumns();
        }
        private void SetBindingData(List<ModelDiffViewModel> vm_list)
        {
            this.timeValueSwiftPlotChartView1.ClearSeries();
            timeValueSwiftPlotChartView1.ClearSeries();
            if (vm_list == null || !vm_list.Any())
            {
                return;
@@ -818,8 +817,8 @@
                //var scada_pressure_list = item.Select(x => new TimeValue(x.Date, x.ScadaPressure)).ToList();
                //var model_pressure_list = item.Select(x => new TimeValue(x.Date, x.MonitorPressure)).ToList();
                var pressure_diff_list = item.Where(x=>!(Math.Abs(x.PressureDiff) > 2)).Select(x => new TimeValue(x.Date, x.PressureDiff)).ToList();
                var pressure_diff_list = item.Where(x => !(Math.Abs(x.PressureDiff) > 2)).Select(x => new TimeValue(x.Date, x.PressureDiff)).ToList();
                //this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(监测流量)", "流量", scada_flow_list);
                //this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(模型流量)", "流量", model_flow_list);
                //this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(偏差流量)", "流量", flow_diff_list);
@@ -827,7 +826,7 @@
                // this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(监测压力)", "压力", scada_pressure_list);
                //this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(模型压力)", "压力", model_pressure_list);
                this.timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(偏差压力)", "压力", pressure_diff_list);
                timeValueSwiftPlotChartView1.AddSwiftPlotSeries(name, color, name + "(偏差压力)", "压力", pressure_diff_list);
            }
        }
@@ -909,7 +908,7 @@
            {
                return;
            }
            if (!int.TryParse(this.cmbFlag.Text, out int flag))
            if (!int.TryParse(cmbFlag.Text, out int flag))
            {
                return;
            }
@@ -918,7 +917,7 @@
            {
                return;
            }
            this.chartControl1.BeginInit();
            chartControl1.BeginInit();
            foreach (var vm in vm_list)
            {
                var time = vm.Time;
@@ -932,7 +931,7 @@
                _series_correct_curve_head.Points.Add(new SeriesPoint(time, Math.Round(diff, 2)));
            }
            this.chartControl1.EndInit();
            chartControl1.EndInit();
        }
@@ -969,7 +968,7 @@
            WaitFrmHelper.ShowWaitForm("正在导出");
            var run_flags_flow_pressure_diff_dict = _model_combine_list
                .Select(x => new Tuple<string, double, List<Tuple<int, double, double>>>(x.RunFlags, x.ScadaTotalFlow, x.ModelDeviation))
                .ToList();
                .ToList();
            var bol = AnalysisHelper.SaveAnalysisDeviationDtoList(_station.SortCode, _pump_list, run_flags_flow_pressure_diff_dict, _min_flow, _max_flow, _space_flow);
            if (!bol)
            {
@@ -979,7 +978,7 @@
            WaitFrmHelper.HideWaitForm();
            AlertTool.ShowInfo(System.Windows.Forms.Application.OpenForms[0], "提示", "导出完成!");
        }
        }
    }