示例#1
0
        //形成输出的datatable
        private System.Data.DataTable OutTable(System.Data.DataTable datatable, ref Dictionary <string, Columqk> viscol)
        {
            System.Data.DataTable dt        = new  System.Data.DataTable();
            List <string>         listColID = new List <string>();

            listColID.Add("Title");
            dt.Columns.Add("Title", typeof(string));
            dt.Columns["Title"].Caption = "项目";
            viscol["Title"]             = new Columqk("项目", 3, 2);
            dt.Columns.Add("ParentID", typeof(string));

            foreach (DataColumn column in datatable.Columns)
            {
                if (column.ColumnName.IndexOf("y") >= 0)
                {
                    int year = Convert.ToInt32(column.ColumnName.Substring(1));

                    if (year >= forecastReport.StartYear && year <= forecastReport.EndYear)
                    {
                        listColID.Add(column.ColumnName);
                        viscol[column.ColumnName] = new Columqk(year + "年", 2, 2);
                        dt.Columns.Add(column.ColumnName, typeof(double));
                    }
                }
                //else
                //    if (column.FieldName == "ParentID")
                //    {
                //        dt.Columns.Add("ParentID", typeof(string));
                //        listColID.Add("ParentID");
                //        dt.Columns["ParentID"].Caption = "父ID";
                //    }
            }
            listColID.Add("ParentID");
            dt.Columns["ParentID"].Caption = "父ID";

            int itemp = -4;
            int jtemp = -4;

            foreach (DataRow node in datatable.Rows)
            {
                jtemp = itemp;
                AddNodeDataToDataTable(dt, datatable, node, listColID, ref itemp, jtemp);
                // itemp++;
            }
            return(dt);
        }
示例#2
0
        private System.Data.DataTable ResultDataTable1(System.Data.DataTable sourceDataTable, ref Dictionary<string, Columqk> viscol, Ps_YearRange yAnge)
        {
            System.Data.DataTable dtReturn = new System.Data.DataTable();
            dtReturn.Columns.Add("Title", typeof(string));
            viscol["Title"] = new Columqk("名称", 3, 2);
            for (int i = yAnge.StartYear; i <= yAnge.FinishYear; i++)
            {

                dtReturn.Columns.Add(i.ToString() + "年", typeof(double));
                viscol[i.ToString() + "年"] = new Columqk(i.ToString() + "年", 2, 2);
            }

            int nRowMaxLoad = 0;//地区最高负荷所在行
            int nRowMaxPower = 0;//地区电网供电能力所在行
            int nRowMaxPowerLow = 0;//枯水期地区电网供电能力所在行

            #region 填充数据
            for (int i = 0; i < sourceDataTable.Rows.Count; i++)
            {
                if (sourceDataTable.Rows[i]["Title"].ToString().IndexOf("500千伏需要容量") != -1)
                    continue;
                DataRow newRow = dtReturn.NewRow();
                DataRow sourceRow = sourceDataTable.Rows[i];
                foreach (DataColumn column in dtReturn.Columns)
                {
                    newRow[column.ColumnName] = sourceRow[ConvertYear(column.ColumnName)];
                }
                dtReturn.Rows.Add(newRow);

            }
            #endregion

            return dtReturn;
        }
示例#3
0
        //根据选择的统计年份,生成统计结果数据表
        private System.Data.DataTable ResultDataTable(System.Data.DataTable sourceDataTable, ref Dictionary<string, Columqk> viscol, Ps_YearRange yAnge)
        {
            System.Data.DataTable dtReturn = new System.Data.DataTable();
            dtReturn.Columns.Add("Title", typeof(string));
            viscol["Title"] = new Columqk("名称", 3, 2);

            for (int i = yAnge.StartYear; i <= yAnge.FinishYear; i++)
            {

                dtReturn.Columns.Add(i.ToString() + "年", typeof(double));
                viscol[i.ToString() + "年"] = new Columqk(i.ToString() + "年", 2, 2);
            }

            int nRowMaxLoad = 0;//地区最高负荷所在行
            int nRowMaxPower = 0;//地区电网供电能力所在行
            int nRowMaxPowerLow = 0;//枯水期地区电网供电能力所在行

            #region 填充数据
            for (int i = 0; i < sourceDataTable.Rows.Count; i++)
            {
                DataRow newRow = dtReturn.NewRow();
                DataRow sourceRow = sourceDataTable.Rows[i];
                foreach (DataColumn column in dtReturn.Columns)
                {
                    newRow[column.ColumnName] = sourceRow[ConvertYear(column.ColumnName)];
                }
                dtReturn.Rows.Add(newRow);

            }
            #endregion

            //#region 计算电力盈亏和枯水期地区电力盈亏
            //foreach (ChoosedYears choosedYear in listChoosedYears)
            //{
            //    object maxLoad = dtReturn.Rows[nRowMaxLoad][choosedYear.Year + "年"];
            //    if (maxLoad != DBNull.Value)
            //    {
            //        object maxPower = dtReturn.Rows[nRowMaxPower][choosedYear.Year + "年"];
            //        if (maxPower != DBNull.Value)
            //        {
            //            dtReturn.Rows[nRowMaxPower + 1][choosedYear.Year + "年"] = (double)maxPower - (double)maxLoad;
            //        }

            //        maxPower = dtReturn.Rows[nRowMaxPowerLow][choosedYear.Year + "年"];
            //        if (maxPower != DBNull.Value)
            //        {
            //            dtReturn.Rows[nRowMaxPowerLow + 1][choosedYear.Year + "年"] = (double)maxPower - (double)maxLoad;
            //        }
            //    }
            //}
            //#endregion

            return dtReturn;
        }
示例#4
0
        //重点建设项目统计
        private void build_zdjsxm()
        {
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "分区县供电实绩_重点建设工业及用电需求表";
            Ps_YearRange py = new Ps_YearRange();
            py.Col4 = "区县发展实绩";
            py.Col5 = ProjectUID;
            int firstyear, endyear;
            IList<Ps_YearRange> li = Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py);
            if (li.Count > 0)
            {
                firstyear = li[0].StartYear;
                endyear = li[0].FinishYear;
            }
            else
            {
                firstyear = 2001;
                endyear = DateTime.Today.Year - 1;
                py.BeginYear = 2001;
                py.FinishYear = endyear;
                py.StartYear = firstyear;
                py.EndYear = 2060;
                py.ID = Guid.NewGuid().ToString();
                Services.BaseService.Create<Ps_YearRange>(py);
            }
            datatable = getfqxdltable();
            datatable2 = getfqxdltable2(datatable);
            //形成统计表

            System.Data.DataTable showtable = new System.Data.DataTable();//要显示的datatable
            //setcols431
            cols.Clear();
            colyears.Clear();
            colsum.Clear();
            showtable.Columns.Add("Col1", typeof(string)).Caption = "编号";
            viscol["Col1"] = new Columqk("编号", 3, 2);
            cols.Add("Col1");
            showtable.Columns.Add("Title", typeof(string)).Caption = "企业(项目)名称";
            viscol["Title"] = new Columqk("企业(项目)名称", 3, 2);
            cols.Add("Title");
            showtable.Columns.Add("Col2", typeof(string)).Caption = "建设规模及内容";
            cols.Add("Col2");
            viscol["Col2"] = new Columqk("建设规模及内容", 3, 2);
            showtable.Columns.Add("Col7", typeof(string)).Caption = "计划建设年限";
            cols.Add("Col7");
            viscol["Col7"] = new Columqk("计划建设年限", 3, 2);
            showtable.Columns.Add("Col6", typeof(string)).Caption = "工作进展";
            cols.Add("Col6");
            viscol["Col6"] = new Columqk("工作进展", 3, 2);
            DataColumn dcol = showtable.Columns.Add("y1990", typeof(double));

            dcol.Caption = "用电量";
            viscol["y1990"] = new Columqk("用电量", 2, 2);
            //dcol = showtable.Columns.Add("y1990_sum", typeof(double));
            //dcol.Caption = "正常用电量";
            //dcol.Expression = "IIF(Title='小计',sum(y1990),y1990)";

            cols.Add("y1990");
            showtable.Columns.Add("y1991", typeof(double)).Caption = "负荷";
            viscol["y1991"] = new Columqk("负荷", 2, 2);
            cols.Add("y1991");

            colsum.Add("y1990");
            colsum.Add("y1991");
            ConvertTreeListToDataTable511(ref showtable, datatable, datatable2, firstyear, endyear);
            if (!shjjbyyear)
            {
                creatsheetbydt(title, showtable, viscol);
            }

            else
            {
                recreatsheetbydt(title, showtable, viscol, 5);
            }
        }
示例#5
0
        private void build_YearMAX()
        {
            string pjt = " ProjectID='" + MIS.ProgUID + "'";
              IList<PS_Table_AreaWH>   AreaList = Common.Services.BaseService.GetList<PS_Table_AreaWH>("SelectPS_Table_AreaWHByConn", pjt);
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "年最大负荷数据";
            IList<BurdenLine> list = Services.BaseService.GetList<BurdenLine>("SelectBurdenLineByWhere", " uid like '%" + Itop.Client.MIS.ProgUID + "%'  order by BurdenDate");

            int i = 1;
            int yeardata = 0;

            //IList<BurdenYear> li = new List<BurdenYear>();
            BurdenYear by = new BurdenYear();
            foreach (BurdenLine bl in list)
            {
                double burmax = 0;
                burmax = Math.Max(bl.Hour1, bl.Hour2);
                burmax = Math.Max(burmax, bl.Hour3);
                burmax = Math.Max(burmax, bl.Hour4);
                burmax = Math.Max(burmax, bl.Hour5);
                burmax = Math.Max(burmax, bl.Hour6);
                burmax = Math.Max(burmax, bl.Hour7);
                burmax = Math.Max(burmax, bl.Hour8);
                burmax = Math.Max(burmax, bl.Hour9);
                burmax = Math.Max(burmax, bl.Hour10);
                burmax = Math.Max(burmax, bl.Hour11);
                burmax = Math.Max(burmax, bl.Hour12);
                burmax = Math.Max(burmax, bl.Hour13);
                burmax = Math.Max(burmax, bl.Hour14);
                burmax = Math.Max(burmax, bl.Hour15);
                burmax = Math.Max(burmax, bl.Hour16);
                burmax = Math.Max(burmax, bl.Hour17);
                burmax = Math.Max(burmax, bl.Hour18);
                burmax = Math.Max(burmax, bl.Hour19);
                burmax = Math.Max(burmax, bl.Hour20);
                burmax = Math.Max(burmax, bl.Hour21);
                burmax = Math.Max(burmax, bl.Hour22);
                burmax = Math.Max(burmax, bl.Hour23);
                burmax = Math.Max(burmax, bl.Hour24);

                if (yeardata != bl.BurdenDate.Year)
                {
                    if (yeardata == 0)
                    {
                        yeardata = bl.BurdenDate.Year;
                        by = new BurdenYear();
                        by.BurdenYears = yeardata;
                        by.Values = burmax;
                        by.BurdenDate = bl.BurdenDate;
                        by.AreaID = bl.AreaID;
                    }
                    else
                    {
                        li.Add(by);
                        yeardata = bl.BurdenDate.Year;
                        by = new BurdenYear();
                        by.BurdenYears = yeardata;
                        by.Values = burmax;
                        by.BurdenDate = bl.BurdenDate;
                        by.AreaID = bl.AreaID;
                    }

                }
                else
                {
                    if (by.Values < burmax)
                    {
                        by.Values = burmax;
                        by.BurdenDate = bl.BurdenDate;
                        by.AreaID = bl.AreaID;
                    }

                    //by.Values = Math.Max(by.Values,burmax);
                    //by.BurdenDate = bl.BurdenDate;
                }
                if (i == list.Count)
                    li.Add(by);
                i++;
            }
               System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("s", typeof(string));
            viscol["s"] = new Columqk("时间",3,2);
            int listCount = li.Count;

            int numi = 0;
            int numj = 0;
            int numk = 0;
            foreach (BurdenYear bys in li)
            {
                numi++;
                numj++;
                numk++;

                dt.Columns.Add("Year" + bys.BurdenYears.ToString(), typeof(double));
                viscol["Year" + bys.BurdenYears.ToString()] = new Columqk(FindArea(bys.AreaID,AreaList) + "_" + bys.BurdenYears.ToString() + "年", 3, 2);
            }
            DataRow row = dt.NewRow();
            row["s"] = "负荷";
            foreach (BurdenYear bys1 in li)
            {
                row["Year" + bys1.BurdenYears.ToString()] = bys1.Values;
            }
            dt.Rows.Add(row);
            if(!shjjbyyear)
            {
                creatsheetbydt(title, dt, viscol);
            }

            else
            {
                recreatsheetbydt(title, dt, viscol, 8);
            }
        }
示例#6
0
        //月最大负荷数据
        private void build_monthmax()
        {
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "月最大负荷数据";
            IList<BurdenMonth> list = Services.BaseService.GetList<BurdenMonth>("SelectBurdenMonthByWhere", " uid like '%" + Itop.Client.MIS.ProgUID + "%' order by BurdenYear ");
            System.Data.DataTable dt = Itop.Common.DataConverter.ToDataTable((IList)list, typeof(BurdenMonth));
            foreach (DataRow dr in dt.Rows)
            {
                PS_Table_AreaWH pa = Client.Common.Services.BaseService.GetOneByKey<PS_Table_AreaWH>(dr["AreaID"].ToString());
                dr["AreaID"] = pa.Title;

            }
            viscol["AreaID"] = new Columqk("地区", 3, 2);
            viscol["BurdenYear"] = new Columqk("年", 3, 2);
            viscol["Month1"] = new Columqk("1月", 2, 2);
            viscol["Month2"] = new Columqk("2月", 2, 2);
            viscol["Month3"] = new Columqk("3月", 2, 2);
            viscol["Month4"] = new Columqk("4月", 2, 2);
            viscol["Month5"] = new Columqk("5月", 2, 2);
            viscol["Month6"] = new Columqk("6月", 2, 2);
            viscol["Month7"] = new Columqk("7月", 2, 2);
            viscol["Month8"] = new Columqk("8月", 2, 2);
            viscol["Month9"] = new Columqk("9月", 2, 2);
            viscol["Month10"] = new Columqk("10月", 2, 2);
            viscol["Month11"] = new Columqk("11月", 2, 2);
            viscol["Month12"] = new Columqk("12月", 2, 2);
            if (!shjjbyyear)
            {
                creatsheetbydt(title, dt, viscol);
            }

            else
            {
                recreatsheetbydt(title, dt, viscol, 7);
            }
        }
示例#7
0
        //输电线路情况表
        private void build_lineqk()
        {
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "变电站情况表";
            System.Data.DataTable dt = InitData();
            viscol["Num"] = new Columqk("序号", 3, 2);
            viscol["Name"] = new Columqk("线路名称", 3, 2);
            viscol["RateVolt"] = new Columqk("电压等级", 3, 2);
            viscol["AreaID"] = new Columqk("区域", 3, 2);
            viscol["Iname"] = new Columqk("高压侧母线", 3, 2);
            viscol["Jname"] = new Columqk("低压侧母线", 3, 2);
            viscol["LineType"] = new Columqk("导线型号", 3, 2);
            viscol["LineLength"] = new Columqk("架空线长度", 2, 2);
            viscol["Length2"] = new Columqk("电缆线长度", 2, 2);
            viscol["OperationYear"] = new Columqk("投产年份", 3, 2);
            if (!shjjbyyear)
            {
                creatsheetbydt(title, dt, viscol);
            }

            else
            {
                recreatsheetbydt(title, dt, viscol, 10);
            }
        }
示例#8
0
        private void build_fqxgdsj()
        {
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "分区县供电实绩";
            //对数据进行处理
             Ps_YearRange py = new Ps_YearRange();
            py.Col4 = "分区供电实绩";
            py.Col5 = ProjectUID;
            int firstyear, endyear;
            IList<Ps_YearRange> li = Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py);
            if (li.Count > 0)
            {
                firstyear = li[0].StartYear;
                endyear = li[0].FinishYear;
            }
            else
            {
                firstyear = 2000;
                endyear = 2008;
                py.BeginYear = 1990;
                py.FinishYear = endyear;
                py.StartYear = firstyear;
                py.EndYear = 2060;
                py.ID = Guid.NewGuid().ToString();
                Services.BaseService.Create<Ps_YearRange>(py);
            }

            System.Data.DataTable datatable = getfqgdsjtable();
            System.Data.DataTable dt = new System.Data.DataTable();
            List<string> listColID = new List<string>();

            listColID.Add("Title");
            dt.Columns.Add("Title", typeof(string));
            dt.Columns["Title"].Caption = "项目";
            viscol["Title"] = new Columqk("项目", 3, 2);
            dt.Columns.Add("ParentID", typeof(string));

            foreach (System.Data.DataColumn column in datatable.Columns)
            {
                if (column.ColumnName.IndexOf("y") >= 0)
                {
                    int year=Convert.ToInt32(column.ColumnName.Substring(1));
                    if (year>=firstyear &&year<=endyear)
                    {
                        listColID.Add(column.ColumnName);
                        dt.Columns.Add(column.ColumnName, typeof(double));
                        viscol[column.ColumnName] = new Columqk(year + "年", 2, 2);
                    }

                }
                //else
                //    if (column.FieldName == "ParentID")
                //    {
                //        dt.Columns.Add("ParentID", typeof(string));
                //        listColID.Add("ParentID");
                //        dt.Columns["ParentID"].Caption = "父ID";
                //    }
            }
            listColID.Add("ParentID");
            dt.Columns["ParentID"].Caption = "父ID";

            int itemp = -4;
            int jtemp = -4;
            foreach (DataRow node in datatable.Rows)
            {
                jtemp = itemp;
                AddNodeDataToDataTable(ref dt, node, listColID, ref itemp, jtemp);
                // itemp++;
            }
            if (!shjjbyyear)
            {
                creatsheetbydt(title, dt, viscol);
            }

            else
            {
                recreatsheetbydt(title, dt, viscol, 3);
            }
        }
示例#9
0
        //典型日最大负荷
        private void build_dxfh()
        {
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "典型日最大负荷数据";
            IList<BurdenLine> list = Services.BaseService.GetList<BurdenLine>("SelectBurdenLineByWhere", " uid like '%" + Itop.Client.MIS.ProgUID + "%' order by BurdenDate");
               System.Data.DataTable dT= Itop.Common.DataConverter.ToDataTable((IList)list, typeof(BurdenLine));
            foreach (DataRow dr in dT.Rows)
            {
                PS_Table_AreaWH pa = Client.Common.Services.BaseService.GetOneByKey<PS_Table_AreaWH>(dr["AreaID"].ToString());
                dr["AreaID"] = pa.Title;

            }
            viscol["AreaID"]=new Columqk("地区",3,2);
            viscol["BurdenDate"] = new Columqk("日期", 3, 2);
            viscol["Season"] = new Columqk("季节", 3, 2);
            viscol["Hour1"] = new Columqk("1时",2, 2);
            viscol["Hour2"] = new Columqk("2时", 2, 2);
            viscol["Hour3"] = new Columqk("3时", 2, 2);
            viscol["Hour4"] = new Columqk("4时", 2, 2);
            viscol["Hour5"] = new Columqk("5时", 2, 2);
            viscol["Hour6"] = new Columqk("6时", 2, 2);
            viscol["Hour7"] = new Columqk("7时", 2, 2);
            viscol["Hour8"] = new Columqk("8时", 2, 2);
            viscol["Hour9"] = new Columqk("9时", 2, 2);
            viscol["Hour10"] = new Columqk("10时", 2, 2);
            viscol["Hour11"] = new Columqk("11时", 2, 2);
            viscol["Hour12"] = new Columqk("12时", 2, 2);
            viscol["Hour13"] = new Columqk("13时", 2, 2);
            viscol["Hour14"] = new Columqk("14时", 2, 2);
            viscol["Hour15"] = new Columqk("15时", 2, 2);
            viscol["Hour16"] = new Columqk("16时", 2, 2);
            viscol["Hour17"] = new Columqk("17时", 2, 2);
            viscol["Hour18"] = new Columqk("18时", 2, 2);
            viscol["Hour19"] = new Columqk("19时", 2, 2);
            viscol["Hour20"] = new Columqk("20时", 2, 2);
            viscol["Hour21"] = new Columqk("21时", 2, 2);
            viscol["Hour22"] = new Columqk("22时", 2, 2);
            viscol["Hour23"] = new Columqk("23时", 2, 2);
            viscol["Hour24"] = new Columqk("24时", 2, 2);
            viscol["IsType"] = new Columqk("是否为典型日", 3, 2);
            viscol["IsMaxDate"] = new Columqk("是否为最大日", 3, 2);
            if (!shjjbyyear)
            {
                creatsheetbydt(title, dT, viscol);
            }

            else
            {
                recreatsheetbydt(title, dT, viscol, 6);
            }
        }
示例#10
0
        //电力发展实绩社会经济用电情况
        private void build_dlhistoryjjyd()
        {
            bool IsFist = true;
            int RealFistYear = 0; ;
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "电力发展实绩_分行业统计";
            Ps_YearRange py = new Ps_YearRange();
            py.Col4 = "电力发展实绩";
            py.Col5 = Itop.Client.MIS.ProgUID;
            int firstyear, endyear;
            IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py);
            if (li.Count > 0)
            {
                firstyear = li[0].StartYear;
                endyear = li[0].FinishYear;
            }
            else
            {
                firstyear = 1990;
                endyear = 2020;
                py.BeginYear = 1990;
                py.FinishYear = endyear;
                py.StartYear = firstyear;
                py.EndYear = 2060;
                py.ID = Guid.NewGuid().ToString();
                Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py);
            }

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("Title");
            viscol["Title"]=new Columqk("统计类别",3,2);
            Ps_History psp_Type = new Ps_History();
            psp_Type.Forecast = 1;
            psp_Type.Col4 = Itop.Client.MIS.ProgUID;
            IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type);
            System.Data.DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History));

            DataRow[] rows1 = dataTable.Select("Title like '全地区GDP%'");
            // DataRow[] rows2 = dataTable.Select("Title like '全社会供电量%'");
            DataRow[] rows4 = dataTable.Select("Title like '全社会用电量%'");
            //DataRow[] rows5 = dataTable.Select("Title like '全社会最大负荷%'");
            DataRow[] rows7 = dataTable.Select("Title like '年末总人口%'");
            DataRow[] rows8 = dataTable.Select("Title='居民用电'");

            if (rows1.Length == 0)
            {
                MessageBox.Show("缺少全地区GDP数据!");
                this.Close();
                return;
            }
            //if (rows2.Length == 0)
            //{
            //    MessageBox.Show("缺少全社会供电量数据!");
            //    this.Close();
            //}
            if (rows4.Length == 0)
            {
                MessageBox.Show("缺少全社会用电量数据!");
                this.Close();
                return;
            }
            //if (rows5.Length == 0)
            //{
            //    MessageBox.Show("缺少全社会最大负荷数据!");
            //    this.Close();
            //}
            if (rows7.Length == 0)
            {
                MessageBox.Show("缺少年末总人口数据!");
                this.Close();
                return;
            }

            string GDPUnits = fpcommon.FindUnits(rows1[0]["Title"].ToString());
            //全社会供电量单位
            //AGdlUnits = Historytool.FindUnits(rows2[0]["Title"].ToString());
            //全社会用电量单位
            string AYdlUnits = fpcommon.FindUnits(rows4[0]["Title"].ToString());
            //全社会最大负荷单位
            // AMaxFhUnits = Historytool.FindUnits(rows5[0]["Title"].ToString());
            //年末总人口单位
               string NMARkUnits = fpcommon.FindUnits(rows7[0]["Title"].ToString());

            string pid = rows1[0]["ID"].ToString();
            string sid = rows4[0]["ID"].ToString();

            ///全地区GDP子类
            DataRow[] rows3 = dataTable.Select("ParentID='" + pid + "'");
            ///会社会用电量子类
            DataRow[] rows6 = dataTable.Select("ParentID='" + sid + "'");
            int m = -1;

            for (int i = firstyear; i <= endyear; i++)
            {
                //如果点击统计按钮
                if (shjjbyyear)
                {
                    if (!ht.ContainsValue(i))
                    continue;
                }

                if (IsFist)
                {
                    RealFistYear = i;
                    IsFist = false;
                }
                m++;
                dt.Columns.Add("y" + i, typeof(double));
                viscol["y"+i]=new Columqk(i+"年",2,2);

                //if (!ht1.ContainsValue(i))
                //    continue;

                dt.Columns.Add("m" + i, typeof(double));
                viscol["m"+i]=new Columqk("年增长率(%)",1,2);

            }

            double sum = 0;// 全地区GDP数据
            try { sum = Convert.ToDouble(rows1[0]["y" + firstyear]); }
            catch { }

            double sum51 = 0;// 全社会用电量数据
            try { sum51 = Convert.ToDouble(rows4[0]["y" + firstyear]); }
            catch { }
            double sum52 = 0;
            double sum53 = 0;

            double sum1 = 0;
            double sum2 = 0;
            double sum3 = 0;
            double sum4 = 0;
            double sum5 = 0;
            double sum6 = 0;
            double sum7 = 0;
            double sum8 = 0;
            double sum9 = 0;
            double sum10 = 0;
            double sum11 = 0;
            double sum12 = 0;
            double sum13 = 0;
            DataRow row = dt.NewRow();
            DataRow row3 = dt.NewRow();
            DataRow row4 = dt.NewRow();
            DataRow row5 = dt.NewRow();
            DataRow row6 = dt.NewRow();
            DataRow row7 = dt.NewRow();
            DataRow row8 = dt.NewRow();
            DataRow row9 = dt.NewRow();
            DataRow row10 = dt.NewRow();
            DataRow row11 = dt.NewRow();
            row["ID"] = Guid.NewGuid().ToString();
            row["Title"] = "一、地区生产总值(GDP," + GDPUnits + ")";

            m = firstyear;

            for (int j = firstyear; j <= endyear; j++)
            {
                if (shjjbyyear)
                {
                    if (!ht.ContainsValue(j))
                        continue;
                }

                try { sum1 = Convert.ToDouble(rows1[0]["y" + j]); }
                catch { }
                row["y" + j] = sum1;

                try { sum51 = Convert.ToDouble(rows4[0]["y" + j]); }
                catch { }

                if (m != firstyear)//表示不是第一年,以后的年份要算增长
                {
                    try { sum2 = Convert.ToDouble(rows1[0]["y" + (j - 1)]); }
                    catch { }

                    try { sum52 = Convert.ToDouble(rows4[0]["y" + (j - 1)]); }
                    catch { }
                    if (sum52 != 0)
                        sum53 = sum51 * 100 / sum52 - 100;//用电量增长

                    if (sum2 != 0)
                        sum3 = sum1 * 100 / sum2 - 100;//GDP增长

                    row3["y" + j] = sum3;
                }
                else
                    row3["y" + j] = 1;

                try { sum4 = Convert.ToDouble(rows4[0]["y" + j]); }
                catch { }
                row4["y" + j] = sum4;//用电量

                //try { sum5 = Convert.ToDouble(rows5[0]["y" + j]); }
                //catch { }
                //row5["y" + j] = sum5;//最大负荷

                //if (sum5 != 0)
                //    sum6 = sum4 * 10000 / sum5;
                //row6["y" + j] = sum6;// 计算全社会最大负荷利用小时数

                //try { sum7 = Convert.ToDouble(rows2[0]["y" + j]); }
                //catch { }

                if (m != firstyear)
                {
                    //if (sum53 != 0)
                    //    sum8 = sum3 / sum53;
                    //row7["y" + j] = sum8;//原计算
                    if (sum3 != 0)
                        sum8 = sum53 / sum3;
                    row7["y" + j] = sum8;//弹性系数,电力消费增长速度与国民经济增长的比值lgm
                }
                else
                    row7["y" + j] = 1;

                try { sum9 = Convert.ToDouble(rows7[0]["y" + j]); }//年末人口
                catch { }

                if (sum9 != 0)
                {
                    if (AYdlUnits.Contains("亿") && NMARkUnits.Contains("万人"))//亿kWh  万人
                    {
                        sum10 = sum51 * 10000 / sum9;//人均用电量
                    }
                    else if (AYdlUnits.Contains("万") && NMARkUnits.Contains("万人"))//万kWh  万人
                    {
                        sum10 = sum51 / sum9;//人均用电量
                    }
                    else
                    {
                        MessageBox.Show("全社会用电量或年末总人口的单位错误!请用默认类别管理较对!(亿kWh,万kWh,万人)");
                        this.Close();
                        return;
                    }

                }
                row8["y" + j] = sum10;

                if (sum1 != 0)
                {
                    if (AYdlUnits.Contains("亿") && GDPUnits.Contains("亿元"))//亿kWh 亿元
                    {
                        sum11 = sum4 * 10000 / sum1;//单产耗能
                    }
                    else if (AYdlUnits.Contains("万") && GDPUnits.Contains("亿元"))//万kWh  亿元
                    {
                        sum11 = sum4 / sum1;//单产耗能
                    }
                    else
                    {
                        MessageBox.Show("全社会用电量或全地区GDP的单位错误!请用默认类别管理较对!(亿kWh,万kWh,亿元)");
                        this.Close();
                        return;
                    }
                }
                row9["y" + j] = sum11;//单产耗能

                if (rows8.Length > 0)
                {
                    try { sum12 = Convert.ToDouble(rows8[0]["y" + j]); }
                    catch { }
                    row11["y" + j] = sum12;

                    if (sum9 != 0)
                    {
                        if (AYdlUnits.Contains("亿") && NMARkUnits.Contains("万人"))//亿kWh 万人
                        {
                            sum13 = sum12 * 10000 / sum9;//居民用电
                        }
                        else if (AYdlUnits.Contains("万") && NMARkUnits.Contains("万人"))//万kWh  万人
                        {
                            sum13 = sum12 / sum9;//居民用电
                        }
                        else
                        {
                            MessageBox.Show("全社会用电量或年末总人口的单位错误!请用默认类别管理较对!(亿kWh,万kWh,万人)");
                            this.Close();
                            return;
                        }

                    }
                    row10["y" + j] = sum13;
                }
                else
                {
                    row10["y" + j] = sum13;
                }
                m++;
            }

            dt.Rows.Add(row);

            for (int k = 0; k < rows3.Length; k++)
            {
                double su1 = 0;
                double su2 = 0;
                double su3 = 0;

                DataRow ro1 = dt.NewRow();
                ro1["ID"] = Guid.NewGuid().ToString();
                ro1["Title"] = rows3[k]["Title"].ToString();

                DataRow ro2 = dt.NewRow();
                ro2["ID"] = Guid.NewGuid().ToString();
                ro2["Title"] = "比例(%)";

                for (int j = firstyear; j <= endyear; j++)
                {
                    if (shjjbyyear)
                    {
                     if (!ht.ContainsValue(j))
                        continue;
                    }

                    try { su1 = Convert.ToDouble(rows1[0]["y" + j]); }
                    catch { }
                    su2 = 0;
                    su3 = 0;
                    try { su2 = Convert.ToDouble(rows3[k]["y" + j]); }
                    catch { }
                    ro1["y" + j] = su2;

                    if (su1 != 0)
                        su3 = su2 * 100 / su1;
                    ro2["y" + j] = su3;

                }

                dt.Rows.Add(ro1);
                dt.Rows.Add(ro2);

            }

            row3["ID"] = Guid.NewGuid().ToString();
            row3["Title"] = "地区生产总值增长率(%)";
            dt.Rows.Add(row3);

            row4["ID"] = Guid.NewGuid().ToString();
            row4["Title"] = "二、全社会用电量(" + AYdlUnits + ")";
            dt.Rows.Add(row4);

            //row5["ID"] = Guid.NewGuid().ToString();
            //row5["Title"] = "最大负荷(万千瓦)";
            //dt.Rows.Add(row5);

            //row6["ID"] = Guid.NewGuid().ToString();
            //row6["Title"] = "最大负荷利用小时数(小时)";
            //dt.Rows.Add(row6);

            for (int k = 0; k < rows6.Length; k++)
            {
                double su1 = 0;
                double su2 = 0;
                double su3 = 0;

                DataRow ro1 = dt.NewRow();
                ro1["ID"] = Guid.NewGuid().ToString();
                ro1["Title"] = rows6[k]["Title"].ToString();

                DataRow ro2 = dt.NewRow();
                ro2["ID"] = Guid.NewGuid().ToString();
                ro2["Title"] = "比例(%)";

                for (int j = firstyear; j <= endyear; j++)
                {
                    if (shjjbyyear)
                    {
                        if (!ht.ContainsValue(j))
                            continue;
                    }

                    try { su1 = Convert.ToDouble(rows4[0]["y" + j]); }
                    catch { }
                    su2 = 0;
                    su3 = 0;
                    try { su2 = Convert.ToDouble(rows6[k]["y" + j]); }
                    catch { }
                    ro1["y" + j] = su2;

                    if (su1 != 0)
                        su3 = su2 * 100 / su1;
                    ro2["y" + j] = su3;

                }

                dt.Rows.Add(ro1);
                dt.Rows.Add(ro2);

            }

            row7["ID"] = Guid.NewGuid().ToString();
            row7["Title"] = "弹性系数";
            dt.Rows.Add(row7);

            row8["ID"] = Guid.NewGuid().ToString();
            row8["Title"] = "人均用电量(千瓦时/人)";
            dt.Rows.Add(row8);

            row9["ID"] = Guid.NewGuid().ToString();
            row9["Title"] = "GDP单耗(千瓦时/万元)";
            dt.Rows.Add(row9);

            for (int k = 0; k < rows6.Length; k++)
            {
                double su1 = 0;
                double su2 = 0;
                double su3 = 0;

                DataRow ro1 = dt.NewRow();
                ro1["ID"] = Guid.NewGuid().ToString();
                ro1["Title"] = rows6[k]["Title"].ToString();

                for (int j = firstyear; j <= endyear; j++)
                {
                    if (shjjbyyear)
                    {
                        if (!ht.ContainsValue(j))
                            continue;
                    }

                    su1 = 0;
                    su2 = 0;
                    su3 = 0;
                    try { su1 = Convert.ToDouble(rows6[k]["y" + j]); }
                    catch { }
                    try { su2 = Convert.ToDouble(rows3[k]["y" + j]); }
                    catch { }

                    if (su2 != 0)
                    { su3 = su1 * 10000 / su2; }
                    else
                        su3 = su1;
                    ro1["y" + j] = su3;
                }
                if (rows6[k]["Title"].ToString().IndexOf("居民") >= 0)
                    continue;
                dt.Rows.Add(ro1);

            }

            row10["ID"] = Guid.NewGuid().ToString();
            row10["Title"] = "居民用电(千瓦时/人)";
            dt.Rows.Add(row10);

            double d = 0;
            foreach (DataRow drw1 in dt.Rows)
            {
                try
                {
                    d = (double)drw1["y" + RealFistYear];
                }
                catch { }
                foreach (DataColumn dc in dt.Columns)
                {
                    if (dc.ColumnName.IndexOf("m") >= 0)
                    {
                        string s = dc.ColumnName.Replace("m", "");
                        int y1 = int.Parse(s);
                        double d1 = 0;
                        try
                        {
                            d1 = (double)drw1["y" + s];
                        }
                        catch { }

                        double sss = Math.Round(Math.Pow(d1 / d, 1.0 / (y1 - RealFistYear)) - 1, 4);

                        if (sss.ToString() == "非数字")
                            sss = 0;
                        drw1["m" + s] = sss;
                    }
                }
            }
            if (!shjjbyyear)
            {
                creatsheetbydt(title, dt, viscol);
            }

            else
            {
                recreatsheetbydt(title, dt, viscol, 2);
            }
        }
示例#11
0
        //形成基础数据电力发展实绩历年地区生产
        private void build_dlhistoryGDP()
        {
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "电力发展实绩_历年地区生产总值";
            Ps_YearRange py = new Ps_YearRange();
            py.Col4 = "电力发展实绩";
            py.Col5 = Itop.Client.MIS.ProgUID;

            IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py);
            int firstyear, endyear;
            if (li.Count > 0)
            {
                firstyear = li[0].StartYear;
                endyear = li[0].FinishYear;
            }
            else
            {
                firstyear = 2000;
                endyear = 2008;
                py.BeginYear = 1990;
                py.FinishYear = endyear;
                py.StartYear = firstyear;
                py.EndYear = 2060;
                py.ID = Guid.NewGuid().ToString();
                Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py);
            }

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("Year");
            viscol["Year"] = new Columqk("年份", 3, 2);
            dt.Columns.Add("GDP", typeof(double));
            viscol["GDP"] = new Columqk("GDP(亿元)", 2, 2);
            dt.Columns.Add("A", typeof(double));
            viscol["A"] = new Columqk("增长指数", 2, 2);
            Ps_History psp_Type = new Ps_History();
            psp_Type.Forecast = 1;
            psp_Type.Col4 = Itop.Client.MIS.ProgUID;
            IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type);
            System.Data.DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History));

            DataRow[] rows1 = dataTable.Select("Title like '全地区GDP%'");
            DataRow[] rows2 = dataTable.Select("Title like '年末总人口%'");
            //找不到数据时给出提示
            if (rows1.Length == 0 || rows2.Length == 0)
            {
                MessageBox.Show("缺少‘全地区GDP’或‘年末总人口’ 数据,无法进行统计!");
                this.Close();
                return;
            }
            string pid = rows1[0]["ID"].ToString();
            DataRow[] rows3 = dataTable.Select("ParentID='" + pid + "'");

            int m = -1;
            for (int k = 0; k < rows3.Length; k++)
            {
                m++;
                dt.Columns.Add("m" + m, typeof(double));
                dt.Columns.Add("n" + m, typeof(double));

                viscol["m" + m] = new Columqk(rows3[k]["Title"].ToString(), 2, 2);

                viscol["n" + m] = new Columqk("比例(%)", 1, 2);
            }
            viscol["RK"] = new Columqk("人口(万人)", 2, 2);
            viscol["RJGDP"] = new Columqk("人均GDP(万元/人)", 1, 2);
            dt.Columns.Add("RK", typeof(double));
            dt.Columns.Add("RJGDP", typeof(double));
            double sum1 = 0;
            for (int i = firstyear; i <= endyear; i++)
            {
                //if (!ht.ContainsValue(i))
                //    continue;

                DataRow row = dt.NewRow();
                row["ID"] = Guid.NewGuid().ToString();
                row["Year"] = i;
                double sum = 0;
                try { sum = Convert.ToDouble(rows1[0]["y" + i]); }
                catch { }
                row["GDP"] = sum.ToString();

                if (i == firstyear)
                    sum1 = sum;

                if (sum1 != 0)
                    sum1 = sum * 100 / sum1;
                row["A"] = sum1.ToString("n2");
                sum1 = sum;
                for (int j = 0; j <= m; j++)
                {
                    double s = 0;
                    double y = 0;
                    try { s = Convert.ToDouble(rows3[j]["y" + i]); }
                    catch { }
                    row["m" + j] = s.ToString();
                    if (sum != 0)
                        y = s * 100 / sum;

                    row["n" + j] = detel_jd(y, 2);
                }
                double rk = 0;
                double rjgdp = 0;
                try { rk = Convert.ToDouble(rows2[0]["y" + i]); }
                catch { }
                row["RK"] = rk.ToString();

                if (rk != 0)
                    rjgdp = sum / rk;

                row["RJGDP"] = detel_jd(rjgdp, 4);
                dt.Rows.Add(row);

            }
            if (!shjjbyyear)
            {
                creatsheetbydt(title, dt, viscol);
            }

            else
            {
                recreatsheetbydt(title, dt, viscol, 0);
            }
        }
示例#12
0
        //电力发展实绩分行业统计
        private void build_dlhistoryfhy()
        {
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "电力发展实绩_分行业统计";
            Ps_YearRange py = new Ps_YearRange();
            py.Col4 = "电力发展实绩";
            py.Col5 = Itop.Client.MIS.ProgUID;
            int firstyear, endyear;
            IList<Ps_YearRange> li = Itop.Client.Common.Services.BaseService.GetList<Ps_YearRange>("SelectPs_YearRangeByCol5andCol4", py);
            if (li.Count > 0)
            {
                firstyear = li[0].StartYear;
                endyear = li[0].FinishYear;
            }
            else
            {
                firstyear = 2000;
                endyear = 2008;
                py.BeginYear = 1990;
                py.FinishYear = endyear;
                py.StartYear = firstyear;
                py.EndYear = 2060;
                py.ID = Guid.NewGuid().ToString();
                Itop.Client.Common.Services.BaseService.Create<Ps_YearRange>(py);
            }

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("Title");
            viscol["Title"] = new Columqk("标题", 3, 2);
            Ps_History psp_Type = new Ps_History();
            psp_Type.Forecast = 1;
            psp_Type.Col4 = Itop.Client.MIS.ProgUID;
            IList<Ps_History> listTypes = Common.Services.BaseService.GetList<Ps_History>("SelectPs_HistoryByForecast", psp_Type);
            System.Data.DataTable dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_History));

            DataRow[] rows1 = dataTable.Select("Title like '全社会用电量%'");
            if (rows1.Length == 0)
            {
                MessageBox.Show("缺少‘全社会用电量’ 数据,无法进行统计!");
                this.Close();
                return;
            }
            string pid = rows1[0]["ID"].ToString();
            string tempTite = rows1[0]["Title"].ToString();
            //取出标题中的单位
               string Untis = fpcommon.FindUnits(tempTite);
            DataRow[] rows3 = dataTable.Select("ParentID='" + pid + "'");
            if (rows3.Length == 0)
            {
                MessageBox.Show("缺少‘全社会用电量’下的分行业用电数据,无法进行统计!");
                this.Close();
                return;
            }

            int m = -1;
            for (int i = firstyear; i <= endyear; i++)
            {
                //if (!ht.ContainsValue(i))
                //    continue;

                m++;
                dt.Columns.Add("y" + i, typeof(double));
                dt.Columns.Add("n" + i, typeof(double));

                viscol["n" + i] = new Columqk(i + "年百分比", 1, 2);

                if (Untis.Length > 0)
                {
                    viscol["y" + i] = new Columqk(i + "年" + "用电量(" + Untis + ")", 2, 2);
                }
                else
                {
                    viscol["y" + i] = new Columqk(i + "年" + "用电量", 2, 2);
                }

            }

            double sum = 0;
            try { sum = Convert.ToDouble(rows1[0]["y" + firstyear]); }
            catch { }

            DataRow row1 = dt.NewRow();
            row1["ID"] = Guid.NewGuid().ToString();
            row1["Title"] = "用电量总计";//rows1[0]["Title"].ToString();
            for (int k = 0; k < rows3.Length; k++)
            {

                DataRow row = dt.NewRow();
                row["ID"] = Guid.NewGuid().ToString();
                row["Title"] = rows3[k]["Title"].ToString();

                for (int j = firstyear; j <= endyear; j++)
                {
                    //if (!ht.ContainsValue(j))
                    //    continue;
                    sum = 0;
                    try
                    {
                        sum = Convert.ToDouble(rows1[0]["y" + j]);
                    }
                    catch { }

                    row1["y" + j] = sum;
                    row1["n" + j] = 1;
                    double sum1 = 0;
                    double sum2 = 0;
                    try { sum1 = Convert.ToDouble(rows3[k]["y" + j]); }
                    catch { }
                    row["y" + j] = sum1;
                    if (sum != 0)
                        sum2 = sum1 / sum;
                    row["n" + j] = sum2;
                }

                dt.Rows.Add(row);
            }
            dt.Rows.Add(row1);

            if (!shjjbyyear)
            {
                creatsheetbydt(title, dt, viscol);
            }

            else
            {
                recreatsheetbydt(title, dt, viscol, 1);
            }
        }
示例#13
0
        //变电站情况表
        private void build_bdzqk()
        {
            Dictionary<string, Columqk> viscol = new Dictionary<string, Columqk>();
            string title = "变电站情况表";
            System.Data.DataTable dt = Calc("");
            viscol["S3"] = new Columqk("序号", 3, 2);
            viscol["AreaName"] = new Columqk("区域", 3, 2);
            viscol["L1"] = new Columqk("电压等级", 2, 2);
            viscol["L2"] = new Columqk("容量(MVA)", 3, 2);
            viscol["L3"] = new Columqk("变电台数(台)", 3, 2);
            viscol["L4"] = new Columqk("容量构成", 3, 2);
            viscol["L5"] = new Columqk("无功总容量(Mvar)", 2, 2);
            viscol["L6"] = new Columqk("无功补偿容量构成(Mvar)", 3, 2);
            viscol["L9"] = new Columqk("最大负荷(MW)", 2, 2);
            viscol["L10"] = new Columqk("负载率(%)", 1, 2);
            viscol["S2"] = new Columqk("投产时间及备注", 3, 2);
            viscol["DQ"] = new Columqk("电网类型", 3, 2);
            if (!shjjbyyear)
            {
                creatsheetbydt(title, dt, viscol);
            }

            else
            {
                recreatsheetbydt(title, dt, viscol, 9);
            }
        }
示例#14
0
        //形成输出的datatable
        private System.Data.DataTable OutTable( System.Data.DataTable datatable,ref Dictionary<string, Columqk> viscol)
        {
            System.Data.DataTable dt = new  System.Data.DataTable();
            List<string> listColID = new List<string>();

            listColID.Add("Title");
            dt.Columns.Add("Title", typeof(string));
            dt.Columns["Title"].Caption = "项目";
            viscol["Title"] = new Columqk("项目", 3, 2);
            dt.Columns.Add("ParentID", typeof(string));

            foreach (DataColumn column in datatable.Columns)
            {
                if (column.ColumnName.IndexOf("y") >= 0)
                {
                    int year=Convert.ToInt32(column.ColumnName.Substring(1));

                     if (year >= forecastReport.StartYear && year <= forecastReport.EndYear)
                    {
                        listColID.Add(column.ColumnName);
                        viscol[column.ColumnName] = new Columqk(year + "年", 2, 2);
                        dt.Columns.Add(column.ColumnName, typeof(double));
                    }

                }
                //else
                //    if (column.FieldName == "ParentID")
                //    {
                //        dt.Columns.Add("ParentID", typeof(string));
                //        listColID.Add("ParentID");
                //        dt.Columns["ParentID"].Caption = "父ID";
                //    }
            }
            listColID.Add("ParentID");
            dt.Columns["ParentID"].Caption = "父ID";

            int itemp = -4;
            int jtemp = -4;
            foreach (DataRow node in datatable.Rows)
            {
                jtemp = itemp;
                AddNodeDataToDataTable(dt,datatable, node, listColID, ref itemp, jtemp);
                // itemp++;
            }
            return dt;
        }