Beispiel #1
0
        private void BuildingEnergyMonth_NeedDataSource(object sender, EventArgs e)
        {
            var buildingIDObj = ReportParameters["buildingId"].Value;
            var yearObj       = ReportParameters["year"].Value;
            var monthObj      = ReportParameters["month"].Value;

            if (buildingIDObj != null)
            {
                int buildingId = Convert.ToInt32(buildingIDObj);
                int year       = 0;
                if (yearObj != null)
                {
                    year = Convert.ToInt32(yearObj);
                    if (year <= 0)
                    {
                        year = DateTime.Now.Year;
                    }
                }
                int month = 0;
                if (monthObj != null)
                {
                    month = Convert.ToInt32(monthObj);
                    if (month <= 0)
                    {
                        month = DateTime.Now.Month;
                    }
                }
                IBuildingRepos buildingRepos = new BuildingRepos();
                var            building      = buildingRepos.GetBuilding(buildingId);
                if (building != null)
                {
                    string buildingName    = building.BDI_Name;
                    double?buildingArea    = building.BDI_Area;
                    double?buildingAreaSpe = building.BDI_AreaSpe;
                    textBox134.Value = buildingName;
                    textBox300.Value = month.ToString();
                    if (buildingArea != null)
                    {
                        textBox135.Value = buildingArea.ToString();
                    }
                    if (buildingAreaSpe != null)
                    {
                        textBox137.Value = buildingAreaSpe.ToString();
                    }
                    ISystemProfileRepos systemProfileRepos = new SystemProfileRepos();
                    var priceDic        = systemProfileRepos.GetAllPrice().ToDictionary(x => x.SP_ID, x => x.SP_Value);
                    var priceHighTime   = priceDic["price_highTime"];
                    var priceNormalTime = priceDic["price_normalTime"];
                    var priceLowTime    = priceDic["price_lowTime"];
                    textBox145.Value = priceHighTime;
                    textBox143.Value = priceNormalTime;
                    textBox141.Value = priceLowTime;

                    var timeDic    = systemProfileRepos.GetByStartStr("time").ToDictionary(x => x.SP_ID, x => x.SP_Value);
                    var timeHigh   = timeDic["time_high"];
                    var timeNormal = timeDic["time_normal"];
                    var timeLow    = timeDic["time_low"];

                    IPowerClassRepos powerClassRepos = new PowerClassRepos();
                    var elecPowers = (powerClassRepos.GetSubPowers("001").Select(x => x.PC_ID).ToArray().Union(new string[] { "001" })).ToArray();

                    IAnalogHistoryRepos analogHistoryRepos = new AnalogHistoryRepos();
                    DateTime            startDate          = DateTime.Parse(year + "-" + month + "-1");
                    DateTime            endDate            = startDate.AddMonths(1);

                    DateTime startDate2 = startDate.AddDays(1);
                    DateTime endDate2   = endDate.AddSeconds(-1);
                    var      dayDataDic = analogHistoryRepos.GetEnergyStatisDay(3, buildingId, startDate, endDate2, elecPowers, 1).ToDictionary(x => x.Time.Day, x => x.StatisVal);

                    var      timeBlocks = timeHigh.Split(new char[] { ',' });
                    double[] highVals   = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    foreach (var timeStr in timeBlocks)
                    {
                        var times = timeStr.Split(new char[] { '-' });
                        if (times != null && times.Length > 1)
                        {
                            int startTime = Int32.Parse(times[0]);
                            int endTime   = Int32.Parse(times[1]);
                            var query     = analogHistoryRepos.GetEnergyBySpecialHours(3, buildingId, startDate, endDate, elecPowers, startTime, endTime);
                            var dayData   = query.ToDictionary(x => x.Time.Day, x => x.StatisVal);
                            foreach (var item in dayData)
                            {
                                highVals[item.Key] = item.Value;
                            }
                        }
                    }
                    timeBlocks = timeNormal.Split(new char[] { ',' });
                    double[] normalVals = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    foreach (var timeStr in timeBlocks)
                    {
                        var times = timeStr.Split(new char[] { '-' });
                        if (times != null && times.Length > 1)
                        {
                            int startTime = Int32.Parse(times[0]);
                            int endTime   = Int32.Parse(times[1]);
                            var query     = analogHistoryRepos.GetEnergyBySpecialHours(3, buildingId, startDate, endDate, elecPowers, startTime, endTime);
                            var dayData   = query.ToDictionary(x => x.Time.Day, x => x.StatisVal);
                            foreach (var item in dayData)
                            {
                                normalVals[item.Key] = item.Value;
                            }
                        }
                    }
                    timeBlocks = timeLow.Split(new char[] { ',' });
                    double[] lowVals = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    foreach (var timeStr in timeBlocks)
                    {
                        var times = timeStr.Split(new char[] { '-' });
                        if (times != null && times.Length > 1)
                        {
                            int startTime = Int32.Parse(times[0]);
                            int endTime   = Int32.Parse(times[1]);
                            var query     = analogHistoryRepos.GetEnergyBySpecialHours(3, buildingId, startDate, endDate, elecPowers, startTime, endTime);
                            var dayData   = query.ToDictionary(x => x.Time.Day, x => x.StatisVal);
                            foreach (var item in dayData)
                            {
                                lowVals[item.Key] = item.Value;
                            }
                        }
                    }

                    foreach (var item in dayDataDic)
                    {
                        double hnlsum = highVals[item.Key] + normalVals[item.Key] + lowVals[item.Key];
                        highVals[item.Key]   = highVals[item.Key] * dayDataDic[item.Key] / hnlsum;
                        normalVals[item.Key] = normalVals[item.Key] * dayDataDic[item.Key] / hnlsum;
                        lowVals[item.Key]    = lowVals[item.Key] * dayDataDic[item.Key] / hnlsum;
                    }

                    IDictionary highDayValDic   = new Dictionary <int, string>();
                    IDictionary normalDayValDic = new Dictionary <int, string>();
                    IDictionary lowDayValDic    = new Dictionary <int, string>();
                    IDictionary dayValDic       = new Dictionary <int, string>();
                    // 合计峰时值
                    double totalHighVal = 0;
                    // 峰时值个数
                    int totalHighValCount = 0;
                    // 合计平时值
                    double totalNormalVal = 0;
                    // 平时值个数
                    int totalNormalValCount = 0;
                    // 合计谷时值
                    double totalLowVal = 0;
                    // 谷时值个数
                    int totalLowValCount = 0;
                    // 合计月值
                    double totalMonthVal = 0;
                    // 合计月值个数
                    int totalValCount = 0;
                    for (int i = 1; i <= 31; i++)
                    {
                        if (highVals[i] > 0)
                        {
                            highDayValDic.Add(i, highVals[i].ToString("f1"));
                            totalHighVal += highVals[i];
                            totalHighValCount++;
                        }
                        else
                        {
                            highDayValDic.Add(i, "/");
                        }
                        if (normalVals[i] > 0)
                        {
                            normalDayValDic.Add(i, normalVals[i].ToString("f1"));
                            totalNormalVal += normalVals[i];
                            totalNormalValCount++;
                        }
                        else
                        {
                            normalDayValDic.Add(i, "/");
                        }
                        if (lowVals[i] > 0)
                        {
                            lowDayValDic.Add(i, lowVals[i].ToString("f1"));
                            totalLowVal += lowVals[i];
                            totalLowValCount++;
                        }
                        else
                        {
                            lowDayValDic.Add(i, "/");
                        }
                        if (dayDataDic.ContainsKey(i) && dayDataDic[i] > 0)
                        {
                            dayValDic.Add(i, dayDataDic[i].ToString("f1"));
                            totalMonthVal += dayDataDic[i];
                            totalValCount++;
                        }
                        else
                        {
                            dayValDic.Add(i, "/");
                        }
                    }
                    int days = (endDate - startDate).Days;
                    // 1日
                    textBox5.Value  = dayValDic[1].ToString();
                    textBox8.Value  = highDayValDic[1].ToString();
                    textBox10.Value = normalDayValDic[1].ToString();
                    textBox12.Value = lowDayValDic[1].ToString();
                    // 2日
                    textBox18.Value = dayValDic[2].ToString();
                    textBox20.Value = highDayValDic[2].ToString();
                    textBox21.Value = normalDayValDic[2].ToString();
                    textBox22.Value = lowDayValDic[2].ToString();
                    // 3日
                    textBox26.Value = dayValDic[3].ToString();
                    textBox28.Value = highDayValDic[3].ToString();
                    textBox29.Value = normalDayValDic[3].ToString();
                    textBox30.Value = lowDayValDic[3].ToString();
                    // 4日
                    textBox34.Value = dayValDic[4].ToString();
                    textBox36.Value = highDayValDic[4].ToString();
                    textBox37.Value = normalDayValDic[4].ToString();
                    textBox38.Value = lowDayValDic[4].ToString();
                    // 5日
                    textBox42.Value = dayValDic[5].ToString();
                    textBox44.Value = highDayValDic[5].ToString();
                    textBox45.Value = normalDayValDic[5].ToString();
                    textBox46.Value = lowDayValDic[5].ToString();
                    // 6日
                    textBox50.Value = dayValDic[6].ToString();
                    textBox52.Value = highDayValDic[6].ToString();
                    textBox53.Value = normalDayValDic[6].ToString();
                    textBox54.Value = lowDayValDic[6].ToString();
                    // 7日
                    textBox58.Value = dayValDic[7].ToString();
                    textBox60.Value = highDayValDic[7].ToString();
                    textBox61.Value = normalDayValDic[7].ToString();
                    textBox62.Value = lowDayValDic[7].ToString();
                    // 8日
                    textBox66.Value = dayValDic[8].ToString();
                    textBox68.Value = highDayValDic[8].ToString();
                    textBox69.Value = normalDayValDic[8].ToString();
                    textBox70.Value = lowDayValDic[8].ToString();
                    // 9日
                    textBox74.Value = dayValDic[9].ToString();
                    textBox76.Value = highDayValDic[9].ToString();
                    textBox77.Value = normalDayValDic[9].ToString();
                    textBox78.Value = lowDayValDic[9].ToString();
                    // 10日
                    textBox82.Value = dayValDic[10].ToString();
                    textBox84.Value = highDayValDic[10].ToString();
                    textBox85.Value = normalDayValDic[10].ToString();
                    textBox86.Value = lowDayValDic[10].ToString();
                    // 11日
                    textBox90.Value = dayValDic[11].ToString();
                    textBox92.Value = highDayValDic[11].ToString();
                    textBox93.Value = normalDayValDic[11].ToString();
                    textBox94.Value = lowDayValDic[11].ToString();
                    // 12日
                    textBox98.Value  = dayValDic[12].ToString();
                    textBox100.Value = highDayValDic[12].ToString();
                    textBox101.Value = normalDayValDic[12].ToString();
                    textBox102.Value = lowDayValDic[12].ToString();
                    // 13日
                    textBox106.Value = dayValDic[13].ToString();
                    textBox108.Value = highDayValDic[13].ToString();
                    textBox109.Value = normalDayValDic[13].ToString();
                    textBox110.Value = lowDayValDic[13].ToString();
                    // 14日
                    textBox114.Value = dayValDic[14].ToString();
                    textBox116.Value = highDayValDic[14].ToString();
                    textBox117.Value = normalDayValDic[14].ToString();
                    textBox118.Value = lowDayValDic[14].ToString();
                    // 15日
                    textBox148.Value = dayValDic[15].ToString();
                    textBox150.Value = highDayValDic[15].ToString();
                    textBox151.Value = normalDayValDic[15].ToString();
                    textBox152.Value = lowDayValDic[15].ToString();
                    // 16日
                    textBox156.Value = dayValDic[16].ToString();
                    textBox158.Value = highDayValDic[16].ToString();
                    textBox159.Value = normalDayValDic[16].ToString();
                    textBox160.Value = lowDayValDic[16].ToString();
                    // 17日
                    textBox164.Value = dayValDic[17].ToString();
                    textBox166.Value = highDayValDic[17].ToString();
                    textBox167.Value = normalDayValDic[17].ToString();
                    textBox168.Value = lowDayValDic[17].ToString();
                    // 18日
                    textBox172.Value = dayValDic[18].ToString();
                    textBox174.Value = highDayValDic[18].ToString();
                    textBox175.Value = normalDayValDic[18].ToString();
                    textBox176.Value = lowDayValDic[18].ToString();
                    // 19日
                    textBox180.Value = dayValDic[19].ToString();
                    textBox182.Value = highDayValDic[19].ToString();
                    textBox183.Value = normalDayValDic[19].ToString();
                    textBox184.Value = lowDayValDic[19].ToString();
                    // 20日
                    textBox188.Value = dayValDic[20].ToString();
                    textBox190.Value = highDayValDic[20].ToString();
                    textBox191.Value = normalDayValDic[20].ToString();
                    textBox192.Value = lowDayValDic[20].ToString();
                    // 21日
                    textBox196.Value = dayValDic[21].ToString();
                    textBox198.Value = highDayValDic[21].ToString();
                    textBox199.Value = normalDayValDic[21].ToString();
                    textBox200.Value = lowDayValDic[21].ToString();
                    // 22日
                    textBox204.Value = dayValDic[22].ToString();
                    textBox206.Value = highDayValDic[22].ToString();
                    textBox207.Value = normalDayValDic[22].ToString();
                    textBox208.Value = lowDayValDic[22].ToString();
                    // 23日
                    textBox212.Value = dayValDic[23].ToString();
                    textBox214.Value = highDayValDic[23].ToString();
                    textBox215.Value = normalDayValDic[23].ToString();
                    textBox216.Value = lowDayValDic[23].ToString();
                    // 24日
                    textBox220.Value = dayValDic[24].ToString();
                    textBox222.Value = highDayValDic[24].ToString();
                    textBox223.Value = normalDayValDic[24].ToString();
                    textBox224.Value = lowDayValDic[24].ToString();
                    // 25日
                    textBox228.Value = dayValDic[25].ToString();
                    textBox230.Value = highDayValDic[25].ToString();
                    textBox231.Value = normalDayValDic[25].ToString();
                    textBox232.Value = lowDayValDic[25].ToString();
                    // 26日
                    textBox236.Value = dayValDic[26].ToString();
                    textBox238.Value = highDayValDic[26].ToString();
                    textBox239.Value = normalDayValDic[26].ToString();
                    textBox240.Value = lowDayValDic[26].ToString();
                    // 27日
                    textBox244.Value = dayValDic[27].ToString();
                    textBox246.Value = highDayValDic[27].ToString();
                    textBox247.Value = normalDayValDic[27].ToString();
                    textBox248.Value = lowDayValDic[27].ToString();
                    // 28日
                    textBox252.Value = dayValDic[28].ToString();
                    textBox254.Value = highDayValDic[28].ToString();
                    textBox255.Value = normalDayValDic[28].ToString();
                    textBox256.Value = lowDayValDic[28].ToString();
                    // 29日
                    if (days >= 29)
                    {
                        textBox260.Value = dayValDic[29].ToString();
                        textBox262.Value = highDayValDic[29].ToString();
                        textBox263.Value = normalDayValDic[29].ToString();
                        textBox264.Value = lowDayValDic[29].ToString();
                    }
                    // 30日
                    if (days >= 30)
                    {
                        textBox268.Value = dayValDic[30].ToString();
                        textBox270.Value = highDayValDic[30].ToString();
                        textBox271.Value = normalDayValDic[30].ToString();
                        textBox272.Value = lowDayValDic[30].ToString();
                    }
                    // 31日
                    if (days >= 31)
                    {
                        textBox276.Value = dayValDic[31].ToString();
                        textBox278.Value = highDayValDic[31].ToString();
                        textBox279.Value = normalDayValDic[31].ToString();
                        textBox290.Value = lowDayValDic[31].ToString();
                    }

                    // 合计平均月值
                    if (totalMonthVal > 0 && totalValCount > 0)
                    {
                        textBox284.Value = totalMonthVal.ToString("f1");
                        textBox292.Value = (totalMonthVal / totalValCount).ToString("f1");
                    }
                    // 合计平均峰时值
                    if (totalHighVal > 0 && totalHighValCount > 0)
                    {
                        textBox286.Value = totalHighVal.ToString("f1");
                        textBox294.Value = (totalHighVal / totalHighValCount).ToString("f1");
                    }
                    // 合计平均平时值
                    if (totalNormalVal > 0 && totalNormalValCount > 0)
                    {
                        textBox287.Value = totalNormalVal.ToString("f1");
                        textBox295.Value = (totalNormalVal / totalNormalValCount).ToString("f1");
                    }
                    // 合计平均谷时值
                    if (totalLowVal > 0 && totalLowValCount > 0)
                    {
                        textBox288.Value = totalLowVal.ToString("f1");
                        textBox296.Value = (totalLowVal / totalLowValCount).ToString("f1");
                    }
                }
            }
        }
        private void BuildingWaterMonth_NeedDataSource(object sender, EventArgs e)
        {
            var buildingIDObj = ReportParameters["buildingId"].Value;
            var yearObj       = ReportParameters["year"].Value;

            if (buildingIDObj != null)
            {
                int buildingId = Convert.ToInt32(buildingIDObj);
                int year       = 0;
                if (yearObj != null)
                {
                    year = Convert.ToInt32(yearObj);
                    if (year <= 0)
                    {
                        year = DateTime.Now.Year;
                    }
                }
                IBuildingRepos buildingRepos = new BuildingRepos();
                var            building      = buildingRepos.GetBuilding(buildingId);
                if (building != null)
                {
                    string buildingName      = building.BDI_Name;
                    double?buildingArea      = building.BDI_Area;
                    double?buildingUserCount = building.BDI_Users;
                    textBox134.Value = buildingName;
                    if (buildingArea != null)
                    {
                        textBox135.Value = buildingArea.ToString();
                    }
                    if (buildingUserCount != null)
                    {
                        textBox137.Value = buildingUserCount.ToString();
                    }
                    ISystemProfileRepos systemProfileRepos = new SystemProfileRepos();
                    var priceDic       = systemProfileRepos.GetAllPrice().ToDictionary(x => x.SP_ID, x => x.SP_Value);
                    var priceWater     = priceDic["price_water"];
                    var pricePollution = priceDic["price_pollution"];
                    textBox11.Value = priceWater;
                    textBox13.Value = pricePollution;

                    IPowerClassRepos powerClassRepos = new PowerClassRepos();
                    var waterPowers = powerClassRepos.GetSubPowers("002").Select(x => x.PC_ID).ToArray();

                    DateTime            startDate          = DateTime.Parse(year + "-1-1");
                    DateTime            endDate            = startDate.AddYears(1);
                    IAnalogHistoryRepos analogHistoryRepos = new AnalogHistoryRepos();
                    // 使用endDate2主要是因为GetEnergyStatisMonth函数中使用AnalogHistoryMonths,部分代码ahm.AHM_MTime <= endTime,所以月如果是下年1月就多了一月,重复
                    DateTime    endDate2      = endDate.AddMonths(-1);
                    var         monthDataDic  = analogHistoryRepos.GetEnergyStatisMonth(3, buildingId, startDate, endDate2, waterPowers, 1).ToDictionary(x => x.Time.Month, x => x.StatisVal);
                    IDictionary monthValDic   = new Dictionary <int, string>();
                    IDictionary monthPriceDic = new Dictionary <int, string>();
                    double      waterPrice    = Convert.ToDouble(priceWater);
                    // 合计月值
                    double totalMonthVal = 0;
                    // 每月水费
                    double totalMonthPrice = 0;
                    // 合计月值个数
                    int totalValCount = 0;
                    for (int i = 1; i <= 12; i++)
                    {
                        if (monthDataDic.ContainsKey(i) && monthDataDic[i] > 0)
                        {
                            monthValDic.Add(i, monthDataDic[i].ToString("f1"));
                            double price = monthDataDic[i] * waterPrice;
                            monthPriceDic.Add(i, price.ToString("f1"));
                            totalMonthVal   += monthDataDic[i];
                            totalMonthPrice += price;
                            totalValCount++;
                        }
                        else
                        {
                            monthValDic.Add(i, "/");
                            monthPriceDic.Add(i, "/");
                        }
                    }
                    // 1月
                    textBox5.Value = monthValDic[1].ToString();
                    textBox6.Value = monthPriceDic[1].ToString();
                    // 2月
                    textBox18.Value = monthValDic[2].ToString();
                    textBox19.Value = monthPriceDic[2].ToString();
                    // 3月
                    textBox26.Value = monthValDic[3].ToString();
                    textBox27.Value = monthPriceDic[3].ToString();
                    // 4月
                    textBox34.Value = monthValDic[4].ToString();
                    textBox35.Value = monthPriceDic[4].ToString();
                    // 5月
                    textBox42.Value = monthValDic[5].ToString();
                    textBox43.Value = monthPriceDic[5].ToString();
                    // 6月
                    textBox50.Value = monthValDic[6].ToString();
                    textBox51.Value = monthPriceDic[6].ToString();
                    // 7月
                    textBox58.Value = monthValDic[7].ToString();
                    textBox59.Value = monthPriceDic[7].ToString();
                    // 8月
                    textBox66.Value = monthValDic[8].ToString();
                    textBox67.Value = monthPriceDic[8].ToString();
                    // 9月
                    textBox74.Value = monthValDic[9].ToString();
                    textBox75.Value = monthPriceDic[9].ToString();
                    // 10月
                    textBox82.Value = monthValDic[10].ToString();
                    textBox83.Value = monthPriceDic[10].ToString();
                    // 11月
                    textBox90.Value = monthValDic[11].ToString();
                    textBox91.Value = monthPriceDic[11].ToString();
                    // 12月
                    textBox98.Value = monthValDic[12].ToString();
                    textBox99.Value = monthPriceDic[12].ToString();
                    // 合计平均月值
                    if (totalMonthVal > 0 && totalValCount > 0)
                    {
                        textBox106.Value = totalMonthVal.ToString("f1");
                        textBox114.Value = (totalMonthVal / totalValCount).ToString("f1");
                    }
                    // 合计平均水费
                    if (totalMonthPrice > 0 && totalValCount > 0)
                    {
                        textBox107.Value = totalMonthPrice.ToString("f1");
                        textBox115.Value = (totalMonthPrice / totalValCount).ToString("f1");
                    }
                }
            }
        }
        private void BuildingEnergyMonth_NeedDataSource(object sender, EventArgs e)
        {
            var buildingIDObj = ReportParameters["buildingId"].Value;
            var yearObj       = ReportParameters["year"].Value;

            if (buildingIDObj != null)
            {
                int buildingId = Convert.ToInt32(buildingIDObj);
                int year       = 0;
                if (yearObj != null)
                {
                    year = Convert.ToInt32(yearObj);
                    if (year <= 0)
                    {
                        year = DateTime.Now.Year;
                    }
                }
                IBuildingRepos buildingRepos = new BuildingRepos();
                var            building      = buildingRepos.GetBuilding(buildingId);
                if (building != null)
                {
                    string buildingName    = building.BDI_Name;
                    double?buildingArea    = building.BDI_Area;
                    double?buildingAreaSpe = building.BDI_AreaSpe;
                    textBox134.Value = buildingName;
                    if (buildingArea != null)
                    {
                        textBox135.Value = buildingArea.ToString();
                    }
                    if (buildingAreaSpe != null)
                    {
                        textBox137.Value = buildingAreaSpe.ToString();
                    }
                    ISystemProfileRepos systemProfileRepos = new SystemProfileRepos();
                    var priceDic        = systemProfileRepos.GetAllPrice().ToDictionary(x => x.SP_ID, x => x.SP_Value);
                    var priceHighTime   = priceDic["price_highTime"];
                    var priceNormalTime = priceDic["price_normalTime"];
                    var priceLowTime    = priceDic["price_lowTime"];
                    textBox145.Value = priceHighTime;
                    textBox143.Value = priceNormalTime;
                    textBox141.Value = priceLowTime;

                    var timeDic    = systemProfileRepos.GetByStartStr("time").ToDictionary(x => x.SP_ID, x => x.SP_Value);
                    var timeHigh   = timeDic["time_high"];
                    var timeNormal = timeDic["time_normal"];
                    var timeLow    = timeDic["time_low"];

                    IPowerClassRepos powerClassRepos = new PowerClassRepos();
                    var elecPowers = (powerClassRepos.GetSubPowers("001").Select(x => x.PC_ID).ToArray().Union(new string[] { "001" })).ToArray();

                    IAnalogHistoryRepos analogHistoryRepos = new AnalogHistoryRepos();
                    DateTime            startDate          = DateTime.Parse(year + "-1-1");
                    DateTime            endDate            = startDate.AddYears(1);

                    var      timeBlocks = timeHigh.Split(new char[] { ',' });
                    double[] highVals   = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    foreach (var timeStr in timeBlocks)
                    {
                        var times = timeStr.Split(new char[] { '-' });
                        if (times != null && times.Length > 1)
                        {
                            int startTime  = Int32.Parse(times[0]);
                            int endTime    = Int32.Parse(times[1]);
                            var query      = analogHistoryRepos.GetEnergyBySpecialHours(3, buildingId, startDate, endDate, elecPowers, startTime, endTime);
                            var monthQuery = query.GroupBy(x => x.Month, x => x.StatisVal).Select(g => new { Month = g.Key, Val = g.Sum() });
                            var monthData  = monthQuery.ToDictionary(x => x.Month, x => x.Val);
                            foreach (var item in monthData)
                            {
                                highVals[item.Key] = item.Value;
                            }
                        }
                    }
                    timeBlocks = timeNormal.Split(new char[] { ',' });
                    double[] normalVals = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    foreach (var timeStr in timeBlocks)
                    {
                        var times = timeStr.Split(new char[] { '-' });
                        if (times != null && times.Length > 1)
                        {
                            int startTime  = Int32.Parse(times[0]);
                            int endTime    = Int32.Parse(times[1]);
                            var query      = analogHistoryRepos.GetEnergyBySpecialHours(3, buildingId, startDate, endDate, elecPowers, startTime, endTime);
                            var monthQuery = query.GroupBy(x => x.Month, x => x.StatisVal).Select(g => new { Month = g.Key, Val = g.Sum() });
                            var monthData  = monthQuery.ToDictionary(x => x.Month, x => x.Val);
                            foreach (var item in monthData)
                            {
                                normalVals[item.Key] = item.Value;
                            }
                        }
                    }
                    timeBlocks = timeLow.Split(new char[] { ',' });
                    double[] lowVals = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    foreach (var timeStr in timeBlocks)
                    {
                        var times = timeStr.Split(new char[] { '-' });
                        if (times != null && times.Length > 1)
                        {
                            int startTime  = Int32.Parse(times[0]);
                            int endTime    = Int32.Parse(times[1]);
                            var query      = analogHistoryRepos.GetEnergyBySpecialHours(3, buildingId, startDate, endDate, elecPowers, startTime, endTime);
                            var monthQuery = query.GroupBy(x => x.Month, x => x.StatisVal).Select(g => new { Month = g.Key, Val = g.Sum() });
                            var monthData  = monthQuery.ToDictionary(x => x.Month, x => x.Val);
                            foreach (var item in monthData)
                            {
                                lowVals[item.Key] = item.Value;
                            }
                        }
                    }
                    // 使用endDate2主要是因为GetEnergyStatisMonth函数中使用endTime = endTime.AddDays(1),所以要减一天,另外使用ahm.AHM_MTime <= endTime,可以考虑多减1秒
                    DateTime endDate2     = endDate.AddDays(-1).AddSeconds(-1);
                    var      monthDataDic = analogHistoryRepos.GetEnergyStatisMonth(3, buildingId, startDate, endDate2, elecPowers, 1).ToDictionary(x => x.Time.Month, x => x.StatisVal);


                    foreach (var item in monthDataDic)
                    {
                        double hnlsum = highVals[item.Key] + normalVals[item.Key] + lowVals[item.Key];
                        highVals[item.Key]   = highVals[item.Key] * monthDataDic[item.Key] / hnlsum;
                        normalVals[item.Key] = normalVals[item.Key] * monthDataDic[item.Key] / hnlsum;
                        lowVals[item.Key]    = lowVals[item.Key] * monthDataDic[item.Key] / hnlsum;
                    }

                    IDictionary highMonthValDic   = new Dictionary <int, string>();
                    IDictionary normalMonthValDic = new Dictionary <int, string>();
                    IDictionary lowMonthValDic    = new Dictionary <int, string>();
                    IDictionary monthValDic       = new Dictionary <int, string>();
                    // 合计峰时值
                    double totalHighVal = 0;
                    // 峰时值个数
                    int totalHighValCount = 0;
                    // 合计平时值
                    double totalNormalVal = 0;
                    // 平时值个数
                    int totalNormalValCount = 0;
                    // 合计谷时值
                    double totalLowVal = 0;
                    // 谷时值个数
                    int totalLowValCount = 0;
                    // 合计月值
                    double totalMonthVal = 0;
                    // 合计月值个数
                    int totalValCount = 0;
                    for (int i = 1; i <= 12; i++)
                    {
                        if (highVals[i] > 0)
                        {
                            highMonthValDic.Add(i, highVals[i].ToString("f1"));
                            totalHighVal += highVals[i];
                            totalHighValCount++;
                        }
                        else
                        {
                            highMonthValDic.Add(i, "/");
                        }
                        if (normalVals[i] > 0)
                        {
                            normalMonthValDic.Add(i, normalVals[i].ToString("f1"));
                            totalNormalVal += normalVals[i];
                            totalNormalValCount++;
                        }
                        else
                        {
                            normalMonthValDic.Add(i, "/");
                        }
                        if (lowVals[i] > 0)
                        {
                            lowMonthValDic.Add(i, lowVals[i].ToString("f1"));
                            totalLowVal += lowVals[i];
                            totalLowValCount++;
                        }
                        else
                        {
                            lowMonthValDic.Add(i, "/");
                        }
                        if (monthDataDic.ContainsKey(i) && monthDataDic[i] > 0)
                        {
                            monthValDic.Add(i, monthDataDic[i].ToString("f1"));
                            totalMonthVal += monthDataDic[i];
                            totalValCount++;
                        }
                        else
                        {
                            monthValDic.Add(i, "/");
                        }
                    }
                    // 1月
                    textBox5.Value  = monthValDic[1].ToString();
                    textBox8.Value  = highMonthValDic[1].ToString();
                    textBox10.Value = normalMonthValDic[1].ToString();
                    textBox12.Value = lowMonthValDic[1].ToString();
                    // 2月
                    textBox18.Value = monthValDic[2].ToString();
                    textBox20.Value = highMonthValDic[2].ToString();
                    textBox21.Value = normalMonthValDic[2].ToString();
                    textBox22.Value = lowMonthValDic[2].ToString();
                    // 3月
                    textBox26.Value = monthValDic[3].ToString();
                    textBox28.Value = highMonthValDic[3].ToString();
                    textBox29.Value = normalMonthValDic[3].ToString();
                    textBox30.Value = lowMonthValDic[3].ToString();
                    // 4月
                    textBox34.Value = monthValDic[4].ToString();
                    textBox36.Value = highMonthValDic[4].ToString();
                    textBox37.Value = normalMonthValDic[4].ToString();
                    textBox38.Value = lowMonthValDic[4].ToString();
                    // 5月
                    textBox42.Value = monthValDic[5].ToString();
                    textBox44.Value = highMonthValDic[5].ToString();
                    textBox45.Value = normalMonthValDic[5].ToString();
                    textBox46.Value = lowMonthValDic[5].ToString();
                    // 6月
                    textBox50.Value = monthValDic[6].ToString();
                    textBox52.Value = highMonthValDic[6].ToString();
                    textBox53.Value = normalMonthValDic[6].ToString();
                    textBox54.Value = lowMonthValDic[6].ToString();
                    // 7月
                    textBox58.Value = monthValDic[7].ToString();
                    textBox60.Value = highMonthValDic[7].ToString();
                    textBox61.Value = normalMonthValDic[7].ToString();
                    textBox62.Value = lowMonthValDic[7].ToString();
                    // 8月
                    textBox66.Value = monthValDic[8].ToString();
                    textBox68.Value = highMonthValDic[8].ToString();
                    textBox69.Value = normalMonthValDic[8].ToString();
                    textBox70.Value = lowMonthValDic[8].ToString();
                    // 9月
                    textBox74.Value = monthValDic[9].ToString();
                    textBox76.Value = highMonthValDic[9].ToString();
                    textBox77.Value = normalMonthValDic[9].ToString();
                    textBox78.Value = lowMonthValDic[9].ToString();
                    // 10月
                    textBox82.Value = monthValDic[10].ToString();
                    textBox84.Value = highMonthValDic[10].ToString();
                    textBox85.Value = normalMonthValDic[10].ToString();
                    textBox86.Value = lowMonthValDic[10].ToString();
                    // 11月
                    textBox90.Value = monthValDic[11].ToString();
                    textBox92.Value = highMonthValDic[11].ToString();
                    textBox93.Value = normalMonthValDic[11].ToString();
                    textBox94.Value = lowMonthValDic[11].ToString();
                    // 12月
                    textBox98.Value  = monthValDic[12].ToString();
                    textBox100.Value = highMonthValDic[12].ToString();
                    textBox101.Value = normalMonthValDic[12].ToString();
                    textBox102.Value = lowMonthValDic[12].ToString();
                    // 合计平均月值
                    if (totalMonthVal > 0 && totalValCount > 0)
                    {
                        textBox106.Value = totalMonthVal.ToString("f1");
                        textBox114.Value = (totalMonthVal / totalValCount).ToString("f1");
                    }
                    // 合计平均峰时值
                    if (totalHighVal > 0 && totalHighValCount > 0)
                    {
                        textBox108.Value = totalHighVal.ToString("f1");
                        textBox116.Value = (totalHighVal / totalHighValCount).ToString("f1");
                    }
                    // 合计平均平时值
                    if (totalNormalVal > 0 && totalNormalValCount > 0)
                    {
                        textBox109.Value = totalNormalVal.ToString("f1");
                        textBox117.Value = (totalNormalVal / totalNormalValCount).ToString("f1");
                    }
                    // 合计平均谷时值
                    if (totalLowVal > 0 && totalLowValCount > 0)
                    {
                        textBox110.Value = totalLowVal.ToString("f1");
                        textBox118.Value = (totalLowVal / totalLowValCount).ToString("f1");
                    }
                }
            }
        }
        private void BuildingEnergyMonth_NeedDataSource(object sender, EventArgs e)
        {
            var buildingIDObj = ReportParameters["buildingId"].Value;
            var yearObj       = ReportParameters["year"].Value;

            if (buildingIDObj != null)
            {
                int buildingId = Convert.ToInt32(buildingIDObj);
                int year       = 0;
                if (yearObj != null)
                {
                    year = Convert.ToInt32(yearObj);
                    if (year <= 0)
                    {
                        year = DateTime.Now.Year;
                    }
                }
                IBuildingRepos buildingRepos = new BuildingRepos();
                var            building      = buildingRepos.GetBuilding(buildingId);
                if (building != null)
                {
                    string buildingName      = building.BDI_Name;
                    double?buildingArea      = building.BDI_Area;
                    double?buildingUserCount = building.BDI_Users;
                    textBox277.Value = buildingName;
                    if (buildingArea != null)
                    {
                        textBox279.Value = buildingArea.ToString();
                    }
                    if (buildingUserCount != null)
                    {
                        textBox281.Value = buildingUserCount.ToString();
                    }
                    ISystemProfileRepos systemProfileRepos = new SystemProfileRepos();
                    var priceDic        = systemProfileRepos.GetAllPrice().ToDictionary(x => x.SP_ID, x => x.SP_Value);
                    var priceHighTime   = Convert.ToDouble(priceDic["price_highTime"]);
                    var priceNormalTime = Convert.ToDouble(priceDic["price_normalTime"]);
                    var priceLowTime    = Convert.ToDouble(priceDic["price_lowTime"]);

                    var timeDic    = systemProfileRepos.GetByStartStr("time").ToDictionary(x => x.SP_ID, x => x.SP_Value);
                    var timeHigh   = timeDic["time_high"];
                    var timeNormal = timeDic["time_normal"];
                    var timeLow    = timeDic["time_low"];

                    IPowerClassRepos powerClassRepos = new PowerClassRepos();
                    var elecPowers = (powerClassRepos.GetSubPowers("001").Select(x => x.PC_ID).ToArray().Union(new string[] { "001" })).ToArray();

                    IAnalogHistoryRepos analogHistoryRepos = new AnalogHistoryRepos();
                    DateTime            startDate          = DateTime.Parse(year + "-1-1");
                    DateTime            endDate            = startDate.AddYears(1);

                    var      timeBlocks = timeHigh.Split(new char[] { ',' });
                    double[] highVals   = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    foreach (var timeStr in timeBlocks)
                    {
                        var times = timeStr.Split(new char[] { '-' });
                        if (times != null && times.Length > 1)
                        {
                            int startTime  = Int32.Parse(times[0]);
                            int endTime    = Int32.Parse(times[1]);
                            var query      = analogHistoryRepos.GetEnergyBySpecialHours(3, buildingId, startDate, endDate, elecPowers, startTime, endTime);
                            var monthQuery = query.GroupBy(x => x.Month, x => x.StatisVal).Select(g => new { Month = g.Key, Val = g.Sum() });
                            var monthData  = monthQuery.ToDictionary(x => x.Month, x => x.Val);
                            foreach (var item in monthData)
                            {
                                highVals[item.Key] = item.Value;
                            }
                        }
                    }
                    timeBlocks = timeNormal.Split(new char[] { ',' });
                    double[] normalVals = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    foreach (var timeStr in timeBlocks)
                    {
                        var times = timeStr.Split(new char[] { '-' });
                        if (times != null && times.Length > 1)
                        {
                            int startTime  = Int32.Parse(times[0]);
                            int endTime    = Int32.Parse(times[1]);
                            var query      = analogHistoryRepos.GetEnergyBySpecialHours(3, buildingId, startDate, endDate, elecPowers, startTime, endTime);
                            var monthQuery = query.GroupBy(x => x.Month, x => x.StatisVal).Select(g => new { Month = g.Key, Val = g.Sum() });
                            var monthData  = monthQuery.ToDictionary(x => x.Month, x => x.Val);
                            foreach (var item in monthData)
                            {
                                normalVals[item.Key] = item.Value;
                            }
                        }
                    }
                    timeBlocks = timeLow.Split(new char[] { ',' });
                    double[] lowVals = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                    foreach (var timeStr in timeBlocks)
                    {
                        var times = timeStr.Split(new char[] { '-' });
                        if (times != null && times.Length > 1)
                        {
                            int startTime  = Int32.Parse(times[0]);
                            int endTime    = Int32.Parse(times[1]);
                            var query      = analogHistoryRepos.GetEnergyBySpecialHours(3, buildingId, startDate, endDate, elecPowers, startTime, endTime);
                            var monthQuery = query.GroupBy(x => x.Month, x => x.StatisVal).Select(g => new { Month = g.Key, Val = g.Sum() });
                            var monthData  = monthQuery.ToDictionary(x => x.Month, x => x.Val);
                            foreach (var item in monthData)
                            {
                                lowVals[item.Key] = item.Value;
                            }
                        }
                    }
                    // 使用endDate2主要是因为GetEnergyStatisMonth函数中使用AnalogHistoryMonths,部分代码ahm.AHM_MTime <= endTime,所以月如果是下年1月就多了一月,重复
                    DateTime endDate2     = endDate.AddMonths(-1);
                    var      monthDataDic = analogHistoryRepos.GetEnergyStatisMonth(3, buildingId, startDate, endDate2, elecPowers, 1).ToDictionary(x => x.Time.Month, x => x.StatisVal);

                    foreach (var item in monthDataDic)
                    {
                        double hnlsum = highVals[item.Key] + normalVals[item.Key] + lowVals[item.Key];
                        highVals[item.Key]   = highVals[item.Key] * monthDataDic[item.Key] / hnlsum;
                        normalVals[item.Key] = normalVals[item.Key] * monthDataDic[item.Key] / hnlsum;
                        lowVals[item.Key]    = lowVals[item.Key] * monthDataDic[item.Key] / hnlsum;
                    }

                    IDictionary highMonthValDic   = new Dictionary <int, string>();
                    IDictionary normalMonthValDic = new Dictionary <int, string>();
                    IDictionary lowMonthValDic    = new Dictionary <int, string>();
                    IDictionary monthValDic       = new Dictionary <int, string>();
                    // 月电费
                    IDictionary elecChargeDic = new Dictionary <int, string>();
                    // 单位面积电耗
                    IDictionary monthValPerUnitDic = new Dictionary <int, string>();
                    // 单位面积电费
                    IDictionary elecChargeDicPerUnitDic = new Dictionary <int, string>();
                    // 合计峰时值
                    double totalHighVal = 0;
                    // 峰时值个数
                    int totalHighValCount = 0;
                    // 合计平时值
                    double totalNormalVal = 0;
                    // 平时值个数
                    int totalNormalValCount = 0;
                    // 合计谷时值
                    double totalLowVal = 0;
                    // 谷时值个数
                    int totalLowValCount = 0;
                    // 合计月值
                    double totalMonthVal = 0;
                    // 合计月值个数
                    int totalValCount = 0;
                    // 合计电费
                    double totalElecCharge = 0;
                    // 合计电费个数
                    int totalElecChargeCount = 0;
                    // 合计单位面积电耗
                    double totalMonthValPerUnit = 0;
                    // 合计单位面积电耗个数
                    int totalMonthValPerUnitCount = 0;
                    // 合计单位面积电费
                    double totalElecChargeDicPerUnit = 0;
                    // 合计单位面积电费个数
                    int totalElecChargeDicPerUnitCount = 0;
                    for (int i = 1; i <= 12; i++)
                    {
                        if (highVals[i] > 0)
                        {
                            highMonthValDic.Add(i, highVals[i].ToString("f1"));
                            totalHighVal += highVals[i];
                            totalHighValCount++;
                        }
                        else
                        {
                            highMonthValDic.Add(i, "/");
                        }
                        if (normalVals[i] > 0)
                        {
                            normalMonthValDic.Add(i, normalVals[i].ToString("f1"));
                            totalNormalVal += normalVals[i];
                            totalNormalValCount++;
                        }
                        else
                        {
                            normalMonthValDic.Add(i, "/");
                        }
                        if (lowVals[i] > 0)
                        {
                            lowMonthValDic.Add(i, lowVals[i].ToString("f1"));
                            totalLowVal += lowVals[i];
                            totalLowValCount++;
                        }
                        else
                        {
                            lowMonthValDic.Add(i, "/");
                        }
                        if (monthDataDic.ContainsKey(i) && monthDataDic[i] > 0)
                        {
                            monthValDic.Add(i, monthDataDic[i].ToString("f1"));
                            if (buildingArea.HasValue)
                            {
                                var val = monthDataDic[i] / buildingArea.Value;
                                monthValPerUnitDic.Add(i, val.ToString("f1"));
                                totalMonthValPerUnit += val;
                                totalMonthValPerUnitCount++;
                            }
                            else
                            {
                                monthValPerUnitDic.Add(i, "/");
                            }
                            totalMonthVal += monthDataDic[i];
                            totalValCount++;
                        }
                        else
                        {
                            monthValDic.Add(i, "/");
                            monthValPerUnitDic.Add(i, "/");
                        }
                        if (highVals[i] > 0 && normalVals[i] > 0 && lowVals[i] > 0)
                        {
                            double price = highVals[i] * priceHighTime + normalVals[i] * priceNormalTime + lowVals[i] * priceLowTime;
                            elecChargeDic.Add(i, price.ToString("f1"));
                            totalElecCharge += price;
                            totalElecChargeCount++;
                            if (buildingArea.HasValue)
                            {
                                var val = price / buildingArea.Value;
                                elecChargeDicPerUnitDic.Add(i, val.ToString("f1"));
                                totalElecChargeDicPerUnit += val;
                                totalElecChargeDicPerUnitCount++;
                            }
                            else
                            {
                                elecChargeDicPerUnitDic.Add(i, "/");
                            }
                        }
                        else
                        {
                            elecChargeDic.Add(i, "/");
                            elecChargeDicPerUnitDic.Add(i, "/");
                        }
                    }
                    // 1月
                    textBox24.Value = monthValDic[1].ToString();
                    textBox25.Value = highMonthValDic[1].ToString();
                    textBox29.Value = normalMonthValDic[1].ToString();
                    textBox31.Value = lowMonthValDic[1].ToString();
                    textBox33.Value = elecChargeDic[1].ToString();
                    textBox35.Value = monthValPerUnitDic[1].ToString();
                    textBox37.Value = elecChargeDicPerUnitDic[1].ToString();
                    // 2月
                    textBox27.Value = monthValDic[2].ToString();
                    textBox28.Value = highMonthValDic[2].ToString();
                    textBox30.Value = normalMonthValDic[2].ToString();
                    textBox32.Value = lowMonthValDic[2].ToString();
                    textBox34.Value = elecChargeDic[2].ToString();
                    textBox36.Value = monthValPerUnitDic[2].ToString();
                    textBox38.Value = elecChargeDicPerUnitDic[2].ToString();
                    // 3月
                    textBox60.Value = monthValDic[3].ToString();
                    textBox61.Value = highMonthValDic[3].ToString();
                    textBox62.Value = normalMonthValDic[3].ToString();
                    textBox63.Value = lowMonthValDic[3].ToString();
                    textBox64.Value = elecChargeDic[3].ToString();
                    textBox65.Value = monthValPerUnitDic[3].ToString();
                    textBox66.Value = elecChargeDicPerUnitDic[3].ToString();
                    // 4月
                    textBox78.Value = monthValDic[4].ToString();
                    textBox79.Value = highMonthValDic[4].ToString();
                    textBox80.Value = normalMonthValDic[4].ToString();
                    textBox81.Value = lowMonthValDic[4].ToString();
                    textBox82.Value = elecChargeDic[4].ToString();
                    textBox83.Value = monthValPerUnitDic[4].ToString();
                    textBox84.Value = elecChargeDicPerUnitDic[4].ToString();

                    // 5月
                    textBox96.Value  = monthValDic[5].ToString();
                    textBox97.Value  = highMonthValDic[5].ToString();
                    textBox98.Value  = normalMonthValDic[5].ToString();
                    textBox99.Value  = lowMonthValDic[5].ToString();
                    textBox100.Value = elecChargeDic[5].ToString();
                    textBox101.Value = monthValPerUnitDic[5].ToString();
                    textBox102.Value = elecChargeDicPerUnitDic[5].ToString();
                    // 6月
                    textBox114.Value = monthValDic[6].ToString();
                    textBox115.Value = highMonthValDic[6].ToString();
                    textBox116.Value = normalMonthValDic[6].ToString();
                    textBox117.Value = lowMonthValDic[6].ToString();
                    textBox118.Value = elecChargeDic[6].ToString();
                    textBox119.Value = monthValPerUnitDic[6].ToString();
                    textBox120.Value = elecChargeDicPerUnitDic[6].ToString();
                    // 7月
                    textBox132.Value = monthValDic[7].ToString();
                    textBox133.Value = highMonthValDic[7].ToString();
                    textBox134.Value = normalMonthValDic[7].ToString();
                    textBox135.Value = lowMonthValDic[7].ToString();
                    textBox136.Value = elecChargeDic[7].ToString();
                    textBox137.Value = monthValPerUnitDic[7].ToString();
                    textBox138.Value = elecChargeDicPerUnitDic[7].ToString();
                    // 8月
                    textBox150.Value = monthValDic[8].ToString();
                    textBox151.Value = highMonthValDic[8].ToString();
                    textBox152.Value = normalMonthValDic[8].ToString();
                    textBox153.Value = lowMonthValDic[8].ToString();
                    textBox154.Value = elecChargeDic[8].ToString();
                    textBox155.Value = monthValPerUnitDic[8].ToString();
                    textBox156.Value = elecChargeDicPerUnitDic[8].ToString();
                    // 9月
                    textBox168.Value = monthValDic[9].ToString();
                    textBox169.Value = highMonthValDic[9].ToString();
                    textBox170.Value = normalMonthValDic[9].ToString();
                    textBox171.Value = lowMonthValDic[9].ToString();
                    textBox172.Value = elecChargeDic[9].ToString();
                    textBox173.Value = monthValPerUnitDic[9].ToString();
                    textBox174.Value = elecChargeDicPerUnitDic[9].ToString();
                    // 10月
                    textBox186.Value = monthValDic[10].ToString();
                    textBox187.Value = highMonthValDic[10].ToString();
                    textBox188.Value = normalMonthValDic[10].ToString();
                    textBox189.Value = lowMonthValDic[10].ToString();
                    textBox190.Value = elecChargeDic[10].ToString();
                    textBox191.Value = monthValPerUnitDic[10].ToString();
                    textBox192.Value = elecChargeDicPerUnitDic[10].ToString();
                    // 11月
                    textBox204.Value = monthValDic[11].ToString();
                    textBox205.Value = highMonthValDic[11].ToString();
                    textBox206.Value = normalMonthValDic[11].ToString();
                    textBox207.Value = lowMonthValDic[11].ToString();
                    textBox208.Value = elecChargeDic[11].ToString();
                    textBox209.Value = monthValPerUnitDic[11].ToString();
                    textBox210.Value = elecChargeDicPerUnitDic[11].ToString();
                    // 12月
                    textBox222.Value = monthValDic[12].ToString();
                    textBox223.Value = highMonthValDic[12].ToString();
                    textBox224.Value = normalMonthValDic[12].ToString();
                    textBox225.Value = lowMonthValDic[12].ToString();
                    textBox226.Value = elecChargeDic[12].ToString();
                    textBox227.Value = monthValPerUnitDic[12].ToString();
                    textBox228.Value = elecChargeDicPerUnitDic[12].ToString();
                    // 合计平均月值
                    if (totalMonthVal > 0 && totalValCount > 0)
                    {
                        textBox240.Value = totalMonthVal.ToString("f1");
                        textBox258.Value = (totalMonthVal / totalValCount).ToString("f1");
                    }
                    // 合计平均峰时值
                    if (totalHighVal > 0 && totalHighValCount > 0)
                    {
                        textBox241.Value = totalHighVal.ToString("f1");
                        textBox259.Value = (totalHighVal / totalHighValCount).ToString("f1");
                    }
                    // 合计平均平时值
                    if (totalNormalVal > 0 && totalNormalValCount > 0)
                    {
                        textBox242.Value = totalNormalVal.ToString("f1");
                        textBox260.Value = (totalNormalVal / totalNormalValCount).ToString("f1");
                    }
                    // 合计平均谷时值
                    if (totalLowVal > 0 && totalLowValCount > 0)
                    {
                        textBox243.Value = totalLowVal.ToString("f1");
                        textBox261.Value = (totalLowVal / totalLowValCount).ToString("f1");
                    }
                    // 合计平均月电费
                    if (totalElecCharge > 0 && totalElecChargeCount > 0)
                    {
                        textBox244.Value = totalElecCharge.ToString("f1");
                        textBox262.Value = (totalElecCharge / totalElecChargeCount).ToString("f1");
                    }
                    // 合计平均单位面积电耗
                    if (totalMonthValPerUnit > 0 && totalMonthValPerUnitCount > 0)
                    {
                        textBox245.Value = totalMonthValPerUnit.ToString("f1");
                        textBox263.Value = (totalMonthValPerUnit / totalMonthValPerUnitCount).ToString("f1");
                    }
                    // 合计平均单位面积电费
                    if (totalElecChargeDicPerUnit > 0 && totalElecChargeDicPerUnitCount > 0)
                    {
                        textBox246.Value = totalElecChargeDicPerUnit.ToString("f1");
                        textBox264.Value = (totalElecChargeDicPerUnit / totalElecChargeDicPerUnitCount).ToString("f1");
                    }
                }
            }
        }
Beispiel #5
0
        private void BuildingDetailReport_ItemDataBinding(object sender, EventArgs e)
        {
            var buildingIDObj = ReportParameters["buildingID"].Value;

            if (buildingIDObj != null)
            {
                int                buildingID    = Convert.ToInt32(buildingIDObj);
                IBuildingRepos     buildingRepos = new BuildingRepos();
                BuildingDetailInfo building      = buildingRepos.GetBuilding(buildingID);
                if (building == null)
                {
                    return;
                }
                buildingTable.DataSource = building;

                var lightDataList        = buildingRepos.GetLight(buildingID);
                var officeDataList       = buildingRepos.GetOfficeEquip(buildingID);
                var elevatorDataList     = buildingRepos.GetElevator(buildingID);
                var waterPumpDataList    = buildingRepos.GetWaterPump(buildingID);
                var windMachDataList     = buildingRepos.GetWindMach(buildingID);
                var kitchenEquipDataList = buildingRepos.GetKitchenEquip(buildingID);

                lightTable.DataSource        = lightDataList;
                officeEquipTable.DataSource  = officeDataList;
                elevatorTable.DataSource     = elevatorDataList;
                waterPumpTable.DataSource    = waterPumpDataList;
                windMachTable.DataSource     = windMachDataList;
                kitchenEquipTable.DataSource = kitchenEquipDataList;

                Parameter subReportPara = new Parameter("buildingID", buildingID);
                //A1A2A3
                if (!String.IsNullOrWhiteSpace(building.BDI_AirSys))
                {
                    if (building.BDI_AirSys == "集中式全空气系统")
                    {
                        NavigateToReportAction a1ReportAction = new NavigateToReportAction();
                        a1ReportAction.Parameters.Add(subReportPara);
                        a1ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixA1, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                        textBox26.Action = a1ReportAction;
                        textBox26.Value  = "详见附表A1";
                    }
                    else if (building.BDI_AirSys == "风机盘管+新风系统")
                    {
                        NavigateToReportAction a2ReportAction = new NavigateToReportAction();
                        a2ReportAction.Parameters.Add(subReportPara);
                        a2ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixA2, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                        textBox25.Action = a2ReportAction;
                        textBox25.Value  = "详见附表A2";
                    }
                    else if (building.BDI_AirSys == "分体式空调或VRV的局部式机组系统")
                    {
                        NavigateToReportAction a3ReportAction = new NavigateToReportAction();
                        a3ReportAction.Parameters.Add(subReportPara);
                        a3ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixA3, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                        textBox28.Action = a3ReportAction;
                        textBox28.Value  = "详见附表A3";
                    }
                }
                //B1
                if (!String.IsNullOrWhiteSpace(building.BDI_DevCool))
                {
                    NavigateToReportAction b1ReportAction = new NavigateToReportAction();
                    b1ReportAction.Parameters.Add(subReportPara);
                    b1ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixB1, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                    textBox34.Action = b1ReportAction;
                    textBox34.Value  = "详见附表B1";
                }
                //B2
                if (!String.IsNullOrWhiteSpace(building.BDI_DevHot))
                {
                    NavigateToReportAction b2ReportAction = new NavigateToReportAction();
                    b2ReportAction.Parameters.Add(subReportPara);
                    b2ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixB2, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                    textBox36.Action = b2ReportAction;
                    textBox36.Value  = "详见附表B2";
                }
                //B3
                if (!String.IsNullOrWhiteSpace(building.BDI_LiBr))
                {
                    NavigateToReportAction b3ReportAction = new NavigateToReportAction();
                    b3ReportAction.Parameters.Add(subReportPara);
                    b3ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixB3, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                    textBox60.Action = b3ReportAction;
                    textBox60.Value  = "详见附表B3";
                }
                //B4
                if (!String.IsNullOrWhiteSpace(building.BDI_AirSplit))
                {
                    NavigateToReportAction b4ReportAction = new NavigateToReportAction();
                    b4ReportAction.Parameters.Add(subReportPara);
                    b4ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixB4, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                    textBox37.Action = b4ReportAction;
                    textBox37.Value  = "详见附表B4";
                }
                //B5
                if (!String.IsNullOrWhiteSpace(building.BDI_BoilerPower))
                {
                    NavigateToReportAction b5ReportAction = new NavigateToReportAction();
                    b5ReportAction.Parameters.Add(subReportPara);
                    b5ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixB5, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                    textBox39.Action = b5ReportAction;
                    textBox39.Value  = "详见附表B5";
                }
                //B6
                if (!String.IsNullOrWhiteSpace(building.BDI_Boiler))
                {
                    NavigateToReportAction b6ReportAction = new NavigateToReportAction();
                    b6ReportAction.Parameters.Add(subReportPara);
                    b6ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixB6, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                    textBox41.Action = b6ReportAction;
                    textBox41.Value  = "详见附表B6";
                }
                //B7
                if (!String.IsNullOrWhiteSpace(building.BDI_PowerHot))
                {
                    NavigateToReportAction b7ReportAction = new NavigateToReportAction();
                    b7ReportAction.Parameters.Add(subReportPara);
                    b7ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixB7, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                    textBox45.Action = b7ReportAction;
                    textBox45.Value  = "详见附表B7";
                }
                //B8
                if (!String.IsNullOrWhiteSpace(building.BDI_DevOther))
                {
                    NavigateToReportAction b8ReportAction = new NavigateToReportAction();
                    b8ReportAction.Parameters.Add(subReportPara);
                    b8ReportAction.ReportDocumentType = "EnergyMonitor.Controllers.Admin.ReportsTemplate.BuildingAppendixB8, Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                    textBox47.Action = b8ReportAction;
                    textBox47.Value  = "详见附表B8";
                }
            }
        }