Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            string beginTime   = context.Request["beginTime"] == null ? string.Empty : context.Request["beginTime"].ToString();
            string endTime     = string.Empty;
            string timeType    = context.Request["timeType"] == null ? string.Empty : context.Request["timeType"].ToString();
            string quarterType = context.Request["quarterType"] == null ? string.Empty : context.Request["quarterType"].ToString();

            //根据选择的时间段,设置开始时间和结束时间
            switch (timeType)
            {
            case "1":    //月度平均值
                DateTime dt1 = new DateTime();
                dt1       = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01");
                beginTime = dh.GetFirstDayOfMonth(dt1).ToString().Replace("/", "-");
                endTime   = dh.GetLastDayOfMonth(dt1).ToString().Replace("/", "-");
                break;

            case "2":    //季度平均值
                switch (quarterType)
                {
                case "0":        //一季度
                    string ti = beginTime.Substring(0, 4) + "-01-01 00:00:00";
                    beginTime = ti;
                    endTime   = beginTime.Substring(0, 4) + "-03-31 23:59:59";
                    break;

                case "1":        //二季度
                    string ti1 = beginTime.Substring(0, 4) + "-04-01 00:00:00";
                    beginTime = ti1;
                    endTime   = beginTime.Substring(0, 4) + "-06-30 23:59:59";
                    break;

                case "2":        //三季度
                    string ti2 = beginTime.Substring(0, 4) + "-07-01 00:00:00";
                    beginTime = ti2;
                    endTime   = beginTime.Substring(0, 4) + "-09-30 23:59:59";
                    break;

                case "3":        //四季度
                    string ti3 = beginTime.Substring(0, 4) + "-10-01 00:00:00";
                    beginTime = ti3;
                    endTime   = beginTime.Substring(0, 4) + "-12-31 23:59:59";
                    break;
                }
                break;

            case "3":    //年度平均值
                string tim = beginTime.Substring(0, 4);
                beginTime = tim + "-01-01 00:00:00";
                endTime   = tim + "-12-31 23:59:59";
                break;
            }

            AllInfo allinfo = new AllInfo();

            List <ConsumeInfo> infoList;

            infoList = bl.get(beginTime, endTime, out errMsg);

            //平均值柱状图
            infos tmp = new infos();

            tmp.name  = new ArrayList();
            tmp.value = new ArrayList();
            foreach (ConsumeInfo tmps in infoList)
            {
                tmp.name.Add(tmps.Name);
                tmp.value.Add(Math.Round(tmps.Count, 2));
            }
            allinfo.ZhuTu = tmp;


            //饼状图
            ArrayList ConsumeList = new ArrayList();

            ArrayList tmsp;

            foreach (ConsumeInfo tmps in infoList)
            {
                tmsp = new ArrayList();
                tmsp.Add(tmps.Name);
                tmsp.Add(Math.Round(tmps.Count, 2));
                ConsumeList.Add(tmsp);
            }
            allinfo.ConsumeList = ConsumeList;


            //环比柱状图
            List <infos> info = new List <infos>();
            //七月份
            infos ht = new infos();

            ht.time  = DateTime.Parse(beginTime).Month + "月份";
            ht.name  = new ArrayList();
            ht.value = new ArrayList();

            foreach (ConsumeInfo tmps in infoList)
            {
                ht.name.Add(tmps.Name);
                ht.value.Add(Math.Round(tmps.Count, 2));
            }
            info.Add(ht);


            //六月份
            infos sixMonth = new infos();

            sixMonth.name  = new ArrayList();
            sixMonth.value = new ArrayList();
            string beforBeginTime = DateTime.Parse(beginTime).AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss");
            string beforEndTime   = DateTime.Parse(beforBeginTime).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");

            sixMonth.time = DateTime.Parse(beforBeginTime).Month + "月份";
            List <ConsumeInfo> beforInfoList = bl.get(beforBeginTime, beforEndTime, out errMsg);

            foreach (ConsumeInfo tmps in beforInfoList)
            {
                sixMonth.name.Add(tmps.Name);
                sixMonth.value.Add(Math.Round(tmps.Count, 2));
            }
            info.Add(sixMonth);

            //环比
            infos SsHb = new infos();

            SsHb.time  = "环比增长";
            SsHb.name  = new ArrayList();
            SsHb.value = new ArrayList();

            foreach (ConsumeInfo infos in infoList)
            {
                ConsumeInfo c = beforInfoList.Where(t => t.Name == infos.Name).FirstOrDefault();
                SsHb.name.Add(c.Name);
                if (infos.Count > 0)
                {
                    SsHb.value.Add(Math.Round(((infos.Count - c.Count) / infos.Count) * 100, 2));
                }
                else
                {
                    SsHb.value.Add(0);
                }
            }
            info.Add(SsHb);

            allinfo.Hb = info;


            string content = allinfo.ToJsonItem();

            context.Response.ContentType = "text/json;charset=gb2312;";
            context.Response.Write(content);
            context.Response.End();
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            string unit = context.Request["unit"] == null ? string.Empty : context.Request["unit"].ToString();

            //string unit = String.IsNullOrEmpty(context.Request["unit"].ToString()) ? string.Empty : context.Request["unit"].ToString();
            //string time = String.IsNullOrEmpty(context.Request["time"].ToString())?  string.Empty:context.Request["time"].ToString() ;
            string beginTime   = context.Request["beginTime"] == null ? string.Empty : context.Request["beginTime"].ToString();
            string endTime     = context.Request["endTime"] == null ? string.Empty : context.Request["endTime"].ToString();
            string timeType    = context.Request["timeType"] == null ? string.Empty : context.Request["timeType"].ToString();
            string quarterType = context.Request["quarterType"] == null ? string.Empty : context.Request["quarterType"].ToString();

            //根据选择的时间段,设置开始时间和结束时间
            switch (timeType)
            {
            case "0":     //指定时间段

                break;

            case "1":    //月度平均值
                DateTime dt1 = new DateTime();
                dt1       = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01");
                beginTime = dh.GetFirstDayOfMonth(dt1).ToString().Replace("/", "-");
                endTime   = dh.GetLastDayOfMonth(dt1).ToString().Replace("/", "-");
                break;

            case "2":    //季度平均值
                switch (quarterType)
                {
                case "0":        //一季度
                    string ti = beginTime.Substring(0, 4) + "-01-01 00:00:00";
                    beginTime = ti;
                    endTime   = beginTime.Substring(0, 4) + "-03-31 23:59:59";
                    break;

                case "1":        //二季度
                    string ti1 = beginTime.Substring(0, 4) + "-04-01 00:00:00";
                    beginTime = ti1;
                    endTime   = beginTime.Substring(0, 4) + "-06-30 23:59:59";
                    break;

                case "2":        //三季度
                    string ti2 = beginTime.Substring(0, 4) + "-07-01 00:00:00";
                    beginTime = ti2;
                    endTime   = beginTime.Substring(0, 4) + "-09-30 23:59:59";
                    break;

                case "3":        //四季度
                    string ti3 = beginTime.Substring(0, 4) + "-10-01 00:00:00";
                    beginTime = ti3;
                    endTime   = beginTime.Substring(0, 4) + "-12-31 23:59:59";
                    break;
                }
                break;

            case "3":    //年度平均值
                string tim = beginTime.Substring(0, 4);
                beginTime = tim + "-01-01 00:00:00";
                endTime   = tim + "-12-31 23:59:59";
                break;
            }

            List <IndicatorInfo> infoList = new List <IndicatorInfo>();

            //获取锅炉和汽机的所有耗差类型。
            infoList = bl.GetInfo(beginTime, endTime, unit, -1, -1, out errMsg);
            infoList = infoList.Where(info => !String.IsNullOrEmpty(info.Name)).ToList();
            ArrayList reason = new ArrayList();
            //锅炉可控
            List <IndicatorInfo> tmpList = infoList.Where(info => info.ConsumeType == "0" && info.TargetType == "0").ToList();
            ArrayList            tmpArr  = new ArrayList();
            double value = 0;

            tmpArr.Add("锅炉可控");
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            //value = 32.23;
            tmpArr.Add(Math.Round(value, 2));
            reason.Add(tmpArr);


            //锅炉不可控
            tmpList = infoList.Where(info => info.ConsumeType == "1" && info.TargetType == "0").ToList();
            tmpArr  = new ArrayList();
            value   = 0;
            tmpArr.Add("锅炉不可控");
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            //value = 32.23;

            tmpArr.Add(Math.Round(value, 2));
            reason.Add(tmpArr);

            //汽机可控
            tmpList = infoList.Where(info => info.ConsumeType == "0" && info.TargetType == "1").ToList();
            tmpArr  = new ArrayList();
            value   = 0;
            tmpArr.Add("汽机可控");
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            //value = 32.23;

            tmpArr.Add(Math.Round(value, 2));
            reason.Add(tmpArr);

            //汽机不可控
            tmpList = infoList.Where(info => info.ConsumeType == "1" && info.TargetType == "1").ToList();
            tmpArr  = new ArrayList();
            value   = 0;
            tmpArr.Add("汽机不可控");
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            //value = 32.23;

            tmpArr.Add(Math.Round(value, 2));
            reason.Add(tmpArr);

            tmpList = infoList.Where(info => info.ConsumeType != "1" && info.TargetType != "1" && info.ConsumeType != "0" && info.TargetType != "0").ToList();
            tmpArr  = new ArrayList();
            value   = 0;
            tmpArr.Add("不可知因素能耗");
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            //value = 32.23;

            tmpArr.Add(Math.Round(value, 2));
            reason.Add(tmpArr);


            //柱状图
            ArrayList name   = new ArrayList();
            ArrayList values = new ArrayList();

            foreach (var i in infoList)
            {
                name.Add(i.Name);
                values.Add(Math.Round(i.ConsumeValue, 2));
            }

            AllInfo allInfo = new AllInfo();

            allInfo.ConsumeList = reason;
            allInfo.name        = name;
            allInfo.value       = values;
            string content = allInfo.ToJsonItem();

            context.Response.ContentType = "text/json;charset=gb2312;";
            context.Response.Write(content);
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            //string unit = String.IsNullOrEmpty(context.Request["unit"].ToString()) ? string.Empty : context.Request["unit"].ToString();
            //传过来的文本框内容
            string time = String.IsNullOrEmpty(context.Request["beginTime"].ToString()) ? string.Empty : context.Request["beginTime"].ToString();
            //月,季,年
            string timeType = String.IsNullOrEmpty(context.Request["timeType"].ToString()) ? string.Empty : context.Request["timeType"].ToString();
            //传过来的季度
            string quarterType = String.IsNullOrEmpty(context.Request["quarterType"].ToString()) ? "-1" : context.Request["quarterType"].ToString();

            AllInfo allinfo = new AllInfo();

            //获取耗差平均值。(柱状图)
            infos tmp = new infos();
            tmp.name = new ArrayList();
            tmp.value = new ArrayList();

            for (int i = 0; i < 10; i++)
            {
                tmp.name.Add("主汽温度(°C)");

                tmp.value.Add(3.22);

            }
            allinfo.ZhuTu = tmp;

            //饼状图
            ArrayList ConsumeList = new ArrayList();

            ArrayList tmsp = new ArrayList();
            tmsp.Add("主汽温度(°C)");
            tmsp.Add(333.22);
            ConsumeList.Add(tmsp);

            tmsp = new ArrayList();
            tmsp.Add("主汽压力(Mpa)");
            tmsp.Add(16.70);
            ConsumeList.Add(tmsp);
            allinfo.ConsumeList = ConsumeList;

            //环比柱状图
            List<infos> info = new List<infos>();
            //七月份
            infos tmps = new infos();
            tmps.time = "七月份";
            tmps.name = new ArrayList();
            tmps.value = new ArrayList();

            for (int i = 0; i < 10; i++)
            {
                tmps.name.Add("主汽温度(°C)");

                tmps.value.Add(3.22);

            }

            info.Add(tmps);

            //六月份
            tmps = new infos();
            tmps.time = "六月份";
            tmps.name = new ArrayList();
            tmps.value = new ArrayList();

            for (int i = 0; i < 10; i++)
            {
                tmps.name.Add("主汽压力(Mpa)");

                tmps.value.Add(1.22);

            }
            info.Add(tmps);

            //环比
            tmps = new infos();
            tmps.time = "环比增长";
            tmps.name = new ArrayList();
            tmps.value = new ArrayList();

            for (int i = 0; i < 10; i++)
            {
                tmps.name.Add("环比(%)");

                tmps.value.Add(3);

            }
            info.Add(tmps);

            allinfo.Hb = info;

            string content = allinfo.ToJsonItem();
            context.Response.ContentType = "text/json;charset=gb2312;";
            context.Response.Write(content);
        }
Ejemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            string unit = String.IsNullOrEmpty(context.Request["unit"].ToString()) ? string.Empty : context.Request["unit"].ToString();
            //string time = String.IsNullOrEmpty(context.Request["time"].ToString())?  string.Empty:context.Request["time"].ToString() ;
            string beginTime = String.IsNullOrEmpty(context.Request["beginTime"].ToString()) ? string.Empty : context.Request["beginTime"].ToString();
            string endTime = String.IsNullOrEmpty(context.Request["endTime"].ToString()) ? string.Empty : context.Request["endTime"].ToString();
            string timeType = String.IsNullOrEmpty(context.Request["timeType"].ToString()) ? string.Empty : context.Request["timeType"].ToString();
            string quarterType = String.IsNullOrEmpty(context.Request["quarterType"].ToString()) ? string.Empty : context.Request["quarterType"].ToString();

            //根据选择的时间段,设置开始时间和结束时间
            switch (quarterType)
            {
                case "0": //指定时间段

                    break;
                case "1"://月度平均值
                    DateTime dt1 = new DateTime();
                    dt1 = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01");
                    beginTime = dh.GetFirstDayOfMonth(dt1).ToString();
                    endTime = dh.GetLastDayOfMonth(dt1).ToString();
                    break;
                case "2"://季度平均值
                    switch (quarterType)
                    {
                        case "0"://一季度
                            string ti = beginTime.Substring(0, 4) + "-01-01";
                            beginTime = ti;
                            endTime = beginTime.Substring(0, 4) + "-03-31";
                            break;
                        case "1"://二季度
                            string ti1 = beginTime.Substring(0, 4) + "-04-01";
                            beginTime = ti1;
                            endTime = beginTime.Substring(0, 4) + "-06-30";
                            break;
                        case "2"://三季度
                            string ti2 = beginTime.Substring(0, 4) + "-07-01";
                            beginTime = ti2;
                            endTime = beginTime.Substring(0, 4) + "-09-30";
                            break;
                        case "3"://四季度
                            string ti3 = beginTime.Substring(0, 4) + "-10-01";
                            beginTime = ti3;
                            endTime = beginTime.Substring(0, 4) + "-12-31";
                            break;
                    }
                    break;
                case "3"://年度平均值
                    string tim = beginTime.Substring(0, 4);
                    beginTime = tim + "01-01";
                    endTime = tim + "-12-31";
                    break;
            }

            List<IndicatorInfo> infoList = new List<IndicatorInfo>();

            //获取锅炉和汽机的所有耗差类型。
            infoList = bl.GetInfo(beginTime, endTime, unit, -1, -1, out errMsg);

            ArrayList reason = new ArrayList();
            //锅炉可控
            List<IndicatorInfo> tmpList = infoList.Where(info => info.ConsumeType == "0" && info.TargetType == "0").ToList();
            ArrayList tmpArr = new ArrayList();
            double value = 0;
            tmpArr.Add("锅炉可控");
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            //value = 32.23;
            tmpArr.Add(value);
            reason.Add(tmpArr);

            //锅炉不可控
            tmpList = infoList.Where(info => info.ConsumeType == "0" && info.TargetType == "1").ToList();
            tmpArr = new ArrayList();
            value = 0;
            tmpArr.Add("锅炉不可控");
            //foreach (var info in tmpList)
            //{
            //    value += info.ConsumeValue;
            //}
            value = 32.23;

            tmpArr.Add(value);
            reason.Add(tmpArr);

            //汽机可控
            tmpList = infoList.Where(info => info.ConsumeType == "1" && info.TargetType == "0").ToList();
            tmpArr = new ArrayList();
            value = 0;
            tmpArr.Add("汽机可控");
            //foreach (var info in tmpList)
            //{
            //    value += info.ConsumeValue;
            //}
            value = 32.23;

            tmpArr.Add(value);
            reason.Add(tmpArr);

            //汽机不可控
            tmpList = infoList.Where(info => info.ConsumeType == "1" && info.TargetType == "1").ToList();
            tmpArr = new ArrayList();
            value = 0;
            tmpArr.Add("汽机不可控");
            //foreach (var info in tmpList)
            //{
            //    value += info.ConsumeValue;
            //}
            value = 32.23;

            tmpArr.Add(value);
            reason.Add(tmpArr);

            tmpList = infoList.Where(info => info.ConsumeType != "1" && info.TargetType != "1" && info.ConsumeType != "0" && info.TargetType != "0").ToList();
            tmpArr = new ArrayList();
            value = 0;
            tmpArr.Add("不可知因素能耗");
            //foreach (var info in tmpList)
            //{
            //    value += info.ConsumeValue;
            //}
            value = 32.23;

            tmpArr.Add(value);
            reason.Add(tmpArr);

            //柱状图
             ArrayList name = new ArrayList();
             ArrayList values = new ArrayList();
             foreach (var i in infoList)
             {
                 name.Add(i.Name);
                 values.Add(i.ConsumeValue);
             }

            AllInfo allInfo = new AllInfo();
            allInfo.ConsumeList = reason;
            allInfo.name = name;
            allInfo.value = values;
            string content = allInfo.ToJsonItem();
            context.Response.ContentType = "text/json;charset=gb2312;";
            context.Response.Write(content);
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            string beginTime = context.Request["beginTime"] == null ? string.Empty : context.Request["beginTime"].ToString();
            string endTime = string.Empty;
            string timeType = context.Request["timeType"] == null ? string.Empty : context.Request["timeType"].ToString();
            string quarterType = context.Request["quarterType"] == null ? string.Empty : context.Request["quarterType"].ToString();

            //根据选择的时间段,设置开始时间和结束时间
            switch (timeType)
            {
                case "1"://月度平均值
                    DateTime dt1 = new DateTime();
                    dt1 = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01");
                    beginTime = dh.GetFirstDayOfMonth(dt1).ToString().Replace("/", "-");
                    endTime = dh.GetLastDayOfMonth(dt1).ToString().Replace("/", "-");
                    break;
                case "2"://季度平均值
                    switch (quarterType)
                    {
                        case "0"://一季度
                            string ti = beginTime.Substring(0, 4) + "-01-01 00:00:00";
                            beginTime = ti;
                            endTime = beginTime.Substring(0, 4) + "-03-31 23:59:59";
                            break;
                        case "1"://二季度
                            string ti1 = beginTime.Substring(0, 4) + "-04-01 00:00:00";
                            beginTime = ti1;
                            endTime = beginTime.Substring(0, 4) + "-06-30 23:59:59";
                            break;
                        case "2"://三季度
                            string ti2 = beginTime.Substring(0, 4) + "-07-01 00:00:00";
                            beginTime = ti2;
                            endTime = beginTime.Substring(0, 4) + "-09-30 23:59:59";
                            break;
                        case "3"://四季度
                            string ti3 = beginTime.Substring(0, 4) + "-10-01 00:00:00";
                            beginTime = ti3;
                            endTime = beginTime.Substring(0, 4) + "-12-31 23:59:59";
                            break;
                    }
                    break;
                case "3"://年度平均值
                    string tim = beginTime.Substring(0, 4);
                    beginTime = tim + "-01-01 00:00:00";
                    endTime = tim + "-12-31 23:59:59";
                    break;
            }

            AllInfo allinfo = new AllInfo();

            List<ConsumeInfo> infoList;

            infoList = bl.get(beginTime, endTime, out errMsg);

            //平均值柱状图
            infos tmp = new infos();
            tmp.name = new ArrayList();
            tmp.value = new ArrayList();
            foreach (ConsumeInfo tmps in infoList)
            {

                tmp.name.Add(tmps.Name);
                tmp.value.Add(Math.Round(tmps.Count, 2));
            }
            allinfo.ZhuTu = tmp;

            //饼状图
            ArrayList ConsumeList = new ArrayList();

            ArrayList tmsp;
            foreach (ConsumeInfo tmps in infoList)
            {
                tmsp = new ArrayList();
                tmsp.Add(tmps.Name);
                tmsp.Add(Math.Round(tmps.Count, 2));
                ConsumeList.Add(tmsp);
            }
            allinfo.ConsumeList = ConsumeList;

            //环比柱状图
            List<infos> info = new List<infos>();
            //七月份
            infos ht = new infos();
            ht.time = DateTime.Parse(beginTime).Month+"月份";
            ht.name = new ArrayList();
            ht.value = new ArrayList();

            foreach (ConsumeInfo tmps in infoList)
            {

                ht.name.Add(tmps.Name);
                ht.value.Add(Math.Round(tmps.Count, 2));
            }
            info.Add(ht);

            //六月份
            infos sixMonth = new infos();
            sixMonth.name = new ArrayList();
            sixMonth.value = new ArrayList();
            string beforBeginTime = DateTime.Parse(beginTime).AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss");
            string beforEndTime = DateTime.Parse(beforBeginTime).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
            sixMonth.time = DateTime.Parse(beforBeginTime).Month + "月份";
            List<ConsumeInfo> beforInfoList = bl.get(beforBeginTime, beforEndTime, out errMsg);

            foreach (ConsumeInfo tmps in beforInfoList)
            {

                sixMonth.name.Add(tmps.Name);
                sixMonth.value.Add(Math.Round(tmps.Count, 2));
            }
            info.Add(sixMonth);

            //环比
            infos SsHb = new infos();
            SsHb.time = "环比增长";
            SsHb.name = new ArrayList();
            SsHb.value = new ArrayList();

            foreach (ConsumeInfo infos in infoList)
            {
                ConsumeInfo c = beforInfoList.Where(t => t.Name == infos.Name).FirstOrDefault();
                SsHb.name.Add(c.Name);
                if (infos.Count > 0)
                {
                    SsHb.value.Add(Math.Round(((infos.Count - c.Count) / infos.Count) * 100, 2));
                }
                else
                {
                    SsHb.value.Add(0);
                }
            }
            info.Add(SsHb);

            allinfo.Hb = info;

            string content = allinfo.ToJsonItem();
            context.Response.ContentType = "text/json;charset=gb2312;";
            context.Response.Write(content);
            context.Response.End();
        }