Example #1
0
        public List<MonitorVehicleEntity> GetWithMonitorVehicleList(string vehicleCodes, EnumMapType mapType)
        {
            if (string.IsNullOrEmpty(vehicleCodes))
            {
                vehicleCodes = "''";
            }
            string cmdText = string.Format(@"SELECT v.VehicleCode, v.LicenceNumber, v.ExpireTime, v.IsStop, v.IconType,
c.Longitude, c.Latitude, c.ACCState, c.Speed, c.ReportTime, c.Direction, vrs.State, vrs.AlarmType
 FROM movo_vehicle v 
      LEFT JOIN gps_currentinfo c ON v.VehicleCode = c.VehicleCode 
      LEFT JOIN gps_vehiclerunningstate vrs ON v.VehicleCode = vrs.VehicleCode 
WHERE v.VehicleCode in({0})", vehicleCodes);

            using (DbDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, cmdText))
            {
                if (sdr != null)
                {
                    List<MonitorVehicleEntity> res = new List<MonitorVehicleEntity>();
                    MonitorVehicleEntity _tmpEntity = null;
                    PES.GPS.MapService.Entity.LatLon _marLatLon = null;
                    while (sdr.Read())
                    {
                        _tmpEntity = new MonitorVehicleEntity
                        {
                            VehicleCode = sdr["VehicleCode"].ToString(),
                            LicenceNumber = sdr["LicenceNumber"].ToString(),
                            ExpireTime = sdr["ExpireTime"].ToDateTimeNull(),
                            IsStop = sdr["IsStop"].ToBoolean(),
                            IconType = (EnumVehicleType)(sdr["IconType"].ToInt()),
                            Lng = sdr["Longitude"].ToDoubleNull(),
                            Lat = sdr["Latitude"].ToDoubleNull(),
                            Acc = sdr["ACCState"].ToInt(),
                            Speed = sdr["Speed"].ToDouble(),
                            ReportTime = sdr["ReportTime"].ToDateTimeNull(),
                            Direction = sdr["Direction"].ToDouble(),
                            IsWarning = false,
                            IsOverdue = false,
                            AlarmType = sdr["AlarmType"].ToIntNull(),
                            OrderByType = 0
                        };
                        if (_tmpEntity.ExpireTime.HasValue && _tmpEntity.ExpireTime.Value.Date < DateTime.Now.Date)
                        {
                            _tmpEntity.IsOverdue = true;
                        }
                        if (_tmpEntity.AlarmType != null)
                        {
                            _tmpEntity.IsWarning = true;
                        }
                        if (_tmpEntity.Lng.HasValue && _tmpEntity.Lat.HasValue)
                        {
                            switch (mapType)
                            {
                                case EnumMapType.GoogleCN:
                                    _marLatLon = gMapSrv.LatLonToMar(new PES.GPS.MapService.Entity.LatLon { Longitude = _tmpEntity.Lng.Value, Latitude = _tmpEntity.Lat.Value });
                                    break;
                                case EnumMapType.BaiduMap:
                                    _marLatLon = bMapSrv.LatLonToMar(new PES.GPS.MapService.Entity.LatLon { Longitude = _tmpEntity.Lng.Value, Latitude = _tmpEntity.Lat.Value });
                                    break;
                            }
                            if (_marLatLon != null)
                            {
                                _tmpEntity.Lng = _marLatLon.Longitude;
                                _tmpEntity.Lat = _marLatLon.Latitude;
                            }
                        }
                        res.Add(_tmpEntity);
                        _marLatLon = null;
                    }
                    sdr.Close();
                    return res;
                }
            }
            return null;
        }
Example #2
0
        public List<MonitorVehicleEntity> GetMonitorVehicleList(string userCode, string tenantCode, EnumMapType mapType, string vehGroupID)
        {
            string cmdText = string.Format(@"SELECT v.VehicleCode, v.LicenceNumber, v.ExpireTime, v.IsStop, v.IconType,
c.Longitude, c.Latitude, c.ACCState, c.Speed, c.ReportTime, c.Direction, vrs.State, vrs.AlarmType 
 FROM movo_vehicle v 
      LEFT JOIN gps_currentinfo c ON v.VehicleCode = c.VehicleCode 
      LEFT JOIN gps_vehiclerunningstate vrs ON v.VehicleCode = vrs.VehicleCode 
WHERE v.TenantCode='{0}'{1}", tenantCode, (string.IsNullOrEmpty(vehGroupID) ? "" : " and v.GroupID=" + vehGroupID));

            List<MonitorVehicleEntity> res = null;
            try
            {
                using (MySqlDataReader sdr = MySqlDB.GetDataReader(CommandType.Text, cmdText))
                {
                    if (sdr != null)
                    {
                        res = new List<MonitorVehicleEntity>();
                        MonitorVehicleEntity _tmpEntity = null;
                        while (sdr.Read())
                        {
                            _tmpEntity = new MonitorVehicleEntity();

                            _tmpEntity.VehicleCode = sdr.GetStringExt(0);
                            _tmpEntity.LicenceNumber = sdr.GetStringExt(1);
                            _tmpEntity.ExpireTime = sdr.GetDateTimeNull(2);
                            _tmpEntity.IsStop = sdr.GetInt16(3) == 1;
                            _tmpEntity.IconType = (EnumVehicleType)(sdr.GetInt16(4));
                            _tmpEntity.Lng = sdr.GetDoubleNull(5);
                            _tmpEntity.Lat = sdr.GetDoubleNull(6);
                            _tmpEntity.Acc = sdr.GetInt(7);
                            _tmpEntity.Speed = sdr.GetDoubleExt(8);
                            _tmpEntity.ReportTime = sdr.GetDateTimeNull(9);
                            _tmpEntity.Direction = sdr.GetDoubleExt(10);
                            _tmpEntity.IsWarning = false;
                            _tmpEntity.IsOverdue = false;
                            _tmpEntity.AlarmType = sdr.GetIntNull(12);
                            _tmpEntity.OrderByType = 0;

                            if (_tmpEntity.ExpireTime.HasValue && _tmpEntity.ExpireTime.Value.Date < DateTime.Now.Date)
                            {
                                _tmpEntity.IsOverdue = true;
                            }
                            if (_tmpEntity.AlarmType != null)
                            {
                                _tmpEntity.IsWarning = true;
                            }
                            res.Add(_tmpEntity);
                        }
                        sdr.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Info(ex.StackTrace + ",连接字符串:" + MySqlDB.ConnString);
                throw;
            }
            return res;
        }