private void SetOilValue(EBaseVehicle vehicleInfo, VRealTimeInfo realTimeInfoViewEntity, EGPSCurrentInfo currentInfo, EGPSInstallationInfo installationInfo, bool isNotCalcOil) { if (!isNotCalcOil) //isNotCalcOil 为真时,不取油耗数据 { try { realTimeInfoViewEntity.OilValue = GetOilValue(vehicleInfo, currentInfo, installationInfo); } catch (Exception ex) { Logger.Error(ex); } } }
private string GetOilValue(EBaseVehicle vehicleInfo, EGPSCurrentInfo currentInfo, EGPSInstallationInfo installationInfo) { try { string oilValue = string.Empty; if (installationInfo != null) { if (GPSTypeHelper.IsSupportOil(installationInfo)) { double oliValue = CalculateOilValue.GetOilValue(vehicleInfo, installationInfo, Convert.ToDouble(currentInfo.OilBearing)); return oliValue.ToString("0.00"); } } } catch (Exception ex) { Logger.Error(ex); } return "0"; }
private void UpdateMileage(IList<EVehicleAndMileage> ltEVehicleAndMileage, EGPSCurrentInfo currentInfo, EGPSInstallationInfo installationInfo) { try { if (ltEVehicleAndMileage.Count > 0) { EVehicleAndMileage vehileAndMileage = ltEVehicleAndMileage.SingleOrDefault(s => s.VehicleCode == currentInfo.VehicleCode.Value); if (vehileAndMileage != null) { currentInfo.StarkMileage = currentInfo.StarkMileage - vehileAndMileage.FirstMileage + vehileAndMileage.TotalMileage; } } currentInfo.StarkMileage = CaculateMileage.CalculateTotalMileage(installationInfo, currentInfo.StarkMileage); } catch (Exception ex) { Logger.Error(ex); } }
private VRealTimeInfo CreateVRealTimeInfo(IList<EVehicleAndMileage> ltEVehicleAndMileage, SessionContext sessionContext, EGPSCurrentInfo currentInfo, EGPSInstallationInfo installationInfo, bool isNotCalcOil, IList<VehicleType> ltVehicleType , IList<EDriver> ltDriver, IList<EVehicleRunningState> ltRunningState) { LocationInfo locationInfo = null; Logger.Trace(string.Format("Vehicle:{0},Latidute:{1},Longitude:{2},EncodeLatLon{3}", currentInfo.VehicleCode.ToString(), currentInfo.Latitude, currentInfo.Longitude, currentInfo.EncodeLatLon)); EBaseVehicle vehicleInfo = installationInfo.VehicleInfo; VRealTimeInfo realTimeInfoViewEntity = new VRealTimeInfo(currentInfo, vehicleInfo, locationInfo); SetVehicleType(vehicleInfo, realTimeInfoViewEntity,ltVehicleType); SetDriverInfo(vehicleInfo, realTimeInfoViewEntity,ltDriver); SetOilValue(vehicleInfo, realTimeInfoViewEntity, currentInfo, installationInfo,isNotCalcOil); UpdateMileage(ltEVehicleAndMileage, currentInfo, installationInfo); realTimeInfoViewEntity.AlarmInfo = GetAlarmInfo(currentInfo.VehicleCode.Value, realTimeInfoViewEntity,ltRunningState); return realTimeInfoViewEntity; }
private IList<EVehicleRunningState> GetRunningStates(EGPSInstallationInfo[] arrEGPSInstallationInfo) { try { IList<Guid> ltVehicleCode = new List<Guid>(); foreach (var item in arrEGPSInstallationInfo) { Guid code = item.VehicleInfo.Code; if (!ltVehicleCode.Contains(code)) { ltVehicleCode.Add(code); } } IVehicleRunningStateManager mgr = new VehicleRunningStateManager(); return mgr.Get(ltVehicleCode); } catch (Exception ex) { Logger.Error(ex); return new List<EVehicleRunningState>(); } }
private IList<EDriver> GetDrivers(SessionContext sessionContext,EGPSInstallationInfo[] arrEGPSInstallationInfo) { try { IList<Guid> ltDriverCode = new List<Guid>(); foreach (var item in arrEGPSInstallationInfo) { if (item.VehicleInfo.DefaultDriverCode.HasValue) { Guid code = item.VehicleInfo.DefaultDriverCode.Value; if (!ltDriverCode.Contains(code)) { ltDriverCode.Add(code); } } } PES.Logistics.Service.DriverService service = new PES.Logistics.Service.DriverService(); return service.Get(sessionContext, ltDriverCode); } catch (Exception ex) { Logger.Error(ex); return new List<EDriver>(); } }
/// 新增GPS安装信息 FOR YWL /// </summary> /// <param name="param"></param> /// <returns></returns> public AndroidData<RResult> SaveGPS(PInstallation param) { string GPSGode =string.Empty; string StrErr = string.Empty; string vehicleCode = string.Empty; AndroidData<RResult> data = new AndroidData<RResult>(); RResult rr = new RResult(); if (!param.CheckTicket()) { data.Message = MessageByInvalidTicket; data.ResultCode = ResultCodeEnum.InvalidTicket; } else { try { GPSGode = GetGPSCode(param.PrefixCode, param.GPSType.ToString(), param.SIMNumber, param.DeviceNumber); if (string.IsNullOrEmpty(GPSGode)) { data.Message = "获取GPS编号失败,不能安装"; data.ResultCode = ResultCodeEnum.Fail; return data; } AndroidInstallation install = new AndroidInstallation(); if (param.VehicleCode == null) { vehicleCode = install.InstallationAddVehicle(param.TenantCode, param.LicenseNumber, ref StrErr); if(vehicleCode==""&&string.IsNullOrEmpty(vehicleCode)) { data.Message = StrErr; data.ResultCode = ResultCodeEnum.Fail; return data; } param.VehicleCode = new Guid(vehicleCode); } EGPSInstallationInfo entity = new EGPSInstallationInfo(); DateTime ExportTime = new DateTime(2020, 1, 1, 23, 59, 59);//默认值:启用服务为开,服务到期为2020-1-1 23:59:59 entity.CreateDate = DateTime.Now; entity.CreateUser = param.UserCode; entity.GPSCode = GPSGode; entity.DeviceNumber = param.DeviceNumber; entity.SIMNumber = param.SIMNumber; entity.InstallReason = param.InstallReason; entity.EnableService = true; entity.AbolishReason = (int)EnumAbolishReason.None; entity.GPSType = new EGPSType() { RecordID = param.GPSType }; entity.TenantInfo = new PES.Guanaco.Entity.Tenant.ETenant() { TenantCode = param.TenantCode }; entity.VehicleInfo = new EVehicle() { Code = param.VehicleCode.Value }; install.AddInsatllInfo(entity); install.UpdateVehicleExpireTime(param.TenantCode, param.VehicleCode.Value, ExportTime); rr.IsSuccess = true; rr.Message = "恭喜您,安装成功"; data.ResultData = rr; data.ResultCode = ResultCodeEnum.Success; } catch (Exception ex) { data.ResultCode = ResultCodeEnum.Fail; data.Message = ex.Message; } } return data; }