/// <summary> /// 查询车辆历史数据(分页) /// </summary> /// <param name="vehicleCode"></param> /// <param name="beginTime"></param> /// <param name="endTime"></param> /// <param name="isRevise"></param> /// <returns></returns> public GPSHistorySectionViewModel GetSectionHistoryLocus(Guid vehicleCode, DateTime beginTime, DateTime endTime, TimeSpan overTime, TimeSpan? lastStopTime, int RecordNum, EnumMapType mapType) { HistoryLocusService service = new HistoryLocusService(); if (RecordNum < 1) RecordNum = _VehicleLocusSize; VGPSHistorySection section = service.GetHistoryLocus(vehicleCode, beginTime, endTime, mapType, RecordNum, overTime, lastStopTime); GPSHistorySectionViewModel res = new GPSHistorySectionViewModel(); res.IsNext = section.IsNext; res.NextBegin = section.NextBegin; res.NextEnd = section.NextEnd; res.PlayKey = Guid.Empty; res.LastPointIsStop = section.LastPointIsStop; res.LastStopTime = section.LastStopTime; if (!section.CurrentHistoryInfos.IsNullOrEmpty()) { res.CurrentHistoryInfos = new List<HistoryLocusViewModel>(); foreach (var item in section.CurrentHistoryInfos) { res.CurrentHistoryInfos.Add(new HistoryLocusViewModel { Latitude = item.Latitude, Longitude = item.Longitude, EncodeLatLon = item.EncodeLatLon, ReportTime = item.ReportTime, Speed = item.Speed, Direction = item.Direction, Mileage = item.Mileage, StarkMileage = item.StarkMileage, StopTime = item.StopTime, StopTimeBegin = item.StopTimeBegin, StopTimeEnd = item.StopTimeEnd, Description = item.Description, IsNotSureStop = item.IsNotSureStop, IsStop = item.IsStop, IsPoweOff = item.IsPoweOff, IsRob = item.IsRob }); } } return res; }
//车辆己熄火5分钟 public bool IsAccOff(Guid vehicleCode) { HistoryLocusService db = new HistoryLocusService(); DateTime endDate = DateTime.Now; DateTime beginDate = endDate.AddMinutes(-5); IList<EGPSHistoryInfo> historyList = db.Get(vehicleCode, beginDate, endDate); foreach (EGPSHistoryInfo info in historyList) { if (info.ACCState == 1 || info.Speed != 0) { return false; } } return true; }
/// <summary> /// 从历史表中生成停车明细报表 /// </summary> public IList<VStopCarReport> SearchStop(IList<Guid> ltVehicleCode, DateTime beginTime, DateTime endTime, int second, string tenantCode, out Dictionary<Guid, TimeSpan> totalTime) { List<VStopCarReport> ltStop = new List<VStopCarReport>(); HistoryLocusService historyServ = new HistoryLocusService(); Dictionary<Guid, IList<EGPSHistoryInfo>> dic = historyServ.Get(ltVehicleCode, beginTime, endTime); totalTime = new Dictionary<Guid, TimeSpan>(); foreach (var item in dic) { if (item.Value != null && item.Value.Count > 0) totalTime.Add(item.Key, item.Value.Last().ReportTime - item.Value.First().ReportTime); else totalTime.Add(item.Key, new TimeSpan(0)); ltStop.AddRange(SearchStop(item.Value, second)); } if (ltStop.Count > 0) { IList<VStopCarReport> ltResult = ltStop as IList<VStopCarReport>; return ltResult; } return ltStop; }
private static DateTime? GetRunningOrOffTime(HistoryLocusService locusServ, EGPSCurrentInfo item) { DateTime? runningOrOffTime = null; //启动/熄火时间 try { runningOrOffTime = locusServ.GetRunngingOrOffTime(item.VehicleCode.Value, item.GPSCode, item.ReportTime, item.ACCState); } catch (Exception ex) { Logger.Error("GetRunningOrOffTime" + ex.Message, ex); } return runningOrOffTime; }
private List<CurrentInfoViewModel> ConvertToViewModel(IList<EGPSCurrentInfo> ltEGPSCurrentInfo, bool isNeedRevise) { HistoryLocusService locusServ = new HistoryLocusService(); if (ltEGPSCurrentInfo.IsNullOrEmpty()) { return null; } List<CurrentInfoViewModel> list = new List<CurrentInfoViewModel>(); foreach (var item in ltEGPSCurrentInfo) { DateTime? runningOrOffTime = GetRunningOrOffTime(locusServ, item); list.Add(ConvertToViewModel(item, runningOrOffTime)); } SetLocation(list); SetWarningState(ltEGPSCurrentInfo, list); SetWebLatLon(list, isNeedRevise); return list; }
/// <summary> /// 查询车辆历史数据(全部轨迹,分页) /// </summary> /// <param name="vehicleCode"></param> /// <param name="beginTime"></param> /// <param name="endTime"></param> /// <param name="isRevise"></param> /// <returns></returns> public GPSHistorySectionViewModel GetAllHistoryLocus(Guid vehicleCode, DateTime beginTime, DateTime endTime, EnumMapType mapType) { HistoryLocusService service = new HistoryLocusService(); VGPSHistorySection section = service.GetHistoryLocus(vehicleCode, beginTime, endTime, mapType, int.MaxValue); List<HistoryLocusViewModel> listViewModel = section.CurrentHistoryInfos.Select(o => new HistoryLocusViewModel() { Latitude = o.Latitude, Longitude = o.Longitude, ReportTime = o.ReportTime, Speed = o.Speed, Direction = o.Direction, Mileage = o.Mileage, StopTime = o.StopTime }).ToList<HistoryLocusViewModel>(); GPSHistorySectionViewModel viewModel = new GPSHistorySectionViewModel() { IsNext = section.IsNext, NextBegin = section.NextBegin, NextEnd = section.NextEnd, CurrentHistoryInfos = listViewModel, LastPointIsStop = section.LastPointIsStop, LastStopTime = section.LastStopTime }; return viewModel; }
/// <summary> /// 查询车辆历史数据(无分页) /// </summary> /// <param name="vehicleCode"></param> /// <param name="beginTime"></param> /// <param name="endTime"></param> /// <param name="isRevise"></param> /// <returns></returns> public List<HistoryLocusViewModel> GetHistoryLocus(Guid vehicleCode, DateTime beginTime, DateTime endTime, EnumMapType mapType) { HistoryLocusService service = new HistoryLocusService(); IList<VGPSHistoryRunInfo> list = service.GetHistoryLocus(vehicleCode, beginTime, endTime, mapType); if (list == null) { list = new List<VGPSHistoryRunInfo>(); } List<HistoryLocusViewModel> listViewModel = list.Select(o => new HistoryLocusViewModel() { Latitude = o.Latitude, Longitude = o.Longitude, ReportTime = o.ReportTime, Speed = o.Speed, Direction = o.Direction, Mileage = o.Mileage, StopTime = o.StopTime }).ToList<HistoryLocusViewModel>(); return listViewModel; }