Пример #1
0
        private void GetList(string idbg, string idpt, string namebg, string namept, string type, string sTime, string eTime, string gq)
        {
            IList <Hashtable> listTitle = new List <Hashtable>(); //Table表格存放列名
            IList <Hashtable> listData  = new List <Hashtable>(); //Table 表格具体数据
            IList <Hashtable> listZXT   = new List <Hashtable>();
            IList <Hashtable> list      = new List <Hashtable>();


            if (idbg.Length > 0 && idpt.Length > 0)
            {
                idbg   += idpt.Substring(0, idpt.Length - 1);
                namebg += namept.Substring(0, namept.Length - 1);
            }
            else if (idbg.Length > 0)
            {
                idbg   = idbg.Substring(0, idbg.Length - 1);
                namebg = namebg.Substring(0, namebg.Length - 1);
            }
            else if (idpt.Length > 0)
            {
                idbg   = idpt.Substring(0, idpt.Length - 1);
                namebg = namept.Substring(0, namept.Length - 1);
            }

            Hashtable timeht = new Hashtable();

            timeht.Add("时间", "时间");
            listTitle.Add(timeht);

            for (int i = 0; i < namebg.Split(',').Length; i++)
            {
                Hashtable ht = new Hashtable();
                ht.Add(namebg.Split(',')[i], namebg.Split(',')[i]);
                listTitle.Add(ht);
            }

            DataTable _dtPoint = _pd.GetPoints(gq, type, idbg);

            if (_dtPoint != null)
            {
                string[] _points = new string[_dtPoint.Rows.Count];

                for (int i = 0; i < _dtPoint.Rows.Count; i++)
                {
                    _points[i] = _dtPoint.Rows[i][0].ToString();
                }

                if (type == "1" || type == "2")
                {
                    list = _pb.GetVal(_points, namebg.Split(','), sTime, eTime, 15 * 60);

                    if (list == null)
                    {
                    }
                    else
                    {
                        //listData = _pb.GetValToTable(_points, namebg.Split(','), sTime, eTime, 15 * 60);

                        int day    = Convert.ToDateTime(eTime).Day - Convert.ToDateTime(sTime).Day;
                        int hour   = Convert.ToDateTime(eTime).Hour - Convert.ToDateTime(sTime).Hour;
                        int minute = Convert.ToDateTime(eTime).Minute - Convert.ToDateTime(sTime).Minute;
                        int second = Convert.ToDateTime(eTime).Second - Convert.ToDateTime(sTime).Second;

                        second = day * 24 * 3600 + hour * 3600 + minute * 60 * second;

                        int num = Convert.ToDateTime(eTime).Second - Convert.ToDateTime(sTime).Second;
                        num = second / 15 / 60;
                        if (second % 15 / 60 != 0)
                        {
                            num += 1;
                        }


                        for (int i = 0; i < num; i++)
                        {
                            sTime = Convert.ToDateTime(sTime).AddSeconds(15 * 60).ToString();
                            eTime = sTime;
                            Hashtable ht = new Hashtable();
                            ht.Add("时间", eTime);
                            //listData.Add(ht);

                            foreach (Hashtable htv in list)
                            {
                                ArrayList listD = (ArrayList)htv["data"];
                                ArrayList listV = (ArrayList)listD[i];
                                string    tname = htv["name"].ToString();
                                string    vname = "";
                                if (listV.Count > 1)
                                {
                                    vname = listV[1].ToString();
                                }
                                else
                                {
                                    vname = "0";
                                }
                                ht.Add(tname, vname);//vname is value ? wo  d  jiu shi  zheme shezhi d
                            }

                            listData.Add(ht);
                        }
                    }
                }
                else if (type == "3" || type == "4")
                {
                    //表格数据
                    DataTable     dtGrid  = _sta.GetDlByTimeAndUnits(sTime, eTime, idbg);
                    List <string> liststr = new List <string>();
                    var           q       =
                        from t in dtGrid.AsEnumerable()
                        group t by new { t1 = t.Field <DateTime>("T_TIME") } into m
                                  select new
                    {
                        T_TIME = m.Key.t1
                    };
                    q.ToList().ForEach(a => liststr.Add(a.T_TIME.ToString()));
                    for (int m = 0; m < liststr.Count; m++)
                    {
                        Hashtable ht = new Hashtable();
                        ht.Add("时间", liststr[m]);
                        for (int o = 0; o < namebg.Split(',').Length; o++)
                        {
                            DataRow[] dr = dtGrid.Select("T_TIME='" + liststr[m] + "' and T_UNITDESC='" + namebg.Split(',')[o] + "'");
                            ht.Add(namebg.Split(',')[o], dr[0]["D_VALUE"].ToString());
                        }

                        listData.Add(ht);
                    }

                    //柱形图数据
                    DataTable dt = _sta.GetDL(sTime, eTime, idbg);
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Hashtable ht = new Hashtable();
                        ht.Add("name", dt.Rows[i]["T_UNITDESC"]);
                        ht.Add("data", new double[1] {
                            Convert.ToDouble(dt.Rows[i]["RESULT"])
                        });
                        listZXT.Add(ht);
                    }
                }
            }

            object obj = new
            {
                columns = ListToString(listTitle),
                rows    = listData,
                list    = list,
                listZXT = listZXT,          //柱形图
            };

            string result = Newtonsoft.Json.JsonConvert.SerializeObject(obj);

            Response.Write(result);
            Response.End();
        }
Пример #2
0
        private void ShowLineYear(string id, string zType, string tType, string time, string gq)
        {
            IList <Hashtable> list      = new List <Hashtable>();
            IList <Hashtable> listTitle = new List <Hashtable>();
            IList <Hashtable> listDl    = new List <Hashtable>();
            IList <Hashtable> listData  = new List <Hashtable>();
            Hashtable         hTitle    = new Hashtable();


            Hashtable ht    = new Hashtable();
            string    _news = "";
            string    _old  = "";

            if (zType == "1" || zType == "2")
            {
                //功率  风速
                DataTable _dtPoint = _pd.GetPoints(gq, zType, "'" + id + "'");
                if (_dtPoint != null && _dtPoint.Rows.Count > 0)
                {
                    string[] ti = time.Split('-');
                    if (ti.Length == 1)
                    {
                        time = time + "-1-1 0:00:00";
                        //_news = "4.42,3.85,4.82,3.8,8.89,5.46,4.86,4.85,6.36,8.01,9.34,8.89,6.63,10.22,8.27,9.66,12.37,6.69,14.8,13.35,12.27,14.53,11.12,10.94,8.16,8.13,5.02,7.29,7.09,8.08,7.3,8.03,7.58,11.38,10.6,10.62,7.9,5.82,8.55,5.71,10.52,13.71,17.23,15.1,14.47,11.12,13.02,10.39,14.6,12.21,6.08,8.69,10.81,12.67,9.1,10.05,12.34,13.55,10.13,13.58,14.74,9.73,6.69,12.48,14.73,15.24,9.44,10.29,7.41,5.63,8.28,9.71,8.19,6.87,7.28,7.12,4.07,7.57,7.28,6.79,9.22,15.52,10.34,13.59,11.75,13.44,8.08,9.17,13.59,11.35,17.55,13.65,7.39,5.13,4.49,3.14,5.35,6.97,6.98,9.36,9.12,10.01,6.8,12.23,9.49,6.01,5.86,4.46,3.93,5.96,9.44,9.97,13,17.59,17.59,15.93,15.23,6.96,6.72,12.7,10.27,7.03,8.52,10.89,10.87,9.77,7.66,5.7,8.06,6.42,5.22,10.48,5.86,7.18,8.06,11.66,10.76,4.27,6.37,5.62,7.12,6.42,6.96,8.95,7.23,6.69,8.44,6.35,8.63,8.24,6.75,9.87,8.52,6.01,6.9,3.81,2.38,2.38,2.38,2.38,5.15,5.4,5.4,5.4,5.4,17.67,16.5,14.87,11.5,23.78,18.14,7.23,6.25,5.96,8.8,12.18,13.88,10.87,13.83,10.08,12.85,0,8.94,9.5,7.51,9.89,10.16,8.4,6.12,12.17,12.34,6.43,8.06,7.06,4.66,6.57,6.3,3.85,4.28,11.84,6.54,8.55,6.9,4.85,4.04,10.84,9.95,10.89,20.53,8.93,8.86,7.42,3.67,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,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,9.06";
                        //_old = "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,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,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,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,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,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,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,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,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,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,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,0,0,0,0,0,0,0,0,0,0,0,0,0";
                    }
                    else if (ti.Length == 2)
                    {
                        time = time + "-1 0:00:00";
                        //_news = "119.3,121.5,114.9,90,152.7,68.4,38,29.2,32.9,9.1,20.1,7.3,-0.300000011920929,63.3,76.1,57.4,89.3,79.4,115.3,294.4,626.2,317.8,436.5,338.7,247.1,163.3,163.6,91.5,209.1,217.5,78.3,110.5,82.7,110.2,288.9,677.4,646.3,869,704.5,669,713,728,760.6,1503.2,1486.4,1502.9,1158.3,1270,1300.7,1106.6,554.8,645.2,284.1,156.3,480.1,115.3,9.8,0,121.9,127.4,220,238.4";
                        //_old = "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,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";
                    }
                    _news    = _pointbll.GetVal(_dtPoint.Rows[0][0].ToString(), time, tType);
                    _old     = _pointbll.GetVal(_dtPoint.Rows[0][0].ToString(), Convert.ToDateTime(time).AddYears(-1).ToString(), tType);
                    listData = _pointbll.GetValList(_dtPoint.Rows[0][0].ToString(), time, tType);
                }

                //grid columns
                hTitle.Add("时间", "去年");
                hTitle.Add("去年", "去年");
                hTitle.Add("今年", "今年");
                listTitle.Add(hTitle);
            }
            else
            {
                //电量  停机时间
                if (tType == "1")
                {
                    //柱形图
                    DataTable newdt = _sta.GetDL(time.ToString() + "-1-1 0:00:00", time.ToString() + "-12-31 23:59:59", "'" + id + "'");
                    DataTable olddt = _sta.GetDL((int.Parse(time) - 1).ToString() + "-1-1 0:00:00", (int.Parse(time) - 1).ToString() + "-12-31 23:59:59", "'" + id + "'");

                    Hashtable h   = new Hashtable();
                    Hashtable hta = new Hashtable();



                    if (newdt.Rows.Count < 1)
                    {
                        h.Add("name", "今年");
                        h.Add("data", new double[1] {
                            0
                        });

                        //rows
                        hta.Add("今年", "0");
                    }
                    else
                    {
                        h.Add("name", "今年");
                        h.Add("data", new double[1] {
                            Convert.ToDouble(newdt.Rows[0]["RESULT"])
                        });

                        //rows
                        hta.Add("今年", newdt.Rows[0]["RESULT"].ToString());
                    }
                    listDl.Add(h);

                    h = new Hashtable();
                    if (olddt.Rows.Count < 1)
                    {
                        h.Add("name", "去年");
                        h.Add("data", new double[1] {
                            0
                        });
                        //rows
                        hta.Add("去年", "0");
                    }
                    else
                    {
                        h.Add("name", "去年");
                        h.Add("data", new double[1] {
                            Convert.ToDouble(olddt.Rows[0]["RESULT"])
                        });
                        //rows
                        hta.Add("去年", olddt.Rows[0]["RESULT"].ToString());
                    }
                    listDl.Add(h);
                    listData.Add(hta);
                    //grid columns
                    hTitle.Add("去年", "去年");
                    hTitle.Add("今年", "今年");
                    listTitle.Add(hTitle);
                }
                else if (tType == "2")
                {
                    //曲线
                    DataTable newdt = _sta.GetDlByTimeAndUnits(time + "-1 0:00:00", time + "-" + getDayCountByDate(time) + " 23:59:59", "'" + id + "'");
                    DataTable olddt = _sta.GetDlByTimeAndUnits((int.Parse(time.Split('-')[0]) - 1).ToString() + "-" + time.Split('-')[1] + "-1 0:00:00", (int.Parse(time.Split('-')[0]) - 1).ToString() + "-" + time.Split('-')[1] + "-" + getDayCountByDate(time) + " 23:59:59", "'" + id + "'");
                    Hashtable hta   = new Hashtable();//存储GRID数据

                    if (newdt.Rows.Count > 0)
                    {
                        for (int i = 0; i < newdt.Rows.Count; i++)
                        {
                            _news += newdt.Rows[i][0].ToString() + ",";
                            hta.Add("时间", newdt.Rows[i]["T_TIME"].ToString());
                            hta.Add("今年", newdt.Rows[i]["D_VALUE"].ToString());
                            if (olddt.Rows.Count > 0)
                            {
                                DataRow[] ddr = olddt.Select("T_TIME='" + newdt.Rows[i]["T_TIME"].ToString() + "'");
                                if (ddr.Length > 0)
                                {
                                    hta.Add("去年", ddr[0]["D_VALUE"].ToString());
                                }
                                else
                                {
                                    hta.Add("去年", "0");
                                }
                            }
                            else
                            {
                                hta.Add("去年", "0");
                            }
                            listData.Add(hta);
                            hta = new Hashtable();
                        }
                        _news = _news.Substring(0, _news.Length - 1);
                    }
                    else
                    {
                        _news = "";

                        if (olddt.Rows.Count > 0)
                        {
                            for (int m = 0; m < olddt.Rows.Count; m++)
                            {
                                hta.Add("时间", olddt.Rows[m]["T_TIME"].ToString());
                                hta.Add("今年", "0");
                                hta.Add("时间", olddt.Rows[m]["D_VALUE"].ToString());
                                listData.Add(hta);
                                hta = new Hashtable();
                            }
                        }
                    }


                    if (olddt.Rows.Count > 0)
                    {
                        for (int j = 0; j < olddt.Rows.Count; j++)
                        {
                            _old += olddt.Rows[j][0].ToString() + ",";
                        }
                        _old = _old.Substring(0, _old.Length - 1);
                    }
                    else
                    {
                        _old = "";
                    }

                    //grid columns
                    hTitle.Add("时间", "时间");
                    hTitle.Add("去年", "去年");
                    hTitle.Add("今年", "今年");
                    listTitle.Add(hTitle);
                }
            }

            _news = "[" + _news + "]";
            _old  = "[" + _old + "]";

            ht.Add("name", "今年");
            ht.Add("data", _news);
            list.Add(ht);

            ht = new Hashtable();
            ht.Add("name", "去年");
            ht.Add("data", _old);
            list.Add(ht);



            object obj = new
            {
                columns = ListToString(listTitle),
                rows    = listData,
                list    = list,
                listDl  = listDl
            };

            string result = Newtonsoft.Json.JsonConvert.SerializeObject(obj);

            Response.Write(result);
            Response.End();
        }