CREATE DATABASE  IF NOT EXISTS `leus` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `leus`;
--
-- Host: localhost    Database: leus
-- ------------------------------------------------------


--
-- Table structure for table `agro_params`
--

CREATE TABLE `agro_params` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Number` int(11) NOT NULL COMMENT 'Номер параметра',
  `Value` varchar(100) DEFAULT NULL COMMENT 'Значение',
  `Description` varchar(50) DEFAULT NULL COMMENT 'Описание',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Таблица параметров';

--
-- Dumping data for table `agro_params`
--


--
-- Table structure for table `commands`
--

CREATE TABLE `commands` (
  `ID` int(11) DEFAULT '0',
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `commands`
--

INSERT INTO `commands` VALUES (10,'DRIVER_MESSAGE_SET_D',NULL),(11,'CONFIG_SMS_SET_D',NULL),(12,'CONFIG_TEL_SET_D',NULL),(13,'CONFIG_EVENT_SET_D',NULL),(14,'CONFIG_UNIQUE_SET_D',NULL),(15,'CONFIG_ZONE_SET_D',NULL),(17,'CONFIG_ID_SET_D',NULL),(18,'CONFIG_OTHER_SET_D',NULL),(20,'DRIVER_MESSAGE_SET_M',NULL),(21,'CONFIG_SMS_SET_M',NULL),(22,'CONFIG_TEL_SET_M',NULL),(23,'CONFIG_EVENT_SET_M',NULL),(24,'CONFIG_UNIQUE_SET_M',NULL),(25,'CONFIG_ZONE_SET_M',NULL),(27,'CONFIG_ID_SET_M',NULL),(28,'CONFIG_OTHER_SET_M',NULL),(31,'CONFIG_SMS_GET_D',NULL),(32,'CONFIG_TEL_GET_D',NULL),(33,'CONFIG_EVENT_GET_D',NULL),(34,'CONFIG_UNIQUE_GET_D',NULL),(35,'CONFIG_ZONE_GET_D',NULL),(36,'DATA_GPS_GET_D',NULL),(37,'CONFIG_ID_GET_D',NULL),(38,'CONFIG_OTHER_GET_D',NULL),(41,'CONFIG_SMS_GET_M',NULL),(42,'CONFIG_TEL_GET_M',NULL),(43,'CONFIG_EVENT_GET_M',NULL),(44,'CONFIG_UNIQUE_GET_M',NULL),(45,'CONFIG_ZONE_GET_M',NULL),(46,'DATA_GPS_GET_M',NULL),(47,'CONFIG_ID_GET_M',NULL),(48,'CONFIG_OTHER_GET_M',NULL),(49,'AUTO_SEND_GET_M',NULL),(99,'ERROR_COMMAND','Невозможно раскодировать входящее сообщение'),(102,'MOBITEL_SERVICE_SEND',NULL),(103,'INTERNAL_1',NULL),(104,'INTERNAL_2',NULL),(105,'INTERNAL_3',NULL),(50,'CONFIG_GPRS_MAIN_SET_D',NULL),(51,'CONFIG_GPRS_EMAIL_SET_D',NULL),(52,'CONFIG_GPRS_SOCKET_SET_D',NULL),(53,'CONFIG_GPRS_FTP_SET_D',NULL),(60,'CONFIG_GPRS_MAIN_SET_M',NULL),(61,'CONFIG_GPRS_EMAIL_SET_M',NULL),(62,'CONFIG_GPRS_SOCKET_SET_M',NULL),(63,'CONFIG_GPRS_FTP_SET_M',NULL),(70,'CONFIG_GPRS_MAIN_GET_D',NULL),(71,'CONFIG_GPRS_EMAIL_GET_D',NULL),(72,'CONFIG_GPRS_SOCKET_GET_D',NULL),(73,'CONFIG_GPRS_FTP_GET_D',NULL),(80,'CONFIG_GPRS_MAIN_GET_M',NULL),(81,'CONFIG_GPRS_EMAIL_GET_M',NULL),(82,'CONFIG_GPRS_SOCKET_GET_M',NULL),(83,'CONFIG_GPRS_FTP_GET_M',NULL),(54,'CONFIG_GPRS_INIT_SET_D',NULL),(64,'CONFIG_GPRS_INIT_SET_M',NULL),(74,'CONFIG_GPRS_INIT_GET_D',NULL),(84,'CONFIG_GPRS_INIT_GET_M',NULL);

--
-- Table structure for table `configdrivermessage`
--

CREATE TABLE `configdrivermessage` (
  `ConfigDriverMessage_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `DriverMessage` char(200) DEFAULT NULL,
  PRIMARY KEY (`ConfigDriverMessage_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configdrivermessage`
--


--
-- Table structure for table `configevent`
--

CREATE TABLE `configevent` (
  `ConfigEvent_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `tmr1Log` int(11) DEFAULT '0',
  `tmr2Send` int(11) DEFAULT '0',
  `tmr3Zone` int(11) DEFAULT '0',
  `dist1Log` int(11) DEFAULT '0',
  `dist2Send` int(11) DEFAULT '0',
  `dist3Zone` int(11) DEFAULT '0',
  `deltaTimeZone` int(11) DEFAULT '0',
  `gprsEmail` int(11) NOT NULL DEFAULT '0',
  `gprsFtp` int(11) NOT NULL DEFAULT '0',
  `gprsSocket` int(11) NOT NULL DEFAULT '0',
  `maskSensor` char(50) DEFAULT NULL,
  `maskEvent1` int(11) DEFAULT '0',
  `maskEvent2` int(11) DEFAULT '0',
  `maskEvent3` int(11) DEFAULT '0',
  `maskEvent4` int(11) DEFAULT '0',
  `maskEvent5` int(11) DEFAULT '0',
  `maskEvent6` int(11) DEFAULT '0',
  `maskEvent7` int(11) DEFAULT '0',
  `maskEvent8` int(11) DEFAULT '0',
  `maskEvent9` int(11) DEFAULT '0',
  `maskEvent10` int(11) DEFAULT '0',
  `maskEvent11` int(11) DEFAULT '0',
  `maskEvent12` int(11) DEFAULT '0',
  `maskEvent13` int(11) DEFAULT '0',
  `maskEvent14` int(11) DEFAULT '0',
  `maskEvent15` int(11) DEFAULT '0',
  `maskEvent16` int(11) DEFAULT '0',
  `maskEvent17` int(11) DEFAULT '0',
  `maskEvent18` int(11) DEFAULT '0',
  `maskEvent19` int(11) DEFAULT '0',
  `maskEvent20` int(11) DEFAULT '0',
  `maskEvent21` int(11) DEFAULT '0',
  `maskEvent22` int(11) DEFAULT '0',
  `maskEvent23` int(11) DEFAULT '0',
  `maskEvent24` int(11) DEFAULT '0',
  `maskEvent25` int(11) DEFAULT '0',
  `maskEvent26` int(11) DEFAULT '0',
  `maskEvent27` int(11) DEFAULT '0',
  `maskEvent28` int(11) DEFAULT '0',
  `maskEvent29` int(11) DEFAULT '0',
  `maskEvent30` int(11) DEFAULT '0',
  `maskEvent31` int(11) DEFAULT '0',
  PRIMARY KEY (`ConfigEvent_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configevent`
--

INSERT INTO `configevent` VALUES (1,'','',1,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(2,'','',2,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(3,'','',3,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(4,'','',4,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(5,'','',5,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

--
-- Table structure for table `configgprsemail`
--

CREATE TABLE `configgprsemail` (
  `ConfigGprsEmail_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Smtpserv` varchar(50) NOT NULL DEFAULT '',
  `Smtpun` varchar(50) NOT NULL DEFAULT '',
  `Smtppw` varchar(50) NOT NULL DEFAULT '',
  `Pop3serv` varchar(50) NOT NULL DEFAULT '',
  `Pop3un` varchar(50) NOT NULL DEFAULT '',
  `Pop3pw` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`ConfigGprsEmail_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configgprsemail`
--

INSERT INTO `configgprsemail` VALUES (1,'','',1,0,0,'','','','','',''),(2,'','',2,0,0,'','','','','',''),(3,'','',3,0,0,'','','','','',''),(4,'','',4,0,0,'','','','','',''),(5,'','',5,0,0,'','','','','','');

--
-- Table structure for table `configgprsinit`
--

CREATE TABLE `configgprsinit` (
  `ConfigGprsInit_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Domain` varchar(50) NOT NULL DEFAULT '0',
  `InitString` varchar(200) NOT NULL DEFAULT '',
  PRIMARY KEY (`ConfigGprsInit_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configgprsinit`
--


--
-- Table structure for table `configgprsmain`
--

CREATE TABLE `configgprsmain` (
  `ConfigGprsMain_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Mode` int(11) NOT NULL DEFAULT '0',
  `Apnserv` varchar(50) NOT NULL DEFAULT '',
  `Apnun` varchar(50) NOT NULL DEFAULT '',
  `Apnpw` varchar(50) NOT NULL DEFAULT '',
  `Dnsserv1` varchar(50) NOT NULL DEFAULT '',
  `Dialn1` varchar(50) NOT NULL DEFAULT '',
  `Ispun` varchar(50) NOT NULL DEFAULT '',
  `Isppw` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`ConfigGprsMain_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configgprsmain`
--

INSERT INTO `configgprsmain` VALUES (1,'','',1,0,0,0,'','','','','','',''),(2,'','',2,0,0,0,'','','','','','',''),(3,'','',3,0,0,0,'','','','','','',''),(4,'','',4,0,0,0,'','','','','','',''),(5,'','',5,0,0,0,'','','','','','','');

--
-- Table structure for table `configmain`
--

CREATE TABLE `configmain` (
  `ConfigMain_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `ConfigOther_ID` int(11) DEFAULT '0',
  `ConfigDriverMessage_ID` int(11) DEFAULT '0',
  `ConfigEvent_ID` int(11) DEFAULT '0',
  `ConfigUnique_ID` int(11) DEFAULT '0',
  `ConfigZoneSet_ID` int(11) DEFAULT '0',
  `ConfigSensorSet_ID` int(11) DEFAULT '0',
  `ConfigTel_ID` int(11) DEFAULT '0',
  `ConfigSms_ID` int(11) DEFAULT '0',
  `Mobitel_ID` int(11) DEFAULT '0',
  `ConfigGprsMain_ID` int(11) NOT NULL DEFAULT '0',
  `ConfigGprsEmail_ID` int(11) NOT NULL DEFAULT '0',
  `ConfigGprsInit_ID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ConfigMain_ID`),
  KEY `Index_2` (`Mobitel_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configmain`
--

INSERT INTO `configmain` VALUES (1,'','',0,0,50,50,1,50,50,50,1,1,942814777,1,1,50),(2,'','',0,0,50,50,2,50,50,50,2,2,809055537,2,2,50),(3,'','',0,0,50,50,3,50,50,50,3,3,842283059,3,3,50),(4,'','',0,0,50,50,4,50,50,50,4,4,909522486,4,4,50),(5,'','',0,0,50,50,5,50,50,50,5,5,942879286,5,5,50);

--
-- Table structure for table `configother`
--

CREATE TABLE `configother` (
  `ConfigOther_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Pin` int(11) DEFAULT '0',
  `Lang` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`ConfigOther_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configother`
--


--
-- Table structure for table `configsensorset`
--

CREATE TABLE `configsensorset` (
  `ConfigSensorSet_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`ConfigSensorSet_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configsensorset`
--


--
-- Table structure for table `configsms`
--

CREATE TABLE `configsms` (
  `ConfigSms_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `smsCenter_ID` int(11) DEFAULT '0',
  `smsDspt_ID` int(11) DEFAULT '0',
  `smsEmailGate_ID` int(11) DEFAULT '0',
  `dsptEmail` char(14) DEFAULT NULL,
  `dsptGprsEmail` char(50) DEFAULT NULL,
  PRIMARY KEY (`ConfigSms_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configsms`
--

INSERT INTO `configsms` VALUES (1,'','',1,0,0,0,0,0,NULL,NULL),(2,'','',2,0,0,0,0,0,NULL,NULL),(3,'','',3,0,0,0,0,0,NULL,NULL),(4,'','',4,0,0,0,0,0,NULL,NULL),(5,'','',5,0,0,0,0,0,NULL,NULL);

--
-- Table structure for table `configtel`
--

CREATE TABLE `configtel` (
  `ConfigTel_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `telSOS` int(11) DEFAULT '0',
  `telDspt` int(11) DEFAULT '0',
  `telAccept1` int(11) DEFAULT '0',
  `telAccept2` int(11) DEFAULT '0',
  `telAccept3` int(11) DEFAULT '0',
  `telAnswer` int(11) DEFAULT '0',
  PRIMARY KEY (`ConfigTel_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configtel`
--

INSERT INTO `configtel` VALUES (1,'','',1,0,0,0,0,0,0,0,0),(2,'','',2,0,0,0,0,0,0,0,0),(3,'','',3,0,0,0,0,0,0,0,0),(4,'','',4,0,0,0,0,0,0,0,0),(5,'','',5,0,0,0,0,0,0,0,0);

--
-- Table structure for table `configunique`
--

CREATE TABLE `configunique` (
  `ConfigUnique_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `pswd` char(8) DEFAULT NULL,
  `tmpPswd` char(8) DEFAULT NULL,
  `dsptId` char(4) DEFAULT NULL,
  PRIMARY KEY (`ConfigUnique_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configunique`
--


--
-- Table structure for table `configzoneset`
--

CREATE TABLE `configzoneset` (
  `ConfigZoneSet_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`ConfigZoneSet_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `configzoneset`
--


--
-- Table structure for table `data_zones`
--

CREATE TABLE `data_zones` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `DataGps_ID` int(11) DEFAULT NULL,
  `Zone_ID` int(11) DEFAULT NULL,
  `Zone_IO` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `data_zones`
--


--
-- Table structure for table `datagps`
--

CREATE TABLE `datagps` (
  `DataGps_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Latitude` int(11) DEFAULT '0',
  `Longitude` int(11) DEFAULT '0',
  `Altitude` int(11) DEFAULT NULL,
  `UnixTime` int(11) DEFAULT '0',
  `Speed` smallint(6) DEFAULT '0',
  `Direction` int(11) NOT NULL DEFAULT '0',
  `Valid` tinyint(4) DEFAULT '1',
  `InMobitelID` int(11) DEFAULT NULL,
  `Events` int(10) unsigned DEFAULT '0',
  `Sensor1` tinyint(4) unsigned DEFAULT '0',
  `Sensor2` tinyint(4) unsigned DEFAULT '0',
  `Sensor3` tinyint(4) unsigned DEFAULT '0',
  `Sensor4` tinyint(4) unsigned DEFAULT '0',
  `Sensor5` tinyint(4) unsigned DEFAULT '0',
  `Sensor6` tinyint(4) unsigned DEFAULT '0',
  `Sensor7` tinyint(4) unsigned DEFAULT '0',
  `Sensor8` tinyint(4) unsigned DEFAULT '0',
  `LogID` int(11) DEFAULT '0',
  `isShow` tinyint(4) DEFAULT '0',
  `whatIs` smallint(6) unsigned DEFAULT '0',
  `Counter1` int(11) NOT NULL DEFAULT '-1',
  `Counter2` int(11) NOT NULL DEFAULT '-1',
  `Counter3` int(11) NOT NULL DEFAULT '-1',
  `Counter4` int(11) NOT NULL DEFAULT '-1',
  `SrvPacketID` bigint(20) NOT NULL DEFAULT '0' COMMENT 'ID серверного пакета в состав которого входит эта запись',
  PRIMARY KEY (`DataGps_ID`),
  UNIQUE KEY `BMC_MobitelID_LogID_UnixTime_UNIQUE` (`Mobitel_ID`,`LogID`,`UnixTime`),
  KEY `Index_3` (`Mobitel_ID`,`UnixTime`,`Valid`),
  KEY `IDX_MobitelIDSrvPacketID` (`Mobitel_ID`,`SrvPacketID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `datagps`
--


--
-- Table structure for table `datagps64`
--

CREATE TABLE `datagps64` (
  `DataGps_ID` bigint(20) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РўРµР»РµС‚СЂРµРєР°',
  `Latitude` int(11) NOT NULL DEFAULT '0' COMMENT 'РЁРёСЂРѕС‚Р°',
  `Longitude` int(11) NOT NULL DEFAULT '0' COMMENT 'Р”РѕР»РіРѕС‚Р°',
  `Direction` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РіСЂР°РґСѓСЃС‹/1.5',
  `Acceleration` int(11) NOT NULL DEFAULT '0' COMMENT 'РР·РјРµРЅРµРЅРёРµ СЃРєРѕСЂРѕСЃС‚Рё РїРѕ GPS Р·Р° РїРѕСЃР»РµРґРЅСЋСЋ СЃРµРєСѓРЅРґСѓ',
  `UnixTime` int(11) NOT NULL DEFAULT '0',
  `Speed` smallint(6) NOT NULL DEFAULT '0' COMMENT 'РЎРѕС‚РµРЅ РјРµС‚СЂРѕРІ РІ С‡Р°СЃ (0,1 РєРј/С‡)',
  `Valid` tinyint(1) NOT NULL DEFAULT '1',
  `Satellites` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РљРѕР»РёС‡РµСЃС‚РІРѕ СЃРїСѓС‚РЅРёРєРѕРІ ',
  `RssiGsm` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РЈСЂРѕРІРµРЅСЊ GSM СЃРёРіРЅР°Р»Р°',
  `Events` int(11) NOT NULL DEFAULT '0' COMMENT 'Р¤Р»Р°РіРё СЃРѕР±С‹С‚РёР№',
  `SensorsSet` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РЅР°Р±РѕСЂР° РґР°С‚С‡РёРєРѕРІ',
  `Sensors` varbinary(50) NOT NULL DEFAULT '0' COMMENT 'Р—РЅР°С‡РµРЅРёСЏ РґР°С‚С‡РёРєРѕРІ',
  `Voltage` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'РќР°РїСЂСЏР¶РµРЅРёРµ РїРёС‚Р°РЅРёСЏ С‚РµРєСѓС‰РµРіРѕ РёСЃС‚РѕС‡РЅРёРєР°/1.5 РѕС‚ 0 РґРѕ 38,2',
  `DGPS` varchar(32) DEFAULT NULL,
  `LogID` int(11) NOT NULL DEFAULT '0' COMMENT 'РРґРµРЅС‚РёС„РёРєР°С‚РѕСЂ Р·Р°РїРёСЃРё РІ Р¶СѓСЂРЅР°Р»Рµ РўРµР»РµС‚СЂРµРєР°',
  `SrvPacketID` bigint(20) NOT NULL DEFAULT '0' COMMENT 'ID СЃРµСЂРІРµСЂРЅРѕРіРѕ РїР°РєРµС‚Р° РІ СЃРѕСЃС‚Р°РІ РєРѕС‚РѕСЂРѕРіРѕ РІС…РѕРґРёС‚ СЌС‚Р° Р·Р°РїРёСЃСЊ',
  PRIMARY KEY (`DataGps_ID`),
  UNIQUE KEY `BMC_MobitelID_LogID_UnixTime_UNIQUE` (`Mobitel_ID`,`LogID`,`UnixTime`),
  KEY `IDX_MobitelIDSrvPacketID64` (`Mobitel_ID`,`SrvPacketID`),
  KEY `Index_3_64` (`Mobitel_ID`,`UnixTime`,`Valid`),
  CONSTRAINT `FK_datagps64_mobitels_Mobitel_ID` FOREIGN KEY (`Mobitel_ID`) REFERENCES `mobitels` (`Mobitel_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `datagps64`
--


--
-- Table structure for table `datagpsbuffer`
--

CREATE TABLE `datagpsbuffer` (
  `DataGps_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Latitude` int(11) DEFAULT '0',
  `Longitude` int(11) DEFAULT '0',
  `Altitude` int(11) DEFAULT NULL,
  `UnixTime` int(11) DEFAULT '0',
  `Speed` smallint(6) DEFAULT '0',
  `Direction` int(11) NOT NULL DEFAULT '0',
  `Valid` tinyint(4) DEFAULT '1',
  `InMobitelID` int(11) DEFAULT NULL,
  `Events` int(10) unsigned DEFAULT '0',
  `Sensor1` tinyint(4) unsigned DEFAULT '0',
  `Sensor2` tinyint(4) unsigned DEFAULT '0',
  `Sensor3` tinyint(4) unsigned DEFAULT '0',
  `Sensor4` tinyint(4) unsigned DEFAULT '0',
  `Sensor5` tinyint(4) unsigned DEFAULT '0',
  `Sensor6` tinyint(4) unsigned DEFAULT '0',
  `Sensor7` tinyint(4) unsigned DEFAULT '0',
  `Sensor8` tinyint(4) unsigned DEFAULT '0',
  `LogID` int(11) DEFAULT '0',
  `isShow` tinyint(4) DEFAULT '0',
  `whatIs` smallint(6) DEFAULT '0',
  `Counter1` int(11) NOT NULL DEFAULT '-1',
  `Counter2` int(11) NOT NULL DEFAULT '-1',
  `Counter3` int(11) NOT NULL DEFAULT '-1',
  `Counter4` int(11) NOT NULL DEFAULT '-1',
  PRIMARY KEY (`DataGps_ID`),
  KEY `IDX_MobitelIDLogID` (`Mobitel_ID`,`LogID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `datagpsbuffer`
--


--
-- Table structure for table `datagpsbuffer_dr`
--

CREATE TABLE `datagpsbuffer_dr` (
  `Mobitel_ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Latitude` int(11) NOT NULL DEFAULT '0',
  `Longitude` int(11) NOT NULL DEFAULT '0',
  `Altitude` int(11) DEFAULT '0',
  `UnixTime` int(11) NOT NULL DEFAULT '0',
  `Speed` smallint(6) NOT NULL DEFAULT '0',
  `Direction` int(11) NOT NULL DEFAULT '0',
  `Valid` tinyint(4) NOT NULL DEFAULT '1',
  `InMobitelID` int(11) DEFAULT '0',
  `Events` int(10) unsigned DEFAULT '0',
  `Sensor1` tinyint(4) unsigned DEFAULT '0',
  `Sensor2` tinyint(4) unsigned DEFAULT '0',
  `Sensor3` tinyint(4) unsigned DEFAULT '0',
  `Sensor4` tinyint(4) unsigned DEFAULT '0',
  `Sensor5` tinyint(4) unsigned DEFAULT '0',
  `Sensor6` tinyint(4) unsigned DEFAULT '0',
  `Sensor7` tinyint(4) unsigned DEFAULT '0',
  `Sensor8` tinyint(4) unsigned DEFAULT '0',
  `LogID` int(11) DEFAULT '0',
  `isShow` tinyint(4) DEFAULT '0',
  `whatIs` smallint(6) unsigned NOT NULL DEFAULT '0',
  `Counter1` int(11) NOT NULL DEFAULT '-1',
  `Counter2` int(11) NOT NULL DEFAULT '-1',
  `Counter3` int(11) NOT NULL DEFAULT '-1',
  `Counter4` int(11) NOT NULL DEFAULT '-1',
  KEY `IDX_MobitelIDLogID` (`Mobitel_ID`,`LogID`) USING BTREE,
  KEY `IDX_MobitelidUnixtime` (`Mobitel_ID`,`UnixTime`) USING BTREE,
  KEY `IDX_MobitelidUnixtimeValid` (`Mobitel_ID`,`UnixTime`,`Valid`) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=cp1251 COMMENT='Буфер приема данных поступающих по socket-ам от телетреков';

--
-- Dumping data for table `datagpsbuffer_dr`
--


--
-- Table structure for table `datagpsbuffer_on`
--

CREATE TABLE `datagpsbuffer_on` (
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Latitude` int(11) NOT NULL DEFAULT '0',
  `Longitude` int(11) NOT NULL DEFAULT '0',
  `Altitude` int(11) DEFAULT NULL,
  `UnixTime` int(11) NOT NULL DEFAULT '0',
  `Speed` smallint(6) NOT NULL DEFAULT '0',
  `Direction` int(11) NOT NULL DEFAULT '0',
  `Valid` tinyint(4) NOT NULL DEFAULT '1',
  `InMobitelID` int(11) DEFAULT NULL,
  `Events` int(10) unsigned DEFAULT '0',
  `Sensor1` tinyint(4) unsigned DEFAULT '0',
  `Sensor2` tinyint(4) unsigned DEFAULT '0',
  `Sensor3` tinyint(4) unsigned DEFAULT '0',
  `Sensor4` tinyint(4) unsigned DEFAULT '0',
  `Sensor5` tinyint(4) unsigned DEFAULT '0',
  `Sensor6` tinyint(4) unsigned DEFAULT '0',
  `Sensor7` tinyint(4) unsigned DEFAULT '0',
  `Sensor8` tinyint(4) unsigned DEFAULT '0',
  `LogID` int(11) NOT NULL DEFAULT '0',
  `isShow` tinyint(4) DEFAULT '0',
  `whatIs` smallint(6) NOT NULL DEFAULT '0',
  `Counter1` int(11) NOT NULL DEFAULT '-1',
  `Counter2` int(11) NOT NULL DEFAULT '-1',
  `Counter3` int(11) NOT NULL DEFAULT '-1',
  `Counter4` int(11) NOT NULL DEFAULT '-1',
  `SrvPacketID` bigint(20) NOT NULL DEFAULT '0',
  KEY `IDX_MobitelidLogid` (`Mobitel_ID`,`LogID`) USING BTREE,
  KEY `IDX_MobitelidUnixtime` (`Mobitel_ID`,`UnixTime`) USING BTREE,
  KEY `IDX_MobitelidUnixtimeValid` (`Mobitel_ID`,`UnixTime`,`Valid`) USING BTREE,
  KEY `IDX_SrvPacketID` (`SrvPacketID`) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=cp1251 COMMENT='Буфер онлайн данных';

--
-- Dumping data for table `datagpsbuffer_on`
--


--
-- Table structure for table `datagpsbuffer_on64`
--

CREATE TABLE `datagpsbuffer_on64` (
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РўРµР»РµС‚СЂРµРєР°',
  `Latitude` int(11) NOT NULL DEFAULT '0' COMMENT 'РЁРёСЂРѕС‚Р°',
  `Longitude` int(11) NOT NULL DEFAULT '0' COMMENT 'Р”РѕР»РіРѕС‚Р°',
  `Direction` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РіСЂР°РґСѓСЃС‹/1.5',
  `Acceleration` int(11) NOT NULL DEFAULT '0' COMMENT 'РР·РјРµРЅРµРЅРёРµ СЃРєРѕСЂРѕСЃС‚Рё РїРѕ GPS Р·Р° РїРѕСЃР»РµРґРЅСЋСЋ СЃРµРєСѓРЅРґСѓ',
  `UnixTime` int(11) NOT NULL DEFAULT '0',
  `Speed` smallint(6) NOT NULL DEFAULT '0' COMMENT 'РЎРѕС‚РµРЅ РјРµС‚СЂРѕРІ РІ С‡Р°СЃ (0,1 РєРј/С‡)',
  `Valid` tinyint(1) NOT NULL DEFAULT '1',
  `Satellites` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РљРѕР»РёС‡РµСЃС‚РІРѕ СЃРїСѓС‚РЅРёРєРѕРІ ',
  `RssiGsm` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РЈСЂРѕРІРµРЅСЊ GSM СЃРёРіРЅР°Р»Р°',
  `Events` int(11) NOT NULL DEFAULT '0' COMMENT 'Р¤Р»Р°РіРё СЃРѕР±С‹С‚РёР№',
  `SensorsSet` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РЅР°Р±РѕСЂР° РґР°С‚С‡РёРєРѕРІ',
  `Sensors` varbinary(50) NOT NULL DEFAULT '0' COMMENT 'Р—РЅР°С‡РµРЅРёСЏ РґР°С‚С‡РёРєРѕРІ',
  `Voltage` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT 'РќР°РїСЂСЏР¶РµРЅРёРµ РїРёС‚Р°РЅРёСЏ С‚РµРєСѓС‰РµРіРѕ РёСЃС‚РѕС‡РЅРёРєР°/1.5 РѕС‚ 0 РґРѕ 38,2',
  `DGPS` varchar(32) NOT NULL DEFAULT '0' COMMENT 'Р”Р°РЅРЅС‹Рµ РґРёС„С„РµСЂРµРЅС†РёР°Р»СЊРЅРѕР№ СЃРёСЃС‚РµРјС‹ GPS - РІС‹СЃРѕС‚Р°,С€РёСЂРѕС‚Р°,РґРѕР»РіРѕС‚Р°',
  `LogID` int(11) NOT NULL DEFAULT '0' COMMENT 'РРґРµРЅС‚РёС„РёРєР°С‚РѕСЂ Р·Р°РїРёСЃРё РІ Р¶СѓСЂРЅР°Р»Рµ РўРµР»РµС‚СЂРµРєР°',
  `SrvPacketID` bigint(20) NOT NULL DEFAULT '0' COMMENT 'ID СЃРµСЂРІРµСЂРЅРѕРіРѕ РїР°РєРµС‚Р° РІ СЃРѕСЃС‚Р°РІ РєРѕС‚РѕСЂРѕРіРѕ РІС…РѕРґРёС‚ СЌС‚Р° Р·Р°РїРёСЃСЊ',
  KEY `IDX_MobitelidLogid_64` (`Mobitel_ID`,`LogID`) USING BTREE,
  KEY `IDX_MobitelidUnixtime_64` (`Mobitel_ID`,`UnixTime`) USING BTREE,
  KEY `IDX_MobitelidUnixtimeValid_64` (`Mobitel_ID`,`UnixTime`,`Valid`) USING BTREE,
  KEY `IDX_SrvPacketID_64` (`SrvPacketID`) USING BTREE,
  CONSTRAINT `FK_datagps64_mobitels_Mobitel_ID_1` FOREIGN KEY (`Mobitel_ID`) REFERENCES `mobitels` (`Mobitel_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `datagpsbuffer_on64`
--


--
-- Table structure for table `datagpsbuffer_ontmp`
--

CREATE TABLE `datagpsbuffer_ontmp` (
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0',
  `LogID` int(11) NOT NULL DEFAULT '0',
  `SrvPacketID` bigint(20) NOT NULL DEFAULT '0',
  KEY `IDX_MobitelidSrvpacketid` (`Mobitel_ID`,`SrvPacketID`) USING BTREE,
  KEY `IDX_Mobitelid` (`Mobitel_ID`) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=cp1251 COMMENT='Временный вспомогательный буфер онлайн данных';

--
-- Dumping data for table `datagpsbuffer_ontmp`
--


--
-- Table structure for table `datagpsbuffer_ontmp64`
--

CREATE TABLE `datagpsbuffer_ontmp64` (
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РўРµР»РµС‚СЂРµРєР°',
  `LogID` int(11) unsigned DEFAULT '0' COMMENT 'РРґРµРЅС‚РёС„РёРєР°С‚РѕСЂ Р·Р°РїРёСЃРё РІ Р¶СѓСЂРЅР°Р»Рµ РўРµР»РµС‚СЂРµРєР°',
  `SrvPacketID` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'ID СЃРµСЂРІРµСЂРЅРѕРіРѕ РїР°РєРµС‚Р° РІ СЃРѕСЃС‚Р°РІ РєРѕС‚РѕСЂРѕРіРѕ РІС…РѕРґРёС‚ СЌС‚Р° Р·Р°РїРёСЃСЊ',
  KEY `IDX_Mobitelid64` (`Mobitel_ID`),
  KEY `IDX_MobitelidSrvpacketid64` (`Mobitel_ID`,`SrvPacketID`),
  CONSTRAINT `FK_datagps64_mobitels_Mobitel_ID_2` FOREIGN KEY (`Mobitel_ID`) REFERENCES `mobitels` (`Mobitel_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `datagpsbuffer_ontmp64`
--


--
-- Table structure for table `datagpsbuffer_pop`
--

CREATE TABLE `datagpsbuffer_pop` (
  `Mobitel_ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Latitude` int(11) NOT NULL DEFAULT '0',
  `Longitude` int(11) NOT NULL DEFAULT '0',
  `Altitude` int(11) DEFAULT '0',
  `UnixTime` int(11) NOT NULL DEFAULT '0',
  `Speed` smallint(6) NOT NULL DEFAULT '0',
  `Direction` int(11) NOT NULL DEFAULT '0',
  `Valid` tinyint(4) NOT NULL DEFAULT '1',
  `InMobitelID` int(11) DEFAULT '0',
  `Events` int(10) unsigned DEFAULT '0',
  `Sensor1` tinyint(4) unsigned DEFAULT '0',
  `Sensor2` tinyint(4) unsigned DEFAULT '0',
  `Sensor3` tinyint(4) unsigned DEFAULT '0',
  `Sensor4` tinyint(4) unsigned DEFAULT '0',
  `Sensor5` tinyint(4) unsigned DEFAULT '0',
  `Sensor6` tinyint(4) unsigned DEFAULT '0',
  `Sensor7` tinyint(4) unsigned DEFAULT '0',
  `Sensor8` tinyint(4) unsigned DEFAULT '0',
  `LogID` int(11) DEFAULT '0',
  `isShow` tinyint(4) DEFAULT '0',
  `whatIs` smallint(6) unsigned NOT NULL DEFAULT '0',
  `Counter1` int(11) NOT NULL DEFAULT '-1',
  `Counter2` int(11) NOT NULL DEFAULT '-1',
  `Counter3` int(11) NOT NULL DEFAULT '-1',
  `Counter4` int(11) NOT NULL DEFAULT '-1',
  KEY `IDX_MobitelIDLogID` (`Mobitel_ID`,`LogID`) USING BTREE,
  KEY `IDX_MobitelidUnixtime` (`Mobitel_ID`,`UnixTime`) USING BTREE,
  KEY `IDX_MobitelidUnixtimeValid` (`Mobitel_ID`,`UnixTime`,`Valid`) USING BTREE
) ENGINE=MEMORY DEFAULT CHARSET=cp1251 COMMENT='Буфер приема данных поступающих по POP3 протоколу';

--
-- Dumping data for table `datagpsbuffer_pop`
--


--
-- Table structure for table `datagpsbufferlite`
--

CREATE TABLE `datagpsbufferlite` (
  `DataGps_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Latitude` int(11) DEFAULT '0',
  `Longitude` int(11) DEFAULT '0',
  `Altitude` int(11) DEFAULT NULL,
  `UnixTime` int(11) DEFAULT '0',
  `Speed` smallint(6) DEFAULT '0',
  `Direction` int(11) NOT NULL DEFAULT '0',
  `Valid` tinyint(4) DEFAULT '1',
  `InMobitelID` int(11) DEFAULT NULL,
  `Events` int(10) unsigned DEFAULT '0',
  `Sensor1` tinyint(4) unsigned DEFAULT '0',
  `Sensor2` tinyint(4) unsigned DEFAULT '0',
  `Sensor3` tinyint(4) unsigned DEFAULT '0',
  `Sensor4` tinyint(4) unsigned DEFAULT '0',
  `Sensor5` tinyint(4) unsigned DEFAULT '0',
  `Sensor6` tinyint(4) unsigned DEFAULT '0',
  `Sensor7` tinyint(4) unsigned DEFAULT '0',
  `Sensor8` tinyint(4) unsigned DEFAULT '0',
  `LogID` int(11) DEFAULT '0',
  `isShow` tinyint(4) DEFAULT '0',
  `whatIs` smallint(6) DEFAULT '0',
  `Counter1` int(11) NOT NULL DEFAULT '-1',
  `Counter2` int(11) NOT NULL DEFAULT '-1',
  `Counter3` int(11) NOT NULL DEFAULT '-1',
  `Counter4` int(11) NOT NULL DEFAULT '-1',
  PRIMARY KEY (`DataGps_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `datagpsbufferlite`
--


--
-- Table structure for table `datagpslost`
--

CREATE TABLE `datagpslost` (
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0',
  `Begin_LogID` int(11) NOT NULL DEFAULT '0' COMMENT 'Значение LogID после которого начинается разрыв',
  `End_LogID` int(11) NOT NULL DEFAULT '0' COMMENT 'Значение LogID перед которым завершается разрыв',
  PRIMARY KEY (`Mobitel_ID`,`Begin_LogID`),
  KEY `IDX_MobitelID` (`Mobitel_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Список пропусков в данных DataGPS пришодящих от RF-модемов';

--
-- Dumping data for table `datagpslost`
--


--
-- Table structure for table `datagpslost_on`
--

CREATE TABLE `datagpslost_on` (
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0',
  `Begin_LogID` int(11) NOT NULL DEFAULT '0' COMMENT 'Значение LogID после которого начинается разрыв',
  `End_LogID` int(11) NOT NULL DEFAULT '0' COMMENT 'Значение LogID перед которым завершается разрыв',
  `Begin_SrvPacketID` bigint(20) NOT NULL DEFAULT '0',
  `End_SrvPacketID` bigint(20) NOT NULL DEFAULT '0',
  `Id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`Mobitel_ID`,`Begin_LogID`),
  UNIQUE KEY `IDX_MobitelID_BeginSrvPacketID` (`Mobitel_ID`,`Begin_SrvPacketID`),
  UNIQUE KEY `Id` (`Id`),
  KEY `IDX_MobitelID` (`Mobitel_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Пропуски в данных DataGPS, приходящих от Online сервера';

--
-- Dumping data for table `datagpslost_on`
--


--
-- Table structure for table `datagpslost_ontmp`
--

CREATE TABLE `datagpslost_ontmp` (
  `LogID` int(11) NOT NULL DEFAULT '0',
  `SrvPacketID` bigint(20) NOT NULL
) ENGINE=MEMORY DEFAULT CHARSET=cp1251 COMMENT='Используется исключительно процедурой OnLostDataGPS';

--
-- Dumping data for table `datagpslost_ontmp`
--


--
-- Table structure for table `datagpslost_rftmp`
--

CREATE TABLE `datagpslost_rftmp` (
  `LogID` int(11) DEFAULT '0'
) ENGINE=MEMORY DEFAULT CHARSET=cp1251 COMMENT='Используется исключительно процедурой LostDataGPS';

--
-- Dumping data for table `datagpslost_rftmp`
--


--
-- Table structure for table `datagpslosted`
--

CREATE TABLE `datagpslosted` (
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0',
  `Begin_LogID` int(11) NOT NULL DEFAULT '0',
  `End_LogID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Mobitel_ID`,`Begin_LogID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `datagpslosted`
--


--
-- Table structure for table `driver`
--

CREATE TABLE `driver` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Family` char(40) DEFAULT NULL COMMENT 'Фамилия',
  `Name` char(40) DEFAULT NULL COMMENT 'Имя',
  `ByrdDay` date DEFAULT NULL COMMENT 'Дата рождения',
  `Category` char(5) DEFAULT NULL COMMENT 'Категория',
  `Permis` char(20) DEFAULT NULL COMMENT 'Права',
  `foto` blob COMMENT 'фото',
  `Identifier` smallint(5) unsigned DEFAULT NULL COMMENT '10 битный идентификатор водителя',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  `idType` int(11) DEFAULT '0' COMMENT 'Код специализации водителя',
  `numTelephone` varchar(32) DEFAULT '' COMMENT 'Телефон водителя для связи',
  `Department` varchar(40) DEFAULT NULL COMMENT 'Организация водителя',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`) USING BTREE,
  UNIQUE KEY `UQ_Identifier` (`Identifier`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `driver`
--

INSERT INTO `driver` VALUES (1,'','','2009-01-01','с','1111',NULL,NULL,NULL,0,'',NULL),(2,'Водитель','','2009-01-22','с','1111',NULL,NULL,NULL,0,'',NULL);

--
-- Table structure for table `driver_types`
--

CREATE TABLE `driver_types` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `TypeName` varchar(50) DEFAULT NULL COMMENT 'Специализация водителя',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `id` (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `driver_types`
--


--
-- Table structure for table `gpsmasks`
--

CREATE TABLE `gpsmasks` (
  `GpsMask_ID` int(11) NOT NULL AUTO_INCREMENT,
  `ID` int(11) DEFAULT '0',
  `Name` char(200) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `Mobitel_ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `LastRecords` int(11) DEFAULT '0',
  `LastTimes` int(11) DEFAULT '0',
  `LastTimesIndex` int(11) DEFAULT '0',
  `LastMeters` int(11) DEFAULT '0',
  `LastMetersIndex` int(11) DEFAULT '0',
  `MaxSmsNum` int(11) DEFAULT '0',
  `MaxSmsNumIndex` int(11) DEFAULT '0',
  `LatitudeStart` int(11) DEFAULT '0',
  `LatitudeEnd` int(11) DEFAULT '0',
  `LongitudeStart` int(11) DEFAULT '0',
  `LongitudeEnd` int(11) DEFAULT '0',
  `AltitudeStart` int(11) DEFAULT '0',
  `AltitudeEnd` int(11) DEFAULT '0',
  `UnixTimeStart` int(11) DEFAULT '0',
  `UnixTimeEnd` int(11) DEFAULT '0',
  `SpeedStart` int(11) DEFAULT '0',
  `SpeedEnd` int(11) DEFAULT '0',
  `DirectionStart` int(11) DEFAULT '0',
  `DirectionEnd` int(11) DEFAULT '0',
  `NumbersStart` int(11) DEFAULT '0',
  `NumbersEnd` int(11) DEFAULT '0',
  `WhatSend` int(1) DEFAULT '0',
  `CheckMask` int(11) DEFAULT '0',
  `InMobitelID` int(11) DEFAULT '0',
  `Events` int(11) DEFAULT '0',
  `Number1` int(11) DEFAULT '0',
  `Number2` int(11) DEFAULT '0',
  `Number3` int(11) DEFAULT '0',
  `Number4` int(11) DEFAULT '0',
  `Number5` int(11) DEFAULT '0',
  PRIMARY KEY (`GpsMask_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `gpsmasks`
--


--
-- Table structure for table `internalmobitelconfig`
--

CREATE TABLE `internalmobitelconfig` (
  `InternalMobitelConfig_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `devIdLong` char(16) DEFAULT NULL,
  `devIdShort` char(4) DEFAULT NULL,
  `verProtocolLong` char(16) DEFAULT NULL,
  `verProtocolShort` char(2) DEFAULT NULL,
  `moduleIdGps` char(50) DEFAULT NULL,
  `moduleIdGsm` char(50) DEFAULT NULL,
  `moduleIdRf` char(50) DEFAULT NULL,
  `RfType` smallint(6) NOT NULL DEFAULT '0',
  `ActiveRf` tinyint(1) NOT NULL DEFAULT '0',
  `moduleIdSs` char(50) DEFAULT NULL,
  `moduleIdMm` char(50) NOT NULL DEFAULT 'moduleIdMm',
  PRIMARY KEY (`InternalMobitelConfig_ID`),
  KEY `Index_3` (`Message_ID`),
  KEY `Index_4` (`devIdShort`),
  KEY `IDX_InternalmobitelconfigID` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `internalmobitelconfig`
--

INSERT INTO `internalmobitelconfig` VALUES (1,'','',1,0,'0','8269','0','0','0','0','0',0,0,'0','0'),(2,'','',2,0,'0','0951','0','0','0','0','0',0,0,'0','0'),(3,'','',3,0,'0','2483','0','0','0','0','0',0,0,'0','0'),(4,'','',4,0,'0','6666','0','0','0','0','0',0,0,'0','0'),(5,'','',5,0,'0','8326','0','0','0','0','0',0,0,'0','0');

--
-- Table structure for table `lastmeters`
--

CREATE TABLE `lastmeters` (
  `LastMeter_ID` int(11) DEFAULT '0',
  `ID` int(11) DEFAULT '0',
  `Name` char(200) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `lastmeters`
--

INSERT INTO `lastmeters` VALUES (200,2,'200 метров',NULL),(1000,3,'1 километр',NULL),(5000,4,'5 километров',NULL),(25000,5,'25 километров',NULL),(100000,6,'100 километров',NULL);

--
-- Table structure for table `lastrecords`
--

CREATE TABLE `lastrecords` (
  `LastRecord_ID` int(11) DEFAULT '0',
  `ID` int(11) DEFAULT '0',
  `Name` char(200) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `lastrecords`
--

INSERT INTO `lastrecords` VALUES (5,1,'5 записей',NULL),(20,2,'20 записей',NULL),(50,3,'50 записей',NULL),(200,4,'200 записей',NULL),(1000,6,'1000 записей',NULL),(500,5,'500 записей',NULL),(3000,7,'3000 записей','3000 записей');

--
-- Table structure for table `lasttimes`
--

CREATE TABLE `lasttimes` (
  `LastTime_ID` int(11) DEFAULT '0',
  `ID` int(11) DEFAULT '0',
  `Name` char(200) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `lasttimes`
--

INSERT INTO `lasttimes` VALUES (5,1,'5 минут',NULL),(20,2,'20 минут',NULL),(120,3,'2 часа',NULL),(360,4,'6 часов',NULL),(1440,5,'сутки',NULL);

--
-- Table structure for table `lines`
--

CREATE TABLE `lines` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Color` int(11) DEFAULT '0' COMMENT 'Цвет',
  `Width` int(11) DEFAULT '3' COMMENT 'Толщина линии',
  `Mobitel_ID` int(11) DEFAULT NULL,
  `Icon` blob,
  PRIMARY KEY (`id`),
  KEY `lines_FK1` (`Mobitel_ID`) USING BTREE,
  CONSTRAINT `lines_FK1` FOREIGN KEY (`Mobitel_ID`) REFERENCES `mobitels` (`Mobitel_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251 COMMENT='Описание линии';

--
-- Dumping data for table `lines`
--

INSERT INTO `lines` VALUES (1,-4194112,3,942814777,NULL),(2,-16777077,3,809055537,NULL),(3,-16776961,3,842283059,NULL),(4,-16760768,3,909522486,NULL),(5,-8388480,3,942879286,NULL);

--
-- Table structure for table `mapstyleglobal`
--

CREATE TABLE `mapstyleglobal` (
  `MapStyleGlobal_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `DefaultLineStyle_ID` int(11) DEFAULT '0',
  `DefaulPointStyle_ID` int(11) DEFAULT '0',
  `EventPointStyle1_ID` int(11) DEFAULT '0',
  `EventPointStyle2_ID` int(11) DEFAULT '0',
  `EventPointStyle3_ID` int(11) DEFAULT '0',
  `EventPointStyle4_ID` int(11) DEFAULT '0',
  `EventPointStyle5_ID` int(11) DEFAULT '0',
  `EventPointStyle6_ID` int(11) DEFAULT '0',
  `EventPointStyle7_ID` int(11) DEFAULT '0',
  `EventPointStyle8_ID` int(11) DEFAULT '0',
  `EventPointStyle9_ID` int(11) DEFAULT '0',
  `EventPointStyle10_ID` int(11) DEFAULT '0',
  `EventPointStyle11_ID` int(11) DEFAULT '0',
  `EventPointStyle12_ID` int(11) DEFAULT '0',
  `EventPointStyle13_ID` int(11) DEFAULT '0',
  `EventPointStyle14_ID` int(11) DEFAULT '0',
  `EventPointStyle15_ID` int(11) DEFAULT '0',
  `EventPointStyle16_ID` int(11) DEFAULT '0',
  `EventPointStyle17_ID` int(11) DEFAULT '0',
  `EventPointStyle18_ID` int(11) DEFAULT '0',
  `EventPointStyle19_ID` int(11) DEFAULT '0',
  `EventPointStyle20_ID` int(11) DEFAULT '0',
  `EventPointStyle21_ID` int(11) DEFAULT '0',
  `EventPointStyle22_ID` int(11) DEFAULT '0',
  `EventPointStyle23_ID` int(11) DEFAULT '0',
  `EventPointStyle24_ID` int(11) DEFAULT '0',
  `EventPointStyle25_ID` int(11) DEFAULT '0',
  `EventPointStyle26_ID` int(11) DEFAULT '0',
  `EventPointStyle27_ID` int(11) DEFAULT '0',
  `EventPointStyle28_ID` int(11) DEFAULT '0',
  `EventPointStyle29_ID` int(11) DEFAULT '0',
  `EventPointStyle30_ID` int(11) DEFAULT '0',
  `EventPointStyle31_ID` int(11) DEFAULT '0',
  `EventPointStyle32_ID` int(11) DEFAULT '0',
  `SensorPointStyle1_ID` int(11) DEFAULT '0',
  `SensorPointStyle2_ID` int(11) DEFAULT '0',
  `SensorPointStyle3_ID` int(11) DEFAULT '0',
  `SensorPointStyle4_ID` int(11) DEFAULT '0',
  `SensorPointStyle5_ID` int(11) DEFAULT '0',
  `SensorPointStyle6_ID` int(11) DEFAULT '0',
  `SensorPointStyle7_ID` int(11) DEFAULT '0',
  `SensorPointStyle8_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`MapStyleGlobal_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `mapstyleglobal`
--

INSERT INTO `mapstyleglobal` VALUES (1,'Настройка 1','Настнойки для Мобител',0,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(2,'Настнойки 4','Настнойки mob 4',0,2,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(3,'Настнойки 3','Настнойки для Мобител 3',0,3,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(4,'Tune 2','Настнойки для Мобител 2',0,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

--
-- Table structure for table `mapstylelines`
--

CREATE TABLE `mapstylelines` (
  `MapStyleLine_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Color` int(11) DEFAULT '0',
  `Width` tinyint(4) DEFAULT '0',
  `Style` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`MapStyleLine_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `mapstylelines`
--

INSERT INTO `mapstylelines` VALUES (1,'Стиль линий Black','Описание',1,0,1,0),(2,'Стиль линий Blue','Стиль линий 2',2,16711680,4,0),(3,'Стиль линий Green','Стиль линий 3',3,32768,5,0),(4,'Стиль линий Red','Стиль линий 4',4,255,1,0),(6,'DEFAULT','Стиль по умолчанию',0,8388736,2,0),(8,'Style Fuchsia','Description for linestyle created at 13.08.2004 10:39:31',0,16711935,1,0);

--
-- Table structure for table `mapstylepoints`
--

CREATE TABLE `mapstylepoints` (
  `MapStylePoint_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `isBitmap` tinyint(1) DEFAULT NULL,
  `SymbolCode` tinyint(4) DEFAULT '0',
  `Color` int(11) DEFAULT '0',
  `Font` char(200) DEFAULT NULL,
  `Size` int(11) DEFAULT '0',
  `Rotation` int(11) DEFAULT '0',
  `BitmapName` char(200) DEFAULT NULL,
  `BitmapStyle` tinyint(4) DEFAULT '0',
  `Style` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`MapStylePoint_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `mapstylepoints`
--

INSERT INTO `mapstylepoints` VALUES (2,'Blue Style','Стиль точек 1',2,0,0,16711680,NULL,3,0,NULL,0,0),(3,'Red Style','Стиль точек 2',3,0,0,255,NULL,4,0,NULL,0,0),(5,'DEFAULT','Стиль по умолчанию',0,0,0,128,NULL,5,0,NULL,0,0),(6,'Yellow Style','Стиль точек 3',4,0,0,65535,NULL,4,0,NULL,0,0),(8,'Fuchisia Style','Description for pointstyle created at 13.08.2004 10:39:45',0,0,0,16711935,NULL,3,0,NULL,0,0),(9,'Lime Style','Description for pointstyle created at 13.08.2004 10:41:19',0,0,0,65280,NULL,2,0,NULL,0,0),(10,'test','Description for pointstyle created at 06.12.2004 17:36:40',0,NULL,0,8421376,NULL,3,0,NULL,0,0);

--
-- Table structure for table `messages`
--

CREATE TABLE `messages` (
  `Message_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Time1` int(11) DEFAULT '0',
  `Time2` int(11) DEFAULT '0',
  `Time3` int(11) DEFAULT '0',
  `Time4` int(11) DEFAULT '0',
  `isSend` tinyint(1) DEFAULT NULL,
  `isDelivered` tinyint(1) DEFAULT NULL,
  `isNew` tinyint(1) DEFAULT NULL,
  `Direction` tinyint(1) DEFAULT NULL,
  `Mobitel_ID` int(11) DEFAULT '0',
  `ServiceInit_ID` int(11) DEFAULT '0',
  `Command_ID` tinyint(4) DEFAULT '0',
  `CommandMask_ID` int(11) DEFAULT '0',
  `MessageCounter` int(11) DEFAULT '0',
  `DataFromService` char(32) DEFAULT NULL,
  `Address` char(20) DEFAULT NULL,
  `Source_ID` int(11) DEFAULT '0',
  `Crc` tinyint(4) DEFAULT '1',
  `SmsId` int(11) DEFAULT '0',
  `AdvCounter` int(11) NOT NULL DEFAULT '0',
  `isNewFromMob` tinyint(4) NOT NULL DEFAULT '1',
  PRIMARY KEY (`Message_ID`),
  KEY `Index_2` (`isNewFromMob`,`Message_ID`,`Time1`) USING BTREE,
  KEY `Index_6` (`isNew`,`Direction`,`ServiceInit_ID`),
  KEY `Index_4` (`Mobitel_ID`,`Command_ID`),
  KEY `Index_5` (`Mobitel_ID`,`MessageCounter`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `messages`
--


--
-- Table structure for table `mobitels`
--

CREATE TABLE `mobitels` (
  `Mobitel_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` bigint(20) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `ServiceInit_ID` int(11) DEFAULT '0',
  `ServiceSend_ID` int(11) DEFAULT '0',
  `InternalMobitelConfig_ID` int(11) DEFAULT '0',
  `MapStyleLine_ID` int(11) DEFAULT '0',
  `MapStyleLastPoint_ID` int(11) DEFAULT '0',
  `MapStylePoint_ID` int(11) DEFAULT '0',
  `Route_ID` int(11) DEFAULT '0',
  `DeviceType` int(11) DEFAULT '0',
  `DeviceEngine` int(11) DEFAULT '0',
  `ConfirmedID` int(11) NOT NULL DEFAULT '0' COMMENT 'MIN значение LogID менее которого считается нет пропусков или уже невозможно загрузить',
  `LastInsertTime` int(11) NOT NULL DEFAULT '0' COMMENT 'UNIX_TIMESTAMP Время последней вставки данных в DataGPS',
  `Is64bitPackets` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'передача данных идет 64 байтными пакетами',
  `IsNotDrawDgps` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'РѕС‚РѕР±СЂР°Р¶Р°С‚СЊ РёР»Рё РЅРµС‚ РґР°РЅРЅС‹Рµ DGPS РЅР° РєР°СЂС‚Рµ',
  PRIMARY KEY (`Mobitel_ID`),
  KEY `IDX_InternalmobitelconfigID` (`InternalMobitelConfig_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=942879287 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `mobitels`
--

INSERT INTO `mobitels` VALUES (809055537,'','',0,0,0,2,2,6,5,5,0,0,0,0,1770913092,1,1),(842283059,'','',0,0,0,3,3,6,5,5,0,0,0,0,1770913086,1,1),(909522486,'6666','',0,0,0,4,4,6,5,5,0,0,0,0,1770913129,0,1),(942814777,'','',0,0,0,1,1,6,5,5,0,0,0,0,1711534525,0,1),(942879286,'8326','',0,0,0,5,5,6,5,5,0,0,0,0,1770913107,1,1);

--
-- Table structure for table `mobitels_info`
--

CREATE TABLE `mobitels_info` (
  `Mobitel_ID` int(10) unsigned NOT NULL,
  `Map_Style_Car` text,
  `Track_Color` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`Mobitel_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `mobitels_info`
--


--
-- Table structure for table `mobitels_rotate_bands`
--

CREATE TABLE `mobitels_rotate_bands` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0',
  `Bound` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `FK_mobitels_rotate_bands_mobitels_Mobitel_ID` (`Mobitel_ID`),
  CONSTRAINT `FK_mobitels_rotate_bands_mobitels_Mobitel_ID` FOREIGN KEY (`Mobitel_ID`) REFERENCES `mobitels` (`Mobitel_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `mobitels_rotate_bands`
--


--
-- Table structure for table `ntf_emails`
--

CREATE TABLE `ntf_emails` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `IsActive` tinyint(1) NOT NULL DEFAULT '0',
  `Email` varchar(127) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `FK_ntf_email_ntf_main_Id` (`Id_main`),
  CONSTRAINT `FK_ntf_email_ntf_main_Id` FOREIGN KEY (`Id_main`) REFERENCES `ntf_main` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `ntf_emails`
--


--
-- Table structure for table `ntf_events`
--

CREATE TABLE `ntf_events` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `TypeEvent` tinyint(4) NOT NULL,
  `EventId` int(11) NOT NULL DEFAULT '0',
  `ParInt1` int(11) NOT NULL DEFAULT '0' COMMENT 'INT параметр любого события',
  `ParDbl1` double NOT NULL DEFAULT '0' COMMENT 'DOUBLE параметр №1 любого события',
  `ParDbl2` double NOT NULL DEFAULT '0' COMMENT 'DOUBLE параметр №2 любого события',
  `ParBool` bit(1) NOT NULL DEFAULT b'0' COMMENT 'BOOL параметр любого события',
  `ParInt2` int(11) NOT NULL DEFAULT '0' COMMENT 'INT параметр №2 любого события',
  PRIMARY KEY (`Id`),
  KEY `FK_ntf_events_ntf_main_Id` (`Id_main`),
  CONSTRAINT `FK_ntf_events_ntf_main_Id` FOREIGN KEY (`Id_main`) REFERENCES `ntf_main` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `ntf_events`
--


--
-- Table structure for table `ntf_log`
--

CREATE TABLE `ntf_log` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `DateEvent` datetime NOT NULL,
  `DateWrite` datetime NOT NULL,
  `TypeEvent` tinyint(4) NOT NULL,
  `Mobitel_id` int(11) NOT NULL DEFAULT '0',
  `Zone_id` int(11) NOT NULL DEFAULT '0',
  `Location` varchar(255) DEFAULT NULL,
  `Lat` double DEFAULT '0',
  `Lng` double DEFAULT '0',
  `Infor` varchar(255) DEFAULT NULL,
  `IsRead` bit(1) DEFAULT b'0' COMMENT 'Уведомление прочитано ',
  `DataGps_ID` bigint(20) DEFAULT '0',
  `Speed` double DEFAULT '0',
  `Value` double DEFAULT '0' COMMENT 'Цифровое значение события (датчики)',
  PRIMARY KEY (`Id`),
  KEY `FK_ntf_log_ntf_main_Id` (`Id_main`),
  CONSTRAINT `FK_ntf_log_ntf_main_Id` FOREIGN KEY (`Id_main`) REFERENCES `ntf_main` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `ntf_log`
--


--
-- Table structure for table `ntf_main`
--

CREATE TABLE `ntf_main` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `IsActive` tinyint(1) NOT NULL DEFAULT '0',
  `IsPopup` tinyint(1) NOT NULL DEFAULT '0',
  `Title` varchar(255) NOT NULL,
  `IconSmall` blob,
  `IconLarge` blob,
  `SoundName` varchar(50) DEFAULT NULL,
  `TimeForControl` double DEFAULT NULL,
  `IsEmailActive` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Активна E-mail рассылка уведомления',
  `Period` int(11) NOT NULL DEFAULT '0' COMMENT 'Периодичность появления уведомления(не чаще)',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `ntf_main`
--


--
-- Table structure for table `ntf_mobitels`
--

CREATE TABLE `ntf_mobitels` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `MobitelId` int(11) NOT NULL,
  `SensorLogicId` int(11) DEFAULT '0',
  `SensorId` int(11) DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `FK_ntf_mobitels_ntf_main_Id` (`Id_main`),
  CONSTRAINT `FK_ntf_mobitels_ntf_main_Id` FOREIGN KEY (`Id_main`) REFERENCES `ntf_main` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `ntf_mobitels`
--


--
-- Table structure for table `ntf_popupusers`
--

CREATE TABLE `ntf_popupusers` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `Id_user` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `FK_ntf_popupUsers_ntf_main_Id` (`Id_main`),
  CONSTRAINT `FK_ntf_popupUsers_ntf_main_Id` FOREIGN KEY (`Id_main`) REFERENCES `ntf_main` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `ntf_popupusers`
--


--
-- Table structure for table `online`
--

CREATE TABLE `online` (
  `DataGps_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Latitude` int(11) NOT NULL DEFAULT '0',
  `Longitude` int(11) NOT NULL DEFAULT '0',
  `Altitude` int(11) DEFAULT '0',
  `UnixTime` int(11) NOT NULL DEFAULT '0',
  `Speed` smallint(6) NOT NULL DEFAULT '0',
  `Direction` int(11) NOT NULL DEFAULT '0',
  `Valid` tinyint(4) NOT NULL DEFAULT '1',
  `InMobitelID` int(11) DEFAULT '0',
  `Events` int(10) unsigned DEFAULT '0',
  `Sensor1` tinyint(4) unsigned DEFAULT '0',
  `Sensor2` tinyint(4) unsigned DEFAULT '0',
  `Sensor3` tinyint(4) unsigned DEFAULT '0',
  `Sensor4` tinyint(4) unsigned DEFAULT '0',
  `Sensor5` tinyint(4) unsigned DEFAULT '0',
  `Sensor6` tinyint(4) unsigned DEFAULT '0',
  `Sensor7` tinyint(4) unsigned DEFAULT '0',
  `Sensor8` tinyint(4) unsigned DEFAULT '0',
  `LogID` int(11) DEFAULT '0',
  `isShow` tinyint(4) DEFAULT '0',
  `whatIs` smallint(6) unsigned NOT NULL DEFAULT '0',
  `Counter1` int(11) NOT NULL DEFAULT '-1',
  `Counter2` int(11) NOT NULL DEFAULT '-1',
  `Counter3` int(11) NOT NULL DEFAULT '-1',
  `Counter4` int(11) NOT NULL DEFAULT '-1',
  PRIMARY KEY (`DataGps_ID`),
  KEY `IDX_MobitelidUnixtimeValid` (`Mobitel_ID`,`UnixTime`,`Valid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1762 DEFAULT CHARSET=cp1251 COMMENT='Оперативные данные';

--
-- Dumping data for table `online`
--

INSERT INTO `online` VALUES (646,942814777,0,30363228,15836657,258,1675064712,0,0,1,1635312,0,0,0,0,206,0,0,0,0,1635312,0,1023,-1,-1,-1,-1),(647,942814777,0,30363228,15836657,258,1675064772,0,0,1,1635313,0,0,0,0,208,0,0,0,0,1635313,0,1023,-1,-1,-1,-1),(648,942814777,0,30363228,15836657,258,1675064832,0,0,1,1635314,0,0,0,0,208,0,0,0,0,1635314,0,1023,-1,-1,-1,-1),(649,942814777,0,30363228,15836657,258,1675064892,0,0,1,1635315,0,0,0,0,208,0,0,0,0,1635315,0,1023,-1,-1,-1,-1),(650,942814777,0,30363228,15836657,258,1675064952,0,0,1,1635316,0,0,0,0,208,0,0,0,0,1635316,0,1023,-1,-1,-1,-1),(651,942814777,0,30363228,15836657,258,1675065012,0,0,1,1635317,0,0,0,0,208,0,0,0,0,1635317,0,1023,-1,-1,-1,-1),(652,942814777,0,30363228,15836657,258,1675065072,0,0,1,1635318,0,0,0,0,209,0,0,0,0,1635318,0,1023,-1,-1,-1,-1),(653,942814777,0,30363228,15836657,258,1675065132,0,0,1,1635319,0,0,0,0,209,0,0,0,0,1635319,0,1023,-1,-1,-1,-1),(654,942814777,0,30363228,15836657,258,1675065192,0,0,1,1635320,0,0,0,0,209,0,0,0,0,1635320,0,1023,-1,-1,-1,-1),(655,942814777,0,30363228,15836657,258,1675065252,0,0,1,1635321,0,0,0,0,209,0,0,0,0,1635321,0,1023,-1,-1,-1,-1),(656,942814777,0,30363228,15836657,258,1675065312,0,0,1,1635322,0,0,0,0,209,0,0,0,0,1635322,0,1023,-1,-1,-1,-1),(657,942814777,0,30363228,15836657,258,1675065372,0,0,1,1635323,0,0,0,0,209,0,0,0,0,1635323,0,1023,-1,-1,-1,-1),(658,942814777,0,30363228,15836657,258,1675065432,0,0,1,1635324,0,0,0,0,209,0,0,0,0,1635324,0,1023,-1,-1,-1,-1),(659,942814777,0,30363228,15836657,258,1675065492,0,0,1,1635325,0,0,0,0,209,0,0,0,0,1635325,0,1023,-1,-1,-1,-1),(660,942814777,0,30363228,15836657,258,1675065552,0,0,1,1635326,0,0,0,0,209,0,0,0,0,1635326,0,1023,-1,-1,-1,-1),(661,942814777,0,30363228,15836657,258,1675065612,0,0,1,1635327,0,0,0,0,209,0,0,0,0,1635327,0,1023,-1,-1,-1,-1),(662,942814777,0,30363228,15836657,258,1675065672,0,0,1,1635328,0,0,0,0,209,0,0,0,0,1635328,0,1023,-1,-1,-1,-1),(663,942814777,0,30363228,15836657,258,1675065732,0,0,1,1635329,0,0,0,0,209,0,0,0,0,1635329,0,1023,-1,-1,-1,-1),(664,942814777,0,30363228,15836657,258,1675065792,0,0,1,1635330,0,0,0,0,209,0,0,0,0,1635330,0,1023,-1,-1,-1,-1),(665,942814777,0,30363228,15836657,258,1675065852,0,0,1,1635331,0,0,0,0,207,0,0,0,0,1635331,0,1023,-1,-1,-1,-1),(666,942814777,0,30363228,15836657,258,1675065875,0,0,1,1635332,0,32,0,0,146,0,0,0,0,1635332,0,1023,-1,-1,-1,-1),(667,942814777,0,30363228,15836657,258,1675065935,0,0,1,1635333,0,32,0,0,201,0,0,0,0,1635333,0,1023,-1,-1,-1,-1),(668,942814777,0,30363228,15836657,258,1675065966,0,0,1,1635334,0,0,0,0,202,0,0,0,0,1635334,0,1023,-1,-1,-1,-1),(669,942814777,0,30363228,15836657,258,1675066025,0,0,1,1635335,0,0,0,0,207,0,0,0,0,1635335,0,1023,-1,-1,-1,-1),(670,942814777,0,30363228,15836657,258,1675066085,0,0,1,1635336,0,0,0,0,208,0,0,0,0,1635336,0,1023,-1,-1,-1,-1),(671,942814777,0,30363228,15836657,258,1675066145,0,0,1,1635337,0,0,0,0,208,0,0,0,0,1635337,0,1023,-1,-1,-1,-1),(672,942814777,0,30363228,15836657,258,1675066205,0,0,1,1635338,0,0,0,0,208,0,0,0,0,1635338,0,1023,-1,-1,-1,-1),(673,942814777,0,30363228,15836657,258,1675066265,0,0,1,1635339,0,0,0,0,208,0,0,0,0,1635339,0,1023,-1,-1,-1,-1),(674,942814777,0,30363228,15836657,258,1675066325,0,0,1,1635340,0,0,0,0,208,0,0,0,0,1635340,0,1023,-1,-1,-1,-1),(675,942814777,0,30363228,15836657,258,1675066385,0,0,1,1635341,0,0,0,0,208,0,0,0,0,1635341,0,1023,-1,-1,-1,-1),(676,942814777,0,30363228,15836657,258,1675066445,0,0,1,1635342,0,0,0,0,209,0,0,0,0,1635342,0,1023,-1,-1,-1,-1),(677,942814777,0,30363228,15836657,258,1675066505,0,0,1,1635343,0,0,0,0,209,0,0,0,0,1635343,0,1023,-1,-1,-1,-1),(678,942814777,0,30363228,15836657,258,1675066565,0,0,1,1635344,0,0,0,0,209,0,0,0,0,1635344,0,1023,-1,-1,-1,-1),(679,942814777,0,30363228,15836657,258,1675066625,0,0,1,1635345,0,0,0,0,209,0,0,0,0,1635345,0,1023,-1,-1,-1,-1),(680,942814777,0,30363228,15836657,258,1675066685,0,0,1,1635346,0,0,0,0,209,0,0,0,0,1635346,0,1023,-1,-1,-1,-1),(681,942814777,0,30363228,15836657,258,1675066745,0,0,1,1635347,0,0,0,0,209,0,0,0,0,1635347,0,1023,-1,-1,-1,-1),(682,942814777,0,30363228,15836657,258,1675066805,0,0,1,1635348,0,0,0,0,209,0,0,0,0,1635348,0,1023,-1,-1,-1,-1),(683,942814777,0,30363228,15836657,258,1675066865,0,0,1,1635349,0,0,0,0,209,0,0,0,0,1635349,0,1023,-1,-1,-1,-1),(684,942814777,0,30363228,15836657,258,1675066925,0,0,1,1635350,0,0,0,0,209,0,0,0,0,1635350,0,1023,-1,-1,-1,-1),(685,942814777,0,30363228,15836657,258,1675066985,0,0,1,1635351,0,0,0,0,209,0,0,0,0,1635351,0,1023,-1,-1,-1,-1),(686,942814777,0,30363228,15836657,258,1675067045,0,0,1,1635352,0,0,0,0,209,0,0,0,0,1635352,0,1023,-1,-1,-1,-1),(687,942814777,0,30363228,15836657,258,1675067105,0,0,1,1635353,0,0,0,0,209,0,0,0,0,1635353,0,1023,-1,-1,-1,-1),(688,942814777,0,30363228,15836657,258,1675067165,0,0,1,1635354,0,0,0,0,209,0,0,0,0,1635354,0,1023,-1,-1,-1,-1),(689,942814777,0,30363228,15836657,258,1675067225,0,0,1,1635355,0,0,0,0,209,0,0,0,0,1635355,0,1023,-1,-1,-1,-1),(690,942814777,0,30363228,15836657,258,1675067285,0,0,1,1635356,0,0,0,0,209,0,0,0,0,1635356,0,1023,-1,-1,-1,-1),(691,942814777,0,30363228,15836657,258,1675067345,0,0,1,1635357,0,0,0,0,209,0,0,0,0,1635357,0,1023,-1,-1,-1,-1),(692,942814777,0,30363228,15836657,258,1675067405,0,0,1,1635358,0,0,0,0,209,0,0,0,0,1635358,0,1023,-1,-1,-1,-1),(693,942814777,0,30363228,15836657,258,1675067465,0,0,1,1635359,0,0,0,0,209,0,0,0,0,1635359,0,1023,-1,-1,-1,-1),(694,942814777,0,30363228,15836657,258,1675067525,0,0,1,1635360,0,0,0,0,209,0,0,0,0,1635360,0,1023,-1,-1,-1,-1),(695,942814777,0,30363228,15836657,258,1675067585,0,0,1,1635361,0,0,0,0,209,0,0,0,0,1635361,0,1023,-1,-1,-1,-1),(696,942814777,0,30363228,15836657,258,1675067645,0,0,1,1635362,0,0,0,0,209,0,0,0,0,1635362,0,1023,-1,-1,-1,-1),(697,942814777,0,30363228,15836657,258,1675067705,0,0,1,1635363,0,0,0,0,209,0,0,0,0,1635363,0,1023,-1,-1,-1,-1),(698,942814777,0,30363228,15836657,258,1675067765,0,0,1,1635364,0,0,0,0,209,0,0,0,0,1635364,0,1023,-1,-1,-1,-1),(699,942814777,0,30363228,15836657,258,1675067825,0,0,1,1635365,0,0,0,0,209,0,0,0,0,1635365,0,1023,-1,-1,-1,-1),(700,942814777,0,30363228,15836657,258,1675067885,0,0,1,1635366,0,0,0,0,209,0,0,0,0,1635366,0,1023,-1,-1,-1,-1),(701,942814777,0,30363228,15836657,258,1675067945,0,0,1,1635367,0,0,0,0,209,0,0,0,0,1635367,0,1023,-1,-1,-1,-1),(702,942814777,0,30363228,15836657,258,1675068005,0,0,1,1635368,0,0,0,0,209,0,0,0,0,1635368,0,1023,-1,-1,-1,-1),(703,942814777,0,30363228,15836657,258,1675068065,0,0,1,1635369,0,0,0,0,209,0,0,0,0,1635369,0,1023,-1,-1,-1,-1),(704,942814777,0,30363228,15836657,258,1675068125,0,0,1,1635370,0,0,0,0,209,0,0,0,0,1635370,0,1023,-1,-1,-1,-1),(705,942814777,0,30363228,15836657,258,1675068185,0,0,1,1635371,0,0,0,0,209,0,0,0,0,1635371,0,1023,-1,-1,-1,-1),(706,942814777,0,30363228,15836657,258,1675068245,0,0,1,1635372,0,0,0,0,209,0,0,0,0,1635372,0,1023,-1,-1,-1,-1),(707,942814777,0,30363228,15836657,258,1675068305,0,0,1,1635373,0,0,0,0,209,0,0,0,0,1635373,0,1023,-1,-1,-1,-1),(708,942814777,0,30363228,15836657,258,1675068365,0,0,1,1635374,0,0,0,0,209,0,0,0,0,1635374,0,1023,-1,-1,-1,-1),(709,942814777,0,30363228,15836657,258,1675068425,0,0,1,1635375,0,0,0,0,209,0,0,0,0,1635375,0,1023,-1,-1,-1,-1),(710,942814777,0,30363228,15836657,258,1675068485,0,0,1,1635376,0,0,0,0,209,0,0,0,0,1635376,0,1023,-1,-1,-1,-1),(711,942814777,0,30363228,15836657,258,1675068545,0,0,1,1635377,0,0,0,0,209,0,0,0,0,1635377,0,1023,-1,-1,-1,-1),(712,942814777,0,30363228,15836657,258,1675068605,0,0,1,1635378,0,0,0,0,209,0,0,0,0,1635378,0,1023,-1,-1,-1,-1),(713,942814777,0,30363228,15836657,258,1675068665,0,0,1,1635379,0,0,0,0,209,0,0,0,0,1635379,0,1023,-1,-1,-1,-1),(714,942814777,0,30363228,15836657,258,1675068725,0,0,1,1635380,0,0,0,0,209,0,0,0,0,1635380,0,1023,-1,-1,-1,-1),(715,942814777,0,30363228,15836657,258,1675068785,0,0,1,1635381,0,0,0,0,209,0,0,0,0,1635381,0,1023,-1,-1,-1,-1),(716,942814777,0,30363228,15836657,258,1675068845,0,0,1,1635382,0,0,0,0,209,0,0,0,0,1635382,0,1023,-1,-1,-1,-1),(717,942814777,0,30363228,15836657,258,1675068905,0,0,1,1635383,0,0,0,0,209,0,0,0,0,1635383,0,1023,-1,-1,-1,-1),(718,942814777,0,30363228,15836657,258,1675068965,0,0,1,1635384,0,0,0,0,209,0,0,0,0,1635384,0,1023,-1,-1,-1,-1),(719,942814777,0,30363228,15836657,258,1675069025,0,0,1,1635385,0,0,0,0,209,0,0,0,0,1635385,0,1023,-1,-1,-1,-1),(720,942814777,0,30363228,15836657,258,1675069085,0,0,1,1635386,0,0,0,0,209,0,0,0,0,1635386,0,1023,-1,-1,-1,-1),(721,942814777,0,30363228,15836657,258,1675069132,0,0,1,1635387,0,32,0,0,203,0,0,0,0,1635387,0,1023,-1,-1,-1,-1),(722,942814777,0,30363228,15836657,258,1675069192,0,0,1,1635388,0,32,0,0,242,0,0,0,0,1635388,0,1023,-1,-1,-1,-1),(723,942814777,0,30363228,15836657,258,1675069252,0,0,1,1635389,0,32,0,0,243,0,0,0,0,1635389,0,1023,-1,-1,-1,-1),(724,942814777,0,30363228,15836657,258,1675069312,0,0,1,1635390,0,32,0,0,243,0,0,0,0,1635390,0,1023,-1,-1,-1,-1),(725,942814777,0,30363228,15836657,258,1675069372,0,0,1,1635391,0,32,0,0,233,0,0,0,0,1635391,0,1023,-1,-1,-1,-1),(726,942814777,0,30363228,15836657,258,1675069373,0,0,1,1635392,0,0,0,0,232,0,0,0,0,1635392,0,1023,-1,-1,-1,-1),(727,942814777,0,30363228,15836657,258,1675069432,0,0,1,1635393,0,0,0,0,221,0,0,0,0,1635393,0,1023,-1,-1,-1,-1),(728,942814777,0,30363228,15836657,258,1675069492,0,0,1,1635394,0,0,0,0,219,0,0,0,0,1635394,0,1023,-1,-1,-1,-1),(729,942814777,0,30363228,15836657,258,1675069552,0,0,1,1635395,0,0,0,0,218,0,0,0,0,1635395,0,1023,-1,-1,-1,-1),(730,942814777,0,30363228,15836657,258,1675069612,0,0,1,1635396,0,0,0,0,217,0,0,0,0,1635396,0,1023,-1,-1,-1,-1),(731,942814777,0,30363228,15836657,258,1675069672,0,0,1,1635397,0,0,0,0,217,0,0,0,0,1635397,0,1023,-1,-1,-1,-1),(732,942814777,0,30363228,15836657,258,1675069732,0,0,1,1635398,0,0,0,0,217,0,0,0,0,1635398,0,1023,-1,-1,-1,-1),(733,942814777,0,30363228,15836657,258,1675069792,0,0,1,1635399,0,0,0,0,216,0,0,0,0,1635399,0,1023,-1,-1,-1,-1),(734,942814777,0,30363228,15836657,258,1675069852,0,0,1,1635400,0,0,0,0,216,0,0,0,0,1635400,0,1023,-1,-1,-1,-1),(735,942814777,0,30363228,15836657,258,1675069912,0,0,1,1635401,0,0,0,0,216,0,0,0,0,1635401,0,1023,-1,-1,-1,-1),(736,942814777,0,30363228,15836657,258,1675069972,0,0,1,1635402,0,0,0,0,216,0,0,0,0,1635402,0,1023,-1,-1,-1,-1),(737,942814777,0,30363228,15836657,258,1675070032,0,0,1,1635403,0,0,0,0,215,0,0,0,0,1635403,0,1023,-1,-1,-1,-1),(738,942814777,0,30363228,15836657,258,1675070092,0,0,1,1635404,0,0,0,0,213,0,0,0,0,1635404,0,1023,-1,-1,-1,-1),(739,942814777,0,30363228,15836657,258,1675070152,0,0,1,1635405,0,0,0,0,211,0,0,0,0,1635405,0,1023,-1,-1,-1,-1),(740,942814777,0,30363228,15836657,258,1675070212,0,0,1,1635406,0,0,0,0,211,0,0,0,0,1635406,0,1023,-1,-1,-1,-1),(741,942814777,0,29854988,13681380,208,1711534285,0,0,1,2360767,0,0,0,0,204,0,0,0,0,2360767,0,1023,-1,-1,-1,-1),(742,942814777,0,29854988,13681380,208,1711534345,0,0,1,2360768,0,0,0,0,204,0,0,0,0,2360768,0,1023,-1,-1,-1,-1),(743,942814777,0,29854988,13681380,208,1711534405,0,0,1,2360769,0,0,0,0,204,0,0,0,0,2360769,0,1023,-1,-1,-1,-1),(744,942814777,0,29854988,13681380,208,1711534465,0,0,1,2360770,0,0,0,0,204,0,0,0,0,2360770,0,1023,-1,-1,-1,-1),(745,942814777,0,29854988,13681380,208,1711534525,0,0,1,2360771,0,0,0,0,204,0,0,0,0,2360771,0,1023,-1,-1,-1,-1),(1662,909522486,0,30952065,13191873,128,1744098293,0,0,1,628648,0,0,131,13,193,213,192,0,0,628648,0,1023,-1,-1,-1,-1),(1663,909522486,0,30952065,13191873,128,1744098353,0,0,1,628649,0,0,131,13,193,213,192,0,0,628649,0,1023,-1,-1,-1,-1),(1664,909522486,0,30952065,13191873,128,1744098413,0,0,1,628650,0,0,131,13,193,213,192,0,0,628650,0,1023,-1,-1,-1,-1),(1665,909522486,0,30952065,13191873,128,1744098473,0,0,1,628651,0,0,131,13,193,213,192,0,0,628651,0,1023,-1,-1,-1,-1),(1666,909522486,0,30952065,13191873,128,1744098533,0,0,1,628652,0,0,131,13,193,213,192,0,0,628652,0,1023,-1,-1,-1,-1),(1667,909522486,0,30952065,13191873,128,1744098593,0,0,1,628653,0,0,131,13,193,213,192,0,0,628653,0,1023,-1,-1,-1,-1),(1668,909522486,0,30952065,13191873,128,1744098653,0,0,1,628654,0,0,131,13,177,213,192,0,0,628654,0,1023,-1,-1,-1,-1),(1669,909522486,0,30952065,13191873,128,1744098713,0,0,1,628655,0,0,131,13,161,213,192,0,0,628655,0,1023,-1,-1,-1,-1),(1670,909522486,0,30952065,13191873,128,1744098773,0,0,1,628656,0,0,131,13,161,213,192,0,0,628656,0,1023,-1,-1,-1,-1),(1671,909522486,0,30952065,13191873,128,1744098833,0,0,1,628657,0,0,131,13,145,213,192,0,0,628657,0,1023,-1,-1,-1,-1),(1672,909522486,0,30952065,13191873,128,1744098892,0,0,1,628658,0,0,131,13,129,213,192,0,0,628658,0,1023,-1,-1,-1,-1),(1673,909522486,0,30952065,13191873,128,1744098953,0,0,1,628659,0,0,131,13,129,213,192,0,0,628659,0,1023,-1,-1,-1,-1),(1674,909522486,0,30952065,13191873,128,1744099013,0,0,1,628660,0,0,131,13,129,213,192,0,0,628660,0,1023,-1,-1,-1,-1),(1675,909522486,0,30952065,13191873,128,1744099073,0,0,1,628661,0,0,131,13,161,213,192,0,0,628661,0,1023,-1,-1,-1,-1),(1676,909522486,0,30952065,13191873,128,1744099133,0,0,1,628662,0,0,131,13,161,213,176,0,0,628662,0,1023,-1,-1,-1,-1),(1677,909522486,0,30952065,13191873,128,1744099193,0,0,1,628663,0,0,131,13,161,213,176,0,0,628663,0,1023,-1,-1,-1,-1),(1678,909522486,0,30952065,13191873,128,1744099253,0,0,1,628664,0,0,131,13,177,213,176,0,0,628664,0,1023,-1,-1,-1,-1),(1679,909522486,0,30952065,13191873,128,1744099313,0,0,1,628665,0,0,131,13,177,213,176,0,0,628665,0,1023,-1,-1,-1,-1),(1680,909522486,0,30952065,13191873,128,1744099373,0,0,1,628666,0,0,131,13,177,213,176,0,0,628666,0,1023,-1,-1,-1,-1),(1681,909522486,0,30952065,13191873,128,1744099433,0,0,1,628667,0,0,131,13,193,213,176,0,0,628667,0,1023,-1,-1,-1,-1),(1682,909522486,0,30952065,13191873,128,1744099493,0,0,1,628668,0,0,131,13,193,213,176,0,0,628668,0,1023,-1,-1,-1,-1),(1683,909522486,0,30952065,13191873,128,1744099553,0,0,1,628669,0,0,131,13,193,213,176,0,0,628669,0,1023,-1,-1,-1,-1),(1684,909522486,0,30952065,13191873,128,1744099613,0,0,1,628670,0,0,131,13,193,213,176,0,0,628670,0,1023,-1,-1,-1,-1),(1685,909522486,0,30952065,13191873,128,1744099673,0,0,1,628671,0,0,131,13,193,213,176,0,0,628671,0,1023,-1,-1,-1,-1),(1686,909522486,0,30952065,13191873,128,1744099733,0,0,1,628672,0,0,131,13,193,213,176,0,0,628672,0,1023,-1,-1,-1,-1),(1687,909522486,0,30952065,13191873,128,1744099793,0,0,1,628673,0,0,131,13,193,213,176,0,0,628673,0,1023,-1,-1,-1,-1),(1688,909522486,0,30952065,13191873,128,1744099853,0,0,1,628674,0,0,131,29,193,213,192,0,0,628674,0,1023,-1,-1,-1,-1),(1689,909522486,0,30952065,13191873,128,1744099913,0,0,1,628675,0,0,131,29,193,213,192,0,0,628675,0,1023,-1,-1,-1,-1),(1690,909522486,0,30952065,13191873,128,1744099973,0,0,1,628676,0,0,131,29,193,213,192,0,0,628676,0,1023,-1,-1,-1,-1),(1691,909522486,0,30952065,13191873,128,1744100033,0,0,1,628677,0,0,131,29,193,213,192,0,0,628677,0,1023,-1,-1,-1,-1),(1692,909522486,0,30952065,13191873,128,1744100093,0,0,1,628678,0,0,131,29,177,213,192,0,0,628678,0,1023,-1,-1,-1,-1),(1693,909522486,0,30952065,13191873,128,1744100153,0,0,1,628679,0,0,131,45,193,213,192,0,0,628679,0,1023,-1,-1,-1,-1),(1694,909522486,0,30952065,13191873,128,1744100213,0,0,1,628680,0,0,131,45,193,213,192,0,0,628680,0,1023,-1,-1,-1,-1),(1695,909522486,0,30952065,13191873,128,1744100273,0,0,1,628681,0,0,131,45,161,213,192,0,0,628681,0,1023,-1,-1,-1,-1),(1696,909522486,0,30952065,13191873,128,1744100333,0,0,1,628682,0,0,131,45,161,213,192,0,0,628682,0,1023,-1,-1,-1,-1),(1697,909522486,0,30952065,13191873,128,1744100393,0,0,1,628683,0,0,131,45,177,213,192,0,0,628683,0,1023,-1,-1,-1,-1),(1698,909522486,0,30952065,13191873,128,1744100453,0,0,1,628684,0,0,131,45,161,213,192,0,0,628684,0,1023,-1,-1,-1,-1),(1699,909522486,0,30952065,13191873,128,1744100513,0,0,1,628685,0,0,131,45,161,213,192,0,0,628685,0,1023,-1,-1,-1,-1),(1700,909522486,0,30952065,13191873,128,1744100573,0,0,1,628686,0,0,131,45,161,213,192,0,0,628686,0,1023,-1,-1,-1,-1),(1701,909522486,0,30952065,13191873,128,1744100633,0,0,1,628687,0,0,131,45,161,213,192,0,0,628687,0,1023,-1,-1,-1,-1),(1702,909522486,0,30952065,13191873,128,1744100693,0,0,1,628688,0,0,131,45,161,213,192,0,0,628688,0,1023,-1,-1,-1,-1),(1703,909522486,0,30952065,13191873,128,1744100753,0,0,1,628689,0,0,131,45,161,213,192,0,0,628689,0,1023,-1,-1,-1,-1),(1704,909522486,0,30952065,13191873,128,1744100813,0,0,1,628690,0,0,131,45,161,213,192,0,0,628690,0,1023,-1,-1,-1,-1),(1705,909522486,0,30952065,13191873,128,1744100873,0,0,1,628691,0,0,131,45,177,213,192,0,0,628691,0,1023,-1,-1,-1,-1),(1706,909522486,0,30952065,13191873,128,1744100933,0,0,1,628692,0,0,131,45,193,213,192,0,0,628692,0,1023,-1,-1,-1,-1),(1707,909522486,0,30952065,13191873,128,1744100993,0,0,1,628693,0,0,131,45,193,213,192,0,0,628693,0,1023,-1,-1,-1,-1),(1708,909522486,0,30952065,13191873,128,1744101053,0,0,1,628694,0,0,131,45,209,213,192,0,0,628694,0,1023,-1,-1,-1,-1),(1709,909522486,0,30952065,13191873,128,1744101113,0,0,1,628695,0,0,131,45,209,213,192,0,0,628695,0,1023,-1,-1,-1,-1),(1710,909522486,0,30952065,13191873,128,1744101173,0,0,1,628696,0,0,131,45,209,213,192,0,0,628696,0,1023,-1,-1,-1,-1),(1711,909522486,0,30952065,13191873,128,1744101233,0,0,1,628697,0,0,131,45,209,213,192,0,0,628697,0,1023,-1,-1,-1,-1),(1712,909522486,0,30952065,13191873,128,1744101293,0,0,1,628698,0,0,131,45,209,213,192,0,0,628698,0,1023,-1,-1,-1,-1),(1713,909522486,0,30952065,13191873,128,1744101353,0,0,1,628699,0,0,131,45,209,213,192,0,0,628699,0,1023,-1,-1,-1,-1),(1714,909522486,0,30952065,13191873,128,1744101413,0,0,1,628700,0,0,131,45,209,213,192,0,0,628700,0,1023,-1,-1,-1,-1),(1715,909522486,0,30952065,13191873,128,1744101472,0,0,1,628701,0,0,131,45,209,213,192,0,0,628701,0,1023,-1,-1,-1,-1),(1716,909522486,0,30952065,13191873,128,1744101533,0,0,1,628702,0,0,131,45,209,213,192,0,0,628702,0,1023,-1,-1,-1,-1),(1717,909522486,0,30952065,13191873,128,1744101593,0,0,1,628703,0,0,131,45,209,213,192,0,0,628703,0,1023,-1,-1,-1,-1),(1718,909522486,0,30952065,13191873,128,1744101653,0,0,1,628704,0,0,131,45,209,213,192,0,0,628704,0,1023,-1,-1,-1,-1),(1719,909522486,0,30952065,13191873,128,1744101713,0,0,1,628705,0,0,131,45,209,213,192,0,0,628705,0,1023,-1,-1,-1,-1),(1720,909522486,0,30952065,13191873,128,1744101773,0,0,1,628706,0,0,131,45,209,213,208,0,0,628706,0,1023,-1,-1,-1,-1),(1721,909522486,0,30952065,13191873,128,1744101833,0,0,1,628707,0,0,131,45,193,213,208,0,0,628707,0,1023,-1,-1,-1,-1),(1722,909522486,0,30952065,13191873,128,1744101893,0,0,1,628708,0,0,131,45,177,213,208,0,0,628708,0,1023,-1,-1,-1,-1),(1723,909522486,0,30952065,13191873,128,1744101953,0,0,1,628709,0,0,131,45,177,213,208,0,0,628709,0,1023,-1,-1,-1,-1),(1724,909522486,0,30952065,13191873,128,1744102013,0,0,1,628710,0,0,131,45,161,213,208,0,0,628710,0,1023,-1,-1,-1,-1),(1725,909522486,0,30952065,13191873,128,1744102073,0,0,1,628711,0,0,131,45,161,213,208,0,0,628711,0,1023,-1,-1,-1,-1),(1726,909522486,0,30952065,13191873,128,1744102133,0,0,1,628712,0,0,131,45,161,213,208,0,0,628712,0,1023,-1,-1,-1,-1),(1727,909522486,0,30952065,13191873,128,1744102193,0,0,1,628713,0,0,131,45,161,213,208,0,0,628713,0,1023,-1,-1,-1,-1),(1728,909522486,0,30952065,13191873,128,1744102253,0,0,1,628714,0,0,131,45,161,213,208,0,0,628714,0,1023,-1,-1,-1,-1),(1729,909522486,0,30952065,13191873,128,1744102313,0,0,1,628715,0,0,131,45,161,213,208,0,0,628715,0,1023,-1,-1,-1,-1),(1730,909522486,0,30952065,13191873,128,1744102373,0,0,1,628716,0,0,131,61,161,213,208,0,0,628716,0,1023,-1,-1,-1,-1),(1731,909522486,0,30952065,13191873,128,1744102433,0,0,1,628717,0,0,131,61,177,213,208,0,0,628717,0,1023,-1,-1,-1,-1),(1732,909522486,0,30952065,13191873,128,1744102493,0,0,1,628718,0,0,131,61,193,213,208,0,0,628718,0,1023,-1,-1,-1,-1),(1733,909522486,0,30952065,13191873,128,1744102553,0,0,1,628719,0,0,131,61,193,213,208,0,0,628719,0,1023,-1,-1,-1,-1),(1734,909522486,0,30952065,13191873,128,1744102613,0,0,1,628720,0,0,131,61,193,213,208,0,0,628720,0,1023,-1,-1,-1,-1),(1735,909522486,0,30952065,13191873,128,1744102673,0,0,1,628721,0,0,131,61,209,213,208,0,0,628721,0,1023,-1,-1,-1,-1),(1736,909522486,0,30952065,13191873,128,1744102733,0,0,1,628722,0,0,131,45,193,213,208,0,0,628722,0,1023,-1,-1,-1,-1),(1737,909522486,0,30952065,13191873,128,1744102793,0,0,1,628723,0,0,131,45,209,213,208,0,0,628723,0,1023,-1,-1,-1,-1),(1738,909522486,0,30952065,13191873,128,1744102853,0,0,1,628724,0,0,131,29,209,213,208,0,0,628724,0,1023,-1,-1,-1,-1),(1739,909522486,0,30952065,13191873,128,1744102913,0,0,1,628725,0,0,131,13,209,213,208,0,0,628725,0,1023,-1,-1,-1,-1),(1740,909522486,0,30952065,13191873,128,1744102973,0,0,1,628726,0,0,131,13,209,213,208,0,0,628726,0,1023,-1,-1,-1,-1),(1741,909522486,0,30712668,14286958,177,1770911929,0,0,1,1223645,0,1,68,93,177,202,48,0,0,1223645,0,1023,-1,-1,-1,-1),(1742,909522486,0,30712668,14286958,177,1770911989,0,0,1,1223646,0,1,68,93,193,202,48,0,0,1223646,0,1023,-1,-1,-1,-1),(1743,909522486,0,30712668,14286958,177,1770912049,0,0,1,1223647,0,1,68,93,177,202,48,0,0,1223647,0,1023,-1,-1,-1,-1),(1744,909522486,0,30712668,14286958,177,1770912109,0,0,1,1223648,0,1,68,93,177,202,48,0,0,1223648,0,1023,-1,-1,-1,-1),(1745,909522486,0,30712668,14286958,177,1770912169,0,0,1,1223649,0,1,68,93,177,202,48,0,0,1223649,0,1023,-1,-1,-1,-1),(1746,909522486,0,30712668,14286958,177,1770912229,0,0,1,1223650,0,1,68,93,177,202,48,0,0,1223650,0,1023,-1,-1,-1,-1),(1747,909522486,0,30712668,14286958,177,1770912289,0,0,1,1223651,0,1,68,93,193,202,48,0,0,1223651,0,1023,-1,-1,-1,-1),(1748,909522486,0,30712668,14286958,177,1770912349,0,0,1,1223652,0,1,68,93,193,202,48,0,0,1223652,0,1023,-1,-1,-1,-1),(1749,909522486,0,30712668,14286958,177,1770912409,0,0,1,1223653,0,1,68,93,177,202,48,0,0,1223653,0,1023,-1,-1,-1,-1),(1750,909522486,0,30712668,14286958,177,1770912469,0,0,1,1223654,0,1,68,93,177,202,48,0,0,1223654,0,1023,-1,-1,-1,-1),(1751,909522486,0,30712668,14286958,177,1770912529,0,0,1,1223655,0,1,68,93,177,202,48,0,0,1223655,0,1023,-1,-1,-1,-1),(1752,909522486,0,30712668,14286958,177,1770912589,0,0,1,1223656,0,1,68,93,177,202,48,0,0,1223656,0,1023,-1,-1,-1,-1),(1753,909522486,0,30712668,14286958,177,1770912649,0,0,1,1223657,0,1,68,93,177,202,48,0,0,1223657,0,1023,-1,-1,-1,-1),(1754,909522486,0,30712668,14286958,177,1770912709,0,0,1,1223658,0,1,68,93,177,202,48,0,0,1223658,0,1023,-1,-1,-1,-1),(1755,909522486,0,30712668,14286958,177,1770912769,0,0,1,1223659,0,1,68,93,177,202,48,0,0,1223659,0,1023,-1,-1,-1,-1),(1756,909522486,0,30712668,14286958,177,1770912829,0,0,1,1223660,0,1,68,93,177,202,48,0,0,1223660,0,1023,-1,-1,-1,-1),(1757,909522486,0,30712668,14286958,177,1770912889,0,0,1,1223661,0,1,68,93,177,202,48,0,0,1223661,0,1023,-1,-1,-1,-1),(1758,909522486,0,30712668,14286958,177,1770912949,0,0,1,1223662,0,1,68,93,177,202,48,0,0,1223662,0,1023,-1,-1,-1,-1),(1759,909522486,0,30712668,14286958,177,1770913009,0,0,1,1223663,0,1,68,93,177,202,48,0,0,1223663,0,1023,-1,-1,-1,-1),(1760,909522486,0,30712668,14286958,177,1770913069,0,0,1,1223664,0,1,68,93,177,202,48,0,0,1223664,0,1023,-1,-1,-1,-1),(1761,909522486,0,30712668,14286958,177,1770913129,0,0,1,1223665,0,1,68,93,177,202,48,0,0,1223665,0,1023,-1,-1,-1,-1);

--
-- Table structure for table `online64`
--

CREATE TABLE `online64` (
  `DataGps_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РўРµР»РµС‚СЂРµРєР°',
  `Latitude` int(11) NOT NULL DEFAULT '0' COMMENT 'РЁРёСЂРѕС‚Р°',
  `Longitude` int(11) NOT NULL DEFAULT '0' COMMENT 'Р”РѕР»РіРѕС‚Р°',
  `Direction` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РіСЂР°РґСѓСЃС‹/1.5',
  `Acceleration` int(11) DEFAULT '0' COMMENT 'РР·РјРµРЅРµРЅРёРµ СЃРєРѕСЂРѕСЃС‚Рё РїРѕ GPS Р·Р° РїРѕСЃР»РµРґРЅСЋСЋ СЃРµРєСѓРЅРґСѓ',
  `UnixTime` int(11) NOT NULL DEFAULT '0',
  `Speed` smallint(6) NOT NULL DEFAULT '0' COMMENT 'РЎРѕС‚РµРЅ РјРµС‚СЂРѕРІ РІ С‡Р°СЃ (0,1 РєРј/С‡)',
  `Valid` tinyint(1) NOT NULL DEFAULT '1',
  `Satellites` tinyint(1) unsigned DEFAULT '0' COMMENT 'РљРѕР»РёС‡РµСЃС‚РІРѕ СЃРїСѓС‚РЅРёРєРѕРІ ',
  `RssiGsm` tinyint(1) unsigned DEFAULT '0' COMMENT 'РЈСЂРѕРІРµРЅСЊ GSM СЃРёРіРЅР°Р»Р°',
  `Events` int(11) DEFAULT '0' COMMENT 'Р¤Р»Р°РіРё СЃРѕР±С‹С‚РёР№',
  `SensorsSet` tinyint(1) DEFAULT '0' COMMENT 'РљРѕРґ РЅР°Р±РѕСЂР° РґР°С‚С‡РёРєРѕРІ',
  `Sensors` varbinary(50) DEFAULT '0' COMMENT 'Р—РЅР°С‡РµРЅРёСЏ РґР°С‚С‡РёРєРѕРІ',
  `Voltage` tinyint(4) unsigned DEFAULT '0' COMMENT 'РќР°РїСЂСЏР¶РµРЅРёРµ РїРёС‚Р°РЅРёСЏ С‚РµРєСѓС‰РµРіРѕ РёСЃС‚РѕС‡РЅРёРєР°/1.5 РѕС‚ 0 РґРѕ 38,2',
  `DGPS` varchar(32) DEFAULT NULL,
  `LogID` int(11) DEFAULT '0' COMMENT 'РРґРµРЅС‚РёС„РёРєР°С‚РѕСЂ Р·Р°РїРёСЃРё РІ Р¶СѓСЂРЅР°Р»Рµ РўРµР»РµС‚СЂРµРєР°',
  `SrvPacketID` bigint(20) NOT NULL DEFAULT '0' COMMENT 'ID СЃРµСЂРІРµСЂРЅРѕРіРѕ РїР°РєРµС‚Р° РІ СЃРѕСЃС‚Р°РІ РєРѕС‚РѕСЂРѕРіРѕ РІС…РѕРґРёС‚ СЌС‚Р° Р·Р°РїРёСЃСЊ',
  PRIMARY KEY (`DataGps_ID`),
  KEY `IDX_MobitelidUnixtimeValid64` (`Mobitel_ID`,`UnixTime`,`Valid`)
) ENGINE=InnoDB AUTO_INCREMENT=1636 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `online64`
--

INSERT INTO `online64` VALUES (1322,809055537,545483333,184986750,0,0,1744098188,0,1,15,0,0,0,_binary 'AAAO1t+iAABdZuQTRRDCAAAAAAAIzLsAAA==',175,'',2045184,3474867072064763136),(1324,809055537,545483333,184986750,0,0,1744098248,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZuETRhDCAAAAAAAIzLsAAA==',175,'',2045185,3474867072064763137),(1326,809055537,545483333,184986750,0,0,1744098308,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZtsTRhDCAAAAAAAIzLsAAA==',175,'',2045186,3474867072064763138),(1328,809055537,545483333,184986750,0,0,1744098368,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZtoTRhDCAAAAAAAIzLsAAA==',175,'',2045187,3474867072064763139),(1330,809055537,545483333,184986750,0,0,1744098428,0,1,15,0,0,0,_binary 'AAAO1t+iAABdZtITRhDCAAAAAAAIzLsAAA==',175,'',2045188,3474867072064763140),(1332,809055537,545483333,184986750,0,0,1744098488,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZtETRhDCAAAAAAAIzLsAAA==',175,'',2045189,3474867072064763141),(1334,809055537,545483333,184986750,0,0,1744098548,0,1,15,0,0,0,_binary 'AAAO1t+iAABdZswTRhDBAAAAAAAIzLsAAA==',175,'',2045190,3474867072064763142),(1336,809055537,545483333,184986750,0,0,1744098608,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZsUTRhDBAAAAAAAIzLsAAA==',175,'',2045191,3474867072064763143),(1338,809055537,545483333,184986750,0,0,1744098668,0,1,15,0,0,0,_binary 'AAAO1t+iAABdZsMTRxDBAAAAAAAIzLsAAA==',175,'',2045192,3474867072064763144),(1340,809055537,545483333,184986750,0,0,1744098728,0,1,15,0,0,0,_binary 'AAAO1t+iAABdZr4TRxDBAAAAAAAIzLsAAA==',175,'',2045193,3474867072064763145),(1342,809055537,545483333,184986750,0,0,1744098788,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZroTRxDBAAAAAAAIzLsAAA==',175,'',2045194,3474867072064763146),(1344,809055537,545483333,184986750,0,0,1744098848,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZrMTRxDBAAAAAAAIzLsAAA==',175,'',2045195,3474867072064763147),(1346,809055537,545483333,184986750,0,0,1744098908,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZqYTRxDBAAAAAAAIzLsAAA==',175,'',2045196,3474867072064763148),(1348,809055537,545483333,184986750,0,0,1744098968,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZqUTRxDBAAAAAAAIzLsAAA==',175,'',2045197,3474867072064763149),(1350,809055537,545483333,184986750,0,0,1744099028,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZqQTRxDAAAAAAAAIzLsAAA==',175,'',2045198,3474867072064763150),(1352,809055537,545483333,184986750,0,0,1744099088,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZp8TRxDAAAAAAAAIzLsAAA==',175,'',2045199,3474867072064763151),(1354,809055537,545483333,184986750,0,0,1744099148,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZpwTRxDAAAAAAAAIzLsAAA==',175,'',2045200,3474867072064763152),(1356,809055537,545483333,184986750,0,0,1744099208,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZpsTSBDAAAAAAAAIzLsAAA==',175,'',2045201,3474867072064763153),(1358,809055537,545483333,184986750,0,0,1744099268,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZpATSBDAAAAAAAAIzLsAAA==',175,'',2045202,3474867072064763154),(1360,809055537,545483333,184986750,0,0,1744099328,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZpATSBDAAAAAAAAIzLsAAA==',175,'',2045203,3474867072064763155),(1362,809055537,545483333,184986750,0,0,1744099388,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZpATSBDAAAAAAAAIzLsAAA==',175,'',2045204,3474867072064763156),(1364,809055537,545483333,184986750,0,0,1744099448,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZosTSBC/AAAAAAAIzLsAAA==',175,'',2045205,3474867072064763157),(1366,809055537,545483333,184986750,0,0,1744099508,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZooTSBC/AAAAAAAIzLsAAA==',175,'',2045206,3474867072064763158),(1368,809055537,545483333,184986750,0,0,1744099568,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZoETSBC/AAAAAAAIzLsAAA==',175,'',2045207,3474867072064763159),(1370,809055537,545483333,184986750,0,0,1744099628,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZn4TSBC/AAAAAAAIzLsAAA==',175,'',2045208,3474867072064763160),(1372,809055537,545483333,184986750,0,0,1744099688,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZngTSRC/AAAAAAAIzLsAAA==',175,'',2045209,3474867072064763161),(1374,809055537,545483333,184986750,0,0,1744099748,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZnYTSRC/AAAAAAAIzLsAAA==',175,'',2045210,3474867072064763162),(1376,809055537,545483333,184986750,0,0,1744099808,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZnITSRC/AAAAAAAIzLsAAA==',175,'',2045211,3474867072064763163),(1378,809055537,545483333,184986750,0,0,1744099868,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZm8TSRC+AAAAAAAIzLsAAA==',175,'',2045212,3474867072064763164),(1380,809055537,545483333,184986750,0,0,1744099928,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZmcTSRC+AAAAAAAIzLsAAA==',175,'',2045213,3474867072064763165),(1382,809055537,545483333,184986750,0,0,1744099988,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZmsTSRC+AAAAAAAIzLsAAA==',175,'',2045214,3474867072064763166),(1384,809055537,545483333,184986750,0,0,1744100048,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZmMTSRC+AAAAAAAIzLsAAA==',175,'',2045215,3474867072064763167),(1386,809055537,545483333,184986750,0,0,1744100108,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZmETSRC+AAAAAAAIzLsAAA==',175,'',2045216,3474867072064763168),(1388,809055537,545483333,184986750,0,0,1744100168,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZloTSRC+AAAAAAAIzLsAAA==',175,'',2045217,3474867072064763169),(1390,809055537,545483333,184986750,0,0,1744100228,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZZwTSRC+AAAAAAAIzLsAAA==',173,'',2045218,3474867072064763170),(1392,809055537,545483333,184986750,0,0,1744100288,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZYITSRC+AAAAAAAIzLsAAA==',173,'',2045219,3474867072064763171),(1394,809055537,545483333,184986750,0,0,1744100348,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZXQTSRC+AAAAAAAIzLsAAA==',173,'',2045220,3474867072064763172),(1396,809055537,545483333,184986750,0,0,1744100408,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZXQTSRC+AAAAAAAIzLsAAA==',173,'',2045221,3474867072064763173),(1398,809055537,545483333,184986750,0,0,1744100468,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZXQTSRC9AAAAAAAIzLsAAA==',173,'',2045222,3474867072064763174),(1400,809055537,545483333,184986750,0,0,1744100528,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZXcTSRC9AAAAAAAIzLsAAA==',173,'',2045223,3474867072064763175),(1402,809055537,545483333,184986750,0,0,1744100588,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZWQTSRC9AAAAAAAIzLsAAA==',173,'',2045224,3474867072064763176),(1404,809055537,545483333,184986750,0,0,1744100648,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZXITSRC9AAAAAAAIzLsAAA==',173,'',2045225,3474867072064763177),(1406,809055537,545483333,184986750,0,0,1744100708,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZXATSRC9AAAAAAAIzLsAAA==',173,'',2045226,3474867072064763178),(1408,809055537,545483333,184986750,0,0,1744100768,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZWwTSRC9AAAAAAAIzLsAAA==',173,'',2045227,3474867072064763179),(1410,809055537,545483333,184986750,0,0,1744100828,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZWcTShC9AAAAAAAIzLsAAA==',173,'',2045228,3474867072064763180),(1412,809055537,545483333,184986750,0,0,1744100888,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZWITShC9AAAAAAAIzLsAAA==',173,'',2045229,3474867072064763181),(1414,809055537,545483333,184986750,0,0,1744100948,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZWITShC9AAAAAAAIzLsAAA==',173,'',2045230,3474867072064763182),(1416,809055537,545483333,184986750,0,0,1744101007,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZV0TShC9AAAAAAAIzLsAAA==',173,'',2045231,3474867072064763183),(1418,809055537,545483333,184986750,0,0,1744101068,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZVgTShC8AAAAAAAIzLsAAA==',173,'',2045232,3474867072064763184),(1420,809055537,545483333,184986750,0,0,1744101128,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZVQTSxC8AAAAAAAIzLsAAA==',173,'',2045233,3474867072064763185),(1422,809055537,545483333,184986750,0,0,1744101188,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZUoTSxC8AAAAAAAIzLsAAA==',173,'',2045234,3474867072064763186),(1424,809055537,545483333,184986750,0,0,1744101248,0,1,18,0,0,0,_binary 'AAAO1t+iAABdZbMTSxC8AAAAAAAIzLsAAA==',173,'',2045235,3474867072064763187),(1426,809055537,545483333,184986750,0,0,1744101308,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZdETSxC8AAAAAAAIzLsAAA==',174,'',2045236,3474867072064763188),(1428,809055537,545483333,184986750,0,0,1744101368,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZeQTSxC8AAAAAAAIzLsAAA==',174,'',2045237,3474867072064763189),(1430,809055537,545483333,184986750,0,0,1744101428,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZeMTSxC8AAAAAAAIzLsAAA==',174,'',2045238,3474867072064763190),(1432,809055537,545483333,184986750,0,0,1744101488,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZeUTSxC8AAAAAAAIzLsAAA==',174,'',2045239,3474867072064763191),(1434,809055537,545483333,184986750,0,0,1744101548,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZeUTSxC7AAAAAAAIzLsAAA==',174,'',2045240,3474867072064763192),(1436,809055537,545483333,184986750,0,0,1744101608,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZekTSxC7AAAAAAAIzLsAAA==',174,'',2045241,3474867072064763193),(1438,809055537,545483333,184986750,0,0,1744101668,0,1,18,0,0,0,_binary 'AAAO1t+iAABdZeUTSxC7AAAAAAAIzLsAAA==',174,'',2045242,3474867072064763194),(1440,809055537,545483333,184986750,0,0,1744101728,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZeUTSxC7AAAAAAAIzLsAAA==',174,'',2045243,3474867072064763195),(1442,809055537,545483333,184986750,0,0,1744101788,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZeQTSxC7AAAAAAAIzLsAAA==',174,'',2045244,3474867072064763196),(1444,809055537,545483333,184986750,0,0,1744101848,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZeMTSxC7AAAAAAAIzLsAAA==',174,'',2045245,3474867072064763197),(1446,809055537,545483333,184986750,0,0,1744101907,0,1,17,0,0,0,_binary 'AAAO1t+iAABdZdkTSxC7AAAAAAAIzLsAAA==',174,'',2045246,3474867072064763198),(1448,809055537,545483333,184986750,0,0,1744101968,0,1,18,0,0,0,_binary 'AAAO1t+iAABdZdwTSxC7AAAAAAAIzLsAAA==',174,'',2045247,3474867072064763199),(1450,809055537,545483333,184986750,0,0,1744102028,0,1,18,0,0,0,_binary 'AAAO1t+iAABdZdkTSxC7AAAAAAAIzLsAAA==',174,'',2045248,3474867072064763200),(1452,809055537,545483333,184986750,0,0,1744102088,0,1,18,0,0,0,_binary 'AAAO1t+iAABdZeETSxC7AAAAAAAIzLsAAA==',174,'',2045249,3474867072064763201),(1455,809055537,545483333,184986750,0,0,1744102148,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZeQTSxC7AAAAAAAIzLsAAA==',174,'',2045250,3474867072064763202),(1456,809055537,545485766,184988533,0,0,1744102223,0,1,12,0,0,0,_binary 'AAAO1t+iAABdZPcTSxC7AAAAAAAIzLsAAA==',172,'',2045251,3474867072064763203),(1457,842283059,543804967,186943267,47,0,1744102227,0,1,21,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGMAAMLZP//AKcAAA==',0,'',791799,3617578192380630263),(1458,809055537,545485766,184988533,0,0,1744102283,0,1,16,0,0,0,_binary 'AAAO1t+iAABdZMsTSxC7AAAAAAAIzLsAAA==',172,'',2045252,3474867072064763204),(1459,842283059,543804967,186943267,47,0,1744102287,0,1,19,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGMAAMLZP//AKcAAA==',0,'',791800,3617578192380630264),(1460,809055537,545485766,184988533,0,0,1744102343,0,1,18,0,0,0,_binary 'AAAO1t+iAABdZLQTSxC7AAAAAAAIzLsAAA==',172,'',2045253,3474867072064763205),(1461,842283059,543804967,186943267,47,0,1744102347,0,1,20,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGMAAMLZP//AKcAAA==',0,'',791801,3617578192380630265),(1462,809055537,545485766,184988533,0,0,1744102403,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZX0TSxC7AAAAAAAIzLsAAA==',173,'',2045254,3474867072064763206),(1463,842283059,543804967,186943267,47,0,1744102407,0,1,20,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGMAAMLZP//AKcAAA==',0,'',791802,3617578192380630266),(1464,809055537,545485766,184988533,0,0,1744102463,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZZkTSxC7AAAAAAAIzLsAAA==',173,'',2045255,3474867072064763207),(1465,842283059,543804967,186943267,47,0,1744102467,0,1,20,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGMAAMLZP//AKcAAA==',0,'',791803,3617578192380630267),(1466,809055537,545485766,184988533,0,0,1744102523,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZa4TSxC7AAAAAAAIzLsAAA==',173,'',2045256,3474867072064763208),(1467,842283059,543804967,186943267,47,0,1744102527,0,1,20,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGMAAMLZP//AKcAAA==',0,'',791804,3617578192380630268),(1468,809055537,545485766,184988533,0,0,1744102583,0,1,20,0,0,0,_binary 'AAAO1t+iAABdZbQTSxC7AAAAAAAIzLsAAA==',173,'',2045257,3474867072064763209),(1469,842283059,543804967,186943267,47,0,1744102587,0,1,21,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791805,3617578192380630269),(1470,809055537,545485766,184988533,0,0,1744102643,0,1,20,0,0,0,_binary 'AAAO1t+iAABdZbsTTBC7AAAAAAAIzLsAAA==',173,'',2045258,3474867072064763210),(1471,842283059,543804967,186943267,47,0,1744102647,0,1,20,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791806,3617578192380630270),(1472,809055537,545485766,184988533,0,0,1744102703,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZbwTTBC7AAAAAAAIzLsAAA==',173,'',2045259,3474867072064763211),(1473,842283059,543804967,186943267,47,0,1744102707,0,1,21,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791807,3617578192380630271),(1474,809055537,545485766,184988533,0,0,1744102763,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZbwTTBC7AAAAAAAIzLsAAA==',173,'',2045260,3474867072064763212),(1475,842283059,543804967,186943267,47,0,1744102767,0,1,20,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791808,3617578192380630272),(1476,842283059,543804967,186943267,47,0,1744102826,0,1,19,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791809,3617578192380630273),(1477,809055537,545485766,184988533,0,0,1744102867,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZaUTTBC6AAAAAAAIzLsAAA==',173,'',2045261,3474867072064763213),(1478,842283059,543804967,186943267,47,0,1744102887,0,1,19,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791810,3617578192380630274),(1479,809055537,545485766,184988533,0,0,1744102927,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZa4TTBC6AAAAAAAIzLsAAA==',173,'',2045262,3474867072064763214),(1480,842283059,543804967,186943267,47,0,1744102947,0,1,20,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791811,3617578192380630275),(1481,809055537,545485766,184988533,0,0,1744102987,0,1,19,0,0,0,_binary 'AAAO1t+iAABdZbITTBC6AAAAAAAIzLsAAA==',173,'',2045263,3474867072064763215),(1482,842283059,543804967,186943267,47,0,1744103007,0,1,21,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791812,3617578192380630276),(1483,842283059,543804967,186943267,47,0,1744103067,0,1,21,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791813,3617578192380630277),(1484,842283059,543804967,186943267,47,0,1744103126,0,1,18,0,0,0,_binary 'AAAJb1mrAAAAABgSuxGLAAMLZP//AKcAAA==',0,'',791814,3617578192380630278),(1485,842283059,506741283,263083017,234,0,1770911914,750,1,12,0,0,0,_binary 'EAAKX28PAAAAABwAAP//AANiQP//Zk4gKQ==',0,'',1385522,3617578192381223986),(1486,842283059,506756850,263080950,1,-1,1770911924,400,1,16,0,0,0,_binary 'EAAKX28wAAAAABwAAP//AANiQP//Zk4akA==',0,'',1385523,3617578192381223987),(1487,842283059,506758900,263081250,11,-1,1770911926,350,1,13,0,0,0,_binary 'EAAKX280AAAAABwZAf//AANiQP//Zk4ZlA==',0,'',1385524,3617578192381223988),(1488,842283059,506760417,263082383,20,0,1770911928,350,1,14,0,0,0,_binary 'EAAKX284AAAAABwZAf//AANiQP//Zk4f4Q==',0,'',1385525,3617578192381223989),(1489,842283059,506762567,263084433,11,0,1770911931,340,1,14,0,0,0,_binary 'EAAKX289AAAAABwAAP//AANiQP//Zk4fzA==',0,'',1385526,3617578192381223990),(1490,842283059,506763400,263084717,5,-1,1770911932,320,1,14,0,0,0,_binary 'EAAKX28/AAAAABwAAP//AANiQP//Zk4hMA==',0,'',1385527,3617578192381223991),(1491,842283059,506764183,263084733,238,0,1770911933,330,1,15,0,0,0,_binary 'EAAKX29BAAAAABwAAP//AANiQP//Zk4gUw==',0,'',1385528,3617578192381223992),(1492,842283059,506766750,263084867,8,0,1770911936,360,1,14,0,0,0,_binary 'EAAKX29HAAAAABwAAP//AANiQP//Zk8kJg==',0,'',1385529,3617578192381223993),(1493,842283059,506767717,263085483,16,0,1770911937,370,1,16,0,0,0,_binary 'EAAKX29JAAAAABwZAf//AANiQP//Zk8nkQ==',0,'',1385530,3617578192381223994),(1494,842283059,506769283,263087567,22,1,1770911939,450,1,17,0,0,0,_binary 'EAAKX29PAAAAAB0ZAf//AANiQP//Zk8u3g==',0,'',1385531,3617578192381223995),(1495,942879286,510229575,284808273,198,0,1770911913,880,1,11,0,0,0,_binary 'EAAKl8qEAACoAB0AAAzLAAAAAAAH2YUlOw==',0,'',586546,4049635697446417202),(1496,942879286,510250173,284745290,198,0,1770911933,900,1,9,0,0,0,_binary 'EAAKl8roAACoAB0AAAzMAAAAAAAH2YUlHg==',0,'',586547,4049635697446417203),(1497,942879286,510270213,284682012,198,0,1770911953,880,1,10,0,0,0,_binary 'EAAKl8tMAACoAB0AAAzNAAAAAAAH2YUlVw==',0,'',586548,4049635697446417204),(1498,809055537,484161000,227049500,0,0,1770911952,0,1,17,0,0,0,_binary 'AAAPv/7/AAAfYXEZEhX8AAAAAAAJXR0AAA==',166,'',2612580,3474867072065330532),(1499,842283059,506807333,263127633,23,0,1770911965,840,1,14,0,0,0,_binary 'EAAKX2+2AAAAAB0AAP//AANiQP//Zk8lew==',0,'',1385532,3617578192381223996),(1500,842283059,506845983,263169050,22,0,1770911986,880,1,17,0,0,0,_binary 'EAAKX3AcAAAAAB0ZAf//AANiQP//Zk8nUg==',0,'',1385533,3617578192381223997),(1501,842283059,506884917,263210283,23,0,1770912007,880,1,13,0,0,0,_binary 'EAAKX3CEAAAAAB0ZAf//AANiQP//Zk8nKQ==',0,'',1385534,3617578192381223998),(1502,942879286,510290317,284619490,197,0,1770911973,890,1,9,0,0,0,_binary 'EAAKl8uwAACpAB0AAAzNAAAAAAAH2YYlug==',0,'',586549,4049635697446417205),(1503,942879286,510311465,284554100,199,0,1770911994,890,1,9,0,0,0,_binary 'EAAKl8wZAACoAB0AAAzOAAAAAAAH2YYlqA==',0,'',586550,4049635697446417206),(1504,942879286,510332120,284491682,198,0,1770912014,900,1,8,0,0,0,_binary 'EAAKl8x9AACoAB0AAAzQAAAAAAAH2YYlPg==',0,'',586551,4049635697446417207),(1505,809055537,484161000,227049500,0,0,1770912011,0,1,16,0,0,0,_binary 'AAAPv/7/AAAfYWgZEhX8AAAAAAAJXR0AAA==',166,'',2612581,3474867072065330533),(1506,842283059,506922550,263250250,23,0,1770912027,900,1,13,0,0,0,_binary 'EAAKX3DoAAAAAB0ZAv//AANiQP//Zk8n0A==',0,'',1385535,3617578192381223999),(1507,842283059,506960833,263289117,20,0,1770912047,900,1,12,0,0,0,_binary 'EAAKX3FMAAAAAB0AAP//AANiQP//Zk8nlg==',0,'',1385536,3617578192381224000),(1508,842283059,506978833,263303483,14,0,1770912056,880,1,12,0,0,0,_binary 'EAAKX3F5AAAAAB0AAP//AANiQP//Zk8mYg==',0,'',1385537,3617578192381224001),(1509,942879286,510352447,284428608,197,0,1770912034,880,1,7,0,0,0,_binary 'EAAKl8zhAACnAB0AAAzRAAAAAAAH2YcleA==',0,'',586552,4049635697446417208),(1510,942879286,510372697,284365733,197,0,1770912054,890,1,10,0,0,0,_binary 'EAAKl81FAACmAB0AAAzSAAAAAAAH2YclxA==',0,'',586553,4049635697446417209),(1511,942879286,510393278,284302817,199,0,1770912074,900,1,11,0,0,0,_binary 'EAAKl82pAACmAB0AAAzSAAAAAAAH2YcloQ==',0,'',586554,4049635697446417210),(1512,809055537,484161000,227049500,0,0,1770912072,0,1,17,0,0,0,_binary 'AAAPv/7/AAAfYWEZEhX8AAAAAAAJXR0AAA==',166,'',2612582,3474867072065330534),(1513,842283059,507022900,263327767,12,0,1770912077,870,1,11,0,0,0,_binary 'EAAKX3HgAAAAAB0AAP//AANiQf//Zk8m+A==',0,'',1385538,3617578192381224002),(1514,842283059,507067083,263351050,12,0,1770912098,870,1,14,0,0,0,_binary 'EAAKX3JIAAAAAB0ZC///AANiQf//Zk8nRw==',0,'',1385539,3617578192381224003),(1515,842283059,507087717,263361783,19,0,1770912108,840,1,14,0,0,0,_binary 'EAAKX3J3AAAAAB0ZDP//AANiQf//Zk8kvg==',0,'',1385540,3617578192381224004),(1516,842283059,507099717,263374567,25,0,1770912115,820,1,11,0,0,0,_binary 'EAAKX3KYAAAAAB0AAP//AANiQf//Zk8lGg==',0,'',1385541,3617578192381224005),(1517,842283059,507110083,263390600,32,0,1770912122,810,1,13,0,0,0,_binary 'EAAKX3K4AAAAAB0AAP//AANiQf//Zk8jbQ==',0,'',1385542,3617578192381224006),(1518,842283059,507116150,263402717,39,0,1770912127,800,1,13,0,0,0,_binary 'EAAKX3LOAAAAAB0ZDP//AANiQf//Zk8k3Q==',0,'',1385543,3617578192381224007),(1519,942879286,510414598,284237883,198,0,1770912095,880,1,11,0,0,0,_binary 'EAAKl84SAAClAB0AAAzTAAAAAAAH2Yclew==',0,'',586555,4049635697446417211),(1520,942879286,510434813,284175098,198,0,1770912115,880,1,10,0,0,0,_binary 'EAAKl852AACmAB0AAAzUAAAAAAAH2YglgA==',0,'',586556,4049635697446417212),(1521,942879286,510455218,284112820,198,0,1770912135,880,1,10,0,0,0,_binary 'EAAKl87aAACmAB0AAAzVAAAAAAAH2YglMA==',0,'',586557,4049635697446417213),(1522,809055537,484161000,227049500,0,0,1770912132,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYWoZEhX8AAAAAAAJXR0AAA==',166,'',2612583,3474867072065330535),(1523,842283059,507122800,263424817,45,0,1770912134,870,1,14,0,0,0,_binary 'EAAKX3LwAAAAAB0AAP//AANiQf//Zk8nJA==',0,'',1385544,3617578192381224008),(1524,842283059,507137083,263492400,45,0,1770912155,840,1,13,0,0,0,_binary 'EAAKX3NVAAAAAB0AAP//AANiQf//Zk8k+w==',0,'',1385545,3617578192381224009),(1525,842283059,507153800,263559033,46,0,1770912176,840,1,17,0,0,0,_binary 'EAAKX3O5AAAAAB0AAP//AANiQf//Zk8kdA==',0,'',1385546,3617578192381224010),(1526,942879286,510475520,284050102,199,0,1770912155,900,1,9,0,0,0,_binary 'EAAKl88+AACmAB0AAAzWAAAAAAAH2YglvA==',0,'',586558,4049635697446417214),(1527,942879286,510495603,283987315,197,0,1770912175,880,1,10,0,0,0,_binary 'EAAKl8+iAAClAB0AAAzXAAAAAAAH2YgluQ==',0,'',586559,4049635697446417215),(1528,942879286,510516807,283922038,198,0,1770912196,840,1,10,0,0,0,_binary 'EAAKl9AKAAClAB0AAAzXAAAAAAAH2YkkPg==',0,'',586560,4049635697446417216),(1529,809055537,484161000,227049500,0,0,1770912192,0,1,17,0,0,0,_binary 'AAAPv/7/AAAfYWwZEhX8AAAAAAAJXR0AAA==',166,'',2612584,3474867072065330536),(1530,842283059,507171550,263620083,40,0,1770912196,800,1,12,0,0,0,_binary 'EAAKX3QYAAAAAB0ZD///AANiQf//ZlAlig==',0,'',1385547,3617578192381224011),(1531,842283059,507185017,263649500,34,0,1770912207,810,1,13,0,0,0,_binary 'EAAKX3RLAAAAAB0ZEf//AANiQf//ZlAkFA==',0,'',1385548,3617578192381224012),(1532,842283059,507194600,263665733,28,0,1770912214,840,1,13,0,0,0,_binary 'EAAKX3RsAAAAAB0AAP//AANiQf//ZlAkug==',0,'',1385549,3617578192381224013),(1533,842283059,507216533,263691633,22,0,1770912227,850,1,13,0,0,0,_binary 'EAAKX3SnAAAAAB0AAP//AANiQf//ZlAlDg==',0,'',1385550,3617578192381224014),(1534,842283059,507246550,263719183,16,0,1770912244,810,1,14,0,0,0,_binary 'EAAKX3TyAAAAAB0AAP//AANiQf//ZlAjsw==',0,'',1385551,3617578192381224015),(1535,942879286,510538112,283857403,198,0,1770912217,860,1,10,0,0,0,_binary 'EAAKl9BxAAClAB0AAAzXAAAAAAAH2YkkyA==',0,'',586561,4049635697446417217),(1536,942879286,510558260,283794797,197,0,1770912237,880,1,9,0,0,0,_binary 'EAAKl9DVAAClAB0AAAzXAAAAAAAH2YklcQ==',0,'',586562,4049635697446417218),(1537,942879286,510577300,283731185,195,0,1770912257,890,1,11,0,0,0,_binary 'EAAKl9E5AACmAB0AAAzYAAAAAAAH2YolpA==',0,'',586563,4049635697446417219),(1538,809055537,484161000,227049500,0,0,1770912252,0,1,17,0,0,0,_binary 'AAAPv/7/AAAfYWwZEhX8AAAAAAAJXR0AAA==',166,'',2612585,3474867072065330537),(1539,842283059,507290550,263743967,13,0,1770912267,800,1,13,0,0,0,_binary 'EAAKX3VaAAAAAB0AAP//AANiQv//ZlAjgA==',0,'',1385552,3617578192381224016),(1540,842283059,507333217,263768100,12,0,1770912292,680,1,14,0,0,0,_binary 'EAAKX3W+AAAAAB0AAP//AANiQv//ZlAexw==',0,'',1385553,3617578192381224017),(1541,842283059,507346050,263772350,6,0,1770912299,750,1,16,0,0,0,_binary 'EAAKX3XaAAAAAB0ZGP//AANiQv//ZlAiFQ==',0,'',1385554,3617578192381224018),(1542,842283059,507358817,263773600,0,0,1770912306,790,1,15,0,0,0,_binary 'EAAKX3X4AAAAABwAAP//AANiQv//ZlAifA==',0,'',1385555,3617578192381224019),(1543,942879286,510591823,283664852,191,0,1770912277,890,1,11,0,0,0,_binary 'EAAKl9GdAAClAB0AAAzZAAAAAAAH2YolVw==',0,'',586564,4049635697446417220),(1544,942879286,510604985,283597593,191,0,1770912297,880,1,11,0,0,0,_binary 'EAAKl9IBAAClAB0AAAzbAAAAAAAH2YolPQ==',0,'',586565,4049635697446417221),(1545,942879286,510618182,283530792,191,0,1770912317,880,1,11,0,0,0,_binary 'EAAKl9JlAAClAB0AAAzdAAAAAAAH2Yolag==',0,'',586566,4049635697446417222),(1546,809055537,484161000,227049500,0,0,1770912312,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYWAZEhX8AAAAAAAJXR0AAA==',166,'',2612586,3474867072065330538),(1547,842283059,507387983,263774367,7,0,1770912321,780,1,16,0,0,0,_binary 'EAAKX3Y6AAAAAB0ZGf//AANiQv//ZlEiEg==',0,'',1385556,3617578192381224020),(1548,842283059,507401433,263779283,13,0,1770912328,760,1,15,0,0,0,_binary 'EAAKX3ZYAAAAAB0AAP//AANiQv//ZlEiaQ==',0,'',1385557,3617578192381224021),(1549,842283059,507409983,263786383,20,0,1770912333,770,1,15,0,0,0,_binary 'EAAKX3ZtAAAAAB0AAP//AANiQv//ZlEjSw==',0,'',1385558,3617578192381224022),(1550,842283059,507446867,263826317,23,0,1770912355,840,1,17,0,0,0,_binary 'EAAKX3bSAAAAAB0ZGv//AANiQv//ZlEk0g==',0,'',1385559,3617578192381224023),(1551,942879286,510631142,283463470,191,0,1770912337,890,1,12,0,0,0,_binary 'EAAKl9LJAAClAB0AAAzeAAAAAAAH2Ysliw==',0,'',586567,4049635697446417223),(1552,942879286,510644118,283395432,191,0,1770912357,900,1,10,0,0,0,_binary 'EAAKl9MtAAClAB0AAAzfAAAAAAAH2Yslwg==',0,'',586568,4049635697446417224),(1553,942879286,510657195,283328458,191,0,1770912377,880,1,11,0,0,0,_binary 'EAAKl9ORAACmAB0AAAzgAAAAAAAH2YslYA==',0,'',586569,4049635697446417225),(1554,809055537,484161000,227049500,0,0,1770912371,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYPcZEhX8AAAAAAAJXR0AAA==',165,'',2612587,3474867072065330539),(1555,842283059,507485017,263868117,21,0,1770912377,840,1,15,0,0,0,_binary 'EAAKX3c5AAAAAB0ZGv//AANiQv//ZlElug==',0,'',1385560,3617578192381224024),(1556,842283059,507522817,263909617,22,0,1770912399,840,1,17,0,0,0,_binary 'EAAKX3efAAAAAB0ZHf//AANiQv//ZlEkmA==',0,'',1385561,3617578192381224025),(1557,842283059,507560800,263950517,23,0,1770912421,830,1,15,0,0,0,_binary 'EAAKX3gFAAAAAB0ZI///AANiQ///ZlEkzA==',0,'',1385562,3617578192381224026),(1558,942879286,510670447,283261177,191,0,1770912397,880,1,9,0,0,0,_binary 'EAAKl9P1AAClAB0AAAzhAAAAAAAH2Ywlhw==',0,'',586570,4049635697446417226),(1559,942879286,510683392,283193275,191,0,1770912417,880,1,10,0,0,0,_binary 'EAAKl9RZAAClAB0AAAziAAAAAAAH2Ywljw==',0,'',586571,4049635697446417227),(1560,942879286,510696402,283125763,191,0,1770912437,890,1,11,0,0,0,_binary 'EAAKl9S9AACkAB0AAAzjAAAAAAAH2YwllA==',0,'',586572,4049635697446417228),(1561,809055537,484161000,227049500,0,0,1770912432,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYW8ZEhX8AAAAAAAJXR0AAA==',166,'',2612588,3474867072065330540),(1562,842283059,507598983,263992267,23,0,1770912444,800,1,16,0,0,0,_binary 'EAAKX3hsAAAAAB0ZKP//AANiQ///ZlEjZQ==',0,'',1385563,3617578192381224027),(1563,842283059,507636750,264033367,23,0,1770912470,570,1,18,0,0,0,_binary 'EAAKX3jRAAAAAB0AAP//AANiQ///ZlEgdg==',0,'',1385564,3617578192381224028),(1564,942879286,510709442,283058312,191,0,1770912457,890,1,10,0,0,0,_binary 'EAAKl9UhAACkAB0AAAzkAAAAAAAH2Y0lZA==',0,'',586573,4049635697446417229),(1565,942879286,510723317,282987982,191,0,1770912478,910,1,12,0,0,0,_binary 'EAAKl9WKAACkAB0AAAzlAAAAAAAH2Y0lnQ==',0,'',586574,4049635697446417230),(1566,942879286,510736623,282917565,190,0,1770912499,890,1,11,0,0,0,_binary 'EAAKl9XzAACkAB0AAAzmAAAAAAAH2Y0lcg==',0,'',586575,4049635697446417231),(1567,809055537,484161000,227049500,0,0,1770912492,0,1,19,0,0,0,_binary 'AAAPv/7/AAAfYW4ZEhX8AAAAAAAJXR0AAA==',166,'',2612589,3474867072065330541),(1568,842283059,507674517,264075050,22,0,1770912497,780,1,16,0,0,0,_binary 'EAAKX3k3AAAAAB0ZL///AANiQ///ZlIjiQ==',0,'',1385565,3617578192381224029),(1569,842283059,507712500,264116400,23,0,1770912519,890,1,16,0,0,0,_binary 'EAAKX3meAAAAAB0ZMf//AANiQ///ZlInRQ==',0,'',1385566,3617578192381224030),(1570,842283059,507749267,264157167,23,0,1770912539,890,1,18,0,0,0,_binary 'EAAKX3oBAAAAAB0AAP//AANiQ///ZlIn3A==',0,'',1385567,3617578192381224031),(1571,942879286,510749545,282849805,191,0,1770912519,880,1,12,0,0,0,_binary 'EAAKl9ZcAACkAB0AAAzmAAAAAAAH2Y0lZw==',0,'',586576,4049635697446417232),(1572,942879286,510763143,282782212,192,0,1770912539,890,1,14,0,0,0,_binary 'EAAKl9a7AACjAB0AAAznAAAAAAAH2Y0lcA==',0,'',586577,4049635697446417233),(1573,942879286,510779167,282713860,195,0,1770912560,890,1,15,0,0,0,_binary 'EAAKl9ckAACjAB0AAAzoAAAAAAAH2Y4lhw==',0,'',586578,4049635697446417234),(1574,809055537,484161000,227049500,0,0,1770912552,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYW8ZEhX8AAAAAAAJXR0AAA==',166,'',2612590,3474867072065330542),(1575,842283059,507786117,264197117,23,0,1770912559,870,1,15,0,0,0,_binary 'EAAKX3pkAAAAABwAAP//AANiQ///ZlImqA==',0,'',1385568,3617578192381224032),(1576,842283059,507822767,264238133,23,0,1770912579,890,1,14,0,0,0,_binary 'EAAKX3rIAAAAABwZOP//AANiQ///ZlIneA==',0,'',1385569,3617578192381224033),(1577,842283059,507861500,264279967,23,0,1770912600,910,1,14,0,0,0,_binary 'EAAKX3swAAAAABwZOf//AANiRP//ZlIn0A==',0,'',1385570,3617578192381224034),(1578,942879286,510797563,282648915,196,0,1770912580,880,1,12,0,0,0,_binary 'EAAKl9eIAACkAB0AAAzpAAAAAAAH2Y4llQ==',0,'',586579,4049635697446417235),(1579,942879286,510816805,282582055,196,0,1770912601,900,1,12,0,0,0,_binary 'EAAKl9fxAACjAB0AAAzqAAAAAAAH2Y4lzg==',0,'',586580,4049635697446417236),(1580,942879286,510835350,282517492,197,0,1770912621,890,1,12,0,0,0,_binary 'EAAKl9hVAACjAB0AAAzrAAAAAAAH2Y8lWQ==',0,'',586581,4049635697446417237),(1581,809055537,484161000,227049500,0,0,1770912612,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYWkZEhX8AAAAAAAJXR0AAA==',166,'',2612591,3474867072065330543),(1582,842283059,507898567,264320983,23,0,1770912620,900,1,17,0,0,0,_binary 'EAAKX3uUAAAAABwZOv//AANiRP//ZlImsg==',0,'',1385571,3617578192381224035),(1583,842283059,507936067,264362467,23,0,1770912641,830,1,15,0,0,0,_binary 'EAAKX3v5AAAAABwAAP//AANiRP//ZlIjfA==',0,'',1385572,3617578192381224036),(1584,842283059,507973667,264402550,22,0,1770912664,760,1,12,0,0,0,_binary 'EAAKX3xeAAAAABwAAP//AANiRP//ZlIh8A==',0,'',1385573,3617578192381224037),(1585,942879286,510854063,282453338,196,0,1770912641,870,1,12,0,0,0,_binary 'EAAKl9i5AACjAB0AAAzrAAAAAAAH2Y8lbQ==',0,'',586582,4049635697446417238),(1586,942879286,510872488,282389027,198,-1,1770912669,260,1,12,0,0,0,_binary 'EAAKl9khAACiAB0AAAztAAAAAAAH2Y8bRQ==',0,'',586583,4049635697446417239),(1587,942879286,510874095,282384227,0,-1,1770912682,0,1,12,0,0,0,_binary 'EAAKl9kqAAChABwAAAzuAAAAAAAH2Y8StA==',0,'',586584,4049635697446417240),(1588,809055537,484161000,227049500,0,0,1770912672,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYVUZEhX8AAAAAAAJXR0AAA==',166,'',2612592,3474867072065330544),(1589,842283059,508002833,264427650,16,0,1770912680,860,1,15,0,0,0,_binary 'EAAKX3yoAAAAABwZPf//AANiRP//ZlIm2g==',0,'',1385574,3617578192381224038),(1590,842283059,508045917,264455950,14,0,1770912701,900,1,13,0,0,0,_binary 'EAAKX30QAAAAABwZPf//AANiRP//ZlIn2w==',0,'',1385575,3617578192381224039),(1591,842283059,508088067,264481600,14,0,1770912721,910,1,14,0,0,0,_binary 'EAAKX31zAAAAABwZQP//AANiRP//ZlMnqw==',0,'',1385576,3617578192381224040),(1592,942879286,510874095,282384227,0,0,1770912742,0,1,16,0,0,0,_binary 'EAAKl9kqAACiAB0AAAzvAAAAAAAH2Y8Sww==',0,'',586585,4049635697446417241),(1593,809055537,484161000,227049500,0,0,1770912732,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYW0ZEhX8AAAAAAAJXR0AAA==',166,'',2612593,3474867072065330545),(1594,842283059,508129800,264507817,14,0,1770912741,880,1,13,0,0,0,_binary 'EAAKX33XAAAAABwAAP//AANiRP//ZlMntg==',0,'',1385577,3617578192381224041),(1595,842283059,508173317,264535100,14,0,1770912762,870,1,12,0,0,0,_binary 'EAAKX34/AAAAABwAAP//AANiRP//ZlMmrg==',0,'',1385578,3617578192381224042),(1596,842283059,508214900,264561367,15,0,1770912782,900,1,13,0,0,0,_binary 'EAAKX36iAAAAABwAAP//AANiRP//ZlMntw==',0,'',1385579,3617578192381224043),(1597,942879286,510874095,282384227,0,0,1770912802,0,1,13,0,0,0,_binary 'EAAKl9kqAACiAB0AAAzvAAAAAAAH2Y8Swg==',0,'',586586,4049635697446417242),(1598,809055537,484161000,227049500,0,0,1770912792,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYWwZEhX8AAAAAAAJXR0AAA==',166,'',2612594,3474867072065330546),(1599,842283059,508256750,264587733,15,0,1770912802,890,1,13,0,0,0,_binary 'EAAKX38GAAAAABwZSP//AANiRf//ZlMnkw==',0,'',1385580,3617578192381224044),(1600,842283059,508298500,264613950,14,0,1770912822,860,1,10,0,0,0,_binary 'EAAKX39oAAAAABwZSv//AANiRf//ZlMkmQ==',0,'',1385581,3617578192381224045),(1601,842283059,508340067,264640350,13,0,1770912846,540,1,11,0,0,0,_binary 'EAAKX3/JAAAAABwZS///AANiRf//ZlMfAQ==',0,'',1385582,3617578192381224046),(1602,842283059,508343850,264641833,5,0,1770912849,520,1,12,0,0,0,_binary 'EAAKX3/TAAAAAB0AAP//AANiRf//ZlMgxQ==',0,'',1385583,3617578192381224047),(1603,842283059,508346450,264642033,239,0,1770912851,520,1,12,0,0,0,_binary 'EAAKX3/ZAAAAAB0AAP//AANiRf//ZlMgwQ==',0,'',1385584,3617578192381224048),(1604,942879286,510874095,282384227,0,0,1770912862,0,1,11,0,0,0,_binary 'EAAKl9kqAACiAB0AAAzvAAAAAAAH2Y8Swg==',0,'',586587,4049635697446417243),(1605,809055537,484161000,227049500,0,0,1770912852,0,1,17,0,0,0,_binary 'AAAPv/7/AAAfYWcZEhX8AAAAAAAJXR0AAA==',166,'',2612595,3474867072065330547),(1606,842283059,508392133,264636850,237,0,1770912882,550,1,13,0,0,0,_binary 'EAAKX4A+AAAAAB0AAP//AANiRf//ZlMe7A==',0,'',1385585,3617578192381224049),(1607,842283059,508403350,264636433,5,0,1770912891,420,1,13,0,0,0,_binary 'EAAKX4BWAAAAAB0ZTf//AANiRf//ZlMabw==',0,'',1385586,3617578192381224050),(1608,842283059,508405050,264637517,15,-1,1770912893,320,1,13,0,0,0,_binary 'EAAKX4BaAAAAAB0ZTf//AANiRf//ZlMV0g==',0,'',1385587,3617578192381224051),(1609,842283059,508406433,264638983,25,0,1770912895,310,1,14,0,0,0,_binary 'EAAKX4BdAAAAAB0AAP//AANiRf//ZlMdpw==',0,'',1385588,3617578192381224052),(1610,842283059,508406967,264639817,31,0,1770912896,310,1,13,0,0,0,_binary 'EAAKX4BfAAAAABwAAP//AANiRf//ZlMfiA==',0,'',1385589,3617578192381224053),(1611,842283059,508407900,264642150,39,1,1770912898,370,1,14,0,0,0,_binary 'EAAKX4BjAAAAAB0AAP//AANiRf//ZlMmBg==',0,'',1385590,3617578192381224054),(1612,942879286,510874095,282384227,0,0,1770912922,0,1,11,0,0,0,_binary 'EAAKl9kqAACiAB0AAAzvAAAAAAAH2Y8SyA==',0,'',586588,4049635697446417244),(1613,809055537,484161000,227049500,0,0,1770912912,0,1,16,0,0,0,_binary 'AAAPv/7/AAAfYWQZEhX8AAAAAAAJXR0AAA==',166,'',2612596,3474867072065330548),(1614,842283059,508423400,264679617,33,0,1770912918,690,1,15,0,0,0,_binary 'EAAKX4CkAAAAAB0AAP//AANiRf//ZlMgAg==',0,'',1385591,3617578192381224055),(1615,842283059,508431017,264692150,27,0,1770912924,760,1,16,0,0,0,_binary 'EAAKX4C8AAAAAB0ZTv//AANiRf//ZlMhbA==',0,'',1385592,3617578192381224056),(1616,842283059,508439250,264701283,21,0,1770912929,790,1,15,0,0,0,_binary 'EAAKX4DSAAAAAB0AAP//AANiRf//ZlMjHw==',0,'',1385593,3617578192381224057),(1617,842283059,508449733,264709833,15,0,1770912935,820,1,15,0,0,0,_binary 'EAAKX4DsAAAAAB0ZTv//AANiRf//ZlQj9A==',0,'',1385594,3617578192381224058),(1618,842283059,508473500,264721717,9,0,1770912947,830,1,16,0,0,0,_binary 'EAAKX4EkAAAAAB0ZTv//AANiRf//ZlQk8w==',0,'',1385595,3617578192381224059),(1619,842283059,508519417,264730600,4,0,1770912969,820,1,17,0,0,0,_binary 'EAAKX4GJAAAAAB0ZTv//AANiRf//ZlQj5g==',0,'',1385596,3617578192381224060),(1620,942879286,510874095,282384227,0,0,1770912982,0,1,13,0,0,0,_binary 'EAAKl9kqAACiAB0AAAzvAAAAAAAH2Y8StQ==',0,'',586589,4049635697446417245),(1621,809055537,484161000,227049500,0,0,1770912972,0,1,16,0,0,0,_binary 'AAAPv/7/AAAfYVwZEhX8AAAAAAAJXR0AAA==',166,'',2612597,3474867072065330549),(1622,842283059,508565317,264740267,10,0,1770912993,730,1,14,0,0,0,_binary 'EAAKX4HvAAAAAB0ZTv//AANiRf//ZlQf3Q==',0,'',1385597,3617578192381224061),(1623,842283059,508578750,264748600,17,0,1770913001,660,1,14,0,0,0,_binary 'EAAKX4IOAAAAAB0ZTv//AANiRf//ZlQd6Q==',0,'',1385598,3617578192381224062),(1624,842283059,508589567,264759667,23,0,1770913009,670,1,16,0,0,0,_binary 'EAAKX4IrAAAAAB0AAP//AANiRf//ZlQc2w==',0,'',1385599,3617578192381224063),(1625,842283059,508598067,264770700,29,0,1770913016,600,1,15,0,0,0,_binary 'EAAKX4JDAAAAAB0ZTv//AANiRf//ZlQh7Q==',0,'',1385600,3617578192381224064),(1626,942879286,510874095,282384227,0,0,1770913042,0,1,13,0,0,0,_binary 'EAAKl9kqAACiAB0AAAzvAAAAAAAH2Y8Stw==',0,'',586590,4049635697446417246),(1627,809055537,484161000,227049500,0,0,1770913032,0,1,18,0,0,0,_binary 'AAAPv/7/AAAfYWkZEhX8AAAAAAAJXR0AAA==',166,'',2612598,3474867072065330550),(1628,842283059,508619000,264803250,23,0,1770913034,700,1,14,0,0,0,_binary 'EAAKX4KFAAAAAB0AAP//AANiRv//ZlQgbQ==',0,'',1385601,3617578192381224065),(1629,842283059,508627233,264810450,17,0,1770913039,750,1,15,0,0,0,_binary 'EAAKX4KaAAAAAB0AAP//AANiRv//ZlQhtA==',0,'',1385602,3617578192381224066),(1630,842283059,508646083,264821667,11,0,1770913050,650,1,13,0,0,0,_binary 'EAAKX4LGAAAAAB0ZTv//AANiRv//ZlQfFw==',0,'',1385603,3617578192381224067),(1631,842283059,508689067,264842017,10,0,1770913079,630,1,13,0,0,0,_binary 'EAAKX4MqAAAAAB0ZTv//AANiRv//ZlQkug==',0,'',1385604,3617578192381224068),(1632,842283059,508700300,264845583,3,0,1770913086,650,1,16,0,0,0,_binary 'EAAKX4NDAAAAAB0AAP//AANiRv//ZlQkxQ==',0,'',1385605,3617578192381224069),(1633,942879286,510874095,282384227,0,0,1770913102,0,1,10,0,0,0,_binary 'EAAKl9krAACiAB0AAAzwAAAAAAAH2ZAiKg==',0,'',586591,4049635697446417247),(1634,942879286,510875640,282383040,189,0,1770913107,80,1,10,0,0,0,_binary 'EAAKl9ktAACjAB0AAAzwAAAAAAAH2ZAvWQ==',0,'',586592,4049635697446417248),(1635,809055537,484161000,227049500,0,0,1770913092,0,1,17,0,0,0,_binary 'AAAPv/7/AAAfYWUZEhX8AAAAAAAJXR0AAA==',166,'',2612599,3474867072065330551);

--
-- Table structure for table `parameters`
--

CREATE TABLE `parameters` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Number` int(11) NOT NULL COMMENT 'Номер параметра',
  `Value` varchar(255) DEFAULT NULL COMMENT 'Значение',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `parameters`
--

INSERT INTO `parameters` VALUES (1,24,'False'),(2,18,'True'),(3,13,'True'),(4,22,'0'),(5,12,'False'),(6,21,'uk'),(7,19,'osm.lwco.biz'),(8,23,'6f16b1ff-29f7-4d45-afdc-80444b888950'),(9,11,'0'),(10,6,'False'),(11,8,'False'),(12,9,'False'),(13,7,'0'),(14,1,'24'),(15,3,'5'),(16,10,'0'),(17,5,'False'),(18,2,'12'),(19,29,'960'),(20,25,'False'),(21,20,'----'),(22,27,'False'),(23,28,'gisfile.com'),(24,26,'ABQIAAAAWaQgWiEBF3lW97ifKnAczhRAzBk5Igf8Z5n2W3hNnMT0j2TikxTLtVIGU7hCLLHMAuAMt-BO5UrEWA');

--
-- Table structure for table `pcbdata`
--

CREATE TABLE `pcbdata` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Индекс',
  `Typedata` varchar(255) NOT NULL DEFAULT ' ' COMMENT 'Тип данных',
  `koeffK` double NOT NULL DEFAULT '0' COMMENT 'Коеффициент К',
  `Startbit` int(11) NOT NULL DEFAULT '0' COMMENT 'Стартовый бит поля',
  `Lengthbit` int(11) NOT NULL DEFAULT '0' COMMENT 'Длина поля',
  `Comment` varchar(255) DEFAULT ' ' COMMENT 'Коментарий',
  `Idpcb` int(11) NOT NULL DEFAULT '0' COMMENT 'Индекс платы датчика',
  `NameVal` varchar(12) DEFAULT ' ' COMMENT 'Name meassurement value',
  `NumAlg` int(11) DEFAULT '0' COMMENT 'Number of algorithm',
  `Shifter` double DEFAULT '0' COMMENT 'Shift coefficient',
  `S` tinyint(1) DEFAULT '0' COMMENT 'Sign arifmetic',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=cp1251 AVG_ROW_LENGTH=2340 COMMENT='Описание платы датчиков';

--
-- Dumping data for table `pcbdata`
--

INSERT INTO `pcbdata` VALUES (11,'бортмережа',0.1181,36,8,'',18,'В',4,0,0),(12,'запалювання',1,60,1,'',18,'#',5,0,0),(13,'бак',1,20,16,'',18,'л',7,0,0),(14,'правий бак',1,80,16,'',19,' л',7,0,0),(15,'штатний ДРП',0.4,128,8,'',19,' %',31,0,0),(16,'оберти двигуна',0.125,0,16,'',19,' rpm',5,0,0),(17,'витрата',0.5,16,64,'',19,' л',27,0,0),(18,'бортмережа',1,112,16,'',19,' В',4,0,0),(19,'пробіг за тахографом',0.005,152,32,'',19,' км',6,0,0),(20,'запалювання',1,196,1,'',19,' ',2,0,0),(22,'лівий бак',1,96,16,'',19,'л',7,0,0),(23,'бак',0.3922,0,8,'',20,'%',7,0,0),(24,'бортмережа',0.1181,8,8,'',20,'В',6,0,0),(25,'витрата за бортовим компом',0.1,16,32,'',20,'л',27,0,0),(26,'одометр за штатним датчику швидкості',1,48,32,'',20,'км',6,0,0),(27,'оберти двигуна',0.25,80,16,'',20,'rpm',5,0,0),(28,'розрахункове значення навантаження на двигун',0.3922,96,8,'',20,'%',6,0,0),(29,'температура охолоджуючої рідини',0,104,8,'',20,'°C',6,0,0),(30,'температура повітря, що всмоктується',0,112,8,'',20,'°C',6,0,0),(31,'запалювання',1,199,1,'',20,'#',2,0,0);

--
-- Table structure for table `pcbversion`
--

CREATE TABLE `pcbversion` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Индекс',
  `Name` varchar(50) NOT NULL DEFAULT '*' COMMENT 'Имя платы датчика',
  `Comment` varchar(255) DEFAULT ' ' COMMENT 'Комментарий',
  `MobitelId` int(11) DEFAULT '-1' COMMENT 'ID машины на которую назначена эта плата датчиков',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=cp1251 AVG_ROW_LENGTH=5461 COMMENT='Распределение данных для версии исполнения платы датчиков';

--
-- Dumping data for table `pcbversion`
--

INSERT INTO `pcbversion` VALUES (18,'SCAD_37','для версии исполнения ПД SCAD',-1),(19,'SCAD_CAN64','для версии исполнения ПД SCAD',-1),(20,'SCAD_OBD II 64','для версии исполнения ПД SCAD',-1);

--
-- Table structure for table `points`
--

CREATE TABLE `points` (
  `Point_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Latitude` int(11) DEFAULT '0',
  `Longitude` int(11) DEFAULT '0',
  `Zone_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`Point_ID`),
  KEY `FK_points_zones` (`Zone_ID`),
  CONSTRAINT `FK_points_zones` FOREIGN KEY (`Zone_ID`) REFERENCES `zones` (`Zone_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `points`
--


--
-- Table structure for table `relationalgorithms`
--

CREATE TABLE `relationalgorithms` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `AlgorithmID` int(11) NOT NULL DEFAULT '0',
  `SensorID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `relationalgorithms`
--

INSERT INTO `relationalgorithms` VALUES (1,7,1),(2,9,2),(3,5,3),(4,27,4),(5,4,5),(6,6,6),(7,2,7),(8,6,8),(9,7,9),(10,4,10),(11,5,11),(12,7,12),(13,7,13),(15,5,15),(16,27,16),(17,4,17),(18,6,18),(19,2,19),(20,7,20),(21,4,21),(22,5,22),(23,7,23),(24,7,24),(25,7,25),(26,31,26),(27,5,27),(28,27,28),(29,4,29),(30,6,30),(31,2,31);

--
-- Table structure for table `report_pass_zones`
--

CREATE TABLE `report_pass_zones` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `ZoneID` int(11) NOT NULL COMMENT 'Идентификатор КЗ',
  PRIMARY KEY (`ID`),
  KEY `IDX_ZoneID` (`ZoneID`) USING BTREE,
  CONSTRAINT `FK_RPZ_Zones` FOREIGN KEY (`ZoneID`) REFERENCES `zones` (`Zone_ID`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Список зон, используемый в отчетах по пассажиропотоку.';

--
-- Dumping data for table `report_pass_zones`
--


--
-- Table structure for table `route_items`
--

CREATE TABLE `route_items` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Seq` int(11) DEFAULT NULL,
  `Route_ID` int(11) DEFAULT NULL,
  `Zone_ID` int(11) DEFAULT NULL,
  `Zone_IO` int(11) DEFAULT NULL,
  `GoNext_Min` int(11) DEFAULT NULL,
  `GoNext_Max` int(11) DEFAULT NULL,
  `Link_Item` int(11) DEFAULT NULL,
  `Link_Info` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `route_items`
--


--
-- Table structure for table `route_list`
--

CREATE TABLE `route_list` (
  `Route_ID` int(11) NOT NULL AUTO_INCREMENT,
  `GIS` blob,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `Modified` int(11) DEFAULT NULL,
  PRIMARY KEY (`Route_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `route_list`
--


--
-- Table structure for table `route_lists`
--

CREATE TABLE `route_lists` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Parent` int(11) DEFAULT NULL,
  `Title` varchar(70) DEFAULT NULL,
  `Data` text,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `route_lists`
--


--
-- Table structure for table `route_mobitel_links`
--

CREATE TABLE `route_mobitel_links` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `List_ID` int(11) DEFAULT NULL,
  `Route_ID` int(11) DEFAULT NULL,
  `Mobitel_ID` int(11) DEFAULT NULL,
  `Time1` int(11) DEFAULT NULL,
  `Time2` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `route_mobitel_links`
--


--
-- Table structure for table `route_mobitel_plans`
--

CREATE TABLE `route_mobitel_plans` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Title` varchar(70) DEFAULT NULL,
  `Time1` int(11) DEFAULT NULL,
  `Time2` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `route_mobitel_plans`
--


--
-- Table structure for table `route_points`
--

CREATE TABLE `route_points` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Route_ID` int(11) DEFAULT NULL,
  `Zone_ID` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `route_points`
--


--
-- Table structure for table `rt_events`
--

CREATE TABLE `rt_events` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rt_events`
--

INSERT INTO `rt_events` VALUES (1,'Въезд'),(2,'Выезд');

--
-- Table structure for table `rt_route`
--

CREATE TABLE `rt_route` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_sample` int(11) NOT NULL COMMENT 'Ссылка на шаблон маршрута ',
  `Id_mobitel` int(11) NOT NULL DEFAULT '0' COMMENT 'Транспортное средство ',
  `Id_driver` int(11) NOT NULL DEFAULT '0' COMMENT 'Водитель',
  `TimeStartPlan` datetime DEFAULT NULL COMMENT 'План время начала маршрута',
  `Distance` double NOT NULL DEFAULT '0' COMMENT 'Общий путь, км',
  `TimePlanTotal` varchar(20) DEFAULT NULL COMMENT 'Общее время на маршруте (план)',
  `TimeFactTotal` varchar(20) DEFAULT NULL COMMENT 'Общее время на маршруте (факт)',
  `Deviation` varchar(20) DEFAULT NULL COMMENT 'Отклонение от графика',
  `DeviationAr` varchar(20) DEFAULT NULL COMMENT 'Отклонение по времени прибытия',
  `Remark` text COMMENT 'Примечание',
  `FuelStart` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДУТ Топливо в начале',
  `FuelAdd` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДУТ Заправлено',
  `FuelSub` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДУТ Слито',
  `FuelEnd` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДУТ Топливо в конце',
  `FuelExpens` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДУТ Общий расход топлива',
  `FuelExpensAvg` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДУТ Средний расход,  л/100 км',
  `Fuel_ExpensMove` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДРТ/CAN Расход топлива в движении, л',
  `Fuel_ExpensStop` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДРТ/CAN Расход топлива на стоянках, л',
  `Fuel_ExpensTotal` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДРТ/CAN Общий расход, л',
  `Fuel_ExpensAvg` double(10,2) NOT NULL DEFAULT '0.00' COMMENT 'ДРТ/CAN Средний расход, л/100 км',
  `TimeMove` varchar(20) DEFAULT NULL COMMENT 'Время движения',
  `TimeStop` varchar(20) DEFAULT NULL COMMENT 'Время остановок',
  `SpeedAvg` double(10,2) DEFAULT '0.00' COMMENT 'Средняя скорость',
  `FuelAddQty` int(11) DEFAULT '0' COMMENT 'ДУТ Заправлено - кол-во',
  `FuelSubQty` int(11) DEFAULT '0' COMMENT 'ДУТ Слито - кол-во',
  `PointsValidity` int(11) DEFAULT '0' COMMENT 'Валидность данных',
  `PointsCalc` int(11) DEFAULT '0' COMMENT 'Количество точек (по Log_ID) расчетное',
  `PointsFact` int(11) DEFAULT '0' COMMENT 'Количество точек (по Log_ID) фактическое',
  `PointsIntervalMax` varchar(20) DEFAULT NULL COMMENT 'Максимальный интервал между точками',
  `Type` tinyint(4) NOT NULL DEFAULT '1' COMMENT 'Тип маршрутного листа - КЗ или населенные пункты',
  `TimeEndFact` datetime DEFAULT NULL COMMENT 'Фактическое время окончания маршрута',
  `DistLogicSensor` double(10,2) DEFAULT '0.00' COMMENT 'Путь с включенным логическим датчиком, км',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rt_route`
--


--
-- Table structure for table `rt_route_fuel`
--

CREATE TABLE `rt_route_fuel` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `Location` varchar(255) NOT NULL,
  `time_` datetime NOT NULL,
  `dValueCalc` double NOT NULL DEFAULT '0' COMMENT 'Расчетная величина',
  `dValueHandle` double DEFAULT '0' COMMENT 'Ручная правка',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `Id` (`Id`) USING BTREE,
  KEY `rt_route_fuel_FK1` (`Id_main`),
  CONSTRAINT `rt_route_fuel_FK1` FOREIGN KEY (`Id_main`) REFERENCES `rt_route` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rt_route_fuel`
--


--
-- Table structure for table `rt_route_sensors`
--

CREATE TABLE `rt_route_sensors` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `SensorName` varchar(127) NOT NULL,
  `Location` varchar(255) NOT NULL,
  `EventTime` datetime NOT NULL,
  `Duration` time NOT NULL,
  `Description` varchar(255) DEFAULT NULL,
  `Speed` double DEFAULT '0',
  `Distance` double(10,2) DEFAULT '0.00' COMMENT 'Путь, км',
  PRIMARY KEY (`Id`),
  KEY `rt_route_sensors_FK1` (`Id_main`) USING BTREE,
  CONSTRAINT `rt_route_sensors_FK1` FOREIGN KEY (`Id_main`) REFERENCES `rt_route` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rt_route_sensors`
--


--
-- Table structure for table `rt_route_stops`
--

CREATE TABLE `rt_route_stops` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `Location` varchar(255) DEFAULT NULL,
  `InitialTime` datetime DEFAULT NULL,
  `FinalTime` datetime DEFAULT NULL,
  `Interval` time DEFAULT NULL,
  `CheckZone` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Остановка в контрольной зоне',
  PRIMARY KEY (`Id`),
  KEY `rt_route_stops_FK1` (`Id_main`) USING BTREE,
  CONSTRAINT `rt_route_stops_FK1` FOREIGN KEY (`Id_main`) REFERENCES `rt_route` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rt_route_stops`
--


--
-- Table structure for table `rt_route_type`
--

CREATE TABLE `rt_route_type` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) NOT NULL COMMENT 'Тип маршрута',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rt_route_type`
--

INSERT INTO `rt_route_type` VALUES (1,'Контрольные зоны'),(2,'Населенные пункты');

--
-- Table structure for table `rt_routet`
--

CREATE TABLE `rt_routet` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `Id_zone` int(11) NOT NULL DEFAULT '0' COMMENT 'Контрольная зона',
  `Id_event` int(11) NOT NULL DEFAULT '1' COMMENT 'Событие - въезд / выезд ',
  `DatePlan` datetime DEFAULT NULL COMMENT 'План время события ',
  `DateFact` datetime DEFAULT NULL COMMENT 'Факт время события ',
  `Deviation` varchar(10) DEFAULT NULL COMMENT 'Отклонение от графика',
  `Remark` text COMMENT 'Примечание',
  `Distance` double DEFAULT '0' COMMENT 'Путь между точками маршрута',
  `Location` varchar(255) DEFAULT NULL COMMENT 'Населенный пункт',
  PRIMARY KEY (`Id`),
  KEY `rt_routet_FK1` (`Id_main`) USING BTREE,
  CONSTRAINT `rt_routet_FK1` FOREIGN KEY (`Id_main`) REFERENCES `rt_route` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rt_routet`
--


--
-- Table structure for table `rt_sample`
--

CREATE TABLE `rt_sample` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(100) NOT NULL,
  `Id_mobitel` int(11) DEFAULT '0' COMMENT 'Транспортное средство (опц)',
  `TimeStart` time DEFAULT NULL COMMENT 'Время начала маршрута (опц)',
  `Distance` double DEFAULT '0' COMMENT 'Общий путь, км',
  `Remark` text COMMENT 'Примечание',
  `Id_main` int(11) NOT NULL DEFAULT '0' COMMENT 'Ссылка на элемент верхнего уровня в иерархии',
  `IsGroupe` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Запись - группа',
  `AutoCreate` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Маршрут может автосоздаваться ',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rt_sample`
--


--
-- Table structure for table `rt_samplet`
--

CREATE TABLE `rt_samplet` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `Position` tinyint(4) NOT NULL COMMENT 'Порядковый номер записи шаблона маршрута',
  `Id_event` int(11) NOT NULL COMMENT 'Событие - въезд / выезд ',
  `Id_zone` int(11) DEFAULT NULL COMMENT 'Контрольная зона',
  `TimeRel` char(5) DEFAULT '00:00' COMMENT 'Относительное время от начала маршрута',
  `TimeRelP` char(5) DEFAULT '00:00' COMMENT 'Допустимое отклонение (+)',
  `TimeRelM` char(5) DEFAULT '00:00' COMMENT 'Допустимое отклонение (-)',
  `TimeAbs` char(8) DEFAULT '00:00:00' COMMENT 'Абсолютное время маршрута',
  PRIMARY KEY (`Id`),
  KEY `rt_samplet_FK1` (`Id_main`) USING BTREE,
  CONSTRAINT `rt_samplet_FK1` FOREIGN KEY (`Id_main`) REFERENCES `rt_sample` (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rt_samplet`
--


--
-- Table structure for table `rt_shedule`
--

CREATE TABLE `rt_shedule` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_shedule_dc` int(11) DEFAULT NULL COMMENT 'Ссылка на справочник графиков',
  `Id_zone_main` int(11) DEFAULT NULL COMMENT 'Зона старта транспортных средств',
  `DateShedule` datetime NOT NULL COMMENT 'Дата графика',
  `Remark` varchar(127) DEFAULT NULL COMMENT 'Примечание',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Ссылка на внешний документ учетной системы',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Шапка документа ГРАФИК ДВИЖЕНИЯ';

--
-- Dumping data for table `rt_shedule`
--


--
-- Table structure for table `rt_shedule_dc`
--

CREATE TABLE `rt_shedule_dc` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(127) NOT NULL COMMENT 'Название шаблона графика движения',
  `Id_zone_main` int(11) DEFAULT NULL COMMENT 'Зона старта транспортных средств',
  `Remark` varchar(127) DEFAULT NULL COMMENT 'Примечание',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Шаблон шапки документа ГРАФИК ДВИЖЕНИЯ';

--
-- Dumping data for table `rt_shedule_dc`
--


--
-- Table structure for table `rt_shedulet`
--

CREATE TABLE `rt_shedulet` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL COMMENT 'Ссылка на шапку документа',
  `Id_zone_to` int(11) DEFAULT NULL COMMENT 'Зона прибытия транспортного средства',
  `Id_vehicle` int(11) DEFAULT NULL COMMENT 'Транспортное средство',
  `TimePlanStart` datetime NOT NULL COMMENT 'Плановая дата начала движения',
  `TimePlanEnd` datetime DEFAULT NULL COMMENT 'Плановая дата окончания движения',
  `TimeFactStart` datetime DEFAULT NULL COMMENT 'Фактическая дата начала движения',
  `TimeFactEnd` datetime DEFAULT NULL COMMENT 'Фактическая дата окончания движения',
  `Distance` float NOT NULL DEFAULT '0' COMMENT 'Плановое расстояние',
  `State` varchar(127) DEFAULT NULL COMMENT 'Статус слежения за транспортным средством',
  `IsClose` bit(1) NOT NULL DEFAULT b'0' COMMENT 'Слежение за транспортным средством прекращено',
  PRIMARY KEY (`Id`),
  KEY `FK_rt_shedulet_rt_shedule` (`Id_main`) USING BTREE,
  CONSTRAINT `FK_rt_shedulet_rt_shedule` FOREIGN KEY (`Id_main`) REFERENCES `rt_shedule` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Содержимое документа ГРАФИК ДВИЖЕНИЯ';

--
-- Dumping data for table `rt_shedulet`
--


--
-- Table structure for table `rt_shedulet_dc`
--

CREATE TABLE `rt_shedulet_dc` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL COMMENT 'Ссылка на шапку документа',
  `Id_zone_to` int(11) DEFAULT NULL COMMENT 'Зона прибытия транспортного средства',
  `TimePlanStart` char(5) NOT NULL COMMENT 'Плановая дата начала движения',
  `TimePlanEnd` char(5) DEFAULT NULL COMMENT 'Плановая дата окончания движения',
  `Distance` float NOT NULL DEFAULT '0' COMMENT 'Плановое расстояние',
  PRIMARY KEY (`Id`),
  KEY `FK_rt_shedulet_rt_shedule` (`Id_main`) USING BTREE,
  CONSTRAINT `FK_rt_shedulet_dc_rt_shedule_dc` FOREIGN KEY (`Id_main`) REFERENCES `rt_shedule_dc` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Шаблон содержимого документа ГРАФИК ДВИЖЕНИЯ';

--
-- Dumping data for table `rt_shedulet_dc`
--


--
-- Table structure for table `rules`
--

CREATE TABLE `rules` (
  `Rule_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Password` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) NOT NULL DEFAULT '0',
  `Rule1` tinyint(4) NOT NULL DEFAULT '0',
  `Rule2` tinyint(4) NOT NULL DEFAULT '0',
  `Rule3` tinyint(4) NOT NULL DEFAULT '0',
  `Rule4` tinyint(4) NOT NULL DEFAULT '0',
  `Rule5` tinyint(4) NOT NULL DEFAULT '0',
  `Rule6` tinyint(4) NOT NULL DEFAULT '0',
  `Rule7` tinyint(4) NOT NULL DEFAULT '0',
  `Rule8` tinyint(4) NOT NULL DEFAULT '0',
  `Rule9` tinyint(4) NOT NULL DEFAULT '0',
  `Rule10` tinyint(4) NOT NULL DEFAULT '0',
  `Rule11` tinyint(4) NOT NULL DEFAULT '0',
  `Rule12` tinyint(4) NOT NULL DEFAULT '0',
  `Rule13` tinyint(4) NOT NULL DEFAULT '0',
  `Rule14` tinyint(4) NOT NULL DEFAULT '0',
  `Rule15` tinyint(4) NOT NULL DEFAULT '0',
  `Rule16` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Rule_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `rules`
--

INSERT INTO `rules` VALUES (1,'guest','guest','guest account',0,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0),(8,'power','power','Description for Power User Profile',0,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0),(9,'root','root','Description for root  Profile',0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0);

--
-- Table structure for table `sensor_hookups`
--

CREATE TABLE `sensor_hookups` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) DEFAULT NULL,
  `Sensor_ID` int(11) DEFAULT NULL,
  `FirstBit` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `sensor_hookups`
--


--
-- Table structure for table `sensor_list`
--

CREATE TABLE `sensor_list` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Title` varchar(70) DEFAULT NULL,
  `Kind` varchar(20) DEFAULT NULL,
  `BitsCount` int(11) DEFAULT NULL,
  `FirstBit` int(11) DEFAULT NULL,
  `Data` text,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `sensor_list`
--


--
-- Table structure for table `sensoralgorithms`
--

CREATE TABLE `sensoralgorithms` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(45) NOT NULL,
  `Description` char(45) DEFAULT NULL,
  `AlgorithmID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `ID` (`ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `sensoralgorithms`
--

INSERT INTO `sensoralgorithms` VALUES (1,'Логический датчик','Для анализа используется критерий вкл. выкл.',1),(2,'Работа основного двигателя','Обычно используется при подключении к заж.',2),(3,'Обороты оборудования','Для анализа используются к-во оборотов',3),(4,'Напряжение','Контролируется борт сеть',4),(5,'Обороты основного двигателя','Для анализа используются к-во оборотов',5),(6,'Температура','Датчик температуры',6),(7,'Уровень топлива','Уровень топлива в баке1',7),(8,'Расход топлива','Уровень топлива в баке2',8),(9,'Пассажиры1','Для подсчета количества пассажиров1',9),(10,'Пассажиры2','Для подсчета количества пассажиров2',10),(11,'Дверь1','Для пассажиров1',11),(12,'Дверь2','Для пассажиров2',12),(13,'Идентификация водителя','Для идентификации водителей',13),(14,'Идентификация прицепного устройства','Для идентификации прицепных устройств',14),(15,'Топливозаправщик','Для контроля запровок с бензовоза',15),(16,'Слежение - логический датчик','Для отображения в режиме слежения',16),(17,'Прицепное оборудование - логический датчик','Для контроля состояний работа/переезд',17),(18,'Инклинометр - продольная ось X,','Для контроля угла наклона по оси Х',18),(19,'Инклинометр - продольная ось Y,','Для контроля угла наклона по оси Y',19),(20,'Идентификация оператора','Для идентификации водителя принявшего топливо',20),(21,'Идентификация транспортного средства','Для идентификации топливозаправщика',21),(22,'Угломерный датчик рабочего положения','Для идентификации агрегата в агро',22),(23,'Датчик разгрузки транспортного средства','Выгрузка бункера комбайна в агро',23),(24,'Расход топлива прямой','Расход топлива в баке прямой',24),(25,'Расход топлива обратный','Расход топлива в баке обратный',25),(26,'Дальномер','Дальномер',26),(27,'Расходомер топлива накопительный','Расходомер типа ДРТ, только накопительный',27),(28,'Определение уровня зерна в бункере','Алгоритм определения уровня зерна в бункере',28),(29,'Расход топлива дифференциальный','Дифференциальный проточник',29),(30,'Топливозаправщик (дифференциальный)','Топливозаправщик на дифф ДРТ',30),(31,'Уровень топлива в агрегате','Уровень топлива в баке агрегата',31);

--
-- Table structure for table `sensorcoefficient`
--

CREATE TABLE `sensorcoefficient` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Sensor_id` int(10) unsigned NOT NULL,
  `UserValue` double(10,5) NOT NULL,
  `SensorValue` double(10,5) NOT NULL,
  `K` double(10,5) NOT NULL DEFAULT '1.00000',
  `b` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `Index_2` (`Sensor_id`,`UserValue`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=287 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `sensorcoefficient`
--

INSERT INTO `sensorcoefficient` VALUES (1,1,0.00000,0.00000,2.01794,0),(2,1,1.00000,6916.00000,-0.06333,439.0133333333334),(3,1,20.00000,6616.00000,-0.06333,439.0133333333334),(4,1,40.00000,6280.00000,-0.05952,413.8095238095238),(5,1,60.00000,5967.00000,-0.06390,441.2779552715655),(6,1,80.00000,5674.00000,-0.06826,467.3037542662116),(7,1,100.00000,5380.00000,-0.06803,465.9863945578232),(8,1,120.00000,5087.00000,-0.06826,467.23549488054607),(9,1,140.00000,4792.00000,-0.06780,464.8813559322034),(10,1,160.00000,4504.00000,-0.06944,472.77777777777777),(11,1,180.00000,4216.00000,-0.06944,472.77777777777777),(12,1,200.00000,3924.00000,-0.06849,468.7671232876712),(13,1,220.00000,3625.00000,-0.06689,462.47491638795987),(14,1,240.00000,3332.00000,-0.06826,467.4402730375427),(15,1,260.00000,3052.00000,-0.07143,478),(16,1,280.00000,2761.00000,-0.06873,469.7594501718213),(17,1,300.00000,2470.00000,-0.06873,469.7594501718213),(18,1,320.00000,2179.00000,-0.06873,469.7594501718213),(19,1,340.00000,1893.00000,-0.06993,472.3776223776224),(20,1,360.00000,1603.00000,-0.06897,470.55172413793105),(21,1,380.00000,1297.00000,-0.06536,464.7712418300654),(22,1,400.00000,991.00000,-0.06536,464.7712418300654),(23,1,405.00000,915.00000,-0.06579,465.1973684210526),(24,1,410.00000,837.00000,-0.06410,463.65384615384613),(25,1,430.00000,530.00000,-0.06515,464.52768729641696),(26,9,0.00000,0.00000,1.61058,0),(27,9,1.00000,7689.00000,-0.09091,700),(28,9,20.00000,7480.00000,-0.09091,700),(29,9,40.00000,7222.00000,-0.07752,599.8449612403101),(30,9,60.00000,6986.00000,-0.08475,652.0338983050847),(31,9,80.00000,6766.00000,-0.09091,695.0909090909091),(32,9,100.00000,6547.00000,-0.09132,697.8995433789954),(33,9,105.00000,6499.00000,-0.10417,781.9791666666667),(34,9,110.00000,6436.00000,-0.07937,620.7936507936508),(35,9,130.00000,6235.00000,-0.09950,750.3980099502488),(36,9,150.00000,6021.00000,-0.09346,712.7102803738318),(37,9,190.00000,5590.00000,-0.09281,708.7935034802784),(38,9,230.00000,5165.00000,-0.09412,716.1176470588235),(39,9,270.00000,4750.00000,-0.09639,727.8313253012049),(40,9,310.00000,4328.00000,-0.09479,720.2369668246445),(41,9,350.00000,3904.00000,-0.09434,718.3018867924529),(42,9,390.00000,3488.00000,-0.09615,725.3846153846155),(43,9,430.00000,3072.00000,-0.09615,725.3846153846155),(44,9,470.00000,2640.00000,-0.09259,714.4444444444445),(45,9,510.00000,2215.00000,-0.09412,718.4705882352941),(46,9,550.00000,1794.00000,-0.09501,720.4513064133016),(47,9,590.00000,1355.00000,-0.09112,713.4624145785878),(48,9,600.00000,1245.00000,-0.09091,713.1818181818182),(49,9,610.00000,1131.00000,-0.08772,709.2105263157895),(50,9,620.00000,1014.00000,-0.08547,706.6666666666666),(51,9,625.00000,956.00000,-0.08621,707.4137931034483),(52,9,630.00000,897.00000,-0.08475,706.0169491525423),(53,9,650.00000,663.00000,-0.08547,706.6666666666666),(54,9,670.00000,416.00000,-0.08097,703.6842105263158),(55,1,450.00000,223.00000,-0.06515,464.52768729641696),(154,23,0.00000,0.00000,0.78593,0),(155,23,1.00000,7531.00000,-0.12857,969.2714285714285),(156,23,10.00000,7461.00000,-0.12857,969.2714285714285),(157,23,20.00000,7296.00000,-0.06061,462.1818181818182),(158,23,40.00000,6995.00000,-0.06645,504.78405315614623),(159,23,60.00000,6716.00000,-0.07168,541.4336917562723),(160,23,80.00000,6442.00000,-0.07299,550.2189781021898),(161,23,100.00000,6182.00000,-0.07692,575.5384615384615),(162,23,120.00000,5919.00000,-0.07605,570.1140684410645),(163,23,140.00000,5659.00000,-0.07692,575.3076923076924),(164,23,160.00000,5401.00000,-0.07752,578.6821705426357),(165,23,180.00000,5140.00000,-0.07663,573.8697318007662),(166,23,200.00000,4888.00000,-0.07937,587.936507936508),(167,23,250.00000,4248.00000,-0.07812,581.875),(168,23,300.00000,3613.00000,-0.07874,584.488188976378),(169,23,350.00000,2978.00000,-0.07874,584.488188976378),(170,23,400.00000,2339.00000,-0.07825,583.0203442879499),(171,23,420.00000,2083.00000,-0.07812,582.734375),(172,23,440.00000,1821.00000,-0.07634,579.0076335877862),(173,23,460.00000,1562.00000,-0.07722,580.6177606177606),(174,23,480.00000,1297.00000,-0.07547,577.8867924528302),(175,23,490.00000,1160.00000,-0.07299,574.6715328467153),(176,23,500.00000,1021.00000,-0.07194,573.4532374100719),(177,23,505.00000,948.00000,-0.06849,569.931506849315),(178,23,525.00000,668.00000,-0.07143,572.7142857142857),(179,24,0.00000,0.00000,1.12278,0),(180,24,1.00000,7478.00000,-0.12500,935.75),(181,24,10.00000,7406.00000,-0.12500,935.75),(182,24,20.00000,7284.00000,-0.08197,617.0491803278688),(183,24,40.00000,7050.00000,-0.08547,642.5641025641025),(184,24,60.00000,6832.00000,-0.09174,686.7889908256881),(185,24,80.00000,6623.00000,-0.09569,713.7799043062201),(186,24,100.00000,6419.00000,-0.09804,729.313725490196),(187,24,120.00000,6219.00000,-0.10000,741.9000000000001),(188,24,140.00000,6025.00000,-0.10309,761.1340206185566),(189,24,160.00000,5831.00000,-0.10309,761.1340206185566),(190,24,180.00000,5635.00000,-0.10204,755),(191,24,200.00000,5443.00000,-0.10417,766.9791666666667),(192,24,250.00000,4963.00000,-0.10417,766.9791666666667),(193,24,300.00000,4479.00000,-0.10331,762.706611570248),(194,24,350.00000,4001.00000,-0.10460,768.5146443514644),(195,24,400.00000,3523.00000,-0.10460,768.5146443514644),(196,24,450.00000,3046.00000,-0.10482,769.2872117400419),(197,24,500.00000,2567.00000,-0.10438,767.9540709812109),(198,24,550.00000,2082.00000,-0.10309,764.639175257732),(199,24,600.00000,1592.00000,-0.10204,762.4489795918367),(200,24,620.00000,1396.00000,-0.10204,762.4489795918367),(201,24,640.00000,1195.00000,-0.09950,758.905472636816),(202,24,660.00000,991.00000,-0.09804,757.156862745098),(203,24,670.00000,885.00000,-0.09434,753.4905660377359),(204,24,675.00000,831.00000,-0.09259,751.9444444444445),(205,24,695.00000,619.00000,-0.09434,753.3962264150944),(206,25,0.00000,0.00000,1.25286,0),(207,25,1.00000,7774.00000,-0.03814,297.46610169491527),(208,25,10.00000,7538.00000,-0.03814,297.46610169491527),(209,25,20.00000,7423.00000,-0.08696,665.4782608695652),(210,25,40.00000,7231.00000,-0.10417,793.2291666666667),(211,25,60.00000,7049.00000,-0.10989,834.6153846153846),(212,25,80.00000,6880.00000,-0.11834,894.2011834319526),(213,25,100.00000,6712.00000,-0.11905,899.047619047619),(214,25,120.00000,6549.00000,-0.12270,923.5582822085889),(215,25,140.00000,6393.00000,-0.12821,959.6153846153845),(216,25,160.00000,6238.00000,-0.12903,964.9032258064516),(217,25,180.00000,6086.00000,-0.13158,980.7894736842105),(218,25,200.00000,5936.00000,-0.13333,991.4666666666667),(219,25,220.00000,5785.00000,-0.13245,986.225165562914),(220,25,240.00000,5636.00000,-0.13423,996.510067114094),(221,25,260.00000,5494.00000,-0.14085,1033.8028169014085),(222,25,280.00000,5348.00000,-0.13699,1012.6027397260274),(223,25,300.00000,5200.00000,-0.13514,1002.7027027027027),(224,25,320.00000,5050.00000,-0.13333,993.3333333333334),(225,25,340.00000,4909.00000,-0.14184,1036.3120567375886),(226,25,360.00000,4761.00000,-0.13514,1003.3783783783784),(227,25,380.00000,4615.00000,-0.13699,1012.1917808219177),(228,25,400.00000,4469.00000,-0.13699,1012.1917808219177),(229,25,420.00000,4328.00000,-0.14184,1033.900709219858),(230,25,440.00000,4183.00000,-0.13793,1016.9655172413793),(231,25,460.00000,4038.00000,-0.13793,1016.9655172413793),(232,25,480.00000,3891.00000,-0.13605,1009.3877551020408),(233,25,500.00000,3750.00000,-0.14184,1031.9148936170213),(234,25,520.00000,3603.00000,-0.13605,1010.2040816326531),(235,25,540.00000,3456.00000,-0.13605,1010.2040816326531),(236,25,560.00000,3313.00000,-0.13986,1023.3566433566434),(237,25,580.00000,3174.00000,-0.14388,1036.6906474820144),(238,25,600.00000,3030.00000,-0.13889,1020.8333333333334),(239,25,620.00000,2886.00000,-0.13889,1020.8333333333334),(240,25,640.00000,2738.00000,-0.13514,1010),(241,25,660.00000,2597.00000,-0.14184,1028.3687943262412),(242,25,680.00000,2444.00000,-0.13072,999.4771241830065),(243,25,700.00000,2288.00000,-0.12821,993.3333333333333),(244,25,720.00000,2132.00000,-0.12821,993.3333333333333),(245,25,740.00000,1980.00000,-0.13158,1000.5263157894736),(246,25,760.00000,1817.00000,-0.12270,982.9447852760736),(247,25,780.00000,1652.00000,-0.12121,980.2424242424242),(248,25,800.00000,1486.00000,-0.12048,979.0361445783133),(249,25,820.00000,1305.00000,-0.11050,964.1988950276243),(250,25,830.00000,1211.00000,-0.10638,958.8297872340426),(251,25,840.00000,1110.00000,-0.09901,949.90099009901),(252,25,850.00000,1008.00000,-0.09804,948.8235294117648),(253,25,857.00000,927.00000,-0.08642,937.1111111111111),(254,25,877.00000,700.00000,-0.08811,938.6740088105727),(255,20,0.00000,0.00000,0.85000,0),(256,20,1.00000,7730.00000,-0.04891,379.09782608695656),(257,20,10.00000,7546.00000,-0.04891,379.09782608695656),(258,20,20.00000,7364.00000,-0.05495,424.6153846153846),(259,20,40.00000,7036.00000,-0.06098,469.0243902439024),(260,20,60.00000,6730.00000,-0.06536,499.8692810457517),(261,20,80.00000,6445.00000,-0.07018,532.280701754386),(262,20,100.00000,6167.00000,-0.07194,543.6690647482014),(263,20,120.00000,5902.00000,-0.07547,565.433962264151),(264,20,140.00000,5638.00000,-0.07576,567.1212121212121),(265,20,160.00000,5385.00000,-0.07905,585.691699604743),(266,20,180.00000,5131.00000,-0.07874,584.0157480314961),(267,20,200.00000,4883.00000,-0.08065,593.7903225806451),(268,20,220.00000,4633.00000,-0.08000,590.64),(269,20,240.00000,4388.00000,-0.08163,598.204081632653),(270,20,260.00000,4141.00000,-0.08097,595.3036437246964),(271,20,280.00000,3892.00000,-0.08032,592.6104417670683),(272,20,300.00000,3647.00000,-0.08163,597.7142857142857),(273,20,320.00000,3394.00000,-0.07905,588.300395256917),(274,20,340.00000,3144.00000,-0.08000,591.52),(275,20,360.00000,2886.00000,-0.07752,583.7209302325582),(276,20,380.00000,2629.00000,-0.07782,584.5914396887159),(277,20,400.00000,2362.00000,-0.07491,576.9288389513108),(278,20,420.00000,2092.00000,-0.07407,574.9629629629629),(279,20,440.00000,1802.00000,-0.06897,564.2758620689655),(280,20,450.00000,1659.00000,-0.06993,566.013986013986),(281,20,460.00000,1499.00000,-0.06250,553.6875),(282,20,470.00000,1340.00000,-0.06289,554.2767295597484),(283,20,480.00000,1168.00000,-0.05814,547.9069767441861),(284,20,490.00000,985.00000,-0.05464,543.8251366120219),(285,20,490.60000,975.00000,-0.06000,549.1000000000022),(286,20,510.00000,600.00000,-0.05173,541.04);

--
-- Table structure for table `sensordata`
--

CREATE TABLE `sensordata` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `datagps_id` int(10) unsigned NOT NULL,
  `sensor_id` int(10) unsigned NOT NULL,
  `Value` double(10,2) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `Index_2` (`datagps_id`,`sensor_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `sensordata`
--


--
-- Table structure for table `sensors`
--

CREATE TABLE `sensors` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mobitel_id` int(11) NOT NULL,
  `Name` varchar(45) NOT NULL,
  `Description` varchar(200) NOT NULL,
  `StartBit` int(10) unsigned NOT NULL,
  `Length` int(10) unsigned NOT NULL,
  `NameUnit` varchar(45) NOT NULL,
  `K` double(10,5) NOT NULL DEFAULT '0.00000',
  `B` double DEFAULT '0' COMMENT 'Shift coefficient',
  `S` tinyint(1) DEFAULT '0' COMMENT 'Sign arifmetic',
  PRIMARY KEY (`id`),
  KEY `Index_2` (`mobitel_id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `sensors`
--

INSERT INTO `sensors` VALUES (1,809055537,'правий бак','',80,16,' л',1.00000,0,0),(2,809055537,'штатний ДРП','',128,8,' %',0.40000,0,0),(3,809055537,'оберти двигуна','',0,16,' rpm',0.12500,0,0),(4,809055537,'витрата','',16,64,' л',0.50000,0,0),(5,809055537,'бортмережа','',112,16,' В',0.00100,0,0),(6,809055537,'пробіг за тахографом','',152,32,' км',0.00500,0,0),(7,809055537,'запалювання','',196,1,' ',1.00000,0,0),(8,809055537,'температура антифрізу','',184,8,'°C',1.00000,0,0),(9,809055537,'лівий бак','',96,16,'л',1.00000,0,0),(10,942814777,'бортмережа','',32,8,'В',0.11810,0,0),(11,942814777,'запалювання','',61,1,'#',1.00000,0,0),(12,942814777,'вірт. бак','',0,8,'л',1.00000,0,0),(13,842283059,'правий бак неспр.','',80,16,' л',1.00000,0,0),(15,842283059,'оберти двигуна','',0,16,' rpm',0.12500,0,0),(16,842283059,'витрата','',48,32,' л',1.00000,0,0),(17,842283059,'бортмережа','',112,16,' В',1.00000,0,0),(18,842283059,'пробіг за тахографом','',152,32,' км',0.00500,0,0),(19,842283059,'запалювання','',196,1,' ',1.00000,0,0),(20,842283059,'лівий бак','Новая',96,16,'л',1.00000,0,0),(21,909522486,'бортмережа','',36,8,'В',0.11810,0,0),(22,909522486,'запалювання','',60,1,'#',1.00000,0,0),(23,909522486,'правий бак','',20,16,'л',1.00000,0,0),(24,909522486,'лівий бак','Новая',44,16,'л',1.00000,0,0),(25,942879286,'бак','',80,16,' л',1.00000,0,0),(26,942879286,'штатний ДРП','',128,8,' %',0.40000,0,0),(27,942879286,'оберти двигуна','',0,16,' rpm',0.12500,0,0),(28,942879286,'витрата','',16,64,' л',0.50000,0,0),(29,942879286,'бортмережа','',112,16,' В',1.00000,0,0),(30,942879286,'пробіг за тахографом','',152,32,' км',0.00500,0,0),(31,942879286,'запалювання','',196,1,' ',1.00000,0,0);

--
-- Table structure for table `serviceinit`
--

CREATE TABLE `serviceinit` (
  `ServiceInit_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `ServiceType_ID` int(11) DEFAULT '0',
  `A1` char(50) DEFAULT NULL,
  `A2` char(50) DEFAULT NULL,
  `A3` char(50) DEFAULT NULL,
  `A4` char(50) DEFAULT NULL,
  `A5` char(50) DEFAULT NULL,
  `A6` char(50) DEFAULT NULL,
  `A7` char(50) DEFAULT NULL,
  `A8` char(50) DEFAULT NULL,
  `A9` char(50) DEFAULT NULL,
  `A10` char(200) DEFAULT NULL,
  `CAtoSAint` int(11) DEFAULT '0',
  `CAtoSAtime` int(11) DEFAULT '0',
  `SAtoCAint` int(11) DEFAULT '0',
  `SAtoCAtime` int(11) DEFAULT '0',
  `SAtoCAtext` char(50) DEFAULT 'STOPPED',
  `CAtoSAtext` char(50) DEFAULT 'STOPPED',
  `MobitelActive_ID` int(11) NOT NULL DEFAULT '0',
  `Active` tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`ServiceInit_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `serviceinit`
--

INSERT INTO `serviceinit` VALUES (1,'Direct Cable','Сервис для прямого кабельного соединения',0,0,5,'COM1','115200','','','','','','','','',0,0,1,1222352358,'Running',NULL,83,0),(7,'GSM модем','Отправка SMS по  GSM каналу',0,0,2,'COM2','115200','','','','','','','','XXX',0,0,1,1127307060,'Running',NULL,75,0),(29,'EMail','Сервис отправки данных через E-mail',29,1125886839,6,'','','','smtp.p314.net','pop.p314.net','25','110','60','','XXX',0,0,1,1128962351,'Running',NULL,68,0),(30,'Online','Онлайн через телематический сервер',30,0,3,'','9010','','','','','','','','',0,0,0,0,'STOPPED','STOPPED',0,0);

--
-- Table structure for table `servicesend`
--

CREATE TABLE `servicesend` (
  `ServiceSend_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `telMobitel` varchar(64) DEFAULT NULL,
  `smsMobitel` varchar(64) DEFAULT NULL,
  `emailMobitel` varchar(64) DEFAULT NULL,
  `IPMobitel` varchar(64) DEFAULT NULL,
  `URLMobitel` varchar(64) DEFAULT NULL,
  `PortMobitel` int(11) DEFAULT '0',
  `RfMobitel` varchar(50) DEFAULT NULL,
  `Message_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`ServiceSend_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `servicesend`
--

INSERT INTO `servicesend` VALUES (1,'','',1,0,'102',NULL,NULL,NULL,NULL,0,NULL,0),(2,'','',2,0,'103',NULL,NULL,NULL,NULL,0,NULL,0),(3,'','',3,0,'104',NULL,NULL,NULL,NULL,0,NULL,0),(4,'','',4,0,'105',NULL,NULL,NULL,NULL,0,NULL,0),(5,'','',5,0,'106',NULL,NULL,NULL,NULL,0,NULL,0);

--
-- Table structure for table `servicetypes`
--

CREATE TABLE `servicetypes` (
  `ServiceType_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `Flags` int(11) DEFAULT '0',
  `D1` char(200) DEFAULT NULL,
  `D2` char(200) DEFAULT NULL,
  `D3` char(200) DEFAULT NULL,
  `D4` char(200) DEFAULT NULL,
  `D5` char(200) DEFAULT NULL,
  `D6` char(200) DEFAULT NULL,
  `D7` char(200) DEFAULT NULL,
  `D8` char(200) DEFAULT NULL,
  `D9` char(200) DEFAULT NULL,
  `D10` char(200) DEFAULT NULL,
  PRIMARY KEY (`ServiceType_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `servicetypes`
--

INSERT INTO `servicetypes` VALUES (1,'reserved','Зарезервировано',0,'Parameter 1','Parameter 2','Parameter 3','','','','','','',''),(2,'GSM','Тип сервиса для отправки SMS через GSM соединение',0,'Номер порта','Скорость порта','','','','','','','',''),(3,'Online','Online',0,'IP','Port','Login','Password','','','','','',''),(4,'RF modem','Радиомодем (не реализовано)',0,'Номер порта','Скорость порта','','','','','','','',''),(5,'DC','Тип сервиса \"прямое кабельное соединения\"',0,'Номер порта','Скорость порта',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),(6,'E-Mail','Тип сервиса \" E-Mail \" для отправки SMS через электронную почту',0,'EMAIL','Login','Password','Smtp Server','Pop3 Server','Smtp Port','Pop3 Port','Check Out time',NULL,NULL);

--
-- Table structure for table `setting`
--

CREATE TABLE `setting` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `TimeBreak` time DEFAULT '00:01:00' COMMENT 'Минимальное время остановки',
  `RotationMain` int(11) DEFAULT '100' COMMENT 'Обороты основного двигателя',
  `RotationAdd` int(11) DEFAULT '100' COMMENT 'Обороты доп. двигателя',
  `FuelingEdge` int(11) DEFAULT '0' COMMENT 'Минимальная заправка',
  `band` int(11) DEFAULT '25' COMMENT 'Полоса осреднения',
  `FuelingDischarge` int(11) DEFAULT '0' COMMENT 'Минимальный слив топлива',
  `accelMax` double DEFAULT '1' COMMENT 'Максимальное ускорение',
  `breakMax` double DEFAULT '1' COMMENT 'Максимальное торможение',
  `speedMax` double DEFAULT '70' COMMENT 'Максимальная скорость',
  `idleRunningMain` int(11) DEFAULT '0' COMMENT 'Холостой ход основного двигателя',
  `idleRunningAdd` int(11) DEFAULT '0' COMMENT 'Холосой ход доп. двигателя',
  `Name` char(20) DEFAULT 'Установки' COMMENT 'Название',
  `Desc` char(80) DEFAULT 'Описание установки' COMMENT 'Описание ',
  `AvgFuelRatePerHour` double(10,5) NOT NULL DEFAULT '15.00000' COMMENT 'Средний расход топлива в час',
  `FuelApproximationTime` time NOT NULL DEFAULT '00:02:00' COMMENT 'Временной интервал перед стоянкой, по точка которого уточняется уровень топлива в начале стоянки',
  `TimeGetFuelAfterStop` time NOT NULL DEFAULT '00:00:00' COMMENT 'Временной интервал между началом стоянки и замером уровня топлива',
  `TimeGetFuelBeforeMotion` time NOT NULL DEFAULT '00:00:00' COMMENT 'Временной интервал между замером уровня топлива и началом движения',
  `CzMinCrossingPairTime` time NOT NULL DEFAULT '00:01:00' COMMENT 'Min временной интервал между двумя пересечениями КЗ',
  `FuelerRadiusFinds` int(11) NOT NULL DEFAULT '10' COMMENT 'Радиус поиска заправляемых ТС вокруг топливозаправщика',
  `FuelerMaxTimeStop` time NOT NULL DEFAULT '00:02:00' COMMENT 'Минимальное время до заправки следующего ТС',
  `FuelerMinFuelrate` int(11) NOT NULL DEFAULT '1' COMMENT 'Минимальная величина заправки, что будет попадать в отчет',
  `FuelerCountInMotion` int(11) NOT NULL DEFAULT '0' COMMENT 'Считать ли заправки, при не нулевой скорости',
  `FuelrateWithDischarge` int(11) NOT NULL DEFAULT '0' COMMENT 'Считать ли в расходе сливы',
  `FuelingMinMaxAlgorithm` int(11) NOT NULL DEFAULT '0' COMMENT 'Считать заправки по MAX-MIN',
  `TimeBreakMaxPermitted` time NOT NULL DEFAULT '03:00:00' COMMENT 'Макс. время разрешенной стоянки',
  `InclinometerMaxAngleAxisX` double NOT NULL DEFAULT '5' COMMENT 'Предельный угол наклона относительно продольной оси Х ',
  `InclinometerMaxAngleAxisY` double NOT NULL DEFAULT '5' COMMENT 'Предельный угол наклона относительно продольной оси Y ',
  `MinTimeSwitch` int(11) NOT NULL DEFAULT '0' COMMENT 'Минимальное время между двумя событиями датчика',
  `TimeMinimMovingSize` time NOT NULL DEFAULT '00:00:00' COMMENT 'Минимальное время движения в начале смены',
  `speedMin` float NOT NULL DEFAULT '0' COMMENT 'Минимальная скорость в км/ч',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `setting`
--

INSERT INTO `setting` VALUES (1,'00:01:00',100,100,15,0,7,1,1,80,0,0,'Настройка 1','Настройка по умолчанию',15.00000,'00:02:00','00:00:00','00:00:00','00:01:00',10,'00:02:00',1,0,1,0,'03:00:00',5,5,0,'00:00:00',0);

--
-- Table structure for table `smsnumbers`
--

CREATE TABLE `smsnumbers` (
  `SmsNumber_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `smsNumber` char(14) DEFAULT NULL,
  PRIMARY KEY (`SmsNumber_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `smsnumbers`
--

INSERT INTO `smsnumbers` VALUES (9,'UMC SMS Center','UMC SMS Center descr',0,0,'+380500005010'),(42,'Golden SMS Center','Golden SMS Center descr',0,0,'+380390001008'),(53,'GOLDEN SMS Шлюз','Номер телефона, на который отправляются данные с ТТ через E_MAIL',0,0,'025'),(80,'SMS',' (SMS)',0,0,'+38067'),(81,'RCSB (SMS)','Телефон (SMS)',0,0,'+380672452724'),(82,'RCSB2 (SMS)',' (SMS)',0,0,'+380672452734'),(83,'RCS1 (SMS)',' (SMS)',0,0,'+380637562677'),(84,'RCS2 (SMS)',' (SMS)',0,0,'+380933222277'),(85,'RCS3 (SMS)',' (SMS)',0,0,'+380637562678');

--
-- Table structure for table `sources`
--

CREATE TABLE `sources` (
  `Source_ID` int(11) NOT NULL AUTO_INCREMENT,
  `SourceText` char(200) DEFAULT NULL,
  `SourceError` char(200) DEFAULT NULL,
  PRIMARY KEY (`Source_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `sources`
--


--
-- Table structure for table `specialmessages`
--

CREATE TABLE `specialmessages` (
  `SpecMessage_ID` int(11) NOT NULL AUTO_INCREMENT,
  `DataString` char(50) DEFAULT NULL,
  `DataInteger` int(11) DEFAULT '0',
  `unixtime` char(50) DEFAULT NULL,
  `isNew` int(11) DEFAULT '0',
  PRIMARY KEY (`SpecMessage_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `specialmessages`
--


--
-- Table structure for table `state`
--

CREATE TABLE `state` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `MinValue` double NOT NULL,
  `MaxValue` double NOT NULL,
  `Title` varchar(50) NOT NULL,
  `SensorId` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `State_FK` (`SensorId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=cp1251 COMMENT='Состояния автомобиля';

--
-- Dumping data for table `state`
--

INSERT INTO `state` VALUES (1,0,0.1,'0',7),(2,1,1.1,'1',7),(3,0,0.1,'0',11),(4,1,1.1,'1',11),(5,0,0.1,'0',19),(6,1,1.1,'1',19),(7,0,0.1,'0',22),(8,1,1.1,'1',22),(9,0,0.1,'0',31),(10,1,1.1,'1',31);

--
-- Table structure for table `swupdate`
--

CREATE TABLE `swupdate` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `ShortID` char(4) NOT NULL COMMENT 'Идентификатор телетрека(логин)',
  `Soft` mediumtext NOT NULL COMMENT 'Прошивка',
  `InsertTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Дата и время вставки в таблицу',
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Обновление прошивки телетрека';

--
-- Dumping data for table `swupdate`
--


--
-- Table structure for table `team`
--

CREATE TABLE `team` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` text COMMENT 'Описание',
  `Setting_id` int(11) DEFAULT NULL,
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  `FuelWayKmGrp` double DEFAULT '0' COMMENT 'Норма расхода топлива л/100 км',
  `FuelMotoHrGrp` double DEFAULT '0' COMMENT 'Норма расхода топлива на холостом ходу л/моточас',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`) USING BTREE,
  KEY `Setting_id` (`Setting_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `team`
--

INSERT INTO `team` VALUES (1,'Автомобиль',NULL,1,NULL,0,0),(2,'Трактор',NULL,1,NULL,0,0),(3,'Комбайн',NULL,1,NULL,0,0),(4,'Заправщик',NULL,1,NULL,0,0),(5,'Кран',NULL,1,NULL,0,0),(6,'Транспорт','',1,'',0,0);

--
-- Table structure for table `telnumbers`
--

CREATE TABLE `telnumbers` (
  `TelNumber_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `TelNumber` char(50) DEFAULT NULL,
  PRIMARY KEY (`TelNumber_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=107 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `telnumbers`
--

INSERT INTO `telnumbers` VALUES (56,'RCSB','Телефон',0,0,'80672452724'),(57,'Телефон','Телефон',0,0,'22222222222'),(58,'Телефон','Телефон',0,0,'33333333333'),(59,'Телефон','Телефон',0,0,'44444444444'),(68,'Телефон','Телефон',0,0,'55555555555'),(71,'Телефон','',0,0,'66666666666'),(73,'Телефон','Телефон',0,0,'77777777777'),(74,'Телефон','Телефон',0,0,'88888888888'),(75,'Телефон','',0,0,'99999999999'),(81,'RCS3','',0,0,'80637562678'),(89,'RCS2','',0,0,'80933222277'),(90,'RCS1','',0,0,'80637562677'),(97,'RCSB2','',0,0,'80672452734'),(101,'Телефон','',0,0,'1'),(102,'rcs','mtel',0,0,'+380673599693'),(103,'rcs','mtel',0,0,'+37254944540'),(104,'rcs','mtel',0,0,'+380671136988'),(105,'rcs','mtel',0,0,'+380674531675'),(106,'rcs','mtel',0,0,'+380675156339');

--
-- Table structure for table `temp`
--

CREATE TABLE `temp` (
  `datagps_id` int(10) unsigned NOT NULL DEFAULT '0',
  `sensor_id` int(10) unsigned NOT NULL DEFAULT '0',
  `Value` double(10,2) NOT NULL DEFAULT '0.00'
) ENGINE=MEMORY DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `temp`
--


--
-- Table structure for table `tmpdatagps`
--

CREATE TABLE `tmpdatagps` (
  `DataGps_ID` int(11) NOT NULL DEFAULT '0',
  `Mobitel_ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Latitude` int(11) DEFAULT '0',
  `Longitude` int(11) DEFAULT '0',
  `Altitude` int(11) DEFAULT NULL,
  `UnixTime` int(11) DEFAULT '0',
  `Speed` smallint(6) DEFAULT '0',
  `Direction` int(11) NOT NULL DEFAULT '0',
  `Valid` tinyint(4) DEFAULT '1',
  `InMobitelID` int(11) DEFAULT NULL,
  `Events` int(10) unsigned DEFAULT '0',
  `Sensor1` tinyint(4) unsigned DEFAULT '0',
  `Sensor2` tinyint(4) unsigned DEFAULT '0',
  `Sensor3` tinyint(4) unsigned DEFAULT '0',
  `Sensor4` tinyint(4) unsigned DEFAULT '0',
  `Sensor5` tinyint(4) unsigned DEFAULT '0',
  `Sensor6` tinyint(4) unsigned DEFAULT '0',
  `Sensor7` tinyint(4) unsigned DEFAULT '0',
  `Sensor8` tinyint(4) unsigned DEFAULT '0',
  `LogID` int(11) DEFAULT '0',
  `isShow` tinyint(4) DEFAULT '0',
  `whatIs` smallint(6) unsigned DEFAULT '0',
  `Counter1` int(11) NOT NULL DEFAULT '-1',
  `Counter2` int(11) NOT NULL DEFAULT '-1',
  `Counter3` int(11) NOT NULL DEFAULT '-1',
  `Counter4` int(11) NOT NULL DEFAULT '-1'
) ENGINE=MEMORY DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `tmpdatagps`
--


--
-- Table structure for table `transition`
--

CREATE TABLE `transition` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `InitialStateId` int(11) DEFAULT NULL,
  `FinalStateId` int(11) DEFAULT NULL,
  `Title` varchar(50) NOT NULL,
  `SensorId` int(11) DEFAULT NULL,
  `IconName` varchar(50) NOT NULL,
  `SoundName` varchar(50) NOT NULL,
  `Enabled` tinyint(1) NOT NULL,
  `ViewInReport` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `Sensors_FK` (`SensorId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=cp1251 COMMENT='Переходы между состояниями';

--
-- Dumping data for table `transition`
--

INSERT INTO `transition` VALUES (1,1,2,'1',7,'Default','Default',0,1),(2,2,1,'0',7,'Default','Default',0,1),(3,3,4,'1',11,'Default','Default',0,1),(4,4,3,'0',11,'Default','Default',0,1),(5,5,6,'1',19,'Default','Default',0,1),(6,6,5,'0',19,'Default','Default',0,1),(7,7,8,'1',22,'Default','Default',0,1),(8,8,7,'0',22,'Default','Default',0,1),(9,9,10,'1',31,'Default','Default',0,1),(10,10,9,'0',31,'Default','Default',0,1);

--
-- Table structure for table `users_acs_objects`
--

CREATE TABLE `users_acs_objects` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_role` int(11) NOT NULL,
  `Id_type` int(11) NOT NULL,
  `Id_object` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `FK_users_acs_objects_users_acs_roles_Id` (`Id_role`),
  CONSTRAINT `FK_users_acs_objects_users_acs_roles_Id` FOREIGN KEY (`Id_role`) REFERENCES `users_acs_roles` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `users_acs_objects`
--

INSERT INTO `users_acs_objects` VALUES (1,2,3,10),(2,2,3,13),(3,2,3,15),(4,2,3,16),(5,2,3,19),(6,2,3,20),(7,2,3,21),(8,2,3,22);

--
-- Table structure for table `users_acs_roles`
--

CREATE TABLE `users_acs_roles` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `users_acs_roles`
--

INSERT INTO `users_acs_roles` VALUES (1,'Администратор'),(2,'Leus');

--
-- Table structure for table `users_actions_log`
--

CREATE TABLE `users_actions_log` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `TypeLog` int(11) NOT NULL DEFAULT '0',
  `DateAction` datetime NOT NULL,
  `Id_document` int(11) NOT NULL DEFAULT '0',
  `TextLog` varchar(255) NOT NULL,
  `User` varchar(127) NOT NULL,
  `Computer` varchar(63) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=147 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `users_actions_log`
--

INSERT INTO `users_actions_log` VALUES (1,8,'2022-02-19 14:23:33',0,'25->0 Період згладжування','admin','MNK'),(2,8,'2022-02-19 14:23:33',0,'10->7 Поріг зливу','admin','MNK'),(3,8,'2022-02-19 14:23:33',0,'50->15 Поріг заправки','admin','MNK'),(4,8,'2022-02-19 14:23:33',0,'70->80 Максимальна швидкість руху, км/год','admin','MNK'),(5,8,'2022-02-19 14:23:33',0,'0->1 Не враховувати зливи у витратах','admin','MNK'),(6,9,'2022-02-19 14:40:04',1,'Вхід','admin','MNK'),(7,9,'2022-02-19 14:40:05',1,'Завантижити','admin','MNK'),(8,9,'2022-02-19 14:40:18',9,'Вхід','admin','MNK'),(9,9,'2022-02-19 14:40:19',9,'Завантижити','admin','MNK'),(10,9,'2023-01-30 11:02:53',1,'Вхід','admin','DESKTOP-Q3JP5LQ'),(11,9,'2023-01-30 11:03:18',1,'Зберегти як','admin','DESKTOP-Q3JP5LQ'),(12,9,'2023-01-30 11:03:59',9,'Вхід','admin','DESKTOP-Q3JP5LQ'),(13,9,'2023-01-30 11:04:56',9,'Set  (29 - Кастомні) to  670','admin','DESKTOP-Q3JP5LQ'),(14,9,'2023-01-30 11:05:00',9,'Set  (29 - Виміряні) to  416','admin','DESKTOP-Q3JP5LQ'),(15,9,'2023-01-30 11:05:07',9,'Вхід','admin','DESKTOP-Q3JP5LQ'),(16,9,'2023-01-30 11:05:12',1,'Вхід','admin','DESKTOP-Q3JP5LQ'),(17,9,'2023-01-30 11:05:51',1,'Set  (26 - Кастомні) to  450','admin','DESKTOP-Q3JP5LQ'),(18,9,'2023-01-30 11:05:54',1,'Set  (26 - Виміряні) to  223','admin','DESKTOP-Q3JP5LQ'),(19,9,'2023-01-30 11:06:37',1,'Вхід','admin','DESKTOP-Q3JP5LQ'),(20,9,'2023-01-30 11:06:47',9,'Вхід','admin','DESKTOP-Q3JP5LQ'),(21,9,'2023-01-30 11:07:30',1,'Вхід','admin','DESKTOP-Q3JP5LQ'),(22,9,'2023-01-30 11:07:31',1,'Зберегти як','admin','DESKTOP-Q3JP5LQ'),(23,9,'2023-11-06 16:11:37',13,'Вхід','admin','MNK_ROG'),(24,9,'2023-11-06 16:11:38',13,'Завантижити','admin','MNK_ROG'),(25,9,'2024-03-27 12:06:47',20,'Вхід','admin','MNK_ROG'),(26,9,'2024-03-27 12:06:48',20,'Завантижити','admin','MNK_ROG'),(27,9,'2024-04-05 13:12:05',23,'Вхід','admin','MNK_ROG'),(28,9,'2024-04-05 13:12:06',23,'Завантижити','admin','MNK_ROG'),(29,9,'2025-02-02 18:14:07',23,'Вхід','admin','MNK_ROG'),(30,9,'2025-02-02 18:14:10',23,'Delete record 0','admin','MNK_ROG'),(31,9,'2025-02-02 18:14:10',23,'Delete record 0','admin','MNK_ROG'),(32,9,'2025-02-02 18:14:10',23,'Delete record 0','admin','MNK_ROG'),(33,9,'2025-02-02 18:14:11',23,'Delete record 0','admin','MNK_ROG'),(34,9,'2025-02-02 18:14:11',23,'Delete record 0','admin','MNK_ROG'),(35,9,'2025-02-02 18:14:11',23,'Delete record 0','admin','MNK_ROG'),(36,9,'2025-02-02 18:14:11',23,'Delete record 0','admin','MNK_ROG'),(37,9,'2025-02-02 18:14:11',23,'Delete record 0','admin','MNK_ROG'),(38,9,'2025-02-02 18:14:12',23,'Delete record 0','admin','MNK_ROG'),(39,9,'2025-02-02 18:14:12',23,'Delete record 0','admin','MNK_ROG'),(40,9,'2025-02-02 18:14:12',23,'Delete record 0','admin','MNK_ROG'),(41,9,'2025-02-02 18:14:12',23,'Delete record 0','admin','MNK_ROG'),(42,9,'2025-02-02 18:14:12',23,'Delete record 0','admin','MNK_ROG'),(43,9,'2025-02-02 18:14:13',23,'Delete record 0','admin','MNK_ROG'),(44,9,'2025-02-02 18:14:13',23,'Delete record 0','admin','MNK_ROG'),(45,9,'2025-02-02 18:14:13',23,'Delete record 0','admin','MNK_ROG'),(46,9,'2025-02-02 18:14:13',23,'Delete record 0','admin','MNK_ROG'),(47,9,'2025-02-02 18:14:13',23,'Delete record 0','admin','MNK_ROG'),(48,9,'2025-02-02 18:14:14',23,'Delete record 0','admin','MNK_ROG'),(49,9,'2025-02-02 18:14:14',23,'Delete record 0','admin','MNK_ROG'),(50,9,'2025-02-02 18:14:14',23,'Delete record 0','admin','MNK_ROG'),(51,9,'2025-02-02 18:14:14',23,'Delete record 0','admin','MNK_ROG'),(52,9,'2025-02-02 18:14:14',23,'Delete record 0','admin','MNK_ROG'),(53,9,'2025-02-02 18:14:15',23,'Delete record 0','admin','MNK_ROG'),(54,9,'2025-02-02 18:14:15',23,'Delete record 0','admin','MNK_ROG'),(55,9,'2025-02-02 18:14:15',23,'Delete record 0','admin','MNK_ROG'),(56,9,'2025-02-02 18:14:15',23,'Delete record 0','admin','MNK_ROG'),(57,9,'2025-02-02 18:14:16',23,'Delete record 0','admin','MNK_ROG'),(58,9,'2025-02-02 18:14:16',23,'Delete record 0','admin','MNK_ROG'),(59,9,'2025-02-02 18:14:16',23,'Delete record 0','admin','MNK_ROG'),(60,9,'2025-02-02 18:14:16',23,'Delete record 0','admin','MNK_ROG'),(61,9,'2025-02-02 18:14:16',23,'Delete record 0','admin','MNK_ROG'),(62,9,'2025-02-02 18:14:19',23,'Delete record 0','admin','MNK_ROG'),(63,9,'2025-02-02 18:14:19',23,'Delete record 0','admin','MNK_ROG'),(64,9,'2025-02-02 18:14:19',23,'Delete record 0','admin','MNK_ROG'),(65,9,'2025-02-02 18:14:20',23,'Delete record 0','admin','MNK_ROG'),(66,9,'2025-02-02 18:14:20',23,'Delete record 0','admin','MNK_ROG'),(67,9,'2025-02-02 18:14:20',23,'Delete record 0','admin','MNK_ROG'),(68,9,'2025-02-02 18:14:20',23,'Delete record 0','admin','MNK_ROG'),(69,9,'2025-02-02 18:14:20',23,'Delete record 0','admin','MNK_ROG'),(70,9,'2025-02-02 18:14:21',23,'Delete record 0','admin','MNK_ROG'),(71,9,'2025-02-02 18:14:27',23,'Вхід','admin','MNK_ROG'),(72,9,'2025-02-02 18:14:28',23,'Завантижити','admin','MNK_ROG'),(73,9,'2025-02-02 18:14:36',24,'Вхід','admin','MNK_ROG'),(74,9,'2025-02-02 18:14:37',24,'Завантижити','admin','MNK_ROG'),(75,9,'2025-02-02 18:14:47',23,'Вхід','admin','MNK_ROG'),(76,9,'2025-05-27 11:30:25',25,'Вхід','admin','MNK_ROG'),(77,9,'2025-05-27 11:30:26',25,'Завантижити','admin','MNK_ROG'),(78,9,'2026-02-12 18:00:13',20,'Вхід','admin','MNK_ROG'),(79,9,'2026-02-12 18:01:53',20,'Вхід','admin','MNK_ROG'),(80,9,'2026-02-12 18:01:55',20,'Зберегти як','admin','MNK_ROG'),(81,9,'2026-02-12 18:03:15',13,'Вхід','admin','MNK_ROG'),(82,9,'2026-02-12 18:03:23',13,'Зберегти як','admin','MNK_ROG'),(83,9,'2026-02-12 18:06:31',20,'Вхід','admin','MNK_ROG'),(84,9,'2026-02-12 18:11:19',13,'Вхід','admin','MNK_ROG'),(85,9,'2026-02-12 18:11:27',20,'Вхід','admin','MNK_ROG'),(86,9,'2026-02-12 18:13:07',20,'Вхід','admin','MNK_ROG'),(87,9,'2026-02-12 18:13:13',20,'Delete record 0','admin','MNK_ROG'),(88,9,'2026-02-12 18:13:14',20,'Delete record 0','admin','MNK_ROG'),(89,9,'2026-02-12 18:13:14',20,'Delete record 0','admin','MNK_ROG'),(90,9,'2026-02-12 18:13:14',20,'Delete record 0','admin','MNK_ROG'),(91,9,'2026-02-12 18:13:14',20,'Delete record 0','admin','MNK_ROG'),(92,9,'2026-02-12 18:13:14',20,'Delete record 0','admin','MNK_ROG'),(93,9,'2026-02-12 18:13:15',20,'Delete record 0','admin','MNK_ROG'),(94,9,'2026-02-12 18:13:15',20,'Delete record 0','admin','MNK_ROG'),(95,9,'2026-02-12 18:13:15',20,'Delete record 0','admin','MNK_ROG'),(96,9,'2026-02-12 18:13:15',20,'Delete record 0','admin','MNK_ROG'),(97,9,'2026-02-12 18:13:15',20,'Delete record 0','admin','MNK_ROG'),(98,9,'2026-02-12 18:13:16',20,'Delete record 0','admin','MNK_ROG'),(99,9,'2026-02-12 18:13:16',20,'Delete record 0','admin','MNK_ROG'),(100,9,'2026-02-12 18:13:16',20,'Delete record 0','admin','MNK_ROG'),(101,9,'2026-02-12 18:13:16',20,'Delete record 0','admin','MNK_ROG'),(102,9,'2026-02-12 18:13:16',20,'Delete record 0','admin','MNK_ROG'),(103,9,'2026-02-12 18:13:19',20,'Delete record 0','admin','MNK_ROG'),(104,9,'2026-02-12 18:13:19',20,'Delete record 0','admin','MNK_ROG'),(105,9,'2026-02-12 18:13:19',20,'Delete record 0','admin','MNK_ROG'),(106,9,'2026-02-12 18:13:19',20,'Delete record 0','admin','MNK_ROG'),(107,9,'2026-02-12 18:13:20',20,'Delete record 0','admin','MNK_ROG'),(108,9,'2026-02-12 18:13:20',20,'Delete record 0','admin','MNK_ROG'),(109,9,'2026-02-12 18:13:20',20,'Delete record 0','admin','MNK_ROG'),(110,9,'2026-02-12 18:13:20',20,'Delete record 0','admin','MNK_ROG'),(111,9,'2026-02-12 18:13:20',20,'Delete record 0','admin','MNK_ROG'),(112,9,'2026-02-12 18:13:27',13,'Вхід','admin','MNK_ROG'),(113,9,'2026-02-12 18:13:30',13,'Delete record 0','admin','MNK_ROG'),(114,9,'2026-02-12 18:13:30',13,'Delete record 0','admin','MNK_ROG'),(115,9,'2026-02-12 18:13:30',13,'Delete record 0','admin','MNK_ROG'),(116,9,'2026-02-12 18:13:30',13,'Delete record 0','admin','MNK_ROG'),(117,9,'2026-02-12 18:13:30',13,'Delete record 0','admin','MNK_ROG'),(118,9,'2026-02-12 18:13:31',13,'Delete record 0','admin','MNK_ROG'),(119,9,'2026-02-12 18:13:31',13,'Delete record 0','admin','MNK_ROG'),(120,9,'2026-02-12 18:13:31',13,'Delete record 0','admin','MNK_ROG'),(121,9,'2026-02-12 18:13:31',13,'Delete record 0','admin','MNK_ROG'),(122,9,'2026-02-12 18:13:31',13,'Delete record 0','admin','MNK_ROG'),(123,9,'2026-02-12 18:13:32',13,'Delete record 0','admin','MNK_ROG'),(124,9,'2026-02-12 18:13:32',13,'Delete record 0','admin','MNK_ROG'),(125,9,'2026-02-12 18:13:32',13,'Delete record 0','admin','MNK_ROG'),(126,9,'2026-02-12 18:13:32',13,'Delete record 0','admin','MNK_ROG'),(127,9,'2026-02-12 18:13:33',13,'Delete record 0','admin','MNK_ROG'),(128,9,'2026-02-12 18:13:33',13,'Delete record 0','admin','MNK_ROG'),(129,9,'2026-02-12 18:13:33',13,'Delete record 0','admin','MNK_ROG'),(130,9,'2026-02-12 18:13:33',13,'Delete record 0','admin','MNK_ROG'),(131,9,'2026-02-12 18:13:33',13,'Delete record 0','admin','MNK_ROG'),(132,9,'2026-02-12 18:13:34',13,'Delete record 0','admin','MNK_ROG'),(133,9,'2026-02-12 18:13:34',13,'Delete record 0','admin','MNK_ROG'),(134,9,'2026-02-12 18:13:34',13,'Delete record 0','admin','MNK_ROG'),(135,9,'2026-02-12 18:13:34',13,'Delete record 0','admin','MNK_ROG'),(136,9,'2026-02-12 18:13:36',13,'Delete record 0','admin','MNK_ROG'),(137,9,'2026-02-12 18:13:37',13,'Delete record 0','admin','MNK_ROG'),(138,9,'2026-02-12 18:13:37',13,'Delete record 0','admin','MNK_ROG'),(139,9,'2026-02-12 18:13:37',13,'Delete record 0','admin','MNK_ROG'),(140,9,'2026-02-12 18:13:37',13,'Delete record 0','admin','MNK_ROG'),(141,9,'2026-02-12 18:13:37',13,'Delete record 0','admin','MNK_ROG'),(142,9,'2026-02-12 18:13:38',13,'Delete record 0','admin','MNK_ROG'),(143,9,'2026-02-12 18:13:38',13,'Delete record 0','admin','MNK_ROG'),(144,9,'2026-02-12 18:13:38',13,'Delete record 0','admin','MNK_ROG'),(145,9,'2026-02-12 18:13:41',20,'Вхід','admin','MNK_ROG'),(146,9,'2026-02-12 18:13:42',20,'Завантижити','admin','MNK_ROG');

--
-- Table structure for table `users_list`
--

CREATE TABLE `users_list` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL,
  `WinLogin` varchar(50) DEFAULT NULL,
  `Password` blob NOT NULL,
  `Admin` tinyint(1) NOT NULL DEFAULT '0',
  `Id_role` int(11) DEFAULT '0' COMMENT 'Код роли пользователя',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `users_list`
--

INSERT INTO `users_list` VALUES (1,'Администратор','',_binary '�e�Y B/�A~Hg\�\�O��J?��~������z\�',1,1),(2,'Leus','',_binary 'B\���3\�`G\�T�S[rP�ҙj\�Up��>s�\�\�x',0,2);

--
-- Table structure for table `users_reports_list`
--

CREATE TABLE `users_reports_list` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `ReportType` varchar(127) NOT NULL,
  `ReportCaption` varchar(127) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `users_reports_list`
--

INSERT INTO `users_reports_list` VALUES (1,'KilometrageControl','Пробег'),(2,'KilometrageDayControl','Пробег суточный'),(3,'KilometrageTotal','Пробег общий'),(4,'FuelControl','Заправки'),(5,'KilometrageControlDut','Пробег+ДУТ'),(6,'FuelExpensesControlDutDay','Топливо суточный ДУТ'),(7,'FuelExpensesControlDut','Общий расход ДУТ'),(8,'FlowmeterControl','Расход'),(9,'FuelExpensesControlDrt','Общий расход ДРТ'),(10,'GrainLevel','Уровень зерна'),(11,'RoadSafetyControl','Безопасность'),(12,'ParamOfMovingControl','Параметры движения'),(13,'CzDetailed','КЗ Детальный'),(14,'CZ_Detailed_General','КЗ Групповой'),(15,'FuelCZ_Inkom_DRT','ДРТ - КЗ'),(16,'FuelCZ_Inkom_DUT','ДУТ - КЗ'),(17,'SensorEventsControl','События датчиков'),(18,'RotationControl','Обороты'),(19,'PassTrafficDaily','Пассажиры суточный'),(20,'FuelerControlDrt','Заправщик'),(21,'ReportDrivers','Водители (RFID)'),(22,'ReportVehicles','Идентификация ТС');

--
-- Table structure for table `vehicle`
--

CREATE TABLE `vehicle` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `MakeCar` text COMMENT 'Марка автомобиля',
  `NumberPlate` text COMMENT 'Номерной знак',
  `Team_id` int(11) DEFAULT NULL,
  `Mobitel_id` int(11) DEFAULT NULL,
  `Odometr` int(11) DEFAULT '0' COMMENT 'Показания одометра',
  `CarModel` text COMMENT 'Модель',
  `setting_id` int(11) DEFAULT '1',
  `odoTime` datetime DEFAULT NULL COMMENT 'Дата и время сверки одометра',
  `driver_id` int(11) DEFAULT '-1',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  `Category_id` int(11) DEFAULT NULL COMMENT 'Категория транспортая',
  `Category_id2` int(11) DEFAULT NULL COMMENT 'Категория2 транспорта',
  `PcbVersionId` int(11) DEFAULT '-1' COMMENT 'Версия плат датчика назначенная на машину',
  `Category_id3` int(11) DEFAULT NULL COMMENT 'Категория3 транспорта',
  `Category_id4` int(11) DEFAULT NULL COMMENT 'Категория4 транспорта',
  `FuelWayLiter` double DEFAULT '0' COMMENT 'Расход топлива л/100 км',
  `FuelMotorLiter` double DEFAULT '0' COMMENT 'Расход топлива л/моточас',
  `Identifier` int(11) DEFAULT '0' COMMENT 'Идентификатор машины',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`) USING BTREE,
  KEY `Mobitel_id` (`Mobitel_id`) USING BTREE,
  KEY `Team_id` (`Team_id`) USING BTREE,
  KEY `setting_id` (`setting_id`) USING BTREE,
  KEY `FK_vehicle_vehicle_category_Id` (`Category_id`),
  KEY `FK_vehicle_vehicle_category_Id2` (`Category_id2`),
  KEY `FK_vehicle_vehicle_category_Id3` (`Category_id3`),
  KEY `FK_vehicle_vehicle_category_Id4` (`Category_id4`),
  CONSTRAINT `FK_vehicle_vehicle_category_Id` FOREIGN KEY (`Category_id`) REFERENCES `vehicle_category` (`Id`),
  CONSTRAINT `FK_vehicle_vehicle_category_Id2` FOREIGN KEY (`Category_id2`) REFERENCES `vehicle_category2` (`Id`),
  CONSTRAINT `FK_vehicle_vehicle_category_Id3` FOREIGN KEY (`Category_id3`) REFERENCES `vehicle_category3` (`Id`),
  CONSTRAINT `FK_vehicle_vehicle_category_Id4` FOREIGN KEY (`Category_id4`) REFERENCES `vehicle_category4` (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `vehicle`
--

INSERT INTO `vehicle` VALUES (1,'Mercedes-Benz','BK7649HP',6,942814777,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(2,'Scania','BK5143HI',6,809055537,0,'R420',1,NULL,1,'',NULL,NULL,19,NULL,NULL,0,0,0),(3,'Renault','BK5459IE',6,842283059,0,'',1,NULL,1,'',NULL,NULL,19,NULL,NULL,0,0,0),(4,'Scania','BK9720IC',6,909522486,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(5,'Volvo','BK4565IT',6,942879286,0,'',1,NULL,1,'',NULL,NULL,19,NULL,NULL,0,0,0);

--
-- Table structure for table `vehicle_category`
--

CREATE TABLE `vehicle_category` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) NOT NULL COMMENT 'Категория транспортного средства',
  `Tonnage` decimal(10,3) NOT NULL DEFAULT '0.000' COMMENT 'Грузоподъемность,  тонн',
  `FuelNormMoving` double NOT NULL DEFAULT '0' COMMENT 'норма расхода топлива в движении л/100 км',
  `FuelNormParking` double NOT NULL DEFAULT '0' COMMENT 'норма расхода топлива на холостых оборотах л/час',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `vehicle_category`
--


--
-- Table structure for table `vehicle_category2`
--

CREATE TABLE `vehicle_category2` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL COMMENT 'Категория2 транспортного средства',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `vehicle_category2`
--


--
-- Table structure for table `vehicle_category3`
--

CREATE TABLE `vehicle_category3` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL COMMENT 'Категория3 транспортного средства',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `vehicle_category3`
--


--
-- Table structure for table `vehicle_category4`
--

CREATE TABLE `vehicle_category4` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL COMMENT 'Категория4 транспортного средства',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `vehicle_category4`
--


--
-- Table structure for table `vehicle_commentary`
--

CREATE TABLE `vehicle_commentary` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Comment` varchar(255) DEFAULT NULL,
  `Mobitel_id` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Комментарий для машины';

--
-- Dumping data for table `vehicle_commentary`
--


--
-- Table structure for table `ver`
--

CREATE TABLE `ver` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Num` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Номер текущей сборки БД',
  `Desc` text NOT NULL COMMENT 'Описание текущей сборки БД',
  `time` datetime DEFAULT NULL COMMENT 'Время обновления',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `ver`
--

INSERT INTO `ver` VALUES (1,1,'Сборка от 9.12.2008','2008-12-09 00:00:00'),(2,2,'Сборка от 10.02.2009','2009-02-10 00:00:00');

--
-- Table structure for table `zone_category`
--

CREATE TABLE `zone_category` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) DEFAULT NULL COMMENT 'Категория зоны',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Категории для зон';

--
-- Dumping data for table `zone_category`
--


--
-- Table structure for table `zone_category2`
--

CREATE TABLE `zone_category2` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) DEFAULT NULL COMMENT 'Категория2 зоны',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Категории2 для зон';

--
-- Dumping data for table `zone_category2`
--


--
-- Table structure for table `zonerelations`
--

CREATE TABLE `zonerelations` (
  `ZoneRelation_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Zone_ID` int(11) DEFAULT '0',
  `ConfigZoneSet_ID` int(11) DEFAULT '0',
  `In_flag` tinyint(4) NOT NULL DEFAULT '0',
  `Out_flag` tinyint(4) NOT NULL DEFAULT '0',
  `In_flag2` tinyint(4) NOT NULL DEFAULT '0',
  `Out_flag2` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ZoneRelation_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `zonerelations`
--


--
-- Table structure for table `zones`
--

CREATE TABLE `zones` (
  `Zone_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` text,
  `ID` int(11) DEFAULT '0',
  `Status` tinyint(4) DEFAULT '0',
  `Square` double(14,5) DEFAULT '0.00000' COMMENT 'Площадь контрольной зоны',
  `ZoneColor` int(11) DEFAULT '0' COMMENT 'Цвет контрольной зоны',
  `TextColor` int(11) DEFAULT '0' COMMENT 'Цвет подписи контрольной зоны',
  `TextFontName` char(50) DEFAULT 'Microsoft Sans Serif' COMMENT 'Шрирфт подписи контрольной зоны',
  `TextFontSize` double(5,2) DEFAULT '25.00' COMMENT 'Размер шрирфта подписи контрольной зоны',
  `TextFontParams` char(8) DEFAULT '0;0;0;0;' COMMENT 'Параметры шрирфта подписи контрольной зоны',
  `Icon` blob COMMENT 'Иконка контрольной зоны',
  `HatchStyle` int(11) DEFAULT '0' COMMENT 'Текстура контрольной зоны',
  `DateCreate` datetime DEFAULT NULL COMMENT 'Дата создания',
  `Id_main` int(11) DEFAULT '0' COMMENT 'Ссылка на элемент верхнего уровня в иерархии',
  `Level` tinyint(4) DEFAULT '1' COMMENT 'Уровень в иерархии',
  `StyleId` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'ID стиля зоны',
  `ZonesGroupId` int(10) unsigned NOT NULL DEFAULT '1' COMMENT 'ID Группы зон',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  `Category_id` int(11) DEFAULT NULL COMMENT 'Категория для зоны',
  `Category_id2` int(11) DEFAULT NULL COMMENT 'Категория2 для зоны',
  PRIMARY KEY (`Zone_ID`),
  KEY `FK_zones_zonesgroup` (`ZonesGroupId`),
  CONSTRAINT `FK_zones_zonesgroup` FOREIGN KEY (`ZonesGroupId`) REFERENCES `zonesgroup` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `zones`
--


--
-- Table structure for table `zonesgroup`
--

CREATE TABLE `zonesgroup` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Title` varchar(50) NOT NULL,
  `Description` varchar(200) NOT NULL,
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=cp1251;

--
-- Dumping data for table `zonesgroup`
--

INSERT INTO `zonesgroup` VALUES (1,'Все зоны','НЕ УДАЛЯТЬ! Корневой элемент дерева контрольных зон',NULL);

--
-- Dumping events for database 'leus'
--

--
-- Dumping routines for database 'leus'
--
/*!50003 DROP PROCEDURE IF EXISTS `BMCTransferBuffer` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `BMCTransferBuffer`(IN DatagpsIsUpdated INT, IN Datagps64IsUpdated INT)
    COMMENT 'v1'
BEGIN
	DECLARE MobitelID INT;
	DECLARE done INT DEFAULT FALSE;
	DECLARE CursorMobitels CURSOR FOR SELECT Mobitel_ID FROM datagpsbuffer_bmc WHERE `Online`=1;
	DECLARE CursorMobitels64 CURSOR FOR SELECT Mobitel_ID FROM datagpsbuffer_bmc64 WHERE `Online`=1;
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
    
	/* datagps */
	IF DatagpsIsUpdated THEN
		OPEN CursorMobitels;
		read_loop: LOOP
			FETCH CursorMobitels INTO MobitelID;
			IF done THEN
				LEAVE read_loop;
			END IF;
			DELETE FROM `online` WHERE Mobitel_ID=MobitelID AND UnixTime <= (SELECT COALESCE(UnixTime, 0) FROM (SELECT UnixTime FROM `online` WHERE Mobitel_ID=MobitelID ORDER BY UnixTime DESC LIMIT 100, 1) o);
		END LOOP;
		CLOSE CursorMobitels;
		UPDATE mobitels m,datagpsbuffer_bmc b SET m.LastInsertTime=b.UnixTime WHERE m.Mobitel_ID=b.Mobitel_ID AND m.LastInsertTime<b.UnixTime;
	END IF;
	/* datagps64 */
	IF Datagps64IsUpdated THEN
		OPEN CursorMobitels64;
		read_loop: LOOP
			FETCH CursorMobitels64 INTO MobitelID;
			IF done THEN
				LEAVE read_loop;
			END IF;
			DELETE FROM `online64` WHERE Mobitel_ID=MobitelID AND UnixTime <= (SELECT COALESCE(UnixTime, 0) FROM (SELECT UnixTime FROM `online64` WHERE Mobitel_ID=MobitelID ORDER BY UnixTime DESC LIMIT 100, 1) o);
		END LOOP;
		CLOSE CursorMobitels64;
		UPDATE mobitels m,datagpsbuffer_bmc64 b SET m.LastInsertTime=b.UnixTime WHERE m.Mobitel_ID=b.Mobitel_ID AND m.LastInsertTime<b.UnixTime;
	END IF;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckOdo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CheckOdo`(IN m_id INTEGER(11), IN end_time DATETIME)
    SQL SECURITY INVOKER
BEGIN

  SELECT 

   FROM_UNIXTIME(datagps.UnixTime) AS `time` ,

   (datagps.Latitude / 600000.00000) AS Lat,

   (datagps.Longitude / 600000.00000) AS Lon

  FROM

    datagps

  WHERE

    datagps.Mobitel_ID = m_id AND 

    datagps.UnixTime BETWEEN (SELECT UNIX_TIMESTAMP(odoTime)  FROM vehicle WHERE Mobitel_id = m_id) AND 

    UNIX_TIMESTAMP(end_time) AND 

    Valid = 1;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `CleaningDataGpsLostOn` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CleaningDataGpsLostOn`()
    SQL SECURITY INVOKER
    COMMENT 'Сия процедура удаляет не корректно оформленные диапазоны пропусков из таблицы datagpslost_on'
BEGIN

  /* удаляем записи у которых BeginSrvPacketId >= EndSrvPacketId */

  DELETE d FROM datagpslost_on d WHERE d.Begin_SrvPacketID >= d.End_SrvPacketID;

  /* удаляем записи у которых EndLogId - BeginLogId <= 1 */

  DELETE d FROM datagpslost_on d WHERE d.End_LogID - d.Begin_LogID <= 1;

  /* удаляем записи которые с заданным LogId и SrvPackId отсутвут в таблице datagps или datagps64 (фантомные записи) */



  CREATE TEMPORARY TABLE MobiTemp (Id bigint(20) UNSIGNED DEFAULT 0)ENGINE = INNODB

    CHARACTER SET cp1251

    COLLATE cp1251_general_ci

    COMMENT = 'Промежуточная временная таблица';



  INSERT INTO MobiTemp SELECT d.Id FROM datagpslost_on d WHERE 

  NOT EXISTS(SELECT NULL FROM datagps d1 WHERE (d.Mobitel_ID = d1.Mobitel_ID) AND ((d.Begin_LogID = d1.LogID) AND (d.Begin_SrvPacketID = d1.SrvPacketID))) AND 

  NOT EXISTS(SELECT NULL FROM datagps64 d2 WHERE (d.Mobitel_ID = d2.Mobitel_ID) AND ((d.Begin_LogID = d2.LogID) AND (d.Begin_SrvPacketID = d2.SrvPacketID))); 

  DELETE d FROM datagpslost_on d, MobiTemp m WHERE m.Id = d.Id;



  TRUNCATE MobiTemp;



  INSERT INTO MobiTemp SELECT d.Id FROM datagpslost_on d WHERE 

  NOT EXISTS(SELECT NULL FROM datagps d1 WHERE (d.Mobitel_ID = d1.Mobitel_ID) AND ((d.End_LogID = d1.LogID) AND (d.End_SrvPacketID = d1.SrvPacketID))) AND 

  NOT EXISTS(SELECT NULL FROM datagps64 d2 WHERE (d.Mobitel_ID = d2.Mobitel_ID) AND ((d.End_LogID = d2.LogID) AND (d.End_SrvPacketID = d2.SrvPacketID))); 

  DELETE d FROM datagpslost_on d, MobiTemp m WHERE m.Id = d.Id;



  DROP TEMPORARY TABLE MobiTemp;



  SELECT 1;

  

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `dataview` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `dataview`(

  IN m_id INTEGER(11), 

  IN val BOOL, 

  IN begin_time DATETIME, 

  IN end_time DATETIME)
    SQL SECURITY INVOKER
BEGIN

  SELECT DataGps_ID AS DataGps_ID,

    Mobitel_ID AS Mobitel_ID,

    ((Latitude * 1.0000) / 600000) AS Lat,

    ((Longitude * 1.0000) / 600000) AS Lon,

    Altitude AS Altitude,

    FROM_UNIXTIME(UnixTime) AS `time`,

    (Speed * 1.852) AS speed,

    ((Direction * 360) / 255) AS direction,

    Valid AS Valid,

    (Sensor8 + (Sensor7 << 8) + (Sensor6 << 16) + 

      (Sensor5 << 24) + (Sensor4 << 32) + (Sensor3 << 40) + 

      (Sensor2 << 48) + (Sensor1 << 56)) AS sensor,

    Events AS Events,

    LogID AS LogID 

  FROM datagps 

  WHERE Mobitel_ID = m_id AND  

    (UnixTime BETWEEN UNIX_TIMESTAMP(begin_time) AND UNIX_TIMESTAMP(end_time)) AND                                                                                                                                

    (Valid = val) AND NOT (Latitude = 0 AND Longitude =0)

  ORDER BY UnixTime;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `delDupSrvPacket` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `delDupSrvPacket`()
    SQL SECURITY INVOKER
    COMMENT 'Удаляет дубликаты SrvPacketID из таблицы datagpsbuffer_on64'
BEGIN

DROP TEMPORARY TABLE IF EXISTS tmp64;




CREATE TEMPORARY TABLE tmp64 SELECT Mobitel_ID,

  Latitude,

  Longitude,

  Direction,

  Acceleration,

  UnixTime,

  Speed,

  Valid,

  Satellites,

  RssiGsm,

  `Events`,

  SensorsSet,

  Sensors,

  Voltage,

  DGPS,

  LogID,

  SrvPacketID

FROM datagpsbuffer_on64 d

GROUP BY d.SrvPacketID;



  TRUNCATE TABLE datagpsbuffer_on64;



  INSERT INTO datagpsbuffer_on64 SELECT Mobitel_ID,

  Latitude,

  Longitude,

  Direction,

  Acceleration,

  UnixTime,

  Speed,

  Valid,

  Satellites,

  RssiGsm,

  `Events`,

  SensorsSet,

  Sensors,

  Voltage,

  DGPS,

  LogID,

  SrvPacketID

FROM tmp64 d;



DROP TEMPORARY TABLE IF EXISTS tmp64;


END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `getDiapasone` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getDiapasone`(

  IN mobile INTEGER(11),  

  IN prevLogId int, 

  IN currLogId int)
    SQL SECURITY INVOKER
BEGIN

  SELECT DataGps_ID AS DataGps_ID,

    Mobitel_ID AS Mobitel_ID,

    ((Latitude * 1.0000) / 600000) AS Lat,

    ((Longitude * 1.0000) / 600000) AS Lon,

    Altitude AS Altitude,

    FROM_UNIXTIME(UnixTime) AS `time`,

    (Speed * 1.852) AS speed,

    ((Direction * 360) / 255) AS direction,

    Valid AS Valid,

    (Sensor8 + (Sensor7 << 8) + (Sensor6 << 16) + 

      (Sensor5 << 24) + (Sensor4 << 32) + (Sensor3 << 40) + 

      (Sensor2 << 48) + (Sensor1 << 56)) AS sensor,

    Events AS Events,

    LogID AS LogID, 

    SrvPacketID AS srvPack

  FROM datagps 

  WHERE Mobitel_ID = mobile AND  Valid = 1 AND  

    (LogID BETWEEN prevLogId AND currLogId) ORDER BY UnixTime;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `getDiapasone64` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getDiapasone64`(

  IN mobile INTEGER(11),  

  IN prevLogId int, 

  IN currLogId int)
    SQL SECURITY INVOKER
BEGIN

  SELECT  DataGps_ID, Mobitel_ID,

    ((Latitude * 1.000) / 10000000) AS Lat,

    ((Longitude * 1.000) / 10000000) AS Lng,

    Acceleration , 

    FROM_UNIXTIME(UnixTime) AS `time` , 

    Speed /10 AS Speed, 

    Valid,

    Sensors AS sensor, 

  `Events`, 

  LogID ,

  Voltage,

  DGPS,

  Direction,

  Satellites,

  SensorsSet,

  RssiGsm,

  SrvPacketID AS srvPack FROM datagps64 d WHERE Mobitel_ID = mobile AND d.Valid = 1 AND  

    (LogID BETWEEN prevLogId AND currLogId) ORDER BY UnixTime;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `hystoryOnline` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `hystoryOnline`(IN id INTEGER(11))
    SQL SECURITY INVOKER
BEGIN

  SELECT LogID, Mobitel_Id, 

    FROM_UNIXTIME(unixtime)  AS `time`,

    ROUND((Latitude / 600000.00000), 6) AS Lat,

    ROUND((Longitude / 600000.00000), 6)  AS Lon,

    Altitude  AS Altitude,

    (Speed * 1.852) AS speed,

    ((Direction * 360) / 255) AS direction,

    Valid AS Valid,

    (Sensor8 + (Sensor7 << 8) + (Sensor6 << 16) + 

      (Sensor5 << 24) + (Sensor4 << 32) + (Sensor3 << 40) + 

      (Sensor2 << 48) + (Sensor1 << 56)) AS sensor,

    Events AS Events,

    DataGPS_ID  AS 'DataGPS_ID'

  FROM online

  WHERE  datagps_id > id

  ORDER BY datagps_id DESC;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnCorrectInfotrackLogId` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnCorrectInfotrackLogId`()
    SQL SECURITY INVOKER
    COMMENT 'Корректировка значений LogId и InMobitelID в данных инфотреков'
BEGIN

  DECLARE MobitelIDInCursor INT; /* Текущее значение MobitelID */

  DECLARE DataExists TINYINT DEFAULT 1; /* Флаг наличия данных после фетча */

  DECLARE MaxLogId INT DEFAULT 0; /* Максимальный LogId для данного дивайса */

  DECLARE SrvPacketIDInCursor BIGINT DEFAULT 0; /* Текущее значение серверного пакета */

    

  /* Курсор по инфотрекам в множестве новых данных. 

     Все инфотреки начинаются с буквы I */

  DECLARE CursorInfoTrack CURSOR FOR

    SELECT DISTINCT buf.Mobitel_ID

    FROM datagpsbuffer_on buf 

      JOIN mobitels m ON (buf.mobitel_id = m.mobitel_id)

      JOIN internalmobitelconfig c ON (c.ID = m.InternalMobitelConfig_ID)

    WHERE (c.InternalMobitelConfig_ID = (

      SELECT intConf.InternalMobitelConfig_ID

      FROM internalmobitelconfig intConf

      WHERE (intConf.ID = c.ID) 

      ORDER BY intConf.InternalMobitelConfig_ID DESC

      LIMIT 1)) AND 

      (c.devIdShort LIKE "I%") AND (buf.LogId = 0)

    ORDER BY 1;

    

  /* Курсор по данным телетрека */

  DECLARE CursorInfoTrackUpdateSet CURSOR FOR

    SELECT SrvPacketID 

    FROM datagpsbuffer_on

    WHERE (Mobitel_ID = MobitelIDInCursor) AND (LogId = 0)

    ORDER BY UnixTime;  



  /* Обработчик отсутствующей записи при FETCH следующей записи */

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  

  OPEN CursorInfoTrack;

  FETCH CursorInfoTrack INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* Находим максимальный LogId для данного инфотрека */

    SELECT COALESCE(MAX(LogID), 0) INTO	MaxLogId

    FROM DataGps

    WHERE Mobitel_ID = MobitelIDInCursor;



    /* Обновляем LogId и InMobitelID в наборе новых данных текущего инфотрека */

    OPEN CursorInfoTrackUpdateSet;

    FETCH CursorInfoTrackUpdateSet INTO SrvPacketIDInCursor;

    WHILE DataExists = 1 DO

      SET MaxLogId = MaxLogId + 1;



      UPDATE datagpsbuffer_on

      SET LogId = MaxLogId, InMobitelID = MaxLogId

      WHERE SrvPacketID = SrvPacketIDInCursor;



      FETCH CursorInfoTrackUpdateSet INTO SrvPacketIDInCursor;

    END WHILE;

    CLOSE CursorInfoTrackUpdateSet;

 

    SET DataExists = 1;

    FETCH CursorInfoTrack INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorInfoTrack;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnCorrectInfotrackLogId64` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnCorrectInfotrackLogId64`()
    SQL SECURITY INVOKER
    COMMENT 'РљРѕСЂСЂРµРєС‚РёСЂРѕРІРєР° Р·РЅР°С‡РµРЅРёР№ LogId Рё InMobitelID РІ РґР°РЅРЅС‹С… РёРЅС„РѕС‚СЂРµРєРѕРІ'
BEGIN

  DECLARE MobitelIDInCursor int; /* РўРµРєСѓС‰РµРµ Р·РЅР°С‡РµРЅРёРµ MobitelID */

  DECLARE DataExists tinyint DEFAULT 1; /* Р¤Р»Р°Рі РЅР°Р»РёС‡РёСЏ РґР°РЅРЅС‹С… РїРѕСЃР»Рµ С„РµС‚С‡Р° */

  DECLARE MaxLogId int DEFAULT 0; /* РњР°РєСЃРёРјР°Р»СЊРЅС‹Р№ LogId РґР»СЏ РґР°РЅРЅРѕРіРѕ РґРёРІР°Р№СЃР° */

  DECLARE SrvPacketIDInCursor bigint DEFAULT 0; /* РўРµРєСѓС‰РµРµ Р·РЅР°С‡РµРЅРёРµ СЃРµСЂРІРµСЂРЅРѕРіРѕ РїР°РєРµС‚Р° */



  /* РљСѓСЂСЃРѕСЂ РїРѕ РёРЅС„РѕС‚СЂРµРєР°Рј РІ РјРЅРѕР¶РµСЃС‚РІРµ РЅРѕРІС‹С… РґР°РЅРЅС‹С…. 

     Р’СЃРµ РёРЅС„РѕС‚СЂРµРєРё РЅР°С‡РёРЅР°СЋС‚СЃСЏ СЃ Р±СѓРєРІС‹ I */

  DECLARE CursorInfoTrack CURSOR FOR

  SELECT DISTINCT

    buf.Mobitel_ID

  FROM datagpsbuffer_on64 buf

    JOIN mobitels m

      ON (buf.mobitel_id = m.mobitel_id)

    JOIN internalmobitelconfig c

      ON (c.ID = m.InternalMobitelConfig_ID)

  WHERE (c.InternalMobitelConfig_ID = (SELECT

      intConf.InternalMobitelConfig_ID

    FROM internalmobitelconfig intConf

    WHERE (intConf.ID = c.ID)

    ORDER BY intConf.InternalMobitelConfig_ID DESC

    LIMIT 1)) AND

  (c.devIdShort LIKE "I%") AND (buf.LogId = 0)

  ORDER BY 1;



  /* РљСѓСЂСЃРѕСЂ РїРѕ РґР°РЅРЅС‹Рј С‚РµР»РµС‚СЂРµРєР° */

  DECLARE CursorInfoTrackUpdateSet CURSOR FOR

  SELECT

    SrvPacketID

  FROM datagpsbuffer_on64

  WHERE (Mobitel_ID = MobitelIDInCursor) AND (LogId = 0)

  ORDER BY UnixTime;



  /* РћР±СЂР°Р±РѕС‚С‡РёРє РѕС‚СЃСѓС‚СЃС‚РІСѓСЋС‰РµР№ Р·Р°РїРёСЃРё РїСЂРё FETCH СЃР»РµРґСѓСЋС‰РµР№ Р·Р°РїРёСЃРё */

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  OPEN CursorInfoTrack;

  FETCH CursorInfoTrack INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* РќР°С…РѕРґРёРј РјР°РєСЃРёРјР°Р»СЊРЅС‹Р№ LogId РґР»СЏ РґР°РЅРЅРѕРіРѕ РёРЅС„РѕС‚СЂРµРєР° */

    SELECT

      COALESCE(MAX(LogID), 0) INTO MaxLogId

    FROM DataGps

    WHERE Mobitel_ID = MobitelIDInCursor;



    /* РћР±РЅРѕРІР»СЏРµРј LogId Рё InMobitelID РІ РЅР°Р±РѕСЂРµ РЅРѕРІС‹С… РґР°РЅРЅС‹С… С‚РµРєСѓС‰РµРіРѕ РёРЅС„РѕС‚СЂРµРєР° */

    OPEN CursorInfoTrackUpdateSet;

    FETCH CursorInfoTrackUpdateSet INTO SrvPacketIDInCursor;

    WHILE DataExists = 1 DO

      SET MaxLogId = MaxLogId + 1;



      UPDATE datagpsbuffer_on64

      SET LogId = MaxLogId,

          InMobitelID = MaxLogId

      WHERE SrvPacketID = SrvPacketIDInCursor;



      FETCH CursorInfoTrackUpdateSet INTO SrvPacketIDInCursor;

    END WHILE;

    CLOSE CursorInfoTrackUpdateSet;



    SET DataExists = 1;

    FETCH CursorInfoTrack INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorInfoTrack;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnDeleteDuplicates` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnDeleteDuplicates`()
    SQL SECURITY INVOKER
    COMMENT 'Удаление повторяющихся строк из datagpsbuffer_on'
BEGIN

  /* Удаляет дубликаты строк из таблицы datagpsbuffer_on. Критерием поиска

   являются одинаковые значения в полях Mobitel_Id + LogID. Из множества

   повторяющихся записей в таблице datagpsbuffer_on останется только одна - 

   последняя принятая телематическим сервером, т.е. с максимальным SrvPacketID. */

   

  /* Текущий MobitelId в курсоре CursorDuplicateGroups */

  DECLARE MobitelIdInCursor INT DEFAULT 0; 

  /* Текущий LogID в курсоре CursorDuplicateGroups */

  DECLARE LogIdInCursor INT DEFAULT 0; 

  /* Max SrvPacketId в множестве строк текущей группы дубликатов */

  DECLARE MaxSrvPacketId BIGINT DEFAULT 0; 

  DECLARE DataExists TINYINT DEFAULT 1;



  /* Курсор для прохода по всем группам дубликатов */  

  DECLARE CursorDuplicateGroups CURSOR FOR

    SELECT Mobitel_Id, LogId 

    FROM datagpsbuffer_on

    GROUP BY Mobitel_Id, LogId 

    HAVING COUNT(LogId) > 1;

    

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  SET DataExists = 1;

  OPEN CursorDuplicateGroups;

  FETCH CursorDuplicateGroups INTO MobitelIdInCursor, LogIdInCursor;

  WHILE DataExists = 1 DO

    SELECT MAX(SrvPacketID) INTO MaxSrvPacketId

    FROM datagpsbuffer_on 

    WHERE (Mobitel_ID = MobitelIdInCursor) AND (LogId = LogIdInCursor);

         

    DELETE FROM datagpsbuffer_on  

    WHERE (Mobitel_ID = MobitelIdInCursor) AND (LogId = LogIdInCursor) 

      AND (SrvPacketID < MaxSrvPacketId);

        

    FETCH CursorDuplicateGroups INTO MobitelIdInCursor, LogIdInCursor;

  END WHILE;

  CLOSE CursorDuplicateGroups; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnDeleteDuplicates64` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnDeleteDuplicates64`()
    SQL SECURITY INVOKER
    COMMENT 'РЈРґР°Р»РµРЅРёРµ РїРѕРІС‚РѕСЂСЏСЋС‰РёС…СЃСЏ СЃС‚СЂРѕРє РёР· datagpsbuffer_on64'
BEGIN

  /* РЈРґР°Р»СЏРµС‚ РґСѓР±Р»РёРєР°С‚С‹ СЃС‚СЂРѕРє РёР· С‚Р°Р±Р»РёС†С‹ datagpsbuffer_on64. РљСЂРёС‚РµСЂРёРµРј РїРѕРёСЃРєР°

   СЏРІР»СЏСЋС‚СЃСЏ РѕРґРёРЅР°РєРѕРІС‹Рµ Р·РЅР°С‡РµРЅРёСЏ РІ РїРѕР»СЏС… Mobitel_Id + LogID. РР· РјРЅРѕР¶РµСЃС‚РІР°

   РїРѕРІС‚РѕСЂСЏСЋС‰РёС…СЃСЏ Р·Р°РїРёСЃРµР№ РІ С‚Р°Р±Р»РёС†Рµ datagpsbuffer_on64 РѕСЃС‚Р°РЅРµС‚СЃСЏ С‚РѕР»СЊРєРѕ РѕРґРЅР° - 

   РїРѕСЃР»РµРґРЅСЏСЏ РїСЂРёРЅСЏС‚Р°СЏ С‚РµР»РµРјР°С‚РёС‡РµСЃРєРёРј СЃРµСЂРІРµСЂРѕРј, С‚.Рµ. СЃ РјР°РєСЃРёРјР°Р»СЊРЅС‹Рј SrvPacketID. */



  /* РўРµРєСѓС‰РёР№ MobitelId РІ РєСѓСЂСЃРѕСЂРµ CursorDuplicateGroups */

  DECLARE MobitelIdInCursor int DEFAULT 0;

  /* РўРµРєСѓС‰РёР№ LogID РІ РєСѓСЂСЃРѕСЂРµ CursorDuplicateGroups */

  DECLARE LogIdInCursor int DEFAULT 0;

  /* Max SrvPacketId РІ РјРЅРѕР¶РµСЃС‚РІРµ СЃС‚СЂРѕРє С‚РµРєСѓС‰РµР№ РіСЂСѓРїРїС‹ РґСѓР±Р»РёРєР°С‚РѕРІ */

  DECLARE MaxSrvPacketId bigint DEFAULT 0;

  DECLARE DataExists tinyint DEFAULT 1;



  /* РљСѓСЂСЃРѕСЂ РґР»СЏ РїСЂРѕС…РѕРґР° РїРѕ РІСЃРµРј РіСЂСѓРїРїР°Рј РґСѓР±Р»РёРєР°С‚РѕРІ */

  DECLARE CursorDuplicateGroups CURSOR FOR

  SELECT

    Mobitel_Id,

    LogId

  FROM datagpsbuffer_on64

  GROUP BY Mobitel_Id,

           LogId

  HAVING COUNT(LogId) > 1;



  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  SET DataExists = 1;

  OPEN CursorDuplicateGroups;

  FETCH CursorDuplicateGroups INTO MobitelIdInCursor, LogIdInCursor;

  WHILE DataExists = 1 DO

    SELECT

      MAX(SrvPacketID) INTO MaxSrvPacketId

    FROM datagpsbuffer_on64

    WHERE (Mobitel_ID = MobitelIdInCursor) AND (LogId = LogIdInCursor);



    DELETE

      FROM datagpsbuffer_on64

    WHERE (Mobitel_ID = MobitelIdInCursor) AND (LogId = LogIdInCursor)

      AND (SrvPacketID < MaxSrvPacketId);



    FETCH CursorDuplicateGroups INTO MobitelIdInCursor, LogIdInCursor;

  END WHILE;

  CLOSE CursorDuplicateGroups;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnDeleteLostRange` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnDeleteLostRange`(IN MobitelID INTEGER(11), IN BeginSrvPacketID BIGINT)
    SQL SECURITY INVOKER
    COMMENT 'Удаление указанного диапазона пропусков из datagpslost_on.'
BEGIN

  /* Определяем является ли запись, предназначенная для удаления,

     первой в списке заданного телетрека. Если является - тогда

     внесем поправку в значение ConfirmedID */  

     

  DECLARE MinBeginSrvPacketID BIGINT; -- Минимальное значение Begin_SrvPacketID для данного телетрека

  DECLARE NewConfirmedID INT; -- Новое значение ConfirmedID  



  /* Нахождение минимального значения Begin_SrvPacketID */  

  SELECT MIN(Begin_SrvPacketID) INTO MinBeginSrvPacketID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;

  

  /* Если есть данные о пропусках у телетрека - продолжим */

  IF MinBeginSrvPacketID IS NOT NULL THEN

    /* Если удаляем первую запись - запомним новое значение ConfirmedID */

    IF MinBeginSrvPacketID = BeginSrvPacketID  THEN

      SELECT End_LogID INTO NewConfirmedID

      FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (Begin_SrvPacketID = BeginSrvPacketID);

    END IF;

  

    /* Удаление записи */

    DELETE FROM  datagpslost_on

    WHERE (Mobitel_ID = MobitelID) AND (Begin_SrvPacketID = BeginSrvPacketID);

    

    /* Если удалили первую запись - обновим ConfirmedID */  

    IF MinBeginSrvPacketID = BeginSrvPacketID  THEN

      UPDATE mobitels

      SET ConfirmedID = NewConfirmedID

      WHERE (Mobitel_ID = MobitelID) AND (NewConfirmedID > ConfirmedID);

    END IF;

  END IF;  

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnInsertDatagpsLost` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnInsertDatagpsLost`(

  IN MobitelID INT, 

  IN BeginLogID INT, 

  IN EndLogID INT,

  IN BeginSrvPacketID BIGINT, 

  IN EndSrvPacketID BIGINT)
    SQL SECURITY INVOKER
    COMMENT 'Вставка данных в таблицу datagpslost_on.'
BEGIN

  /* Флаг существования записи с заданными Mobitel_ID и Begin_LogID

     в таблице datagpslost_on */

  DECLARE MobitelId_BeginLogID_Exists TINYINT DEFAULT 0; 

  /* Флаг существования записи с заданными Mobitel_ID и Begin_SrvPacketID

     в таблице datagpslost_on  */

  DECLARE MobitelId_BeginSrvPacketID_Exists TINYINT DEFAULT 0;

  

  DECLARE RowBeginSrvPacketID BIGINT; 

  

  IF EXISTS(

    SELECT NULL

    FROM datagpslost_on

    WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID = BeginLogID))

  THEN

    SET MobitelId_BeginLogID_Exists = 1;

  END IF;



  IF EXISTS(

    SELECT NULL

    FROM datagpslost_on

    WHERE (Mobitel_ID = MobitelID) AND (Begin_SrvPacketID = BeginSrvPacketID))

  THEN

    SET MobitelId_BeginSrvPacketID_Exists = 1;

  END IF;



  IF (MobitelId_BeginLogID_Exists = 0) AND (MobitelId_BeginSrvPacketID_Exists = 0)

  THEN

    /* Вставка новой записи */

    INSERT INTO datagpslost_on(Mobitel_ID, Begin_LogID, End_LogID, Begin_SrvPacketID, End_SrvPacketID)

    VALUES (MobitelID, BeginLogID, EndLogID, BeginSrvPacketID, EndSrvPacketID);

  ELSE

    IF ((MobitelId_BeginLogID_Exists = 1) AND (MobitelId_BeginSrvPacketID_Exists = 1))

    THEN

      /* Обновление существующей записи */

      UPDATE datagpslost_on

      SET End_LogID = EndLogID, End_SrvPacketID = EndSrvPacketID

      WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID = BeginLogID);

    ELSE

      /* Комбинацию MobitelId_BeginLogID_Exists = 0, MobitelId_BeginSrvPacketID_Exists = 1

         игнорируем - это исключительная ситуация, которая не должна возникать. */

      SELECT Begin_SrvPacketID

      INTO RowBeginSrvPacketID

      FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID = BeginLogID)

      LIMIT 1;

      

      IF ((MobitelId_BeginLogID_Exists = 1) AND (MobitelId_BeginSrvPacketID_Exists = 0) AND

        (BeginSrvPacketID < RowBeginSrvPacketID))

      THEN

        /* В эту ветвь попадаем, если телетрек отдаст одну и ту же запись несколько раз 

           (LogID у записей один и тотже, а SrvPacketID различны) */

        UPDATE datagpslost_on

        SET End_LogID = EndLogID, Begin_SrvPacketID = BeginSrvPacketID, End_SrvPacketID = EndSrvPacketID

        WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID = BeginLogID);

      END IF;

    END IF;

  END IF;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `online` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `online`()
    SQL SECURITY INVOKER
BEGIN

  SELECT Log_ID, MobitelId, 

    (SELECT DataGPS_ID

    FROM `online` 

    WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS 'DataGPS_ID',

      (SELECT from_unixtime(unixtime) 

      FROM `online` 

      WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS 'time',

        (SELECT ROUND((`Latitude` / 600000.00000),6)

        FROM `online` 

        WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS `Lat`,

          (SELECT ROUND((`Longitude` / 600000.00000),6) 

          FROM `online` 

          WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS `Lon`,

            (SELECT `Altitude` 

            FROM `online` 

            WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS `Altitude`,

              (SELECT (`Speed` * 1.852)

              FROM `online` 

              WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS `speed`,

                (SELECT ((`Direction` * 360) / 255)

                FROM `online` 

                WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS `direction`,

                  (SELECT `Valid`

                  FROM `online` 

                  WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS `Valid`,

                    (SELECT (((((((`Sensor8` + 

                    (`Sensor7` << 8)) + 

                    (`Sensor6` << 16)) + 

                    (`Sensor5` << 24)) + 

                    (`Sensor4` << 32)) + 

                    (`Sensor3` << 40)) + 

                    (`Sensor2` << 48)) + 

                    (`Sensor1` << 56)) 

                    FROM `online` 

                    WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS `sensor`,

                      (SELECT `Events`

                      FROM `online` 

                      WHERE mobitel_id = MobitelId AND LogId = Log_ID Limit 1) AS `Events`

   

  FROM (SELECT MAX(`LogID`) AS `Log_ID`, mobitel_id AS MobitelId

        FROM `online` 

        GROUP BY `Mobitel_ID`) T1;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnListMobitelConfig` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnListMobitelConfig`()
    SQL SECURITY INVOKER
    COMMENT 'Выборка настроек телетреков которые могут работать в online режиме'
BEGIN

  DECLARE MobitelIDInCursor INT;

  DECLARE DevIdShortInCursor CHAR(4);

  DECLARE DataExists TINYINT DEFAULT 1;



  /* Курсор в множестве настроенных телетреков */

  DECLARE CursorMobitels CURSOR FOR

    SELECT m.Mobitel_ID AS MobitelID, c.devIdShort AS DevIdShort

    FROM mobitels m

      JOIN internalmobitelconfig c ON (c.ID = m.InternalMobitelConfig_ID)

    WHERE (c.InternalMobitelConfig_ID = (

      SELECT intConf.InternalMobitelConfig_ID

      FROM internalmobitelconfig intConf

      WHERE (intConf.ID = c.ID)

      ORDER BY intConf.InternalMobitelConfig_ID DESC

      LIMIT 1)) AND

      (c.devIdShort IS NOT NULL) AND (c.devIdShort <> _cp1251'')

    ORDER BY m.Mobitel_ID;



  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  /* Временная таблица настроек телетрека */

  CREATE TEMPORARY TABLE tmpMobitelsConfig (

    MobitelID INT NOT NULL,

    DevIdShort CHAR(4) NOT NULL,

    LastPacketID BIGINT NOT NULL) ENGINE = MEMORY;



  OPEN CursorMobitels;

  FETCH CursorMobitels INTO MobitelIDInCursor, DevIdShortInCursor;

  WHILE DataExists = 1 DO



    INSERT INTO tmpMobitelsConfig SELECT MobitelIDInCursor, DevIdShortInCursor,

      (SELECT COALESCE(MAX(SrvPacketID), 0)

       FROM datagps

       WHERE Mobitel_ID = MobitelIDInCursor) AS LastPacketID;



    FETCH CursorMobitels INTO MobitelIDInCursor, DevIdShortInCursor;

  END WHILE;

  CLOSE CursorMobitels;



  SELECT MobitelID, DevIdShort, LastPacketID

  FROM tmpMobitelsConfig;



  DROP TEMPORARY TABLE tmpMobitelsConfig;  

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnListMobitelConfig64` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnListMobitelConfig64`()
    SQL SECURITY INVOKER
    COMMENT 'Выборка настроек телетреков которые могут работать в online режиме для datagps и datagps64'
BEGIN

  DECLARE MobitelIDInCursor INT;

  DECLARE Is64Cursor tinyint;

  DECLARE DevIdShortInCursor CHAR(4);

  DECLARE DataExists TINYINT DEFAULT 1;



  /* Курсор в множестве настроенных телетреков */

  DECLARE CursorMobitels CURSOR FOR

    SELECT m.Mobitel_ID AS MobitelID, m.Is64bitPackets AS Is64, c.devIdShort AS DevIdShort

    FROM mobitels m

      JOIN internalmobitelconfig c ON (c.ID = m.InternalMobitelConfig_ID)

    WHERE (c.InternalMobitelConfig_ID = (

      SELECT intConf.InternalMobitelConfig_ID

      FROM internalmobitelconfig intConf

      WHERE (intConf.ID = c.ID)

      ORDER BY intConf.InternalMobitelConfig_ID DESC

      LIMIT 1)) AND

      (c.devIdShort IS NOT NULL) AND (c.devIdShort <> _cp1251'')

    ORDER BY m.Mobitel_ID;



  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  /* Временная таблица настроек телетрека */

  CREATE TEMPORARY TABLE tmpMobitelsConfig (

    MobitelID INT NOT NULL,

    Is64 tinyint NOT NULL,

    DevIdShort CHAR(4) NOT NULL,

    LastPacketID BIGINT NOT NULL,

    LastPacketID64 BIGINT NOT NULL) ENGINE = MEMORY;



  OPEN CursorMobitels;

  FETCH CursorMobitels INTO MobitelIDInCursor, Is64Cursor, DevIdShortInCursor;

  WHILE DataExists = 1 DO



    INSERT INTO tmpMobitelsConfig SELECT MobitelIDInCursor, Is64Cursor, DevIdShortInCursor,

      (SELECT COALESCE(MAX(d.SrvPacketID), 0)

       FROM datagps d

       WHERE d.Mobitel_ID = MobitelIDInCursor) AS LastPacketID,

      (SELECT COALESCE(MAX(t.SrvPacketID), 0)

       FROM datagps64 t

       WHERE t.Mobitel_ID = MobitelIDInCursor) AS LastPacketID64;



    FETCH CursorMobitels INTO MobitelIDInCursor, Is64Cursor, DevIdShortInCursor;

  END WHILE;

  CLOSE CursorMobitels;



  SELECT MobitelID, Is64, DevIdShort, LastPacketID, LastPacketID64

  FROM tmpMobitelsConfig;



  DROP TEMPORARY TABLE tmpMobitelsConfig;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnLostDataGPS` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnLostDataGPS`(IN MobitelID INTEGER(11), OUT NeedOptimize TINYINT)
    SQL SECURITY INVOKER
    COMMENT 'Поиск пропусков в online данных заданного телетрека и заполнение таблиц.'
BEGIN



  /********** DECLARE **********/

  

  DECLARE CurrentConfirmedID INT DEFAULT 0; /* Текущее значение ConfirmedID */

  DECLARE NewConfirmedID INT DEFAULT 0; /* Новое значение ConfirmedID */

  DECLARE StartLogIDSelect INT DEFAULT 0; /* min LogID для выборки */

  DECLARE FinishLogIDSelect INT DEFAULT 0; /* max LogID для выборки */

  DECLARE MaxEndLogID INT DEFAULT 0; /* max End_LogID в пропущенных диапазонах данного телетрека */

  

  DECLARE MinLogID_n INT DEFAULT 0; /* Минимальный LogID после ConfirmedID в множестве новых данных */

  DECLARE MaxLogID_n INT DEFAULT 0; /* Максимальный LogID в множестве новых данных */

  

  DECLARE DataExists TINYINT DEFAULT 1; /* Флаг наличия данных после фетча */

    

  DECLARE NewLogID INT; /* Значение LogID в курсоре CursorNewLogID */

  DECLARE NewSrvPacketID BIGINT; /* Значение SrvPacketID в курсоре CursorNewLogID */

  DECLARE FirstLogID INT DEFAULT -9999999; /* Первое значение LogID для анализа */

  DECLARE SecondLogID INT; /* Второе значение LogID для анализа */

  DECLARE FirstSrvPacketID BIGINT; /* Первое значение SrvPacketID */

  DECLARE SecondSrvPacketID BIGINT; /* Второе значение SrvPacketID */

  

  DECLARE tmpSrvPacketID BIGINT DEFAULT 0; /* Значение SrvPacketID для первой искусственной записи в анализе новых данных, не пересекающихся с существующими */  

  

  /* Курсор для прохода по новым LogID */

  DECLARE CursorNewLogID CURSOR FOR

    SELECT LogID, SrvPacketID 

    FROM datagpslost_ontmp;

    

  /* Обработчик отсутствующей записи при FETCH следующей записи */

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  

  /********** END DECLARE **********/



  SET NeedOptimize = 0;

 

  SELECT COALESCE(ConfirmedID, 0) INTO CurrentConfirmedID

  FROM mobitels

  WHERE Mobitel_ID = MobitelID;



  /* Минимальный LogID в новом наборе данных c которым будем работать */

  SELECT MIN(LogID) INTO MinLogID_n

  FROM datagpsbuffer_on

  WHERE (Mobitel_ID = MobitelID) AND (LogID > CurrentConfirmedID);

  

  /* Максимальный LogID в новом наборе данных c которым будем работать */

  SELECT MAX(LogID) INTO MaxLogID_n

  FROM datagpsbuffer_on 

  WHERE Mobitel_ID = MobitelID;  

  

  /* Максимальный End_LogID в пропущенных диапазонах данного телетрека */

  SELECT COALESCE(MAX(End_LogID), 0) INTO MaxEndLogID

  FROM datagpslost_on 

  WHERE Mobitel_ID = MobitelID;  

  

  /* Проверим есть ли данные для анализа */

  IF MinLogID_n IS NOT NULL THEN

  

    /********** PREPARE **********/

    

    TRUNCATE TABLE datagpslost_ontmp;

  

    IF MinLogID_n < MaxEndLogID THEN

      /* Если  MinLogID_n < MaxEndLogID значит пришли данные, 

       которые возможно закроют часть пропусков. */

       

      /* Находим стартовый LogID для пересчета. */

      SELECT COALESCE(Begin_LogID, MinLogID_n) INTO StartLogIDSelect

      FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (MinLogID_n > Begin_LogID) 

        AND (MinLogID_n < End_LogID);

      

      /* Находим последний LogID для пересчета. */  

      SELECT COALESCE(End_LogID, MaxLogID_n) INTO FinishLogIDSelect

      FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (MaxLogID_n > Begin_LogID) 

        AND (MaxLogID_n < End_LogID);

       

      /* Удалим старые записи из реестра пропущенных записей 

         (стали неактуальными, надо пересчитать) */

      DELETE FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID >= StartLogIDSelect)

        AND (Begin_LogID <= FinishLogIDSelect);

      

      /* Если первая запись LogID = 0 и этой записи нет в DataGps, тогда

         надо добавить первую фиктивную запись для анализа. */

      IF (StartLogIDSelect = 0) AND (NOT EXISTS

        (Select 1 

         FROM datagps 

         WHERE (Mobitel_ID = MobitelID) AND (LogID = StartLogIDSelect))) THEN

      

        INSERT INTO datagpslost_ontmp(LogID, SrvPacketID) VALUES (0, 0);  

      END IF;       

    ELSE

      /* Пришли новые данные. Надо добавить для анализа искусственную запись - 

         нижнюю границу */

      

      /* Находим стартовый LogID для пересчета. */

      SELECT COALESCE(MAX(End_LogID), CurrentConfirmedID) INTO StartLogIDSelect

      FROM datagpslost_on

      WHERE Mobitel_ID = MobitelID;   

         

      /* Находим последний LogID для пересчета. */  

      SELECT MAX(LogID)  INTO FinishLogIDSelect

      FROM datagpsbuffer_on

      WHERE Mobitel_ID = MobitelID;

      

      /* Выбираем из datagps соответствующее значение SrvPacketID  для первой

         искусственной записи */

      SELECT COALESCE(SrvPacketID, 0) INTO tmpSrvPacketID

      FROM datagps

      WHERE (Mobitel_ID = MobitelID) AND (LogID = StartLogIDSelect);

      

      /* Помещаем в таблицу datagpslost_ontmp для анализа пропусков 

         дополнительную первую запись */

      INSERT INTO datagpslost_ontmp(LogID, SrvPacketID)

      VALUES (StartLogIDSelect, tmpSrvPacketID);

    END IF; -- IF MinLogID_n < MaxEndLogID   

    

    /********** END PREPARE **********/

    

    /**********  INSERT ROWS **********/

    

    /* Заполнение временной таблицы последними данными телетрека

       для анализа разрывов */

    INSERT INTO datagpslost_ontmp  (LogID, SrvPacketID)

      SELECT LogID, SrvPacketID

      FROM datagps

      WHERE (Mobitel_ID = MobitelID) AND (LogID >= StartLogIDSelect)

        AND (LogID <= FinishLogIDSelect)

      ORDER BY LogID;

            

    /* Формирование команды-вставки в таблицу пропущенных диапазонов */

    SET DataExists = 1;

    OPEN CursorNewLogID;

    FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

    WHILE DataExists = 1 DO

      IF FirstLogID = -9999999 THEN

        /* Первое значение в списке */

        SET FirstLogID = NewLogID;

        SET FirstSrvPacketID = NewSrvPacketID;

      ELSE

        /* Основная ветка расчета*/

        SET SecondLogID = NewLogID;

        SET SecondSrvPacketID = NewSrvPacketID;

        

        IF (SecondLogID - FirstLogID) > 1 THEN

          /* Найден разрыв */

          /* Из-за всяких комбинаций состояний LogId и SrvPacketId из-за особенностей работы телематического сервера

          и ТДМ вводим дополнительный анализ вставляемых записей, если запись не соответсвует указаным правилам, она 

          отбрасывается */

          IF (SecondSrvPacketID > FirstSrvPacketID) THEN

            IF EXISTS(SELECT NULL FROM datagps d WHERE (d.Mobitel_ID = MobitelID) AND ((d.LogID = FirstLogID) AND (d.SrvPacketID = FirstSrvPacketID))) THEN 

              IF EXISTS(SELECT NULL FROM datagps d WHERE (d.Mobitel_ID = MobitelID) AND ((d.LogID = SecondLogID) AND (d.SrvPacketID = SecondSrvPacketID))) THEN 



                CALL OnInsertDatagpsLost(MobitelID, FirstLogID, SecondLogID, FirstSrvPacketID, SecondSrvPacketID);

                IF NeedOptimize = 0 THEN SET NeedOptimize = 1; END IF;

                

              END IF;

            END IF;

          END IF;

        END IF;

        /* Переместим текущее второе значение на первую позицию

           для участия в следующей итерации в качестве начального значения */

        SET  FirstLogID = SecondLogID;

        SET FirstSrvPacketID = SecondSrvPacketID;

      END IF;  

      FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

    END WHILE;

    CLOSE CursorNewLogID;

 

    /********** END INSERT ROWS **********/

               

    /********** UPDATE MOBITELS **********/

    

    /* Если пропущенных записей у данного телетрека нет - 

       тогда ConfirmedID будет равен максимальному LogID 

       данного телетрека. Иначе - минимальный Begin_LogID

       из таблицы пропусков */

    SELECT MIN(Begin_LogID) INTO NewConfirmedID

    FROM datagpslost_on

    WHERE Mobitel_ID = MobitelID;

       

    IF NewConfirmedID IS NULL THEN

      SELECT MAX(LogID) INTO NewConfirmedID

      FROM datagps

      WHERE Mobitel_ID = MobitelID;

    END IF;  

    

    /* Обновим ConfirmedID если надо */

    UPDATE mobitels

    SET ConfirmedID = NewConfirmedID

    WHERE (Mobitel_ID = MobitelID) AND (ConfirmedID < NewConfirmedID);

    

    /********** END UPDATE MOBITELS **********/

        

    TRUNCATE TABLE datagpslost_ontmp;

  END IF; -- IF MaxEndLogID IS NOT NULL  

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnLostDataGPS2` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnLostDataGPS2`(IN MobitelID INTEGER(11), OUT NeedOptimize TINYINT)
    SQL SECURITY INVOKER
    COMMENT 'Модификация диапазонов пропусков. Анализ дублирующих данных заданного телетрека.'
BEGIN

    /********** DECLARE **********/

    

  DECLARE NewConfirmedID INT DEFAULT 0; /* Новое значение ConfirmedID */

  DECLARE BeginLogID INT; /* Begin_LogID в курсоре CursorLostRanges */

  DECLARE EndLogID INT; /* End_LogID в курсоре CursorLostRanges */

  DECLARE BeginSrvPacketID BIGINT; /* Begin_SrvPacketID в курсоре CursorLostRanges */

  DECLARE EndSrvPacketID BIGINT; /* End_SrvPacketID в курсоре CursorLostRanges */

  DECLARE RowCountForAnalyze INT DEFAULT 0; /* Количество записей для анализа */

  DECLARE DataExists TINYINT DEFAULT 1; /* Флаг наличия данных после фетча */

    

  /* Курсор для прохода по диапазонам пропусков телетрека */

  DECLARE CursorLostRanges CURSOR FOR

    SELECT Begin_LogID, End_LogID, Begin_SrvPacketID, End_SrvPacketID 

    FROM datagpslost_on

    WHERE Mobitel_ID = MobitelID;    



  /* Курсор для прохода по новым LogID */

  DECLARE CursorNewLogID CURSOR FOR

    SELECT LogID, SrvPacketID 

    FROM datagpslost_ontmp

    ORDER BY SrvPacketID;    

    

  /* Обработчик отсутствующей записи при FETCH следующей записи */

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  

  /********** END DECLARE **********/



  SET NeedOptimize = 0;

  

  TRUNCATE TABLE datagpslost_ontmp;

  

  /* Перебираем диапазоны и сокращаем разрывы если это возможно */

  SET DataExists = 1;

  OPEN CursorLostRanges;

  FETCH CursorLostRanges INTO BeginLogID, EndLogID, BeginSrvPacketID, EndSrvPacketID;

  WHILE DataExists = 1 DO

    /* Заполнение временной таблицы дублирующими данными телетрека

       для анализа разрывов */

    INSERT INTO datagpslost_ontmp  (LogID, SrvPacketID)

      SELECT DISTINCT LogID, SrvPacketID

      FROM datagpsbuffer_ontmp

      WHERE (Mobitel_ID = MobitelID) AND (SrvPacketID > BeginSrvPacketID)

        AND (SrvPacketID < EndSrvPacketID)

      ORDER BY SrvPacketID;

      

    /* Если есть данные модифицируем диапазон */  

    SELECT COUNT(1) INTO RowCountForAnalyze

    FROM datagpslost_ontmp;  

    

    IF RowCountForAnalyze > 0 THEN  

      /* Добавляем первую и последнюю записи для анализа */  

      INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

      VALUES (BeginLogID, BeginSrvPacketID), (EndLogID, EndSrvPacketID);

      

      /* Удаляем старый диапазон */

      DELETE FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID = BeginLogID);

       

      /**********  INSERT ROWS **********/             

      BEGIN

        DECLARE NewLogID INT; /* Значение LogID в курсоре CursorNewLogID */

        DECLARE NewSrvPacketID BIGINT; /* Значение SrvPacketID в курсоре CursorNewLogID */

        DECLARE FirstLogID INT DEFAULT -9999999; /* Первое значение LogID для анализа */

        DECLARE SecondLogID INT; /* Второе значение LogID для анализа */

        DECLARE FirstSrvPacketID BIGINT; /* Первое значение SrvPacketID */

        DECLARE SecondSrvPacketID BIGINT; /* Второе значение SrvPacketID */

        

        /* Обработчик отсутствующей записи при FETCH следующей записи */

        DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

        

        /* Формирование команды-вставки в таблицу пропущенных диапазонов */

        SET DataExists = 1;

        OPEN CursorNewLogID;

        FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

        WHILE DataExists = 1 DO

          IF FirstLogID = -9999999 THEN

            /* Первое значение в списке */

            SET FirstLogID = NewLogID;

            SET FirstSrvPacketID = NewSrvPacketID;

          ELSE

            /* Основная ветка расчета*/

            SET SecondLogID = NewLogID;

            SET SecondSrvPacketID = NewSrvPacketID;

            

            IF (SecondLogID - FirstLogID) > 1 THEN

          /* Найден разрыв */

          /* Из-за всяких комбинаций состояний LogId и SrvPacketId из-за особенностей работы телематического сервера

          и ТДМ вводим дополнительный анализ вставляемых записей, если запись не соответсвует указаным правилам, она 

          отбрасывается */

          IF (SecondSrvPacketID > FirstSrvPacketID) THEN

            IF EXISTS(SELECT NULL FROM datagps d WHERE (d.Mobitel_ID = MobitelID) AND ((d.LogID = FirstLogID) AND (d.SrvPacketID = FirstSrvPacketID))) THEN 

              IF EXISTS(SELECT NULL FROM datagps d WHERE (d.Mobitel_ID = MobitelID) AND ((d.LogID = SecondLogID) AND (d.SrvPacketID = SecondSrvPacketID))) THEN 



                CALL OnInsertDatagpsLost(MobitelID, FirstLogID, SecondLogID, FirstSrvPacketID, SecondSrvPacketID);

                IF NeedOptimize = 0 THEN SET NeedOptimize = 1; END IF;

                

              END IF;

            END IF;

          END IF;

        END IF;

            /* Переместим текущее второе значение на первую позицию

               для участия в следующей итерации в качестве начального значения */

            SET FirstLogID = SecondLogID;

            SET FirstSrvPacketID = SecondSrvPacketID;

          END IF;  

          FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

        END WHILE;

        CLOSE CursorNewLogID;

      END;

      /********** END INSERT ROWS **********/  



      TRUNCATE TABLE datagpslost_ontmp;

    END IF;

      

    FETCH CursorLostRanges INTO BeginLogID, EndLogID, BeginSrvPacketID, EndSrvPacketID;

  END WHILE;

  CLOSE CursorLostRanges;

  

  /********** UPDATE MOBITELS **********/

    

  /* Если пропущенных записей у данного телетрека нет - 

     тогда ConfirmedID будет равен максимальному LogID 

     данного телетрека. Иначе - минимальный Begin_LogID

     из таблицы пропусков */

  SELECT MIN(Begin_LogID) INTO NewConfirmedID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;

       

  IF NewConfirmedID IS NULL THEN

    SELECT MAX(LogID) INTO NewConfirmedID

    FROM datagps

    WHERE Mobitel_ID = MobitelID;

  END IF;  

    

  /* Обновим ConfirmedID если надо */

  UPDATE mobitels

  SET ConfirmedID = NewConfirmedID

  WHERE (Mobitel_ID = MobitelID) AND (ConfirmedID < NewConfirmedID);

    

  /********** END UPDATE MOBITELS **********/

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnLostDataGPS264` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnLostDataGPS264`(IN MobitelID integer(11), OUT NeedOptimize tinyint)
    SQL SECURITY INVOKER
    COMMENT 'РњРѕРґРёС„РёРєР°С†РёСЏ РґРёР°РїР°Р·РѕРЅРѕРІ РїСЂРѕРїСѓСЃРєРѕРІ. РђРЅР°Р»РёР· РґСѓР±Р»РёСЂСѓСЋС‰РёС… РґР°РЅРЅС‹С… Р·Р°РґР°РЅРЅРѕРіРѕ С‚РµР»РµС‚СЂРµРєР°.'
BEGIN

  /********** DECLARE **********/



  DECLARE NewConfirmedID int DEFAULT 0; /* РќРѕРІРѕРµ Р·РЅР°С‡РµРЅРёРµ ConfirmedID */

  DECLARE BeginLogID int; /* Begin_LogID РІ РєСѓСЂСЃРѕСЂРµ CursorLostRanges */

  DECLARE EndLogID int; /* End_LogID РІ РєСѓСЂСЃРѕСЂРµ CursorLostRanges */

  DECLARE BeginSrvPacketID bigint; /* Begin_SrvPacketID РІ РєСѓСЂСЃРѕСЂРµ CursorLostRanges */

  DECLARE EndSrvPacketID bigint; /* End_SrvPacketID РІ РєСѓСЂСЃРѕСЂРµ CursorLostRanges */

  DECLARE RowCountForAnalyze int DEFAULT 0; /* РљРѕР»РёС‡РµСЃС‚РІРѕ Р·Р°РїРёСЃРµР№ РґР»СЏ Р°РЅР°Р»РёР·Р° */

  DECLARE DataExists tinyint DEFAULT 1; /* Р¤Р»Р°Рі РЅР°Р»РёС‡РёСЏ РґР°РЅРЅС‹С… РїРѕСЃР»Рµ С„РµС‚С‡Р° */



  /* РљСѓСЂСЃРѕСЂ РґР»СЏ РїСЂРѕС…РѕРґР° РїРѕ РґРёР°РїР°Р·РѕРЅР°Рј РїСЂРѕРїСѓСЃРєРѕРІ С‚РµР»РµС‚СЂРµРєР° */

  DECLARE CursorLostRanges CURSOR FOR

  SELECT

    Begin_LogID,

    End_LogID,

    Begin_SrvPacketID,

    End_SrvPacketID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;



  /* РљСѓСЂСЃРѕСЂ РґР»СЏ РїСЂРѕС…РѕРґР° РїРѕ РЅРѕРІС‹Рј LogID */

  DECLARE CursorNewLogID CURSOR FOR

  SELECT

    LogID,

    SrvPacketID

  FROM datagpslost_ontmp

  ORDER BY SrvPacketID;



  /* РћР±СЂР°Р±РѕС‚С‡РёРє РѕС‚СЃСѓС‚СЃС‚РІСѓСЋС‰РµР№ Р·Р°РїРёСЃРё РїСЂРё FETCH СЃР»РµРґСѓСЋС‰РµР№ Р·Р°РїРёСЃРё */

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  /********** END DECLARE **********/



  SET NeedOptimize = 0;



  TRUNCATE TABLE datagpslost_ontmp;



  /* РџРµСЂРµР±РёСЂР°РµРј РґРёР°РїР°Р·РѕРЅС‹ Рё СЃРѕРєСЂР°С‰Р°РµРј СЂР°Р·СЂС‹РІС‹ РµСЃР»Рё СЌС‚Рѕ РІРѕР·РјРѕР¶РЅРѕ */

  SET DataExists = 1;

  OPEN CursorLostRanges;

  FETCH CursorLostRanges INTO BeginLogID, EndLogID, BeginSrvPacketID, EndSrvPacketID;

  WHILE DataExists = 1 DO

    /* Р—Р°РїРѕР»РЅРµРЅРёРµ РІСЂРµРјРµРЅРЅРѕР№ С‚Р°Р±Р»РёС†С‹ РґСѓР±Р»РёСЂСѓСЋС‰РёРјРё РґР°РЅРЅС‹РјРё С‚РµР»РµС‚СЂРµРєР°

       РґР»СЏ Р°РЅР°Р»РёР·Р° СЂР°Р·СЂС‹РІРѕРІ */

    INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

      SELECT DISTINCT

        LogID,

        SrvPacketID

      FROM datagpsbuffer_ontmp64

      WHERE (Mobitel_ID = MobitelID) AND (SrvPacketID > BeginSrvPacketID)

      AND (SrvPacketID < EndSrvPacketID)

      ORDER BY SrvPacketID;



    /* Р•СЃР»Рё РµСЃС‚СЊ РґР°РЅРЅС‹Рµ РјРѕРґРёС„РёС†РёСЂСѓРµРј РґРёР°РїР°Р·РѕРЅ */

    SELECT

      COUNT(1) INTO RowCountForAnalyze

    FROM datagpslost_ontmp;



    IF RowCountForAnalyze > 0 THEN

      /* Р”РѕР±Р°РІР»СЏРµРј РїРµСЂРІСѓСЋ Рё РїРѕСЃР»РµРґРЅСЋСЋ Р·Р°РїРёСЃРё РґР»СЏ Р°РЅР°Р»РёР·Р° */

      INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

        VALUES (BeginLogID, BeginSrvPacketID), (EndLogID, EndSrvPacketID);



      /* РЈРґР°Р»СЏРµРј СЃС‚Р°СЂС‹Р№ РґРёР°РїР°Р·РѕРЅ */

      DELETE

        FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID = BeginLogID);



      /**********  INSERT ROWS **********/

      BEGIN

        DECLARE NewLogID int; /* Р—РЅР°С‡РµРЅРёРµ LogID РІ РєСѓСЂСЃРѕСЂРµ CursorNewLogID */

        DECLARE NewSrvPacketID bigint; /* Р—РЅР°С‡РµРЅРёРµ SrvPacketID РІ РєСѓСЂСЃРѕСЂРµ CursorNewLogID */

        DECLARE FirstLogID int DEFAULT -9999999; /* РџРµСЂРІРѕРµ Р·РЅР°С‡РµРЅРёРµ LogID РґР»СЏ Р°РЅР°Р»РёР·Р° */

        DECLARE SecondLogID int; /* Р’С‚РѕСЂРѕРµ Р·РЅР°С‡РµРЅРёРµ LogID РґР»СЏ Р°РЅР°Р»РёР·Р° */

        DECLARE FirstSrvPacketID bigint; /* РџРµСЂРІРѕРµ Р·РЅР°С‡РµРЅРёРµ SrvPacketID */

        DECLARE SecondSrvPacketID bigint; /* Р’С‚РѕСЂРѕРµ Р·РЅР°С‡РµРЅРёРµ SrvPacketID */



        /* РћР±СЂР°Р±РѕС‚С‡РёРє РѕС‚СЃСѓС‚СЃС‚РІСѓСЋС‰РµР№ Р·Р°РїРёСЃРё РїСЂРё FETCH СЃР»РµРґСѓСЋС‰РµР№ Р·Р°РїРёСЃРё */

        DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



        /* Р¤РѕСЂРјРёСЂРѕРІР°РЅРёРµ РєРѕРјР°РЅРґС‹-РІСЃС‚Р°РІРєРё РІ С‚Р°Р±Р»РёС†Сѓ РїСЂРѕРїСѓС‰РµРЅРЅС‹С… РґРёР°РїР°Р·РѕРЅРѕРІ */

        SET DataExists = 1;

        OPEN CursorNewLogID;

        FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

        WHILE DataExists = 1 DO

          IF FirstLogID = -9999999 THEN

            /* РџРµСЂРІРѕРµ Р·РЅР°С‡РµРЅРёРµ РІ СЃРїРёСЃРєРµ */

            SET FirstLogID = NewLogID;

            SET FirstSrvPacketID = NewSrvPacketID;

          ELSE

            /* РћСЃРЅРѕРІРЅР°СЏ РІРµС‚РєР° СЂР°СЃС‡РµС‚Р°*/

            SET SecondLogID = NewLogID;

            SET SecondSrvPacketID = NewSrvPacketID;



            IF (SecondLogID - FirstLogID) > 1 THEN

          /* РќР°Р№РґРµРЅ СЂР°Р·СЂС‹РІ */

          /* РР·-Р·Р° РІСЃСЏРєРёС… РєРѕРјР±РёРЅР°С†РёР№ СЃРѕСЃС‚РѕСЏРЅРёР№ LogId Рё SrvPacketId РёР·-Р·Р° РѕСЃРѕР±РµРЅРЅРѕСЃС‚РµР№ СЂР°Р±РѕС‚С‹ С‚РµР»РµРјР°С‚РёС‡РµСЃРєРѕРіРѕ СЃРµСЂРІРµСЂР°

          Рё РўР”Рњ РІРІРѕРґРёРј РґРѕРїРѕР»РЅРёС‚РµР»СЊРЅС‹Р№ Р°РЅР°Р»РёР· РІСЃС‚Р°РІР»СЏРµРјС‹С… Р·Р°РїРёСЃРµР№, РµСЃР»Рё Р·Р°РїРёСЃСЊ РЅРµ СЃРѕРѕС‚РІРµС‚СЃРІСѓРµС‚ СѓРєР°Р·Р°РЅС‹Рј РїСЂР°РІРёР»Р°Рј, РѕРЅР° 

          РѕС‚Р±СЂР°СЃС‹РІР°РµС‚СЃСЏ */

          IF (SecondSrvPacketID > FirstSrvPacketID) THEN

            IF EXISTS(SELECT NULL FROM datagps64 d WHERE (d.Mobitel_ID = MobitelID) AND ((d.LogID = FirstLogID) AND (d.SrvPacketID = FirstSrvPacketID))) THEN 

              IF EXISTS(SELECT NULL FROM datagps64 d WHERE (d.Mobitel_ID = MobitelID) AND ((d.LogID = SecondLogID) AND (d.SrvPacketID = SecondSrvPacketID))) THEN 



                CALL OnInsertDatagpsLost(MobitelID, FirstLogID, SecondLogID, FirstSrvPacketID, SecondSrvPacketID);

                IF NeedOptimize = 0 THEN SET NeedOptimize = 1; END IF;

                

              END IF;

            END IF;

          END IF;

        END IF;

            /* РџРµСЂРµРјРµСЃС‚РёРј С‚РµРєСѓС‰РµРµ РІС‚РѕСЂРѕРµ Р·РЅР°С‡РµРЅРёРµ РЅР° РїРµСЂРІСѓСЋ РїРѕР·РёС†РёСЋ

               РґР»СЏ СѓС‡Р°СЃС‚РёСЏ РІ СЃР»РµРґСѓСЋС‰РµР№ РёС‚РµСЂР°С†РёРё РІ РєР°С‡РµСЃС‚РІРµ РЅР°С‡Р°Р»СЊРЅРѕРіРѕ Р·РЅР°С‡РµРЅРёСЏ */

            SET FirstLogID = SecondLogID;

            SET FirstSrvPacketID = SecondSrvPacketID;

          END IF;

          FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

        END WHILE;

        CLOSE CursorNewLogID;

      END;

      /********** END INSERT ROWS **********/



      TRUNCATE TABLE datagpslost_ontmp;

    END IF;



    FETCH CursorLostRanges INTO BeginLogID, EndLogID, BeginSrvPacketID, EndSrvPacketID;

  END WHILE;

  CLOSE CursorLostRanges;



  /********** UPDATE MOBITELS **********/



  /* Р•СЃР»Рё РїСЂРѕРїСѓС‰РµРЅРЅС‹С… Р·Р°РїРёСЃРµР№ Сѓ РґР°РЅРЅРѕРіРѕ С‚РµР»РµС‚СЂРµРєР° РЅРµС‚ - 

     С‚РѕРіРґР° ConfirmedID Р±СѓРґРµС‚ СЂР°РІРµРЅ РјР°РєСЃРёРјР°Р»СЊРЅРѕРјСѓ LogID 

     РґР°РЅРЅРѕРіРѕ С‚РµР»РµС‚СЂРµРєР°. РРЅР°С‡Рµ - РјРёРЅРёРјР°Р»СЊРЅС‹Р№ Begin_LogID

     РёР· С‚Р°Р±Р»РёС†С‹ РїСЂРѕРїСѓСЃРєРѕРІ */

  SELECT

    MIN(Begin_LogID) INTO NewConfirmedID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;



  IF NewConfirmedID IS NULL THEN

    SELECT

      MAX(LogID) INTO NewConfirmedID

    FROM datagps64

    WHERE Mobitel_ID = MobitelID;

  END IF;



  /* РћР±РЅРѕРІРёРј ConfirmedID РµСЃР»Рё РЅР°РґРѕ */

  UPDATE mobitels

  SET ConfirmedID = NewConfirmedID

  WHERE (Mobitel_ID = MobitelID) AND (ConfirmedID < NewConfirmedID);



/********** END UPDATE MOBITELS **********/

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnLostDataGPS64` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnLostDataGPS64`(IN MobitelID integer(11), OUT NeedOptimize tinyint)
    SQL SECURITY INVOKER
    COMMENT 'РџРѕРёСЃРє РїСЂРѕРїСѓСЃРєРѕРІ РІ online РґР°РЅРЅС‹С… Р·Р°РґР°РЅРЅРѕРіРѕ С‚РµР»РµС‚СЂРµРєР° Рё Р·Р°РїРѕР»РЅРµРЅРёРµ С‚Р°Р±Р»РёС†.'
BEGIN



  /********** DECLARE **********/



  DECLARE CurrentConfirmedID int DEFAULT 0; /* РўРµРєСѓС‰РµРµ Р·РЅР°С‡РµРЅРёРµ ConfirmedID */

  DECLARE NewConfirmedID int DEFAULT 0; /* РќРѕРІРѕРµ Р·РЅР°С‡РµРЅРёРµ ConfirmedID */

  DECLARE StartLogIDSelect int DEFAULT 0; /* min LogID РґР»СЏ РІС‹Р±РѕСЂРєРё */

  DECLARE FinishLogIDSelect int DEFAULT 0; /* max LogID РґР»СЏ РІС‹Р±РѕСЂРєРё */

  DECLARE MaxEndLogID int DEFAULT 0; /* max End_LogID РІ РїСЂРѕРїСѓС‰РµРЅРЅС‹С… РґРёР°РїР°Р·РѕРЅР°С… РґР°РЅРЅРѕРіРѕ С‚РµР»РµС‚СЂРµРєР° */



  DECLARE MinLogID_n int DEFAULT 0; /* РњРёРЅРёРјР°Р»СЊРЅС‹Р№ LogID РїРѕСЃР»Рµ ConfirmedID РІ РјРЅРѕР¶РµСЃС‚РІРµ РЅРѕРІС‹С… РґР°РЅРЅС‹С… */

  DECLARE MaxLogID_n int DEFAULT 0; /* РњР°РєСЃРёРјР°Р»СЊРЅС‹Р№ LogID РІ РјРЅРѕР¶РµСЃС‚РІРµ РЅРѕРІС‹С… РґР°РЅРЅС‹С… */



  DECLARE DataExists tinyint DEFAULT 1; /* Р¤Р»Р°Рі РЅР°Р»РёС‡РёСЏ РґР°РЅРЅС‹С… РїРѕСЃР»Рµ С„РµС‚С‡Р° */



  DECLARE NewLogID int; /* Р—РЅР°С‡РµРЅРёРµ LogID РІ РєСѓСЂСЃРѕСЂРµ CursorNewLogID */

  DECLARE NewSrvPacketID bigint; /* Р—РЅР°С‡РµРЅРёРµ SrvPacketID РІ РєСѓСЂСЃРѕСЂРµ CursorNewLogID */

  DECLARE FirstLogID int DEFAULT -9999999; /* РџРµСЂРІРѕРµ Р·РЅР°С‡РµРЅРёРµ LogID РґР»СЏ Р°РЅР°Р»РёР·Р° */

  DECLARE SecondLogID int; /* Р’С‚РѕСЂРѕРµ Р·РЅР°С‡РµРЅРёРµ LogID РґР»СЏ Р°РЅР°Р»РёР·Р° */

  DECLARE FirstSrvPacketID bigint; /* РџРµСЂРІРѕРµ Р·РЅР°С‡РµРЅРёРµ SrvPacketID */

  DECLARE SecondSrvPacketID bigint; /* Р’С‚РѕСЂРѕРµ Р·РЅР°С‡РµРЅРёРµ SrvPacketID */



  DECLARE tmpSrvPacketID bigint DEFAULT 0; /* Р—РЅР°С‡РµРЅРёРµ SrvPacketID РґР»СЏ РїРµСЂРІРѕР№ РёСЃРєСѓСЃСЃС‚РІРµРЅРЅРѕР№ Р·Р°РїРёСЃРё РІ Р°РЅР°Р»РёР·Рµ РЅРѕРІС‹С… РґР°РЅРЅС‹С…, РЅРµ РїРµСЂРµСЃРµРєР°СЋС‰РёС…СЃСЏ СЃ СЃСѓС‰РµСЃС‚РІСѓСЋС‰РёРјРё */



  /* РљСѓСЂСЃРѕСЂ РґР»СЏ РїСЂРѕС…РѕРґР° РїРѕ РЅРѕРІС‹Рј LogID */

  DECLARE CursorNewLogID CURSOR FOR

  SELECT

    LogID,

    SrvPacketID

  FROM datagpslost_ontmp;



  /* РћР±СЂР°Р±РѕС‚С‡РёРє РѕС‚СЃСѓС‚СЃС‚РІСѓСЋС‰РµР№ Р·Р°РїРёСЃРё РїСЂРё FETCH СЃР»РµРґСѓСЋС‰РµР№ Р·Р°РїРёСЃРё */

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  /********** END DECLARE **********/



  SET NeedOptimize = 0;



  SELECT

    COALESCE(ConfirmedID, 0) INTO CurrentConfirmedID

  FROM mobitels

  WHERE Mobitel_ID = MobitelID;



  /* РњРёРЅРёРјР°Р»СЊРЅС‹Р№ LogID РІ РЅРѕРІРѕРј РЅР°Р±РѕСЂРµ РґР°РЅРЅС‹С… c РєРѕС‚РѕСЂС‹Рј Р±СѓРґРµРј СЂР°Р±РѕС‚Р°С‚СЊ */

  SELECT

    MIN(LogID) INTO MinLogID_n

  FROM datagpsbuffer_on64

  WHERE (Mobitel_ID = MobitelID) AND (LogID > CurrentConfirmedID);



  /* РњР°РєСЃРёРјР°Р»СЊРЅС‹Р№ LogID РІ РЅРѕРІРѕРј РЅР°Р±РѕСЂРµ РґР°РЅРЅС‹С… c РєРѕС‚РѕСЂС‹Рј Р±СѓРґРµРј СЂР°Р±РѕС‚Р°С‚СЊ */

  SELECT

    MAX(LogID) INTO MaxLogID_n

  FROM datagpsbuffer_on64

  WHERE Mobitel_ID = MobitelID;



  /* РњР°РєСЃРёРјР°Р»СЊРЅС‹Р№ End_LogID РІ РїСЂРѕРїСѓС‰РµРЅРЅС‹С… РґРёР°РїР°Р·РѕРЅР°С… РґР°РЅРЅРѕРіРѕ С‚РµР»РµС‚СЂРµРєР° */

  SELECT

    COALESCE(MAX(End_LogID), 0) INTO MaxEndLogID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;



  /* РџСЂРѕРІРµСЂРёРј РµСЃС‚СЊ Р»Рё РґР°РЅРЅС‹Рµ РґР»СЏ Р°РЅР°Р»РёР·Р° */

  IF MinLogID_n IS NOT NULL THEN



    /********** PREPARE **********/



    TRUNCATE TABLE datagpslost_ontmp;



    IF MinLogID_n < MaxEndLogID THEN

      /* Р•СЃР»Рё  MinLogID_n < MaxEndLogID Р·РЅР°С‡РёС‚ РїСЂРёС€Р»Рё РґР°РЅРЅС‹Рµ, 

       РєРѕС‚РѕСЂС‹Рµ РІРѕР·РјРѕР¶РЅРѕ Р·Р°РєСЂРѕСЋС‚ С‡Р°СЃС‚СЊ РїСЂРѕРїСѓСЃРєРѕРІ. */



      /* РќР°С…РѕРґРёРј СЃС‚Р°СЂС‚РѕРІС‹Р№ LogID РґР»СЏ РїРµСЂРµСЃС‡РµС‚Р°. */

      SELECT

        COALESCE(Begin_LogID, MinLogID_n) INTO StartLogIDSelect

      FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (MinLogID_n > Begin_LogID)

      AND (MinLogID_n < End_LogID);



      /* РќР°С…РѕРґРёРј РїРѕСЃР»РµРґРЅРёР№ LogID РґР»СЏ РїРµСЂРµСЃС‡РµС‚Р°. */

      SELECT

        COALESCE(End_LogID, MaxLogID_n) INTO FinishLogIDSelect

      FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (MaxLogID_n > Begin_LogID)

      AND (MaxLogID_n < End_LogID);



      /* РЈРґР°Р»РёРј СЃС‚Р°СЂС‹Рµ Р·Р°РїРёСЃРё РёР· СЂРµРµСЃС‚СЂР° РїСЂРѕРїСѓС‰РµРЅРЅС‹С… Р·Р°РїРёСЃРµР№ 

         (СЃС‚Р°Р»Рё РЅРµР°РєС‚СѓР°Р»СЊРЅС‹РјРё, РЅР°РґРѕ РїРµСЂРµСЃС‡РёС‚Р°С‚СЊ) */

      DELETE

        FROM datagpslost_on

      WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID >= StartLogIDSelect)

        AND (Begin_LogID <= FinishLogIDSelect);



      /* Р•СЃР»Рё РїРµСЂРІР°СЏ Р·Р°РїРёСЃСЊ LogID = 0 Рё СЌС‚РѕР№ Р·Р°РїРёСЃРё РЅРµС‚ РІ DataGps, С‚РѕРіРґР°

         РЅР°РґРѕ РґРѕР±Р°РІРёС‚СЊ РїРµСЂРІСѓСЋ С„РёРєС‚РёРІРЅСѓСЋ Р·Р°РїРёСЃСЊ РґР»СЏ Р°РЅР°Р»РёР·Р°. */

      IF (StartLogIDSelect = 0) AND (NOT EXISTS (SELECT

            1

          FROM datagps64

          WHERE (Mobitel_ID = MobitelID) AND (LogID = StartLogIDSelect))) THEN



        INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

          VALUES (0, 0);

      END IF;

    ELSE

      /* РџСЂРёС€Р»Рё РЅРѕРІС‹Рµ РґР°РЅРЅС‹Рµ. РќР°РґРѕ РґРѕР±Р°РІРёС‚СЊ РґР»СЏ Р°РЅР°Р»РёР·Р° РёСЃРєСѓСЃСЃС‚РІРµРЅРЅСѓСЋ Р·Р°РїРёСЃСЊ - 

         РЅРёР¶РЅСЋСЋ РіСЂР°РЅРёС†Сѓ */



      /* РќР°С…РѕРґРёРј СЃС‚Р°СЂС‚РѕРІС‹Р№ LogID РґР»СЏ РїРµСЂРµСЃС‡РµС‚Р°. */

      SELECT

        COALESCE(MAX(End_LogID), CurrentConfirmedID) INTO StartLogIDSelect

      FROM datagpslost_on

      WHERE Mobitel_ID = MobitelID;



      /* РќР°С…РѕРґРёРј РїРѕСЃР»РµРґРЅРёР№ LogID РґР»СЏ РїРµСЂРµСЃС‡РµС‚Р°. */

      SELECT

        MAX(LogID) INTO FinishLogIDSelect

      FROM datagpsbuffer_on64

      WHERE Mobitel_ID = MobitelID;



      /* Р’С‹Р±РёСЂР°РµРј РёР· datagps СЃРѕРѕС‚РІРµС‚СЃС‚РІСѓСЋС‰РµРµ Р·РЅР°С‡РµРЅРёРµ SrvPacketID  РґР»СЏ РїРµСЂРІРѕР№

         РёСЃРєСѓСЃСЃС‚РІРµРЅРЅРѕР№ Р·Р°РїРёСЃРё */

      SELECT

        COALESCE(SrvPacketID, 0) INTO tmpSrvPacketID

      FROM datagps64

      WHERE (Mobitel_ID = MobitelID) AND (LogID = StartLogIDSelect);



      /* РџРѕРјРµС‰Р°РµРј РІ С‚Р°Р±Р»РёС†Сѓ datagpslost_ontmp64 РґР»СЏ Р°РЅР°Р»РёР·Р° РїСЂРѕРїСѓСЃРєРѕРІ 

         РґРѕРїРѕР»РЅРёС‚РµР»СЊРЅСѓСЋ РїРµСЂРІСѓСЋ Р·Р°РїРёСЃСЊ */

      INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

        VALUES (StartLogIDSelect, tmpSrvPacketID);

    END IF; -- IF MinLogID_n < MaxEndLogID   



    /********** END PREPARE **********/



    /**********  INSERT ROWS **********/



    /* Р—Р°РїРѕР»РЅРµРЅРёРµ РІСЂРµРјРµРЅРЅРѕР№ С‚Р°Р±Р»РёС†С‹ РїРѕСЃР»РµРґРЅРёРјРё РґР°РЅРЅС‹РјРё С‚РµР»РµС‚СЂРµРєР°

       РґР»СЏ Р°РЅР°Р»РёР·Р° СЂР°Р·СЂС‹РІРѕРІ */

    INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

      SELECT

        LogID,

        SrvPacketID

      FROM datagps64

      WHERE (Mobitel_ID = MobitelID) AND (LogID >= StartLogIDSelect)

      AND (LogID <= FinishLogIDSelect)

      ORDER BY LogID;



    /* Р¤РѕСЂРјРёСЂРѕРІР°РЅРёРµ РєРѕРјР°РЅРґС‹-РІСЃС‚Р°РІРєРё РІ С‚Р°Р±Р»РёС†Сѓ РїСЂРѕРїСѓС‰РµРЅРЅС‹С… РґРёР°РїР°Р·РѕРЅРѕРІ */

    SET DataExists = 1;

    OPEN CursorNewLogID;

    FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

    WHILE DataExists = 1 DO

      IF FirstLogID = -9999999 THEN

        /* РџРµСЂРІРѕРµ Р·РЅР°С‡РµРЅРёРµ РІ СЃРїРёСЃРєРµ */

        SET FirstLogID = NewLogID;

        SET FirstSrvPacketID = NewSrvPacketID;

      ELSE

        /* РћСЃРЅРѕРІРЅР°СЏ РІРµС‚РєР° СЂР°СЃС‡РµС‚Р°*/

        SET SecondLogID = NewLogID;

        SET SecondSrvPacketID = NewSrvPacketID;



        IF (SecondLogID - FirstLogID) > 1 THEN

          /* РќР°Р№РґРµРЅ СЂР°Р·СЂС‹РІ */

          /* РР·-Р·Р° РІСЃСЏРєРёС… РєРѕРјР±РёРЅР°С†РёР№ СЃРѕСЃС‚РѕСЏРЅРёР№ LogId Рё SrvPacketId РёР·-Р·Р° РѕСЃРѕР±РµРЅРЅРѕСЃС‚РµР№ СЂР°Р±РѕС‚С‹ С‚РµР»РµРјР°С‚РёС‡РµСЃРєРѕРіРѕ СЃРµСЂРІРµСЂР°

          Рё РўР”Рњ РІРІРѕРґРёРј РґРѕРїРѕР»РЅРёС‚РµР»СЊРЅС‹Р№ Р°РЅР°Р»РёР· РІСЃС‚Р°РІР»СЏРµРјС‹С… Р·Р°РїРёСЃРµР№, РµСЃР»Рё Р·Р°РїРёСЃСЊ РЅРµ СЃРѕРѕС‚РІРµС‚СЃРІСѓРµС‚ СѓРєР°Р·Р°РЅС‹Рј РїСЂР°РІРёР»Р°Рј, РѕРЅР° 

          РѕС‚Р±СЂР°СЃС‹РІР°РµС‚СЃСЏ */

          IF (SecondSrvPacketID > FirstSrvPacketID) THEN

            IF EXISTS(SELECT NULL FROM datagps64 d WHERE (d.Mobitel_ID = MobitelID) AND ((d.LogID = FirstLogID) AND (d.SrvPacketID = FirstSrvPacketID))) THEN 

              IF EXISTS(SELECT NULL FROM datagps64 d WHERE (d.Mobitel_ID = MobitelID) AND ((d.LogID = SecondLogID) AND (d.SrvPacketID = SecondSrvPacketID))) THEN 



                CALL OnInsertDatagpsLost(MobitelID, FirstLogID, SecondLogID, FirstSrvPacketID, SecondSrvPacketID);

                IF NeedOptimize = 0 THEN SET NeedOptimize = 1; END IF;

                

              END IF;

            END IF;

          END IF;

        END IF;

        /* РџРµСЂРµРјРµСЃС‚РёРј С‚РµРєСѓС‰РµРµ РІС‚РѕСЂРѕРµ Р·РЅР°С‡РµРЅРёРµ РЅР° РїРµСЂРІСѓСЋ РїРѕР·РёС†РёСЋ

           РґР»СЏ СѓС‡Р°СЃС‚РёСЏ РІ СЃР»РµРґСѓСЋС‰РµР№ РёС‚РµСЂР°С†РёРё РІ РєР°С‡РµСЃС‚РІРµ РЅР°С‡Р°Р»СЊРЅРѕРіРѕ Р·РЅР°С‡РµРЅРёСЏ */

        SET FirstLogID = SecondLogID;

        SET FirstSrvPacketID = SecondSrvPacketID;

      END IF;

      FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

    END WHILE;

    CLOSE CursorNewLogID;



    /********** END INSERT ROWS **********/



    /********** UPDATE MOBITELS **********/



    /* Р•СЃР»Рё РїСЂРѕРїСѓС‰РµРЅРЅС‹С… Р·Р°РїРёСЃРµР№ Сѓ РґР°РЅРЅРѕРіРѕ С‚РµР»РµС‚СЂРµРєР° РЅРµС‚ - 

       С‚РѕРіРґР° ConfirmedID Р±СѓРґРµС‚ СЂР°РІРµРЅ РјР°РєСЃРёРјР°Р»СЊРЅРѕРјСѓ LogID 

       РґР°РЅРЅРѕРіРѕ С‚РµР»РµС‚СЂРµРєР°. РРЅР°С‡Рµ - РјРёРЅРёРјР°Р»СЊРЅС‹Р№ Begin_LogID

       РёР· С‚Р°Р±Р»РёС†С‹ РїСЂРѕРїСѓСЃРєРѕРІ */

    SELECT

      MIN(Begin_LogID) INTO NewConfirmedID

    FROM datagpslost_on

    WHERE Mobitel_ID = MobitelID;



    IF NewConfirmedID IS NULL THEN

      SELECT

        MAX(LogID) INTO NewConfirmedID

      FROM datagps64

      WHERE Mobitel_ID = MobitelID;

    END IF;



    /* РћР±РЅРѕРІРёРј ConfirmedID РµСЃР»Рё РЅР°РґРѕ */

    UPDATE mobitels

    SET ConfirmedID = NewConfirmedID

    WHERE (Mobitel_ID = MobitelID) AND (ConfirmedID < NewConfirmedID);



    /********** END UPDATE MOBITELS **********/



    TRUNCATE TABLE datagpslost_ontmp;

  END IF; -- IF MaxEndLogID IS NOT NULL  

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnTransferBuffer` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnTransferBuffer`()
    SQL SECURITY INVOKER
    COMMENT 'Переносит GPS данные из буферной таблицы в datagps'
BEGIN

  DECLARE MobitelIDInCursor INT; /* Текущее значение MobitelID */

  DECLARE DataExists TINYINT DEFAULT 1; /* Флаг наличия данных после фетча */

  DECLARE NeedOptimize TINYINT DEFAULT 0; /* Нужна оптимизация или нет */

  DECLARE NeedOptimizeParam TINYINT;

  

  DECLARE TmpMaxUnixTime INT; /* Временная переменная для хранения Max UnixTime из таблицы online */



  /* Курсор по телетрекам в множестве новых данных */

  DECLARE CursorMobitelsInsertSet CURSOR FOR

    SELECT DISTINCT(Mobitel_ID) FROM datagpsbuffer_on;

  /* Курсор по телетрекам в множестве повторных данных */

  DECLARE CursorMobitelsUpdateSet CURSOR FOR

    SELECT DISTINCT(Mobitel_ID) FROM datagpsbuffer_ontmp;  



  /* Обработчик отсутствующей записи при FETCH следующей записи */

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  CALL OnDeleteDuplicates();

  CALL OnCorrectInfotrackLogId();

  

  /* Сохраняем записи, которые уже есть в БД, для второго этапа анализа пропусков 

     Используется процедурой OnLostDataGPS2. */

  INSERT INTO datagpsbuffer_ontmp (Mobitel_ID, LogID, SrvPacketID)

    SELECT b.Mobitel_ID, b.LogID, b.SrvPacketID

    FROM datagpsbuffer_on b LEFT JOIN datagps d ON

      (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

    WHERE d.LogID IS NOT NULL;

       

  /* -------------------- Заполнение таблицы Online ---------------------- */  

  /* Удаление из таблицы online дублирующих строк таблицы datagpsbuffer_on */

  /* по полям Mobitel_ID и LogID */

  DELETE o

  FROM `online` o, datagpsbuffer_on dgb

  WHERE (o.Mobitel_ID = dgb.Mobitel_ID) AND (o.LogID = dgb.LogID);

  

  SET DataExists = 1;

  OPEN CursorMobitelsInsertSet;

  FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* Нахождение Max значения UnixTime в таблице online для заданного

       телетрека. p.s. UnixTime в таблице online только валидный */

    SELECT COALESCE(MAX(UnixTime), 0) INTO TmpMaxUnixTime

    FROM online FORCE INDEX (IDX_Mobitelid)

    WHERE Mobitel_ID = MobitelIDInCursor;



    /* Вставка новых записей (максимум 100)каждого телетрека в online */

    INSERT INTO `online` (

      Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Altitude,

      Direction, Speed, Valid, `Events`,

      Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6, Sensor7, Sensor8,

      Counter1, Counter2, Counter3, Counter4, whatIs)

    SELECT

      Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Altitude,

      Direction, Speed, Valid, `Events`,

      Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6, Sensor7, Sensor8,

      Counter1, Counter2, Counter3, Counter4, whatIs

    FROM (

      SELECT *

      FROM datagpsbuffer_on

      WHERE (Mobitel_ID = MobitelIDInCursor)  AND 

        (UnixTime > TmpMaxUnixTime) AND (Valid = 1)

      GROUP BY Mobitel_ID, LogID

      ORDER BY UnixTime DESC

      LIMIT 100) AS T

    ORDER BY UnixTime ASC;



    /* Удаление строк из таблицы оперативных данных не удовлетворяющие

       условиям хранения - не являются последними 100 строками */

    DELETE FROM `online`

    WHERE (Mobitel_ID = MobitelIDInCursor) AND (UnixTime < 

      (SELECT COALESCE(MIN(UnixTime), 0) 

       FROM (

         SELECT UnixTime

         FROM `online`

         WHERE Mobitel_ID = MobitelIDInCursor 

         ORDER BY UnixTime DESC

         LIMIT 100) T1)); 

  

    FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsInsertSet;

  /* ---------------- Online ---------------- */ 

  

  /* Зачем-то нужен апдейт ... */

  UPDATE datagps d, datagpsbuffer_on b SET

    d.Latitude = b.Latitude,

    d.Longitude = b.Longitude,

    d.Altitude = b.Altitude,

    d.UnixTime = b.UnixTime,

    d.Speed = b.Speed,

    d.Direction = b.Direction,

    d.Valid = b.Valid,

    d.InMobitelID = b.LogID,

    d.Events = b.Events,

    d.Sensor1 = b.Sensor1,

    d.Sensor2 = b.Sensor2,

    d.Sensor3 = b.Sensor3,

    d.Sensor4 = b.Sensor4,

    d.Sensor5 = b.Sensor5,

    d.Sensor6 = b.Sensor6,

    d.Sensor7 = b.Sensor7,

    d.Sensor8 = b.Sensor8,

    d.whatIs = b.whatIs,

    d.Counter1 = b.Counter1,

    d.Counter2 = b.Counter2,

    d.Counter3 = b.Counter3,

    d.Counter4 = b.Counter4,

    d.SrvPacketID = b.SrvPacketID

  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

    AND (d.SrvPacketID < b.SrvPacketID);



  /* Удалим записи которые участвовали в апдейте */

  DELETE b

  FROM datagps d, datagpsbuffer_on b

  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID);



  /* Вставка новых записей*/

  INSERT INTO datagps (

    Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Altitude,

    Direction, Speed, Valid, `Events`, InMobitelID,

    Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6, Sensor7, Sensor8,

    Counter1, Counter2, Counter3, Counter4, whatIs, SrvPacketID)

  SELECT

    Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Altitude,

    Direction, Speed, Valid, `Events`, LogID,

    Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6, Sensor7, Sensor8,

    Counter1, Counter2, Counter3, Counter4, whatIs, SrvPacketID

  FROM datagpsbuffer_on

  GROUP BY Mobitel_ID, LogID;



  /* ------------------- FETCH Mobitels (INSERT SET) ----------------------- */

  SET DataExists = 1;

  OPEN CursorMobitelsInsertSet;

  FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* ------ Обновление времени последней вставки записей ------- */

    UPDATE mobitels SET LastInsertTime = UNIX_TIMESTAMP(NOW())

    WHERE Mobitel_ID = MobitelIDInCursor;

       

    /* ------ Обновление списка пропущенных записей -------------- */

    CALL OnLostDataGPS(MobitelIDInCursor, NeedOptimizeParam);

    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);

    FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsInsertSet;



  /* Очистка буфера */

  TRUNCATE TABLE datagpsbuffer_on;

    

  /* ------------------- FETCH Mobitels (UPDATE SET) ---------------------- */

  SET DataExists = 1;

  OPEN CursorMobitelsUpdateSet;

  FETCH CursorMobitelsUpdateSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* ---- Обновление списка пропущенных записей по второму алгоритму --- */

    CALL OnLostDataGPS2(MobitelIDInCursor, NeedOptimizeParam);

    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);

    FETCH CursorMobitelsUpdateSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsUpdateSet;

  

  /* Очистка вспомогательного буфера */

  TRUNCATE TABLE datagpsbuffer_ontmp;



  /* Были изменения - сделаем оптимизацию */

  /*IF NeedOptimize = 1 THEN

    OPTIMIZE TABLE datagpslost_on;

  END IF; */           

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `OnTransferBuffer64` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnTransferBuffer64`()
    SQL SECURITY INVOKER
BEGIN

  DECLARE MobitelIDInCursor int; /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ MobitelID */

  DECLARE DataExists tinyint DEFAULT 1; /* пїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ */

  DECLARE NeedOptimize tinyint DEFAULT 0; /* пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅ */

  DECLARE NeedOptimizeParam tinyint;



  DECLARE TmpMaxUnixTime int; /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ Max UnixTime пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ online */



  /* пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  DECLARE CursorMobitelsInsertSet CURSOR FOR

  SELECT DISTINCT

    (Mobitel_ID)

  FROM datagpsbuffer_on64;

  /* пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  DECLARE CursorMobitelsUpdateSet CURSOR FOR

  SELECT DISTINCT

    (Mobitel_ID)

  FROM datagpsbuffer_ontmp64;



  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ FETCH пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  /*DECLARE EXIT HANDLER FOR SQLEXCEPTION 

  BEGIN

    ROLLBACK;

    SELECT 'An error has occurred, operation rollbacked and the stored procedure was terminated';

  end;*/



  CALL delDupSrvPacket();

  CALL OnDeleteDuplicates64();

  /*CALL OnCorrectInfotrackLogId64();*/



  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ, пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅпїЅ пїЅ пїЅпїЅ, пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ 

     пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ OnLostDataGPS264. */

  /*INSERT INTO datagpsbuffer_ontmp64 (Mobitel_ID, LogID, SrvPacketID)

    SELECT

      b.Mobitel_ID,

      b.LogID,

      b.SrvPacketID

    FROM datagpsbuffer_on64 b

      LEFT JOIN datagps64 d

        ON (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

    WHERE d.LogID IS NOT NULL GROUP BY d.SrvPacketID;*/

 DROP TEMPORARY TABLE IF EXISTS temp1;

  DROP TABLE IF EXISTS temp1;

  CREATE TEMPORARY TABLE temp1  SELECT

      b.Mobitel_ID,

      b.LogID,

      b.SrvPacketID

    FROM datagpsbuffer_on64 b

      LEFT JOIN datagps64 d

        ON (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

    WHERE d.LogID IS NOT NULL GROUP BY d.SrvPacketID;



INSERT INTO datagpsbuffer_ontmp64 (Mobitel_ID, LogID, SrvPacketID) SELECT * FROM temp1 GROUP BY SrvPacketID;



DROP TEMPORARY TABLE IF EXISTS temp1;


  /* -------------------- пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ Online ---------------------- */

  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ online пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ datagpsbuffer_on64 */

  /* пїЅпїЅ пїЅпїЅпїЅпїЅпїЅ Mobitel_ID пїЅ LogID */

  DELETE o

    FROM online64 o, datagpsbuffer_on64 dgb

  WHERE (o.Mobitel_ID = dgb.Mobitel_ID) AND (o.LogID = dgb.LogID);



  SET DataExists = 1;

  OPEN CursorMobitelsInsertSet;

  FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ Max пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ UnixTime пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ online пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ

       пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ. p.s. UnixTime пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ online пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ */

    SELECT

      COALESCE(MAX(UnixTime), 0) INTO TmpMaxUnixTime

    FROM online64 FORCE INDEX (IDX_Mobitelid64)

    WHERE Mobitel_ID = MobitelIDInCursor;



    /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ (пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ 100)пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅ online */

    INSERT INTO online64 (Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Acceleration,

    Direction, Speed, Valid, `Events`,

    Satellites, RssiGsm, SensorsSet, Sensors, Voltage, DGPS)

      SELECT

        Mobitel_ID,

        LogID,

        UnixTime,

        Latitude,

        Longitude,

        Acceleration,

        Direction,

        Speed,

        Valid,

        `Events`,

        Satellites,

        RssiGsm,

        SensorsSet,

        Sensors,

        Voltage,

        DGPS

      FROM (SELECT

          *

        FROM datagpsbuffer_on64

        WHERE (Mobitel_ID = MobitelIDInCursor) AND

        (UnixTime > TmpMaxUnixTime) AND (Valid = 1)

        GROUP BY Mobitel_ID,

                 LogID

        ORDER BY UnixTime DESC

        LIMIT 100) AS T

      ORDER BY UnixTime ASC;



    /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ

       пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ - пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ 100 пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ */

    DELETE

      FROM online64

    WHERE (Mobitel_ID = MobitelIDInCursor) AND (UnixTime < (SELECT

          COALESCE(MIN(UnixTime), 0)

        FROM (SELECT

            UnixTime

          FROM online64

          WHERE Mobitel_ID = MobitelIDInCursor

          ORDER BY UnixTime DESC

          LIMIT 100) T1));



    FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsInsertSet;

  /* ---------------- Online ---------------- */

  /* пїЅпїЅпїЅпїЅпїЅ-пїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ ... */

  UPDATE datagps64 d, datagpsbuffer_on64 b

  SET d.Latitude = b.Latitude,

      d.Longitude = b.Longitude,

      d.Acceleration = b.Acceleration,

      d.UnixTime = b.UnixTime,

      d.Speed = b.Speed,

      d.Direction = b.Direction,

      d.Valid = b.Valid,

      d.LogID = b.LogID,

      d.`Events` = b.`Events`,

      d.Satellites = b.Satellites,

      d.RssiGsm = b.RssiGsm,

      d.SensorsSet = b.SensorsSet,

      d.Sensors = b.Sensors,

      d.Voltage = b.Voltage,

      d.DGPS = b.DGPS,

      d.SrvPacketID = b.SrvPacketID

  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

  AND (d.SrvPacketID < b.SrvPacketID);



  /* пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ */

  DELETE b

    FROM datagps64 d, datagpsbuffer_on64 b

  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID);



    /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ */ 

  INSERT INTO datagps64 (Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Acceleration,

  Direction, Speed, Valid, `Events`,

  Satellites, RssiGsm, SensorsSet, Sensors, Voltage, DGPS, SrvPacketID)

    SELECT

      Mobitel_ID,

      LogID,

      UnixTime,

      Latitude,

      Longitude,

      Acceleration,

      Direction,

      Speed,

      Valid,

      `Events`,

      Satellites,

      RssiGsm,

      SensorsSet,

      Sensors,

      Voltage,

      DGPS,

      SrvPacketID

    FROM datagpsbuffer_on64

    GROUP BY Mobitel_ID,

             LogID;



  /* ------------------- FETCH Mobitels (INSERT SET) ----------------------- */

  SET DataExists = 1;

  OPEN CursorMobitelsInsertSet;

  FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* ------ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ ------- */

    UPDATE mobitels

    SET LastInsertTime = UNIX_TIMESTAMP(NOW())

    WHERE Mobitel_ID = MobitelIDInCursor;



    /* ------ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ -------------- */

    CALL OnLostDataGPS64(MobitelIDInCursor, NeedOptimizeParam);

    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);

    FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsInsertSet;



  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  TRUNCATE TABLE datagpsbuffer_on64;



  /* ------------------- FETCH Mobitels (UPDATE SET) ---------------------- */

  SET DataExists = 1;

  OPEN CursorMobitelsUpdateSet;

  FETCH CursorMobitelsUpdateSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* ---- пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ --- */

    CALL OnLostDataGPS264(MobitelIDInCursor, NeedOptimizeParam);

    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);

    FETCH CursorMobitelsUpdateSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsUpdateSet;



  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  TRUNCATE TABLE datagpsbuffer_ontmp64;



  /* пїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ - пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ */

  /*IF NeedOptimize = 1 THEN

    OPTIMIZE TABLE datagpslost_on;

  END IF;*/

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `SelectDataGpsPeriodAll` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `SelectDataGpsPeriodAll`(IN mobile int, IN beginperiod datetime, IN endperiod datetime,

IN timebegin varchar(9), IN timeend varchar(9), IN weekdays varchar(15), IN daymonth varchar(90))
BEGIN

  DECLARE time0 time DEFAULT '23:59:59';

  DECLARE time1 time DEFAULT '00:00:00'; 



  DROP TEMPORARY TABLE IF EXISTS tempperiod4;



  CREATE TEMPORARY TABLE tempperiod4 -- временная таблица выборок в указанном диапазоне

  SELECT

    DataGps_ID AS DataGps_ID,

    Mobitel_ID AS Mobitel_ID,

    ((Latitude * 1.0000) / 600000) AS Lat,

    ((Longitude * 1.0000) / 600000) AS Lon,

    Altitude AS Altitude,

    FROM_UNIXTIME(UnixTime) AS `time`,

    (Speed * 1.852) AS speed,

    Valid AS Valid,

    (Sensor8 + (Sensor7 << 8) + (Sensor6 << 16) + (Sensor5 << 24) + (Sensor4 << 32) + (Sensor3 << 40) + (Sensor2 << 48) + (Sensor1 << 56)) AS sensor,

    Events AS Events,

    LogID AS LogID

  FROM datagps

  WHERE Mobitel_ID = mobile AND

  (UnixTime BETWEEN UNIX_TIMESTAMP(beginperiod) AND UNIX_TIMESTAMP(endperiod)) AND

  (Valid = 1) AND NOT (Latitude = 0 AND Longitude = 0)

  ORDER BY UnixTime;



  DROP TEMPORARY TABLE IF EXISTS tempweeks;



  IF weekdays != '' THEN



    CREATE TEMPORARY TABLE tempweeks (

      shead varchar(2)

    );



    SET @saTail = weekdays;

    WHILE @saTail != '' DO

      SET @sHead = SUBSTRING_INDEX(@saTail, ';', 1);

      SET @saTail = SUBSTRING(@saTail, LENGTH(@sHead) + 2);

      INSERT INTO tempweeks (shead)

        VALUES (@sHead);

    END WHILE;

  END IF;



  DROP TEMPORARY TABLE IF EXISTS tempday0;



  IF daymonth != '' THEN



    CREATE TEMPORARY TABLE tempday0 (

      shead varchar(2)

    );



    SET @saTail = daymonth;

    WHILE @saTail != '' DO

      SET @sHead = SUBSTRING_INDEX(@saTail, ';', 1);

      SET @saTail = SUBSTRING(@saTail, LENGTH(@sHead) + 2);

      INSERT INTO tempday0 (shead)

        VALUES (@sHead);

    END WHILE;

  END IF;



  -- getting selecting data

  IF (daymonth != '') AND (weekdays != '') THEN

    IF TIME(timebegin) < TIME(timeend) then

    SELECT

      *

    FROM tempperiod4

    WHERE ((DAY(`time`) IN (SELECT

      *

    FROM tempday0)) AND -- чтение по дням месяца

    (WEEKDAY(`time`) IN (SELECT

      *

    FROM tempweeks)) AND -- чтение по дням недели

    (TIME(`time`) BETWEEN TIME(timebegin) AND TIME(timeend))); -- чтение дат

    END IF;



    IF TIME(timebegin) > TIME(timeend) then

    SELECT

      *

    FROM tempperiod4

    WHERE ((DAY(`time`) IN (SELECT

      *

    FROM tempday0)) AND -- чтение по дням месяца

    (WEEKDAY(`time`) IN (SELECT

      *

    FROM tempweeks)) AND -- чтение по дням недели

    ((time(`time`) > time(timebegin) and time(`time`) < time(time0))

    OR (time(`time`) > time(time1) AND time(`time`) < time(timeend)))); -- чтение дат

    END IF;

    END IF;



      IF (daymonth = '') AND (weekdays != '') THEN

        IF TIME(timebegin) < TIME(timeend) then

        SELECT

          *

        FROM tempperiod4

        WHERE ((WEEKDAY(`time`) IN (SELECT

          *

        FROM tempweeks)) AND -- чтение по дням недели

        (TIME(`time`) BETWEEN TIME(timebegin) AND TIME(timeend))); -- чтение дат

          end IF;



        IF TIME(timebegin) > TIME(timeend) then

        SELECT

          *

        FROM tempperiod4

        WHERE ((WEEKDAY(`time`) IN (SELECT

          *

        FROM tempweeks)) AND -- чтение по дням недели

        ((time(`time`) > time(timebegin) and time(`time`) < time(time0))

    OR (time(`time`) > time(time1) AND time(`time`) < time(timeend)))); -- чтение дат

          end IF;

        END IF;



          IF (daymonth != '') AND (weekdays = '') THEN

            IF TIME(timebegin) < TIME(timeend) then

            SELECT

              *

            FROM tempperiod4

            WHERE ((DAY(`time`) IN (SELECT

              *

            FROM tempday0)) AND -- чтение по дням месяца

            (TIME(`time`) BETWEEN TIME(timebegin) AND TIME(timeend))); -- чтение дат

              END IF;



            IF TIME(timebegin) > TIME(timeend) then

            SELECT

              *

            FROM tempperiod4

            WHERE ((DAY(`time`) IN (SELECT

              *

            FROM tempday0)) AND -- чтение по дням месяца

            ((time(`time`) > time(timebegin) and time(`time`) < time(time0))

              OR (time(`time`) > time(time1) AND time(`time`) < time(timeend)))); -- чтение дат

              END IF;

            END IF;



              IF (daymonth = '') AND (weekdays = '') THEN

                IF TIME(timebegin) < TIME(timeend) then

                SELECT

                  *

                FROM tempperiod4

                WHERE (TIME(`time`) BETWEEN TIME(timebegin) AND TIME(timeend)); -- чтение дат

                  end IF;



                IF TIME(timebegin) > TIME(timeend) then

                SELECT

                  *

                FROM tempperiod4

                WHERE ((time(`time`) > time(timebegin) and time(`time`) < time(time0))

                  OR (time(`time`) > time(time1) AND time(`time`) < time(timeend))); -- чтение дат

                  end IF;

              END IF;

            END ;;
DELIMITER ;


