| | |
| | | |
| | | DateTime DateTime; //api查询需要的日期 |
| | | DateTime ListDayTime; //listBox当前选择的日期 |
| | | DateTime HistoryTime=new DateTime(); |
| | | DateTime HistoryTime = new DateTime(); |
| | | List<CurrentModel> _CurrentModel = new List<CurrentModel>(); |
| | | PumpRunHelper _PumpRunHelper = new PumpRunHelper(); |
| | | CalcModel.AnaPrj _Ana = null; //方案数据 |
| | | Model.RunParasData _LastYeay = null; //去年同期 |
| | | Model.RunParasData _CurrentData = null; //实际数据 |
| | | List<PumpWater> _HistorypumpWater = new List<PumpWater>(); //历史参数日期重构 |
| | | bool isChage=true; |
| | | bool isChage = true; |
| | | |
| | | |
| | | List<Model.PumpWater> _CurrentPumpWater =new List<PumpWater>(); //实际参数日期重构 |
| | | List<Model.PumpWater> _CurrentPumpWater = new List<PumpWater>(); //实际参数日期重构 |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | /// <param name="datetime"></param> |
| | | public void SetBindingData(DateTime datetime) |
| | | { |
| | | /* PumpHistoryDataFileHelper pumpHistoryDataFileHelper = new PumpHistoryDataFileHelper(); |
| | | pumpHistoryDataFileHelper.GetHistoryData();*/ |
| | | /* PumpHistoryDataFileHelper pumpHistoryDataFileHelper = new PumpHistoryDataFileHelper(); |
| | | pumpHistoryDataFileHelper.GetHistoryData();*/ |
| | | WaitFrmHelper.ShowWaitForm(); |
| | | ListDayTime = datetime; |
| | | if (isChage) { SetTextToCheckBtn(datetime); } |
| | | if (checkEditCalendar.SelectedIndex == 0) |
| | | if (checkEditCalendar.SelectedIndex == 0) |
| | | { |
| | | DateTime = datetime.AddDays(-366); |
| | | } |
| | |
| | | { |
| | | _LastYeay = _PumpRunHelper.GetByHistoryOneData(DateTime, out string error); |
| | | } |
| | | _CurrentData = _PumpRunHelper.GetPumpRunParasOneDay(DateTime, out string err); //实际数据 |
| | | _CurrentData = _PumpRunHelper.GetPumpRunParasOneDay(DateTime, out string err); //实际数据 |
| | | MergeCurrentModel(_Ana, _LastYeay, _CurrentData);//girdview合并数据 |
| | | SetHistoryPumpWaterParas(new DateTime(datetime.Year, datetime.Month, datetime.Day)); //历史取水量 |
| | | SetCurretnPumpWaterParas(new DateTime(datetime.Year, datetime.Month, datetime.Day)); //实际取水量 |
| | |
| | | SeriesCurrent.Points.Add(new SeriesPoint(item.DateTime, Math.Round(item.TotalEle), 2)); |
| | | } |
| | | } |
| | | if (_Ana != null&& isSetData) |
| | | if (_Ana != null && isSetData) |
| | | { |
| | | foreach (var item in _Ana.PointTimes) |
| | | foreach (var bt in _Ana.BlockTimes) |
| | | { |
| | | SeriesAna.Points.Add(new SeriesPoint(item.Time, Math.Round(item.SumPower), 2)); |
| | | foreach (var item in bt.PointTimes) |
| | | { |
| | | SeriesAna.Points.Add(new SeriesPoint(item.Time, Math.Round(item.SumPower), 2)); |
| | | } |
| | | } |
| | | } |
| | | if (SeriesHistory.Points.Count == 0) |
| | |
| | | this.checkEditCalendar.Properties.Items.Add($"阴历({ConvertDateTime(dateTime).ToString("yyyy-MM-dd")})"); |
| | | this.checkEditCalendar.Properties.Items.Add("自定义选择时间"); |
| | | this.checkEditCalendar.SelectedIndex = 0; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | //修改自定义时间 |
| | | private void EditComBom(DateTime dateTime) |
| | | { |
| | | isChage=false; |
| | | isChage = false; |
| | | this.checkEditCalendar.Properties.Items.RemoveAt(2); |
| | | this.checkEditCalendar.Properties.Items.Add($"自定义时间{dateTime}"); |
| | | HistoryTime = dateTime; |
| | |
| | | |
| | | |
| | | //农历阴历日期转换 |
| | | private DateTime ConvertDateTime(DateTime lastYearDay) |
| | | private DateTime ConvertDateTime(DateTime lastYearDay) |
| | | { |
| | | // lastYearDay = new DateTime(2024, 4, 8); |
| | | // lastYearDay = new DateTime(2024, 4, 8); |
| | | //lastYearDay = lastYearDay.AddYears(-1); |
| | | // 创建一个 ChineseLunisolarCalendar 实例 |
| | | ChineseLunisolarCalendar chineseCalendar = new ChineseLunisolarCalendar(); |
| | | int thisYear = chineseCalendar.GetYear(lastYearDay); |
| | | int thisMonth = chineseCalendar.GetMonth(lastYearDay); |
| | | int thisDay = chineseCalendar.GetDayOfMonth(lastYearDay); |
| | | |
| | | // DateTime lastYearLunarDate = new DateTime(thisYear, thisMonth, thisDay, 0, 0, 0, 0).AddYears(-1); |
| | | var LunarDate = convert(thisYear-1, thisMonth, thisDay); |
| | | // DateTime gregorianDate = chineseCalendar.ToDateTime(thisYear, thisMonth, thisDay, 0, 0, 0, 0); |
| | | |
| | | // DateTime lastYearLunarDate = new DateTime(thisYear, thisMonth, thisDay, 0, 0, 0, 0).AddYears(-1); |
| | | var LunarDate = convert(thisYear - 1, thisMonth, thisDay); |
| | | // DateTime gregorianDate = chineseCalendar.ToDateTime(thisYear, thisMonth, thisDay, 0, 0, 0, 0); |
| | | return LunarDate; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | //阴历转换阳历 |
| | | private DateTime convert(int year,int month,int day) |
| | | private DateTime convert(int year, int month, int day) |
| | | { |
| | | for (DateTime dateTime = new DateTime(year, 1, 1); dateTime < new DateTime(year, month + 3, 1);dateTime=dateTime.AddDays(1)) |
| | | for (DateTime dateTime = new DateTime(year, 1, 1); dateTime < new DateTime(year, month + 3, 1); dateTime = dateTime.AddDays(1)) |
| | | { |
| | | ChineseLunisolarCalendar chineseCalendar = new ChineseLunisolarCalendar(); |
| | | int thisYear = chineseCalendar.GetYear(dateTime); |
| | |
| | | { |
| | | return dateTime; |
| | | } |
| | | |
| | | |
| | | } |
| | | return new DateTime(2023,1,1); |
| | | return new DateTime(2023, 1, 1); |
| | | } |
| | | |
| | | //获取水位数据 |
| | |
| | | axisTime.VisualRange.SideMarginsValue = 0; |
| | | // axisTime.WholeRange.SetMinMaxValues(LastYearTime, LastYearTime.AddDays(1)); |
| | | // axisTime.VisualRange.SetMinMaxValues(LastYearTime, LastYearTime.AddDays(1)); |
| | | var waterParas = _PumpRunHelper.GetByPumpOneDayWaterData(LastYearTime, out string error); |
| | | var waterParas = _PumpRunHelper.GetByPumpOneDayWaterData(LastYearTime, out string error); |
| | | if (waterParas == null) return; |
| | | foreach (var item in waterParas) |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | //添加实际取水量 |
| | | //添加实际取水量 |
| | | private void SetCurretnPumpWaterParas(DateTime dateTime) |
| | | { |
| | | // List<PumpWater> pumpWater = new List<PumpWater>(); |
| | | // List<PumpWater> pumpWater = new List<PumpWater>(); |
| | | XYDiagram main_diagram = chartControl实时数据.Diagram as XYDiagram; |
| | | var axisTime = main_diagram.AxisX; |
| | | axisTime.VisualRange.Auto = true; |
| | |
| | | axisTimeele.VisualRange.SideMarginsValue = 0; |
| | | // axisTime.WholeRange.SetMinMaxValues(LastYearTime, LastYearTime.AddDays(1)); |
| | | // axisTime.VisualRange.SetMinMaxValues(LastYearTime, LastYearTime.AddDays(1)); |
| | | var CurrentPumpWater = _PumpRunHelper.GetByPumpOneDayWaterData(dateTime, out string error); |
| | | var CurrentPumpWater = _PumpRunHelper.GetByPumpOneDayWaterData(dateTime, out string error); |
| | | var SeriseMonitor = this.chartControl实时数据.Series[0]; |
| | | if (CurrentPumpWater == null) return; |
| | | _CurrentPumpWater.Clear(); |
| | |
| | | //添加方案取水量 |
| | | private void GetAnaWater() |
| | | { |
| | | XYDiagram main_diagram = chartControl实时数据.Diagram as XYDiagram; |
| | | XYDiagram main_diagram = chartControl实时数据.Diagram as XYDiagram; |
| | | var axisTime = main_diagram.AxisX; |
| | | axisTime.VisualRange.Auto = true; |
| | | axisTime.WholeRange.Auto = true; |
| | | axisTime.WholeRange.SideMarginsValue = 0; |
| | | axisTime.VisualRange.SideMarginsValue = 0; |
| | | var SeriseMonitor = this.chartControl实时数据.Series[2]; |
| | | var SeriseMonitor = this.chartControl实时数据.Series[2]; |
| | | SeriseMonitor.Points.Clear(); |
| | | if (_Ana == null || !isSetData) |
| | | if (_Ana == null || !isSetData) |
| | | { |
| | | SeriseMonitor.ShowInLegend = false; |
| | | return; |
| | | } |
| | | foreach (var item in _Ana.PointTimes) |
| | | { |
| | | var allTime = _Ana.GetAllPointTimeList(); |
| | | foreach (var item in allTime) |
| | | { |
| | | SeriseMonitor.Points.Add(new SeriesPoint(item.Time, item.RealFlow)); |
| | | } |
| | | } |
| | | SeriseMonitor.ShowInLegend = true; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | private void barCheckData_CheckedChanged(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | isSetData = this.barCheckData.Checked; |
| | | var a = new CalcModel.AnaPrj(); |
| | | var a = new CalcModel.AnaPrj(); |
| | | GetAnaWater(); |
| | | SetSeriseEle(); |
| | | MergeCurrentModel(a, _LastYeay, _CurrentData); |
| | |
| | | this.barCheckData.Caption = "隐藏方案数据"; |
| | | } |
| | | else this.barCheckData.Caption = "显示方案数据"; |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | HistoryDataAPiHelper historyDataAPiHelper = new HistoryDataAPiHelper(); |
| | | var LastYearIsOpen = historyDataAPiHelper.MergeTimeSlots(MergeList(LastYeay)); |
| | | |
| | | |
| | | var CurrentDateOpen = historyDataAPiHelper.MergeTimeSlots(MergeList(currentData)); |
| | | _CurrentModel.Clear(); |
| | | if (DateTime.Now.Date >= ListDayTime && CurrentDateOpen != null /*&& LastYearIsOpen != null *//*&& anaPrj != null*/) |
| | |
| | | PumpCount = string.Format("{0}台泵", model.Item3.ToString()), |
| | | Time = model.Item1.ToString("HH:mm") + "-" + model.Item2.ToString("HH:mm"), |
| | | ElectricityPrice = model.Item4 * 1000, |
| | | Water = model.Item5*1000, //km³---m³ |
| | | Electricity = model.Item6*1000, |
| | | Water = model.Item5 * 1000, //km³---m³ |
| | | Electricity = model.Item6 * 1000, |
| | | TimeSpan = (model.Item2 - model.Item1).TotalMinutes, |
| | | TotalEle = _CurrentData.Electric*1000, //Mwh--kwh |
| | | TotalEle = _CurrentData.Electric * 1000, //Mwh--kwh |
| | | TotalElePrice = _CurrentData.Money * 1000, |
| | | TotalWater =Math.Round( _CurrentData.FlowIn/10,1),//km³ ---万m³ |
| | | QDSLN = Math.Round(((_CurrentData.Electric * 1000) /( _CurrentData.FlowIn / 10))/10, 1) |
| | | TotalWater = Math.Round(_CurrentData.FlowIn / 10, 1),//km³ ---万m³ |
| | | QDSLN = Math.Round(((_CurrentData.Electric * 1000) / (_CurrentData.FlowIn / 10)) / 10, 1) |
| | | }; |
| | | _CurrentModel.Add(CurrentDate); |
| | | } |
| | |
| | | _CurrentModel.Add(project); |
| | | } |
| | | } |
| | | if (LastYearIsOpen != null ) |
| | | if (LastYearIsOpen != null) |
| | | { |
| | | foreach (var model in LastYearIsOpen) |
| | | { |
| | |
| | | PumpCount = string.Format("{0}台泵", model.Item3.ToString()), |
| | | Time = model.Item1.ToString("HH:mm") + "-" + model.Item2.ToString("HH:mm"), |
| | | ElectricityPrice = model.Item4 * 1000, |
| | | Water = model.Item5*1000, |
| | | Water = model.Item5 * 1000, |
| | | Electricity = model.Item6 * 1000, |
| | | TimeSpan = (model.Item2 - model.Item1).TotalMinutes, |
| | | TotalEle = _LastYeay.Electric * 1000, |
| | | TotalElePrice = _LastYeay.Money*1000, |
| | | TotalWater = Math.Round( _LastYeay.FlowIn/10,1), |
| | | TotalElePrice = _LastYeay.Money * 1000, |
| | | TotalWater = Math.Round(_LastYeay.FlowIn / 10, 1), |
| | | QDSLN = Math.Round(((_LastYeay.Electric * 1000) / (_LastYeay.FlowIn / 10)) / 10, 1) |
| | | }; |
| | | _CurrentModel.Add(LastYear); |
| | | } |
| | | } |
| | | |
| | | |
| | | this.bindingSource1.DataSource = _CurrentModel; |
| | | this.bindingSource1.ResetBindings(false); |
| | | } |
| | | } |
| | | |
| | | |
| | | //自定义合并 |
| | | private void gridView2_CellMerge(object sender, CellMergeEventArgs e) |
| | | private void gridView2_CellMerge(object sender, CellMergeEventArgs e) |
| | | { |
| | | var gridViewPumpID1 = gridView2.GetRow(e.RowHandle1) as CurrentModel; |
| | | var gridViewPumpID2 = gridView2.GetRow(e.RowHandle2) as CurrentModel; |
| | | if (gridViewPumpID1 == gridViewPumpID2) |
| | | var gridViewPumpID2 = gridView2.GetRow(e.RowHandle2) as CurrentModel; |
| | | if (gridViewPumpID1 == gridViewPumpID2) |
| | | { |
| | | return; |
| | | } |
| | |
| | | e.Merge = false; |
| | | e.Handled = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |