//根据一个GPS编号获取车辆编号。临时使用,最终会使用组件替代。 public static string GetVehicleCodeByGPSCode(string gpsCode) { GPSInstallationManager manager = new GPSInstallationManager(); string vehicleCode = manager.GetVehicleCodeByGPSCode(gpsCode); if (vehicleCode == null) { Loggers.LogInfo("GPSDataHelper.GetVehicleCodeByGPSCode:无对应的车辆关系[" + gpsCode + "]"); } manager = null; return vehicleCode; }
public bool HadInstallGPS(Guid vehicleCode) { IGPSInstallationManager img = new GPSInstallationManager(); return img.IsInstalled(vehicleCode); }
public IList<VRealTimeInfo> GetRealTimeInfo(string[] arrVehicleCode, SessionContext sessionContext, bool isNotCalcOil,bool isNotEncode) { if (arrVehicleCode == null || arrVehicleCode.Length == 0) throw new ArgumentNullException("GetRealTimeInfo: VehicleCode can not be null or empty!"); if (sessionContext == null) throw new ArgumentNullException("GetRealTimeInfo: SessionContext can not be null!"); if (string.IsNullOrEmpty(sessionContext.TenantCode)) throw new ArgumentNullException("GetRealTimeInfo: TenantCode can not be null!"); DateTime now = DateTime.Now; IList<EGPSCurrentInfo> ltCurrentInfo = this.GetCurrentInfo(arrVehicleCode); if (ltCurrentInfo.Count == 0) { return new List<VRealTimeInfo>(); } string[] arrLatLonEncode = GetEncodeLatLon(isNotEncode, ltCurrentInfo); Guid[] arrVehicleCode_G = arrVehicleCode.Select(s => new Guid(s)).ToArray(); IGPSInstallationManager igm = new GPSInstallationManager(); Dictionary<Guid, EGPSInstallationInfo> dcInstallation = igm.GetUsingVehicleDict(sessionContext.TenantCode, arrVehicleCode_G); IVehicleAndMileageService service = new VehicleAndMileageService(); IList<EVehicleAndMileage> ltEVehicleAndMileage = service.Get(arrVehicleCode_G); IList<VehicleType> ltVehicleType = GetAllVehicleTypes(sessionContext.TenantCode); IList<EDriver> ltDriver = GetDrivers(sessionContext, dcInstallation.Values.ToArray()); IList<EVehicleRunningState> ltRunningState = GetRunningStates(dcInstallation.Values.ToArray()); IList<VRealTimeInfo> ltRealTimeInfo = new List<VRealTimeInfo>(); now = DateTime.Now; for (int i = 0; i < ltCurrentInfo.Count; i++) { if (!isNotEncode) { ltCurrentInfo[i].EncodeLatLon = arrLatLonEncode[i]; } VRealTimeInfo realTimeInfo; try { if (!dcInstallation.ContainsKey(ltCurrentInfo[i].VehicleCode.Value)) { continue; } EGPSInstallationInfo installationInfo = dcInstallation[ltCurrentInfo[i].VehicleCode.Value]; realTimeInfo = this.CreateVRealTimeInfo(ltEVehicleAndMileage, sessionContext, ltCurrentInfo[i], installationInfo, isNotCalcOil,ltVehicleType,ltDriver,ltRunningState); } catch (GPSCurrentInfoNullException ex) { Logger.Error(ex); continue; } catch (InvalidGPSCurrentInfoException ex) { Logger.Error(ex); continue; } catch (VehicleInfoNullException ex) { Logger.Error(ex); continue; } ltRealTimeInfo.Add(realTimeInfo); } TimeSpan ts = DateTime.Now - now; Logger.Trace(string.Format("Get CreateVRealTimeInfo use{0}", ts.TotalMilliseconds.ToString())); return ltRealTimeInfo; }
public IList<Guid> VehicleSearch(string maxEncodeLatLon,string minEncodeLatLon,string tenantCode) { PES.MapService.MapSearchService.MapService mapService = new PES.MapService.MapSearchService.MapService(); LatLon maxLatLon = mapService.Decode(maxEncodeLatLon); LatLon minLatLon = mapService.Decode(minEncodeLatLon); IGPSInstallationManager installManager = new GPSInstallationManager(); IList<string> ltGPSCode = installManager.GetGPSCode(tenantCode); IGPSTrackManager trackManager = new GPSTrackManager(); Rectangle rec = new Rectangle(maxLatLon.Latitude, maxLatLon.Longitude, minLatLon.Latitude, minLatLon.Longitude); IList<EGPSCurrentInfo> ltCurrentInfo = trackManager.SearchVehicleInRectange(rec, ltGPSCode.ToArray<string>()); if (ltCurrentInfo == null || ltCurrentInfo.Count == 0) return null; return ltCurrentInfo.Select(s => s.VehicleCode.Value).ToList(); }