Esempio n. 1
0
        public IList<VVehicleSearchResult> VehicleSearch(string maxEncodeLatLon, string minEncodeLatLon, string tenantCode, string userCode,
            string permissionCode,int rowIndex,int pageSize,ref int rowCount)
        {
            PES.MapService.MapSearchService.MapService mapService = new PES.MapService.MapSearchService.MapService();

            LatLon maxLatLon = mapService.Decode(maxEncodeLatLon);
            LatLon minLatLon = mapService.Decode(minEncodeLatLon);

            IVehicleManager vm = new VehicleManager();

            IList<EBaseVehicle> ltVehicle = vm.Get(tenantCode, userCode, permissionCode);

            Rectangle rec = new Rectangle(maxLatLon.Latitude, maxLatLon.Longitude, minLatLon.Latitude, minLatLon.Longitude);

            IGPSTrackManager trackManager = new GPSTrackManager();

            IList<EGPSCurrentInfo> ltCurrentInfo = trackManager.SearchVehicleInRectange(rec, ltVehicle.Select(s => s.Code).ToArray(), rowIndex, pageSize,ref rowCount);

            Dictionary<Guid, string> dcVehicle = ltVehicle.ToDictionary(new Func<EBaseVehicle, Guid>(c => c.Code),
                    new Func<EBaseVehicle, string>(c => c.LicenceNumber));

            IList<VVehicleSearchResult> ltResult = new List<VVehicleSearchResult>();

            if (ltCurrentInfo == null)
                return ltResult;
            foreach (EGPSCurrentInfo currentInfo in ltCurrentInfo)
            {
                string licenceNumber = dcVehicle[currentInfo.VehicleCode.Value];

                VVehicleSearchResult result = new VVehicleSearchResult(currentInfo.VehicleCode.Value, licenceNumber, currentInfo.GPSCode, currentInfo.ReportTime.ToString(),currentInfo.Latitude,currentInfo.Longitude);

                ltResult.Add(result);
            }
            SetEncodeLatLon(mapService, ltResult);

            return ltResult;
        }
Esempio n. 2
0
        public IList<VRealTimeInfo> GetVehicleRealTimeInfo(string username, string password, string[] arrLicenceNumber)
        {

            Logger.Error(string.Format("{0},{1}", username, password));

            ////password = EncodeStr.EncodePassword(password);
            ////EUser user = null;
            ////try
            ////{
            ////    user = SSOProxy.LogonUser(username, password, PES.Guanaco.Entity.EnumLoginType.UserName, "127.0.0.1");

            ////    if (user == null || user.TenantList.Count == 0)
            ////    {
            ////        throw new Exception("User name or password error!");
            ////    }
            ////}
            ////catch (Exception ex)
            ////{
            ////    Logger.Error(ex);
            ////    throw new Exception("User name or password error!");
            ////}
            try
            {
                UserEntity user = GuanacoServiceFacade.Tenant.GetUser(username, EncodeStr.EncodePassword(password), EnumLoginType.UserName);
                if (user == null || GuanacoServiceFacade.Tenant.GetUserTenants(user.UserCode).Count == 0)
                {
                    throw new Exception("User name or password error!");
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new Exception("User name or password error!");
            }

            IVehicleManager vm = new VehicleManager();

            IList<VRealTimeInfo> ltCurrentInfo = new List<VRealTimeInfo>();

            IList<LatLon> ltLatLon = new List<LatLon>();

            foreach (string licenceNumber in arrLicenceNumber)
            {
                Guid vehicleCode = vm.GetVehicleCodeByLicenceNumber(licenceNumber);

                IGPSTrackManager trackManager = new GPSTrackManager();

                EGPSCurrentInfo currentInfo;

                try
                {
                    currentInfo = trackManager.GetCurrentInfo(vehicleCode);

                    ltLatLon.Add(new LatLon(currentInfo.Latitude, currentInfo.Longitude));

                    VRealTimeInfo realtimeInfo = new VRealTimeInfo();

                    realtimeInfo.CurrentGPSInfo = currentInfo;

                    EBaseVehicle vehicle = new EVehicle();

                    vehicle.LicenceNumber = licenceNumber;

                    realtimeInfo.VehicleInfo = vehicle;

                    ltCurrentInfo.Add(realtimeInfo);
                }
                catch (GPSCurrentInfoNullException ex)
                {
                    Logger.Error(ex);
                    throw ex;
                }
            }

            IMapService mapService = new PES.MapService.MapSearchService.MapService();

            IList<LocationInfo> ltLocationInfo = mapService.InverseGeocoding(ltLatLon.ToArray());

            for (int i = 0; i < ltCurrentInfo.Count; i++)
            {
                ltCurrentInfo[i].LocationInfo = ltLocationInfo[i];
            }

            return ltCurrentInfo;
        }
Esempio n. 3
0
        /// <summary>
        /// 带分页根据租户编码获取车辆列表
        /// </summary>
        /// <param name="tenantCode">租户编码</param>
        /// <param name="rows">当前页码</param>
        /// <param name="pageSize">每页显示条数</param>
        /// <param name="rowCount">总条数</param>
        /// <returns></returns>
        public List<VehicleManager> GetCarList(string tenantCode, string LicenceNumber, string SIMNo, string DeviceNo, int rows, int pageSize, out int rowCount)
        {
            rowCount = 0;
            List<VehicleManager> list = new List<VehicleManager>();
            if (string.IsNullOrEmpty(tenantCode))
                return list;

            string sqlWhere = string.Empty;
            if (!string.IsNullOrEmpty(LicenceNumber))
            {
                sqlWhere += string.Format(" and vehicle.LicenceNumber like '%{0}%' ", LicenceNumber);
            }
            if (!string.IsNullOrEmpty(SIMNo))
            {
                sqlWhere += string.Format(" and vehicle.SIMNo like '%{0}%' ", SIMNo);
            }
            if (!string.IsNullOrEmpty(DeviceNo))
            {
                sqlWhere += string.Format(" and vehicle.DeviceNo like '%{0}%' ", DeviceNo);
            }

            string sql = string.Format("SELECT COUNT(1) FROM movo_vehicle vehicle WHERE vehicle.Tenantcode={0}{1}", tenantCode, sqlWhere);
            rowCount = MySqlDB.ExecuteScalar(sql, CommandType.Text).ToInt();
            if (rowCount < 1)
            {
                return list;
            }

            string cmdText = string.Format(@"SELECT gpsstate.State,gpscur.Reporttime,vehicle.isStop,gpscur.Speed,gpscur.ACCState,gpscur.Direction,gpscur.Latitude,gpscur.Longitude,gpscur.GPSCode,gpscur.ReportTime,
vehicle.CreateTime,vehicle.DeviceNo,vehicle.ExpireTime,vehicle.GPSCode,vehicle.GPSTypeID,vehicle.GPSTypeName,vehicle.GroupID,vehicle.IconType,vehicle.InitMileage,vehicle.InstallTime,vehicle.IsStop,vehicle.LicenceNumber,
vehicle.SIMNo,vehicle.TenantCode,vehicle.VehicleCode,tenant.email,tenant.PhoneNumber, tenant.RegisterUserName,tenant.TenantName 
 FROM movo_vehicle vehicle
      LEFT JOIN movo_tenant tenant ON tenant.tenantcode=vehicle.tenantcode 
      LEFT JOIN gps_currentinfo gpscur ON gpscur.VehicleCode=vehicle.VehicleCode 
      LEFT JOIN gps_vehiclerunningstate gpsstate ON gpsstate.VehicleCode=vehicle.VehicleCode 
WHERE vehicle.Tenantcode={0}{1} ORDER BY InstallTime desc LIMIT {2},{3}", tenantCode, sqlWhere, rows, pageSize);

            using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, cmdText))
            {
                if (sdr != null)
                {
                    VehicleManager vm = null;
                    while (sdr.Read())
                    {
                        vm = new VehicleManager();

                        vm.CreateTime = sdr["CreateTime"].ToDateTime();
                        vm.DeviceNo = sdr["DeviceNo"].ToString();
                        vm.IsStop = sdr["isStop"].ToString() == "1";
                        vm.Email = sdr["email"].ToString();
                        vm.ExpireTime = sdr["ExpireTime"].ToDateTimeNull();
                        vm.GPSCode = sdr["GPSCode"].ToString();
                        vm.GPSTypeID = sdr["GPSTypeID"].ToULong();
                        vm.GPSTypeName = sdr["GPSTypeName"].ToString();
                        vm.GroupID = sdr["GroupID"].ToULong();
                        vm.IconType = (EnumVehicleType)sdr["IconType"].ToInt();
                        vm.InitMileage = sdr["InitMileage"].ToDecimal();
                        vm.InstallTime = sdr["InstallTime"].ToDateTime();
                        vm.LicenceNumber = sdr["LicenceNumber"].ToString();
                        vm.NowTime = System.DateTime.Now;
                        vm.PhoneNumber = sdr["PhoneNumber"].ToString();
                        vm.RegisterUserName = sdr["RegisterUserName"].ToString();
                        vm.SIMNo = sdr["SIMNo"].ToString();
                        vm.TenantCode = sdr["TenantCode"].ToString();
                        vm.TenantName = sdr["TenantName"].ToString();
                        vm.VehicleCode = sdr["VehicleCode"].ToGuid();
                        vm.DeviceState = string.Empty;
                        vm.Remarkably = string.Empty;
                        if (vm.ExpireTime.HasValue && vm.ExpireTime.Value < DateTime.Now)
                        {
                            vm.Remarkably = "已过期";
                            vm.DeviceState = "已过期";
                        }
                        else
                        {
                            if (vm.IsStop)
                            {
                                vm.Remarkably = "已停用";
                                vm.DeviceState = "已停用";
                            }
                            else
                            {
                                DateTime? sreportTime = sdr["Reporttime"].ToDateTimeNull();
                                bool isWarning = sdr["State"].ToString() == "1"; //state=1表示报警
                                double sspeed = sdr["Speed"].ToDouble();
                                vm.DeviceState = GetVehicleStateStr(sreportTime, isWarning, sspeed);
                                if (vm.DeviceState == "离线")
                                {
                                    vm.Remarkably = "离线";
                                }
                            }
                        }
                        list.Add(vm);
                    }
                    sdr.Close();
                }
            }

            return list;
        }