CREATE DATABASE  IF NOT EXISTS `kbm` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `kbm`;
-- MySQL dump 10.13  Distrib 8.0.36, for Win64 (x86_64)
--
-- Host: localhost    Database: kbm
-- ------------------------------------------------------
-- Server version	5.7.44-log

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

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

DROP TABLE IF EXISTS `agro_params`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Таблица параметров';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `agro_params` WRITE;
/*!40000 ALTER TABLE `agro_params` DISABLE KEYS */;
/*!40000 ALTER TABLE `agro_params` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `commands`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `commands` (
  `ID` int(11) DEFAULT '0',
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `commands` WRITE;
/*!40000 ALTER TABLE `commands` DISABLE KEYS */;
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);
/*!40000 ALTER TABLE `commands` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configdrivermessage`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configdrivermessage` WRITE;
/*!40000 ALTER TABLE `configdrivermessage` DISABLE KEYS */;
/*!40000 ALTER TABLE `configdrivermessage` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configevent`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configevent` WRITE;
/*!40000 ALTER TABLE `configevent` DISABLE KEYS */;
INSERT INTO `configevent` VALUES (1,'2538','Desctiption for Teletrack registered at 30.09.2019 15:46:04',0,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,'6091','Desctiption for Teletrack registered at 30.09.2019 15:46:48',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,'8865','Desctiption for Teletrack registered at 30.09.2019 15:47:12',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,'6079','Desctiption for Teletrack registered at 30.09.2019 15:47:59',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,'9004','Desctiption for Teletrack registered at 30.09.2019 15:48:21',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);
/*!40000 ALTER TABLE `configevent` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configgprsemail`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configgprsemail` WRITE;
/*!40000 ALTER TABLE `configgprsemail` DISABLE KEYS */;
INSERT INTO `configgprsemail` VALUES (1,'2538','Desctiption for Teletrack registered at 30.09.2019 15:46:04',0,0,0,'','','','','',''),(2,'6091','Desctiption for Teletrack registered at 30.09.2019 15:46:48',2,0,0,'','','','','',''),(3,'8865','Desctiption for Teletrack registered at 30.09.2019 15:47:12',3,0,0,'','','','','',''),(4,'6079','Desctiption for Teletrack registered at 30.09.2019 15:47:59',4,0,0,'','','','','',''),(5,'9004','Desctiption for Teletrack registered at 30.09.2019 15:48:21',5,0,0,'','','','','','');
/*!40000 ALTER TABLE `configgprsemail` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configgprsinit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configgprsinit` WRITE;
/*!40000 ALTER TABLE `configgprsinit` DISABLE KEYS */;
/*!40000 ALTER TABLE `configgprsinit` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configgprsmain`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configgprsmain` WRITE;
/*!40000 ALTER TABLE `configgprsmain` DISABLE KEYS */;
INSERT INTO `configgprsmain` VALUES (1,'2538','Desctiption for Teletrack registered at 30.09.2019 15:46:04',0,0,0,0,'','','','','','',''),(2,'6091','Desctiption for Teletrack registered at 30.09.2019 15:46:48',2,0,0,0,'','','','','','',''),(3,'8865','Desctiption for Teletrack registered at 30.09.2019 15:47:12',3,0,0,0,'','','','','','',''),(4,'6079','Desctiption for Teletrack registered at 30.09.2019 15:47:59',4,0,0,0,'','','','','','',''),(5,'9004','Desctiption for Teletrack registered at 30.09.2019 15:48:21',5,0,0,0,'','','','','','','');
/*!40000 ALTER TABLE `configgprsmain` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configmain`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configmain` WRITE;
/*!40000 ALTER TABLE `configmain` DISABLE KEYS */;
INSERT INTO `configmain` VALUES (1,'mobitel','mca4',0,0,50,50,1,50,50,50,1,1,1,1,1,50),(2,'mobitel','mca4',0,0,50,50,2,50,50,50,2,2,2,2,2,50),(3,'mobitel','mca4',0,0,50,50,3,50,50,50,3,3,3,3,3,50),(4,'mobitel','mca4',0,0,50,50,4,50,50,50,4,4,4,4,4,50),(5,'mobitel','mca4',0,0,50,50,5,50,50,50,5,5,5,5,5,50);
/*!40000 ALTER TABLE `configmain` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configother`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configother` WRITE;
/*!40000 ALTER TABLE `configother` DISABLE KEYS */;
/*!40000 ALTER TABLE `configother` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configsensorset`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configsensorset` WRITE;
/*!40000 ALTER TABLE `configsensorset` DISABLE KEYS */;
/*!40000 ALTER TABLE `configsensorset` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configsms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configsms` WRITE;
/*!40000 ALTER TABLE `configsms` DISABLE KEYS */;
INSERT INTO `configsms` VALUES (1,'2538','Desctiption for Teletrack registered at 30.09.2019 15:46:04',0,0,0,0,0,0,NULL,NULL),(2,'6091','Desctiption for Teletrack registered at 30.09.2019 15:46:48',2,0,0,0,0,0,NULL,NULL),(3,'8865','Desctiption for Teletrack registered at 30.09.2019 15:47:12',3,0,0,0,0,0,NULL,NULL),(4,'6079','Desctiption for Teletrack registered at 30.09.2019 15:47:59',4,0,0,0,0,0,NULL,NULL),(5,'9004','Desctiption for Teletrack registered at 30.09.2019 15:48:21',5,0,0,0,0,0,NULL,NULL);
/*!40000 ALTER TABLE `configsms` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configtel`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configtel` WRITE;
/*!40000 ALTER TABLE `configtel` DISABLE KEYS */;
INSERT INTO `configtel` VALUES (1,'2538','Desctiption for Teletrack registered at 30.09.2019 15:46:04',0,0,0,0,0,0,0,0,0),(2,'6091','Desctiption for Teletrack registered at 30.09.2019 15:46:48',2,0,0,0,0,0,0,0,0),(3,'8865','Desctiption for Teletrack registered at 30.09.2019 15:47:12',3,0,0,0,0,0,0,0,0),(4,'6079','Desctiption for Teletrack registered at 30.09.2019 15:47:59',4,0,0,0,0,0,0,0,0),(5,'9004','Desctiption for Teletrack registered at 30.09.2019 15:48:21',5,0,0,0,0,0,0,0,0);
/*!40000 ALTER TABLE `configtel` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configunique`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configunique` WRITE;
/*!40000 ALTER TABLE `configunique` DISABLE KEYS */;
/*!40000 ALTER TABLE `configunique` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configzoneset`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `configzoneset` WRITE;
/*!40000 ALTER TABLE `configzoneset` DISABLE KEYS */;
/*!40000 ALTER TABLE `configzoneset` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `data_zones`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `data_zones` WRITE;
/*!40000 ALTER TABLE `data_zones` DISABLE KEYS */;
/*!40000 ALTER TABLE `data_zones` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagps`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagps` WRITE;
/*!40000 ALTER TABLE `datagps` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagps` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagps64`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagps64` WRITE;
/*!40000 ALTER TABLE `datagps64` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagps64` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpsbuffer`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpsbuffer` WRITE;
/*!40000 ALTER TABLE `datagpsbuffer` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpsbuffer` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpsbuffer_dr`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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-ам от телетреков';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpsbuffer_dr` WRITE;
/*!40000 ALTER TABLE `datagpsbuffer_dr` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpsbuffer_dr` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpsbuffer_on`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Буфер онлайн данных';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpsbuffer_on` WRITE;
/*!40000 ALTER TABLE `datagpsbuffer_on` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpsbuffer_on` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpsbuffer_on64`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpsbuffer_on64` WRITE;
/*!40000 ALTER TABLE `datagpsbuffer_on64` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpsbuffer_on64` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpsbuffer_ontmp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Временный вспомогательный буфер онлайн данных';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpsbuffer_ontmp` WRITE;
/*!40000 ALTER TABLE `datagpsbuffer_ontmp` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpsbuffer_ontmp` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpsbuffer_ontmp64`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpsbuffer_ontmp64` WRITE;
/*!40000 ALTER TABLE `datagpsbuffer_ontmp64` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpsbuffer_ontmp64` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpsbuffer_pop`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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 протоколу';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpsbuffer_pop` WRITE;
/*!40000 ALTER TABLE `datagpsbuffer_pop` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpsbuffer_pop` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpsbufferlite`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpsbufferlite` WRITE;
/*!40000 ALTER TABLE `datagpsbufferlite` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpsbufferlite` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpslost`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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-модемов';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpslost` WRITE;
/*!40000 ALTER TABLE `datagpslost` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpslost` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpslost_on`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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 сервера';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpslost_on` WRITE;
/*!40000 ALTER TABLE `datagpslost_on` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpslost_on` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpslost_ontmp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `datagpslost_ontmp` (
  `LogID` int(11) NOT NULL DEFAULT '0',
  `SrvPacketID` bigint(20) NOT NULL
) ENGINE=MEMORY DEFAULT CHARSET=cp1251 COMMENT='Используется исключительно процедурой OnLostDataGPS';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpslost_ontmp` WRITE;
/*!40000 ALTER TABLE `datagpslost_ontmp` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpslost_ontmp` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpslost_rftmp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `datagpslost_rftmp` (
  `LogID` int(11) DEFAULT '0'
) ENGINE=MEMORY DEFAULT CHARSET=cp1251 COMMENT='Используется исключительно процедурой LostDataGPS';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpslost_rftmp` WRITE;
/*!40000 ALTER TABLE `datagpslost_rftmp` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpslost_rftmp` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `datagpslosted`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `datagpslosted` WRITE;
/*!40000 ALTER TABLE `datagpslosted` DISABLE KEYS */;
/*!40000 ALTER TABLE `datagpslosted` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Temporary view structure for view `datavalue1`
--

DROP TABLE IF EXISTS `datavalue1`;
/*!50001 DROP VIEW IF EXISTS `datavalue1`*/;
SET @saved_cs_client     = @@character_set_client;
/*!50503 SET character_set_client = utf8mb4 */;
/*!50001 CREATE VIEW `datavalue1` AS SELECT 
 1 AS `lon`,
 1 AS `lat`,
 1 AS `Mobitel_ID`,
 1 AS `Value`,
 1 AS `speed`,
 1 AS `time`,
 1 AS `sensor_id`,
 1 AS `datavalue_id`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary view structure for view `dataview`
--

DROP TABLE IF EXISTS `dataview`;
/*!50001 DROP VIEW IF EXISTS `dataview`*/;
SET @saved_cs_client     = @@character_set_client;
/*!50503 SET character_set_client = utf8mb4 */;
/*!50001 CREATE VIEW `dataview` AS SELECT 
 1 AS `DataGps_ID`,
 1 AS `Mobitel_ID`,
 1 AS `Lat`,
 1 AS `Lon`,
 1 AS `Altitude`,
 1 AS `time`,
 1 AS `speed`,
 1 AS `direction`,
 1 AS `Valid`,
 1 AS `sensor`,
 1 AS `Events`,
 1 AS `LogID`*/;
SET character_set_client = @saved_cs_client;

--
-- Temporary view structure for view `deviceview`
--

DROP TABLE IF EXISTS `deviceview`;
/*!50001 DROP VIEW IF EXISTS `deviceview`*/;
SET @saved_cs_client     = @@character_set_client;
/*!50503 SET character_set_client = utf8mb4 */;
/*!50001 CREATE VIEW `deviceview` AS SELECT 
 1 AS `Mobitel_ID`,
 1 AS `Name`,
 1 AS `Descr`,
 1 AS `devIdShort`,
 1 AS `DeviceType`,
 1 AS `ConfirmedID`,
 1 AS `moduleIdRf`*/;
SET character_set_client = @saved_cs_client;

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

DROP TABLE IF EXISTS `driver`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `driver` WRITE;
/*!40000 ALTER TABLE `driver` DISABLE KEYS */;
INSERT INTO `driver` VALUES (1,'','','2009-01-01','с','1111',NULL,NULL,NULL,0,'',NULL),(2,'Водитель','','2009-01-22','с','1111',NULL,NULL,NULL,0,'',NULL);
/*!40000 ALTER TABLE `driver` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `driver_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `driver_types` WRITE;
/*!40000 ALTER TABLE `driver_types` DISABLE KEYS */;
/*!40000 ALTER TABLE `driver_types` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `gpsmasks`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `gpsmasks` WRITE;
/*!40000 ALTER TABLE `gpsmasks` DISABLE KEYS */;
/*!40000 ALTER TABLE `gpsmasks` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `internalmobitelconfig`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `internalmobitelconfig` WRITE;
/*!40000 ALTER TABLE `internalmobitelconfig` DISABLE KEYS */;
INSERT INTO `internalmobitelconfig` VALUES (1,'','',1,0,'0','2538','0','0','0','0','0',0,0,'0','0'),(2,'','',2,0,'0','6091','0','0','0','0','0',0,0,'0','0'),(3,'','',3,0,'0','8865','0','0','0','0','0',0,0,'0','0'),(4,'','',4,0,'0','6079','0','0','0','0','0',0,0,'0','0'),(5,'','',5,0,'0','9004','0','0','0','0','0',0,0,'0','0');
/*!40000 ALTER TABLE `internalmobitelconfig` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Temporary view structure for view `internalmobitelconfigview`
--

DROP TABLE IF EXISTS `internalmobitelconfigview`;
/*!50001 DROP VIEW IF EXISTS `internalmobitelconfigview`*/;
SET @saved_cs_client     = @@character_set_client;
/*!50503 SET character_set_client = utf8mb4 */;
/*!50001 CREATE VIEW `internalmobitelconfigview` AS SELECT 
 1 AS `ID`,
 1 AS `LastRecord`*/;
SET character_set_client = @saved_cs_client;

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

DROP TABLE IF EXISTS `lastmeters`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `lastmeters` WRITE;
/*!40000 ALTER TABLE `lastmeters` DISABLE KEYS */;
INSERT INTO `lastmeters` VALUES (200,2,'200 метров',NULL),(1000,3,'1 километр',NULL),(5000,4,'5 километров',NULL),(25000,5,'25 километров',NULL),(100000,6,'100 километров',NULL);
/*!40000 ALTER TABLE `lastmeters` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `lastrecords`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `lastrecords` WRITE;
/*!40000 ALTER TABLE `lastrecords` DISABLE KEYS */;
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 записей');
/*!40000 ALTER TABLE `lastrecords` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `lasttimes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `lasttimes` WRITE;
/*!40000 ALTER TABLE `lasttimes` DISABLE KEYS */;
INSERT INTO `lasttimes` VALUES (5,1,'5 минут',NULL),(20,2,'20 минут',NULL),(120,3,'2 часа',NULL),(360,4,'6 часов',NULL),(1440,5,'сутки',NULL);
/*!40000 ALTER TABLE `lasttimes` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `lines`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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 DEFAULT CHARSET=cp1251 COMMENT='Описание линии';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `lines` WRITE;
/*!40000 ALTER TABLE `lines` DISABLE KEYS */;
/*!40000 ALTER TABLE `lines` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `mapstyleglobal`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `mapstyleglobal` WRITE;
/*!40000 ALTER TABLE `mapstyleglobal` DISABLE KEYS */;
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);
/*!40000 ALTER TABLE `mapstyleglobal` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `mapstylelines`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `mapstylelines` WRITE;
/*!40000 ALTER TABLE `mapstylelines` DISABLE KEYS */;
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);
/*!40000 ALTER TABLE `mapstylelines` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `mapstylepoints`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `mapstylepoints` WRITE;
/*!40000 ALTER TABLE `mapstylepoints` DISABLE KEYS */;
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);
/*!40000 ALTER TABLE `mapstylepoints` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `messages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `messages` WRITE;
/*!40000 ALTER TABLE `messages` DISABLE KEYS */;
/*!40000 ALTER TABLE `messages` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `mobitels`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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=6 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `mobitels` WRITE;
/*!40000 ALTER TABLE `mobitels` DISABLE KEYS */;
INSERT INTO `mobitels` VALUES (1,'2538','Desctiption for Teletrack registered at 30.09.2019 15:46:04',0,0,0,1,1,6,5,5,0,0,0,0,1569849618,0,0),(2,'6091','Desctiption for Teletrack registered at 30.09.2019 15:46:48',0,0,0,3,2,6,5,5,0,0,0,0,1569849667,0,0),(3,'8865','Desctiption for Teletrack registered at 30.09.2019 15:47:12',0,0,0,5,3,6,5,5,0,0,0,0,1569849562,0,0),(4,'6079','Desctiption for Teletrack registered at 30.09.2019 15:47:59',0,0,0,7,4,6,5,5,0,0,0,0,1569849602,0,0),(5,'9004','Desctiption for Teletrack registered at 30.09.2019 15:48:21',0,0,0,9,5,6,5,5,0,0,0,0,1569849619,0,0);
/*!40000 ALTER TABLE `mobitels` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `mobitels_info`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `mobitels_info` WRITE;
/*!40000 ALTER TABLE `mobitels_info` DISABLE KEYS */;
/*!40000 ALTER TABLE `mobitels_info` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `mobitels_rotate_bands`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `mobitels_rotate_bands` WRITE;
/*!40000 ALTER TABLE `mobitels_rotate_bands` DISABLE KEYS */;
/*!40000 ALTER TABLE `mobitels_rotate_bands` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `ntf_emails`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `ntf_emails` WRITE;
/*!40000 ALTER TABLE `ntf_emails` DISABLE KEYS */;
/*!40000 ALTER TABLE `ntf_emails` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `ntf_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `ntf_events` WRITE;
/*!40000 ALTER TABLE `ntf_events` DISABLE KEYS */;
/*!40000 ALTER TABLE `ntf_events` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `ntf_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `ntf_log` WRITE;
/*!40000 ALTER TABLE `ntf_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `ntf_log` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `ntf_main`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `ntf_main` WRITE;
/*!40000 ALTER TABLE `ntf_main` DISABLE KEYS */;
/*!40000 ALTER TABLE `ntf_main` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `ntf_mobitels`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `ntf_mobitels` WRITE;
/*!40000 ALTER TABLE `ntf_mobitels` DISABLE KEYS */;
/*!40000 ALTER TABLE `ntf_mobitels` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `ntf_popupusers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `ntf_popupusers` WRITE;
/*!40000 ALTER TABLE `ntf_popupusers` DISABLE KEYS */;
/*!40000 ALTER TABLE `ntf_popupusers` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `online`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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=3018 DEFAULT CHARSET=cp1251 COMMENT='Оперативные данные';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `online` WRITE;
/*!40000 ALTER TABLE `online` DISABLE KEYS */;
INSERT INTO `online` VALUES (6,4,0,30360606,15770922,235,1569844082,0,0,1,7211,0,0,0,0,214,0,0,0,0,7211,0,1023,-1,-1,-1,-1),(8,1,0,30360864,15770772,231,1569844132,0,0,1,7143,0,0,0,0,218,0,0,0,0,7143,0,1023,-1,-1,-1,-1),(17,4,0,30360606,15770922,235,1569844142,0,0,1,7212,0,0,0,0,214,0,0,0,0,7212,0,1023,-1,-1,-1,-1),(21,1,0,30360864,15770772,231,1569844192,0,0,1,7144,0,0,0,0,218,0,0,0,0,7144,0,1023,-1,-1,-1,-1),(24,4,0,30360606,15770922,235,1569844202,0,0,1,7213,0,0,0,0,214,0,0,0,0,7213,0,1023,-1,-1,-1,-1),(34,1,0,30360864,15770772,231,1569844252,0,0,1,7145,0,0,0,0,218,0,0,0,0,7145,0,1023,-1,-1,-1,-1),(37,4,0,30360606,15770922,235,1569844262,0,0,1,7214,0,0,0,0,214,0,0,0,0,7214,0,1023,-1,-1,-1,-1),(46,1,0,30360864,15770772,231,1569844312,0,0,1,7146,0,0,0,0,218,0,0,0,0,7146,0,1023,-1,-1,-1,-1),(49,4,0,30360606,15770922,235,1569844322,0,0,1,7215,0,0,0,0,214,0,0,0,0,7215,0,1023,-1,-1,-1,-1),(55,1,0,30360864,15770772,231,1569844372,0,0,1,7147,0,0,0,0,218,0,0,0,0,7147,0,1023,-1,-1,-1,-1),(58,4,0,30360606,15770922,235,1569844382,0,0,1,7216,0,0,0,0,214,0,0,0,0,7216,0,1023,-1,-1,-1,-1),(67,1,0,30360864,15770772,231,1569844432,0,0,1,7148,0,0,0,0,218,0,0,0,0,7148,0,1023,-1,-1,-1,-1),(70,4,0,30360606,15770922,235,1569844442,0,0,1,7217,0,0,0,0,214,0,0,0,0,7217,0,1023,-1,-1,-1,-1),(82,1,0,30360864,15770772,231,1569844492,0,0,1,7149,0,0,0,0,218,0,0,0,0,7149,0,1023,-1,-1,-1,-1),(89,4,0,30360606,15770922,235,1569844502,0,0,1,7218,0,0,0,0,214,0,0,0,0,7218,0,1023,-1,-1,-1,-1),(90,1,0,30360864,15770772,231,1569844552,0,0,1,7150,0,0,0,0,218,0,0,0,0,7150,0,1023,-1,-1,-1,-1),(93,4,0,30360606,15770922,235,1569844562,0,0,1,7219,0,0,0,0,214,0,0,0,0,7219,0,1023,-1,-1,-1,-1),(95,1,0,30360864,15770772,231,1569844612,0,0,1,7151,0,0,0,0,218,0,0,0,0,7151,0,1023,-1,-1,-1,-1),(99,4,0,30360606,15770922,235,1569844622,0,0,1,7220,0,0,0,0,214,0,0,0,0,7220,0,1023,-1,-1,-1,-1),(100,1,0,30360864,15770772,231,1569844672,0,0,1,7152,0,0,0,0,218,0,0,0,0,7152,0,1023,-1,-1,-1,-1),(104,4,0,30360606,15770922,235,1569844682,0,0,1,7221,0,0,0,0,214,0,0,0,0,7221,0,1023,-1,-1,-1,-1),(105,1,0,30360864,15770772,231,1569844732,0,0,1,7153,0,0,0,0,218,0,0,0,0,7153,0,1023,-1,-1,-1,-1),(109,4,0,30360606,15770922,235,1569844742,0,0,1,7222,0,0,0,0,214,0,0,0,0,7222,0,1023,-1,-1,-1,-1),(111,1,0,30360864,15770772,231,1569844792,0,0,1,7154,0,0,0,0,218,0,0,0,0,7154,0,1023,-1,-1,-1,-1),(127,4,0,30360606,15770922,235,1569844802,0,0,1,7223,0,0,0,0,214,0,0,0,0,7223,0,1023,-1,-1,-1,-1),(128,1,0,30360864,15770772,231,1569844852,0,0,1,7155,0,0,0,0,218,0,0,0,0,7155,0,1023,-1,-1,-1,-1),(132,4,0,30360606,15770922,235,1569844862,0,0,1,7224,0,0,0,0,214,0,0,0,0,7224,0,1023,-1,-1,-1,-1),(133,1,0,30360864,15770772,231,1569844912,0,0,1,7156,0,0,0,0,218,0,0,0,0,7156,0,1023,-1,-1,-1,-1),(137,4,0,30360606,15770922,235,1569844922,0,0,1,7225,0,0,0,0,214,0,0,0,0,7225,0,1023,-1,-1,-1,-1),(138,1,0,30360864,15770772,231,1569844972,0,0,1,7157,0,0,0,0,218,0,0,0,0,7157,0,1023,-1,-1,-1,-1),(149,4,0,30360606,15770922,235,1569844982,0,0,1,7226,0,0,0,0,214,0,0,0,0,7226,0,1023,-1,-1,-1,-1),(150,1,0,30360864,15770772,231,1569845032,0,0,1,7158,0,0,0,0,218,0,0,0,0,7158,0,1023,-1,-1,-1,-1),(161,4,0,30360606,15770922,235,1569845042,0,0,1,7227,0,0,0,0,214,0,0,0,0,7227,0,1023,-1,-1,-1,-1),(162,1,0,30360864,15770772,231,1569845092,0,0,1,7159,0,0,0,0,218,0,0,0,0,7159,0,1023,-1,-1,-1,-1),(171,4,0,30360606,15770922,235,1569845102,0,0,1,7228,0,0,0,0,214,0,0,0,0,7228,0,1023,-1,-1,-1,-1),(172,1,0,30360864,15770772,231,1569845152,0,0,1,7160,0,0,0,0,217,0,0,0,0,7160,0,1023,-1,-1,-1,-1),(187,4,0,30360606,15770922,235,1569845162,0,0,1,7229,0,0,0,0,214,0,0,0,0,7229,0,1023,-1,-1,-1,-1),(188,1,0,30360864,15770772,231,1569845212,0,0,1,7161,0,0,0,0,217,0,0,0,0,7161,0,1023,-1,-1,-1,-1),(201,4,0,30360606,15770922,235,1569845222,0,0,1,7230,0,0,0,0,214,0,0,0,0,7230,0,1023,-1,-1,-1,-1),(202,1,0,30360864,15770772,231,1569845272,0,0,1,7162,0,0,0,0,217,0,0,0,0,7162,0,1023,-1,-1,-1,-1),(211,4,0,30360606,15770922,235,1569845282,0,0,1,7231,0,0,0,0,214,0,0,0,0,7231,0,1023,-1,-1,-1,-1),(212,1,0,30360864,15770772,231,1569845332,0,0,1,7163,0,0,0,0,217,0,0,0,0,7163,0,1023,-1,-1,-1,-1),(217,4,0,30360606,15770922,235,1569845342,0,0,1,7232,0,0,0,0,214,0,0,0,0,7232,0,1023,-1,-1,-1,-1),(218,1,0,30360864,15770772,231,1569845392,0,0,1,7164,0,0,0,0,217,0,0,0,0,7164,0,1023,-1,-1,-1,-1),(233,4,0,30360606,15770922,235,1569845402,0,0,1,7233,0,0,0,0,214,0,0,0,0,7233,0,1023,-1,-1,-1,-1),(234,1,0,30360864,15770772,231,1569845452,0,0,1,7165,0,0,0,0,217,0,0,0,0,7165,0,1023,-1,-1,-1,-1),(248,4,0,30360606,15770922,235,1569845462,0,0,1,7234,0,0,0,0,214,0,0,0,0,7234,0,1023,-1,-1,-1,-1),(249,1,0,30360864,15770772,231,1569845512,0,0,1,7166,0,0,0,0,217,0,0,0,0,7166,0,1023,-1,-1,-1,-1),(254,4,0,30360606,15770922,235,1569845522,0,0,1,7235,0,0,0,0,214,0,0,0,0,7235,0,1023,-1,-1,-1,-1),(255,1,0,30360864,15770772,231,1569845572,0,0,1,7167,0,0,0,0,217,0,0,0,0,7167,0,1023,-1,-1,-1,-1),(263,4,0,30360606,15770922,235,1569845582,0,0,1,7236,0,0,0,0,214,0,0,0,0,7236,0,1023,-1,-1,-1,-1),(264,1,0,30360864,15770772,231,1569845632,0,0,1,7168,0,0,0,0,217,0,0,0,0,7168,0,1023,-1,-1,-1,-1),(269,4,0,30360606,15770922,235,1569845642,0,0,1,7237,0,0,0,0,214,0,0,0,0,7237,0,1023,-1,-1,-1,-1),(270,1,0,30360864,15770772,231,1569845692,0,0,1,7169,0,0,0,0,217,0,0,0,0,7169,0,1023,-1,-1,-1,-1),(282,4,0,30360606,15770922,235,1569845702,0,0,1,7238,0,0,0,0,214,0,0,0,0,7238,0,1023,-1,-1,-1,-1),(283,1,0,30360864,15770772,231,1569845752,0,0,1,7170,0,0,0,0,217,0,0,0,0,7170,0,1023,-1,-1,-1,-1),(297,4,0,30360606,15770922,235,1569845762,0,0,1,7239,0,0,0,0,214,0,0,0,0,7239,0,1023,-1,-1,-1,-1),(298,1,0,30360864,15770772,231,1569845812,0,0,1,7171,0,0,0,0,217,0,0,0,0,7171,0,1023,-1,-1,-1,-1),(306,4,0,30360606,15770922,235,1569845822,0,0,1,7240,0,0,0,0,214,0,0,0,0,7240,0,1023,-1,-1,-1,-1),(307,1,0,30360864,15770772,231,1569845872,0,0,1,7172,0,0,0,0,217,0,0,0,0,7172,0,1023,-1,-1,-1,-1),(312,4,0,30360606,15770922,235,1569845882,0,0,1,7241,0,0,0,0,214,0,0,0,0,7241,0,1023,-1,-1,-1,-1),(313,1,0,30360864,15770772,231,1569845932,0,0,1,7173,0,0,0,0,217,0,0,0,0,7173,0,1023,-1,-1,-1,-1),(327,4,0,30360606,15770922,235,1569845942,0,0,1,7242,0,0,0,0,214,0,0,0,0,7242,0,1023,-1,-1,-1,-1),(328,1,0,30360864,15770772,231,1569845992,0,0,1,7174,0,0,0,0,217,0,0,0,0,7174,0,1023,-1,-1,-1,-1),(337,4,0,30360606,15770922,235,1569846002,0,0,1,7243,0,0,0,0,214,0,0,0,0,7243,0,1023,-1,-1,-1,-1),(338,1,0,30360864,15770772,231,1569846052,0,0,1,7175,0,0,0,0,217,0,0,0,0,7175,0,1023,-1,-1,-1,-1),(353,4,0,30360606,15770922,235,1569846062,0,0,1,7244,0,0,0,0,214,0,0,0,0,7244,0,1023,-1,-1,-1,-1),(354,1,0,30360864,15770772,231,1569846112,0,0,1,7176,0,0,0,0,217,0,0,0,0,7176,0,1023,-1,-1,-1,-1),(365,4,0,30360606,15770922,235,1569846122,0,0,1,7245,0,0,0,0,214,0,0,0,0,7245,0,1023,-1,-1,-1,-1),(366,1,0,30360864,15770772,231,1569846172,0,0,1,7177,0,0,0,0,217,0,0,0,0,7177,0,1023,-1,-1,-1,-1),(377,4,0,30360606,15770922,235,1569846182,0,0,1,7246,0,0,0,0,214,0,0,0,0,7246,0,1023,-1,-1,-1,-1),(378,1,0,30360864,15770772,231,1569846232,0,0,1,7178,0,0,0,0,217,0,0,0,0,7178,0,1023,-1,-1,-1,-1),(393,4,0,30360606,15770922,235,1569846242,0,0,1,7247,0,0,0,0,214,0,0,0,0,7247,0,1023,-1,-1,-1,-1),(394,1,0,30360864,15770772,231,1569846292,0,0,1,7179,0,0,0,0,217,0,0,0,0,7179,0,1023,-1,-1,-1,-1),(413,4,0,30360606,15770922,235,1569846302,0,0,1,7248,0,0,0,0,214,0,0,0,0,7248,0,1023,-1,-1,-1,-1),(414,1,0,30360864,15770772,231,1569846352,0,0,1,7180,0,0,0,0,217,0,0,0,0,7180,0,1023,-1,-1,-1,-1),(435,4,0,30360606,15770922,235,1569846362,0,0,1,7249,0,0,0,0,214,0,0,0,0,7249,0,1023,-1,-1,-1,-1),(440,1,0,30360864,15770772,231,1569846412,0,0,1,7181,0,0,0,0,217,0,0,0,0,7181,0,1023,-1,-1,-1,-1),(447,4,0,30360606,15770922,235,1569846422,0,0,1,7250,0,0,0,0,214,0,0,0,0,7250,0,1023,-1,-1,-1,-1),(449,1,0,30360864,15770772,231,1569846472,0,0,1,7182,0,0,0,0,217,0,0,0,0,7182,0,1023,-1,-1,-1,-1),(456,4,0,30360606,15770922,235,1569846482,0,0,1,7251,0,0,0,0,214,0,0,0,0,7251,0,1023,-1,-1,-1,-1),(458,1,0,30360864,15770772,231,1569846532,0,0,1,7183,0,0,0,0,217,0,0,0,0,7183,0,1023,-1,-1,-1,-1),(462,4,0,30360606,15770922,235,1569846542,0,0,1,7252,0,0,0,0,214,0,0,0,0,7252,0,1023,-1,-1,-1,-1),(464,1,0,30360864,15770772,231,1569846592,0,0,1,7184,0,0,0,0,217,0,0,0,0,7184,0,1023,-1,-1,-1,-1),(478,4,0,30360606,15770922,235,1569846602,0,0,1,7253,0,0,0,0,214,0,0,0,0,7253,0,1023,-1,-1,-1,-1),(480,1,0,30360864,15770772,231,1569846652,0,0,1,7185,0,0,0,0,217,0,0,0,0,7185,0,1023,-1,-1,-1,-1),(492,4,0,30360606,15770922,235,1569846662,0,0,1,7254,0,0,0,0,214,0,0,0,0,7254,0,1023,-1,-1,-1,-1),(494,1,0,30360864,15770772,231,1569846712,0,0,1,7186,0,0,0,0,217,0,0,0,0,7186,0,1023,-1,-1,-1,-1),(507,4,0,30360606,15770922,235,1569846722,0,0,1,7255,0,0,0,0,214,0,0,0,0,7255,0,1023,-1,-1,-1,-1),(509,1,0,30360864,15770772,231,1569846772,0,0,1,7187,0,0,0,0,217,0,0,0,0,7187,0,1023,-1,-1,-1,-1),(534,4,0,30360606,15770922,235,1569846782,0,0,1,7256,0,0,0,0,214,0,0,0,0,7256,0,1023,-1,-1,-1,-1),(537,1,0,30360864,15770772,231,1569846832,0,0,1,7188,0,0,0,0,217,0,0,0,0,7188,0,1023,-1,-1,-1,-1),(548,4,0,30360606,15770922,235,1569846842,0,0,1,7257,0,0,0,0,214,0,0,0,0,7257,0,1023,-1,-1,-1,-1),(549,1,0,30360864,15770772,231,1569846892,0,0,1,7189,0,0,0,0,217,0,0,0,0,7189,0,1023,-1,-1,-1,-1),(552,4,0,30360606,15770922,235,1569846902,0,0,1,7258,0,0,0,0,214,0,0,0,0,7258,0,1023,-1,-1,-1,-1),(567,1,0,30360864,15770772,231,1569846952,0,0,1,7190,0,0,0,0,217,0,0,0,0,7190,0,1023,-1,-1,-1,-1),(571,4,0,30360606,15770922,235,1569846962,0,0,1,7259,0,0,0,0,214,0,0,0,0,7259,0,1023,-1,-1,-1,-1),(573,1,0,30360864,15770772,231,1569847012,0,0,1,7191,0,0,0,0,217,0,0,0,0,7191,0,1023,-1,-1,-1,-1),(576,5,0,30331452,15807822,249,1569847004,31,217,1,8464,0,32,0,0,120,0,0,0,0,8464,0,1023,-1,-1,-1,-1),(577,5,0,30333888,15805542,249,1569847039,29,219,1,8465,0,32,0,0,120,0,0,0,0,8465,0,1023,-1,-1,-1,-1),(578,4,0,30360606,15770922,235,1569847022,0,0,1,7260,0,0,0,0,214,0,0,0,0,7260,0,1023,-1,-1,-1,-1),(580,1,0,30360864,15770772,231,1569847072,0,0,1,7192,0,0,0,0,217,0,0,0,0,7192,0,1023,-1,-1,-1,-1),(582,5,0,30335274,15804366,250,1569847058,29,223,1,8466,0,32,0,0,120,0,0,0,0,8466,0,1023,-1,-1,-1,-1),(583,5,0,30336978,15803154,247,1569847084,21,218,1,8467,0,32,0,0,121,0,0,0,0,8467,0,1023,-1,-1,-1,-1),(584,5,0,30337260,15802824,245,1569847090,21,214,1,8468,0,32,0,0,121,0,0,0,0,8468,0,1023,-1,-1,-1,-1),(585,5,0,30337428,15802584,244,1569847094,20,210,1,8469,0,32,0,0,120,0,0,0,0,8469,0,1023,-1,-1,-1,-1),(586,5,0,30337500,15802440,244,1569847096,20,205,1,8470,0,32,0,0,121,0,0,0,0,8470,0,1023,-1,-1,-1,-1),(587,4,0,30360606,15770922,235,1569847082,0,0,1,7261,0,0,0,0,214,0,0,0,0,7261,0,1023,-1,-1,-1,-1),(589,1,0,30360864,15770772,231,1569847132,0,0,1,7193,0,0,0,0,217,0,0,0,0,7193,0,1023,-1,-1,-1,-1),(590,1,0,30360864,15770772,231,1569847144,0,0,1,7194,0,32,0,0,216,0,0,0,0,7194,0,1023,-1,-1,-1,-1),(604,1,0,30360864,15770772,231,1569847158,0,0,1,7195,0,0,0,0,216,0,0,0,0,7195,0,1023,-1,-1,-1,-1),(605,5,0,30337800,15801792,241,1569847156,0,0,1,8471,0,32,0,0,103,0,0,0,0,8471,0,1023,-1,-1,-1,-1),(606,4,0,30360606,15770922,235,1569847142,0,0,1,7262,0,0,0,0,214,0,0,0,0,7262,0,1023,-1,-1,-1,-1),(621,1,0,30360864,15770772,231,1569847218,0,0,1,7196,0,0,0,0,217,0,0,0,0,7196,0,1023,-1,-1,-1,-1),(622,5,0,30337800,15801774,241,1569847201,2,197,1,8472,0,32,0,0,120,0,0,0,0,8472,0,1023,-1,-1,-1,-1),(623,5,0,30337842,15801666,240,1569847207,6,201,1,8473,0,32,0,0,120,0,0,0,0,8473,0,1023,-1,-1,-1,-1),(624,4,0,30360606,15770922,235,1569847202,0,0,1,7263,0,0,0,0,214,0,0,0,0,7263,0,1023,-1,-1,-1,-1),(636,1,0,30360864,15770772,231,1569847278,0,0,1,7197,0,0,0,0,217,0,0,0,0,7197,0,1023,-1,-1,-1,-1),(637,5,0,30339390,15797880,221,1569847257,25,201,1,8474,0,32,0,0,120,0,0,0,0,8474,0,1023,-1,-1,-1,-1),(638,5,0,30340080,15796290,218,1569847275,23,205,1,8475,0,32,0,0,120,0,0,0,0,8475,0,1023,-1,-1,-1,-1),(639,5,0,30340170,15796140,218,1569847277,23,210,1,8476,0,32,0,0,120,0,0,0,0,8476,0,1023,-1,-1,-1,-1),(640,5,0,30340260,15796008,217,1569847279,22,214,1,8477,0,32,0,0,120,0,0,0,0,8477,0,1023,-1,-1,-1,-1),(641,5,0,30340362,15795912,218,1569847281,21,218,1,8478,0,32,0,0,114,0,0,0,0,8478,0,1023,-1,-1,-1,-1),(642,4,0,30360606,15770922,235,1569847262,0,0,1,7264,0,0,0,0,214,0,0,0,0,7264,0,1023,-1,-1,-1,-1),(643,5,0,30340554,15795744,218,1569847285,21,223,1,8479,0,32,0,0,120,0,0,0,0,8479,0,1023,-1,-1,-1,-1),(644,5,0,30340890,15795546,215,1569847291,21,227,1,8480,0,32,0,0,120,0,0,0,0,8480,0,1023,-1,-1,-1,-1),(645,5,0,30341460,15795234,211,1569847301,23,227,1,8481,0,0,0,0,114,0,0,0,0,8481,0,1023,-1,-1,-1,-1),(647,5,0,30343188,15794334,200,1569847326,28,227,1,8482,0,32,0,0,113,0,0,0,0,8482,0,1023,-1,-1,-1,-1),(661,1,0,30360864,15770772,231,1569847338,0,0,1,7198,0,0,0,0,217,0,0,0,0,7198,0,1023,-1,-1,-1,-1),(664,4,0,30360606,15770922,235,1569847322,0,0,1,7265,0,0,0,0,214,0,0,0,0,7265,0,1023,-1,-1,-1,-1),(665,5,0,30344352,15793686,197,1569847342,27,222,1,8483,0,32,0,0,120,0,0,0,0,8483,0,1023,-1,-1,-1,-1),(666,5,0,30344532,15793506,197,1569847345,26,217,1,8484,0,32,0,0,120,0,0,0,0,8484,0,1023,-1,-1,-1,-1),(667,5,0,30344706,15793278,195,1569847348,27,212,1,8485,0,32,0,0,120,0,0,0,0,8485,0,1023,-1,-1,-1,-1),(668,5,0,30345060,15792828,192,1569847354,26,217,1,8486,0,32,0,0,120,0,0,0,0,8486,0,1023,-1,-1,-1,-1),(669,5,0,30345192,15792720,192,1569847356,26,225,1,8487,0,32,0,0,120,0,0,0,0,8487,0,1023,-1,-1,-1,-1),(670,5,0,30345264,15792690,190,1569847357,26,229,1,8488,0,32,0,0,120,0,0,0,0,8488,0,1023,-1,-1,-1,-1),(671,5,0,30345342,15792684,191,1569847358,26,234,1,8489,0,32,0,0,120,0,0,0,0,8489,0,1023,-1,-1,-1,-1),(672,5,0,30345486,15792672,190,1569847360,26,238,1,8490,0,32,0,0,120,0,0,0,0,8490,0,1023,-1,-1,-1,-1),(673,5,0,30346788,15792642,189,1569847379,23,5,1,8491,0,32,0,0,120,0,0,0,0,8491,0,1023,-1,-1,-1,-1),(674,5,0,30346908,15792678,189,1569847381,22,9,1,8492,0,32,0,0,120,0,0,0,0,8492,0,1023,-1,-1,-1,-1),(697,1,0,30360864,15770772,231,1569847398,0,0,1,7199,0,0,0,0,217,0,0,0,0,7199,0,1023,-1,-1,-1,-1),(700,4,0,30360606,15770922,235,1569847382,0,0,1,7266,0,0,0,0,214,0,0,0,0,7266,0,1023,-1,-1,-1,-1),(701,5,0,30347928,15793086,192,1569847396,26,5,1,8493,0,32,0,0,120,0,0,0,0,8493,0,1023,-1,-1,-1,-1),(702,5,0,30348150,15793152,195,1569847399,26,9,1,8494,0,32,0,0,120,0,0,0,0,8494,0,1023,-1,-1,-1,-1),(703,5,0,30349254,15793656,206,1569847416,18,3,1,8495,0,32,0,0,120,0,0,0,0,8495,0,1023,-1,-1,-1,-1),(704,5,0,30349308,15793656,206,1569847417,19,239,1,8496,0,32,0,0,120,0,0,0,0,8496,0,1023,-1,-1,-1,-1),(705,5,0,30350070,15793602,200,1569847431,18,235,1,8497,0,32,0,0,113,0,0,0,0,8497,0,1023,-1,-1,-1,-1),(706,5,0,30350166,15793566,199,1569847433,16,228,1,8498,0,32,0,0,113,0,0,0,0,8498,0,1023,-1,-1,-1,-1),(707,5,0,30350232,15793518,198,1569847435,11,223,1,8499,0,32,0,0,112,0,0,0,0,8499,0,1023,-1,-1,-1,-1),(726,1,0,30360864,15770772,231,1569847458,0,0,1,7200,0,0,0,0,217,0,0,0,0,7200,0,1023,-1,-1,-1,-1),(728,4,0,30360606,15770922,235,1569847442,0,0,1,7267,0,0,0,0,214,0,0,0,0,7267,0,1023,-1,-1,-1,-1),(729,5,0,30350298,15793458,197,1569847465,4,219,1,8500,0,32,0,0,120,0,0,0,0,8500,0,1023,-1,-1,-1,-1),(730,5,0,30350418,15793326,196,1569847470,15,215,1,8501,0,32,0,0,120,0,0,0,0,8501,0,1023,-1,-1,-1,-1),(731,5,0,30350532,15793164,195,1569847473,20,211,1,8502,0,32,0,0,120,0,0,0,0,8502,0,1023,-1,-1,-1,-1),(732,5,0,30351162,15792054,195,1569847486,27,207,1,8503,0,32,0,0,120,0,0,0,0,8503,0,1023,-1,-1,-1,-1),(743,1,0,30360864,15770772,231,1569847518,0,0,1,7201,0,0,0,0,217,0,0,0,0,7201,0,1023,-1,-1,-1,-1),(745,4,0,30360606,15770922,235,1569847502,0,0,1,7268,0,0,0,0,214,0,0,0,0,7268,0,1023,-1,-1,-1,-1),(746,5,0,30353052,15788706,211,1569847526,20,207,1,8504,0,32,0,0,120,0,0,0,0,8504,0,1023,-1,-1,-1,-1),(770,1,0,30360864,15770772,231,1569847578,0,0,1,7202,0,0,0,0,217,0,0,0,0,7202,0,1023,-1,-1,-1,-1),(788,4,0,30360606,15770922,235,1569847562,0,0,1,7269,0,0,0,0,214,0,0,0,0,7269,0,1023,-1,-1,-1,-1),(792,5,0,30354900,15785406,231,1569847568,31,207,1,8505,0,32,0,0,120,0,0,0,0,8505,0,1023,-1,-1,-1,-1),(793,5,0,30356772,15782094,234,1569847600,30,207,1,8506,0,32,0,0,120,0,0,0,0,8506,0,1023,-1,-1,-1,-1),(809,1,0,30360864,15770772,231,1569847638,0,0,1,7203,0,0,0,0,217,0,0,0,0,7203,0,1023,-1,-1,-1,-1),(815,4,0,30360606,15770922,235,1569847622,0,0,1,7270,0,0,0,0,214,0,0,0,0,7270,0,1023,-1,-1,-1,-1),(817,5,0,30358644,15778746,233,1569847633,31,206,1,8507,0,32,0,0,120,0,0,0,0,8507,0,1023,-1,-1,-1,-1),(818,5,0,30360324,15775722,230,1569847664,28,202,1,8508,0,32,0,0,120,0,0,0,0,8508,0,1023,-1,-1,-1,-1),(819,5,0,30360486,15775296,230,1569847668,28,197,1,8509,0,32,0,0,120,0,0,0,0,8509,0,1023,-1,-1,-1,-1),(820,5,0,30360600,15774822,229,1569847672,29,192,1,8510,0,32,0,0,120,0,0,0,0,8510,0,1023,-1,-1,-1,-1),(821,1,0,30360864,15770772,231,1569847698,0,0,1,7204,0,0,0,0,217,0,0,0,0,7204,0,1023,-1,-1,-1,-1),(823,4,0,30360606,15770922,235,1569847682,0,0,1,7271,0,0,0,0,214,0,0,0,0,7271,0,1023,-1,-1,-1,-1),(825,5,0,30361254,15771786,227,1569847702,8,185,1,8511,0,32,0,0,120,0,0,0,0,8511,0,1023,-1,-1,-1,-1),(826,5,0,30361248,15771750,227,1569847703,9,172,1,8512,0,32,0,0,120,0,0,0,0,8512,0,1023,-1,-1,-1,-1),(827,5,0,30361242,15771714,227,1569847704,10,163,1,8513,0,32,0,0,111,0,0,0,0,8513,0,1023,-1,-1,-1,-1),(828,5,0,30361224,15771678,227,1569847705,9,157,1,8514,0,32,0,0,120,0,0,0,0,8514,0,1023,-1,-1,-1,-1),(829,5,0,30361212,15771648,228,1569847706,8,144,1,8515,0,32,0,0,120,0,0,0,0,8515,0,1023,-1,-1,-1,-1),(830,5,0,30361188,15771630,228,1569847707,9,133,1,8516,0,32,0,0,120,0,0,0,0,8516,0,1023,-1,-1,-1,-1),(831,5,0,30361158,15771618,229,1569847708,10,127,1,8517,0,32,0,0,120,0,0,0,0,8517,0,1023,-1,-1,-1,-1),(832,5,0,30361134,15771612,229,1569847709,9,122,1,8518,0,32,0,0,120,0,0,0,0,8518,0,1023,-1,-1,-1,-1),(833,5,0,30361008,15771612,229,1569847715,6,129,1,8519,0,32,0,0,120,0,0,0,0,8519,0,1023,-1,-1,-1,-1),(834,5,0,30360972,15771600,229,1569847717,7,133,1,8520,0,32,0,0,120,0,0,0,0,8520,0,1023,-1,-1,-1,-1),(835,5,0,30360828,15771540,231,1569847724,4,137,1,8521,0,32,0,0,109,0,0,0,0,8521,0,1023,-1,-1,-1,-1),(836,5,0,30360738,15771444,233,1569847731,5,146,1,8522,0,32,0,0,120,0,0,0,0,8522,0,1023,-1,-1,-1,-1),(837,5,0,30360732,15771426,233,1569847732,5,151,1,8523,0,32,0,0,120,0,0,0,0,8523,0,1023,-1,-1,-1,-1),(838,5,0,30360720,15771402,234,1569847733,5,160,1,8524,0,32,0,0,120,0,0,0,0,8524,0,1023,-1,-1,-1,-1),(839,5,0,30360714,15771378,233,1569847734,5,165,1,8525,0,32,0,0,120,0,0,0,0,8525,0,1023,-1,-1,-1,-1),(840,5,0,30360714,15771354,232,1569847735,6,173,1,8526,0,32,0,0,120,0,0,0,0,8526,0,1023,-1,-1,-1,-1),(841,5,0,30360708,15771300,232,1569847737,5,180,1,8527,0,32,0,0,120,0,0,0,0,8527,0,1023,-1,-1,-1,-1),(842,5,0,30360708,15771276,232,1569847738,5,184,1,8528,0,32,0,0,120,0,0,0,0,8528,0,1023,-1,-1,-1,-1),(843,5,0,30360720,15771222,231,1569847740,6,190,1,8529,0,32,0,0,120,0,0,0,0,8529,0,1023,-1,-1,-1,-1),(844,5,0,30360732,15771138,231,1569847743,8,185,1,8530,0,32,0,0,120,0,0,0,0,8530,0,1023,-1,-1,-1,-1),(845,5,0,30360744,15771030,231,1569847746,8,190,1,8531,0,32,0,0,120,0,0,0,0,8531,0,1023,-1,-1,-1,-1),(846,1,0,30360864,15770772,231,1569847758,0,0,1,7205,0,0,0,0,217,0,0,0,0,7205,0,1023,-1,-1,-1,-1),(847,5,0,30360780,15770904,232,1569847759,0,0,1,8532,0,0,0,0,114,0,0,0,0,8532,0,1023,-1,-1,-1,-1),(849,4,0,30360606,15770922,235,1569847742,0,0,1,7272,0,0,0,0,214,0,0,0,0,7272,0,1023,-1,-1,-1,-1),(851,1,0,30360864,15770772,231,1569847818,0,0,1,7206,0,0,0,0,217,0,0,0,0,7206,0,1023,-1,-1,-1,-1),(852,5,0,30360780,15770904,232,1569847819,0,0,1,8533,0,0,0,0,114,0,0,0,0,8533,0,1023,-1,-1,-1,-1),(854,4,0,30360606,15770922,235,1569847802,0,0,1,7273,0,0,0,0,214,0,0,0,0,7273,0,1023,-1,-1,-1,-1),(856,1,0,30360864,15770772,231,1569847878,0,0,1,7207,0,0,0,0,217,0,0,0,0,7207,0,1023,-1,-1,-1,-1),(857,5,0,30360780,15770904,232,1569847879,0,0,1,8534,0,0,0,0,113,0,0,0,0,8534,0,1023,-1,-1,-1,-1),(859,4,0,30360606,15770922,235,1569847862,0,0,1,7274,0,0,0,0,214,0,0,0,0,7274,0,1023,-1,-1,-1,-1),(861,1,0,30360864,15770772,231,1569847938,0,0,1,7208,0,0,0,0,217,0,0,0,0,7208,0,1023,-1,-1,-1,-1),(862,5,0,30360780,15770904,232,1569847939,0,0,1,8535,0,0,0,0,113,0,0,0,0,8535,0,1023,-1,-1,-1,-1),(864,4,0,30360606,15770922,235,1569847922,0,0,1,7275,0,0,0,0,214,0,0,0,0,7275,0,1023,-1,-1,-1,-1),(866,1,0,30360864,15770772,231,1569847998,0,0,1,7209,0,0,0,0,217,0,0,0,0,7209,0,1023,-1,-1,-1,-1),(867,5,0,30360780,15770904,232,1569847999,0,0,1,8536,0,0,0,0,113,0,0,0,0,8536,0,1023,-1,-1,-1,-1),(869,4,0,30360606,15770922,235,1569847982,0,0,1,7276,0,0,0,0,214,0,0,0,0,7276,0,1023,-1,-1,-1,-1),(871,1,0,30360864,15770772,231,1569848058,0,0,1,7210,0,0,0,0,217,0,0,0,0,7210,0,1023,-1,-1,-1,-1),(872,5,0,30360780,15770904,232,1569848059,0,0,1,8537,0,0,0,0,112,0,0,0,0,8537,0,1023,-1,-1,-1,-1),(874,4,0,30360606,15770922,235,1569848042,0,0,1,7277,0,0,0,0,214,0,0,0,0,7277,0,1023,-1,-1,-1,-1),(876,1,0,30360864,15770772,231,1569848118,0,0,1,7211,0,0,0,0,217,0,0,0,0,7211,0,1023,-1,-1,-1,-1),(877,5,0,30360780,15770904,232,1569848119,0,0,1,8538,0,0,0,0,112,0,0,0,0,8538,0,1023,-1,-1,-1,-1),(879,4,0,30360606,15770922,235,1569848102,0,0,1,7278,0,0,0,0,214,0,0,0,0,7278,0,1023,-1,-1,-1,-1),(882,1,0,30360864,15770772,231,1569848178,0,0,1,7212,0,0,0,0,217,0,0,0,0,7212,0,1023,-1,-1,-1,-1),(883,5,0,30360780,15770904,232,1569848179,0,0,1,8539,0,0,0,0,112,0,0,0,0,8539,0,1023,-1,-1,-1,-1),(903,4,0,30360606,15770922,235,1569848162,0,0,1,7279,0,0,0,0,214,0,0,0,0,7279,0,1023,-1,-1,-1,-1),(920,1,0,30360864,15770772,231,1569848238,0,0,1,7213,0,0,0,0,217,0,0,0,0,7213,0,1023,-1,-1,-1,-1),(921,5,0,30360780,15770904,232,1569848239,0,0,1,8540,0,0,0,0,112,0,0,0,0,8540,0,1023,-1,-1,-1,-1),(949,4,0,30360606,15770922,235,1569848222,0,0,1,7280,0,0,0,0,214,0,0,0,0,7280,0,1023,-1,-1,-1,-1),(959,1,0,30360864,15770772,231,1569848298,0,0,1,7214,0,0,0,0,217,0,0,0,0,7214,0,1023,-1,-1,-1,-1),(960,5,0,30360780,15770904,232,1569848299,0,0,1,8541,0,0,0,0,112,0,0,0,0,8541,0,1023,-1,-1,-1,-1),(965,4,0,30360606,15770922,235,1569848282,0,0,1,7281,0,0,0,0,214,0,0,0,0,7281,0,1023,-1,-1,-1,-1),(975,1,0,30360864,15770772,231,1569848358,0,0,1,7215,0,0,0,0,217,0,0,0,0,7215,0,1023,-1,-1,-1,-1),(976,5,0,30360780,15770904,232,1569848359,0,0,1,8542,0,0,0,0,111,0,0,0,0,8542,0,1023,-1,-1,-1,-1),(982,4,0,30360606,15770922,235,1569848342,0,0,1,7282,0,0,0,0,214,0,0,0,0,7282,0,1023,-1,-1,-1,-1),(986,2,0,30362820,15764412,224,1569848356,8,197,1,7144,0,32,0,0,120,0,0,0,0,7144,0,1023,-1,-1,-1,-1),(987,2,0,30362844,15764322,224,1569848358,12,192,1,7145,0,32,0,0,120,0,0,0,0,7145,0,1023,-1,-1,-1,-1),(988,2,0,30362940,15763920,224,1569848365,15,197,1,7146,0,32,0,0,120,0,0,0,0,7146,0,1023,-1,-1,-1,-1),(989,2,0,30362958,15763860,224,1569848366,14,202,1,7147,0,32,0,0,120,0,0,0,0,7147,0,1023,-1,-1,-1,-1),(990,2,0,30362982,15763806,224,1569848367,14,206,1,7148,0,32,0,0,120,0,0,0,0,7148,0,1023,-1,-1,-1,-1),(991,2,0,30363006,15763764,224,1569848368,13,211,1,7149,0,32,0,0,120,0,0,0,0,7149,0,1023,-1,-1,-1,-1),(992,2,0,30363036,15763728,224,1569848369,13,215,1,7150,0,32,0,0,119,0,0,0,0,7150,0,1023,-1,-1,-1,-1),(993,2,0,30363162,15763572,224,1569848373,13,201,1,7151,0,32,0,0,119,0,0,0,0,7151,0,1023,-1,-1,-1,-1),(994,2,0,30363174,15763518,224,1569848374,13,191,1,7152,0,32,0,0,118,0,0,0,0,7152,0,1023,-1,-1,-1,-1),(995,2,0,30363180,15763464,224,1569848375,12,183,1,7153,0,32,0,0,119,0,0,0,0,7153,0,1023,-1,-1,-1,-1),(996,2,0,30363186,15763260,222,1569848380,6,187,1,7154,0,32,0,0,119,0,0,0,0,7154,0,1023,-1,-1,-1,-1),(997,2,0,30363192,15763230,222,1569848381,6,192,1,7155,0,32,0,0,119,0,0,0,0,7155,0,1023,-1,-1,-1,-1),(998,2,0,30363198,15763206,222,1569848382,7,199,1,7156,0,32,0,0,120,0,0,0,0,7156,0,1023,-1,-1,-1,-1),(999,2,0,30363222,15763146,222,1569848384,9,204,1,7157,0,32,0,0,120,0,0,0,0,7157,0,1023,-1,-1,-1,-1),(1000,2,0,30363696,15762078,212,1569848401,22,198,1,7158,0,32,0,0,119,0,0,0,0,7158,0,1023,-1,-1,-1,-1),(1906,4,0,30360606,15770922,235,1569843662,0,0,1,7204,0,0,0,0,214,0,0,0,0,7204,0,1023,-1,-1,-1,-1),(1917,4,0,30360606,15770922,235,1569843722,0,0,1,7205,0,0,0,0,214,0,0,0,0,7205,0,1023,-1,-1,-1,-1),(1927,1,0,30360864,15770772,231,1569843772,0,0,1,7137,0,0,0,0,219,0,0,0,0,7137,0,1023,-1,-1,-1,-1),(1930,4,0,30360606,15770922,235,1569843782,0,0,1,7206,0,0,0,0,214,0,0,0,0,7206,0,1023,-1,-1,-1,-1),(1939,1,0,30360864,15770772,231,1569843832,0,0,1,7138,0,0,0,0,219,0,0,0,0,7138,0,1023,-1,-1,-1,-1),(1942,4,0,30360606,15770922,235,1569843842,0,0,1,7207,0,0,0,0,214,0,0,0,0,7207,0,1023,-1,-1,-1,-1),(1944,1,0,30360864,15770772,231,1569843892,0,0,1,7139,0,0,0,0,219,0,0,0,0,7139,0,1023,-1,-1,-1,-1),(1954,1,0,30360864,15770772,231,1569843952,0,0,1,7140,0,0,0,0,218,0,0,0,0,7140,0,1023,-1,-1,-1,-1),(1969,4,0,30360606,15770922,235,1569843902,0,0,1,7208,0,0,0,0,214,0,0,0,0,7208,0,1023,-1,-1,-1,-1),(1970,4,0,30360606,15770922,235,1569843962,0,0,1,7209,0,0,0,0,214,0,0,0,0,7209,0,1023,-1,-1,-1,-1),(1984,1,0,30360864,15770772,231,1569844012,0,0,1,7141,0,0,0,0,218,0,0,0,0,7141,0,1023,-1,-1,-1,-1),(1989,4,0,30360606,15770922,235,1569844022,0,0,1,7210,0,0,0,0,214,0,0,0,0,7210,0,1023,-1,-1,-1,-1),(1998,1,0,30360864,15770772,231,1569844072,0,0,1,7142,0,0,0,0,218,0,0,0,0,7142,0,1023,-1,-1,-1,-1),(2674,1,0,30360864,15770772,231,1569848418,0,0,1,7216,0,0,0,0,217,0,0,0,0,7216,0,1023,-1,-1,-1,-1),(2675,5,0,30360780,15770904,232,1569848419,0,0,1,8543,0,0,0,0,111,0,0,0,0,8543,0,1023,-1,-1,-1,-1),(2694,4,0,30360606,15770922,235,1569848402,0,0,1,7283,0,0,0,0,214,0,0,0,0,7283,0,1023,-1,-1,-1,-1),(2695,2,0,30363768,15761904,212,1569848403,24,203,1,7159,0,32,0,0,120,0,0,0,0,7159,0,1023,-1,-1,-1,-1),(2696,2,0,30364674,15759798,205,1569848430,18,207,1,7160,0,32,0,0,120,0,0,0,0,7160,0,1023,-1,-1,-1,-1),(2697,2,0,30364806,15759516,207,1569848434,22,202,1,7161,0,32,0,0,119,0,0,0,0,7161,0,1023,-1,-1,-1,-1),(2698,1,0,30360864,15770772,231,1569848478,0,0,1,7217,0,0,0,0,216,0,0,0,0,7217,0,1023,-1,-1,-1,-1),(2699,5,0,30360780,15770904,232,1569848479,0,0,1,8544,0,0,0,0,111,0,0,0,0,8544,0,1023,-1,-1,-1,-1),(2710,4,0,30360606,15770922,235,1569848462,0,0,1,7284,0,0,0,0,214,0,0,0,0,7284,0,1023,-1,-1,-1,-1),(2711,2,0,30366396,15755784,201,1569848484,17,203,1,7162,0,32,0,0,120,0,0,0,0,7162,0,1023,-1,-1,-1,-1),(2712,2,0,30366894,15754656,197,1569848512,4,212,1,7163,0,32,0,0,120,0,0,0,0,7163,0,1023,-1,-1,-1,-1),(2713,2,0,30366906,15754644,197,1569848513,5,217,1,7164,0,32,0,0,120,0,0,0,0,7164,0,1023,-1,-1,-1,-1),(2714,2,0,30366924,15754632,197,1569848514,7,221,1,7165,0,32,0,0,120,0,0,0,0,7165,0,1023,-1,-1,-1,-1),(2715,2,0,30366960,15754602,196,1569848516,8,226,1,7166,0,32,0,0,119,0,0,0,0,7166,0,1023,-1,-1,-1,-1),(2716,2,0,30367008,15754584,196,1569848518,7,231,1,7167,0,32,0,0,119,0,0,0,0,7167,0,1023,-1,-1,-1,-1),(2717,1,0,30360864,15770772,231,1569848538,0,0,1,7218,0,0,0,0,216,0,0,0,0,7218,0,1023,-1,-1,-1,-1),(2718,5,0,30360780,15770904,232,1569848539,0,0,1,8545,0,0,0,0,111,0,0,0,0,8545,0,1023,-1,-1,-1,-1),(2738,4,0,30360606,15770922,235,1569848522,0,0,1,7285,0,0,0,0,214,0,0,0,0,7285,0,1023,-1,-1,-1,-1),(2739,2,0,30367056,15754566,195,1569848521,5,223,1,7168,0,32,0,0,119,0,0,0,0,7168,0,1023,-1,-1,-1,-1),(2740,2,0,30367074,15754560,195,1569848522,5,235,1,7169,0,32,0,0,120,0,0,0,0,7169,0,1023,-1,-1,-1,-1),(2741,2,0,30367098,15754560,195,1569848524,3,229,1,7170,0,32,0,0,119,0,0,0,0,7170,0,1023,-1,-1,-1,-1),(2742,2,0,30367140,15754554,194,1569848541,3,238,1,7171,0,32,0,0,120,0,0,0,0,7171,0,1023,-1,-1,-1,-1),(2743,2,0,30367158,15754548,195,1569848542,6,233,1,7172,0,32,0,0,120,0,0,0,0,7172,0,1023,-1,-1,-1,-1),(2744,2,0,30367350,15754446,195,1569848552,5,227,1,7173,0,32,0,0,120,0,0,0,0,7173,0,1023,-1,-1,-1,-1),(2745,2,0,30367374,15754434,194,1569848554,4,223,1,7174,0,32,0,0,120,0,0,0,0,7174,0,1023,-1,-1,-1,-1),(2746,2,0,30367410,15754404,194,1569848556,7,229,1,7175,0,32,0,0,119,0,0,0,0,7175,0,1023,-1,-1,-1,-1),(2747,2,0,30367860,15754188,194,1569848575,3,225,1,7176,0,32,0,0,119,0,0,0,0,7176,0,1023,-1,-1,-1,-1),(2748,1,0,30360864,15770772,231,1569848598,0,0,1,7219,0,0,0,0,216,0,0,0,0,7219,0,1023,-1,-1,-1,-1),(2749,5,0,30360780,15770904,232,1569848599,0,0,1,8546,0,0,0,0,111,0,0,0,0,8546,0,1023,-1,-1,-1,-1),(2760,4,0,30360606,15770922,235,1569848582,0,0,1,7286,0,0,0,0,214,0,0,0,0,7286,0,1023,-1,-1,-1,-1),(2761,2,0,30367920,15754140,193,1569848594,3,217,1,7177,0,32,0,0,119,0,0,0,0,7177,0,1023,-1,-1,-1,-1),(2762,2,0,30367926,15754128,193,1569848595,4,211,1,7178,0,32,0,0,119,0,0,0,0,7178,0,1023,-1,-1,-1,-1),(2763,2,0,30367932,15754116,193,1569848596,4,204,1,7179,0,32,0,0,120,0,0,0,0,7179,0,1023,-1,-1,-1,-1),(2764,2,0,30367932,15754098,193,1569848597,4,190,1,7180,0,32,0,0,119,0,0,0,0,7180,0,1023,-1,-1,-1,-1),(2765,2,0,30367938,15754074,193,1569848598,5,179,1,7181,0,32,0,0,119,0,0,0,0,7181,0,1023,-1,-1,-1,-1),(2766,2,0,30367932,15754050,193,1569848599,4,173,1,7182,0,32,0,0,119,0,0,0,0,7182,0,1023,-1,-1,-1,-1),(2767,2,0,30367926,15754032,193,1569848600,5,166,1,7183,0,32,0,0,120,0,0,0,0,7183,0,1023,-1,-1,-1,-1),(2768,2,0,30367914,15753972,193,1569848602,9,170,1,7184,0,32,0,0,120,0,0,0,0,7184,0,1023,-1,-1,-1,-1),(2769,2,0,30367902,15753822,192,1569848605,11,177,1,7185,0,32,0,0,120,0,0,0,0,7185,0,1023,-1,-1,-1,-1),(2770,2,0,30367902,15753774,192,1569848606,12,173,1,7186,0,32,0,0,120,0,0,0,0,7186,0,1023,-1,-1,-1,-1),(2771,1,0,30360864,15770772,231,1569848658,0,0,1,7220,0,0,0,0,216,0,0,0,0,7220,0,1023,-1,-1,-1,-1),(2772,5,0,30360780,15770904,232,1569848659,0,0,1,8547,0,0,0,0,111,0,0,0,0,8547,0,1023,-1,-1,-1,-1),(2779,4,0,30360606,15770922,235,1569848642,0,0,1,7287,0,0,0,0,214,0,0,0,0,7287,0,1023,-1,-1,-1,-1),(2780,2,0,30367626,15750396,185,1569848647,19,177,1,7187,0,32,0,0,120,0,0,0,0,7187,0,1023,-1,-1,-1,-1),(2781,2,0,30367338,15746004,182,1569848689,19,177,1,7188,0,32,0,0,119,0,0,0,0,7188,0,1023,-1,-1,-1,-1),(2782,2,0,30367302,15745362,185,1569848697,18,181,1,7189,0,32,0,0,119,0,0,0,0,7189,0,1023,-1,-1,-1,-1),(2783,1,0,30360864,15770772,231,1569848718,0,0,1,7221,0,0,0,0,216,0,0,0,0,7221,0,1023,-1,-1,-1,-1),(2784,5,0,30360780,15770904,232,1569848719,0,0,1,8548,0,0,0,0,110,0,0,0,0,8548,0,1023,-1,-1,-1,-1),(2786,4,0,30360606,15770922,235,1569848702,0,0,1,7288,0,0,0,0,214,0,0,0,0,7288,0,1023,-1,-1,-1,-1),(2787,2,0,30367308,15745062,184,1569848700,22,185,1,7190,0,32,0,0,119,0,0,0,0,7190,0,1023,-1,-1,-1,-1),(2788,2,0,30367356,15744672,184,1569848704,24,189,1,7191,0,32,0,0,119,0,0,0,0,7191,0,1023,-1,-1,-1,-1),(2789,2,0,30367710,15742728,184,1569848724,11,193,1,7192,0,32,0,0,118,0,0,0,0,7192,0,1023,-1,-1,-1,-1),(2790,2,0,30367722,15742692,184,1569848725,9,199,1,7193,0,32,0,0,119,0,0,0,0,7193,0,1023,-1,-1,-1,-1),(2791,2,0,30367734,15742662,184,1569848726,8,212,1,7194,0,32,0,0,119,0,0,0,0,7194,0,1023,-1,-1,-1,-1),(2792,2,0,30367752,15742644,184,1569848727,8,223,1,7195,0,32,0,0,119,0,0,0,0,7195,0,1023,-1,-1,-1,-1),(2793,2,0,30367776,15742638,184,1569848728,8,235,1,7196,0,32,0,0,119,0,0,0,0,7196,0,1023,-1,-1,-1,-1),(2794,2,0,30367866,15742626,185,1569848732,8,227,1,7197,0,32,0,0,119,0,0,0,0,7197,0,1023,-1,-1,-1,-1),(2795,2,0,30367884,15742614,185,1569848733,8,221,1,7198,0,32,0,0,120,0,0,0,0,7198,0,1023,-1,-1,-1,-1),(2796,2,0,30367902,15742596,185,1569848734,9,214,1,7199,0,32,0,0,119,0,0,0,0,7199,0,1023,-1,-1,-1,-1),(2797,2,0,30367920,15742572,184,1569848735,8,207,1,7200,0,32,0,0,119,0,0,0,0,7200,0,1023,-1,-1,-1,-1),(2798,2,0,30367944,15742512,184,1569848737,8,198,1,7201,0,32,0,0,119,0,0,0,0,7201,0,1023,-1,-1,-1,-1),(2799,2,0,30367968,15742446,183,1569848739,8,193,1,7202,0,32,0,0,119,0,0,0,0,7202,0,1023,-1,-1,-1,-1),(2800,2,0,30367980,15742380,182,1569848741,7,187,1,7203,0,32,0,0,119,0,0,0,0,7203,0,1023,-1,-1,-1,-1),(2801,1,0,30360864,15770772,231,1569848778,0,0,1,7222,0,0,0,0,216,0,0,0,0,7222,0,1023,-1,-1,-1,-1),(2802,5,0,30360780,15770904,232,1569848779,0,0,1,8549,0,0,0,0,110,0,0,0,0,8549,0,1023,-1,-1,-1,-1),(2811,4,0,30360606,15770922,235,1569848762,0,0,1,7289,0,0,0,0,214,0,0,0,0,7289,0,1023,-1,-1,-1,-1),(2812,2,0,30368028,15742068,182,1569848800,4,187,1,7204,0,32,0,0,120,0,0,0,0,7204,0,1023,-1,-1,-1,-1),(2813,2,0,30368154,15741234,182,1569848819,11,192,1,7205,0,32,0,0,120,0,0,0,0,7205,0,1023,-1,-1,-1,-1),(2814,1,0,30360864,15770772,231,1569848838,0,0,1,7223,0,0,0,0,216,0,0,0,0,7223,0,1023,-1,-1,-1,-1),(2815,5,0,30360780,15770904,232,1569848839,0,0,1,8550,0,0,0,0,110,0,0,0,0,8550,0,1023,-1,-1,-1,-1),(2822,4,0,30360606,15770922,235,1569848822,0,0,1,7290,0,0,0,0,214,0,0,0,0,7290,0,1023,-1,-1,-1,-1),(2823,2,0,30368370,15740220,187,1569848842,7,197,1,7206,0,32,0,0,119,0,0,0,0,7206,0,1023,-1,-1,-1,-1),(2824,2,0,30368376,15740190,187,1569848843,6,202,1,7207,0,32,0,0,120,0,0,0,0,7207,0,1023,-1,-1,-1,-1),(2825,2,0,30368388,15740166,188,1569848844,6,211,1,7208,0,32,0,0,120,0,0,0,0,7208,0,1023,-1,-1,-1,-1),(2826,2,0,30368406,15740148,188,1569848845,7,219,1,7209,0,32,0,0,120,0,0,0,0,7209,0,1023,-1,-1,-1,-1),(2827,2,0,30368424,15740136,188,1569848846,6,228,1,7210,0,32,0,0,120,0,0,0,0,7210,0,1023,-1,-1,-1,-1),(2828,2,0,30368442,15740130,189,1569848847,6,234,1,7211,0,32,0,0,120,0,0,0,0,7211,0,1023,-1,-1,-1,-1),(2829,2,0,30368460,15740124,189,1569848848,7,0,1,7212,0,32,0,0,120,0,0,0,0,7212,0,1023,-1,-1,-1,-1),(2830,2,0,30368478,15740130,189,1569848849,8,5,1,7213,0,32,0,0,120,0,0,0,0,7213,0,1023,-1,-1,-1,-1),(2831,2,0,30368550,15740148,189,1569848852,9,11,1,7214,0,32,0,0,120,0,0,0,0,7214,0,1023,-1,-1,-1,-1),(2832,2,0,30368592,15740178,188,1569848854,9,15,1,7215,0,32,0,0,120,0,0,0,0,7215,0,1023,-1,-1,-1,-1),(2833,2,0,30368742,15740298,187,1569848862,5,20,1,7216,0,32,0,0,119,0,0,0,0,7216,0,1023,-1,-1,-1,-1),(2834,2,0,30368796,15740346,187,1569848873,0,0,1,7217,0,0,0,0,115,0,0,0,0,7217,0,1023,-1,-1,-1,-1),(2835,1,0,30360864,15770772,231,1569848898,0,0,1,7224,0,0,0,0,216,0,0,0,0,7224,0,1023,-1,-1,-1,-1),(2836,5,0,30360780,15770904,232,1569848899,0,0,1,8551,0,0,0,0,110,0,0,0,0,8551,0,1023,-1,-1,-1,-1),(2841,4,0,30360606,15770922,235,1569848882,0,0,1,7291,0,0,0,0,214,0,0,0,0,7291,0,1023,-1,-1,-1,-1),(2842,2,0,30368796,15740346,187,1569848932,0,0,1,7218,0,0,0,0,114,0,0,0,0,7218,0,1023,-1,-1,-1,-1),(2843,1,0,30360864,15770772,231,1569848958,0,0,1,7225,0,0,0,0,216,0,0,0,0,7225,0,1023,-1,-1,-1,-1),(2844,5,0,30360780,15770904,232,1569848959,0,0,1,8552,0,0,0,0,110,0,0,0,0,8552,0,1023,-1,-1,-1,-1),(2846,4,0,30360606,15770922,235,1569848942,0,0,1,7292,0,0,0,0,214,0,0,0,0,7292,0,1023,-1,-1,-1,-1),(2847,2,0,30368796,15740346,187,1569848992,0,0,1,7219,0,0,0,0,114,0,0,0,0,7219,0,1023,-1,-1,-1,-1),(2848,1,0,30360864,15770772,231,1569849018,0,0,1,7226,0,0,0,0,216,0,0,0,0,7226,0,1023,-1,-1,-1,-1),(2849,5,0,30360780,15770904,232,1569849019,0,0,1,8553,0,0,0,0,110,0,0,0,0,8553,0,1023,-1,-1,-1,-1),(2857,2,0,30368796,15740346,187,1569849025,0,0,1,7220,0,32,0,0,115,0,0,0,0,7220,0,1023,-1,-1,-1,-1),(2864,3,0,30368784,15753570,196,1569849005,2,228,1,8133,0,32,0,0,115,0,0,0,0,8133,0,1023,-1,-1,-1,-1),(2865,4,0,30360606,15770922,235,1569849002,0,0,1,7293,0,0,0,0,214,0,0,0,0,7293,0,1023,-1,-1,-1,-1),(2866,1,0,30360864,15770772,231,1569849078,0,0,1,7227,0,0,0,0,216,0,0,0,0,7227,0,1023,-1,-1,-1,-1),(2867,5,0,30360780,15770904,232,1569849079,0,0,1,8554,0,0,0,0,110,0,0,0,0,8554,0,1023,-1,-1,-1,-1),(2868,3,0,30368982,15753426,197,1569849045,3,223,1,8134,0,32,0,0,115,0,0,0,0,8134,0,1023,-1,-1,-1,-1),(2869,3,0,30369018,15753384,197,1569849049,3,227,1,8135,0,32,0,0,115,0,0,0,0,8135,0,1023,-1,-1,-1,-1),(2870,3,0,30369042,15753372,197,1569849051,4,233,1,8136,0,32,0,0,116,0,0,0,0,8136,0,1023,-1,-1,-1,-1),(2871,3,0,30369054,15753360,197,1569849052,4,229,1,8137,0,32,0,0,116,0,0,0,0,8137,0,1023,-1,-1,-1,-1),(2872,3,0,30369078,15753336,198,1569849054,4,235,1,8138,0,32,0,0,116,0,0,0,0,8138,0,1023,-1,-1,-1,-1),(2873,3,0,30369084,15753330,198,1569849055,3,227,1,8139,0,32,0,0,115,0,0,0,0,8139,0,1023,-1,-1,-1,-1),(2874,3,0,30369096,15753324,199,1569849056,3,222,1,8140,0,32,0,0,115,0,0,0,0,8140,0,1023,-1,-1,-1,-1),(2875,2,0,30368826,15740358,187,1569849044,2,231,1,7221,0,32,0,0,120,0,0,0,0,7221,0,1023,-1,-1,-1,-1),(2876,2,0,30368838,15740334,187,1569849051,2,181,1,7222,0,32,0,0,120,0,0,0,0,7222,0,1023,-1,-1,-1,-1),(2877,2,0,30368838,15740322,187,1569849052,2,176,1,7223,0,32,0,0,120,0,0,0,0,7223,0,1023,-1,-1,-1,-1),(2878,2,0,30368838,15740328,187,1569849059,2,73,1,7224,0,32,0,0,119,0,0,0,0,7224,0,1023,-1,-1,-1,-1),(2879,2,0,30368832,15740334,187,1569849060,2,66,1,7225,0,32,0,0,119,0,0,0,0,7225,0,1023,-1,-1,-1,-1),(2880,2,0,30368832,15740346,187,1569849061,3,57,1,7226,0,32,0,0,119,0,0,0,0,7226,0,1023,-1,-1,-1,-1),(2881,2,0,30368838,15740358,187,1569849062,3,43,1,7227,0,32,0,0,119,0,0,0,0,7227,0,1023,-1,-1,-1,-1),(2882,3,0,30369144,15753270,200,1569849061,3,218,1,8141,0,32,0,0,116,0,0,0,0,8141,0,1023,-1,-1,-1,-1),(2883,3,0,30369150,15753258,200,1569849062,2,223,1,8142,0,32,0,0,116,0,0,0,0,8142,0,1023,-1,-1,-1,-1),(2884,2,0,30368892,15740460,187,1569849080,2,7,1,7228,0,32,0,0,119,0,0,0,0,7228,0,1023,-1,-1,-1,-1),(2885,2,0,30368916,15740472,187,1569849085,2,12,1,7229,0,32,0,0,119,0,0,0,0,7229,0,1023,-1,-1,-1,-1),(2886,4,0,30360606,15770922,235,1569849062,0,0,1,7294,0,0,0,0,214,0,0,0,0,7294,0,1023,-1,-1,-1,-1),(2887,2,0,30368952,15740502,187,1569849090,2,19,1,7230,0,32,0,0,119,0,0,0,0,7230,0,1023,-1,-1,-1,-1),(2888,2,0,30369012,15740550,187,1569849099,2,15,1,7231,0,32,0,0,119,0,0,0,0,7231,0,1023,-1,-1,-1,-1),(2889,2,0,30369102,15740598,186,1569849111,2,26,1,7232,0,32,0,0,119,0,0,0,0,7232,0,1023,-1,-1,-1,-1),(2890,2,0,30369102,15740604,186,1569849112,2,19,1,7233,0,32,0,0,120,0,0,0,0,7233,0,1023,-1,-1,-1,-1),(2891,2,0,30369102,15740604,186,1569849127,0,0,1,7234,0,0,0,0,115,0,0,0,0,7234,0,1023,-1,-1,-1,-1),(2892,1,0,30360864,15770772,231,1569849138,0,0,1,7228,0,0,0,0,216,0,0,0,0,7228,0,1023,-1,-1,-1,-1),(2893,5,0,30360780,15770904,232,1569849139,0,0,1,8555,0,0,0,0,110,0,0,0,0,8555,0,1023,-1,-1,-1,-1),(2894,3,0,30369222,15753228,201,1569849092,3,11,1,8143,0,32,0,0,115,0,0,0,0,8143,0,1023,-1,-1,-1,-1),(2895,3,0,30369240,15753216,201,1569849093,3,2,1,8144,0,32,0,0,115,0,0,0,0,8144,0,1023,-1,-1,-1,-1),(2896,3,0,30369252,15753210,200,1569849094,3,225,1,8145,0,32,0,0,115,0,0,0,0,8145,0,1023,-1,-1,-1,-1),(2897,3,0,30369264,15753192,200,1569849095,4,215,1,8146,0,32,0,0,116,0,0,0,0,8146,0,1023,-1,-1,-1,-1),(2898,3,0,30369276,15753174,199,1569849096,5,210,1,8147,0,32,0,0,116,0,0,0,0,8147,0,1023,-1,-1,-1,-1),(2899,3,0,30369300,15753108,199,1569849099,3,205,1,8148,0,32,0,0,115,0,0,0,0,8148,0,1023,-1,-1,-1,-1),(2900,3,0,30369330,15753030,200,1569849104,4,209,1,8149,0,32,0,0,115,0,0,0,0,8149,0,1023,-1,-1,-1,-1),(2901,3,0,30369354,15752994,200,1569849106,5,204,1,8150,0,32,0,0,115,0,0,0,0,8150,0,1023,-1,-1,-1,-1),(2902,3,0,30369408,15752886,200,1569849112,3,208,1,8151,0,32,0,0,115,0,0,0,0,8151,0,1023,-1,-1,-1,-1),(2903,3,0,30369426,15752874,200,1569849113,4,216,1,8152,0,32,0,0,115,0,0,0,0,8152,0,1023,-1,-1,-1,-1),(2904,3,0,30369438,15752856,200,1569849114,4,212,1,8153,0,32,0,0,115,0,0,0,0,8153,0,1023,-1,-1,-1,-1),(2905,3,0,30369456,15752832,201,1569849134,4,204,1,8154,0,32,0,0,116,0,0,0,0,8154,0,1023,-1,-1,-1,-1),(2906,3,0,30369528,15752682,200,1569849141,8,208,1,8155,0,32,0,0,116,0,0,0,0,8155,0,1023,-1,-1,-1,-1),(2907,3,0,30369630,15752496,199,1569849147,4,202,1,8156,0,32,0,0,115,0,0,0,0,8156,0,1023,-1,-1,-1,-1),(2908,4,0,30360606,15770922,235,1569849122,0,0,1,7295,0,0,0,0,214,0,0,0,0,7295,0,1023,-1,-1,-1,-1),(2909,2,0,30369102,15740604,186,1569849187,0,0,1,7235,0,0,0,0,114,0,0,0,0,7235,0,1023,-1,-1,-1,-1),(2910,1,0,30360864,15770772,231,1569849198,0,0,1,7229,0,0,0,0,216,0,0,0,0,7229,0,1023,-1,-1,-1,-1),(2911,5,0,30360780,15770904,232,1569849199,0,0,1,8556,0,0,0,0,110,0,0,0,0,8556,0,1023,-1,-1,-1,-1),(2912,3,0,30369642,15752484,199,1569849148,4,211,1,8157,0,32,0,0,116,0,0,0,0,8157,0,1023,-1,-1,-1,-1),(2913,3,0,30369654,15752466,199,1569849149,3,207,1,8158,0,32,0,0,115,0,0,0,0,8158,0,1023,-1,-1,-1,-1),(2914,3,0,30369660,15752454,199,1569849150,3,203,1,8159,0,32,0,0,115,0,0,0,0,8159,0,1023,-1,-1,-1,-1),(2915,3,0,30369678,15752424,199,1569849152,3,207,1,8160,0,32,0,0,115,0,0,0,0,8160,0,1023,-1,-1,-1,-1),(2916,3,0,30369690,15752412,199,1569849153,3,213,1,8161,0,32,0,0,115,0,0,0,0,8161,0,1023,-1,-1,-1,-1),(2917,3,0,30369702,15752382,199,1569849179,3,203,1,8162,0,32,0,0,116,0,0,0,0,8162,0,1023,-1,-1,-1,-1),(2918,3,0,30369750,15752316,198,1569849182,10,207,1,8163,0,32,0,0,117,0,0,0,0,8163,0,1023,-1,-1,-1,-1),(2919,3,0,30369864,15752076,197,1569849186,17,203,1,8164,0,32,0,0,116,0,0,0,0,8164,0,1023,-1,-1,-1,-1),(2920,3,0,30369942,15751878,193,1569849189,17,199,1,8165,0,32,0,0,116,0,0,0,0,8165,0,1023,-1,-1,-1,-1),(2921,3,0,30370008,15751782,191,1569849191,15,205,1,8166,0,32,0,0,117,0,0,0,0,8166,0,1023,-1,-1,-1,-1),(2922,3,0,30370050,15751734,190,1569849192,16,210,1,8167,0,32,0,0,117,0,0,0,0,8167,0,1023,-1,-1,-1,-1),(2923,3,0,30370086,15751686,189,1569849193,17,214,1,8168,0,32,0,0,117,0,0,0,0,8168,0,1023,-1,-1,-1,-1),(2924,3,0,30370230,15751548,190,1569849197,14,219,1,8169,0,32,0,0,115,0,0,0,0,8169,0,1023,-1,-1,-1,-1),(2925,3,0,30370374,15751428,196,1569849210,8,229,1,8170,0,32,0,0,116,0,0,0,0,8170,0,1023,-1,-1,-1,-1),(2926,3,0,30370398,15751410,196,1569849211,11,233,1,8171,0,32,0,0,117,0,0,0,0,8171,0,1023,-1,-1,-1,-1),(2927,3,0,30370500,15751380,195,1569849214,16,3,1,8172,0,32,0,0,117,0,0,0,0,8172,0,1023,-1,-1,-1,-1),(2928,4,0,30360606,15770922,235,1569849182,0,0,1,7296,0,0,0,0,214,0,0,0,0,7296,0,1023,-1,-1,-1,-1),(2929,2,0,30369102,15740604,186,1569849247,0,0,1,7236,0,0,0,0,113,0,0,0,0,7236,0,1023,-1,-1,-1,-1),(2930,1,0,30360864,15770772,231,1569849258,0,0,1,7230,0,0,0,0,216,0,0,0,0,7230,0,1023,-1,-1,-1,-1),(2931,5,0,30360780,15770904,232,1569849259,0,0,1,8557,0,0,0,0,110,0,0,0,0,8557,0,1023,-1,-1,-1,-1),(2932,3,0,30370584,15751386,196,1569849216,13,239,1,8173,0,32,0,0,115,0,0,0,0,8173,0,1023,-1,-1,-1,-1),(2933,3,0,30370674,15751386,197,1569849219,10,4,1,8174,0,32,0,0,115,0,0,0,0,8174,0,1023,-1,-1,-1,-1),(2934,3,0,30370686,15751380,199,1569849220,6,237,1,8175,0,32,0,0,115,0,0,0,0,8175,0,1023,-1,-1,-1,-1),(2935,3,0,30370716,15751368,198,1569849255,4,229,1,8176,0,32,0,0,116,0,0,0,0,8176,0,1023,-1,-1,-1,-1),(2936,3,0,30370728,15751368,198,1569849256,7,237,1,8177,0,32,0,0,116,0,0,0,0,8177,0,1023,-1,-1,-1,-1),(2937,3,0,30371082,15751320,200,1569849265,12,1,1,8178,0,32,0,0,117,0,0,0,0,8178,0,1023,-1,-1,-1,-1),(2938,4,0,30360606,15770922,235,1569849242,0,0,1,7297,0,0,0,0,214,0,0,0,0,7297,0,1023,-1,-1,-1,-1),(2939,2,0,30369102,15740604,186,1569849307,0,0,1,7237,0,0,0,0,113,0,0,0,0,7237,0,1023,-1,-1,-1,-1),(2940,1,0,30360864,15770772,231,1569849318,0,0,1,7231,0,0,0,0,216,0,0,0,0,7231,0,1023,-1,-1,-1,-1),(2941,5,0,30360780,15770904,232,1569849319,0,0,1,8558,0,0,0,0,110,0,0,0,0,8558,0,1023,-1,-1,-1,-1),(2942,3,0,30371352,15751386,199,1569849274,10,7,1,8179,0,32,0,0,115,0,0,0,0,8179,0,1023,-1,-1,-1,-1),(2943,3,0,30371400,15751380,199,1569849276,8,234,1,8180,0,32,0,0,115,0,0,0,0,8180,0,1023,-1,-1,-1,-1),(2944,3,0,30371442,15751356,199,1569849278,8,225,1,8181,0,32,0,0,115,0,0,0,0,8181,0,1023,-1,-1,-1,-1),(2945,3,0,30371460,15751338,199,1569849279,8,219,1,8182,0,32,0,0,115,0,0,0,0,8182,0,1023,-1,-1,-1,-1),(2946,3,0,30371478,15751314,199,1569849280,9,225,1,8183,0,32,0,0,116,0,0,0,0,8183,0,1023,-1,-1,-1,-1),(2947,3,0,30371502,15751290,199,1569849281,10,229,1,8184,0,32,0,0,116,0,0,0,0,8184,0,1023,-1,-1,-1,-1),(2948,3,0,30371532,15751272,199,1569849282,12,233,1,8185,0,32,0,0,116,0,0,0,0,8185,0,1023,-1,-1,-1,-1),(2949,3,0,30371568,15751266,199,1569849283,13,238,1,8186,0,32,0,0,117,0,0,0,0,8186,0,1023,-1,-1,-1,-1),(2950,3,0,30371610,15751266,198,1569849284,12,3,1,8187,0,32,0,0,116,0,0,0,0,8187,0,1023,-1,-1,-1,-1),(2951,3,0,30371646,15751272,198,1569849285,12,7,1,8188,0,32,0,0,117,0,0,0,0,8188,0,1023,-1,-1,-1,-1),(2952,3,0,30372420,15751548,193,1569849316,20,11,1,8189,0,32,0,0,117,0,0,0,0,8189,0,1023,-1,-1,-1,-1),(2953,4,0,30360606,15770922,235,1569849302,0,0,1,7298,0,0,0,0,214,0,0,0,0,7298,0,1023,-1,-1,-1,-1),(2954,2,0,30369102,15740604,186,1569849367,0,0,1,7238,0,0,0,0,113,0,0,0,0,7238,0,1023,-1,-1,-1,-1),(2955,1,0,30360864,15770772,231,1569849378,0,0,1,7232,0,0,0,0,216,0,0,0,0,7232,0,1023,-1,-1,-1,-1),(2956,5,0,30360780,15770904,232,1569849379,0,0,1,8559,0,0,0,0,109,0,0,0,0,8559,0,1023,-1,-1,-1,-1),(2957,3,0,30372858,15751740,194,1569849330,12,4,1,8190,0,32,0,0,117,0,0,0,0,8190,0,1023,-1,-1,-1,-1),(2958,3,0,30372924,15751764,194,1569849332,12,9,1,8191,0,32,0,0,117,0,0,0,0,8191,0,1023,-1,-1,-1,-1),(2959,3,0,30373602,15752070,205,1569849349,16,13,1,8192,0,32,0,0,116,0,0,0,0,8192,0,1023,-1,-1,-1,-1),(2960,3,0,30373734,15752142,204,1569849352,15,17,1,8193,0,32,0,0,117,0,0,0,0,8193,0,1023,-1,-1,-1,-1),(2961,3,0,30373764,15752178,204,1569849353,16,23,1,8194,0,32,0,0,117,0,0,0,0,8194,0,1023,-1,-1,-1,-1),(2962,3,0,30373782,15752238,203,1569849354,17,37,1,8195,0,32,0,0,117,0,0,0,0,8195,0,1023,-1,-1,-1,-1),(2963,3,0,30373962,15752664,196,1569849360,19,41,1,8196,0,32,0,0,117,0,0,0,0,8196,0,1023,-1,-1,-1,-1),(2964,3,0,30374196,15753306,185,1569849369,10,36,1,8197,0,32,0,0,116,0,0,0,0,8197,0,1023,-1,-1,-1,-1),(2965,3,0,30374202,15753366,183,1569849371,6,45,1,8198,0,32,0,0,116,0,0,0,0,8198,0,1023,-1,-1,-1,-1),(2966,3,0,30374208,15753390,183,1569849372,5,54,1,8199,0,32,0,0,116,0,0,0,0,8199,0,1023,-1,-1,-1,-1),(2967,3,0,30374220,15753426,183,1569849374,5,47,1,8200,0,32,0,0,116,0,0,0,0,8200,0,1023,-1,-1,-1,-1),(2968,3,0,30374232,15753450,183,1569849375,6,39,1,8201,0,32,0,0,116,0,0,0,0,8201,0,1023,-1,-1,-1,-1),(2969,3,0,30374268,15753522,184,1569849378,5,44,1,8202,0,32,0,0,116,0,0,0,0,8202,0,1023,-1,-1,-1,-1),(2970,3,0,30374274,15753564,183,1569849380,5,40,1,8203,0,32,0,0,116,0,0,0,0,8203,0,1023,-1,-1,-1,-1),(2971,3,0,30374286,15753582,183,1569849381,5,45,1,8204,0,32,0,0,116,0,0,0,0,8204,0,1023,-1,-1,-1,-1),(2972,3,0,30374304,15753630,184,1569849383,8,40,1,8205,0,32,0,0,117,0,0,0,0,8205,0,1023,-1,-1,-1,-1),(2973,3,0,30374382,15753786,187,1569849387,13,33,1,8206,0,32,0,0,117,0,0,0,0,8206,0,1023,-1,-1,-1,-1),(2974,3,0,30374412,15753828,187,1569849388,13,29,1,8207,0,32,0,0,117,0,0,0,0,8207,0,1023,-1,-1,-1,-1),(2975,4,0,30360606,15770922,235,1569849362,0,0,1,7299,0,0,0,0,214,0,0,0,0,7299,0,1023,-1,-1,-1,-1),(2976,2,0,30369102,15740604,186,1569849427,0,0,1,7239,0,0,0,0,112,0,0,0,0,7239,0,1023,-1,-1,-1,-1),(2977,1,0,30360864,15770772,231,1569849438,0,0,1,7233,0,0,0,0,216,0,0,0,0,7233,0,1023,-1,-1,-1,-1),(2978,5,0,30360780,15770904,232,1569849439,0,0,1,8560,0,0,0,0,109,0,0,0,0,8560,0,1023,-1,-1,-1,-1),(2979,3,0,30374436,15753864,188,1569849389,12,19,1,8208,0,32,0,0,117,0,0,0,0,8208,0,1023,-1,-1,-1,-1),(2980,3,0,30374472,15753876,188,1569849390,12,8,1,8209,0,32,0,0,117,0,0,0,0,8209,0,1023,-1,-1,-1,-1),(2981,3,0,30374574,15753864,189,1569849393,11,0,1,8210,0,32,0,0,117,0,0,0,0,8210,0,1023,-1,-1,-1,-1),(2982,3,0,30374592,15753852,189,1569849394,9,235,1,8211,0,32,0,0,117,0,0,0,0,8211,0,1023,-1,-1,-1,-1),(2983,3,0,30374610,15753840,190,1569849395,8,6,1,8212,0,32,0,0,117,0,0,0,0,8212,0,1023,-1,-1,-1,-1),(2984,3,0,30374628,15753852,191,1569849396,8,21,1,8213,0,32,0,0,117,0,0,0,0,8213,0,1023,-1,-1,-1,-1),(2985,3,0,30374646,15753876,191,1569849397,10,32,1,8214,0,32,0,0,117,0,0,0,0,8214,0,1023,-1,-1,-1,-1),(2986,3,0,30374658,15753918,191,1569849398,11,44,1,8215,0,32,0,0,117,0,0,0,0,8215,0,1023,-1,-1,-1,-1),(2987,3,0,30374664,15753966,191,1569849399,11,52,1,8216,0,32,0,0,117,0,0,0,0,8216,0,1023,-1,-1,-1,-1),(2988,3,0,30374676,15754236,194,1569849406,6,56,1,8217,0,32,0,0,116,0,0,0,0,8217,0,1023,-1,-1,-1,-1),(2989,3,0,30374700,15754476,200,1569849432,5,51,1,8218,0,32,0,0,117,0,0,0,0,8218,0,1023,-1,-1,-1,-1),(2990,3,0,30374706,15754524,200,1569849434,4,47,1,8219,0,32,0,0,116,0,0,0,0,8219,0,1023,-1,-1,-1,-1),(2991,3,0,30374730,15754620,200,1569849439,4,41,1,8220,0,32,0,0,117,0,0,0,0,8220,0,1023,-1,-1,-1,-1),(2992,3,0,30374742,15754656,199,1569849441,4,45,1,8221,0,32,0,0,117,0,0,0,0,8221,0,1023,-1,-1,-1,-1),(2993,3,0,30374766,15754728,197,1569849445,4,49,1,8222,0,32,0,0,117,0,0,0,0,8222,0,1023,-1,-1,-1,-1),(2994,3,0,30374772,15754764,198,1569849447,4,41,1,8223,0,32,0,0,116,0,0,0,0,8223,0,1023,-1,-1,-1,-1),(2995,4,0,30360606,15770922,235,1569849422,0,0,1,7300,0,0,0,0,214,0,0,0,0,7300,0,1023,-1,-1,-1,-1),(2996,2,0,30369102,15740604,186,1569849487,0,0,1,7240,0,0,0,0,112,0,0,0,0,7240,0,1023,-1,-1,-1,-1),(2997,1,0,30360864,15770772,231,1569849498,0,0,1,7234,0,0,0,0,216,0,0,0,0,7234,0,1023,-1,-1,-1,-1),(2998,5,0,30360780,15770904,232,1569849499,0,0,1,8561,0,0,0,0,109,0,0,0,0,8561,0,1023,-1,-1,-1,-1),(2999,3,0,30374844,15754938,200,1569849476,3,46,1,8224,0,32,0,0,116,0,0,0,0,8224,0,1023,-1,-1,-1,-1),(3000,3,0,30374844,15754950,200,1569849477,4,34,1,8225,0,32,0,0,116,0,0,0,0,8225,0,1023,-1,-1,-1,-1),(3001,3,0,30374862,15754986,200,1569849479,4,39,1,8226,0,32,0,0,116,0,0,0,0,8226,0,1023,-1,-1,-1,-1),(3002,3,0,30374904,15755118,201,1569849486,4,45,1,8227,0,32,0,0,116,0,0,0,0,8227,0,1023,-1,-1,-1,-1),(3003,3,0,30374910,15755130,201,1569849487,4,40,1,8228,0,32,0,0,116,0,0,0,0,8228,0,1023,-1,-1,-1,-1),(3004,4,0,30360606,15770922,235,1569849482,0,0,1,7301,0,0,0,0,214,0,0,0,0,7301,0,1023,-1,-1,-1,-1),(3005,2,0,30369102,15740604,186,1569849547,0,0,1,7241,0,0,0,0,112,0,0,0,0,7241,0,1023,-1,-1,-1,-1),(3006,1,0,30360864,15770772,231,1569849558,0,0,1,7235,0,0,0,0,216,0,0,0,0,7235,0,1023,-1,-1,-1,-1),(3007,5,0,30360780,15770904,232,1569849559,0,0,1,8562,0,0,0,0,109,0,0,0,0,8562,0,1023,-1,-1,-1,-1),(3008,3,0,30375102,15755622,207,1569849528,4,36,1,8229,0,32,0,0,116,0,0,0,0,8229,0,1023,-1,-1,-1,-1),(3009,3,0,30375222,15755856,213,1569849539,4,31,1,8230,0,32,0,0,115,0,0,0,0,8230,0,1023,-1,-1,-1,-1),(3010,3,0,30375240,15755886,213,1569849554,6,36,1,8231,0,32,0,0,116,0,0,0,0,8231,0,1023,-1,-1,-1,-1),(3011,3,0,30375354,15756144,216,1569849562,5,32,1,8232,0,32,0,0,115,0,0,0,0,8232,0,1023,-1,-1,-1,-1),(3012,4,0,30360606,15770922,235,1569849542,0,0,1,7302,0,0,0,0,214,0,0,0,0,7302,0,1023,-1,-1,-1,-1),(3013,2,0,30369102,15740604,186,1569849607,0,0,1,7242,0,0,0,0,112,0,0,0,0,7242,0,1023,-1,-1,-1,-1),(3014,1,0,30360864,15770772,231,1569849618,0,0,1,7236,0,0,0,0,216,0,0,0,0,7236,0,1023,-1,-1,-1,-1),(3015,5,0,30360780,15770904,232,1569849619,0,0,1,8563,0,0,0,0,109,0,0,0,0,8563,0,1023,-1,-1,-1,-1),(3016,4,0,30360606,15770922,235,1569849602,0,0,1,7303,0,0,0,0,214,0,0,0,0,7303,0,1023,-1,-1,-1,-1),(3017,2,0,30369102,15740604,186,1569849667,0,0,1,7243,0,32,0,0,110,0,0,0,0,7243,0,1023,-1,-1,-1,-1);
/*!40000 ALTER TABLE `online` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `online64`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `online64` WRITE;
/*!40000 ALTER TABLE `online64` DISABLE KEYS */;
/*!40000 ALTER TABLE `online64` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `parameters`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `parameters` WRITE;
/*!40000 ALTER TABLE `parameters` DISABLE KEYS */;
INSERT INTO `parameters` VALUES (1,24,'False'),(2,18,'True'),(3,13,'False'),(4,22,'0'),(5,12,'False'),(6,21,'uk'),(7,19,'osm.lwco.biz'),(8,23,'15c7c70796ad393d3b627afaee71fccd'),(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');
/*!40000 ALTER TABLE `parameters` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `pcbdata`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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=30 DEFAULT CHARSET=cp1251 AVG_ROW_LENGTH=2340 COMMENT='Описание платы датчиков';
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `pcbversion`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Распределение данных для версии исполнения платы датчиков';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `pcbversion` WRITE;
/*!40000 ALTER TABLE `pcbversion` DISABLE KEYS */;
INSERT INTO `pcbversion` VALUES (18,'SCAD_37','для версии исполнения ПД SCAD',-1),(19,'SCAD_CAN64','для версии исполнения ПД SCAD',-1),(20,'SCAD_OBD II 64','для версии исполнения ПД SCAD',-1);
/*!40000 ALTER TABLE `pcbversion` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `points`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `points` WRITE;
/*!40000 ALTER TABLE `points` DISABLE KEYS */;
/*!40000 ALTER TABLE `points` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `relationalgorithms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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=11 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `relationalgorithms` WRITE;
/*!40000 ALTER TABLE `relationalgorithms` DISABLE KEYS */;
INSERT INTO `relationalgorithms` VALUES (1,4,1),(2,5,2),(3,4,3),(4,5,4),(5,4,5),(6,5,6),(7,4,7),(8,5,8),(9,4,9),(10,5,10);
/*!40000 ALTER TABLE `relationalgorithms` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `report_pass_zones`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Список зон, используемый в отчетах по пассажиропотоку.';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `report_pass_zones` WRITE;
/*!40000 ALTER TABLE `report_pass_zones` DISABLE KEYS */;
/*!40000 ALTER TABLE `report_pass_zones` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `route_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `route_items` WRITE;
/*!40000 ALTER TABLE `route_items` DISABLE KEYS */;
/*!40000 ALTER TABLE `route_items` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `route_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `route_list` WRITE;
/*!40000 ALTER TABLE `route_list` DISABLE KEYS */;
/*!40000 ALTER TABLE `route_list` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `route_lists`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `route_lists` WRITE;
/*!40000 ALTER TABLE `route_lists` DISABLE KEYS */;
/*!40000 ALTER TABLE `route_lists` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `route_mobitel_links`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `route_mobitel_links` WRITE;
/*!40000 ALTER TABLE `route_mobitel_links` DISABLE KEYS */;
/*!40000 ALTER TABLE `route_mobitel_links` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `route_mobitel_plans`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `route_mobitel_plans` WRITE;
/*!40000 ALTER TABLE `route_mobitel_plans` DISABLE KEYS */;
/*!40000 ALTER TABLE `route_mobitel_plans` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `route_points`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `route_points` WRITE;
/*!40000 ALTER TABLE `route_points` DISABLE KEYS */;
/*!40000 ALTER TABLE `route_points` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_events` WRITE;
/*!40000 ALTER TABLE `rt_events` DISABLE KEYS */;
INSERT INTO `rt_events` VALUES (1,'Въезд'),(2,'Выезд');
/*!40000 ALTER TABLE `rt_events` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_route`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_route` WRITE;
/*!40000 ALTER TABLE `rt_route` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_route` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_route_fuel`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_route_fuel` WRITE;
/*!40000 ALTER TABLE `rt_route_fuel` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_route_fuel` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_route_sensors`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_route_sensors` WRITE;
/*!40000 ALTER TABLE `rt_route_sensors` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_route_sensors` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_route_stops`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_route_stops` WRITE;
/*!40000 ALTER TABLE `rt_route_stops` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_route_stops` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_route_type`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_route_type` WRITE;
/*!40000 ALTER TABLE `rt_route_type` DISABLE KEYS */;
INSERT INTO `rt_route_type` VALUES (1,'Контрольные зоны'),(2,'Населенные пункты');
/*!40000 ALTER TABLE `rt_route_type` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_routet`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_routet` WRITE;
/*!40000 ALTER TABLE `rt_routet` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_routet` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_sample`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_sample` WRITE;
/*!40000 ALTER TABLE `rt_sample` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_sample` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_samplet`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_samplet` WRITE;
/*!40000 ALTER TABLE `rt_samplet` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_samplet` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_shedule`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Шапка документа ГРАФИК ДВИЖЕНИЯ';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_shedule` WRITE;
/*!40000 ALTER TABLE `rt_shedule` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_shedule` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_shedule_dc`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Шаблон шапки документа ГРАФИК ДВИЖЕНИЯ';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_shedule_dc` WRITE;
/*!40000 ALTER TABLE `rt_shedule_dc` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_shedule_dc` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_shedulet`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Содержимое документа ГРАФИК ДВИЖЕНИЯ';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_shedulet` WRITE;
/*!40000 ALTER TABLE `rt_shedulet` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_shedulet` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rt_shedulet_dc`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Шаблон содержимого документа ГРАФИК ДВИЖЕНИЯ';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rt_shedulet_dc` WRITE;
/*!40000 ALTER TABLE `rt_shedulet_dc` DISABLE KEYS */;
/*!40000 ALTER TABLE `rt_shedulet_dc` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `rules`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rules` WRITE;
/*!40000 ALTER TABLE `rules` DISABLE KEYS */;
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);
/*!40000 ALTER TABLE `rules` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `sensor_hookups`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `sensor_hookups` WRITE;
/*!40000 ALTER TABLE `sensor_hookups` DISABLE KEYS */;
/*!40000 ALTER TABLE `sensor_hookups` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `sensor_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `sensor_list` WRITE;
/*!40000 ALTER TABLE `sensor_list` DISABLE KEYS */;
/*!40000 ALTER TABLE `sensor_list` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `sensoralgorithms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `sensoralgorithms` WRITE;
/*!40000 ALTER TABLE `sensoralgorithms` DISABLE KEYS */;
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);
/*!40000 ALTER TABLE `sensoralgorithms` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `sensorcoefficient`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `sensorcoefficient` WRITE;
/*!40000 ALTER TABLE `sensorcoefficient` DISABLE KEYS */;
/*!40000 ALTER TABLE `sensorcoefficient` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `sensordata`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `sensordata` WRITE;
/*!40000 ALTER TABLE `sensordata` DISABLE KEYS */;
/*!40000 ALTER TABLE `sensordata` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `sensors`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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=11 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `sensors` WRITE;
/*!40000 ALTER TABLE `sensors` DISABLE KEYS */;
INSERT INTO `sensors` VALUES (1,3,'бортмережа','',32,8,'В',0.11810,0,0),(2,3,'запалювання','',61,1,'#',1.00000,0,0),(3,1,'бортмережа','',32,8,'В',0.11810,0,0),(4,1,'запалювання','',61,1,'#',1.00000,0,0),(5,5,'бортмережа','',32,8,'В',0.11810,0,0),(6,5,'запалювання','',61,1,'#',1.00000,0,0),(7,2,'бортмережа','',32,8,'В',0.11810,0,0),(8,2,'запалювання','',61,1,'#',1.00000,0,0),(9,4,'бортмережа','',32,8,'В',0.11810,0,0),(10,4,'запалювання','',61,1,'#',1.00000,0,0);
/*!40000 ALTER TABLE `sensors` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `serviceinit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `serviceinit` WRITE;
/*!40000 ALTER TABLE `serviceinit` DISABLE KEYS */;
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);
/*!40000 ALTER TABLE `serviceinit` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `servicesend`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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=11 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `servicesend` WRITE;
/*!40000 ALTER TABLE `servicesend` DISABLE KEYS */;
INSERT INTO `servicesend` VALUES (1,'2538','Desctiption for Teletrack registered at 30.09.2019 15:46:04',0,0,'107',NULL,NULL,NULL,NULL,0,NULL,0),(2,'set','phone',1,0,'102',NULL,NULL,NULL,NULL,0,NULL,0),(3,'6091','Desctiption for Teletrack registered at 30.09.2019 15:46:48',3,0,'108',NULL,NULL,NULL,NULL,0,NULL,0),(4,'set','phone',3,0,'103',NULL,NULL,NULL,NULL,0,NULL,0),(5,'8865','Desctiption for Teletrack registered at 30.09.2019 15:47:12',5,0,'109',NULL,NULL,NULL,NULL,0,NULL,0),(6,'set','phone',5,0,'104',NULL,NULL,NULL,NULL,0,NULL,0),(7,'6079','Desctiption for Teletrack registered at 30.09.2019 15:47:59',7,0,'110',NULL,NULL,NULL,NULL,0,NULL,0),(8,'set','phone',7,0,'105',NULL,NULL,NULL,NULL,0,NULL,0),(9,'9004','Desctiption for Teletrack registered at 30.09.2019 15:48:21',9,0,'111',NULL,NULL,NULL,NULL,0,NULL,0),(10,'set','phone',9,0,'106',NULL,NULL,NULL,NULL,0,NULL,0);
/*!40000 ALTER TABLE `servicesend` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `servicetypes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `servicetypes` WRITE;
/*!40000 ALTER TABLE `servicetypes` DISABLE KEYS */;
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);
/*!40000 ALTER TABLE `servicetypes` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `setting`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `setting` WRITE;
/*!40000 ALTER TABLE `setting` DISABLE KEYS */;
INSERT INTO `setting` VALUES (1,'00:01:00',100,100,20,0,7,1,1,85,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);
/*!40000 ALTER TABLE `setting` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `smsnumbers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `smsnumbers` WRITE;
/*!40000 ALTER TABLE `smsnumbers` DISABLE KEYS */;
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');
/*!40000 ALTER TABLE `smsnumbers` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `sources`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `sources` WRITE;
/*!40000 ALTER TABLE `sources` DISABLE KEYS */;
/*!40000 ALTER TABLE `sources` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `specialmessages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `specialmessages` WRITE;
/*!40000 ALTER TABLE `specialmessages` DISABLE KEYS */;
/*!40000 ALTER TABLE `specialmessages` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `state`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Состояния автомобиля';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `state` WRITE;
/*!40000 ALTER TABLE `state` DISABLE KEYS */;
INSERT INTO `state` VALUES (1,0,0.1,'0',2),(2,1,1.1,'1',2),(3,0,0.1,'0',4),(4,1,1.1,'1',4),(5,0,0.1,'0',6),(6,1,1.1,'1',6),(7,0,0.1,'0',8),(8,1,1.1,'1',8),(9,0,0.1,'0',10),(10,1,1.1,'1',10);
/*!40000 ALTER TABLE `state` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `swupdate`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Обновление прошивки телетрека';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `swupdate` WRITE;
/*!40000 ALTER TABLE `swupdate` DISABLE KEYS */;
/*!40000 ALTER TABLE `swupdate` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `team`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `team` WRITE;
/*!40000 ALTER TABLE `team` DISABLE KEYS */;
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);
/*!40000 ALTER TABLE `team` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `telnumbers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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=112 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `telnumbers` WRITE;
/*!40000 ALTER TABLE `telnumbers` DISABLE KEYS */;
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,'2538',NULL,0,0,'+380981617735'),(103,'6091',NULL,0,0,'+380981617734'),(104,'8865',NULL,0,0,'+380981620590'),(105,'6079',NULL,0,0,'+380981617801'),(106,'9004',NULL,0,0,'+380981617752'),(107,'rcs','mtel',0,0,'+380981617735'),(108,'rcs','mtel',0,0,'+380981617734'),(109,'rcs','mtel',0,0,'+380981620590'),(110,'rcs','mtel',0,0,'+380981617801'),(111,'rcs','mtel',0,0,'+380981617752');
/*!40000 ALTER TABLE `telnumbers` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `temp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `temp` WRITE;
/*!40000 ALTER TABLE `temp` DISABLE KEYS */;
/*!40000 ALTER TABLE `temp` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `tmpdatagps`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `tmpdatagps` WRITE;
/*!40000 ALTER TABLE `tmpdatagps` DISABLE KEYS */;
/*!40000 ALTER TABLE `tmpdatagps` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `transition`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Переходы между состояниями';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `transition` WRITE;
/*!40000 ALTER TABLE `transition` DISABLE KEYS */;
INSERT INTO `transition` VALUES (1,1,2,'увімк.',2,'Default','Default',0,1),(2,2,1,'вимк.',2,'Default','Default',0,1),(3,3,4,'увімк.',4,'Default','Default',0,1),(4,4,3,'вимк.',4,'Default','Default',0,1),(5,5,6,'увімк.',6,'Default','Default',0,1),(6,6,5,'вимк.',6,'Default','Default',0,1),(7,7,8,'увімк.',8,'Default','Default',0,1),(8,8,7,'вимк.',8,'Default','Default',0,1),(9,9,10,'увімк.',10,'Default','Default',0,1),(10,10,9,'вимк.',10,'Default','Default',0,1);
/*!40000 ALTER TABLE `transition` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `users_acs_objects`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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=30 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `users_acs_objects` WRITE;
/*!40000 ALTER TABLE `users_acs_objects` DISABLE KEYS */;
INSERT INTO `users_acs_objects` VALUES (16,2,3,5),(17,2,3,6),(18,2,3,7),(19,2,3,8),(20,2,3,9),(21,2,3,10),(22,2,3,13),(23,2,3,14),(24,2,3,15),(25,2,3,16),(26,2,3,19),(27,2,3,20),(28,2,3,21),(29,2,3,22);
/*!40000 ALTER TABLE `users_acs_objects` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `users_acs_roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `users_acs_roles` WRITE;
/*!40000 ALTER TABLE `users_acs_roles` DISABLE KEYS */;
INSERT INTO `users_acs_roles` VALUES (1,'Администратор'),(2,'КБМ');
/*!40000 ALTER TABLE `users_acs_roles` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `users_actions_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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=6 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `users_actions_log` WRITE;
/*!40000 ALTER TABLE `users_actions_log` DISABLE KEYS */;
INSERT INTO `users_actions_log` VALUES (1,8,'2019-09-30 15:54:43',0,'25->0 Період згладжування','admin','MNK'),(2,8,'2019-09-30 15:54:43',0,'10->7 Поріг зливу','admin','MNK'),(3,8,'2019-09-30 15:54:43',0,'50->20 Поріг заправки','admin','MNK'),(4,8,'2019-09-30 15:54:43',0,'70->85 Максимальна швидкість руху, км/год','admin','MNK'),(5,8,'2019-09-30 15:54:43',0,'0->1 Не враховувати зливи у витратах','admin','MNK');
/*!40000 ALTER TABLE `users_actions_log` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `users_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `users_list` WRITE;
/*!40000 ALTER TABLE `users_list` DISABLE KEYS */;
INSERT INTO `users_list` VALUES (1,'Администратор','',_binary '�e�Y B/�A~Hg\�\�O��J?��~������z\�',1,1),(2,'КБМ','',_binary 'B\���3\�`G\�T�S[rP�ҙj\�Up��>s�\�\�x',0,2);
/*!40000 ALTER TABLE `users_list` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `users_reports_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `users_reports_list` WRITE;
/*!40000 ALTER TABLE `users_reports_list` DISABLE KEYS */;
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','Идентификация ТС');
/*!40000 ALTER TABLE `users_reports_list` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `vehicle`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `vehicle` WRITE;
/*!40000 ALTER TABLE `vehicle` DISABLE KEYS */;
INSERT INTO `vehicle` VALUES (1,'DAF','BK 3625 BB',6,1,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(2,'Volkswagen','BK 8028 AK',6,2,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(3,'Volkswagen','BK 0399 BB',6,3,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(4,'DAF','BK 8431 AX',6,4,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(5,'Peugeot','BK 3832 AK',6,5,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0);
/*!40000 ALTER TABLE `vehicle` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `vehicle_category`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `vehicle_category` WRITE;
/*!40000 ALTER TABLE `vehicle_category` DISABLE KEYS */;
/*!40000 ALTER TABLE `vehicle_category` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `vehicle_category2`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `vehicle_category2` WRITE;
/*!40000 ALTER TABLE `vehicle_category2` DISABLE KEYS */;
/*!40000 ALTER TABLE `vehicle_category2` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `vehicle_category3`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `vehicle_category3` WRITE;
/*!40000 ALTER TABLE `vehicle_category3` DISABLE KEYS */;
/*!40000 ALTER TABLE `vehicle_category3` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `vehicle_category4`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `vehicle_category4` WRITE;
/*!40000 ALTER TABLE `vehicle_category4` DISABLE KEYS */;
/*!40000 ALTER TABLE `vehicle_category4` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `vehicle_commentary`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Комментарий для машины';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `vehicle_commentary` WRITE;
/*!40000 ALTER TABLE `vehicle_commentary` DISABLE KEYS */;
/*!40000 ALTER TABLE `vehicle_commentary` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `ver`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `ver` WRITE;
/*!40000 ALTER TABLE `ver` DISABLE KEYS */;
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');
/*!40000 ALTER TABLE `ver` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `zone_category`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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='Категории для зон';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `zone_category` WRITE;
/*!40000 ALTER TABLE `zone_category` DISABLE KEYS */;
/*!40000 ALTER TABLE `zone_category` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `zone_category2`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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 для зон';
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `zone_category2` WRITE;
/*!40000 ALTER TABLE `zone_category2` DISABLE KEYS */;
/*!40000 ALTER TABLE `zone_category2` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `zonerelations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `zonerelations` WRITE;
/*!40000 ALTER TABLE `zonerelations` DISABLE KEYS */;
/*!40000 ALTER TABLE `zonerelations` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `zones`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `zones` WRITE;
/*!40000 ALTER TABLE `zones` DISABLE KEYS */;
/*!40000 ALTER TABLE `zones` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `zonesgroup`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
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;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `zonesgroup` WRITE;
/*!40000 ALTER TABLE `zonesgroup` DISABLE KEYS */;
INSERT INTO `zonesgroup` VALUES (1,'Все зоны','НЕ УДАЛЯТЬ! Корневой элемент дерева контрольных зон',NULL);
/*!40000 ALTER TABLE `zonesgroup` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Dumping events for database 'kbm'
--

--
-- Dumping routines for database 'kbm'
--
/*!50003 DROP FUNCTION IF EXISTS `CheckVersion` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_VALUE_ON_ZERO' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `CheckVersion`(maskVersion TINYTEXT) RETURNS tinyint(4)
    SQL SECURITY INVOKER
    COMMENT 'Проверка версии СУБД. Должна быть maskVersion или выше. Результа'
BEGIN
  DECLARE currentVersion TINYTEXT;
  SELECT Left(VERSION(), Length(maskVersion)) INTO currentVersion;
  RETURN currentVersion >= maskVersion;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP FUNCTION IF EXISTS `HaveSuperPrivileges` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_VALUE_ON_ZERO' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `HaveSuperPrivileges`() RETURNS tinyint(4)
    SQL SECURITY INVOKER
    COMMENT 'Проверка, имеет ли пользователь привилегию SUPER. Результат: 1 -'
BEGIN
  DECLARE usrstr TINYTEXT DEFAULT '';

  DECLARE usr TINYTEXT DEFAULT '';
  DECLARE hst TINYTEXT DEFAULT '';
  DECLARE pos TINYINT;

  SELECT USER() INTO usrstr;

  SELECT INSTR(usrstr, '@') INTO pos;


  SELECT Left(usrstr, pos - 1), Right(usrstr, Length(usrstr) - pos) INTO usr, hst;

  RETURN (
    SELECT COUNT(*) > 0
    FROM mysql.`user` u
    WHERE u.`User` = usr AND u.Host = hst AND Super_priv = 'Y'
  );
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `BMCTransferBuffer` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `BMCTransferBuffer`(IN DatagpsIsUpdated INT, IN Datagps64IsUpdated INT)
    COMMENT 'Обновление online* для BMC'
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckDB` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_VALUE_ON_ZERO' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CheckDB`()
    SQL SECURITY INVOKER
    COMMENT 'Проверка БД при подключении.'
BEGIN

  SELECT 'OK';

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckOdo` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `CleaningDataGpsLostOn` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `dataview` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `delDupSrvPacket` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `delDupSrvPacket`()
    SQL SECURITY INVOKER
    COMMENT 'Удаляет дубликаты SrvPacketID из таблицы datagpsbuffer_on64'
BEGIN

DROP TEMPORARY TABLE IF EXISTS tmp64;

DROP 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;

DROP TABLE IF EXISTS tmp64;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `DrListMobitelConfig` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DrListMobitelConfig`()
    SQL SECURITY INVOKER
    COMMENT 'Выборка настроек телетреков в режиме DirectOnline'
BEGIN
  SELECT m.Mobitel_id AS MobitelID, 
    imc.DevIdShort AS DevIdShort,
    cge.Pop3un AS Login, 
    cge.Pop3pw AS Password
  FROM Mobitels m JOIN ConfigMain cm ON m.Mobitel_id = cm.Mobitel_ID
    JOIN ConfigGprsEmail cge ON cm.ConfigGprsEmail_ID = cge.ID
    JOIN internalmobitelconfig imc ON m.InternalMobitelConfig_ID = imc.ID 
  WHERE (cge.ConfigGprsEmail_ID = (
      SELECT MAX(intCge.ConfigGprsEmail_ID)
      FROM ConfigGprsEmail intCge
      WHERE intCge.ID = cge.ID)) AND
    (imc.InternalMobitelConfig_ID = (
      SELECT MAX(intConf.InternalMobitelConfig_ID)
      FROM internalmobitelconfig intConf
      WHERE intConf.ID = imc.ID)) AND 
    (imc.devIdShort IS NOT NULL) AND (imc.devIdShort <> _cp1251 '')	AND 
    (cge.Pop3un IS NOT NULL) AND (cge.Pop3un <> _cp1251 '') 
  ORDER BY m.Mobitel_ID;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `DrTransferBuffer` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `DrTransferBuffer`()
    SQL SECURITY INVOKER
    COMMENT 'Переносит GPS данные DirectOnline из буферной таблицы в datagps'
BEGIN
  DECLARE MobitelIDInCursor INT; 
  DECLARE DataExists TINYINT DEFAULT 1; 
  
  DECLARE TmpMaxUnixTime INT; 

  DECLARE CursorMobitels CURSOR FOR
    SELECT DISTINCT(Mobitel_ID) FROM datagpsbuffer_dr;

  
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;


    
  
  
  DELETE o
  FROM online o, datagpsbuffer_dr dgb
  WHERE (o.Mobitel_ID = dgb.Mobitel_ID) AND (o.LogID = dgb.LogID);
  
  SET DataExists = 1;
  OPEN CursorMobitels;
  FETCH CursorMobitels INTO MobitelIDInCursor;
  WHILE DataExists = 1 DO
    
    SELECT COALESCE(MAX(UnixTime), 0) INTO TmpMaxUnixTime
    FROM online FORCE INDEX (IDX_Mobitelid)
    WHERE Mobitel_ID = MobitelIDInCursor;

    
    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_dr
      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;

    
    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 CursorMobitels INTO MobitelIDInCursor;
  END WHILE;
  CLOSE CursorMobitels;
   


  
  UPDATE datagps d, datagpsbuffer_dr 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
  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID);

  
  DELETE b
  FROM datagps d, datagpsbuffer_dr 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)
  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
  FROM datagpsbuffer_dr
  GROUP BY Mobitel_ID, LogID;

  
  TRUNCATE TABLE datagpsbuffer_dr;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `ExecuteQuery` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_VALUE_ON_ZERO' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ExecuteQuery`(IN sqlQuery TINYTEXT)
    SQL SECURITY INVOKER
BEGIN
  SET @s = sqlQuery;
  PREPARE stmt FROM @s;
  EXECUTE stmt;
  DEALLOCATE PREPARE stmt;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getDiapasone` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getDiapasone64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `hystoryOnline` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `IsTeletrackDatabase` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_VALUE_ON_ZERO' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `IsTeletrackDatabase`()
    SQL SECURITY INVOKER
    COMMENT 'Проверка базы данных на соответствие структуре системы Teletrack'
BEGIN
  DECLARE i TINYINT;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `new_proc` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_VALUE_ON_ZERO' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `new_proc`(IN sensor INTEGER(11), IN m_id INTEGER(11), IN s_id INTEGER(11), IN begin_time DATETIME, IN end_time DATETIME)
    READS SQL DATA
    SQL SECURITY INVOKER
BEGIN                                                                                                                                      
select                                                                                                                                     
    round((`datagps`.`Longitude` / 600000),6) AS `lon`,                                                                                    
    round((`datagps`.`Latitude` / 600000),6) AS `lat`,                                                                                     
    `datagps`.`Mobitel_ID` AS `Mobitel_ID`,                                                                                                
    `sensordata`.`Value` AS `Value`,                                                                                                       
    (`datagps`.`Speed` * 1.852) AS `speed`,                                                                                                
    from_unixtime(`datagps`.`UnixTime`) AS `time`,                                                                                         
    `sensordata`.`sensor_id` AS `sensor_id`,                                                                                               
    `datagps`.`DataGps_ID` AS `datagps_id`,                                                                                                
    `datagps`.`Sensor1`&`sensor` AS `sensor`                                                                                              
  from                                                                                                                                     
    (`sensordata` join `datagps` on((`sensordata`.`datagps_id` = `datagps`.`DataGps_ID`)))                                                 
  where                                                                                                                                    
    (`datagps`.`Valid` = 1) and                                                                                                            
    ( datagps.UnixTime BETWEEN UNIX_TIMESTAMP(begin_time) and UNIX_TIMESTAMP(end_time))                                                    
    and datagps.Mobitel_ID = m_id AND sensordata.sensor_id = s_id                                                                          
  order by                                                                                                                                 
    `datagps`.`UnixTime`,`datagps`.`Mobitel_ID`,`sensordata`.`sensor_id`;                                                                  
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnCorrectInfotrackLogId` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnCorrectInfotrackLogId64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnDeleteDuplicates` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnDeleteDuplicates64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnDeleteLostRange` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnInsertDatagpsLost` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `online` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnListMobitelConfig` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnListMobitelConfig64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnLostDataGPS` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnLostDataGPS2` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnLostDataGPS264` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnLostDataGPS64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnTransferBuffer` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnTransferBuffer64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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;

DROP 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 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `PopListMobitelConfig` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `PopListMobitelConfig`()
    SQL SECURITY INVOKER
    COMMENT 'Выборка настроек телетреков для работы в режиме POP3'
BEGIN
  SELECT m.Mobitel_ID AS MobitelID, c.devIdShort AS DevIdShort,
    COALESCE(
      (SELECT s.EmailMobitel 
       FROM Mobitels m2 JOIN ServiceSend s ON s.ID = m2.ServiceSend_ID 
       WHERE m2.Mobitel_ID = m.Mobitel_ID
       ORDER BY s.ServiceSend_ID DESC
       LIMIT 1), "") AS Email
  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;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `PopTransferBuffer` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `PopTransferBuffer`()
    SQL SECURITY INVOKER
    COMMENT 'Переносит GPS данные из буферной таблицы в datagps'
BEGIN
  DECLARE MobitelIDInCursor INT; 
  DECLARE DataExists TINYINT DEFAULT 1; 
  
  DECLARE TmpMaxUnixTime INT; 

  DECLARE CursorMobitels CURSOR FOR
    SELECT DISTINCT(Mobitel_ID) FROM datagpsbuffer_pop;

  
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

    
  
  
  DELETE o
  FROM online o, datagpsbuffer_pop dgb
  WHERE (o.Mobitel_ID = dgb.Mobitel_ID) AND (o.LogID = dgb.LogID);
  
  SET DataExists = 1;
  OPEN CursorMobitels;
  FETCH CursorMobitels INTO MobitelIDInCursor;
  WHILE DataExists = 1 DO
    
    SELECT COALESCE(MAX(UnixTime), 0) INTO TmpMaxUnixTime
    FROM online FORCE INDEX (IDX_Mobitelid)
    WHERE Mobitel_ID = MobitelIDInCursor;

    
    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_pop
      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;

    
    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 CursorMobitels INTO MobitelIDInCursor;
  END WHILE;
  CLOSE CursorMobitels;
    

  
  UPDATE datagps d, datagpsbuffer_pop 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
  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID);

  
  DELETE b
  FROM datagps d, datagpsbuffer_pop 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)
  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
  FROM datagpsbuffer_pop
  GROUP BY Mobitel_ID, LogID;

  
  TRUNCATE TABLE datagpsbuffer_pop;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `RfFillLostDataGPS` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `RfFillLostDataGPS`()
    COMMENT 'Поиск пропусков в RF данных и заполнение таблицы datagpslost'
BEGIN
  DECLARE MobitelIDInCursor INT; 
  DECLARE DataExists TINYINT DEFAULT 1; 
  DECLARE NeedOptimize TINYINT DEFAULT 0; 
  DECLARE NeedOptimizeParam TINYINT;

  
  DECLARE CursorMobitels CURSOR FOR
    SELECT m.Mobitel_ID AS Mobitel_ID
    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.moduleIdRf IS NOT NULL) AND (c.moduleIdRf <> _cp1251'')
    ORDER BY m.Mobitel_ID;
  
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;
  
  SET DataExists = 1;
  
  
  DELETE d
  FROM datagpslost d
  WHERE NOT EXISTS(
    SELECT 1
    FROM mobitels m
    WHERE m.Mobitel_ID = d.Mobitel_ID);
  
  
  OPEN CursorMobitels;
  FETCH CursorMobitels INTO MobitelIDInCursor;
  WHILE DataExists = 1 DO
    CALL RfLostDataGPS(MobitelIDInCursor, NeedOptimizeParam);
    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);
    FETCH CursorMobitels INTO MobitelIDInCursor;
  END WHILE;
  CLOSE CursorMobitels;

  
  IF NeedOptimize = 1 THEN
    OPTIMIZE TABLE datagpslost;
  END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `RfListMobitelConfig` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `RfListMobitelConfig`()
    COMMENT 'Выборка RF настроек телетреков'
BEGIN
  DECLARE MobitelIDInCursor INT;
  DECLARE NameInCursor CHAR(50);
  DECLARE DescrInCursor CHAR(200);
  DECLARE ConfirmedIDInCursor INT;
  DECLARE moduleIdRfInCursor CHAR(50);
  DECLARE LastInsertTimeInCursor DateTime;
  DECLARE DataExists TINYINT DEFAULT 1;

  
  DECLARE CursorMobitels CURSOR FOR
    SELECT m.Mobitel_ID AS Mobitel_ID,
      m.Name AS Name,
      m.Descr AS Descr,
      m.ConfirmedID AS ConfirmedID,
      c.moduleIdRf AS moduleIdRf,
      FROM_UNIXTIME(m.LastInsertTime) AS LastInsertTime
    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.moduleIdRf IS NOT NULL) AND (c.moduleIdRf <> _cp1251'')
    ORDER BY m.Mobitel_ID;

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  
  CREATE TEMPORARY TABLE tmpMobitelsConfig (
    Mobitel_ID INT NOT NULL,
    Name CHAR(50),
    Descr CHAR(200),
    ConfirmedID INT NOT NULL,
    moduleIdRf CHAR(50) NOT NULL,
    LastInsertTime DateTime NOT NULL,
    LastLogID INT NOT NULL) ENGINE = MEMORY;

  OPEN CursorMobitels;
  FETCH CursorMobitels INTO MobitelIDInCursor, NameInCursor, DescrInCursor, 
    ConfirmedIDInCursor, moduleIdRfInCursor, LastInsertTimeInCursor;
  WHILE DataExists = 1 DO

    INSERT INTO tmpMobitelsConfig SELECT MobitelIDInCursor, NameInCursor, DescrInCursor, 
      ConfirmedIDInCursor, moduleIdRfInCursor, LastInsertTimeInCursor,
      (SELECT COALESCE(MAX(LogID), 0)
       FROM datagps
       WHERE Mobitel_ID = MobitelIDInCursor) AS LastLogID;

    FETCH CursorMobitels INTO MobitelIDInCursor, NameInCursor, DescrInCursor, 
    ConfirmedIDInCursor, moduleIdRfInCursor, LastInsertTimeInCursor;
  END WHILE;
  CLOSE CursorMobitels;

  SELECT Mobitel_ID, Name, Descr, ConfirmedID, moduleIdRf, LastInsertTime, LastLogID
  FROM tmpMobitelsConfig;

  DROP TEMPORARY TABLE tmpMobitelsConfig;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `RfLostDataGPS` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `RfLostDataGPS`(IN MobitelID INTEGER(11), OUT NeedOptimize TINYINT)
    COMMENT 'Поиск пропусков в RF данных заданного телетрека и заполнение таб'
BEGIN
  
  DECLARE MAX_RECORD_COUNT INT DEFAULT 33792;
  DECLARE FirstActualLogID INT; 

  DECLARE CurrentConfirmedID INT; 
  DECLARE NewConfirmedID INT DEFAULT 0; 
  DECLARE NewStartLogIDSelect INT DEFAULT 0; 
  DECLARE MaxMobitelLogID INT; 

  DECLARE BeginLogIDInCursor INT; 
  DECLARE EndLogIDInCursor INT; 
  DECLARE CountInLostRange INT; 
  DECLARE DataExists TINYINT DEFAULT 1; 
  DECLARE DataChanged TINYINT DEFAULT 0; 
  DECLARE NeedAnalyze TINYINT DEFAULT 0; 
  
  DECLARE NewRowCount INT DEFAULT 0; 
  
  DECLARE NewLogID INT; 
  DECLARE FirstLogID INT DEFAULT -9999999; 
  DECLARE SecondLogID INT; 
                                                                                    
  
  
  DECLARE CursorLostData CURSOR FOR
    SELECT Begin_LogID, End_LogID
    FROM datagpslost
    WHERE Mobitel_ID = MobitelID
    ORDER BY Begin_LogID;
    
  
  DECLARE CursorNewLogID CURSOR FOR
    SELECT LogID 
    FROM datagpslost_rftmp;
    
  
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  SET DataExists = 1;
  SET NeedOptimize = 0;
 
  SELECT COALESCE(ConfirmedID, 0) INTO CurrentConfirmedID
  FROM mobitels
  WHERE Mobitel_ID = MobitelID;

  
  SELECT COALESCE(MAX(LogID), 0) INTO MaxMobitelLogID
  FROM datagps
  WHERE (Mobitel_ID = MobitelID);

  IF CurrentConfirmedID <> MaxMobitelLogID THEN
    
    SET FirstActualLogID = MaxMobitelLogID - MAX_RECORD_COUNT;
    IF FirstActualLogID < 0 THEN
      SET FirstActualLogID = 0;
    END IF;

    
    DELETE FROM datagpslost
    WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID < FirstActualLogID);
    
    
    OPEN CursorLostData;
    FETCH CursorLostData INTO BeginLogIDInCursor, EndLogIDInCursor;
    
    
    IF DataExists = 0 THEN
      SET DataChanged = 0;
      SET NeedAnalyze = 1;
      
      SET NewStartLogIDSelect = GREATEST(CurrentConfirmedID, FirstActualLogID);
    END IF;

    
    WHILE DataExists = 1 DO
      
      SELECT COUNT(1) INTO CountInLostRange
      FROM datagps
      WHERE (Mobitel_ID = MobitelID) AND
        (LogID > BeginLogIDInCursor) AND (LogID < EndLogIDInCursor);

      
      IF (CountInLostRange > 0)  THEN
        
        DELETE FROM datagpslost
        WHERE (Mobitel_ID = MobitelID) AND (Begin_LogID >= BeginLogIDInCursor);

        SET DataChanged = 1;
        SET NeedAnalyze = 1;
        SET NewStartLogIDSelect = BeginLogIDInCursor;
        
        
        SET DataExists = 0;
      ELSE
        FETCH CursorLostData INTO BeginLogIDInCursor, EndLogIDInCursor;
      END IF;	
    END WHILE;
    CLOSE CursorLostData;
   
    
       
    IF (NeedAnalyze = 0) AND (EndLogIDInCursor < MaxMobitelLogID) THEN
      SET NewStartLogIDSelect = EndLogIDInCursor;
      SET NeedAnalyze = 1;
    END IF;
   
    

    IF NeedAnalyze = 1 THEN
      TRUNCATE TABLE datagpslost_rftmp;

      
      INSERT INTO datagpslost_rftmp	(LogID)
      SELECT DISTINCT(LogID)
      FROM datagps
      WHERE (Mobitel_ID = MobitelID) AND (LogID >= NewStartLogIDSelect)
      ORDER BY LogID;
      
      
      SET @InsertLostDataStatement = 
        "INSERT INTO datagpslost(Mobitel_ID, Begin_LogID, End_LogID) VALUES ";
      
      
      SET DataExists = 1;
      OPEN CursorNewLogID;
      FETCH CursorNewLogID INTO NewLogID;
      WHILE DataExists = 1 DO
        IF FirstLogID = -9999999 THEN
          
          SET FirstLogID = NewLogID;
        ELSE
          
          SET SecondLogID = NewLogID;
          IF (SecondLogID -	FirstLogID) > 1 THEN
            
            IF NewRowCount > 0 THEN
              SET @InsertLostDataStatement = 
                CONCAT(@InsertLostDataStatement, ",");
            END IF;
            SET @InsertLostDataStatement = 
              CONCAT(@InsertLostDataStatement, 
                " (", MobitelID, ", ", FirstLogID, ", ", SecondLogID, ")");
            
            SET NewRowCount = NewRowCount + 1;
          END IF;
          
          SET	FirstLogID = SecondLogID;
        END IF;	
        FETCH CursorNewLogID INTO NewLogID;
      END WHILE;
      CLOSE CursorNewLogID;
      
        
      IF NewRowCount > 0 THEN
        
        PREPARE stmt FROM @InsertLostDataStatement;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
        
        SET DataChanged = 1;
      END IF; 
             
      
      
      SELECT COALESCE(MIN(Begin_LogID), -1) INTO NewConfirmedID
      FROM datagpslost
      WHERE Mobitel_ID = MobitelID;

      
      IF NewConfirmedID = -1 THEN
        SET NewConfirmedID = MaxMobitelLogID;
      END IF;

      
      IF NewConfirmedID > CurrentConfirmedID THEN
        UPDATE mobitels
        SET ConfirmedID = NewConfirmedID
        WHERE (Mobitel_ID = MobitelID) AND (ConfirmedID < NewConfirmedID);
      END IF;
      
      TRUNCATE TABLE datagpslost_rftmp;
    END IF;	 
    
    IF DataChanged = 1 THEN
      SET NeedOptimize = 1;
    END IF;
  
  END IF;	
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `RfMobitelConfig` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `RfMobitelConfig`(IN paramMobitelID INTEGER(11))
    COMMENT 'Выборка RF настроек заданного телетрека'
BEGIN
SELECT
  m.Mobitel_ID AS Mobitel_ID,
  m.Name AS Name,
  m.Descr AS Descr,
  m.ConfirmedID AS ConfirmedID,
  c.moduleIdRf AS moduleIdRf,
  FROM_UNIXTIME(m.LastInsertTime) AS LastInsertTime,
  ( SELECT COALESCE(d.LogID, 0)
    FROM datagps d
    WHERE d.Mobitel_ID = m.Mobitel_ID
    ORDER BY d.LogID DESC
    LIMIT 1 ) AS LastLogID
FROM mobitels m
  JOIN internalmobitelconfig c ON (c.ID = m.InternalMobitelConfig_ID)
WHERE (m.Mobitel_ID = paramMobitelID) AND
  (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.moduleIdRf IS NOT NULL) AND (c.moduleIdRf <> _cp1251'')
ORDER BY m.Mobitel_ID;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `RfTransferBuffer` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `RfTransferBuffer`()
    SQL SECURITY INVOKER
    COMMENT 'Переносит GPS данные из буферной таблицы в datagps.'
BEGIN

  DECLARE MobitelIDInCursor INT; 
  DECLARE DataExists TINYINT DEFAULT 1; 
  DECLARE NeedOptimize TINYINT DEFAULT 0; 
  DECLARE NeedOptimizeParam TINYINT;
  DECLARE TmpMaxUnixTime INT; 

  DECLARE CursorMobitels CURSOR FOR
    SELECT DISTINCT(Mobitel_ID) FROM datagpsbuffer;

  
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;
  
    
  
  
  DELETE o
  FROM online o, datagpsbuffer_pop dgb
  WHERE (o.Mobitel_ID = dgb.Mobitel_ID) AND (o.LogID = dgb.LogID);
  
  SET DataExists = 1;
  OPEN CursorMobitels;
  FETCH CursorMobitels INTO MobitelIDInCursor;
  WHILE DataExists = 1 DO
    
    SELECT COALESCE(MAX(UnixTime), 0) INTO TmpMaxUnixTime
    FROM online FORCE INDEX (IDX_Mobitelid)
    WHERE Mobitel_ID = MobitelIDInCursor;

    
    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
      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; 

    
    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 CursorMobitels INTO MobitelIDInCursor;
  END WHILE;
  CLOSE CursorMobitels;
    


  
  UPDATE datagps d, datagpsbuffer b SET
    d.Message_ID = 0, 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.isShow = 0,
    d.whatIs = b.whatIs,
    d.Counter1 = b.Counter1,
    d.Counter2 = b.Counter2,
    d.Counter3 = b.Counter3,
    d.Counter4 = b.Counter4
  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID);

  
  DELETE b
  FROM datagps d, datagpsbuffer 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)
  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
  FROM datagpsbuffer
  GROUP BY Mobitel_ID, LogID;

  
  SET DataExists = 1;
  OPEN CursorMobitels;
  FETCH CursorMobitels INTO MobitelIDInCursor;
  WHILE DataExists = 1 DO
    
    UPDATE mobitels SET LastInsertTime = UNIX_TIMESTAMP(NOW())
    WHERE Mobitel_ID = MobitelIDInCursor;
        
    
    CALL RfLostDataGPS(MobitelIDInCursor, NeedOptimizeParam);
    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);
    
    FETCH CursorMobitels INTO MobitelIDInCursor;
  END WHILE;
  CLOSE CursorMobitels;

  
  TRUNCATE TABLE datagpsbuffer;

  
  IF NeedOptimize = 1 THEN
    OPTIMIZE TABLE datagpslost;
  END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `SelectDataGpsPeriodAll` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
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 ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `TestP` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_VALUE_ON_ZERO' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `TestP`()
BEGIN
  SELECT VERSION();
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `TransferBuffer` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_VALUE_ON_ZERO' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `TransferBuffer`()
    SQL SECURITY INVOKER
    COMMENT 'Переносит GPS данные из буферной таблицы в datagps.'
BEGIN





CREATE TEMPORARY TABLE IF NOT EXISTS temp1 ENGINE=HEAP(
  SELECT DataGPS_ID FROM datagpsbuffer
  );



UPDATE datagps d, datagpsbuffer b, temp1 t SET
  d.Message_ID = 0, 
  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 = NULL, 
  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.isShow = 0, 
  d.whatIs = b.whatIs,
  d.Counter1 = b.Counter1,
  d.Counter2 = b.Counter2,
  d.Counter3 = b.Counter3,
  d.Counter4 = b.Counter4
WHERE b.DataGps_ID = t.DataGps_ID
  AND d.Mobitel_ID = b.Mobitel_ID
  AND d.LogID = b.LogID;


DELETE b
FROM datagps d, datagpsbuffer b, temp1 t
WHERE b.DataGps_ID = t.DataGps_ID
  AND 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`,
  Sensor1,
  Sensor2,
  Sensor3,
  Sensor4,
  Sensor5,
  Sensor6,
  Sensor7,
  Sensor8,
  Counter1,
  Counter2,
  Counter3,
  Counter4,
  whatIs
  )
SELECT
  b.Mobitel_ID,
  b.LogID,
  b.UnixTime,
  b.Latitude,
  b.Longitude,
  b.Altitude,
  b.Direction,
  b.Speed,
  b.Valid,
  b.`Events`,
  b.Sensor1,
  b.Sensor2,
  b.Sensor3,
  b.Sensor4,
  b.Sensor5,
  b.Sensor6,
  b.Sensor7,
  b.Sensor8,
  b.Counter1,
  b.Counter2,
  b.Counter3,
  b.Counter4,
  b.whatIs
FROM datagpsbuffer b, temp1 t
WHERE b.DataGps_ID = t.DataGps_ID
GROUP BY b.Mobitel_ID, b.LogID;


DELETE b
FROM datagpsbuffer b, temp1 t
WHERE b.DataGps_ID = t.DataGps_ID;


DROP TEMPORARY TABLE temp1;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `TransferLiteBuffer` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'NO_AUTO_VALUE_ON_ZERO' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `TransferLiteBuffer`()
    SQL SECURITY INVOKER
    COMMENT 'Переносит GPS данные из буферной таблицы в datagps.'
BEGIN





CREATE TEMPORARY TABLE IF NOT EXISTS temp2 ENGINE=HEAP(
  SELECT DataGPS_ID FROM datagpsbufferlite
  );



UPDATE datagps d, datagpsbuffer b, temp2 t SET
  d.Message_ID = b.Message_ID,
  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 = NULL, 
  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.isShow = b.IsShow,
  d.whatIs = b.whatIs,
  d.Counter1 = b.Counter1,
  d.Counter2 = b.Counter2,
  d.Counter3 = b.Counter3,
  d.Counter4 = b.Counter4
WHERE b.DataGps_ID = t.DataGps_ID
  AND d.Mobitel_ID = b.Mobitel_ID
  AND d.Latitude = b.Latitude
  AND d.Longitude = b.Longitude
  AND d.Altitude = b.Altitude
  AND d.UnixTime = b.UnixTime;


DELETE b
FROM datagps d, datagpsbufferlite b, temp2 t
WHERE b.DataGps_ID = t.DataGps_ID
  AND d.Mobitel_ID = b.Mobitel_ID
  AND d.Latitude = b.Latitude
  AND d.Longitude = b.Longitude
  AND d.Altitude = b.Altitude
  AND d.UnixTime = b.UnixTime;


INSERT INTO datagps
  (
  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
  b.Mobitel_ID,
  b.LogID,
  b.UnixTime,
  b.Latitude,
  b.Longitude,
  b.Altitude,
  b.Direction,
  b.Speed,
  b.Valid,
  b.`Events`,
  b.Sensor1,
  b.Sensor2,
  b.Sensor3,
  b.Sensor4,
  b.Sensor5,
  b.Sensor6,
  b.Sensor7,
  b.Sensor8,
  b.Counter1,
  b.Counter2,
  b.Counter3,
  b.Counter4,
  b.whatIs
FROM datagpsbufferlite b, temp2 t
WHERE b.DataGps_ID = t.DataGps_ID
GROUP BY b.Mobitel_ID, b.LogID, b.Latitude, b.Longitude, b.Altitude, b.UnixTime;


DELETE b
FROM datagpsbufferlite b, temp2 t
WHERE b.DataGps_ID = t.DataGps_ID;


DROP TEMPORARY TABLE temp2;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;

--
-- Final view structure for view `datavalue1`
--

/*!50001 DROP VIEW IF EXISTS `datavalue1`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `datavalue1` AS select round((`datagps`.`Longitude` / 600000),6) AS `lon`,round((`datagps`.`Latitude` / 600000),6) AS `lat`,`datagps`.`Mobitel_ID` AS `Mobitel_ID`,`sensordata`.`Value` AS `Value`,(`datagps`.`Speed` * 1.852) AS `speed`,from_unixtime(`datagps`.`UnixTime`) AS `time`,`sensordata`.`sensor_id` AS `sensor_id`,`datagps`.`DataGps_ID` AS `datavalue_id` from (`sensordata` join `datagps` on((`sensordata`.`datagps_id` = `datagps`.`DataGps_ID`))) where (`datagps`.`Valid` = 1) order by `datagps`.`UnixTime`,`datagps`.`Mobitel_ID`,`sensordata`.`sensor_id` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `dataview`
--

/*!50001 DROP VIEW IF EXISTS `dataview`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `dataview` AS select `datagps`.`DataGps_ID` AS `DataGps_ID`,`datagps`.`Mobitel_ID` AS `Mobitel_ID`,(`datagps`.`Latitude` / 600000.00000) AS `Lat`,(`datagps`.`Longitude` / 600000.00000) AS `Lon`,`datagps`.`Altitude` AS `Altitude`,from_unixtime(`datagps`.`UnixTime`) AS `time`,(`datagps`.`Speed` * 1.852) AS `speed`,((`datagps`.`Direction` * 360) / 255) AS `direction`,`datagps`.`Valid` AS `Valid`,(((((((`datagps`.`Sensor8` + (`datagps`.`Sensor7` << 8)) + (`datagps`.`Sensor6` << 16)) + (`datagps`.`Sensor5` << 24)) + (`datagps`.`Sensor4` << 32)) + (`datagps`.`Sensor3` << 40)) + (`datagps`.`Sensor2` << 48)) + (`datagps`.`Sensor1` << 56)) AS `sensor`,`datagps`.`Events` AS `Events`,`datagps`.`LogID` AS `LogID` from `datagps` order by `datagps`.`LogID` */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `deviceview`
--

/*!50001 DROP VIEW IF EXISTS `deviceview`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=MERGE */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `deviceview` AS (select `m`.`Mobitel_ID` AS `Mobitel_ID`,`m`.`Name` AS `Name`,`m`.`Descr` AS `Descr`,`c`.`devIdShort` AS `devIdShort`,`m`.`DeviceType` AS `DeviceType`,`m`.`ConfirmedID` AS `ConfirmedID`,`c`.`moduleIdRf` AS `moduleIdRf` from ((`mobitels` `m` join `internalmobitelconfig` `c`) join `internalmobitelconfigview` `v`) where ((`v`.`ID` = `m`.`InternalMobitelConfig_ID`) and (`v`.`LastRecord` = `c`.`InternalMobitelConfig_ID`)) order by `m`.`Name`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;

--
-- Final view structure for view `internalmobitelconfigview`
--

/*!50001 DROP VIEW IF EXISTS `internalmobitelconfigview`*/;
/*!50001 SET @saved_cs_client          = @@character_set_client */;
/*!50001 SET @saved_cs_results         = @@character_set_results */;
/*!50001 SET @saved_col_connection     = @@collation_connection */;
/*!50001 SET character_set_client      = utf8 */;
/*!50001 SET character_set_results     = utf8 */;
/*!50001 SET collation_connection      = utf8_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `internalmobitelconfigview` AS (select `c`.`ID` AS `ID`,max(`c`.`InternalMobitelConfig_ID`) AS `LastRecord` from `internalmobitelconfig` `c` where (`c`.`devIdShort` <> _cp1251'') group by `c`.`ID`) */;
/*!50001 SET character_set_client      = @saved_cs_client */;
/*!50001 SET character_set_results     = @saved_cs_results */;
/*!50001 SET collation_connection      = @saved_col_connection */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2024-02-07 10:14:46
