/// <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; }