/// <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> private PageModel <VideoStruct> SelectList(List <Lane> lanes, VideoStructType structType, DateTime startTime, DateTime endTime, int pageNum, int pageSize, bool hasTotal) { string dataIds = StringConvert.ToSplitString(lanes .Select(l => l.DataId) .ToArray()); List <string> urls = lanes .Where(l => !string.IsNullOrEmpty(l.Channel.FlowDevice_FlowChannel.Device.NodeUrl)) .Select(l => $"http://{l.Channel.FlowDevice_FlowChannel.Device.NodeUrl}/api/videoStructs/{dataIds}?structType={structType}&startTime={startTime}&endTime={endTime}&pageNum={pageNum}&pageSize={pageSize}&hasTotal={hasTotal}") .Distinct() .ToList(); PageModel <VideoStruct> totalList = new PageModel <VideoStruct> { Datas = new List <VideoStruct>() }; using (HttpClient client = new HttpClient()) { foreach (string url in urls) { PageModel <VideoStruct> itemList = client.Get <PageModel <VideoStruct> >(url); if (itemList != null) { totalList.Datas.AddRange(itemList.Datas); totalList.Total += itemList.Total; } } } return(totalList); }
/// <summary> /// 按路段流向查询流量数据 /// </summary> /// <param name="lanes">车道集合</param> /// <param name="level">时间粒度</param> /// <param name="startTimes">开始时间集合</param> /// <param name="endTimes">结束时间集合</param> /// <returns>流量数据集合</returns> private List <List <LaneFlow> > SelectList(List <Lane> lanes, DateTimeLevel level, DateTime[] startTimes, DateTime[] endTimes) { string dataIds = StringConvert.ToSplitString(lanes .Select(l => l.DataId) .ToArray()); List <string> urls = lanes .Where(l => !string.IsNullOrEmpty(l.Channel.FlowDevice_FlowChannel.Device.NodeUrl)) .Select(l => $"http://{l.Channel.FlowDevice_FlowChannel.Device.NodeUrl}/api/laneflows/{dataIds}?level={level}&startTimes={StringConvert.ToSplitString(startTimes)}&endTimes={StringConvert.ToSplitString(endTimes)}") .Distinct() .ToList(); List <List <LaneFlow> > totalList = new List <List <LaneFlow> >(); for (int i = 0; i < startTimes.Length; ++i) { totalList.Add(new List <LaneFlow>()); } using (HttpClient client = new HttpClient()) { foreach (string url in urls) { List <List <LaneFlow> > itemList = client.Get <List <List <LaneFlow> > >(url); if (itemList == null) { _logger.LogDebug((int)LogEvent.流量查询, $"{url} 查询失败"); } else { _logger.LogDebug((int)LogEvent.流量查询, $"{url} {itemList.Count}"); for (int i = 0; i < startTimes.Length; ++i) { totalList[i].AddRange(itemList[i]); } } } } return(totalList); }