Ejemplo n.º 1
0
        /// <summary>
        /// 按区域查询密度集合
        /// </summary>
        /// <param name="dataId">数据编号</param>
        /// <param name="level">时间级别</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns>高点密度数据集合</returns>
        public List <TrafficDensity> QueryList(string dataId, DateTimeLevel level, DateTime startTime, DateTime endTime)
        {
            dataId = Uri.UnescapeDataString(dataId);
            List <IQueryable <TrafficDensity> > queryables = BranchDbConvert.GetQuerables(startTime, endTime, _context.Queryable(level));
            List <TrafficDensity> result = new List <TrafficDensity>();

            foreach (IQueryable <TrafficDensity> queryable in queryables)
            {
                try
                {
                    IQueryable <TrafficDensity> whereQueryable = Where(queryable, dataId, level, startTime, endTime);
                    if (level >= DateTimeLevel.Day)
                    {
                        result.AddRange(whereQueryable
                                        .GroupBy(f => TimePointConvert.CurrentTimePoint(level, f.DateTime))
                                        .Select(g => new TrafficDensity
                        {
                            DataId   = g.First().DataId,
                            DateTime = g.Key,
                            Value    = Convert.ToInt32(g.Average(d => d.Value))
                        })
                                        .ToList());
                    }
                    else
                    {
                        result.AddRange(whereQueryable.ToList());
                    }
                }
                catch
                {
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 按车道查询流量数据
        /// </summary>
        /// <param name="lanes">车道集合</param>
        /// <param name="level">时间粒度</param>
        /// <param name="startTimes">开始时间集合</param>
        /// <param name="endTimes">结束时间集合</param>
        /// <param name="baseTime">基准时间</param>
        /// <param name="flowTypes">流量密度数据</param>
        /// <returns>流量数据集合</returns>
        public virtual List <List <TrafficChart <DateTime, int, LaneFlow> > > QueryCharts(List <Lane> lanes, DateTimeLevel level, DateTime[] startTimes, DateTime[] endTimes, DateTime baseTime, FlowType[] flowTypes = null)
        {
            List <List <TrafficChart <DateTime, int, LaneFlow> > > result = new List <List <TrafficChart <DateTime, int, LaneFlow> > >();
            HashSet <string> dataIds = lanes.Select(l => l.DataId).ToHashSet();

            for (int i = 0; i < startTimes.Length; ++i)
            {
                List <TrafficChart <DateTime, int, LaneFlow> > item = new List <TrafficChart <DateTime, int, LaneFlow> >();
                foreach (IQueryable <LaneFlow> queryable in BranchDbConvert.GetQuerables(startTimes[i], endTimes[i], _flowContext.Queryable(level)))
                {
                    item.AddRange(SelectChart(Where(queryable, dataIds, level, startTimes[i], endTimes[i]), level, startTimes[0], startTimes[i], flowTypes));
                }
                result.Add(item);
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 选择图表
        /// </summary>
        /// <param name="dataId">数据编号</param>
        /// <param name="level">时间级别</param>
        /// <param name="baseTime">基准时间</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns>查询结果</returns>
        private List <TrafficChart <DateTime, int> > SelectCharts(string dataId, DateTimeLevel level, DateTime baseTime, DateTime startTime, DateTime endTime)
        {
            List <IQueryable <TrafficDensity> > queryables =
                BranchDbConvert.GetQuerables(startTime, endTime, _context.Queryable(level));
            List <TrafficChart <DateTime, int> > result = new List <TrafficChart <DateTime, int> >();

            foreach (IQueryable <TrafficDensity> queryable in queryables)
            {
                try
                {
                    string   timeFormat     = TimePointConvert.TimeFormat(level);
                    TimeSpan span           = TimePointConvert.CurrentTimePoint(level, baseTime) - TimePointConvert.CurrentTimePoint(level, startTime);
                    var      whereQueryable = Where(queryable, dataId, level, startTime, endTime);
                    if (level >= DateTimeLevel.Day)
                    {
                        result.AddRange(whereQueryable
                                        .GroupBy(f => TimePointConvert.CurrentTimePoint(level, f.DateTime))
                                        .Select(g => new TrafficChart <DateTime, int>
                        {
                            Axis   = g.Key.Add(span),
                            Remark = g.Key.ToString(timeFormat),
                            Value  = Convert.ToInt32(g.Average(d => d.Value))
                        })
                                        .ToList());
                    }
                    else
                    {
                        result.AddRange(whereQueryable
                                        .ToList()
                                        .Select(d => new TrafficChart <DateTime, int>
                        {
                            Axis   = d.DateTime.Add(span),
                            Remark = d.DateTime.ToString(timeFormat),
                            Value  = d.Value
                        })
                                        .ToList());
                    }
                }
                catch
                {
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 按路口查询视频数据化结构数据集合
 /// </summary>
 /// <param name="lanes">车道集合</param>
 /// <param name="structType">视频结构化数据类型</param>
 /// <param name="startTime">开始时间</param>
 /// <param name="endTime">结束时间</param>
 /// <param name="pageSize">分页页码</param>
 /// <param name="pageNum">分页数量</param>
 /// <param name="hasTotal">是否查询总数</param>
 /// <returns>视频数据化结构数据集合</returns>
 public virtual PageModel <VideoStruct> QueryList(List <Lane> lanes, VideoStructType structType, DateTime startTime, DateTime endTime, int pageNum, int pageSize, bool hasTotal)
 {
     return(SelectList(BranchDbConvert.GetQuerables(startTime, endTime, _context.Queryable(structType)), lanes.Select(l => l.DataId).ToHashSet(), startTime, endTime, pageNum, pageSize, hasTotal));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 按车道查询多组流量数据
 /// </summary>
 /// <param name="lanes">车道集合</param>
 /// <param name="level">时间粒度</param>
 /// <param name="startTimes">开始时间集合</param>
 /// <param name="endTimes">结束时间集合</param>
 /// <returns>流量数据集合</returns>
 public virtual List <List <LaneFlow> > QueryList(List <Lane> lanes, DateTimeLevel level, DateTime[] startTimes, DateTime[] endTimes)
 {
     return(startTimes.Select((t, i) => SelectList(BranchDbConvert.GetQuerables(t, endTimes[i], _flowContext.Queryable(level)), lanes.Select(l => l.DataId).ToHashSet(), level, t, endTimes[i])).ToList());
 }