/// <summary> /// 获取同一个历史数据配置,多台车辆,指定时间段内,里程汇总数据 /// </summary> /// <param name="config">历史数据配置</param> /// <param name="vehicleList">车辆序列</param> /// <param name="beginTime">起始时间</param> /// <param name="endTime">结束时间</param> /// <returns></returns> public List<EMileage> GetReportTimeSpanMileage(EHistoryDataStoreConfig config, List<Guid> vehicleList, DateTime beginTime, DateTime endTime) { List<EMileage> ModelList = new List<EMileage>(); List<EGPSHistoryInfo> firstList = objReportServer.GetFirstRecordList(config, vehicleList, beginTime, endTime, true); List<EGPSHistoryInfo> lastList = objReportServer.GetLastRecordList(config, vehicleList, beginTime, endTime, true); if (firstList != null && lastList != null) { foreach (Guid vehicle in vehicleList) { EMileage Model = new EMileage(); Model.VehicleCode = vehicle; Model.QueryBeginTime = beginTime; Model.QueryEndTime = endTime; EGPSHistoryInfo first = firstList.Where(f => f.VehicleCode == vehicle).FirstOrDefault(); EGPSHistoryInfo last = lastList.Where(f => f.VehicleCode == vehicle).FirstOrDefault(); if (first == null || last == null) continue; Model.BeginTime = first.ReportTime; Model.EndTime = last.ReportTime; Model.BeginMileage = decimal.Round((first.StarkMileage / 1000), 2); Model.EndMileage = decimal.Round((last.StarkMileage / 1000), 2); Model.TotalMileage += decimal.Round((last.StarkMileage / 1000 - first.StarkMileage / 1000), 2); ModelList.Add(Model); } } return ModelList; }
/// <summary> /// 获取同一个历史数据配置,多台车辆,指定时间段内,里程汇总数据 /// </summary> /// <param name="config">历史数据配置</param> /// <param name="vehicleList">车辆序列</param> /// <param name="beginTime">起始时间</param> /// <param name="endTime">结束时间</param> /// <returns></returns> private List<EMileage> GetReportTimeSpanMileage(EHistoryDataStoreConfig config, List<Guid> vehicleList, DateTime beginTime, DateTime endTime, bool getPostition) { IMapService mapService = new PES.GPS.MapService.MapSearchService.MapService(); List<EMileage> ModelList = new List<EMileage>(); List<EGPSHistoryInfo> firstList = objReportServer.GetFirstRecordList(config, vehicleList, beginTime, endTime, true); List<EGPSHistoryInfo> lastList = objReportServer.GetLastRecordList(config, vehicleList, beginTime, endTime, true); if (firstList != null && lastList != null) { foreach (Guid vehicle in vehicleList) { EMileage Model = new EMileage(); Model.VehicleCode = vehicle; Model.QueryBeginTime = beginTime; Model.QueryEndTime = endTime; EGPSHistoryInfo first = firstList.Where(f => f.VehicleCode == vehicle).FirstOrDefault(); EGPSHistoryInfo last = lastList.Where(f => f.VehicleCode == vehicle).FirstOrDefault(); if (first == null || last == null) continue; Model.BeginTime = first.ReportTime; Model.EndTime = last.ReportTime; if (getPostition) { Model.BeginLocation = InverseGeocoding(mapService, first.Latitude, first.Longitude); Model.EndLocation = InverseGeocoding(mapService, last.Latitude, last.Longitude); } Model.BeginMileage = decimal.Round((first.StarkMileage / 1000), 2); Model.EndMileage = decimal.Round((last.StarkMileage / 1000), 2); Model.TotalMileage += decimal.Round((last.StarkMileage / 1000 - first.StarkMileage / 1000), 2); ModelList.Add(Model); } } return ModelList; }
private List<EMileage> GetReportTimeSpanListMileage(EHistoryDataStoreConfig config, List<Guid> vehicleCodeList, List<DateTime[]> timeSpanList, string TenantCode, bool getPostition) { IMapService mapService = new PES.GPS.MapService.MapSearchService.MapService(); List<EMileage> list = new List<EMileage>(); List<EGPSHistoryInfo> firstList = objReportServer.GetFirstRecordList(config, vehicleCodeList, timeSpanList, true); List<EGPSHistoryInfo> lastList = objReportServer.GetLastRecordList(config, vehicleCodeList, timeSpanList, true); if (firstList == null || firstList.Count == 0 || lastList == null || lastList.Count == 0) return list; foreach (Guid vehicleCode in vehicleCodeList) { foreach (DateTime[] timeSpan in timeSpanList) { EMileage Model = new EMileage(); Model.VehicleCode = vehicleCode; Model.QueryBeginTime = timeSpan[0]; Model.QueryEndTime = timeSpan[1]; var first = firstList.Where(o => o.ReportTime >= timeSpan[0] && o.ReportTime <= timeSpan[1] && o.VehicleCode == vehicleCode).FirstOrDefault(); var last = lastList.Where(o => o.ReportTime >= timeSpan[0] && o.ReportTime <= timeSpan[1] && o.VehicleCode == vehicleCode).FirstOrDefault(); if (first == null || last == null) continue; Model.BeginTime = first.ReportTime; if (getPostition) { Model.BeginLocation = InverseGeocoding(mapService, first.Latitude, first.Longitude); } Model.EndTime = last.ReportTime; if (getPostition) { Model.EndLocation = InverseGeocoding(mapService, last.Latitude, last.Longitude); } Model.BeginMileage = decimal.Round((first.StarkMileage / 1000), 2); Model.EndMileage = decimal.Round((last.StarkMileage / 1000), 2); Model.TotalMileage += decimal.Round((last.StarkMileage / 1000 - first.StarkMileage / 1000), 2); list.Add(Model); } } return list; }
//这里设为公有,是提供给其他WCF服务调用 private EMileage GetReportTimeSpanMileage(Guid vehicleCode, DateTime StartTime, DateTime EndTime, bool getPostition) { EMileage Model = new EMileage(); Model.VehicleCode = vehicleCode; Model.QueryBeginTime = StartTime; Model.QueryEndTime = EndTime; EHistoryDataStoreConfig config = tableConfigSev.GetVehicleStoreTableConfig(vehicleCode); IMapService mapService = new PES.GPS.MapService.MapSearchService.MapService(); var first = objReportServer.GetFirstRecord(config, StartTime, EndTime, true); var last = objReportServer.GetLastRecord(config, StartTime, EndTime, true); if (first == null || last == null) return Model; Model.BeginTime = first.ReportTime; if (getPostition) { Model.BeginLocation = InverseGeocoding(mapService, first.Latitude, first.Longitude); } Model.EndTime = last.ReportTime; if (getPostition) { Model.EndLocation = InverseGeocoding(mapService, last.Latitude, last.Longitude); } Model.BeginMileage = decimal.Round((first.StarkMileage / 1000), 2); Model.EndMileage = decimal.Round((last.StarkMileage / 1000), 2); Model.TotalMileage += decimal.Round((last.StarkMileage / 1000 - first.StarkMileage / 1000), 2); return Model; }
/// <summary> /// 返回总里程,单位(千米) /// </summary> /// <param name="vehicleCode"></param> /// <param name="StartTime"></param> /// <param name="EndTime"></param> /// <returns></returns> private decimal GetTotalMileage(Guid vehicleCode, DateTime StartTime, DateTime EndTime) { EMileage Model = new EMileage(); IReportService objReportServer = new ReportService(); IList<VGPSInstallationInfo> installationInfoList = objReportServer.GetGpsRelationList(vehicleCode, StartTime, EndTime); EHistoryDataStoreConfig config = objReportServer.GetVehicleStoreTableConfig(vehicleCode); if (installationInfoList == null || installationInfoList.Count == 0) { return 0; } for (int i = 0, i_Count = installationInfoList.Count(); i < i_Count; i++) { VGPSInstallationInfo installInfo = installationInfoList[i]; DateTime bTime = installInfo.CreateDate > StartTime ? installInfo.CreateDate : StartTime; DateTime eTime = EndTime; if (installInfo.StopDate.HasValue) { if (installInfo.StopDate.Value < EndTime) { eTime = installInfo.StopDate.Value; } } var first = objReportServer.GetFirstRecordInDay(config, installInfo.GpsCode, bTime, eTime, true); var last = objReportServer.GetLastRecordInDay(config, installInfo.GpsCode, bTime, eTime, true); if (first == null || last == null) continue; Model.TotalMileage += decimal.Round((last.StarkMileage / 1000 - first.StarkMileage / 1000), 2); } return Model.TotalMileage; }
private double GetTotalMileageByVehicle(Guid vehicleCode, DateTime StartTime, DateTime EndTime) { EMileage Model = new EMileage(); IReportService objReportServer = new ReportService(); IList<VGPSInstallationInfo> installationInfoList = objReportServer.GetGpsRelationList(vehicleCode, StartTime, EndTime); EHistoryDataStoreConfig config = objReportServer.GetVehicleStoreTableConfig(vehicleCode); if (installationInfoList == null || installationInfoList.Count == 0) { Logger.Trace(string.Format("车辆编号为:{0}在时间{1}到{2}内未找到对应的GPS关联", vehicleCode, StartTime, EndTime)); return 0; } IMapService mapService = new PES.MapService.MapSearchService.MapService(); for (int i = 0, i_Count = installationInfoList.Count(); i < i_Count; i++) { VGPSInstallationInfo installInfo = installationInfoList[i]; DateTime bTime = installInfo.CreateDate > StartTime ? installInfo.CreateDate : StartTime; DateTime eTime = EndTime; if (installInfo.StopDate.HasValue) { if (installInfo.StopDate.Value < EndTime) { eTime = installInfo.StopDate.Value; } } var first = objReportServer.GetFirstRecordInDay(config, installInfo.GpsCode, bTime, eTime, true); var last = objReportServer.GetLastRecordInDay(config, installInfo.GpsCode, bTime, eTime, true); if (first == null || last == null) continue; Model.TotalMileage += decimal.Round((last.StarkMileage / 1000 - first.StarkMileage / 1000), 2); } return (double)Model.TotalMileage; }