CREATE DATABASE  IF NOT EXISTS `lohvytsya_service` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `lohvytsya_service`;
-- MySQL dump 10.13  Distrib 8.0.36, for Win64 (x86_64)
--
-- Host: 127.0.0.1    Database: lohvytsya_service
-- ------------------------------------------------------
-- Server version	8.0.40

/*!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 NOT NULL AUTO_INCREMENT,
  `Number` int 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 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `tmr1Log` int DEFAULT '0',
  `tmr2Send` int DEFAULT '0',
  `tmr3Zone` int DEFAULT '0',
  `dist1Log` int DEFAULT '0',
  `dist2Send` int DEFAULT '0',
  `dist3Zone` int DEFAULT '0',
  `deltaTimeZone` int DEFAULT '0',
  `gprsEmail` int NOT NULL DEFAULT '0',
  `gprsFtp` int NOT NULL DEFAULT '0',
  `gprsSocket` int NOT NULL DEFAULT '0',
  `maskSensor` char(50) DEFAULT NULL,
  `maskEvent1` int DEFAULT '0',
  `maskEvent2` int DEFAULT '0',
  `maskEvent3` int DEFAULT '0',
  `maskEvent4` int DEFAULT '0',
  `maskEvent5` int DEFAULT '0',
  `maskEvent6` int DEFAULT '0',
  `maskEvent7` int DEFAULT '0',
  `maskEvent8` int DEFAULT '0',
  `maskEvent9` int DEFAULT '0',
  `maskEvent10` int DEFAULT '0',
  `maskEvent11` int DEFAULT '0',
  `maskEvent12` int DEFAULT '0',
  `maskEvent13` int DEFAULT '0',
  `maskEvent14` int DEFAULT '0',
  `maskEvent15` int DEFAULT '0',
  `maskEvent16` int DEFAULT '0',
  `maskEvent17` int DEFAULT '0',
  `maskEvent18` int DEFAULT '0',
  `maskEvent19` int DEFAULT '0',
  `maskEvent20` int DEFAULT '0',
  `maskEvent21` int DEFAULT '0',
  `maskEvent22` int DEFAULT '0',
  `maskEvent23` int DEFAULT '0',
  `maskEvent24` int DEFAULT '0',
  `maskEvent25` int DEFAULT '0',
  `maskEvent26` int DEFAULT '0',
  `maskEvent27` int DEFAULT '0',
  `maskEvent28` int DEFAULT '0',
  `maskEvent29` int DEFAULT '0',
  `maskEvent30` int DEFAULT '0',
  `maskEvent31` int DEFAULT '0',
  PRIMARY KEY (`ConfigEvent_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 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,'','',1,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
/*!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 NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int 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=2 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,'','',1,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 NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int 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 NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `Mode` int 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=2 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,'','',1,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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `ConfigOther_ID` int DEFAULT '0',
  `ConfigDriverMessage_ID` int DEFAULT '0',
  `ConfigEvent_ID` int DEFAULT '0',
  `ConfigUnique_ID` int DEFAULT '0',
  `ConfigZoneSet_ID` int DEFAULT '0',
  `ConfigSensorSet_ID` int DEFAULT '0',
  `ConfigTel_ID` int DEFAULT '0',
  `ConfigSms_ID` int DEFAULT '0',
  `Mobitel_ID` int DEFAULT '0',
  `ConfigGprsMain_ID` int NOT NULL DEFAULT '0',
  `ConfigGprsEmail_ID` int NOT NULL DEFAULT '0',
  `ConfigGprsInit_ID` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`ConfigMain_ID`),
  KEY `Index_2` (`Mobitel_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 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,'','',0,0,50,50,1,50,50,50,1,1,926036787,1,1,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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Pin` int DEFAULT '0',
  `Lang` int DEFAULT '0',
  `Message_ID` int 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `smsCenter_ID` int DEFAULT '0',
  `smsDspt_ID` int DEFAULT '0',
  `smsEmailGate_ID` int DEFAULT '0',
  `dsptEmail` char(14) DEFAULT NULL,
  `dsptGprsEmail` char(50) DEFAULT NULL,
  PRIMARY KEY (`ConfigSms_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 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,'','',1,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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `telSOS` int DEFAULT '0',
  `telDspt` int DEFAULT '0',
  `telAccept1` int DEFAULT '0',
  `telAccept2` int DEFAULT '0',
  `telAccept3` int DEFAULT '0',
  `telAnswer` int DEFAULT '0',
  PRIMARY KEY (`ConfigTel_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 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,'','',1,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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `Message_ID` int 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 NOT NULL AUTO_INCREMENT,
  `DataGps_ID` int DEFAULT NULL,
  `Zone_ID` int DEFAULT NULL,
  `Zone_IO` int 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 NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `Latitude` int DEFAULT '0',
  `Longitude` int DEFAULT '0',
  `Altitude` int DEFAULT NULL,
  `UnixTime` int DEFAULT '0',
  `Speed` smallint DEFAULT '0',
  `Direction` int NOT NULL DEFAULT '0',
  `Valid` tinyint DEFAULT '1',
  `InMobitelID` int DEFAULT NULL,
  `Events` int unsigned DEFAULT '0',
  `Sensor1` tinyint unsigned DEFAULT '0',
  `Sensor2` tinyint unsigned DEFAULT '0',
  `Sensor3` tinyint unsigned DEFAULT '0',
  `Sensor4` tinyint unsigned DEFAULT '0',
  `Sensor5` tinyint unsigned DEFAULT '0',
  `Sensor6` tinyint unsigned DEFAULT '0',
  `Sensor7` tinyint unsigned DEFAULT '0',
  `Sensor8` tinyint unsigned DEFAULT '0',
  `LogID` int DEFAULT '0',
  `isShow` tinyint DEFAULT '0',
  `whatIs` smallint unsigned DEFAULT '0',
  `Counter1` int NOT NULL DEFAULT '-1',
  `Counter2` int NOT NULL DEFAULT '-1',
  `Counter3` int NOT NULL DEFAULT '-1',
  `Counter4` int NOT NULL DEFAULT '-1',
  `SrvPacketID` bigint 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 AUTO_INCREMENT=441 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 */;
INSERT INTO `datagps` VALUES (1,926036787,0,30185692,19931545,109,1780381931,11,51,1,1,0,0,0,0,0,0,0,0,0,1,0,1023,-1,-1,-1,-1,0),(2,926036787,0,30185741,19931911,108,1780381942,5,39,1,2,0,0,0,0,0,0,0,0,0,2,0,1023,-1,-1,-1,-1,0),(3,926036787,0,30185752,19931929,108,1780381943,6,25,1,3,0,0,0,0,0,0,0,0,0,3,0,1023,-1,-1,-1,-1,0),(4,926036787,0,30185772,19931943,108,1780381944,8,10,1,4,0,0,0,0,0,0,0,0,0,4,0,1023,-1,-1,-1,-1,0),(5,926036787,0,30187042,19932481,112,1780381974,20,8,1,5,0,0,0,0,0,0,0,0,0,5,0,1023,-1,-1,-1,-1,0),(6,926036787,0,30188865,19933228,105,1780382004,24,5,1,6,0,0,0,0,0,0,0,0,0,6,0,1023,-1,-1,-1,-1,0),(7,926036787,0,30190716,19933669,113,1780382034,5,239,1,7,0,0,0,0,0,0,0,0,0,7,0,1023,-1,-1,-1,-1,0),(8,926036787,0,30192418,19934049,113,1780382064,18,3,1,8,0,0,0,0,0,0,0,0,0,8,0,1023,-1,-1,-1,-1,0),(9,926036787,0,30194697,19934602,113,1780382094,30,4,1,9,0,0,0,0,0,0,0,0,0,9,0,1023,-1,-1,-1,-1,0),(10,926036787,0,30197234,19935278,112,1780382124,31,8,1,10,0,0,0,0,0,0,0,0,0,10,0,1023,-1,-1,-1,-1,0),(11,926036787,0,30199547,19936260,113,1780382154,29,13,1,11,0,0,0,0,0,0,0,0,0,11,0,1023,-1,-1,-1,-1,0),(12,926036787,0,30201899,19937658,111,1780382184,29,10,1,12,0,0,0,0,0,0,0,0,0,12,0,1023,-1,-1,-1,-1,0),(13,926036787,0,30202528,19937753,112,1780382192,24,0,1,13,0,0,0,0,0,0,0,0,0,13,0,1023,-1,-1,-1,-1,0),(14,926036787,0,30202859,19937792,113,1780382199,15,15,1,14,0,0,0,0,0,0,0,0,0,14,0,1023,-1,-1,-1,-1,0),(15,926036787,0,30202930,19937878,114,1780382201,18,29,1,15,0,0,0,0,0,0,0,0,0,15,0,1023,-1,-1,-1,-1,0),(16,926036787,0,30204734,19940279,110,1780382231,32,26,1,16,0,0,0,0,0,0,0,0,0,16,0,1023,-1,-1,-1,-1,0),(17,926036787,0,30206813,19943231,109,1780382261,32,32,1,17,0,0,0,0,0,0,0,0,0,17,0,1023,-1,-1,-1,-1,0),(18,926036787,0,30208061,19945613,111,1780382291,25,37,1,18,0,0,0,0,0,0,0,0,0,18,0,1023,-1,-1,-1,-1,0),(19,926036787,0,30209300,19948536,109,1780382321,31,37,1,19,0,0,0,0,0,0,0,0,0,19,0,1023,-1,-1,-1,-1,0),(20,926036787,0,30210887,19952001,105,1780382351,33,31,1,20,0,0,0,0,0,0,0,0,0,20,0,1023,-1,-1,-1,-1,0),(21,926036787,0,30212624,19955221,105,1780382381,30,29,1,21,0,0,0,0,0,0,0,0,0,21,0,1023,-1,-1,-1,-1,0),(22,926036787,0,30212969,19955564,104,1780382386,30,19,1,22,0,0,0,0,0,0,0,0,0,22,0,1023,-1,-1,-1,-1,0),(23,926036787,0,30213535,19956148,102,1780382394,30,29,1,23,0,0,0,0,0,0,0,0,0,23,0,1023,-1,-1,-1,-1,0),(24,926036787,0,30213842,19956760,100,1780382400,30,44,1,24,0,0,0,0,0,0,0,0,0,24,0,1023,-1,-1,-1,-1,0),(25,926036787,0,30214414,19960743,107,1780382430,29,52,1,25,0,0,0,0,0,0,0,0,0,25,0,1023,-1,-1,-1,-1,0),(26,926036787,0,30214552,19961588,105,1780382438,23,41,1,26,0,0,0,0,0,0,0,0,0,26,0,1023,-1,-1,-1,-1,0),(27,926036787,0,30214652,19961756,104,1780382440,23,26,1,27,0,0,0,0,0,0,0,0,0,27,0,1023,-1,-1,-1,-1,0),(28,926036787,0,30215755,19962937,90,1780382467,13,15,1,28,0,0,0,0,0,0,0,0,0,28,0,1023,-1,-1,-1,-1,0),(29,926036787,0,30215813,19963014,93,1780382469,12,31,1,29,0,0,0,0,0,0,0,0,0,29,0,1023,-1,-1,-1,-1,0),(30,926036787,0,30215830,19963070,93,1780382470,13,41,1,30,0,0,0,0,0,0,0,0,0,30,0,1023,-1,-1,-1,-1,0),(31,926036787,0,30215851,19963206,93,1780382472,16,55,1,31,0,0,0,0,0,0,0,0,0,31,0,1023,-1,-1,-1,-1,0),(32,926036787,0,30215844,19963431,94,1780382475,16,67,1,32,0,0,0,0,0,0,0,0,0,32,0,1023,-1,-1,-1,-1,0),(33,926036787,0,30215739,19963999,97,1780382484,10,53,1,33,0,0,0,0,0,0,0,0,0,33,0,1023,-1,-1,-1,-1,0),(34,926036787,0,30215756,19964028,98,1780382485,9,41,1,34,0,0,0,0,0,0,0,0,0,34,0,1023,-1,-1,-1,-1,0),(35,926036787,0,30215778,19964040,99,1780382486,7,25,1,35,0,0,0,0,0,0,0,0,0,35,0,1023,-1,-1,-1,-1,0),(36,926036787,0,30215810,19964010,100,1780382487,7,229,1,36,0,0,0,0,0,0,0,0,0,36,0,1023,-1,-1,-1,-1,0),(37,926036787,0,30215838,19963978,101,1780382488,9,213,1,37,0,0,0,0,0,0,0,0,0,37,0,1023,-1,-1,-1,-1,0),(38,926036787,0,30215876,19963912,102,1780382490,10,199,1,38,0,0,0,0,0,0,0,0,0,38,0,1023,-1,-1,-1,-1,0),(39,926036787,0,30216058,19963271,106,1780382503,10,215,1,39,0,0,0,0,0,0,0,0,0,39,0,1023,-1,-1,-1,-1,0),(40,926036787,0,30216085,19963251,106,1780382504,10,226,1,40,0,0,0,0,0,0,0,0,0,40,0,1023,-1,-1,-1,-1,0),(41,926036787,0,30216142,19963235,106,1780382506,10,236,1,41,0,0,0,0,0,0,0,0,0,41,0,1023,-1,-1,-1,-1,0),(42,926036787,0,30216234,19963237,107,1780382514,0,3,1,42,0,0,0,0,0,0,0,0,0,42,0,1023,-1,-1,-1,-1,0),(43,926036787,0,30216297,19963225,107,1780382519,8,233,1,43,0,0,0,0,0,0,0,0,0,43,0,1023,-1,-1,-1,-1,0),(44,926036787,0,30217534,19963206,105,1780382549,17,238,1,44,0,0,0,0,0,0,0,0,0,44,0,1023,-1,-1,-1,-1,0),(45,926036787,0,30219087,19963115,104,1780382579,15,237,1,45,0,0,0,0,0,0,0,0,0,45,0,1023,-1,-1,-1,-1,0),(46,926036787,0,30220245,19963052,105,1780382609,13,239,1,46,0,0,0,0,0,0,0,0,0,46,0,1023,-1,-1,-1,-1,0),(47,926036787,0,30220317,19963033,105,1780382611,13,228,1,47,0,0,0,0,0,0,0,0,0,47,0,1023,-1,-1,-1,-1,0),(48,926036787,0,30220377,19962976,106,1780382613,12,209,1,48,0,0,0,0,0,0,0,0,0,48,0,1023,-1,-1,-1,-1,0),(49,926036787,0,30220399,19962934,107,1780382614,13,198,1,49,0,0,0,0,0,0,0,0,0,49,0,1023,-1,-1,-1,-1,0),(50,926036787,0,30220864,19960907,106,1780382644,19,192,1,50,0,0,0,0,0,0,0,0,0,50,0,1023,-1,-1,-1,-1,0),(51,926036787,0,30221359,19958763,110,1780382674,16,197,1,51,0,0,0,0,0,0,0,0,0,51,0,1023,-1,-1,-1,-1,0),(52,926036787,0,30221754,19957584,108,1780382693,17,208,1,52,0,0,0,0,0,0,0,0,0,52,0,1023,-1,-1,-1,-1,0),(53,926036787,0,30221830,19957491,107,1780382695,17,219,1,53,0,0,0,0,0,0,0,0,0,53,0,1023,-1,-1,-1,-1,0),(54,926036787,0,30221975,19957399,107,1780382698,19,229,1,54,0,0,0,0,0,0,0,0,0,54,0,1023,-1,-1,-1,-1,0),(55,926036787,0,30222610,19957003,108,1780382709,23,219,1,55,0,0,0,0,0,0,0,0,0,55,0,1023,-1,-1,-1,-1,0),(56,926036787,0,30223153,19956300,108,1780382720,24,209,1,56,0,0,0,0,0,0,0,0,0,56,0,1023,-1,-1,-1,-1,0),(57,926036787,0,30224390,19953780,106,1780382750,19,205,1,57,0,0,0,0,0,0,0,0,0,57,0,1023,-1,-1,-1,-1,0),(58,926036787,0,30225229,19952039,105,1780382780,16,205,1,58,0,0,0,0,0,0,0,0,0,58,0,1023,-1,-1,-1,-1,0),(59,926036787,0,30226158,19950132,104,1780382810,18,199,1,59,0,0,0,0,0,0,0,0,0,59,0,1023,-1,-1,-1,-1,0),(60,926036787,0,30226310,19949525,104,1780382818,20,189,1,60,0,0,0,0,0,0,0,0,0,60,0,1023,-1,-1,-1,-1,0),(61,926036787,0,30226343,19948903,107,1780382825,19,175,1,61,0,0,0,0,0,0,0,0,0,61,0,1023,-1,-1,-1,-1,0),(62,926036787,0,30226093,19945878,104,1780382855,22,179,1,62,0,0,0,0,0,0,0,0,0,62,0,1023,-1,-1,-1,-1,0),(63,926036787,0,30226172,19944906,103,1780382865,21,190,1,63,0,0,0,0,0,0,0,0,0,63,0,1023,-1,-1,-1,-1,0),(64,926036787,0,30226899,19942390,114,1780382895,19,198,1,64,0,0,0,0,0,0,0,0,0,64,0,1023,-1,-1,-1,-1,0),(65,926036787,0,30227613,19939869,116,1780382925,21,193,1,65,0,0,0,0,0,0,0,0,0,65,0,1023,-1,-1,-1,-1,0),(66,926036787,0,30228181,19936920,126,1780382955,25,191,1,66,0,0,0,0,0,0,0,0,0,66,0,1023,-1,-1,-1,-1,0),(67,926036787,0,30229068,19933588,129,1780382985,28,198,1,67,0,0,0,0,0,0,0,0,0,67,0,1023,-1,-1,-1,-1,0),(68,926036787,0,30230188,19930367,144,1780383015,28,198,1,68,0,0,0,0,0,0,0,0,0,68,0,1023,-1,-1,-1,-1,0),(69,926036787,0,30231173,19927965,153,1780383037,29,208,1,69,0,0,0,0,0,0,0,0,0,69,0,1023,-1,-1,-1,-1,0),(70,926036787,0,30233097,19925329,160,1780383067,30,212,1,70,0,0,0,0,0,0,0,0,0,70,0,1023,-1,-1,-1,-1,0),(71,926036787,0,30234943,19922920,169,1780383097,29,213,1,71,0,0,0,0,0,0,0,0,0,71,0,1023,-1,-1,-1,-1,0),(72,926036787,0,30251684,18256967,164,1778147387,0,47,1,72,0,0,0,0,0,0,0,0,0,72,0,1023,-1,-1,-1,-1,0),(73,926036787,0,30251684,18256967,164,1778147207,0,47,1,73,0,0,0,0,0,0,0,0,0,73,0,1023,-1,-1,-1,-1,0),(74,926036787,0,30251684,18256967,164,1778147027,0,47,1,74,0,0,0,0,0,0,0,0,0,74,0,1023,-1,-1,-1,-1,0),(75,926036787,0,30251684,18256967,164,1778146847,0,47,1,75,0,0,0,0,0,0,0,0,0,75,0,1023,-1,-1,-1,-1,0),(76,926036787,0,30251684,18256967,164,1778146667,0,47,1,76,0,0,0,0,0,0,0,0,0,76,0,1023,-1,-1,-1,-1,0),(77,926036787,0,30251684,18256967,164,1778146487,0,47,1,77,0,0,0,0,0,0,0,0,0,77,0,1023,-1,-1,-1,-1,0),(78,926036787,0,30251684,18256967,164,1778146307,0,47,1,78,0,0,0,0,0,0,0,0,0,78,0,1023,-1,-1,-1,-1,0),(79,926036787,0,30251684,18256967,164,1778146127,0,47,1,79,0,0,0,0,0,0,0,0,0,79,0,1023,-1,-1,-1,-1,0),(80,926036787,0,30251684,18256967,164,1778145947,0,47,1,80,0,0,0,0,0,0,0,0,0,80,0,1023,-1,-1,-1,-1,0),(81,926036787,0,30251684,18256967,164,1778145767,0,47,1,81,0,0,0,0,0,0,0,0,0,81,0,1023,-1,-1,-1,-1,0),(82,926036787,0,30251684,18256967,164,1778145587,0,47,1,82,0,0,0,0,0,0,0,0,0,82,0,1023,-1,-1,-1,-1,0),(83,926036787,0,30251684,18256967,164,1778145407,0,47,1,83,0,0,0,0,0,0,0,0,0,83,0,1023,-1,-1,-1,-1,0),(84,926036787,0,30251684,18256967,164,1778145227,0,47,1,84,0,0,0,0,0,0,0,0,0,84,0,1023,-1,-1,-1,-1,0),(85,926036787,0,30251684,18256967,164,1778145047,0,47,1,85,0,0,0,0,0,0,0,0,0,85,0,1023,-1,-1,-1,-1,0),(86,926036787,0,30251684,18256967,164,1778144867,0,47,1,86,0,0,0,0,0,0,0,0,0,86,0,1023,-1,-1,-1,-1,0),(87,926036787,0,30251684,18256967,164,1778144687,0,47,1,87,0,0,0,0,0,0,0,0,0,87,0,1023,-1,-1,-1,-1,0),(88,926036787,0,30251684,18256967,164,1778144507,0,47,1,88,0,0,0,0,0,0,0,0,0,88,0,1023,-1,-1,-1,-1,0),(89,926036787,0,30251684,18256967,164,1778144327,0,47,1,89,0,0,0,0,0,0,0,0,0,89,0,1023,-1,-1,-1,-1,0),(90,926036787,0,30251684,18256967,164,1778144147,0,47,1,90,0,0,0,0,0,0,0,0,0,90,0,1023,-1,-1,-1,-1,0),(91,926036787,0,30251684,18256967,164,1778143967,0,47,1,91,0,0,0,0,0,0,0,0,0,91,0,1023,-1,-1,-1,-1,0),(92,926036787,0,30251684,18256967,164,1778143787,0,47,1,92,0,0,0,0,0,0,0,0,0,92,0,1023,-1,-1,-1,-1,0),(93,926036787,0,30251684,18256967,164,1778143607,0,47,1,93,0,0,0,0,0,0,0,0,0,93,0,1023,-1,-1,-1,-1,0),(94,926036787,0,30251684,18256967,164,1778143427,0,47,1,94,0,0,0,0,0,0,0,0,0,94,0,1023,-1,-1,-1,-1,0),(95,926036787,0,30238859,19917288,158,1780383171,22,201,1,95,0,0,0,0,0,0,0,0,0,95,0,1023,-1,-1,-1,-1,0),(96,926036787,0,30238668,19917539,153,1780383167,22,212,1,96,0,0,0,0,0,0,0,0,0,96,0,1023,-1,-1,-1,-1,0),(97,926036787,0,30238424,19917815,152,1780383163,17,201,1,97,0,0,0,0,0,0,0,0,0,97,0,1023,-1,-1,-1,-1,0),(98,926036787,0,30238347,19917948,154,1780383162,12,191,1,98,0,0,0,0,0,0,0,0,0,98,0,1023,-1,-1,-1,-1,0),(99,926036787,0,30238228,19918199,155,1780383157,20,203,1,99,0,0,0,0,0,0,0,0,0,99,0,1023,-1,-1,-1,-1,0),(100,926036787,0,30236676,19920471,156,1780383127,26,209,1,100,0,0,0,0,0,0,0,0,0,100,0,1023,-1,-1,-1,-1,0),(101,926036787,0,30239006,19917066,159,1780383175,19,211,1,101,0,0,0,0,0,0,0,0,0,101,0,1023,-1,-1,-1,-1,0),(102,926036787,0,30239155,19916854,153,1780383179,15,197,1,102,0,0,0,0,0,0,0,0,0,102,0,1023,-1,-1,-1,-1,0),(103,926036787,0,30239269,19916659,155,1780383182,19,209,1,103,0,0,0,0,0,0,0,0,0,103,0,1023,-1,-1,-1,-1,0),(104,926036787,0,30240647,19914725,180,1780383212,22,208,1,104,0,0,0,0,0,0,0,0,0,104,0,1023,-1,-1,-1,-1,0),(105,926036787,0,30241416,19913194,179,1780383234,19,198,1,105,0,0,0,0,0,0,0,0,0,105,0,1023,-1,-1,-1,-1,0),(106,926036787,0,30242587,19910970,183,1780383264,23,205,1,106,0,0,0,0,0,0,0,0,0,106,0,1023,-1,-1,-1,-1,0),(107,926036787,0,30243927,19908391,194,1780383294,29,207,1,107,0,0,0,0,0,0,0,0,0,107,0,1023,-1,-1,-1,-1,0),(108,926036787,0,30245526,19905573,186,1780383324,11,224,1,108,0,0,0,0,0,0,0,0,0,108,0,1023,-1,-1,-1,-1,0),(109,926036787,0,30245547,19905564,186,1780383325,9,235,1,109,0,0,0,0,0,0,0,0,0,109,0,1023,-1,-1,-1,-1,0),(110,926036787,0,30245568,19905568,186,1780383326,8,7,1,110,0,0,0,0,0,0,0,0,0,110,0,1023,-1,-1,-1,-1,0),(111,926036787,0,30245587,19905586,186,1780383327,8,21,1,111,0,0,0,0,0,0,0,0,0,111,0,1023,-1,-1,-1,-1,0),(112,926036787,0,30245602,19905614,186,1780383328,8,32,1,112,0,0,0,0,0,0,0,0,0,112,0,1023,-1,-1,-1,-1,0),(113,926036787,0,30245669,19905705,185,1780383332,9,17,1,113,0,0,0,0,0,0,0,0,0,113,0,1023,-1,-1,-1,-1,0),(114,926036787,0,30245709,19905795,185,1780383335,8,33,1,114,0,0,0,0,0,0,0,0,0,114,0,1023,-1,-1,-1,-1,0),(115,926036787,0,30245731,19905805,184,1780383337,5,22,1,115,0,0,0,0,0,0,0,0,0,115,0,1023,-1,-1,-1,-1,0),(116,926036787,0,30245767,19905854,181,1780383344,0,25,1,116,0,0,0,0,0,0,0,0,0,116,0,1023,-1,-1,-1,-1,0),(117,926036787,0,30245767,19905854,181,1780383374,0,25,1,117,0,0,0,0,0,0,0,0,0,117,0,1023,-1,-1,-1,-1,0),(118,926036787,0,30245767,19905854,181,1780383404,0,25,1,118,0,0,0,0,0,0,0,0,0,118,0,1023,-1,-1,-1,-1,0),(119,926036787,0,30245767,19905854,181,1780383434,0,25,1,119,0,0,0,0,0,0,0,0,0,119,0,1023,-1,-1,-1,-1,0),(120,926036787,0,30245767,19905854,181,1780383464,0,25,1,120,0,0,0,0,0,0,0,0,0,120,0,1023,-1,-1,-1,-1,0),(121,926036787,0,30245707,19905760,182,1780383466,8,147,1,121,0,0,0,0,0,0,0,0,0,121,0,1023,-1,-1,-1,-1,0),(122,926036787,0,30245576,19905546,180,1780383473,9,166,1,122,0,0,0,0,0,0,0,0,0,122,0,1023,-1,-1,-1,-1,0),(123,926036787,0,30245571,19905502,180,1780383474,9,177,1,123,0,0,0,0,0,0,0,0,0,123,0,1023,-1,-1,-1,-1,0),(124,926036787,0,30245574,19905463,179,1780383475,8,189,1,124,0,0,0,0,0,0,0,0,0,124,0,1023,-1,-1,-1,-1,0),(125,926036787,0,30245653,19905320,179,1780383479,11,205,1,125,0,0,0,0,0,0,0,0,0,125,0,1023,-1,-1,-1,-1,0),(126,926036787,0,30246945,19903315,179,1780383509,21,209,1,126,0,0,0,0,0,0,0,0,0,126,0,1023,-1,-1,-1,-1,0),(127,926036787,0,30247283,19902651,181,1780383518,21,198,1,127,0,0,0,0,0,0,0,0,0,127,0,1023,-1,-1,-1,-1,0),(128,926036787,0,30248126,19900085,171,1780383548,22,204,1,128,0,0,0,0,0,0,0,0,0,128,0,1023,-1,-1,-1,-1,0),(129,926036787,0,30248712,19899156,166,1780383561,22,214,1,129,0,0,0,0,0,0,0,0,0,129,0,1023,-1,-1,-1,-1,0),(130,926036787,0,30250740,19896643,142,1780383591,37,214,1,130,0,0,0,0,0,0,0,0,0,130,0,1023,-1,-1,-1,-1,0),(131,926036787,0,30252846,19893966,119,1780383621,17,215,1,131,0,0,0,0,0,0,0,0,0,131,0,1023,-1,-1,-1,-1,0),(132,926036787,0,30252934,19893861,120,1780383624,9,201,1,132,0,0,0,0,0,0,0,0,0,132,0,1023,-1,-1,-1,-1,0),(133,926036787,0,30252942,19893828,120,1780383625,8,188,1,133,0,0,0,0,0,0,0,0,0,133,0,1023,-1,-1,-1,-1,0),(134,926036787,0,30252940,19893795,120,1780383626,8,171,1,134,0,0,0,0,0,0,0,0,0,134,0,1023,-1,-1,-1,-1,0),(135,926036787,0,30252929,19893768,120,1780383627,7,161,1,135,0,0,0,0,0,0,0,0,0,135,0,1023,-1,-1,-1,-1,0),(136,926036787,0,30217270,19967086,95,1780327172,0,202,1,136,0,0,0,0,0,0,0,0,0,136,0,1023,-1,-1,-1,-1,0),(137,926036787,0,30217270,19967086,95,1780326992,0,202,1,137,0,0,0,0,0,0,0,0,0,137,0,1023,-1,-1,-1,-1,0),(138,926036787,0,30217270,19967086,95,1780326812,0,202,1,138,0,0,0,0,0,0,0,0,0,138,0,1023,-1,-1,-1,-1,0),(139,926036787,0,30217270,19967086,95,1780326631,0,202,1,139,0,0,0,0,0,0,0,0,0,139,0,1023,-1,-1,-1,-1,0),(140,926036787,0,30217270,19967086,95,1780326452,0,202,1,140,0,0,0,0,0,0,0,0,0,140,0,1023,-1,-1,-1,-1,0),(141,926036787,0,30217270,19967086,95,1780326272,0,202,1,141,0,0,0,0,0,0,0,0,0,141,0,1023,-1,-1,-1,-1,0),(142,926036787,0,30252850,19893633,120,1780383636,0,152,1,142,0,0,0,0,0,0,0,0,0,142,0,1023,-1,-1,-1,-1,0),(143,926036787,0,30252895,19893718,120,1780383629,8,149,1,143,0,0,0,0,0,0,0,0,0,143,0,1023,-1,-1,-1,-1,0),(144,926036787,0,30215904,19963114,111,1780380223,6,167,1,144,0,0,0,0,0,0,0,0,0,144,0,1023,-1,-1,-1,-1,0),(145,926036787,0,30215915,19963260,112,1780380219,7,181,1,145,0,0,0,0,0,0,0,0,0,145,0,1023,-1,-1,-1,-1,0),(146,926036787,0,30215792,19963844,108,1780380203,6,193,1,146,0,0,0,0,0,0,0,0,0,146,0,1023,-1,-1,-1,-1,0),(147,926036787,0,30215786,19963878,108,1780380202,6,181,1,147,0,0,0,0,0,0,0,0,0,147,0,1023,-1,-1,-1,-1,0),(148,926036787,0,30215794,19963930,108,1780380200,7,163,1,148,0,0,0,0,0,0,0,0,0,148,0,1023,-1,-1,-1,-1,0),(149,926036787,0,30215802,19963945,108,1780380199,8,151,1,149,0,0,0,0,0,0,0,0,0,149,0,1023,-1,-1,-1,-1,0),(150,926036787,0,30215824,19963966,109,1780380197,9,134,1,150,0,0,0,0,0,0,0,0,0,150,0,1023,-1,-1,-1,-1,0),(151,926036787,0,30216403,19963962,110,1780380176,11,120,1,151,0,0,0,0,0,0,0,0,0,151,0,1023,-1,-1,-1,-1,0),(152,926036787,0,30217478,19963914,110,1780380146,6,117,1,152,0,0,0,0,0,0,0,0,0,152,0,1023,-1,-1,-1,-1,0),(153,926036787,0,30217579,19963918,109,1780380142,4,127,1,153,0,0,0,0,0,0,0,0,0,153,0,1023,-1,-1,-1,-1,0),(154,926036787,0,30217600,19963926,109,1780380141,4,137,1,154,0,0,0,0,0,0,0,0,0,154,0,1023,-1,-1,-1,-1,0),(155,926036787,0,30217616,19963939,109,1780380140,4,151,1,155,0,0,0,0,0,0,0,0,0,155,0,1023,-1,-1,-1,-1,0),(156,926036787,0,30217628,19963962,109,1780380138,5,168,1,156,0,0,0,0,0,0,0,0,0,156,0,1023,-1,-1,-1,-1,0),(157,926036787,0,30217630,19963968,110,1780380137,5,155,1,157,0,0,0,0,0,0,0,0,0,157,0,1023,-1,-1,-1,-1,0),(158,926036787,0,30217633,19963973,110,1780380136,6,169,1,158,0,0,0,0,0,0,0,0,0,158,0,1023,-1,-1,-1,-1,0),(159,926036787,0,30217630,19964841,109,1780380114,9,180,1,159,0,0,0,0,0,0,0,0,0,159,0,1023,-1,-1,-1,-1,0),(160,926036787,0,30217641,19966026,112,1780380084,5,179,1,160,0,0,0,0,0,0,0,0,0,160,0,1023,-1,-1,-1,-1,0),(161,926036787,0,30217646,19966803,118,1780380054,5,179,1,161,0,0,0,0,0,0,0,0,0,161,0,1023,-1,-1,-1,-1,0),(162,926036787,0,30217643,19966855,118,1780380052,5,189,1,162,0,0,0,0,0,0,0,0,0,162,0,1023,-1,-1,-1,-1,0),(163,926036787,0,30217638,19966880,118,1780380051,5,201,1,163,0,0,0,0,0,0,0,0,0,163,0,1023,-1,-1,-1,-1,0),(164,926036787,0,30217626,19966901,119,1780380050,4,211,1,164,0,0,0,0,0,0,0,0,0,164,0,1023,-1,-1,-1,-1,0),(165,926036787,0,30217447,19966965,119,1780380037,5,232,1,165,0,0,0,0,0,0,0,0,0,165,0,1023,-1,-1,-1,-1,0),(166,926036787,0,30217438,19966971,119,1780380036,5,221,1,166,0,0,0,0,0,0,0,0,0,166,0,1023,-1,-1,-1,-1,0),(167,926036787,0,30217403,19967003,120,1780380033,4,211,1,167,0,0,0,0,0,0,0,0,0,167,0,1023,-1,-1,-1,-1,0),(168,926036787,0,30217311,19966964,113,1780379858,0,15,1,168,0,0,0,0,0,0,0,0,0,168,0,1023,-1,-1,-1,-1,0),(169,926036787,0,30252838,19893673,120,1780383964,0,135,1,169,0,16,0,1,192,61,144,0,0,169,0,1023,-1,-1,-1,-1,0),(170,926036787,0,30252838,19893673,120,1780383904,0,135,1,170,0,16,0,1,192,61,160,0,0,170,0,1023,-1,-1,-1,-1,0),(171,926036787,0,30252838,19893673,120,1780383844,0,135,1,171,0,16,0,1,192,61,160,0,0,171,0,1023,-1,-1,-1,-1,0),(172,926036787,0,30252838,19893673,120,1780383784,0,135,1,172,0,16,0,1,192,61,240,0,0,172,0,1023,-1,-1,-1,-1,0),(173,926036787,0,30252838,19893673,120,1780383723,0,135,1,173,0,16,0,1,192,62,112,0,0,173,0,1023,-1,-1,-1,-1,0),(174,926036787,0,30252838,19893673,120,1780383663,0,135,1,174,0,16,0,1,192,62,128,0,0,174,0,1023,-1,-1,-1,-1,0),(175,926036787,0,30215858,19962997,111,1780380226,8,152,1,175,0,0,0,0,0,0,0,0,0,175,0,1023,-1,-1,-1,-1,0),(176,926036787,0,30215537,19962644,111,1780380237,13,142,1,176,0,0,0,0,0,0,0,0,0,176,0,1023,-1,-1,-1,-1,0),(177,926036787,0,30214616,19961624,109,1780380267,12,149,1,177,0,0,0,0,0,0,0,0,0,177,0,1023,-1,-1,-1,-1,0),(178,926036787,0,30214572,19961494,110,1780380269,16,163,1,178,0,0,0,0,0,0,0,0,0,178,0,1023,-1,-1,-1,-1,0),(179,926036787,0,30214392,19960207,109,1780380282,27,173,1,179,0,0,0,0,0,0,0,0,0,179,0,1023,-1,-1,-1,-1,0),(180,926036787,0,30213828,19956520,107,1780380311,28,159,1,180,0,0,0,0,0,0,0,0,0,180,0,1023,-1,-1,-1,-1,0),(181,926036787,0,30213600,19956151,104,1780380315,28,148,1,181,0,0,0,0,0,0,0,0,0,181,0,1023,-1,-1,-1,-1,0),(182,926036787,0,30213200,19955685,107,1780380322,26,137,1,182,0,0,0,0,0,0,0,0,0,182,0,1023,-1,-1,-1,-1,0),(183,926036787,0,30212641,19955125,108,1780380331,28,149,1,183,0,0,0,0,0,0,0,0,0,183,0,1023,-1,-1,-1,-1,0),(184,926036787,0,30210821,19951814,109,1780380361,36,151,1,184,0,0,0,0,0,0,0,0,0,184,0,1023,-1,-1,-1,-1,0),(185,926036787,0,30209081,19947895,105,1780380391,37,157,1,185,0,0,0,0,0,0,0,0,0,185,0,1023,-1,-1,-1,-1,0),(186,926036787,0,30207222,19943881,108,1780380421,39,152,1,186,0,0,0,0,0,0,0,0,0,186,0,1023,-1,-1,-1,-1,0),(187,926036787,0,30204794,19940398,122,1780380451,40,145,1,187,0,0,0,0,0,0,0,0,0,187,0,1023,-1,-1,-1,-1,0),(188,926036787,0,30202823,19937729,110,1780380478,18,134,1,188,0,0,0,0,0,0,0,0,0,188,0,1023,-1,-1,-1,-1,0),(189,926036787,0,30202728,19937711,107,1780380480,17,122,1,189,0,0,0,0,0,0,0,0,0,189,0,1023,-1,-1,-1,-1,0),(190,926036787,0,30202589,19937735,105,1780380483,16,110,1,190,0,0,0,0,0,0,0,0,0,190,0,1023,-1,-1,-1,-1,0),(191,926036787,0,30202445,19937749,102,1780380486,16,123,1,191,0,0,0,0,0,0,0,0,0,191,0,1023,-1,-1,-1,-1,0),(192,926036787,0,30201758,19937543,108,1780380498,23,133,1,192,0,0,0,0,0,0,0,0,0,192,0,1023,-1,-1,-1,-1,0),(193,926036787,0,30199483,19936170,113,1780380528,32,133,1,193,0,0,0,0,0,0,0,0,0,193,0,1023,-1,-1,-1,-1,0),(194,926036787,0,30196916,19935138,108,1780380558,31,127,1,194,0,0,0,0,0,0,0,0,0,194,0,1023,-1,-1,-1,-1,0),(195,926036787,0,30194307,19934506,104,1780380588,32,125,1,195,0,0,0,0,0,0,0,0,0,195,0,1023,-1,-1,-1,-1,0),(196,926036787,0,30191715,19933909,102,1780380618,30,125,1,196,0,0,0,0,0,0,0,0,0,196,0,1023,-1,-1,-1,-1,0),(197,926036787,0,30189108,19933296,105,1780380648,30,127,1,197,0,0,0,0,0,0,0,0,0,197,0,1023,-1,-1,-1,-1,0),(198,926036787,0,30186745,19932351,106,1780380678,25,129,1,198,0,0,0,0,0,0,0,0,0,198,0,1023,-1,-1,-1,-1,0),(199,926036787,0,30185808,19931943,106,1780380703,11,139,1,199,0,0,0,0,0,0,0,0,0,199,0,1023,-1,-1,-1,-1,0),(200,926036787,0,30185765,19931891,106,1780380705,9,150,1,200,0,0,0,0,0,0,0,0,0,200,0,1023,-1,-1,-1,-1,0),(201,926036787,0,30185741,19931821,105,1780380707,8,169,1,201,0,0,0,0,0,0,0,0,0,201,0,1023,-1,-1,-1,-1,0),(202,926036787,0,30185478,19930480,106,1780380737,12,167,1,202,0,0,0,0,0,0,0,0,0,202,0,1023,-1,-1,-1,-1,0),(203,926036787,0,30185207,19929131,107,1780380767,13,166,1,203,0,0,0,0,0,0,0,0,0,203,0,1023,-1,-1,-1,-1,0),(204,926036787,0,30184812,19927363,114,1780380797,15,166,1,204,0,0,0,0,0,0,0,0,0,204,0,1023,-1,-1,-1,-1,0),(205,926036787,0,30184305,19924964,122,1780380827,21,167,1,205,0,0,0,0,0,0,0,0,0,205,0,1023,-1,-1,-1,-1,0),(206,926036787,0,30183965,19923302,121,1780380857,14,167,1,206,0,0,0,0,0,0,0,0,0,206,0,1023,-1,-1,-1,-1,0),(207,926036787,0,30183492,19921065,116,1780380887,16,167,1,207,0,0,0,0,0,0,0,0,0,207,0,1023,-1,-1,-1,-1,0),(208,926036787,0,30183258,19919937,119,1780380917,14,168,1,208,0,0,0,0,0,0,0,0,0,208,0,1023,-1,-1,-1,-1,0),(209,926036787,0,30183200,19919268,116,1780380927,17,178,1,209,0,0,0,0,0,0,0,0,0,209,0,1023,-1,-1,-1,-1,0),(210,926036787,0,30183199,19918410,114,1780380938,15,190,1,210,0,0,0,0,0,0,0,0,0,210,0,1023,-1,-1,-1,-1,0),(211,926036787,0,30183394,19917194,116,1780380962,15,179,1,211,0,0,0,0,0,0,0,0,0,211,0,1023,-1,-1,-1,-1,0),(212,926036787,0,30183358,19916934,115,1780380966,15,168,1,212,0,0,0,0,0,0,0,0,0,212,0,1023,-1,-1,-1,-1,0),(213,926036787,0,30183121,19916285,115,1780380976,17,155,1,213,0,0,0,0,0,0,0,0,0,213,0,1023,-1,-1,-1,-1,0),(214,926036787,0,30182647,19915297,120,1780380996,13,165,1,214,0,0,0,0,0,0,0,0,0,214,0,1023,-1,-1,-1,-1,0),(215,926036787,0,30182617,19915122,119,1780381001,4,175,1,215,0,0,0,0,0,0,0,0,0,215,0,1023,-1,-1,-1,-1,0),(216,926036787,0,30182621,19914682,123,1780381015,8,186,1,216,0,0,0,0,0,0,0,0,0,216,0,1023,-1,-1,-1,-1,0),(217,926036787,0,30182635,19914383,120,1780381023,8,175,1,217,0,0,0,0,0,0,0,0,0,217,0,1023,-1,-1,-1,-1,0),(218,926036787,0,30182534,19913492,118,1780381053,6,177,1,218,0,0,0,0,0,0,0,0,0,218,0,1023,-1,-1,-1,-1,0),(219,926036787,0,30182530,19913382,119,1780381057,5,189,1,219,0,0,0,0,0,0,0,0,0,219,0,1023,-1,-1,-1,-1,0),(220,926036787,0,30182535,19913363,120,1780381058,4,201,1,220,0,0,0,0,0,0,0,0,0,220,0,1023,-1,-1,-1,-1,0),(221,926036787,0,30182547,19913351,122,1780381064,3,72,1,221,0,0,0,0,0,0,0,0,0,221,0,1023,-1,-1,-1,-1,0),(222,926036787,0,30182539,19913375,123,1780381066,4,91,1,222,0,0,0,0,0,0,0,0,0,222,0,1023,-1,-1,-1,-1,0),(223,926036787,0,30182531,19913384,124,1780381067,4,103,1,223,0,0,0,0,0,0,0,0,0,223,0,1023,-1,-1,-1,-1,0),(224,926036787,0,30182514,19913388,124,1780381072,0,103,1,224,0,0,0,0,0,0,0,0,0,224,0,1023,-1,-1,-1,-1,0),(225,926036787,0,30182514,19913388,124,1780381102,0,103,1,225,0,0,0,0,0,0,0,0,0,225,0,1023,-1,-1,-1,-1,0),(226,926036787,0,30182514,19913388,124,1780381132,0,103,1,226,0,0,0,0,0,0,0,0,0,226,0,1023,-1,-1,-1,-1,0),(227,926036787,0,30182512,19913354,123,1780381141,3,197,1,227,0,0,0,0,0,0,0,0,0,227,0,1023,-1,-1,-1,-1,0),(228,926036787,0,30182510,19913352,122,1780381142,0,197,1,228,0,0,0,0,0,0,0,0,0,228,0,1023,-1,-1,-1,-1,0),(229,926036787,0,30182510,19913352,122,1780381172,0,197,1,229,0,0,0,0,0,0,0,0,0,229,0,1023,-1,-1,-1,-1,0),(230,926036787,0,30182504,19913477,125,1780381177,5,56,1,230,0,0,0,0,0,0,0,0,0,230,0,1023,-1,-1,-1,-1,0),(231,926036787,0,30182598,19914171,127,1780381207,5,52,1,231,0,0,0,0,0,0,0,0,0,231,0,1023,-1,-1,-1,-1,0),(232,926036787,0,30182630,19914370,127,1780381214,8,40,1,232,0,0,0,0,0,0,0,0,0,232,0,1023,-1,-1,-1,-1,0),(233,926036787,0,30182651,19914451,127,1780381217,5,53,1,233,0,0,0,0,0,0,0,0,0,233,0,1023,-1,-1,-1,-1,0),(234,926036787,0,30182649,19914493,127,1780381219,4,71,1,234,0,0,0,0,0,0,0,0,0,234,0,1023,-1,-1,-1,-1,0),(235,926036787,0,30182641,19914534,126,1780381225,0,71,1,235,0,0,0,0,0,0,0,0,0,235,0,1023,-1,-1,-1,-1,0),(236,926036787,0,30182641,19914534,126,1780381255,0,71,1,236,0,0,0,0,0,0,0,0,0,236,0,1023,-1,-1,-1,-1,0),(237,926036787,0,30182641,19914534,126,1780381285,0,71,1,237,0,0,0,0,0,0,0,0,0,237,0,1023,-1,-1,-1,-1,0),(238,926036787,0,30182641,19914534,126,1780381315,0,71,1,238,0,0,0,0,0,0,0,0,0,238,0,1023,-1,-1,-1,-1,0),(239,926036787,0,30182641,19914534,126,1780381345,0,71,1,239,0,0,0,0,0,0,0,0,0,239,0,1023,-1,-1,-1,-1,0),(240,926036787,0,30182641,19914534,126,1780381375,0,71,1,240,0,0,0,0,0,0,0,0,0,240,0,1023,-1,-1,-1,-1,0),(241,926036787,0,30182641,19914534,126,1780381405,0,71,1,241,0,0,0,0,0,0,0,0,0,241,0,1023,-1,-1,-1,-1,0),(242,926036787,0,30182641,19914534,126,1780381435,0,71,1,242,0,0,0,0,0,0,0,0,0,242,0,1023,-1,-1,-1,-1,0),(243,926036787,0,30182641,19914534,126,1780381465,0,71,1,243,0,0,0,0,0,0,0,0,0,243,0,1023,-1,-1,-1,-1,0),(244,926036787,0,30182641,19914534,126,1780381495,0,71,1,244,0,0,0,0,0,0,0,0,0,244,0,1023,-1,-1,-1,-1,0),(245,926036787,0,30182641,19914534,126,1780381525,0,71,1,245,0,0,0,0,0,0,0,0,0,245,0,1023,-1,-1,-1,-1,0),(246,926036787,0,30182635,19914625,127,1780381613,5,63,1,246,0,0,0,0,0,0,0,0,0,246,0,1023,-1,-1,-1,-1,0),(247,926036787,0,30182606,19914878,124,1780381623,6,53,1,247,0,0,0,0,0,0,0,0,0,247,0,1023,-1,-1,-1,-1,0),(248,926036787,0,30182656,19915326,121,1780381637,8,42,1,248,0,0,0,0,0,0,0,0,0,248,0,1023,-1,-1,-1,-1,0),(249,926036787,0,30182836,19915828,122,1780381653,9,32,1,249,0,0,0,0,0,0,0,0,0,249,0,1023,-1,-1,-1,-1,0),(250,926036787,0,30183288,19916773,118,1780381678,15,42,1,250,0,0,0,0,0,0,0,0,0,250,0,1023,-1,-1,-1,-1,0),(251,926036787,0,30183366,19917114,116,1780381684,13,53,1,251,0,0,0,0,0,0,0,0,0,251,0,1023,-1,-1,-1,-1,0),(252,926036787,0,30183372,19917472,113,1780381690,13,63,1,252,0,0,0,0,0,0,0,0,0,252,0,1023,-1,-1,-1,-1,0),(253,926036787,0,30183299,19917940,111,1780381698,13,74,1,253,0,0,0,0,0,0,0,0,0,253,0,1023,-1,-1,-1,-1,0),(254,926036787,0,30183186,19918508,112,1780381708,15,63,1,254,0,0,0,0,0,0,0,0,0,254,0,1023,-1,-1,-1,-1,0),(255,926036787,0,30183215,19919750,118,1780381724,21,53,1,255,0,0,0,0,0,0,0,0,0,255,0,1023,-1,-1,-1,-1,0),(256,926036787,0,30183384,19920543,117,1780381736,4,41,1,256,0,0,0,0,0,0,0,0,0,256,0,1023,-1,-1,-1,-1,0),(257,926036787,0,30183402,19920618,116,1780381740,7,51,1,257,0,0,0,0,0,0,0,0,0,257,0,1023,-1,-1,-1,-1,0),(258,926036787,0,30183740,19922290,121,1780381770,21,48,1,258,0,0,0,0,0,0,0,0,0,258,0,1023,-1,-1,-1,-1,0),(259,926036787,0,30184092,19924011,120,1780381798,9,38,1,259,0,0,0,0,0,0,0,0,0,259,0,1023,-1,-1,-1,-1,0),(260,926036787,0,30184125,19924085,118,1780381800,9,23,1,260,0,0,0,0,0,0,0,0,0,260,0,1023,-1,-1,-1,-1,0),(261,926036787,0,30184158,19924167,117,1780381802,10,40,1,261,0,0,0,0,0,0,0,0,0,261,0,1023,-1,-1,-1,-1,0),(262,926036787,0,30184244,19924598,116,1780381811,14,51,1,262,0,0,0,0,0,0,0,0,0,262,0,1023,-1,-1,-1,-1,0),(263,926036787,0,30184648,19926644,121,1780381841,16,45,1,263,0,0,0,0,0,0,0,0,0,263,0,1023,-1,-1,-1,-1,0),(264,926036787,0,30185083,19928637,110,1780381871,13,47,1,264,0,0,0,0,0,0,0,0,0,264,0,1023,-1,-1,-1,-1,0),(265,926036787,0,30185399,19930137,111,1780381901,10,47,1,265,0,0,0,0,0,0,0,0,0,265,0,1023,-1,-1,-1,-1,0),(266,926036787,0,30252838,19893673,120,1780384024,0,135,1,266,0,16,0,1,192,61,160,0,0,266,0,1023,-1,-1,-1,-1,0),(267,926036787,0,30252838,19893673,120,1780384084,0,135,1,267,0,16,0,1,192,61,176,0,0,267,0,1023,-1,-1,-1,-1,0),(268,926036787,0,30252838,19893673,120,1780384144,0,135,1,268,0,16,0,1,192,61,192,0,0,268,0,1023,-1,-1,-1,-1,0),(269,926036787,0,30253075,19893747,127,1780384153,5,217,1,269,0,16,0,1,192,61,208,0,0,269,0,1023,-1,-1,-1,-1,0),(270,926036787,0,30254349,19892108,123,1780384185,22,211,1,270,0,16,0,1,192,61,240,0,0,270,0,1023,-1,-1,-1,-1,0),(271,926036787,0,30254755,19891493,116,1780384194,24,203,1,271,0,16,0,1,192,62,0,0,0,271,0,1023,-1,-1,-1,-1,0),(272,926036787,0,30255070,19890986,114,1780384201,22,209,1,272,0,16,0,1,192,62,0,0,0,272,0,1023,-1,-1,-1,-1,0),(273,926036787,0,30255399,19890395,116,1780384209,23,203,1,273,0,16,0,1,192,62,0,0,0,273,0,1023,-1,-1,-1,-1,0),(274,926036787,0,30255520,19890048,116,1780384213,22,196,1,274,0,16,0,1,192,62,0,0,0,274,0,1023,-1,-1,-1,-1,0),(275,926036787,0,30255765,19889059,114,1780384224,19,188,1,275,0,16,0,1,192,62,16,0,0,275,0,1023,-1,-1,-1,-1,0),(276,926036787,0,30255942,19887499,114,1780384241,22,182,1,276,0,16,0,1,192,62,48,0,0,276,0,1023,-1,-1,-1,-1,0),(277,926036787,0,30255947,19886814,119,1780384248,23,175,1,277,0,16,0,1,192,62,48,0,0,277,0,1023,-1,-1,-1,-1,0),(278,926036787,0,30255474,19880916,158,1780384308,25,173,1,278,0,16,0,1,192,62,176,0,0,278,0,1023,-1,-1,-1,-1,0),(279,926036787,0,30255169,19878069,163,1780384334,29,179,1,279,0,16,0,1,192,62,176,0,0,279,0,1023,-1,-1,-1,-1,0),(280,926036787,0,30255515,19872112,161,1780384374,36,182,1,280,0,16,0,1,192,63,32,0,0,280,0,1023,-1,-1,-1,-1,0),(281,926036787,0,30255514,19870229,168,1780384386,35,176,1,281,0,16,0,1,192,63,64,0,0,281,0,1023,-1,-1,-1,-1,0),(282,926036787,0,30255046,19864397,165,1780384425,34,175,1,282,0,16,0,1,192,63,128,0,0,282,0,1023,-1,-1,-1,-1,0),(283,926036787,0,30254982,19862756,161,1780384437,30,181,1,283,0,16,0,1,192,63,144,0,0,283,0,1023,-1,-1,-1,-1,0),(284,926036787,0,30255205,19858254,167,1780384473,28,175,1,284,0,16,0,1,192,63,208,0,0,284,0,1023,-1,-1,-1,-1,0),(285,926036787,0,30255097,19857515,169,1780384479,29,168,1,285,0,16,0,1,192,63,208,0,0,285,0,1023,-1,-1,-1,-1,0),(286,926036787,0,30254726,19856063,163,1780384491,31,162,1,286,0,16,0,1,192,63,224,0,0,286,0,1023,-1,-1,-1,-1,0),(287,926036787,0,30254202,19854105,156,1780384507,29,168,1,287,0,16,0,1,192,63,224,0,0,287,0,1023,-1,-1,-1,-1,0),(288,926036787,0,30253977,19852788,168,1780384518,29,174,1,288,0,16,0,1,192,63,224,0,0,288,0,1023,-1,-1,-1,-1,0),(289,926036787,0,30253924,19851773,171,1780384526,29,180,1,289,0,16,0,1,192,63,224,0,0,289,0,1023,-1,-1,-1,-1,0),(290,926036787,0,30253813,19849032,162,1780384547,30,174,1,290,0,16,0,1,192,63,240,0,0,290,0,1023,-1,-1,-1,-1,0),(291,926036787,0,30253541,19844721,161,1780384599,16,181,1,291,0,16,0,1,192,64,0,0,0,291,0,1023,-1,-1,-1,-1,0),(292,926036787,0,30253559,19843847,164,1780384609,22,187,1,292,0,16,0,1,192,64,0,0,0,292,0,1023,-1,-1,-1,-1,0),(293,926036787,0,30253858,19841994,164,1780384627,24,193,1,293,0,16,0,1,192,64,64,0,0,293,0,1023,-1,-1,-1,-1,0),(294,926036787,0,30254732,19838075,170,1780384667,24,187,1,294,0,16,0,1,192,65,32,0,0,294,0,1023,-1,-1,-1,-1,0),(295,926036787,0,30255196,19832793,171,1780384727,19,187,1,295,0,16,0,1,192,65,96,0,0,295,0,1023,-1,-1,-1,-1,0),(296,926036787,0,30255209,19832565,171,1780384730,15,181,1,296,0,16,0,1,192,65,96,0,0,296,0,1023,-1,-1,-1,-1,0),(297,926036787,0,30255280,19831934,170,1780384738,21,187,1,297,0,16,0,1,192,65,96,0,0,297,0,1023,-1,-1,-1,-1,0),(298,926036787,0,30255715,19828868,169,1780384772,9,195,1,298,0,16,0,1,192,65,16,0,0,298,0,1023,-1,-1,-1,-1,0),(299,926036787,0,30255726,19828798,169,1780384774,9,184,1,299,0,16,0,1,192,65,16,0,0,299,0,1023,-1,-1,-1,-1,0),(300,926036787,0,30255791,19828279,165,1780384793,6,191,1,300,0,16,0,1,192,64,208,0,0,300,0,1023,-1,-1,-1,-1,0),(301,926036787,0,30255813,19828105,165,1780384798,6,185,1,301,0,16,0,1,192,64,208,0,0,301,0,1023,-1,-1,-1,-1,0),(302,926036787,0,30256014,19826637,170,1780384833,12,191,1,302,0,16,0,1,192,64,192,0,0,302,0,1023,-1,-1,-1,-1,0),(303,926036787,0,30256030,19826534,170,1780384835,12,183,1,303,0,16,0,1,192,64,192,0,0,303,0,1023,-1,-1,-1,-1,0),(304,926036787,0,30256072,19826161,171,1780384842,8,191,1,304,0,16,0,1,192,64,208,0,0,304,0,1023,-1,-1,-1,-1,0),(305,926036787,0,30256085,19826068,170,1780384845,7,184,1,305,0,16,0,1,192,64,208,0,0,305,0,1023,-1,-1,-1,-1,0),(306,926036787,0,30256114,19825796,170,1780384851,11,190,1,306,0,16,0,1,192,65,0,0,0,306,0,1023,-1,-1,-1,-1,0),(307,926036787,0,30256270,19824329,169,1780384867,24,184,1,307,0,16,0,1,192,65,32,0,0,307,0,1023,-1,-1,-1,-1,0),(308,926036787,0,30256320,19823170,168,1780384880,10,178,1,308,0,16,0,1,192,65,64,0,0,308,0,1023,-1,-1,-1,-1,0),(309,926036787,0,30256322,19823087,168,1780384882,9,184,1,309,0,16,0,1,192,65,96,0,0,309,0,1023,-1,-1,-1,-1,0),(310,926036787,0,30256325,19822980,168,1780384887,3,178,1,310,0,16,0,1,192,65,96,0,0,310,0,1023,-1,-1,-1,-1,0),(311,926036787,0,30256323,19822841,169,1780384892,9,184,1,311,0,16,0,1,192,65,112,0,0,311,0,1023,-1,-1,-1,-1,0),(312,926036787,0,30256402,19820937,165,1780384932,8,175,1,312,0,16,0,1,192,65,128,0,0,312,0,1023,-1,-1,-1,-1,0),(313,926036787,0,30256394,19820704,167,1780384938,9,182,1,313,0,16,0,1,192,65,128,0,0,313,0,1023,-1,-1,-1,-1,0),(314,926036787,0,30256435,19818411,169,1780384971,6,175,1,314,0,16,0,1,192,65,128,0,0,314,0,1023,-1,-1,-1,-1,0),(315,926036787,0,30256428,19818335,169,1780384976,4,169,1,315,0,16,0,1,192,65,128,0,0,315,0,1023,-1,-1,-1,-1,0),(316,926036787,0,30256416,19818246,169,1780384979,9,176,1,316,0,16,0,1,192,65,128,0,0,316,0,1023,-1,-1,-1,-1,0),(317,926036787,0,30256385,19817714,174,1780384989,12,169,1,317,0,16,0,1,192,65,128,0,0,317,0,1023,-1,-1,-1,-1,0),(318,926036787,0,30256348,19817455,173,1780384994,10,177,1,318,0,16,0,1,192,65,144,0,0,318,0,1023,-1,-1,-1,-1,0),(319,926036787,0,30256338,19817227,174,1780385000,4,171,1,319,0,16,0,1,192,65,144,0,0,319,0,1023,-1,-1,-1,-1,0),(320,926036787,0,30256325,19817176,174,1780385004,0,171,1,320,0,16,0,1,192,65,160,0,0,320,0,1023,-1,-1,-1,-1,0),(321,926036787,0,30256279,19816898,172,1780385017,11,171,1,321,0,16,0,1,192,65,192,0,0,321,0,1023,-1,-1,-1,-1,0),(322,926036787,0,30256042,19815247,168,1780385058,7,177,1,322,0,16,0,1,192,65,224,0,0,322,0,1023,-1,-1,-1,-1,0),(323,926036787,0,30256033,19815167,168,1780385060,9,168,1,323,0,16,0,1,192,65,224,0,0,323,0,1023,-1,-1,-1,-1,0),(324,926036787,0,30255269,19811055,161,1780385120,21,170,1,324,0,16,0,1,192,65,224,0,0,324,0,1023,-1,-1,-1,-1,0),(325,926036787,0,30255180,19810623,162,1780385127,8,164,1,325,0,16,0,1,192,65,240,0,0,325,0,1023,-1,-1,-1,-1,0),(326,926036787,0,30255156,19810571,163,1780385129,8,151,1,326,0,16,0,1,192,65,240,0,0,326,0,1023,-1,-1,-1,-1,0),(327,926036787,0,30255137,19810553,163,1780385130,8,141,1,327,0,16,0,1,192,65,240,0,0,327,0,1023,-1,-1,-1,-1,0),(328,926036787,0,30255118,19810543,164,1780385131,8,129,1,328,0,16,0,1,192,65,240,0,0,328,0,1023,-1,-1,-1,-1,0),(329,926036787,0,30255096,19810540,164,1780385132,8,121,1,329,0,16,0,1,192,65,240,0,0,329,0,1023,-1,-1,-1,-1,0),(330,926036787,0,30255044,19810550,164,1780385134,11,114,1,330,0,16,0,1,192,65,240,0,0,330,0,1023,-1,-1,-1,-1,0),(331,926036787,0,30251875,19811361,167,1780385194,17,113,1,331,0,16,0,1,192,66,176,0,0,331,0,1023,-1,-1,-1,-1,0),(332,926036787,0,30248457,19812210,166,1780385254,22,113,1,332,0,16,0,1,192,67,32,0,0,332,0,1023,-1,-1,-1,-1,0),(333,926036787,0,30244984,19813342,167,1780385314,18,106,1,333,0,16,0,1,192,67,96,0,0,333,0,1023,-1,-1,-1,-1,0),(334,926036787,0,30244522,19813516,166,1780385322,22,112,1,334,0,16,0,1,192,67,112,0,0,334,0,1023,-1,-1,-1,-1,0),(335,926036787,0,30243948,19813728,164,1780385332,21,105,1,335,0,16,0,1,192,67,112,0,0,335,0,1023,-1,-1,-1,-1,0),(336,926036787,0,30243727,19813818,164,1780385336,21,111,1,336,0,16,0,1,192,67,112,0,0,336,0,1023,-1,-1,-1,-1,0),(337,926036787,0,30242018,19814435,163,1780385365,18,104,1,337,0,16,0,1,192,67,144,0,0,337,0,1023,-1,-1,-1,-1,0),(338,926036787,0,30241834,19814585,166,1780385369,18,98,1,338,0,16,0,1,192,67,144,0,0,338,0,1023,-1,-1,-1,-1,0),(339,926036787,0,30240928,19815557,168,1780385392,17,91,1,339,0,16,0,1,192,67,176,0,0,339,0,1023,-1,-1,-1,-1,0),(340,926036787,0,30240710,19815915,168,1780385398,19,85,1,340,0,16,0,1,192,67,176,0,0,340,0,1023,-1,-1,-1,-1,0),(341,926036787,0,30238970,19818984,166,1780385447,10,97,1,341,0,16,0,1,192,67,192,0,0,341,0,1023,-1,-1,-1,-1,0),(342,926036787,0,30238954,19819000,166,1780385448,8,104,1,342,0,16,0,1,192,67,192,0,0,342,0,1023,-1,-1,-1,-1,0),(343,926036787,0,30238940,19818997,166,1780385449,6,123,1,343,0,16,0,1,192,67,192,0,0,343,0,1023,-1,-1,-1,-1,0),(344,926036787,0,30238929,19818988,166,1780385450,4,137,1,344,0,16,0,1,192,67,192,0,0,344,0,1023,-1,-1,-1,-1,0),(345,926036787,0,30238918,19818977,166,1780385451,5,131,1,345,0,16,0,1,192,67,192,0,0,345,0,1023,-1,-1,-1,-1,0),(346,926036787,0,30238898,19818945,166,1780385454,3,143,1,346,0,16,0,1,192,67,192,0,0,346,0,1023,-1,-1,-1,-1,0),(347,926036787,0,30238897,19818927,166,1780385455,4,159,1,347,0,16,0,1,192,67,192,0,0,347,0,1023,-1,-1,-1,-1,0),(348,926036787,0,30238818,19818660,165,1780385465,6,170,1,348,0,16,0,1,192,67,192,0,0,348,0,1023,-1,-1,-1,-1,0),(349,926036787,0,30238795,19818566,165,1780385469,5,163,1,349,0,16,0,1,192,67,192,0,0,349,0,1023,-1,-1,-1,-1,0),(350,926036787,0,30238759,19818461,167,1780385473,6,157,1,350,0,16,0,1,192,67,192,0,0,350,0,1023,-1,-1,-1,-1,0),(351,926036787,0,30238731,19818397,169,1780385476,5,165,1,351,0,16,0,1,192,67,192,0,0,351,0,1023,-1,-1,-1,-1,0),(352,926036787,0,30238708,19818274,170,1780385481,5,171,1,352,0,16,0,1,192,67,192,0,0,352,0,1023,-1,-1,-1,-1,0),(353,926036787,0,30238690,19818159,169,1780385485,6,165,1,353,0,16,0,1,192,67,192,0,0,353,0,1023,-1,-1,-1,-1,0),(354,926036787,0,30238642,19818005,170,1780385491,5,159,1,354,0,16,0,1,192,67,192,0,0,354,0,1023,-1,-1,-1,-1,0),(355,926036787,0,30238619,19817939,170,1780385494,5,165,1,355,0,16,0,1,192,67,192,0,0,355,0,1023,-1,-1,-1,-1,0),(356,926036787,0,30238600,19817875,170,1780385497,5,159,1,356,0,16,0,1,192,67,192,0,0,356,0,1023,-1,-1,-1,-1,0),(357,926036787,0,30238580,19817840,171,1780385499,5,143,1,357,0,16,0,1,192,67,192,0,0,357,0,1023,-1,-1,-1,-1,0),(358,926036787,0,30238566,19817816,171,1780385504,0,138,1,358,0,16,0,1,192,67,192,0,0,358,0,1023,-1,-1,-1,-1,0),(359,926036787,0,30238599,19817932,171,1780385526,4,57,1,359,0,16,0,1,192,67,192,0,0,359,0,1023,-1,-1,-1,-1,0),(360,926036787,0,30238601,19817970,171,1780385528,4,48,1,360,0,16,0,1,192,67,192,0,0,360,0,1023,-1,-1,-1,-1,0),(361,926036787,0,30238602,19818013,171,1780385533,0,47,1,361,0,16,0,1,192,67,192,0,0,361,0,1023,-1,-1,-1,-1,0),(362,926036787,0,30238629,19818118,171,1780385591,5,45,1,362,0,16,0,1,192,67,192,0,0,362,0,1023,-1,-1,-1,-1,0),(363,926036787,0,30238647,19818191,170,1780385594,6,39,1,363,0,16,0,1,192,67,192,0,0,363,0,1023,-1,-1,-1,-1,0),(364,926036787,0,30238735,19818445,171,1780385605,6,45,1,364,0,16,0,1,192,67,192,0,0,364,0,1023,-1,-1,-1,-1,0),(365,926036787,0,30238787,19818646,171,1780385612,8,39,1,365,0,16,0,1,192,67,192,0,0,365,0,1023,-1,-1,-1,-1,0),(366,926036787,0,30238847,19818822,171,1780385618,7,45,1,366,0,16,0,1,192,67,192,0,0,366,0,1023,-1,-1,-1,-1,0),(367,926036787,0,30238902,19819000,171,1780385625,5,39,1,367,0,16,0,1,192,67,192,0,0,367,0,1023,-1,-1,-1,-1,0),(368,926036787,0,30238914,19819015,171,1780385626,5,27,1,368,0,16,0,1,192,67,192,0,0,368,0,1023,-1,-1,-1,-1,0),(369,926036787,0,30238930,19819026,171,1780385627,6,13,1,369,0,16,0,1,192,67,192,0,0,369,0,1023,-1,-1,-1,-1,0),(370,926036787,0,30238949,19819033,171,1780385628,7,6,1,370,0,16,0,1,192,67,192,0,0,370,0,1023,-1,-1,-1,-1,0),(371,926036787,0,30238968,19819027,171,1780385629,6,228,1,371,0,16,0,1,192,67,192,0,0,371,0,1023,-1,-1,-1,-1,0),(372,926036787,0,30238987,19819007,171,1780385630,8,214,1,372,0,16,0,1,192,67,192,0,0,372,0,1023,-1,-1,-1,-1,0),(373,926036787,0,30239005,19818980,171,1780385631,8,206,1,373,0,16,0,1,192,67,192,0,0,373,0,1023,-1,-1,-1,-1,0),(374,926036787,0,30239035,19818919,171,1780385633,9,198,1,374,0,16,0,1,192,67,192,0,0,374,0,1023,-1,-1,-1,-1,0),(375,926036787,0,30239100,19818803,169,1780385637,9,205,1,375,0,16,0,1,192,67,192,0,0,375,0,1023,-1,-1,-1,-1,0),(376,926036787,0,30239207,19818625,167,1780385645,4,199,1,376,0,16,0,1,192,67,192,0,0,376,0,1023,-1,-1,-1,-1,0),(377,926036787,0,30239217,19818621,167,1780385649,0,199,1,377,0,16,0,1,192,67,192,0,0,377,0,1023,-1,-1,-1,-1,0),(378,926036787,0,30239217,19818621,167,1780385709,0,199,1,378,0,16,0,1,192,67,224,0,0,378,0,1023,-1,-1,-1,-1,0),(379,926036787,0,30239217,19818621,167,1780385769,0,199,1,379,0,16,0,1,192,68,64,0,0,379,0,1023,-1,-1,-1,-1,0),(380,926036787,0,30239217,19818621,167,1780385829,0,199,1,380,0,16,0,1,192,68,48,0,0,380,0,1023,-1,-1,-1,-1,0),(381,926036787,0,30239283,19818529,168,1780385861,9,210,1,381,0,16,0,1,192,68,0,0,0,381,0,1023,-1,-1,-1,-1,0),(382,926036787,0,30239890,19817483,165,1780385888,6,225,1,382,0,16,0,1,192,68,0,0,0,382,0,1023,-1,-1,-1,-1,0),(383,926036787,0,30239906,19817479,165,1780385889,5,239,1,383,0,16,0,1,192,68,0,0,0,383,0,1023,-1,-1,-1,-1,0),(384,926036787,0,30239920,19817485,165,1780385890,5,11,1,384,0,16,0,1,192,68,0,0,0,384,0,1023,-1,-1,-1,-1,0),(385,926036787,0,30239942,19817505,164,1780385892,4,26,1,385,0,16,0,1,192,68,0,0,0,385,0,1023,-1,-1,-1,-1,0),(386,926036787,0,30239951,19817518,164,1780385893,3,37,1,386,0,16,0,1,192,68,0,0,0,386,0,1023,-1,-1,-1,-1,0),(387,926036787,0,30239966,19817560,165,1780385896,4,48,1,387,0,16,0,1,192,68,0,0,0,387,0,1023,-1,-1,-1,-1,0),(388,926036787,0,30240097,19818106,167,1780385916,6,41,1,388,0,16,0,1,192,68,0,0,0,388,0,1023,-1,-1,-1,-1,0),(389,926036787,0,30240106,19818130,167,1780385917,6,33,1,389,0,16,0,1,192,68,0,0,0,389,0,1023,-1,-1,-1,-1,0),(390,926036787,0,30240120,19818150,167,1780385918,6,25,1,390,0,16,0,1,192,68,0,0,0,390,0,1023,-1,-1,-1,-1,0),(391,926036787,0,30240151,19818172,167,1780385920,6,9,1,391,0,16,0,1,192,68,0,0,0,391,0,1023,-1,-1,-1,-1,0),(392,926036787,0,30240187,19818177,167,1780385922,5,237,1,392,0,16,0,1,192,68,0,0,0,392,0,1023,-1,-1,-1,-1,0),(393,926036787,0,30240230,19818163,168,1780385924,8,230,1,393,0,16,0,1,192,68,0,0,0,393,0,1023,-1,-1,-1,-1,0),(394,926036787,0,30240427,19818082,167,1780385935,5,237,1,394,0,16,0,1,192,68,0,0,0,394,0,1023,-1,-1,-1,-1,0),(395,926036787,0,30240454,19818072,166,1780385937,5,225,1,395,0,16,0,1,192,68,0,0,0,395,0,1023,-1,-1,-1,-1,0),(396,926036787,0,30240463,19818058,166,1780385938,5,216,1,396,0,16,0,1,192,68,0,0,0,396,0,1023,-1,-1,-1,-1,0),(397,926036787,0,30240489,19818029,165,1780385944,0,218,1,397,0,16,0,1,192,68,0,0,0,397,0,1023,-1,-1,-1,-1,0),(398,926036787,0,30240458,19818094,166,1780385951,3,49,1,398,0,16,0,1,192,68,0,0,0,398,0,1023,-1,-1,-1,-1,0),(399,926036787,0,30240465,19818109,167,1780385954,0,49,1,399,0,16,0,1,192,68,0,0,0,399,0,1023,-1,-1,-1,-1,0),(400,926036787,0,30240465,19818109,167,1780386014,0,49,1,400,0,16,0,1,192,68,0,0,0,400,0,1023,-1,-1,-1,-1,0),(401,926036787,0,30240465,19818109,167,1780386074,0,49,1,401,0,16,0,1,192,68,64,0,0,401,0,1023,-1,-1,-1,-1,0),(402,926036787,0,30240304,19818120,168,1780386103,6,107,1,402,0,16,0,1,192,68,80,0,0,402,0,1023,-1,-1,-1,-1,0),(403,926036787,0,30240212,19818150,168,1780386108,7,115,1,403,0,16,0,1,192,68,96,0,0,403,0,1023,-1,-1,-1,-1,0),(404,926036787,0,30240175,19818148,168,1780386110,6,130,1,404,0,16,0,1,192,68,96,0,0,404,0,1023,-1,-1,-1,-1,0),(405,926036787,0,30240144,19818122,168,1780386112,5,139,1,405,0,16,0,1,192,68,96,0,0,405,0,1023,-1,-1,-1,-1,0),(406,926036787,0,30240131,19818094,168,1780386113,5,148,1,406,0,16,0,1,192,68,96,0,0,406,0,1023,-1,-1,-1,-1,0),(407,926036787,0,30240120,19818061,168,1780386114,6,161,1,407,0,16,0,1,192,68,96,0,0,407,0,1023,-1,-1,-1,-1,0),(408,926036787,0,30240113,19818030,168,1780386115,6,167,1,408,0,16,0,1,192,68,112,0,0,408,0,1023,-1,-1,-1,-1,0),(409,926036787,0,30239940,19817425,169,1780386136,6,173,1,409,0,16,0,1,192,68,128,0,0,409,0,1023,-1,-1,-1,-1,0),(410,926036787,0,30239938,19817397,169,1780386137,6,184,1,410,0,16,0,1,192,68,128,0,0,410,0,1023,-1,-1,-1,-1,0),(411,926036787,0,30239943,19817367,168,1780386138,6,198,1,411,0,16,0,1,192,68,128,0,0,411,0,1023,-1,-1,-1,-1,0),(412,926036787,0,30239953,19817339,168,1780386139,7,205,1,412,0,16,0,1,192,68,128,0,0,412,0,1023,-1,-1,-1,-1,0),(413,926036787,0,30240090,19817082,166,1780386148,8,199,1,413,0,16,0,1,192,68,128,0,0,413,0,1023,-1,-1,-1,-1,0),(414,926036787,0,30240129,19816956,165,1780386153,5,207,1,414,0,16,0,1,192,68,128,0,0,414,0,1023,-1,-1,-1,-1,0),(415,926036787,0,30240140,19816944,165,1780386154,5,223,1,415,0,16,0,1,192,68,128,0,0,415,0,1023,-1,-1,-1,-1,0),(416,926036787,0,30240153,19816940,165,1780386155,3,233,1,416,0,16,0,1,192,68,128,0,0,416,0,1023,-1,-1,-1,-1,0),(417,926036787,0,30240168,19816941,165,1780386159,0,233,1,417,0,16,0,1,192,68,128,0,0,417,0,1023,-1,-1,-1,-1,0),(418,926036787,0,30240168,19816941,165,1780386219,0,233,1,418,0,16,0,1,192,68,128,0,0,418,0,1023,-1,-1,-1,-1,0),(419,926036787,0,30240168,19816941,165,1780386279,0,233,1,419,0,16,0,1,192,68,64,0,0,419,0,1023,-1,-1,-1,-1,0),(420,926036787,0,30240168,19816941,165,1780386339,0,233,1,420,0,16,0,1,192,68,48,0,0,420,0,1023,-1,-1,-1,-1,0),(421,926036787,0,30240260,19816897,166,1780386360,8,213,1,421,0,16,0,1,192,68,48,0,0,421,0,1023,-1,-1,-1,-1,0),(422,926036787,0,30240446,19816590,164,1780386370,12,207,1,422,0,16,0,1,192,68,32,0,0,422,0,1023,-1,-1,-1,-1,0),(423,926036787,0,30240509,19816456,163,1780386373,12,200,1,423,0,16,0,1,192,68,32,0,0,423,0,1023,-1,-1,-1,-1,0),(424,926036787,0,30240771,19815884,164,1780386383,19,207,1,424,0,16,0,1,192,68,32,0,0,424,0,1023,-1,-1,-1,-1,0),(425,926036787,0,30240931,19815634,162,1780386387,19,213,1,425,0,16,0,1,192,68,32,0,0,425,0,1023,-1,-1,-1,-1,0),(426,926036787,0,30241845,19814614,162,1780386411,15,221,1,426,0,16,0,1,192,68,16,0,0,426,0,1023,-1,-1,-1,-1,0),(427,926036787,0,30242154,19814381,162,1780386419,15,228,1,427,0,16,0,1,192,68,16,0,0,427,0,1023,-1,-1,-1,-1,0),(428,926036787,0,30245474,19813201,164,1780386479,18,230,1,428,0,16,0,1,192,68,48,0,0,428,0,1023,-1,-1,-1,-1,0),(429,926036787,0,30246319,19812898,163,1780386497,10,4,1,429,0,16,0,1,192,68,80,0,0,429,0,1023,-1,-1,-1,-1,0),(430,926036787,0,30246344,19812914,163,1780386498,9,19,1,430,0,16,0,1,192,68,80,0,0,430,0,1023,-1,-1,-1,-1,0),(431,926036787,0,30246367,19812948,164,1780386499,9,33,1,431,0,16,0,1,192,68,80,0,0,431,0,1023,-1,-1,-1,-1,0),(432,926036787,0,30246382,19812983,164,1780386500,9,39,1,432,0,16,0,1,192,68,80,0,0,432,0,1023,-1,-1,-1,-1,0),(433,926036787,0,30247271,19815949,162,1780386547,8,47,1,433,0,16,0,1,192,68,224,0,0,433,0,1023,-1,-1,-1,-1,0),(434,926036787,0,30247276,19815975,162,1780386548,5,53,1,434,0,16,0,1,192,68,224,0,0,434,0,1023,-1,-1,-1,-1,0),(435,926036787,0,30247274,19815994,162,1780386549,4,69,1,435,0,16,0,1,192,68,224,0,0,435,0,1023,-1,-1,-1,-1,0),(436,926036787,0,30247269,19816004,162,1780386550,4,86,1,436,0,16,0,1,192,68,224,0,0,436,0,1023,-1,-1,-1,-1,0),(437,926036787,0,30247260,19816015,162,1780386551,3,97,1,437,0,16,0,1,192,68,224,0,0,437,0,1023,-1,-1,-1,-1,0),(438,926036787,0,30247254,19816011,163,1780386552,3,121,1,438,0,16,0,1,192,68,224,0,0,438,0,1023,-1,-1,-1,-1,0),(439,926036787,0,30247240,19816004,164,1780386556,0,121,1,439,0,16,0,1,192,68,240,0,0,439,0,1023,-1,-1,-1,-1,0),(440,926036787,0,30247240,19816004,164,1780386616,0,121,1,440,0,16,0,1,192,69,48,0,0,440,0,1023,-1,-1,-1,-1,0);
/*!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 NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РўРµР»РµС‚СЂРµРєР°',
  `Latitude` int NOT NULL DEFAULT '0' COMMENT 'РЁРёСЂРѕС‚Р°',
  `Longitude` int NOT NULL DEFAULT '0' COMMENT 'Р”РѕР»РіРѕС‚Р°',
  `Direction` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РіСЂР°РґСѓСЃС‹/1.5',
  `Acceleration` int NOT NULL DEFAULT '0' COMMENT 'РР·РјРµРЅРµРЅРёРµ СЃРєРѕСЂРѕСЃС‚Рё РїРѕ GPS Р·Р° РїРѕСЃР»РµРґРЅСЋСЋ СЃРµРєСѓРЅРґСѓ',
  `UnixTime` int NOT NULL DEFAULT '0',
  `Speed` smallint NOT NULL DEFAULT '0' COMMENT 'РЎРѕС‚РµРЅ РјРµС‚СЂРѕРІ РІ С‡Р°СЃ (0,1 РєРј/С‡)',
  `Valid` tinyint(1) NOT NULL DEFAULT '1',
  `Satellites` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РљРѕР»РёС‡РµСЃС‚РІРѕ СЃРїСѓС‚РЅРёРєРѕРІ ',
  `RssiGsm` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РЈСЂРѕРІРµРЅСЊ GSM СЃРёРіРЅР°Р»Р°',
  `Events` int NOT NULL DEFAULT '0' COMMENT 'Р¤Р»Р°РіРё СЃРѕР±С‹С‚РёР№',
  `SensorsSet` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РЅР°Р±РѕСЂР° РґР°С‚С‡РёРєРѕРІ',
  `Sensors` varbinary(50) NOT NULL DEFAULT '0' COMMENT 'Р—РЅР°С‡РµРЅРёСЏ РґР°С‚С‡РёРєРѕРІ',
  `Voltage` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РќР°РїСЂСЏР¶РµРЅРёРµ РїРёС‚Р°РЅРёСЏ С‚РµРєСѓС‰РµРіРѕ РёСЃС‚РѕС‡РЅРёРєР°/1.5 РѕС‚ 0 РґРѕ 38,2',
  `DGPS` varchar(32) DEFAULT NULL,
  `LogID` int NOT NULL DEFAULT '0' COMMENT 'РРґРµРЅС‚РёС„РёРєР°С‚РѕСЂ Р·Р°РїРёСЃРё РІ Р¶СѓСЂРЅР°Р»Рµ РўРµР»РµС‚СЂРµРєР°',
  `SrvPacketID` bigint 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 NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `Latitude` int DEFAULT '0',
  `Longitude` int DEFAULT '0',
  `Altitude` int DEFAULT NULL,
  `UnixTime` int DEFAULT '0',
  `Speed` smallint DEFAULT '0',
  `Direction` int NOT NULL DEFAULT '0',
  `Valid` tinyint DEFAULT '1',
  `InMobitelID` int DEFAULT NULL,
  `Events` int unsigned DEFAULT '0',
  `Sensor1` tinyint unsigned DEFAULT '0',
  `Sensor2` tinyint unsigned DEFAULT '0',
  `Sensor3` tinyint unsigned DEFAULT '0',
  `Sensor4` tinyint unsigned DEFAULT '0',
  `Sensor5` tinyint unsigned DEFAULT '0',
  `Sensor6` tinyint unsigned DEFAULT '0',
  `Sensor7` tinyint unsigned DEFAULT '0',
  `Sensor8` tinyint unsigned DEFAULT '0',
  `LogID` int DEFAULT '0',
  `isShow` tinyint DEFAULT '0',
  `whatIs` smallint DEFAULT '0',
  `Counter1` int NOT NULL DEFAULT '-1',
  `Counter2` int NOT NULL DEFAULT '-1',
  `Counter3` int NOT NULL DEFAULT '-1',
  `Counter4` int 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 DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `Latitude` int NOT NULL DEFAULT '0',
  `Longitude` int NOT NULL DEFAULT '0',
  `Altitude` int DEFAULT '0',
  `UnixTime` int NOT NULL DEFAULT '0',
  `Speed` smallint NOT NULL DEFAULT '0',
  `Direction` int NOT NULL DEFAULT '0',
  `Valid` tinyint NOT NULL DEFAULT '1',
  `InMobitelID` int DEFAULT '0',
  `Events` int unsigned DEFAULT '0',
  `Sensor1` tinyint unsigned DEFAULT '0',
  `Sensor2` tinyint unsigned DEFAULT '0',
  `Sensor3` tinyint unsigned DEFAULT '0',
  `Sensor4` tinyint unsigned DEFAULT '0',
  `Sensor5` tinyint unsigned DEFAULT '0',
  `Sensor6` tinyint unsigned DEFAULT '0',
  `Sensor7` tinyint unsigned DEFAULT '0',
  `Sensor8` tinyint unsigned DEFAULT '0',
  `LogID` int DEFAULT '0',
  `isShow` tinyint DEFAULT '0',
  `whatIs` smallint unsigned NOT NULL DEFAULT '0',
  `Counter1` int NOT NULL DEFAULT '-1',
  `Counter2` int NOT NULL DEFAULT '-1',
  `Counter3` int NOT NULL DEFAULT '-1',
  `Counter4` int 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 NOT NULL DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `Latitude` int NOT NULL DEFAULT '0',
  `Longitude` int NOT NULL DEFAULT '0',
  `Altitude` int DEFAULT NULL,
  `UnixTime` int NOT NULL DEFAULT '0',
  `Speed` smallint NOT NULL DEFAULT '0',
  `Direction` int NOT NULL DEFAULT '0',
  `Valid` tinyint NOT NULL DEFAULT '1',
  `InMobitelID` int DEFAULT NULL,
  `Events` int unsigned DEFAULT '0',
  `Sensor1` tinyint unsigned DEFAULT '0',
  `Sensor2` tinyint unsigned DEFAULT '0',
  `Sensor3` tinyint unsigned DEFAULT '0',
  `Sensor4` tinyint unsigned DEFAULT '0',
  `Sensor5` tinyint unsigned DEFAULT '0',
  `Sensor6` tinyint unsigned DEFAULT '0',
  `Sensor7` tinyint unsigned DEFAULT '0',
  `Sensor8` tinyint unsigned DEFAULT '0',
  `LogID` int NOT NULL DEFAULT '0',
  `isShow` tinyint DEFAULT '0',
  `whatIs` smallint NOT NULL DEFAULT '0',
  `Counter1` int NOT NULL DEFAULT '-1',
  `Counter2` int NOT NULL DEFAULT '-1',
  `Counter3` int NOT NULL DEFAULT '-1',
  `Counter4` int NOT NULL DEFAULT '-1',
  `SrvPacketID` bigint 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 NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РўРµР»РµС‚СЂРµРєР°',
  `Latitude` int NOT NULL DEFAULT '0' COMMENT 'РЁРёСЂРѕС‚Р°',
  `Longitude` int NOT NULL DEFAULT '0' COMMENT 'Р”РѕР»РіРѕС‚Р°',
  `Direction` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РіСЂР°РґСѓСЃС‹/1.5',
  `Acceleration` int NOT NULL DEFAULT '0' COMMENT 'РР·РјРµРЅРµРЅРёРµ СЃРєРѕСЂРѕСЃС‚Рё РїРѕ GPS Р·Р° РїРѕСЃР»РµРґРЅСЋСЋ СЃРµРєСѓРЅРґСѓ',
  `UnixTime` int NOT NULL DEFAULT '0',
  `Speed` smallint NOT NULL DEFAULT '0' COMMENT 'РЎРѕС‚РµРЅ РјРµС‚СЂРѕРІ РІ С‡Р°СЃ (0,1 РєРј/С‡)',
  `Valid` tinyint(1) NOT NULL DEFAULT '1',
  `Satellites` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РљРѕР»РёС‡РµСЃС‚РІРѕ СЃРїСѓС‚РЅРёРєРѕРІ ',
  `RssiGsm` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РЈСЂРѕРІРµРЅСЊ GSM СЃРёРіРЅР°Р»Р°',
  `Events` int NOT NULL DEFAULT '0' COMMENT 'Р¤Р»Р°РіРё СЃРѕР±С‹С‚РёР№',
  `SensorsSet` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РЅР°Р±РѕСЂР° РґР°С‚С‡РёРєРѕРІ',
  `Sensors` varbinary(50) NOT NULL DEFAULT '0' COMMENT 'Р—РЅР°С‡РµРЅРёСЏ РґР°С‚С‡РёРєРѕРІ',
  `Voltage` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РќР°РїСЂСЏР¶РµРЅРёРµ РїРёС‚Р°РЅРёСЏ С‚РµРєСѓС‰РµРіРѕ РёСЃС‚РѕС‡РЅРёРєР°/1.5 РѕС‚ 0 РґРѕ 38,2',
  `DGPS` varchar(32) NOT NULL DEFAULT '0' COMMENT 'Р”Р°РЅРЅС‹Рµ РґРёС„С„РµСЂРµРЅС†РёР°Р»СЊРЅРѕР№ СЃРёСЃС‚РµРјС‹ GPS - РІС‹СЃРѕС‚Р°,С€РёСЂРѕС‚Р°,РґРѕР»РіРѕС‚Р°',
  `LogID` int NOT NULL DEFAULT '0' COMMENT 'РРґРµРЅС‚РёС„РёРєР°С‚РѕСЂ Р·Р°РїРёСЃРё РІ Р¶СѓСЂРЅР°Р»Рµ РўРµР»РµС‚СЂРµРєР°',
  `SrvPacketID` bigint 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 NOT NULL DEFAULT '0',
  `LogID` int NOT NULL DEFAULT '0',
  `SrvPacketID` bigint 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 NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РўРµР»РµС‚СЂРµРєР°',
  `LogID` int unsigned DEFAULT '0' COMMENT 'РРґРµРЅС‚РёС„РёРєР°С‚РѕСЂ Р·Р°РїРёСЃРё РІ Р¶СѓСЂРЅР°Р»Рµ РўРµР»РµС‚СЂРµРєР°',
  `SrvPacketID` bigint 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 DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `Latitude` int NOT NULL DEFAULT '0',
  `Longitude` int NOT NULL DEFAULT '0',
  `Altitude` int DEFAULT '0',
  `UnixTime` int NOT NULL DEFAULT '0',
  `Speed` smallint NOT NULL DEFAULT '0',
  `Direction` int NOT NULL DEFAULT '0',
  `Valid` tinyint NOT NULL DEFAULT '1',
  `InMobitelID` int DEFAULT '0',
  `Events` int unsigned DEFAULT '0',
  `Sensor1` tinyint unsigned DEFAULT '0',
  `Sensor2` tinyint unsigned DEFAULT '0',
  `Sensor3` tinyint unsigned DEFAULT '0',
  `Sensor4` tinyint unsigned DEFAULT '0',
  `Sensor5` tinyint unsigned DEFAULT '0',
  `Sensor6` tinyint unsigned DEFAULT '0',
  `Sensor7` tinyint unsigned DEFAULT '0',
  `Sensor8` tinyint unsigned DEFAULT '0',
  `LogID` int DEFAULT '0',
  `isShow` tinyint DEFAULT '0',
  `whatIs` smallint unsigned NOT NULL DEFAULT '0',
  `Counter1` int NOT NULL DEFAULT '-1',
  `Counter2` int NOT NULL DEFAULT '-1',
  `Counter3` int NOT NULL DEFAULT '-1',
  `Counter4` int 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 NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `Latitude` int DEFAULT '0',
  `Longitude` int DEFAULT '0',
  `Altitude` int DEFAULT NULL,
  `UnixTime` int DEFAULT '0',
  `Speed` smallint DEFAULT '0',
  `Direction` int NOT NULL DEFAULT '0',
  `Valid` tinyint DEFAULT '1',
  `InMobitelID` int DEFAULT NULL,
  `Events` int unsigned DEFAULT '0',
  `Sensor1` tinyint unsigned DEFAULT '0',
  `Sensor2` tinyint unsigned DEFAULT '0',
  `Sensor3` tinyint unsigned DEFAULT '0',
  `Sensor4` tinyint unsigned DEFAULT '0',
  `Sensor5` tinyint unsigned DEFAULT '0',
  `Sensor6` tinyint unsigned DEFAULT '0',
  `Sensor7` tinyint unsigned DEFAULT '0',
  `Sensor8` tinyint unsigned DEFAULT '0',
  `LogID` int DEFAULT '0',
  `isShow` tinyint DEFAULT '0',
  `whatIs` smallint DEFAULT '0',
  `Counter1` int NOT NULL DEFAULT '-1',
  `Counter2` int NOT NULL DEFAULT '-1',
  `Counter3` int NOT NULL DEFAULT '-1',
  `Counter4` int 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 NOT NULL DEFAULT '0',
  `Begin_LogID` int NOT NULL DEFAULT '0' COMMENT 'Значение LogID после которого начинается разрыв',
  `End_LogID` int 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 NOT NULL DEFAULT '0',
  `Begin_LogID` int NOT NULL DEFAULT '0' COMMENT 'Значение LogID после которого начинается разрыв',
  `End_LogID` int NOT NULL DEFAULT '0' COMMENT 'Значение LogID перед которым завершается разрыв',
  `Begin_SrvPacketID` bigint NOT NULL DEFAULT '0',
  `End_SrvPacketID` bigint NOT NULL DEFAULT '0',
  `Id` bigint 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 NOT NULL DEFAULT '0',
  `SrvPacketID` bigint 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 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 NOT NULL DEFAULT '0',
  `Begin_LogID` int NOT NULL DEFAULT '0',
  `End_LogID` int 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;

--
-- 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 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 unsigned DEFAULT NULL COMMENT '10 битный идентификатор водителя',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  `idType` int 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 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 NOT NULL AUTO_INCREMENT,
  `ID` int DEFAULT '0',
  `Name` char(200) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `Mobitel_ID` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `LastRecords` int DEFAULT '0',
  `LastTimes` int DEFAULT '0',
  `LastTimesIndex` int DEFAULT '0',
  `LastMeters` int DEFAULT '0',
  `LastMetersIndex` int DEFAULT '0',
  `MaxSmsNum` int DEFAULT '0',
  `MaxSmsNumIndex` int DEFAULT '0',
  `LatitudeStart` int DEFAULT '0',
  `LatitudeEnd` int DEFAULT '0',
  `LongitudeStart` int DEFAULT '0',
  `LongitudeEnd` int DEFAULT '0',
  `AltitudeStart` int DEFAULT '0',
  `AltitudeEnd` int DEFAULT '0',
  `UnixTimeStart` int DEFAULT '0',
  `UnixTimeEnd` int DEFAULT '0',
  `SpeedStart` int DEFAULT '0',
  `SpeedEnd` int DEFAULT '0',
  `DirectionStart` int DEFAULT '0',
  `DirectionEnd` int DEFAULT '0',
  `NumbersStart` int DEFAULT '0',
  `NumbersEnd` int DEFAULT '0',
  `WhatSend` int DEFAULT '0',
  `CheckMask` int DEFAULT '0',
  `InMobitelID` int DEFAULT '0',
  `Events` int DEFAULT '0',
  `Number1` int DEFAULT '0',
  `Number2` int DEFAULT '0',
  `Number3` int DEFAULT '0',
  `Number4` int DEFAULT '0',
  `Number5` int 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Message_ID` int 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 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=2 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','7233','0','0','0','0','0',0,0,'0','0');
/*!40000 ALTER TABLE `internalmobitelconfig` ENABLE KEYS */;
UNLOCK TABLES;

--
-- 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 DEFAULT '0',
  `ID` int 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 DEFAULT '0',
  `ID` int 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 DEFAULT '0',
  `ID` int 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 NOT NULL AUTO_INCREMENT,
  `Color` int DEFAULT '0' COMMENT 'Цвет',
  `Width` int DEFAULT '3' COMMENT 'Толщина линии',
  `Mobitel_ID` int DEFAULT NULL,
  `Icon` blob,
  PRIMARY KEY (`id`),
  KEY `lines_FK1` (`Mobitel_ID`) USING BTREE,
  CONSTRAINT `lines_FK1` FOREIGN KEY (`Mobitel_ID`) REFERENCES `mobitels` (`Mobitel_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 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 */;
INSERT INTO `lines` VALUES (1,-16777077,3,926036787,NULL);
/*!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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `DefaultLineStyle_ID` int DEFAULT '0',
  `DefaulPointStyle_ID` int DEFAULT '0',
  `EventPointStyle1_ID` int DEFAULT '0',
  `EventPointStyle2_ID` int DEFAULT '0',
  `EventPointStyle3_ID` int DEFAULT '0',
  `EventPointStyle4_ID` int DEFAULT '0',
  `EventPointStyle5_ID` int DEFAULT '0',
  `EventPointStyle6_ID` int DEFAULT '0',
  `EventPointStyle7_ID` int DEFAULT '0',
  `EventPointStyle8_ID` int DEFAULT '0',
  `EventPointStyle9_ID` int DEFAULT '0',
  `EventPointStyle10_ID` int DEFAULT '0',
  `EventPointStyle11_ID` int DEFAULT '0',
  `EventPointStyle12_ID` int DEFAULT '0',
  `EventPointStyle13_ID` int DEFAULT '0',
  `EventPointStyle14_ID` int DEFAULT '0',
  `EventPointStyle15_ID` int DEFAULT '0',
  `EventPointStyle16_ID` int DEFAULT '0',
  `EventPointStyle17_ID` int DEFAULT '0',
  `EventPointStyle18_ID` int DEFAULT '0',
  `EventPointStyle19_ID` int DEFAULT '0',
  `EventPointStyle20_ID` int DEFAULT '0',
  `EventPointStyle21_ID` int DEFAULT '0',
  `EventPointStyle22_ID` int DEFAULT '0',
  `EventPointStyle23_ID` int DEFAULT '0',
  `EventPointStyle24_ID` int DEFAULT '0',
  `EventPointStyle25_ID` int DEFAULT '0',
  `EventPointStyle26_ID` int DEFAULT '0',
  `EventPointStyle27_ID` int DEFAULT '0',
  `EventPointStyle28_ID` int DEFAULT '0',
  `EventPointStyle29_ID` int DEFAULT '0',
  `EventPointStyle30_ID` int DEFAULT '0',
  `EventPointStyle31_ID` int DEFAULT '0',
  `EventPointStyle32_ID` int DEFAULT '0',
  `SensorPointStyle1_ID` int DEFAULT '0',
  `SensorPointStyle2_ID` int DEFAULT '0',
  `SensorPointStyle3_ID` int DEFAULT '0',
  `SensorPointStyle4_ID` int DEFAULT '0',
  `SensorPointStyle5_ID` int DEFAULT '0',
  `SensorPointStyle6_ID` int DEFAULT '0',
  `SensorPointStyle7_ID` int DEFAULT '0',
  `SensorPointStyle8_ID` int 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Color` int DEFAULT '0',
  `Width` tinyint DEFAULT '0',
  `Style` tinyint 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `isBitmap` tinyint(1) DEFAULT NULL,
  `SymbolCode` tinyint DEFAULT '0',
  `Color` int DEFAULT '0',
  `Font` char(200) DEFAULT NULL,
  `Size` int DEFAULT '0',
  `Rotation` int DEFAULT '0',
  `BitmapName` char(200) DEFAULT NULL,
  `BitmapStyle` tinyint DEFAULT '0',
  `Style` tinyint 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 NOT NULL AUTO_INCREMENT,
  `Time1` int DEFAULT '0',
  `Time2` int DEFAULT '0',
  `Time3` int DEFAULT '0',
  `Time4` int 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 DEFAULT '0',
  `ServiceInit_ID` int DEFAULT '0',
  `Command_ID` tinyint DEFAULT '0',
  `CommandMask_ID` int DEFAULT '0',
  `MessageCounter` int DEFAULT '0',
  `DataFromService` char(32) DEFAULT NULL,
  `Address` char(20) DEFAULT NULL,
  `Source_ID` int DEFAULT '0',
  `Crc` tinyint DEFAULT '1',
  `SmsId` int DEFAULT '0',
  `AdvCounter` int NOT NULL DEFAULT '0',
  `isNewFromMob` tinyint 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` bigint DEFAULT '0',
  `Flags` int DEFAULT '0',
  `ServiceInit_ID` int DEFAULT '0',
  `ServiceSend_ID` int DEFAULT '0',
  `InternalMobitelConfig_ID` int DEFAULT '0',
  `MapStyleLine_ID` int DEFAULT '0',
  `MapStyleLastPoint_ID` int DEFAULT '0',
  `MapStylePoint_ID` int DEFAULT '0',
  `Route_ID` int DEFAULT '0',
  `DeviceType` int DEFAULT '0',
  `DeviceEngine` int DEFAULT '0',
  `ConfirmedID` int NOT NULL DEFAULT '0' COMMENT 'MIN значение LogID менее которого считается нет пропусков или уже невозможно загрузить',
  `LastInsertTime` int 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=926036788 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 (926036787,'7233','',0,0,0,1,1,6,5,5,0,0,0,0,1780386616,0,1);
/*!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 unsigned NOT NULL,
  `Map_Style_Car` text,
  `Track_Color` int 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 NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int NOT NULL DEFAULT '0',
  `Bound` int 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int NOT NULL,
  `TypeEvent` tinyint NOT NULL,
  `EventId` int NOT NULL DEFAULT '0',
  `ParInt1` int 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 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int NOT NULL,
  `DateEvent` datetime NOT NULL,
  `DateWrite` datetime NOT NULL,
  `TypeEvent` tinyint NOT NULL,
  `Mobitel_id` int NOT NULL DEFAULT '0',
  `Zone_id` int 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 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 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 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int NOT NULL,
  `MobitelId` int NOT NULL,
  `SensorLogicId` int DEFAULT '0',
  `SensorId` int 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int NOT NULL,
  `Id_user` int 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 NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `Latitude` int NOT NULL DEFAULT '0',
  `Longitude` int NOT NULL DEFAULT '0',
  `Altitude` int DEFAULT '0',
  `UnixTime` int NOT NULL DEFAULT '0',
  `Speed` smallint NOT NULL DEFAULT '0',
  `Direction` int NOT NULL DEFAULT '0',
  `Valid` tinyint NOT NULL DEFAULT '1',
  `InMobitelID` int DEFAULT '0',
  `Events` int unsigned DEFAULT '0',
  `Sensor1` tinyint unsigned DEFAULT '0',
  `Sensor2` tinyint unsigned DEFAULT '0',
  `Sensor3` tinyint unsigned DEFAULT '0',
  `Sensor4` tinyint unsigned DEFAULT '0',
  `Sensor5` tinyint unsigned DEFAULT '0',
  `Sensor6` tinyint unsigned DEFAULT '0',
  `Sensor7` tinyint unsigned DEFAULT '0',
  `Sensor8` tinyint unsigned DEFAULT '0',
  `LogID` int DEFAULT '0',
  `isShow` tinyint DEFAULT '0',
  `whatIs` smallint unsigned NOT NULL DEFAULT '0',
  `Counter1` int NOT NULL DEFAULT '-1',
  `Counter2` int NOT NULL DEFAULT '-1',
  `Counter3` int NOT NULL DEFAULT '-1',
  `Counter4` int NOT NULL DEFAULT '-1',
  PRIMARY KEY (`DataGps_ID`),
  KEY `IDX_MobitelidUnixtimeValid` (`Mobitel_ID`,`UnixTime`,`Valid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=412 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 (312,926036787,0,30238970,19818984,166,1780385447,10,97,1,341,0,16,0,1,192,67,192,0,0,341,0,1023,-1,-1,-1,-1),(313,926036787,0,30238954,19819000,166,1780385448,8,104,1,342,0,16,0,1,192,67,192,0,0,342,0,1023,-1,-1,-1,-1),(314,926036787,0,30238940,19818997,166,1780385449,6,123,1,343,0,16,0,1,192,67,192,0,0,343,0,1023,-1,-1,-1,-1),(315,926036787,0,30238929,19818988,166,1780385450,4,137,1,344,0,16,0,1,192,67,192,0,0,344,0,1023,-1,-1,-1,-1),(316,926036787,0,30238918,19818977,166,1780385451,5,131,1,345,0,16,0,1,192,67,192,0,0,345,0,1023,-1,-1,-1,-1),(317,926036787,0,30238898,19818945,166,1780385454,3,143,1,346,0,16,0,1,192,67,192,0,0,346,0,1023,-1,-1,-1,-1),(318,926036787,0,30238897,19818927,166,1780385455,4,159,1,347,0,16,0,1,192,67,192,0,0,347,0,1023,-1,-1,-1,-1),(319,926036787,0,30238818,19818660,165,1780385465,6,170,1,348,0,16,0,1,192,67,192,0,0,348,0,1023,-1,-1,-1,-1),(320,926036787,0,30238795,19818566,165,1780385469,5,163,1,349,0,16,0,1,192,67,192,0,0,349,0,1023,-1,-1,-1,-1),(321,926036787,0,30238759,19818461,167,1780385473,6,157,1,350,0,16,0,1,192,67,192,0,0,350,0,1023,-1,-1,-1,-1),(322,926036787,0,30238731,19818397,169,1780385476,5,165,1,351,0,16,0,1,192,67,192,0,0,351,0,1023,-1,-1,-1,-1),(323,926036787,0,30238708,19818274,170,1780385481,5,171,1,352,0,16,0,1,192,67,192,0,0,352,0,1023,-1,-1,-1,-1),(324,926036787,0,30238690,19818159,169,1780385485,6,165,1,353,0,16,0,1,192,67,192,0,0,353,0,1023,-1,-1,-1,-1),(325,926036787,0,30238642,19818005,170,1780385491,5,159,1,354,0,16,0,1,192,67,192,0,0,354,0,1023,-1,-1,-1,-1),(326,926036787,0,30238619,19817939,170,1780385494,5,165,1,355,0,16,0,1,192,67,192,0,0,355,0,1023,-1,-1,-1,-1),(327,926036787,0,30238600,19817875,170,1780385497,5,159,1,356,0,16,0,1,192,67,192,0,0,356,0,1023,-1,-1,-1,-1),(328,926036787,0,30238580,19817840,171,1780385499,5,143,1,357,0,16,0,1,192,67,192,0,0,357,0,1023,-1,-1,-1,-1),(329,926036787,0,30238566,19817816,171,1780385504,0,138,1,358,0,16,0,1,192,67,192,0,0,358,0,1023,-1,-1,-1,-1),(330,926036787,0,30238599,19817932,171,1780385526,4,57,1,359,0,16,0,1,192,67,192,0,0,359,0,1023,-1,-1,-1,-1),(331,926036787,0,30238601,19817970,171,1780385528,4,48,1,360,0,16,0,1,192,67,192,0,0,360,0,1023,-1,-1,-1,-1),(332,926036787,0,30238602,19818013,171,1780385533,0,47,1,361,0,16,0,1,192,67,192,0,0,361,0,1023,-1,-1,-1,-1),(333,926036787,0,30238629,19818118,171,1780385591,5,45,1,362,0,16,0,1,192,67,192,0,0,362,0,1023,-1,-1,-1,-1),(334,926036787,0,30238647,19818191,170,1780385594,6,39,1,363,0,16,0,1,192,67,192,0,0,363,0,1023,-1,-1,-1,-1),(335,926036787,0,30238735,19818445,171,1780385605,6,45,1,364,0,16,0,1,192,67,192,0,0,364,0,1023,-1,-1,-1,-1),(336,926036787,0,30238787,19818646,171,1780385612,8,39,1,365,0,16,0,1,192,67,192,0,0,365,0,1023,-1,-1,-1,-1),(337,926036787,0,30238847,19818822,171,1780385618,7,45,1,366,0,16,0,1,192,67,192,0,0,366,0,1023,-1,-1,-1,-1),(338,926036787,0,30238902,19819000,171,1780385625,5,39,1,367,0,16,0,1,192,67,192,0,0,367,0,1023,-1,-1,-1,-1),(339,926036787,0,30238914,19819015,171,1780385626,5,27,1,368,0,16,0,1,192,67,192,0,0,368,0,1023,-1,-1,-1,-1),(340,926036787,0,30238930,19819026,171,1780385627,6,13,1,369,0,16,0,1,192,67,192,0,0,369,0,1023,-1,-1,-1,-1),(341,926036787,0,30238949,19819033,171,1780385628,7,6,1,370,0,16,0,1,192,67,192,0,0,370,0,1023,-1,-1,-1,-1),(342,926036787,0,30238968,19819027,171,1780385629,6,228,1,371,0,16,0,1,192,67,192,0,0,371,0,1023,-1,-1,-1,-1),(343,926036787,0,30238987,19819007,171,1780385630,8,214,1,372,0,16,0,1,192,67,192,0,0,372,0,1023,-1,-1,-1,-1),(344,926036787,0,30239005,19818980,171,1780385631,8,206,1,373,0,16,0,1,192,67,192,0,0,373,0,1023,-1,-1,-1,-1),(345,926036787,0,30239035,19818919,171,1780385633,9,198,1,374,0,16,0,1,192,67,192,0,0,374,0,1023,-1,-1,-1,-1),(346,926036787,0,30239100,19818803,169,1780385637,9,205,1,375,0,16,0,1,192,67,192,0,0,375,0,1023,-1,-1,-1,-1),(347,926036787,0,30239207,19818625,167,1780385645,4,199,1,376,0,16,0,1,192,67,192,0,0,376,0,1023,-1,-1,-1,-1),(348,926036787,0,30239217,19818621,167,1780385649,0,199,1,377,0,16,0,1,192,67,192,0,0,377,0,1023,-1,-1,-1,-1),(349,926036787,0,30239217,19818621,167,1780385709,0,199,1,378,0,16,0,1,192,67,224,0,0,378,0,1023,-1,-1,-1,-1),(350,926036787,0,30239217,19818621,167,1780385769,0,199,1,379,0,16,0,1,192,68,64,0,0,379,0,1023,-1,-1,-1,-1),(351,926036787,0,30239217,19818621,167,1780385829,0,199,1,380,0,16,0,1,192,68,48,0,0,380,0,1023,-1,-1,-1,-1),(352,926036787,0,30239283,19818529,168,1780385861,9,210,1,381,0,16,0,1,192,68,0,0,0,381,0,1023,-1,-1,-1,-1),(353,926036787,0,30239890,19817483,165,1780385888,6,225,1,382,0,16,0,1,192,68,0,0,0,382,0,1023,-1,-1,-1,-1),(354,926036787,0,30239906,19817479,165,1780385889,5,239,1,383,0,16,0,1,192,68,0,0,0,383,0,1023,-1,-1,-1,-1),(355,926036787,0,30239920,19817485,165,1780385890,5,11,1,384,0,16,0,1,192,68,0,0,0,384,0,1023,-1,-1,-1,-1),(356,926036787,0,30239942,19817505,164,1780385892,4,26,1,385,0,16,0,1,192,68,0,0,0,385,0,1023,-1,-1,-1,-1),(357,926036787,0,30239951,19817518,164,1780385893,3,37,1,386,0,16,0,1,192,68,0,0,0,386,0,1023,-1,-1,-1,-1),(358,926036787,0,30239966,19817560,165,1780385896,4,48,1,387,0,16,0,1,192,68,0,0,0,387,0,1023,-1,-1,-1,-1),(359,926036787,0,30240097,19818106,167,1780385916,6,41,1,388,0,16,0,1,192,68,0,0,0,388,0,1023,-1,-1,-1,-1),(360,926036787,0,30240106,19818130,167,1780385917,6,33,1,389,0,16,0,1,192,68,0,0,0,389,0,1023,-1,-1,-1,-1),(361,926036787,0,30240120,19818150,167,1780385918,6,25,1,390,0,16,0,1,192,68,0,0,0,390,0,1023,-1,-1,-1,-1),(362,926036787,0,30240151,19818172,167,1780385920,6,9,1,391,0,16,0,1,192,68,0,0,0,391,0,1023,-1,-1,-1,-1),(363,926036787,0,30240187,19818177,167,1780385922,5,237,1,392,0,16,0,1,192,68,0,0,0,392,0,1023,-1,-1,-1,-1),(364,926036787,0,30240230,19818163,168,1780385924,8,230,1,393,0,16,0,1,192,68,0,0,0,393,0,1023,-1,-1,-1,-1),(365,926036787,0,30240427,19818082,167,1780385935,5,237,1,394,0,16,0,1,192,68,0,0,0,394,0,1023,-1,-1,-1,-1),(366,926036787,0,30240454,19818072,166,1780385937,5,225,1,395,0,16,0,1,192,68,0,0,0,395,0,1023,-1,-1,-1,-1),(367,926036787,0,30240463,19818058,166,1780385938,5,216,1,396,0,16,0,1,192,68,0,0,0,396,0,1023,-1,-1,-1,-1),(368,926036787,0,30240489,19818029,165,1780385944,0,218,1,397,0,16,0,1,192,68,0,0,0,397,0,1023,-1,-1,-1,-1),(369,926036787,0,30240458,19818094,166,1780385951,3,49,1,398,0,16,0,1,192,68,0,0,0,398,0,1023,-1,-1,-1,-1),(370,926036787,0,30240465,19818109,167,1780385954,0,49,1,399,0,16,0,1,192,68,0,0,0,399,0,1023,-1,-1,-1,-1),(371,926036787,0,30240465,19818109,167,1780386014,0,49,1,400,0,16,0,1,192,68,0,0,0,400,0,1023,-1,-1,-1,-1),(372,926036787,0,30240465,19818109,167,1780386074,0,49,1,401,0,16,0,1,192,68,64,0,0,401,0,1023,-1,-1,-1,-1),(373,926036787,0,30240304,19818120,168,1780386103,6,107,1,402,0,16,0,1,192,68,80,0,0,402,0,1023,-1,-1,-1,-1),(374,926036787,0,30240212,19818150,168,1780386108,7,115,1,403,0,16,0,1,192,68,96,0,0,403,0,1023,-1,-1,-1,-1),(375,926036787,0,30240175,19818148,168,1780386110,6,130,1,404,0,16,0,1,192,68,96,0,0,404,0,1023,-1,-1,-1,-1),(376,926036787,0,30240144,19818122,168,1780386112,5,139,1,405,0,16,0,1,192,68,96,0,0,405,0,1023,-1,-1,-1,-1),(377,926036787,0,30240131,19818094,168,1780386113,5,148,1,406,0,16,0,1,192,68,96,0,0,406,0,1023,-1,-1,-1,-1),(378,926036787,0,30240120,19818061,168,1780386114,6,161,1,407,0,16,0,1,192,68,96,0,0,407,0,1023,-1,-1,-1,-1),(379,926036787,0,30240113,19818030,168,1780386115,6,167,1,408,0,16,0,1,192,68,112,0,0,408,0,1023,-1,-1,-1,-1),(380,926036787,0,30239940,19817425,169,1780386136,6,173,1,409,0,16,0,1,192,68,128,0,0,409,0,1023,-1,-1,-1,-1),(381,926036787,0,30239938,19817397,169,1780386137,6,184,1,410,0,16,0,1,192,68,128,0,0,410,0,1023,-1,-1,-1,-1),(382,926036787,0,30239943,19817367,168,1780386138,6,198,1,411,0,16,0,1,192,68,128,0,0,411,0,1023,-1,-1,-1,-1),(383,926036787,0,30239953,19817339,168,1780386139,7,205,1,412,0,16,0,1,192,68,128,0,0,412,0,1023,-1,-1,-1,-1),(384,926036787,0,30240090,19817082,166,1780386148,8,199,1,413,0,16,0,1,192,68,128,0,0,413,0,1023,-1,-1,-1,-1),(385,926036787,0,30240129,19816956,165,1780386153,5,207,1,414,0,16,0,1,192,68,128,0,0,414,0,1023,-1,-1,-1,-1),(386,926036787,0,30240140,19816944,165,1780386154,5,223,1,415,0,16,0,1,192,68,128,0,0,415,0,1023,-1,-1,-1,-1),(387,926036787,0,30240153,19816940,165,1780386155,3,233,1,416,0,16,0,1,192,68,128,0,0,416,0,1023,-1,-1,-1,-1),(388,926036787,0,30240168,19816941,165,1780386159,0,233,1,417,0,16,0,1,192,68,128,0,0,417,0,1023,-1,-1,-1,-1),(389,926036787,0,30240168,19816941,165,1780386219,0,233,1,418,0,16,0,1,192,68,128,0,0,418,0,1023,-1,-1,-1,-1),(390,926036787,0,30240168,19816941,165,1780386279,0,233,1,419,0,16,0,1,192,68,64,0,0,419,0,1023,-1,-1,-1,-1),(391,926036787,0,30240168,19816941,165,1780386339,0,233,1,420,0,16,0,1,192,68,48,0,0,420,0,1023,-1,-1,-1,-1),(392,926036787,0,30240260,19816897,166,1780386360,8,213,1,421,0,16,0,1,192,68,48,0,0,421,0,1023,-1,-1,-1,-1),(393,926036787,0,30240446,19816590,164,1780386370,12,207,1,422,0,16,0,1,192,68,32,0,0,422,0,1023,-1,-1,-1,-1),(394,926036787,0,30240509,19816456,163,1780386373,12,200,1,423,0,16,0,1,192,68,32,0,0,423,0,1023,-1,-1,-1,-1),(395,926036787,0,30240771,19815884,164,1780386383,19,207,1,424,0,16,0,1,192,68,32,0,0,424,0,1023,-1,-1,-1,-1),(396,926036787,0,30240931,19815634,162,1780386387,19,213,1,425,0,16,0,1,192,68,32,0,0,425,0,1023,-1,-1,-1,-1),(397,926036787,0,30241845,19814614,162,1780386411,15,221,1,426,0,16,0,1,192,68,16,0,0,426,0,1023,-1,-1,-1,-1),(398,926036787,0,30242154,19814381,162,1780386419,15,228,1,427,0,16,0,1,192,68,16,0,0,427,0,1023,-1,-1,-1,-1),(399,926036787,0,30245474,19813201,164,1780386479,18,230,1,428,0,16,0,1,192,68,48,0,0,428,0,1023,-1,-1,-1,-1),(400,926036787,0,30246319,19812898,163,1780386497,10,4,1,429,0,16,0,1,192,68,80,0,0,429,0,1023,-1,-1,-1,-1),(401,926036787,0,30246344,19812914,163,1780386498,9,19,1,430,0,16,0,1,192,68,80,0,0,430,0,1023,-1,-1,-1,-1),(402,926036787,0,30246367,19812948,164,1780386499,9,33,1,431,0,16,0,1,192,68,80,0,0,431,0,1023,-1,-1,-1,-1),(403,926036787,0,30246382,19812983,164,1780386500,9,39,1,432,0,16,0,1,192,68,80,0,0,432,0,1023,-1,-1,-1,-1),(404,926036787,0,30247271,19815949,162,1780386547,8,47,1,433,0,16,0,1,192,68,224,0,0,433,0,1023,-1,-1,-1,-1),(405,926036787,0,30247276,19815975,162,1780386548,5,53,1,434,0,16,0,1,192,68,224,0,0,434,0,1023,-1,-1,-1,-1),(406,926036787,0,30247274,19815994,162,1780386549,4,69,1,435,0,16,0,1,192,68,224,0,0,435,0,1023,-1,-1,-1,-1),(407,926036787,0,30247269,19816004,162,1780386550,4,86,1,436,0,16,0,1,192,68,224,0,0,436,0,1023,-1,-1,-1,-1),(408,926036787,0,30247260,19816015,162,1780386551,3,97,1,437,0,16,0,1,192,68,224,0,0,437,0,1023,-1,-1,-1,-1),(409,926036787,0,30247254,19816011,163,1780386552,3,121,1,438,0,16,0,1,192,68,224,0,0,438,0,1023,-1,-1,-1,-1),(410,926036787,0,30247240,19816004,164,1780386556,0,121,1,439,0,16,0,1,192,68,240,0,0,439,0,1023,-1,-1,-1,-1),(411,926036787,0,30247240,19816004,164,1780386616,0,121,1,440,0,16,0,1,192,69,48,0,0,440,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 NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РўРµР»РµС‚СЂРµРєР°',
  `Latitude` int NOT NULL DEFAULT '0' COMMENT 'РЁРёСЂРѕС‚Р°',
  `Longitude` int NOT NULL DEFAULT '0' COMMENT 'Р”РѕР»РіРѕС‚Р°',
  `Direction` tinyint unsigned NOT NULL DEFAULT '0' COMMENT 'РіСЂР°РґСѓСЃС‹/1.5',
  `Acceleration` int DEFAULT '0' COMMENT 'РР·РјРµРЅРµРЅРёРµ СЃРєРѕСЂРѕСЃС‚Рё РїРѕ GPS Р·Р° РїРѕСЃР»РµРґРЅСЋСЋ СЃРµРєСѓРЅРґСѓ',
  `UnixTime` int NOT NULL DEFAULT '0',
  `Speed` smallint NOT NULL DEFAULT '0' COMMENT 'РЎРѕС‚РµРЅ РјРµС‚СЂРѕРІ РІ С‡Р°СЃ (0,1 РєРј/С‡)',
  `Valid` tinyint(1) NOT NULL DEFAULT '1',
  `Satellites` tinyint unsigned DEFAULT '0' COMMENT 'РљРѕР»РёС‡РµСЃС‚РІРѕ СЃРїСѓС‚РЅРёРєРѕРІ ',
  `RssiGsm` tinyint unsigned DEFAULT '0' COMMENT 'РЈСЂРѕРІРµРЅСЊ GSM СЃРёРіРЅР°Р»Р°',
  `Events` int DEFAULT '0' COMMENT 'Р¤Р»Р°РіРё СЃРѕР±С‹С‚РёР№',
  `SensorsSet` tinyint(1) DEFAULT '0' COMMENT 'РљРѕРґ РЅР°Р±РѕСЂР° РґР°С‚С‡РёРєРѕРІ',
  `Sensors` varbinary(50) DEFAULT '0' COMMENT 'Р—РЅР°С‡РµРЅРёСЏ РґР°С‚С‡РёРєРѕРІ',
  `Voltage` tinyint unsigned DEFAULT '0' COMMENT 'РќР°РїСЂСЏР¶РµРЅРёРµ РїРёС‚Р°РЅРёСЏ С‚РµРєСѓС‰РµРіРѕ РёСЃС‚РѕС‡РЅРёРєР°/1.5 РѕС‚ 0 РґРѕ 38,2',
  `DGPS` varchar(32) DEFAULT NULL,
  `LogID` int DEFAULT '0' COMMENT 'РРґРµРЅС‚РёС„РёРєР°С‚РѕСЂ Р·Р°РїРёСЃРё РІ Р¶СѓСЂРЅР°Р»Рµ РўРµР»РµС‚СЂРµРєР°',
  `SrvPacketID` bigint 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 NOT NULL AUTO_INCREMENT,
  `Number` int 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,'False'),(3,13,'False'),(4,22,'0'),(5,12,'True'),(6,21,'ru'),(7,19,'http://nominatim.openstreetmap.org/reverse?format=xml&accept-language={2}&lat={0}&lon={1}&zoom=18&addressdetails=1'),(8,23,'QkC9Ip4YS49P28ocINmGujVItxLo3EPg'),(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,'812'),(20,20,'----'),(21,27,'False'),(22,28,'gisfile.com'),(23,25,'False'),(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 unsigned NOT NULL AUTO_INCREMENT COMMENT 'Индекс',
  `Typedata` varchar(255) NOT NULL DEFAULT ' ' COMMENT 'Тип данных',
  `koeffK` double NOT NULL DEFAULT '0' COMMENT 'Коеффициент К',
  `Startbit` int NOT NULL DEFAULT '0' COMMENT 'Стартовый бит поля',
  `Lengthbit` int NOT NULL DEFAULT '0' COMMENT 'Длина поля',
  `Comment` varchar(255) DEFAULT ' ' COMMENT 'Коментарий',
  `Idpcb` int NOT NULL DEFAULT '0' COMMENT 'Индекс платы датчика',
  `NameVal` varchar(12) DEFAULT ' ' COMMENT 'Name meassurement value',
  `NumAlg` int 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=53 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 (12,'запалювання',1,48,1,'',18,'#',5,0,0),(13,'вірт. бак',1,49,8,'',18,'л',7,0,0),(14,'напруга акумулятора трекера',1,16,32,'',18,'В',6,0,0),(32,'бортмережа',0.1181,36,8,'',21,'В',4,0,0),(33,'запалювання',1,60,1,'',21,'#',5,0,0),(34,'бак',1,20,16,'',21,'л',7,0,0),(35,'правий бак',1,80,16,'',22,' л',7,0,0),(36,'штатний ДРП',0.4,128,8,'',22,' %',31,0,0),(37,'оберти двигуна',0.125,0,16,'',22,' rpm',5,0,0),(38,'витрата',0.5,16,64,'',22,' л',27,0,0),(39,'бортмережа',0.001,112,16,'',22,' В',4,0,0),(40,'пробіг за тахографом',0.005,152,32,'',22,' км',6,0,0),(41,'запалювання',1,196,1,'',22,' ',2,0,0),(42,'температура антифрізу',1,184,8,'',22,'°C',6,0,0),(43,'лівий бак',1,96,16,'',22,'л',7,0,0),(44,'бак',0.3922,0,8,'',23,'%',7,0,0),(45,'бортмережа',0.1181,8,8,'',23,'В',6,0,0),(46,'витрата за бортовим компом',0.1,16,32,'',23,'л',27,0,0),(47,'одометр за штатним датчику швидкості',1,48,32,'',23,'км',6,0,0),(48,'оберти двигуна',0.25,80,16,'',23,'rpm',5,0,0),(49,'розрахункове значення навантаження на двигун',0.3922,96,8,'',23,'%',6,0,0),(50,'температура охолоджуючої рідини',0,104,8,'',23,'°C',6,0,0),(51,'температура повітря, що всмоктується',0,112,8,'',23,'°C',6,0,0),(52,'запалювання',1,199,1,'',23,'#',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 unsigned NOT NULL AUTO_INCREMENT COMMENT 'Индекс',
  `Name` varchar(50) NOT NULL DEFAULT '*' COMMENT 'Имя платы датчика',
  `Comment` varchar(255) DEFAULT ' ' COMMENT 'Комментарий',
  `MobitelId` int DEFAULT '-1' COMMENT 'ID машины на которую назначена эта плата датчиков',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=24 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_5xx','для версии исполнения ПД SCAD',-1),(21,'SCAD_37','для версии исполнения ПД SCAD',-1),(22,'SCAD_CAN64','для версии исполнения ПД SCAD',-1),(23,'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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Latitude` int DEFAULT '0',
  `Longitude` int DEFAULT '0',
  `Zone_ID` int 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 NOT NULL AUTO_INCREMENT,
  `AlgorithmID` int NOT NULL DEFAULT '0',
  `SensorID` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=4 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,7,3);
/*!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 NOT NULL AUTO_INCREMENT,
  `ZoneID` int 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 NOT NULL AUTO_INCREMENT,
  `Seq` int DEFAULT NULL,
  `Route_ID` int DEFAULT NULL,
  `Zone_ID` int DEFAULT NULL,
  `Zone_IO` int DEFAULT NULL,
  `GoNext_Min` int DEFAULT NULL,
  `GoNext_Max` int DEFAULT NULL,
  `Link_Item` int DEFAULT NULL,
  `Link_Info` int 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 NOT NULL AUTO_INCREMENT,
  `GIS` blob,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `Modified` int 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 NOT NULL AUTO_INCREMENT,
  `Parent` int 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 NOT NULL AUTO_INCREMENT,
  `List_ID` int DEFAULT NULL,
  `Route_ID` int DEFAULT NULL,
  `Mobitel_ID` int DEFAULT NULL,
  `Time1` int DEFAULT NULL,
  `Time2` int 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 NOT NULL AUTO_INCREMENT,
  `Title` varchar(70) DEFAULT NULL,
  `Time1` int DEFAULT NULL,
  `Time2` int 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 NOT NULL AUTO_INCREMENT,
  `Route_ID` int DEFAULT NULL,
  `Zone_ID` int 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 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 NOT NULL AUTO_INCREMENT,
  `Id_sample` int NOT NULL COMMENT 'Ссылка на шаблон маршрута ',
  `Id_mobitel` int NOT NULL DEFAULT '0' COMMENT 'Транспортное средство ',
  `Id_driver` int 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 DEFAULT '0' COMMENT 'ДУТ Заправлено - кол-во',
  `FuelSubQty` int DEFAULT '0' COMMENT 'ДУТ Слито - кол-во',
  `PointsValidity` int DEFAULT '0' COMMENT 'Валидность данных',
  `PointsCalc` int DEFAULT '0' COMMENT 'Количество точек (по Log_ID) расчетное',
  `PointsFact` int DEFAULT '0' COMMENT 'Количество точек (по Log_ID) фактическое',
  `PointsIntervalMax` varchar(20) DEFAULT NULL COMMENT 'Максимальный интервал между точками',
  `Type` tinyint 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int 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 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int NOT NULL,
  `Id_zone` int NOT NULL DEFAULT '0' COMMENT 'Контрольная зона',
  `Id_event` int 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 NOT NULL AUTO_INCREMENT,
  `Name` varchar(100) NOT NULL,
  `Id_mobitel` int DEFAULT '0' COMMENT 'Транспортное средство (опц)',
  `TimeStart` time DEFAULT NULL COMMENT 'Время начала маршрута (опц)',
  `Distance` double DEFAULT '0' COMMENT 'Общий путь, км',
  `Remark` text COMMENT 'Примечание',
  `Id_main` int 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int NOT NULL,
  `Position` tinyint NOT NULL COMMENT 'Порядковый номер записи шаблона маршрута',
  `Id_event` int NOT NULL COMMENT 'Событие - въезд / выезд ',
  `Id_zone` int 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 NOT NULL AUTO_INCREMENT,
  `Id_shedule_dc` int DEFAULT NULL COMMENT 'Ссылка на справочник графиков',
  `Id_zone_main` int 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 NOT NULL AUTO_INCREMENT,
  `Name` varchar(127) NOT NULL COMMENT 'Название шаблона графика движения',
  `Id_zone_main` int 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int NOT NULL COMMENT 'Ссылка на шапку документа',
  `Id_zone_to` int DEFAULT NULL COMMENT 'Зона прибытия транспортного средства',
  `Id_vehicle` int 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 NOT NULL AUTO_INCREMENT,
  `Id_main` int NOT NULL COMMENT 'Ссылка на шапку документа',
  `Id_zone_to` int 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Password` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int NOT NULL DEFAULT '0',
  `Rule1` tinyint NOT NULL DEFAULT '0',
  `Rule2` tinyint NOT NULL DEFAULT '0',
  `Rule3` tinyint NOT NULL DEFAULT '0',
  `Rule4` tinyint NOT NULL DEFAULT '0',
  `Rule5` tinyint NOT NULL DEFAULT '0',
  `Rule6` tinyint NOT NULL DEFAULT '0',
  `Rule7` tinyint NOT NULL DEFAULT '0',
  `Rule8` tinyint NOT NULL DEFAULT '0',
  `Rule9` tinyint NOT NULL DEFAULT '0',
  `Rule10` tinyint NOT NULL DEFAULT '0',
  `Rule11` tinyint NOT NULL DEFAULT '0',
  `Rule12` tinyint NOT NULL DEFAULT '0',
  `Rule13` tinyint NOT NULL DEFAULT '0',
  `Rule14` tinyint NOT NULL DEFAULT '0',
  `Rule15` tinyint NOT NULL DEFAULT '0',
  `Rule16` tinyint 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 NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int DEFAULT NULL,
  `Sensor_ID` int DEFAULT NULL,
  `FirstBit` int 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 NOT NULL AUTO_INCREMENT,
  `Title` varchar(70) DEFAULT NULL,
  `Kind` varchar(20) DEFAULT NULL,
  `BitsCount` int DEFAULT NULL,
  `FirstBit` int 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 NOT NULL AUTO_INCREMENT,
  `Name` char(45) NOT NULL,
  `Description` char(45) DEFAULT NULL,
  `AlgorithmID` int 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 unsigned NOT NULL AUTO_INCREMENT,
  `Sensor_id` int unsigned NOT NULL,
  `UserValue` double(10,5) NOT NULL,
  `SensorValue` double(10,5) NOT NULL,
  `K` double(10,5) NOT NULL DEFAULT '1.00000',
  `b` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `Index_2` (`Sensor_id`,`UserValue`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=17 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 */;
INSERT INTO `sensorcoefficient` VALUES (1,3,0.00000,0.00000,0.22581,0),(2,3,1.00000,3913.00000,-0.04286,168.7),(3,3,10.00000,3703.00000,-0.04286,168.7),(4,3,20.00000,3436.00000,-0.03745,148.68913857677904),(5,3,30.00000,3180.00000,-0.03906,154.21875),(6,3,40.00000,2925.00000,-0.03922,154.70588235294116),(7,3,50.00000,2676.00000,-0.04016,157.46987951807228),(8,3,60.00000,2424.00000,-0.03968,156.1904761904762),(9,3,70.00000,2175.00000,-0.04016,157.34939759036143),(10,3,80.00000,1924.00000,-0.03984,156.65338645418325),(11,3,90.00000,1675.00000,-0.04016,157.2690763052209),(12,3,100.00000,1419.00000,-0.03906,155.4296875),(13,3,110.00000,1161.00000,-0.03876,155),(14,3,120.00000,902.00000,-0.03861,154.82625482625483),(15,3,123.00000,849.00000,-0.05660,171.0566037735849),(16,3,133.00000,589.00000,-0.03846,155.65384615384616);
/*!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 unsigned NOT NULL AUTO_INCREMENT,
  `datagps_id` int unsigned NOT NULL,
  `sensor_id` int 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 NOT NULL AUTO_INCREMENT,
  `mobitel_id` int NOT NULL,
  `Name` varchar(45) NOT NULL,
  `Description` varchar(200) NOT NULL,
  `StartBit` int unsigned NOT NULL,
  `Length` int 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=4 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,926036787,'бортмережа','',36,8,'В',1.00000,0,0),(2,926036787,'запалювання','',60,1,'#',1.00000,0,0),(3,926036787,'бак','',20,16,'л',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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `ServiceType_ID` int 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 DEFAULT '0',
  `CAtoSAtime` int DEFAULT '0',
  `SAtoCAint` int DEFAULT '0',
  `SAtoCAtime` int DEFAULT '0',
  `SAtoCAtext` char(50) DEFAULT 'STOPPED',
  `CAtoSAtext` char(50) DEFAULT 'STOPPED',
  `MobitelActive_ID` int NOT NULL DEFAULT '0',
  `Active` tinyint 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 NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int 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 DEFAULT '0',
  `RfMobitel` varchar(50) DEFAULT NULL,
  `Message_ID` int DEFAULT '0',
  PRIMARY KEY (`ServiceSend_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 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,'','',1,0,'102',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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `Flags` int 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 NOT NULL AUTO_INCREMENT,
  `TimeBreak` time DEFAULT '00:01:00' COMMENT 'Минимальное время остановки',
  `RotationMain` int DEFAULT '100' COMMENT 'Обороты основного двигателя',
  `RotationAdd` int DEFAULT '100' COMMENT 'Обороты доп. двигателя',
  `FuelingEdge` int DEFAULT '0' COMMENT 'Минимальная заправка',
  `band` int DEFAULT '25' COMMENT 'Полоса осреднения',
  `FuelingDischarge` int DEFAULT '0' COMMENT 'Минимальный слив топлива',
  `accelMax` double DEFAULT '1' COMMENT 'Максимальное ускорение',
  `breakMax` double DEFAULT '1' COMMENT 'Максимальное торможение',
  `speedMax` double DEFAULT '70' COMMENT 'Максимальная скорость',
  `idleRunningMain` int DEFAULT '0' COMMENT 'Холостой ход основного двигателя',
  `idleRunningAdd` int 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 NOT NULL DEFAULT '10' COMMENT 'Радиус поиска заправляемых ТС вокруг топливозаправщика',
  `FuelerMaxTimeStop` time NOT NULL DEFAULT '00:02:00' COMMENT 'Минимальное время до заправки следующего ТС',
  `FuelerMinFuelrate` int NOT NULL DEFAULT '1' COMMENT 'Минимальная величина заправки, что будет попадать в отчет',
  `FuelerCountInMotion` int NOT NULL DEFAULT '0' COMMENT 'Считать ли заправки, при не нулевой скорости',
  `FuelrateWithDischarge` int NOT NULL DEFAULT '0' COMMENT 'Считать ли в расходе сливы',
  `FuelingMinMaxAlgorithm` int 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 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,80,0,0,'Настройка 1','Настройка по умолчанию',15.00000,'00:02:00','00:00:00','00:00:00','00:01:00',10,'00:02:00',1,0,1,0,'03:00:00',5,5,0,'00:00:00',0);
/*!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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int 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 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 NOT NULL AUTO_INCREMENT,
  `DataString` char(50) DEFAULT NULL,
  `DataInteger` int DEFAULT '0',
  `unixtime` char(50) DEFAULT NULL,
  `isNew` int 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 NOT NULL AUTO_INCREMENT,
  `MinValue` double NOT NULL,
  `MaxValue` double NOT NULL,
  `Title` varchar(50) NOT NULL,
  `SensorId` int DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `State_FK` (`SensorId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 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);
/*!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 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 NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` text COMMENT 'Описание',
  `Setting_id` int 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int DEFAULT '0',
  `Flags` int DEFAULT '0',
  `TelNumber` char(50) DEFAULT NULL,
  PRIMARY KEY (`TelNumber_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=103 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,'rcs','mtel',0,0,'+380670085354');
/*!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 unsigned NOT NULL DEFAULT '0',
  `sensor_id` int 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 NOT NULL DEFAULT '0',
  `Mobitel_ID` int DEFAULT '0',
  `Message_ID` int DEFAULT '0',
  `Latitude` int DEFAULT '0',
  `Longitude` int DEFAULT '0',
  `Altitude` int DEFAULT NULL,
  `UnixTime` int DEFAULT '0',
  `Speed` smallint DEFAULT '0',
  `Direction` int NOT NULL DEFAULT '0',
  `Valid` tinyint DEFAULT '1',
  `InMobitelID` int DEFAULT NULL,
  `Events` int unsigned DEFAULT '0',
  `Sensor1` tinyint unsigned DEFAULT '0',
  `Sensor2` tinyint unsigned DEFAULT '0',
  `Sensor3` tinyint unsigned DEFAULT '0',
  `Sensor4` tinyint unsigned DEFAULT '0',
  `Sensor5` tinyint unsigned DEFAULT '0',
  `Sensor6` tinyint unsigned DEFAULT '0',
  `Sensor7` tinyint unsigned DEFAULT '0',
  `Sensor8` tinyint unsigned DEFAULT '0',
  `LogID` int DEFAULT '0',
  `isShow` tinyint DEFAULT '0',
  `whatIs` smallint unsigned DEFAULT '0',
  `Counter1` int NOT NULL DEFAULT '-1',
  `Counter2` int NOT NULL DEFAULT '-1',
  `Counter3` int NOT NULL DEFAULT '-1',
  `Counter4` int 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 NOT NULL AUTO_INCREMENT,
  `InitialStateId` int DEFAULT NULL,
  `FinalStateId` int DEFAULT NULL,
  `Title` varchar(50) NOT NULL,
  `SensorId` int 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=3 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,'1',2,'Default','Default',0,1),(2,2,1,'0',2,'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 NOT NULL AUTO_INCREMENT,
  `Id_role` int NOT NULL,
  `Id_type` int NOT NULL,
  `Id_object` int 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=13 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 (1,2,3,5),(2,2,3,8),(3,2,3,9),(4,2,3,10),(5,2,3,13),(6,2,3,14),(7,2,3,15),(8,2,3,16),(9,2,3,19),(10,2,3,20),(11,2,3,21),(12,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 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 NOT NULL AUTO_INCREMENT,
  `TypeLog` int NOT NULL DEFAULT '0',
  `DateAction` datetime NOT NULL,
  `Id_document` int 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=8 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,'2026-06-02 10:31:20',0,'25->0 Період згладжування','admin','MNK_ROG'),(2,8,'2026-06-02 10:31:20',0,'10->7 Поріг зливу','admin','MNK_ROG'),(3,8,'2026-06-02 10:31:20',0,'50->20 Поріг заправки','admin','MNK_ROG'),(4,8,'2026-06-02 10:31:20',0,'70->80 Максимальна швидкість руху, км/год','admin','MNK_ROG'),(5,8,'2026-06-02 10:31:32',0,'0->1 Не враховувати зливи у витратах','admin','MNK_ROG'),(6,9,'2026-06-02 10:33:41',3,'Вхід','admin','MNK_ROG'),(7,9,'2026-06-02 10:33:42',3,'Завантижити','admin','MNK_ROG');
/*!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 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 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 'R!V\Z\�m̌\�r�\�b߆4�6\�K��$t�\�k��',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 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 NOT NULL AUTO_INCREMENT,
  `MakeCar` text COMMENT 'Марка автомобиля',
  `NumberPlate` text COMMENT 'Номерной знак',
  `Team_id` int DEFAULT NULL,
  `Mobitel_id` int DEFAULT NULL,
  `Odometr` int DEFAULT '0' COMMENT 'Показания одометра',
  `CarModel` text COMMENT 'Модель',
  `setting_id` int DEFAULT '1',
  `odoTime` datetime DEFAULT NULL COMMENT 'Дата и время сверки одометра',
  `driver_id` int DEFAULT '-1',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  `Category_id` int DEFAULT NULL COMMENT 'Категория транспортая',
  `Category_id2` int DEFAULT NULL COMMENT 'Категория2 транспорта',
  `PcbVersionId` int DEFAULT '-1' COMMENT 'Версия плат датчика назначенная на машину',
  `Category_id3` int DEFAULT NULL COMMENT 'Категория3 транспорта',
  `Category_id4` int DEFAULT NULL COMMENT 'Категория4 транспорта',
  `FuelWayLiter` double DEFAULT '0' COMMENT 'Расход топлива л/100 км',
  `FuelMotorLiter` double DEFAULT '0' COMMENT 'Расход топлива л/моточас',
  `Identifier` int 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=2 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,'МАЗ','BI 7795 CP',6,926036787,0,'',1,NULL,1,'',NULL,NULL,21,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 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 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 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 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 NOT NULL AUTO_INCREMENT,
  `Comment` varchar(255) DEFAULT NULL,
  `Mobitel_id` int 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 NOT NULL AUTO_INCREMENT,
  `Num` int 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 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 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 NOT NULL AUTO_INCREMENT,
  `Zone_ID` int DEFAULT '0',
  `ConfigZoneSet_ID` int DEFAULT '0',
  `In_flag` tinyint NOT NULL DEFAULT '0',
  `Out_flag` tinyint NOT NULL DEFAULT '0',
  `In_flag2` tinyint NOT NULL DEFAULT '0',
  `Out_flag2` tinyint NOT NULL DEFAULT '0',
  PRIMARY KEY (`ZoneRelation_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=222 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 NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` text,
  `ID` int DEFAULT '0',
  `Status` tinyint DEFAULT '0',
  `Square` double(14,5) DEFAULT '0.00000' COMMENT 'Площадь контрольной зоны',
  `ZoneColor` int DEFAULT '0' COMMENT 'Цвет контрольной зоны',
  `TextColor` int 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 DEFAULT '0' COMMENT 'Текстура контрольной зоны',
  `DateCreate` datetime DEFAULT NULL COMMENT 'Дата создания',
  `Id_main` int DEFAULT '0' COMMENT 'Ссылка на элемент верхнего уровня в иерархии',
  `Level` tinyint DEFAULT '1' COMMENT 'Уровень в иерархии',
  `StyleId` int unsigned NOT NULL DEFAULT '0' COMMENT 'ID стиля зоны',
  `ZonesGroupId` int unsigned NOT NULL DEFAULT '1' COMMENT 'ID Группы зон',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  `Category_id` int DEFAULT NULL COMMENT 'Категория для зоны',
  `Category_id2` int 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 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 'lohvytsya_service'
--

--
-- Dumping routines for database 'lohvytsya_service'
--
/*!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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `BMCTransferBuffer`(IN DatagpsIsUpdated INT, IN Datagps64IsUpdated INT)
    COMMENT 'v1'
BEGIN
	DECLARE MobitelID INT;
	DECLARE done INT DEFAULT FALSE;
	DECLARE CursorMobitels CURSOR FOR SELECT Mobitel_ID FROM datagpsbuffer_bmc WHERE `Online`=1;
	DECLARE CursorMobitels64 CURSOR FOR SELECT Mobitel_ID FROM datagpsbuffer_bmc64 WHERE `Online`=1;
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
    
	/* datagps */
	IF DatagpsIsUpdated THEN
		OPEN CursorMobitels;
		read_loop: LOOP
			FETCH CursorMobitels INTO MobitelID;
			IF done THEN
				LEAVE read_loop;
			END IF;
			DELETE FROM `online` WHERE Mobitel_ID=MobitelID AND UnixTime <= (SELECT COALESCE(UnixTime, 0) FROM (SELECT UnixTime FROM `online` WHERE Mobitel_ID=MobitelID ORDER BY UnixTime DESC LIMIT 100, 1) o);
		END LOOP;
		CLOSE CursorMobitels;
		UPDATE mobitels m,datagpsbuffer_bmc b SET m.LastInsertTime=b.UnixTime WHERE m.Mobitel_ID=b.Mobitel_ID AND m.LastInsertTime<b.UnixTime;
	END IF;
	/* datagps64 */
	IF Datagps64IsUpdated THEN
		OPEN CursorMobitels64;
		read_loop: LOOP
			FETCH CursorMobitels64 INTO MobitelID;
			IF done THEN
				LEAVE read_loop;
			END IF;
			DELETE FROM `online64` WHERE Mobitel_ID=MobitelID AND UnixTime <= (SELECT COALESCE(UnixTime, 0) FROM (SELECT UnixTime FROM `online64` WHERE Mobitel_ID=MobitelID ORDER BY UnixTime DESC LIMIT 100, 1) o);
		END LOOP;
		CLOSE CursorMobitels64;
		UPDATE mobitels m,datagpsbuffer_bmc64 b SET m.LastInsertTime=b.UnixTime WHERE m.Mobitel_ID=b.Mobitel_ID AND m.LastInsertTime<b.UnixTime;
	END IF;
END ;;
DELIMITER ;
/*!50003 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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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 `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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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 `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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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 `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  = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection  = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,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 */ ;
/*!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 2026-06-02 10:55:10
