Exemplo n.º 1
0
        /// <summary>
        /// 取得设备跨小时的测点数据
        /// </summary>
        /// <param name="device">设备</param>
        /// <param name="startYYYYMMDDHH">开始时间 精确到小时 比如:2011062807</param>
        /// <param name="endYYYYMMDDHH">截止时间 精确到小时 比如:2011062817</param>
        /// <param name="intervalMins">数据统计的间隔时间,单位是分钟,比如60表示一小时</param>
        /// <param name="monitorCode">设备测点代码,参见MonitorType.cs</param>
        /// <returns>hashtable,key表示时间点 value是值</returns>
        public Hashtable GetDaydataList(IList <string> XAxis, Device device, string startYYYYMMDDHH, string endYYYYMMDDHH, int intervalMins, int monitorCode)
        {
            //累加多个单元的功率数据
            Hashtable hhpowerHash = new Hashtable();
            string    startYYYYMM = startYYYYMMDDHH.Substring(0, 6);
            string    endYYYYMM   = endYYYYMMDDHH.Substring(0, 6);
            int       startDD     = int.Parse(startYYYYMMDDHH.Substring(6, 2));
            int       endDD       = int.Parse(endYYYYMMDDHH.Substring(6, 2));

            if (startYYYYMM.Equals(endYYYYMM))
            {
                string year  = startYYYYMM.Substring(0, 4);
                string month = startYYYYMM.Substring(4, 2);
                return(this.getMultiDayBetweenData(XAxis, device, year, month, startDD, endDD, intervalMins, monitorCode));
            }
            else
            {
                string    year       = startYYYYMM.Substring(0, 4);
                string    month      = startYYYYMM.Substring(4, 2);
                int       firstEndDD = CalenderUtil.getMonthDays(year + month);
                Hashtable firstHash  = this.getMultiDayBetweenData(XAxis, device, year, month, startDD, firstEndDD, intervalMins, monitorCode);
                year  = endYYYYMM.Substring(0, 4);
                month = endYYYYMM.Substring(4, 2);
                Hashtable secondHash = this.getMultiDayBetweenData(XAxis, device, year, month, 1, endDD, intervalMins, monitorCode);

                foreach (Object obj in secondHash.Keys)
                {
                    firstHash.Add(obj, secondHash[obj]);
                }
                return(firstHash);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将各个月度数据付给map
        /// </summary>
        /// <param name="monthDataMap"></param>
        /// <param name="unitYearData"></param>
        private void putMonthDayMap(Hashtable monthDataMap, CollectorMonthDayData unitMonthData)
        {
            int month = unitMonthData.month;
            int year  = unitMonthData.year;

            //使用反射获得对象的号到最后一天的属性值
            int days = CalenderUtil.getMonthDays(year, month);

            for (int i = 1; i <= days; i++)
            {
                string        key = year + TableUtil.convertIntToMnthStr(month) + TableUtil.convertIntToMnthStr(i);
                System.Object obj = monthDataMap[key];
                if (obj == null)
                {
                    obj = 0;
                }
                object curValue = unitMonthData.GetType().GetProperty("d_" + i).GetValue(unitMonthData, null);
                if (curValue == null)
                {
                    continue;
                }
                float value = StringUtil.stringtoFloat(curValue.ToString());
                monthDataMap[key] = StringUtil.stringtoFloat(obj.ToString()) + value;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据起始年月天取得横坐标
        /// </summary>
        /// <param name="startYearMMDD"></param>
        /// <param name="endYearMMDD"></param>
        /// <returns></returns>
        public IList <String> getXseriesFromYYYYMMDD(string startYearMMDD, string endYearMMDD)
        {
            int startMM = int.Parse(startYearMMDD.Substring(4, 2));
            int endMM   = int.Parse(endYearMMDD.Substring(4, 2));

            int startDD = int.Parse(startYearMMDD.Substring(6, 2));
            int endDD   = int.Parse(endYearMMDD.Substring(6, 2));

            int startYYYY = int.Parse(startYearMMDD.Substring(0, 4));
            int endYYYY   = int.Parse(endYearMMDD.Substring(0, 4));

            IList <string> resList = new List <string>();

            for (int i = startYYYY; i <= endYYYY; i++)
            {
                for (int k = 1; k <= 12; k++)
                {
                    if ((i == startYYYY && k < startMM) || (i == endYYYY && k > endMM))
                    {
                        continue;
                    }
                    int monthDay = CalenderUtil.getMonthDays(i, k);
                    for (int n = 1; n <= monthDay; n++)
                    {
                        if ((k == startMM && n < startDD) || (k == endMM && n > endDD))
                        {
                            continue;
                        }
                        resList.Add(i + TableUtil.convertIntToMnthStr(k) + TableUtil.convertIntToMnthStr(n));
                    }
                }
            }
            return(resList);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据起始年月天小时取得横坐标
        /// </summary>
        /// <param name="startYearMMDDHH"></param>
        /// <param name="endYearMMDDHH"></param>
        /// <returns>天小时列表</returns>
        public IList <String> getXseriesFromYYYYMMDDHH(String startYearMMDDHH, string endYearMMDDHH, int intervalMins)
        {
            int startMM = int.Parse(startYearMMDDHH.Substring(4, 2));
            int endMM   = int.Parse(endYearMMDDHH.Substring(4, 2));

            int startDD = int.Parse(startYearMMDDHH.Substring(6, 2));
            int endDD   = int.Parse(endYearMMDDHH.Substring(6, 2));

            int startHH = int.Parse(startYearMMDDHH.Substring(8, 2));
            int endHH   = int.Parse(endYearMMDDHH.Substring(8, 2));

            int            startYYYY = int.Parse(startYearMMDDHH.Substring(0, 4));
            int            endYYYY   = int.Parse(endYearMMDDHH.Substring(0, 4));
            IList <string> resList   = new List <string>();

            for (int i = startYYYY; i <= endYYYY; i++)
            {
                for (int k = 1; k <= 12; k++)
                {
                    if ((i == startYYYY && k < startMM) || (i == endYYYY && k > endMM))
                    {
                        continue;
                    }

                    for (int n = 1; n <= CalenderUtil.getMonthDays(i, k); n++)
                    {
                        if ((k == startMM && n < startDD) || (k == endMM && n > endDD))
                        {
                            continue;
                        }
                        for (int m = 0; m <= 23; m++)
                        {
                            //add by qianhb in 2011/12/17 去掉日中的5点之前和21点之后的
                            if (m > 21 || m < 5)
                            {
                                continue;
                            }
                            //add by qianhb in 2011/12/17 去掉日中的5点之前和21点之后的 end
                            if ((n == startDD && m < startHH) || (n == endDD && m > endHH))
                            {
                                continue;
                            }
                            if (intervalMins >= 60)
                            {
                                resList.Add(n.ToString("00") + m.ToString("00") + "00");
                            }
                            else
                            {
                                for (int z = 0; z < 60; z = z + intervalMins)
                                {
                                    resList.Add(n.ToString("00") + m.ToString("00") + z.ToString("00"));
                                }
                            }
                        }
                    }
                }
            }
            return(resList);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 作者:鄢睿
        /// 功能:通过电站列表获得单月天发电图表
        /// 创建时间:2011年02月25日
        /// 修改:胡圣忠
        /// </summary>
        /// <param name="plantList">电站列表</param>
        /// <returns></returns>
        public ChartData MMDDChartBypList(IList <Plant> plantList, int year, int month, string chartType, string unit)
        {
            string monthstr      = TableUtil.convertIntToMnthStr(month);
            string startYearMMDD = year + monthstr + "01";
            string endYearMMDD   = year + monthstr + CalenderUtil.getMonthDays(year, month);

            return(this.MMDDChartBypList(plantList, startYearMMDD, endYearMMDD, chartType, unit));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 作者:鄢睿
        /// 功能:取得设备多个年度的年月比较数据
        /// 创建时间:2011年02月25日
        /// </summary>
        /// <param name="device"></param>
        /// <param name="years"></param>
        /// <param name="monitorCode"></param>
        /// <param name="unit"></param>
        /// <param name="chartType"></param>
        /// <returns></returns>
        public ChartData DeviceMMCompare(Device device, IList <string> yearmms, MonitorType mt, string unit, string chartType, float rate)
        {
            ICollection <ICollection> keys = new List <ICollection>();
            StringBuilder             sb   = new StringBuilder();
            // foreach (string year in yearmms)
            //{
            // sb.Append("," + year);
            //}
            string chartName = mt.name + " " + LanguageUtil.getDesc("CHART_TITLE_COMPARE");
            IList <KeyValuePair <string, float?[]> > datas = new List <KeyValuePair <string, float?[]> >();

            string[] chartTypes = new string[1] {
                chartType
            };
            string[] units = new string[1] {
                unit
            };
            string[] ynames = new string[1] {
                ""
            };
            string[] ic = null;

            bool hasData = false;
            //取得多个年度的发电月数据
            int i = 0;

            foreach (string yearMM in yearmms)
            {
                Hashtable dataHash = null;
                string    curName  = yearMM;
                dataHash = DeviceMonthDayDataService.GetInstance().DeviceYearMMDDList(device, yearMM, yearMM);
                string[] tmpic = base.getXseriesFromYYYYMMDD(yearMM + "01", yearMM + CalenderUtil.getMonthDays(yearMM).ToString("00")).ToArray();
                if (ic == null || tmpic.Length > ic.Length)
                {
                    ic = tmpic;
                }
                //如果有多个设备进行编辑,没有数据的时候也显示
                //if (dataHash.Count > 0)
                //{
                KeyValuePair <string, float?[]> data = GenerateChartData(curName, ic, dataHash, rate);
                datas.Add(data);
                //}
                //如果有数据则将有数据标识为true
                if (dataHash.Count > 0)
                {
                    hasData = true;
                }
                i++;
            }
            if (!hasData)
            {
                //如果所有设备都没数据才清空数据,即图表中显示无数据提示
                datas.Clear();
            }
            string[] xAxis = formatXaxis(ic, ChartTimeType.MonthDay);
            return(ReportBuilder.createMultiJsonChartXY(chartName, xAxis, datas, ynames, chartTypes, units, fromApp));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 将不同类型报表所传时间转成起止时间
        /// </summary>
        /// <param name="reportType"></param>
        /// <param name="datetime"></param>
        /// <returns></returns>
        public string[] convertToDateArr(int reportType, string datetime)
        {
            string[] dataArr = new string[2];
            switch (reportType)
            {
            case DataReportType.TODAY_REPORT_CODE:
                dataArr[0] = datetime.Replace("-", "") + "07";
                dataArr[1] = datetime.Replace("-", "") + "19";
                break;

            case DataReportType.WEEK_REPORT_CODE:
                string[] darr1     = datetime.Split('-');
                int      year1     = int.Parse(darr1[0]);
                int      month1    = int.Parse(darr1[1]);
                int      day1      = int.Parse(darr1[2]);
                string   bTime     = new DateTime(year1, month1, day1).AddDays(-6).ToString("yyyy-MM-dd");
                string[] darr2     = bTime.Split('-');
                string   year2     = darr2[0];
                string   month2    = darr2[1];
                string   day2      = darr2[2];
                string   beginTime = year2 + month2 + day2;
                string   endTime   = year1 + "" + month1.ToString("00") + "" + day1.ToString("00");
                string[] t         = new string[] { beginTime, endTime };
                dataArr = t;
                break;

            case DataReportType.MONTH_REPORT_CODE:
                string[] darr  = datetime.Split('-');
                int      year  = int.Parse(darr[0]);
                int      month = int.Parse(darr[1]);
                dataArr[0] = datetime.Replace("-", "") + "01";
                dataArr[1] = datetime.Replace("-", "") + CalenderUtil.getMonthDays(year, month).ToString("00");

                break;

            case DataReportType.YEAR_REPORT_CODE:
                dataArr[0] = datetime + "01";
                dataArr[1] = datetime + "12";
                break;

            case DataReportType.TOTAL_REPORT_CODE:
                dataArr = datetime.Split('-');
                break;

            default:
                break;
            }

            return(dataArr);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 将各个月度数据付给map
        /// </summary>
        /// <param name="monthDataMap"></param>
        /// <param name="deviceMonthData"></param>
        /// <param name="rate">每个设备的rate可能不一样,所以要单独计算</param>
        private void putMonthDayMap(Hashtable monthDataMap, DeviceMonthDayData deviceMonthData, float rate)
        {
            int month = deviceMonthData.month;
            int year  = deviceMonthData.year;

            //使用反射获得对象的号到最后一天的属性值
            int days = CalenderUtil.getMonthDays(year, month);

            for (int i = 1; i <= days; i++)
            {
                string        key = year + TableUtil.convertIntToMnthStr(month) + TableUtil.convertIntToMnthStr(i);
                System.Object obj = monthDataMap[key];

                object tmpvalue = deviceMonthData.GetType().GetProperty("d_" + i).GetValue(deviceMonthData, null);
                float  value    = tmpvalue == null ? 0 : StringUtil.stringtoFloat(tmpvalue.ToString());
                if (obj != null || tmpvalue != null)
                {
                    monthDataMap[key] = (obj == null ? 0 : StringUtil.stringtoFloat(obj.ToString())) + value * rate;
                }
            }
        }