示例#1
0
        /// <summary>
        /// 按区域查询密度同比环比分析
        /// </summary>
        /// <param name="dataId">数据编号</param>
        /// <param name="level">密度时间粒度</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns>高点密度数据集合</returns>
        public List <List <TrafficChart <DateTime, int> > > QueryComparison(string dataId, DateTimeLevel level, DateTime startTime, DateTime endTime)
        {
            dataId    = Uri.UnescapeDataString(dataId);
            startTime = TimePointConvert.CurrentTimePoint(level, startTime);
            endTime   = TimePointConvert.CurrentTimePoint(level, endTime);
            List <DateTime> startTimes = new List <DateTime>();
            List <DateTime> endTimes   = new List <DateTime>();

            startTimes.Add(startTime);
            endTimes.Add(endTime);

            //同比
            if (level == DateTimeLevel.FiveMinutes ||
                level == DateTimeLevel.FifteenMinutes ||
                level == DateTimeLevel.Hour)
            {
                startTimes.Add(TimePointConvert.PreTimePoint(DateTimeLevel.Day, startTime));
                endTimes.Add(TimePointConvert.PreTimePoint(DateTimeLevel.Day, endTime));
            }

            else if (level == DateTimeLevel.Day)
            {
                startTimes.Add(TimePointConvert.PreTimePoint(DateTimeLevel.Month, startTime));
                endTimes.Add(TimePointConvert.PreTimePoint(DateTimeLevel.Month, endTime));
            }
            else if (level == DateTimeLevel.Month)
            {
                startTimes.Add(TimePointConvert.PreTimePoint(DateTimeLevel.Year, startTime));
                endTimes.Add(TimePointConvert.PreTimePoint(DateTimeLevel.Year, endTime));
            }
            else
            {
                return(new List <List <TrafficChart <DateTime, int> > >());
            }

            //环比
            startTimes.Add(TimePointConvert.PreTimePoint(level, startTime));
            endTimes.Add(TimePointConvert.PreTimePoint(level, endTime));
            return(startTimes.Select((t, i) => SelectCharts(dataId, level, startTimes[0], t, endTimes[i])).ToList());
        }