duheng
8 天以前 4de480ec624d3b79ca690dc906e10cd2fbdc9be7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using DevExpress.XtraCharts;
using DevExpress.XtraEditors; 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace IStation.WinFrmUI.River
{
    public partial class RiverWaterLevelDropByFlowCtrl : XtraUserControl
    {
        public RiverWaterLevelDropByFlowCtrl()
        {
            InitializeComponent();
           
            //this.mainChart.BoxSelCompleteEvent += TimeValueEasyChartView1_BoxSelCompleteEvent;
        }
        public class ChartViewModel
        {
            public double Flow { get; set; }
            public double RiverHeight { get; set; }
            public double BoxHeight { get; set; }
            public double Drop  { get; set; } 
        }
 
 
        List<ChartViewModel> _allBindList1 = null;
 
        List<Model.RiverWaterLevelDrop> _listRiverWaterLevelDrop = null;
        List<Model.MonthSignalRecordPacket> _allPacketList = null;
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<Model.MonthSignalRecordPacket> allPacketList)
        {
            this._allPacketList = allPacketList;
            //var monitorPoints = new BLL.MonitorPoint().GetAll();
 
            //if (monitorPoints!=null&&monitorPoints.Any())
            //{
            //    var cjsw = monitorPoints.Find(x=>x.TagName== "_0402010205002020001");
            //    var chqsk= monitorPoints.Find(x => x.TagName == "_0402010204089903001");
 
 
            //   // var records = new BLL.MonitorDataSet().GetSignalRecordPacket();
            //}
            if (_allBindList1 == null)
                _allBindList1 = new List<ChartViewModel>();
            else
                _allBindList1.Clear();
 
 
            _listRiverWaterLevelDrop = IStation.AnaGlobalParas.RiverWaterLevelDropList;
 
 
 
            foreach (var packet in _allPacketList)
            {
                foreach (var r in packet.StationSignalRecords)
                {
                    if (r.PumpRunCount <= 0) continue;
                    if (r.ChangJiangWL == null) continue;
                    if (r.QianChiWL == null) continue;
                    if (r.ChangJiangWL <= -100) continue;
                    if (r.QianChiWL <= -100) continue;
 
                    var b = new ChartViewModel()
                    {
                        RiverHeight = r.ChangJiangWL.Value,
                        BoxHeight = r.QianChiWL.Value,
                    };
                    b.Drop = Math.Round(b.RiverHeight - b.BoxHeight, 2);
                    if (b.Drop > 8.5) continue;
                    foreach (var p in r.PumpSignalRecords)
                        b.Flow += p.FlowRate == null ? 0 : p.FlowRate.Value;
 
                    if (b.Flow < 20000)
                        continue;
                    b.Flow = (int)(b.Flow / 1000) * 1000;
 
                    _allBindList1.Add(b);
 
                }
            }
 
 
 
 
 
            this.bindingSourceChart.DataSource = _allBindList1;
 
 
 
 
 
            if (_listRiverWaterLevelDrop == null || _listRiverWaterLevelDrop.Count() == 0)
            {
 
            }
            else
            {
                this.bindingSourceGrid.DataSource = _listRiverWaterLevelDrop;
            }
 
 
        }
 
        private void groupControl1_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
        {
            BLL.RiverWaterLevelDrop.SaveList(_listRiverWaterLevelDrop);
            MessageBox.Show("已保存");
        }
 
        private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            this.bindingSourceGrid.ResetBindings(false);
        }
    }
 
}