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

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

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

DROP TABLE IF EXISTS `agro_params`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `agro_params` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Number` int(11) NOT NULL COMMENT 'Номер параметра',
  `Value` varchar(100) DEFAULT NULL COMMENT 'Значение',
  `Description` varchar(50) DEFAULT NULL COMMENT 'Описание',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Таблица параметров';
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `configdrivermessage`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configdrivermessage` (
  `ConfigDriverMessage_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `DriverMessage` char(200) DEFAULT NULL,
  PRIMARY KEY (`ConfigDriverMessage_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `configevent`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configevent` (
  `ConfigEvent_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `tmr1Log` int(11) DEFAULT '0',
  `tmr2Send` int(11) DEFAULT '0',
  `tmr3Zone` int(11) DEFAULT '0',
  `dist1Log` int(11) DEFAULT '0',
  `dist2Send` int(11) DEFAULT '0',
  `dist3Zone` int(11) DEFAULT '0',
  `deltaTimeZone` int(11) DEFAULT '0',
  `gprsEmail` int(11) NOT NULL DEFAULT '0',
  `gprsFtp` int(11) NOT NULL DEFAULT '0',
  `gprsSocket` int(11) NOT NULL DEFAULT '0',
  `maskSensor` char(50) DEFAULT NULL,
  `maskEvent1` int(11) DEFAULT '0',
  `maskEvent2` int(11) DEFAULT '0',
  `maskEvent3` int(11) DEFAULT '0',
  `maskEvent4` int(11) DEFAULT '0',
  `maskEvent5` int(11) DEFAULT '0',
  `maskEvent6` int(11) DEFAULT '0',
  `maskEvent7` int(11) DEFAULT '0',
  `maskEvent8` int(11) DEFAULT '0',
  `maskEvent9` int(11) DEFAULT '0',
  `maskEvent10` int(11) DEFAULT '0',
  `maskEvent11` int(11) DEFAULT '0',
  `maskEvent12` int(11) DEFAULT '0',
  `maskEvent13` int(11) DEFAULT '0',
  `maskEvent14` int(11) DEFAULT '0',
  `maskEvent15` int(11) DEFAULT '0',
  `maskEvent16` int(11) DEFAULT '0',
  `maskEvent17` int(11) DEFAULT '0',
  `maskEvent18` int(11) DEFAULT '0',
  `maskEvent19` int(11) DEFAULT '0',
  `maskEvent20` int(11) DEFAULT '0',
  `maskEvent21` int(11) DEFAULT '0',
  `maskEvent22` int(11) DEFAULT '0',
  `maskEvent23` int(11) DEFAULT '0',
  `maskEvent24` int(11) DEFAULT '0',
  `maskEvent25` int(11) DEFAULT '0',
  `maskEvent26` int(11) DEFAULT '0',
  `maskEvent27` int(11) DEFAULT '0',
  `maskEvent28` int(11) DEFAULT '0',
  `maskEvent29` int(11) DEFAULT '0',
  `maskEvent30` int(11) DEFAULT '0',
  `maskEvent31` int(11) DEFAULT '0',
  PRIMARY KEY (`ConfigEvent_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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),(2,'','',2,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(3,'','',3,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(4,'','',4,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(5,'0023','Desctiption for Teletrack registered at 09.02.2022 10:15:15',5,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(6,'4739','Desctiption for Teletrack registered at 09.02.2022 10:15:56',6,0,0,0,0,0,0,0,0,0,0,0,0,NULL,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
/*!40000 ALTER TABLE `configevent` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configgprsemail`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configgprsemail` (
  `ConfigGprsEmail_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Smtpserv` varchar(50) NOT NULL DEFAULT '',
  `Smtpun` varchar(50) NOT NULL DEFAULT '',
  `Smtppw` varchar(50) NOT NULL DEFAULT '',
  `Pop3serv` varchar(50) NOT NULL DEFAULT '',
  `Pop3un` varchar(50) NOT NULL DEFAULT '',
  `Pop3pw` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`ConfigGprsEmail_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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,'','','','','',''),(2,'','',2,0,0,'','','','','',''),(3,'','',3,0,0,'','','','','',''),(4,'','',4,0,0,'','','','','',''),(5,'0023','Desctiption for Teletrack registered at 09.02.2022 10:15:15',5,0,0,'','','','','',''),(6,'4739','Desctiption for Teletrack registered at 09.02.2022 10:15:56',6,0,0,'','','','','','');
/*!40000 ALTER TABLE `configgprsemail` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configgprsinit`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configgprsinit` (
  `ConfigGprsInit_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Domain` varchar(50) NOT NULL DEFAULT '0',
  `InitString` varchar(200) NOT NULL DEFAULT '',
  PRIMARY KEY (`ConfigGprsInit_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `configgprsmain`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configgprsmain` (
  `ConfigGprsMain_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Mode` int(11) NOT NULL DEFAULT '0',
  `Apnserv` varchar(50) NOT NULL DEFAULT '',
  `Apnun` varchar(50) NOT NULL DEFAULT '',
  `Apnpw` varchar(50) NOT NULL DEFAULT '',
  `Dnsserv1` varchar(50) NOT NULL DEFAULT '',
  `Dialn1` varchar(50) NOT NULL DEFAULT '',
  `Ispun` varchar(50) NOT NULL DEFAULT '',
  `Isppw` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`ConfigGprsMain_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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,'','','','','','',''),(2,'','',2,0,0,0,'','','','','','',''),(3,'','',3,0,0,0,'','','','','','',''),(4,'','',4,0,0,0,'','','','','','',''),(5,'0023','Desctiption for Teletrack registered at 09.02.2022 10:15:15',5,0,0,0,'','','','','','',''),(6,'4739','Desctiption for Teletrack registered at 09.02.2022 10:15:56',6,0,0,0,'','','','','','','');
/*!40000 ALTER TABLE `configgprsmain` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configmain`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configmain` (
  `ConfigMain_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `ConfigOther_ID` int(11) DEFAULT '0',
  `ConfigDriverMessage_ID` int(11) DEFAULT '0',
  `ConfigEvent_ID` int(11) DEFAULT '0',
  `ConfigUnique_ID` int(11) DEFAULT '0',
  `ConfigZoneSet_ID` int(11) DEFAULT '0',
  `ConfigSensorSet_ID` int(11) DEFAULT '0',
  `ConfigTel_ID` int(11) DEFAULT '0',
  `ConfigSms_ID` int(11) DEFAULT '0',
  `Mobitel_ID` int(11) DEFAULT '0',
  `ConfigGprsMain_ID` int(11) NOT NULL DEFAULT '0',
  `ConfigGprsEmail_ID` int(11) NOT NULL DEFAULT '0',
  `ConfigGprsInit_ID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ConfigMain_ID`),
  KEY `Index_2` (`Mobitel_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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,959590963,1,1,50),(2,'','',0,0,50,50,2,50,50,50,2,2,909195569,2,2,50),(3,'','',0,0,50,50,3,50,50,50,3,3,942879027,3,3,50),(4,'','',0,0,50,50,4,50,50,50,4,4,926431026,4,4,50),(5,'mobitel','mca4',0,0,50,50,5,50,50,50,5,5,959590964,5,5,50),(6,'mobitel','mca4',0,0,50,50,6,50,50,50,6,6,959590965,6,6,50);
/*!40000 ALTER TABLE `configmain` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configother`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configother` (
  `ConfigOther_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Pin` int(11) DEFAULT '0',
  `Lang` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`ConfigOther_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `configsms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configsms` (
  `ConfigSms_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `smsCenter_ID` int(11) DEFAULT '0',
  `smsDspt_ID` int(11) DEFAULT '0',
  `smsEmailGate_ID` int(11) DEFAULT '0',
  `dsptEmail` char(14) DEFAULT NULL,
  `dsptGprsEmail` char(50) DEFAULT NULL,
  PRIMARY KEY (`ConfigSms_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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),(2,'','',2,0,0,0,0,0,NULL,NULL),(3,'','',3,0,0,0,0,0,NULL,NULL),(4,'','',4,0,0,0,0,0,NULL,NULL),(5,'0023','Desctiption for Teletrack registered at 09.02.2022 10:15:15',5,0,0,0,0,0,NULL,NULL),(6,'4739','Desctiption for Teletrack registered at 09.02.2022 10:15:56',6,0,0,0,0,0,NULL,NULL);
/*!40000 ALTER TABLE `configsms` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configtel`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configtel` (
  `ConfigTel_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `telSOS` int(11) DEFAULT '0',
  `telDspt` int(11) DEFAULT '0',
  `telAccept1` int(11) DEFAULT '0',
  `telAccept2` int(11) DEFAULT '0',
  `telAccept3` int(11) DEFAULT '0',
  `telAnswer` int(11) DEFAULT '0',
  PRIMARY KEY (`ConfigTel_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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),(2,'','',2,0,0,0,0,0,0,0,0),(3,'','',3,0,0,0,0,0,0,0,0),(4,'','',4,0,0,0,0,0,0,0,0),(5,'0023','Desctiption for Teletrack registered at 09.02.2022 10:15:15',5,0,0,0,0,0,0,0,0),(6,'4739','Desctiption for Teletrack registered at 09.02.2022 10:15:56',6,0,0,0,0,0,0,0,0);
/*!40000 ALTER TABLE `configtel` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `configunique`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `configunique` (
  `ConfigUnique_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `pswd` char(8) DEFAULT NULL,
  `tmpPswd` char(8) DEFAULT NULL,
  `dsptId` char(4) DEFAULT NULL,
  PRIMARY KEY (`ConfigUnique_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `data_zones`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `data_zones` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `DataGps_ID` int(11) DEFAULT NULL,
  `Zone_ID` int(11) DEFAULT NULL,
  `Zone_IO` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `datagpslosted`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `datagpslosted` (
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0',
  `Begin_LogID` int(11) NOT NULL DEFAULT '0',
  `End_LogID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Mobitel_ID`,`Begin_LogID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `driver_types`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `driver_types` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `TypeName` varchar(50) DEFAULT NULL COMMENT 'Специализация водителя',
  PRIMARY KEY (`Id`),
  UNIQUE KEY `id` (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `internalmobitelconfig`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `internalmobitelconfig` (
  `InternalMobitelConfig_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `devIdLong` char(16) DEFAULT NULL,
  `devIdShort` char(4) DEFAULT NULL,
  `verProtocolLong` char(16) DEFAULT NULL,
  `verProtocolShort` char(2) DEFAULT NULL,
  `moduleIdGps` char(50) DEFAULT NULL,
  `moduleIdGsm` char(50) DEFAULT NULL,
  `moduleIdRf` char(50) DEFAULT NULL,
  `RfType` smallint(6) NOT NULL DEFAULT '0',
  `ActiveRf` tinyint(1) NOT NULL DEFAULT '0',
  `moduleIdSs` char(50) DEFAULT NULL,
  `moduleIdMm` char(50) NOT NULL DEFAULT 'moduleIdMm',
  PRIMARY KEY (`InternalMobitelConfig_ID`),
  KEY `Index_3` (`Message_ID`),
  KEY `Index_4` (`devIdShort`),
  KEY `IDX_InternalmobitelconfigID` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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','9223','0','0','0','0','0',0,0,'0','0'),(2,'','',2,0,'0','6191','0','0','0','0','0',0,0,'0','0'),(3,'','',3,0,'0','8313','0','0','0','0','0',0,0,'0','0'),(4,'','',4,0,'0','7872','0','0','0','0','0',0,0,'0','0'),(5,'','',5,0,'0','0023','0','0','0','0','0',0,0,'0','0'),(6,'','',6,0,'0','4739','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(11) DEFAULT '0',
  `ID` int(11) DEFAULT '0',
  `Name` char(200) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

LOCK TABLES `lastrecords` WRITE;
/*!40000 ALTER TABLE `lastrecords` DISABLE KEYS */;
INSERT INTO `lastrecords` VALUES (5,1,'5 записей',NULL),(20,2,'20 записей',NULL),(50,3,'50 записей',NULL),(200,4,'200 записей',NULL),(1000,6,'1000 записей',NULL),(500,5,'500 записей',NULL),(3000,7,'3000 записей','3000 записей');
/*!40000 ALTER TABLE `lastrecords` ENABLE KEYS */;
UNLOCK TABLES;

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

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

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

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

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

DROP TABLE IF EXISTS `lines`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `lines` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `Color` int(11) DEFAULT '0' COMMENT 'Цвет',
  `Width` int(11) DEFAULT '3' COMMENT 'Толщина линии',
  `Mobitel_ID` int(11) DEFAULT NULL,
  `Icon` blob,
  PRIMARY KEY (`id`),
  KEY `lines_FK1` (`Mobitel_ID`) USING BTREE,
  CONSTRAINT `lines_FK1` FOREIGN KEY (`Mobitel_ID`) REFERENCES `mobitels` (`Mobitel_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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,942879027,NULL),(2,-16777077,3,909195569,NULL),(3,-16777077,3,926431026,NULL),(4,-16777077,3,959590963,NULL),(5,-16777077,3,959590965,NULL),(6,-16777077,3,959590964,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(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `DefaultLineStyle_ID` int(11) DEFAULT '0',
  `DefaulPointStyle_ID` int(11) DEFAULT '0',
  `EventPointStyle1_ID` int(11) DEFAULT '0',
  `EventPointStyle2_ID` int(11) DEFAULT '0',
  `EventPointStyle3_ID` int(11) DEFAULT '0',
  `EventPointStyle4_ID` int(11) DEFAULT '0',
  `EventPointStyle5_ID` int(11) DEFAULT '0',
  `EventPointStyle6_ID` int(11) DEFAULT '0',
  `EventPointStyle7_ID` int(11) DEFAULT '0',
  `EventPointStyle8_ID` int(11) DEFAULT '0',
  `EventPointStyle9_ID` int(11) DEFAULT '0',
  `EventPointStyle10_ID` int(11) DEFAULT '0',
  `EventPointStyle11_ID` int(11) DEFAULT '0',
  `EventPointStyle12_ID` int(11) DEFAULT '0',
  `EventPointStyle13_ID` int(11) DEFAULT '0',
  `EventPointStyle14_ID` int(11) DEFAULT '0',
  `EventPointStyle15_ID` int(11) DEFAULT '0',
  `EventPointStyle16_ID` int(11) DEFAULT '0',
  `EventPointStyle17_ID` int(11) DEFAULT '0',
  `EventPointStyle18_ID` int(11) DEFAULT '0',
  `EventPointStyle19_ID` int(11) DEFAULT '0',
  `EventPointStyle20_ID` int(11) DEFAULT '0',
  `EventPointStyle21_ID` int(11) DEFAULT '0',
  `EventPointStyle22_ID` int(11) DEFAULT '0',
  `EventPointStyle23_ID` int(11) DEFAULT '0',
  `EventPointStyle24_ID` int(11) DEFAULT '0',
  `EventPointStyle25_ID` int(11) DEFAULT '0',
  `EventPointStyle26_ID` int(11) DEFAULT '0',
  `EventPointStyle27_ID` int(11) DEFAULT '0',
  `EventPointStyle28_ID` int(11) DEFAULT '0',
  `EventPointStyle29_ID` int(11) DEFAULT '0',
  `EventPointStyle30_ID` int(11) DEFAULT '0',
  `EventPointStyle31_ID` int(11) DEFAULT '0',
  `EventPointStyle32_ID` int(11) DEFAULT '0',
  `SensorPointStyle1_ID` int(11) DEFAULT '0',
  `SensorPointStyle2_ID` int(11) DEFAULT '0',
  `SensorPointStyle3_ID` int(11) DEFAULT '0',
  `SensorPointStyle4_ID` int(11) DEFAULT '0',
  `SensorPointStyle5_ID` int(11) DEFAULT '0',
  `SensorPointStyle6_ID` int(11) DEFAULT '0',
  `SensorPointStyle7_ID` int(11) DEFAULT '0',
  `SensorPointStyle8_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`MapStyleGlobal_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `mapstyleglobal` WRITE;
/*!40000 ALTER TABLE `mapstyleglobal` DISABLE KEYS */;
INSERT INTO `mapstyleglobal` VALUES (1,'Настройка 1','Настнойки для Мобител',0,1,1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(2,'Настнойки 4','Настнойки mob 4',0,2,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(3,'Настнойки 3','Настнойки для Мобител 3',0,3,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),(4,'Tune 2','Настнойки для Мобител 2',0,4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
/*!40000 ALTER TABLE `mapstyleglobal` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `mapstylelines`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mapstylelines` (
  `MapStyleLine_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Color` int(11) DEFAULT '0',
  `Width` tinyint(4) DEFAULT '0',
  `Style` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`MapStyleLine_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `mapstylepoints`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mapstylepoints` (
  `MapStylePoint_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `isBitmap` tinyint(1) DEFAULT NULL,
  `SymbolCode` tinyint(4) DEFAULT '0',
  `Color` int(11) DEFAULT '0',
  `Font` char(200) DEFAULT NULL,
  `Size` int(11) DEFAULT '0',
  `Rotation` int(11) DEFAULT '0',
  `BitmapName` char(200) DEFAULT NULL,
  `BitmapStyle` tinyint(4) DEFAULT '0',
  `Style` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`MapStylePoint_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `mobitels`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mobitels` (
  `Mobitel_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` bigint(20) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `ServiceInit_ID` int(11) DEFAULT '0',
  `ServiceSend_ID` int(11) DEFAULT '0',
  `InternalMobitelConfig_ID` int(11) DEFAULT '0',
  `MapStyleLine_ID` int(11) DEFAULT '0',
  `MapStyleLastPoint_ID` int(11) DEFAULT '0',
  `MapStylePoint_ID` int(11) DEFAULT '0',
  `Route_ID` int(11) DEFAULT '0',
  `DeviceType` int(11) DEFAULT '0',
  `DeviceEngine` int(11) DEFAULT '0',
  `ConfirmedID` int(11) NOT NULL DEFAULT '0' COMMENT 'MIN значение LogID менее которого считается нет пропусков или уже невозможно загрузить',
  `LastInsertTime` int(11) NOT NULL DEFAULT '0' COMMENT 'UNIX_TIMESTAMP Время последней вставки данных в DataGPS',
  `Is64bitPackets` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'передача данных идет 64 байтными пакетами',
  `IsNotDrawDgps` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'РѕС‚РѕР±СЂР°Р¶Р°С‚СЊ РёР»Рё РЅРµС‚ РґР°РЅРЅС‹Рµ DGPS РЅР° РєР°СЂС‚Рµ',
  PRIMARY KEY (`Mobitel_ID`),
  KEY `IDX_InternalmobitelconfigID` (`InternalMobitelConfig_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=959590966 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 (909195569,'','',0,0,0,2,2,6,5,5,0,0,0,0,1647542709,0,1),(926431026,'','',0,0,0,4,4,6,5,5,0,0,0,0,1651055842,0,1),(942879027,'','',0,0,0,3,3,6,5,5,0,0,0,0,1646119415,1,1),(959590963,'','',0,0,0,1,1,6,5,5,0,0,0,0,1651055784,0,1),(959590964,'0023','Desctiption for Teletrack registered at 09.02.2022 10:15:15',0,0,0,5,5,6,5,5,0,0,0,0,1648140902,0,1),(959590965,'4739','Desctiption for Teletrack registered at 09.02.2022 10:15:56',0,0,0,6,6,6,5,5,0,0,0,0,1651055811,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(10) unsigned NOT NULL,
  `Map_Style_Car` text,
  `Track_Color` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`Mobitel_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `mobitels_rotate_bands`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `mobitels_rotate_bands` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0',
  `Bound` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `FK_mobitels_rotate_bands_mobitels_Mobitel_ID` (`Mobitel_ID`),
  CONSTRAINT `FK_mobitels_rotate_bands_mobitels_Mobitel_ID` FOREIGN KEY (`Mobitel_ID`) REFERENCES `mobitels` (`Mobitel_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `ntf_emails`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ntf_emails` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `IsActive` tinyint(1) NOT NULL DEFAULT '0',
  `Email` varchar(127) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `FK_ntf_email_ntf_main_Id` (`Id_main`),
  CONSTRAINT `FK_ntf_email_ntf_main_Id` FOREIGN KEY (`Id_main`) REFERENCES `ntf_main` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `ntf_mobitels`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ntf_mobitels` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `MobitelId` int(11) NOT NULL,
  `SensorLogicId` int(11) DEFAULT '0',
  `SensorId` int(11) DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `FK_ntf_mobitels_ntf_main_Id` (`Id_main`),
  CONSTRAINT `FK_ntf_mobitels_ntf_main_Id` FOREIGN KEY (`Id_main`) REFERENCES `ntf_main` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `ntf_popupusers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `ntf_popupusers` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_main` int(11) NOT NULL,
  `Id_user` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `FK_ntf_popupUsers_ntf_main_Id` (`Id_main`),
  CONSTRAINT `FK_ntf_popupUsers_ntf_main_Id` FOREIGN KEY (`Id_main`) REFERENCES `ntf_main` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `online`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `online` (
  `DataGps_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) DEFAULT '0',
  `Message_ID` int(11) DEFAULT '0',
  `Latitude` int(11) NOT NULL DEFAULT '0',
  `Longitude` int(11) NOT NULL DEFAULT '0',
  `Altitude` int(11) DEFAULT '0',
  `UnixTime` int(11) NOT NULL DEFAULT '0',
  `Speed` smallint(6) NOT NULL DEFAULT '0',
  `Direction` int(11) NOT NULL DEFAULT '0',
  `Valid` tinyint(4) NOT NULL DEFAULT '1',
  `InMobitelID` int(11) DEFAULT '0',
  `Events` int(10) unsigned DEFAULT '0',
  `Sensor1` tinyint(4) unsigned DEFAULT '0',
  `Sensor2` tinyint(4) unsigned DEFAULT '0',
  `Sensor3` tinyint(4) unsigned DEFAULT '0',
  `Sensor4` tinyint(4) unsigned DEFAULT '0',
  `Sensor5` tinyint(4) unsigned DEFAULT '0',
  `Sensor6` tinyint(4) unsigned DEFAULT '0',
  `Sensor7` tinyint(4) unsigned DEFAULT '0',
  `Sensor8` tinyint(4) unsigned DEFAULT '0',
  `LogID` int(11) DEFAULT '0',
  `isShow` tinyint(4) DEFAULT '0',
  `whatIs` smallint(6) unsigned NOT NULL DEFAULT '0',
  `Counter1` int(11) NOT NULL DEFAULT '-1',
  `Counter2` int(11) NOT NULL DEFAULT '-1',
  `Counter3` int(11) NOT NULL DEFAULT '-1',
  `Counter4` int(11) NOT NULL DEFAULT '-1',
  PRIMARY KEY (`DataGps_ID`),
  KEY `IDX_MobitelidUnixtimeValid` (`Mobitel_ID`,`UnixTime`,`Valid`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1908 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 (1503,959590964,0,30270698,18384164,107,1645184841,2,41,1,44871,0,17,54,223,1,86,64,0,0,44871,0,1023,-1,-1,-1,-1),(1513,959590964,0,30270702,18384171,106,1645184901,0,0,1,44872,0,17,54,207,17,86,64,0,0,44872,0,1023,-1,-1,-1,-1),(1515,959590964,0,30270702,18384171,106,1645184961,0,0,1,44873,0,17,54,207,17,86,64,0,0,44873,0,1023,-1,-1,-1,-1),(1516,959590964,0,30270702,18384171,106,1645184992,0,0,1,44874,0,1,54,206,241,86,64,0,0,44874,0,1023,-1,-1,-1,-1),(1525,959590964,0,30270702,18384171,106,1645185052,0,0,1,44875,0,1,54,190,1,86,64,0,0,44875,0,1023,-1,-1,-1,-1),(1527,959590964,0,30270702,18384171,106,1645185112,0,0,1,44876,0,1,54,189,225,86,64,0,0,44876,0,1023,-1,-1,-1,-1),(1529,959590964,0,30270702,18384171,106,1645185172,0,0,1,44877,0,1,54,189,209,86,64,0,0,44877,0,1023,-1,-1,-1,-1),(1535,959590964,0,30270702,18384171,106,1645185232,0,0,1,44878,0,1,54,173,209,86,80,0,0,44878,0,1023,-1,-1,-1,-1),(1537,959590964,0,30270702,18384171,106,1645185292,0,0,1,44879,0,1,54,173,193,86,80,0,0,44879,0,1023,-1,-1,-1,-1),(1539,959590964,0,30270702,18384171,106,1645185352,0,0,1,44880,0,1,54,157,193,86,96,0,0,44880,0,1023,-1,-1,-1,-1),(1540,959590964,0,30270702,18384171,106,1645185412,0,0,1,44881,0,1,54,157,193,86,112,0,0,44881,0,1023,-1,-1,-1,-1),(1541,959590964,0,30270702,18384171,106,1645185472,0,0,1,44882,0,1,54,157,177,86,112,0,0,44882,0,1023,-1,-1,-1,-1),(1542,959590964,0,30270702,18384171,106,1645185532,0,0,1,44883,0,1,54,141,177,86,128,0,0,44883,0,1023,-1,-1,-1,-1),(1543,959590964,0,30270702,18384171,106,1645185592,0,0,1,44884,0,1,54,141,177,86,144,0,0,44884,0,1023,-1,-1,-1,-1),(1544,959590964,0,30270702,18384171,106,1645185652,0,0,1,44885,0,1,54,125,177,86,160,0,0,44885,0,1023,-1,-1,-1,-1),(1545,959590964,0,30270702,18384171,106,1645185712,0,0,1,44886,0,1,54,125,177,86,176,0,0,44886,0,1023,-1,-1,-1,-1),(1546,959590964,0,30270702,18384171,106,1645185772,0,0,1,44887,0,1,54,125,177,86,192,0,0,44887,0,1023,-1,-1,-1,-1),(1547,959590964,0,30270702,18384171,106,1645185832,0,0,1,44888,0,1,54,125,161,86,208,0,0,44888,0,1023,-1,-1,-1,-1),(1548,959590964,0,30270702,18384171,106,1645185860,0,0,1,44889,0,17,54,125,161,86,208,0,0,44889,0,1023,-1,-1,-1,-1),(1549,959590964,0,30270702,18384171,106,1645185863,0,0,1,44890,0,1,54,125,129,86,208,0,0,44890,0,1023,-1,-1,-1,-1),(1571,959590964,0,30270702,18384171,106,1645185923,0,0,1,44891,0,1,54,109,161,86,224,0,0,44891,0,1023,-1,-1,-1,-1),(1575,959590964,0,30270702,18384171,106,1645185983,0,0,1,44892,0,1,54,109,161,86,240,0,0,44892,0,1023,-1,-1,-1,-1),(1580,959590964,0,30270702,18384171,106,1645186043,0,0,1,44893,0,1,54,93,161,86,240,0,0,44893,0,1023,-1,-1,-1,-1),(1583,959590964,0,30270702,18384171,106,1645186103,0,0,1,44894,0,1,54,93,161,87,0,0,0,44894,0,1023,-1,-1,-1,-1),(1591,959590964,0,30270702,18384171,106,1645186163,0,0,1,44895,0,1,54,93,145,87,16,0,0,44895,0,1023,-1,-1,-1,-1),(1594,959590964,0,30270702,18384171,106,1645186223,0,0,1,44896,0,1,54,77,145,87,32,0,0,44896,0,1023,-1,-1,-1,-1),(1600,959590964,0,30270702,18384171,106,1645186283,0,0,1,44897,0,1,54,77,145,87,48,0,0,44897,0,1023,-1,-1,-1,-1),(1602,959590964,0,30270702,18384171,106,1645186343,0,0,1,44898,0,1,54,77,145,87,48,0,0,44898,0,1023,-1,-1,-1,-1),(1604,959590964,0,30270702,18384171,106,1645186403,0,0,1,44899,0,1,54,61,145,87,64,0,0,44899,0,1023,-1,-1,-1,-1),(1610,959590964,0,30270702,18384171,106,1645186424,0,0,1,44900,0,17,54,61,129,87,64,0,0,44900,0,1023,-1,-1,-1,-1),(1614,959590964,0,30270702,18384171,106,1645186484,0,0,1,44901,0,17,54,61,97,87,80,0,0,44901,0,1023,-1,-1,-1,-1),(1621,959590964,0,30270702,18384171,106,1645186544,0,0,1,44902,0,17,54,61,97,87,96,0,0,44902,0,1023,-1,-1,-1,-1),(1622,959590964,0,30270702,18384171,106,1645186593,0,0,1,44903,0,1,54,45,81,87,112,0,0,44903,0,1023,-1,-1,-1,-1),(1634,959590964,0,30270702,18384171,106,1645186652,0,0,1,44904,0,1,54,45,113,87,112,0,0,44904,0,1023,-1,-1,-1,-1),(1639,959590964,0,30270702,18384171,106,1645186712,0,0,1,44905,0,1,54,45,113,87,128,0,0,44905,0,1023,-1,-1,-1,-1),(1641,959590964,0,30270702,18384171,106,1645186772,0,0,1,44906,0,1,54,29,113,87,144,0,0,44906,0,1023,-1,-1,-1,-1),(1643,959590964,0,30270702,18384171,106,1645186832,0,0,1,44907,0,1,54,29,113,87,160,0,0,44907,0,1023,-1,-1,-1,-1),(1647,959590964,0,30270702,18384171,106,1645186892,0,0,1,44908,0,1,54,13,113,87,176,0,0,44908,0,1023,-1,-1,-1,-1),(1649,959590964,0,30270702,18384171,106,1645186952,0,0,1,44909,0,1,54,13,113,87,176,0,0,44909,0,1023,-1,-1,-1,-1),(1651,959590964,0,30270702,18384171,106,1645187008,0,0,1,44910,0,17,53,253,97,87,192,0,0,44910,0,1023,-1,-1,-1,-1),(1653,959590964,0,30270702,18384171,106,1645187068,0,0,1,44911,0,17,53,253,81,87,208,0,0,44911,0,1023,-1,-1,-1,-1),(1664,959590964,0,30270702,18384171,106,1645187128,0,0,1,44912,0,17,53,253,81,87,224,0,0,44912,0,1023,-1,-1,-1,-1),(1674,959590964,0,30270702,18384171,106,1645187188,0,0,1,44913,0,17,53,253,65,87,224,0,0,44913,0,1023,-1,-1,-1,-1),(1687,959590964,0,30270702,18384171,106,1645187248,0,0,1,44914,0,17,53,253,65,87,240,0,0,44914,0,1023,-1,-1,-1,-1),(1690,959590964,0,30270702,18384171,106,1645187308,0,0,1,44915,0,17,53,237,81,88,0,0,0,44915,0,1023,-1,-1,-1,-1),(1692,959590964,0,30270702,18384171,106,1645187368,0,0,1,44916,0,17,53,237,81,88,0,0,0,44916,0,1023,-1,-1,-1,-1),(1695,959590964,0,30270702,18384171,106,1645187428,0,0,1,44917,0,17,53,237,81,88,16,0,0,44917,0,1023,-1,-1,-1,-1),(1697,959590964,0,30270702,18384171,106,1645187458,0,0,1,44918,0,1,53,237,65,88,32,0,0,44918,0,1023,-1,-1,-1,-1),(1699,959590964,0,30270702,18384171,106,1645187518,0,0,1,44919,0,1,53,221,97,88,32,0,0,44919,0,1023,-1,-1,-1,-1),(1702,959590964,0,30270702,18384171,106,1645187578,0,0,1,44920,0,1,53,221,113,88,48,0,0,44920,0,1023,-1,-1,-1,-1),(1705,959590964,0,30270702,18384171,106,1645187638,0,0,1,44921,0,1,53,221,113,88,64,0,0,44921,0,1023,-1,-1,-1,-1),(1708,959590964,0,30270702,18384171,106,1645187698,0,0,1,44922,0,1,53,221,113,88,64,0,0,44922,0,1023,-1,-1,-1,-1),(1711,959590964,0,30270702,18384171,106,1645187758,0,0,1,44923,0,1,53,205,113,88,80,0,0,44923,0,1023,-1,-1,-1,-1),(1716,959590964,0,30270702,18384171,106,1645187818,0,0,1,44924,0,1,53,205,113,88,80,0,0,44924,0,1023,-1,-1,-1,-1),(1722,959590964,0,30270702,18384171,106,1645187878,0,0,1,44925,0,1,53,205,113,88,96,0,0,44925,0,1023,-1,-1,-1,-1),(1729,959590964,0,30270702,18384171,106,1645187938,0,0,1,44926,0,1,53,205,113,88,96,0,0,44926,0,1023,-1,-1,-1,-1),(1730,959590964,0,30270702,18384171,106,1645187998,0,0,1,44927,0,1,53,205,113,88,112,0,0,44927,0,1023,-1,-1,-1,-1),(1736,959590964,0,30270702,18384171,106,1645188058,0,0,1,44928,0,1,53,189,113,88,128,0,0,44928,0,1023,-1,-1,-1,-1),(1741,959590964,0,30270702,18384171,106,1645188118,0,0,1,44929,0,1,53,189,113,88,128,0,0,44929,0,1023,-1,-1,-1,-1),(1744,959590964,0,30270702,18384171,106,1645188178,0,0,1,44930,0,1,53,189,113,88,144,0,0,44930,0,1023,-1,-1,-1,-1),(1754,959590964,0,30270702,18384171,106,1645188238,0,0,1,44931,0,1,53,189,113,88,144,0,0,44931,0,1023,-1,-1,-1,-1),(1760,959590964,0,30270702,18384171,106,1645188298,0,0,1,44932,0,1,53,173,113,88,160,0,0,44932,0,1023,-1,-1,-1,-1),(1763,959590964,0,30270702,18384171,106,1645188358,0,0,1,44933,0,1,53,173,113,88,160,0,0,44933,0,1023,-1,-1,-1,-1),(1765,959590964,0,30270702,18384171,106,1645188418,0,0,1,44934,0,1,53,173,113,88,176,0,0,44934,0,1023,-1,-1,-1,-1),(1772,959590964,0,30270702,18384171,106,1645188478,0,0,1,44935,0,1,53,173,113,88,176,0,0,44935,0,1023,-1,-1,-1,-1),(1773,909195569,0,30241502,18027015,178,1645188502,28,239,1,103820,0,33,54,206,177,61,16,0,0,103820,0,1023,-1,-1,-1,-1),(1774,909195569,0,30242433,18027023,174,1645188514,27,233,1,103821,0,33,54,206,177,61,16,0,0,103821,0,1023,-1,-1,-1,-1),(1775,909195569,0,30242580,18026965,175,1645188516,27,227,1,103822,0,33,54,206,177,61,16,0,0,103822,0,1023,-1,-1,-1,-1),(1776,909195569,0,30242717,18026873,176,1645188518,25,221,1,103823,0,33,54,206,177,61,16,0,0,103823,0,1023,-1,-1,-1,-1),(1777,959590964,0,30270702,18384171,106,1645188538,0,0,1,44936,0,1,53,173,113,88,192,0,0,44936,0,1023,-1,-1,-1,-1),(1778,909195569,0,30244133,18025596,183,1645188551,19,216,1,103824,0,33,54,190,177,61,0,0,0,103824,0,1023,-1,-1,-1,-1),(1779,909195569,0,30244663,18024955,181,1645188562,22,211,1,103825,0,33,54,190,177,61,0,0,0,103825,0,1023,-1,-1,-1,-1),(1780,909195569,0,30244913,18024607,181,1645188568,17,221,1,103826,0,33,54,190,177,61,0,0,0,103826,0,1023,-1,-1,-1,-1),(1781,909195569,0,30244995,18024553,181,1645188570,15,230,1,103827,0,33,54,190,177,61,0,0,0,103827,0,1023,-1,-1,-1,-1),(1782,909195569,0,30245028,18024542,180,1645188571,12,235,1,103828,0,33,54,190,177,61,0,0,0,103828,0,1023,-1,-1,-1,-1),(1783,909195569,0,30245111,18024526,179,1645188576,3,230,1,103829,0,33,54,190,177,61,0,0,0,103829,0,1023,-1,-1,-1,-1),(1784,909195569,0,30245117,18024519,179,1645188577,3,222,1,103830,0,33,54,190,177,61,0,0,0,103830,0,1023,-1,-1,-1,-1),(1785,909195569,0,30245135,18024509,179,1645188579,4,231,1,103831,0,33,54,190,177,61,0,0,0,103831,0,1023,-1,-1,-1,-1),(1786,909195569,0,30245158,18024502,179,1645188581,5,237,1,103832,0,33,54,190,177,61,0,0,0,103832,0,1023,-1,-1,-1,-1),(1787,959590964,0,30270702,18384171,106,1645188598,0,0,1,44937,0,1,53,173,113,88,192,0,0,44937,0,1023,-1,-1,-1,-1),(1788,909195569,0,30245352,18024503,177,1645188590,11,3,1,103833,0,33,54,190,177,61,0,0,0,103833,0,1023,-1,-1,-1,-1),(1789,909195569,0,30246094,18024614,178,1645188608,17,238,1,103834,0,33,54,174,177,60,240,0,0,103834,0,1023,-1,-1,-1,-1),(1790,909195569,0,30247332,18024562,181,1645188629,21,7,1,103835,0,33,54,174,177,60,240,0,0,103835,0,1023,-1,-1,-1,-1),(1791,909195569,0,30247704,18024714,175,1645188636,21,13,1,103836,0,33,54,174,177,60,240,0,0,103836,0,1023,-1,-1,-1,-1),(1792,959590964,0,30270702,18384171,106,1645188658,0,0,1,44938,0,1,53,157,113,88,208,0,0,44938,0,1023,-1,-1,-1,-1),(1793,909195569,0,30248246,18025096,166,1645188646,19,19,1,103837,0,33,54,174,177,60,240,0,0,103837,0,1023,-1,-1,-1,-1),(1794,909195569,0,30248364,18025215,162,1645188649,14,24,1,103838,0,33,54,174,161,60,240,0,0,103838,0,1023,-1,-1,-1,-1),(1795,909195569,0,30249300,18026450,160,1645188675,17,17,1,103839,0,33,54,158,177,60,240,0,0,103839,0,1023,-1,-1,-1,-1),(1796,909195569,0,30249484,18026582,159,1645188679,17,12,1,103840,0,33,54,158,177,60,240,0,0,103840,0,1023,-1,-1,-1,-1),(1797,909195569,0,30249583,18026619,159,1645188681,17,5,1,103841,0,33,54,158,177,60,240,0,0,103841,0,1023,-1,-1,-1,-1),(1798,909195569,0,30249680,18026632,161,1645188683,17,239,1,103842,0,33,54,158,177,60,240,0,0,103842,0,1023,-1,-1,-1,-1),(1799,909195569,0,30249821,18026619,161,1645188686,16,233,1,103843,0,33,54,158,177,60,240,0,0,103843,0,1023,-1,-1,-1,-1),(1800,909195569,0,30250109,18026511,164,1645188692,17,227,1,103844,0,33,54,158,177,60,240,0,0,103844,0,1023,-1,-1,-1,-1),(1801,909195569,0,30250442,18026304,167,1645188699,18,222,1,103845,0,33,54,158,177,60,240,0,0,103845,0,1023,-1,-1,-1,-1),(1802,959590964,0,30270702,18384171,106,1645188718,0,0,1,44939,0,1,53,157,113,88,208,0,0,44939,0,1023,-1,-1,-1,-1),(1803,909195569,0,30251035,18025809,174,1645188711,17,229,1,103846,0,33,54,126,161,60,224,0,0,103846,0,1023,-1,-1,-1,-1),(1804,909195569,0,30251083,18025795,174,1645188712,18,235,1,103847,0,33,54,126,161,60,224,0,0,103847,0,1023,-1,-1,-1,-1),(1805,909195569,0,30251236,18025784,175,1645188715,18,0,1,103848,0,33,54,126,177,60,224,0,0,103848,0,1023,-1,-1,-1,-1),(1806,909195569,0,30251840,18025795,178,1645188727,17,7,1,103849,0,33,54,126,177,60,224,0,0,103849,0,1023,-1,-1,-1,-1),(1807,909195569,0,30251935,18025837,178,1645188729,17,13,1,103850,0,33,54,126,177,60,224,0,0,103850,0,1023,-1,-1,-1,-1),(1808,909195569,0,30252072,18025945,177,1645188732,19,19,1,103851,0,33,54,126,177,60,224,0,0,103851,0,1023,-1,-1,-1,-1),(1809,909195569,0,30252202,18026084,178,1645188735,18,25,1,103852,0,33,54,126,177,60,224,0,0,103852,0,1023,-1,-1,-1,-1),(1810,909195569,0,30252710,18026755,178,1645188750,12,17,1,103853,0,33,54,126,177,60,224,0,0,103853,0,1023,-1,-1,-1,-1),(1811,909195569,0,30252766,18026792,178,1645188752,10,9,1,103854,0,33,54,126,177,60,224,0,0,103854,0,1023,-1,-1,-1,-1),(1812,909195569,0,30252794,18026801,178,1645188753,10,3,1,103855,0,33,54,126,161,60,224,0,0,103855,0,1023,-1,-1,-1,-1),(1813,909195569,0,30252849,18026801,178,1645188755,8,237,1,103856,0,33,54,126,177,60,224,0,0,103856,0,1023,-1,-1,-1,-1),(1814,959590964,0,30270702,18384171,106,1645188778,0,0,1,44940,0,1,53,157,113,88,224,0,0,44940,0,1023,-1,-1,-1,-1),(1815,909195569,0,30253025,18026756,179,1645188776,4,228,1,103857,0,33,54,110,177,60,208,0,0,103857,0,1023,-1,-1,-1,-1),(1816,959590964,0,30270702,18384171,106,1645188838,0,0,1,44941,0,1,53,157,97,88,224,0,0,44941,0,1023,-1,-1,-1,-1),(1817,909195569,0,30255432,18025502,163,1645188836,23,227,1,103858,0,33,54,94,177,60,208,0,0,103858,0,1023,-1,-1,-1,-1),(1818,959590964,0,30270702,18384171,106,1645188898,0,0,1,44942,0,1,53,157,97,88,240,0,0,44942,0,1023,-1,-1,-1,-1),(1819,909195569,0,30258710,18023837,165,1645188896,9,230,1,103859,0,33,54,78,161,60,192,0,0,103859,0,1023,-1,-1,-1,-1),(1820,909195569,0,30258772,18023817,166,1645188899,6,2,1,103860,0,33,54,78,177,60,192,0,0,103860,0,1023,-1,-1,-1,-1),(1821,909195569,0,30258794,18023823,166,1645188900,8,11,1,103861,0,33,54,78,177,60,192,0,0,103861,0,1023,-1,-1,-1,-1),(1822,909195569,0,30258814,18023833,166,1645188901,8,20,1,103862,0,33,54,78,177,60,192,0,0,103862,0,1023,-1,-1,-1,-1),(1823,909195569,0,30258835,18023852,167,1645188902,8,27,1,103863,0,33,54,78,177,60,192,0,0,103863,0,1023,-1,-1,-1,-1),(1824,909195569,0,30258849,18023879,167,1645188903,8,38,1,103864,0,33,54,78,177,60,192,0,0,103864,0,1023,-1,-1,-1,-1),(1825,909195569,0,30258860,18023910,167,1645188904,8,46,1,103865,0,33,54,78,177,60,192,0,0,103865,0,1023,-1,-1,-1,-1),(1826,909195569,0,30258882,18024059,166,1645188908,9,52,1,103866,0,33,54,78,177,60,192,0,0,103866,0,1023,-1,-1,-1,-1),(1827,909195569,0,30258918,18024400,162,1645188917,10,47,1,103867,0,33,54,78,161,60,192,0,0,103867,0,1023,-1,-1,-1,-1),(1828,909195569,0,30258942,18024484,162,1645188919,10,41,1,103868,0,33,54,78,177,60,192,0,0,103868,0,1023,-1,-1,-1,-1),(1829,909195569,0,30258983,18024626,163,1645188922,13,47,1,103869,0,33,54,78,177,60,192,0,0,103869,0,1023,-1,-1,-1,-1),(1830,909195569,0,30258997,18024734,163,1645188924,12,54,1,103870,0,33,54,62,177,60,192,0,0,103870,0,1023,-1,-1,-1,-1),(1831,909195569,0,30259054,18025549,166,1645188941,5,44,1,103871,0,33,54,62,161,60,192,0,0,103871,0,1023,-1,-1,-1,-1),(1832,909195569,0,30259063,18025573,166,1645188942,7,33,1,103872,0,33,54,62,177,60,192,0,0,103872,0,1023,-1,-1,-1,-1),(1833,909195569,0,30259078,18025592,167,1645188943,8,21,1,103873,0,33,54,62,177,60,192,0,0,103873,0,1023,-1,-1,-1,-1),(1834,909195569,0,30259097,18025614,168,1645188944,8,11,1,103874,0,33,54,62,177,60,192,0,0,103874,0,1023,-1,-1,-1,-1),(1835,909195569,0,30259119,18025632,170,1645188945,7,1,1,103875,0,33,54,62,177,60,192,0,0,103875,0,1023,-1,-1,-1,-1),(1836,909195569,0,30259141,18025631,170,1645188946,9,230,1,103876,0,33,54,62,161,60,192,0,0,103876,0,1023,-1,-1,-1,-1),(1837,909195569,0,30259154,18025610,170,1645188947,8,208,1,103877,0,33,54,62,177,60,192,0,0,103877,0,1023,-1,-1,-1,-1),(1838,909195569,0,30259164,18025578,170,1645188948,9,198,1,103878,0,33,54,62,177,60,192,0,0,103878,0,1023,-1,-1,-1,-1),(1839,959590964,0,30270702,18384171,106,1645188958,0,0,1,44943,0,1,53,141,97,88,240,0,0,44943,0,1023,-1,-1,-1,-1),(1840,909195569,0,30259165,18025544,170,1645188949,9,185,1,103879,0,33,54,62,177,60,192,0,0,103879,0,1023,-1,-1,-1,-1),(1841,909195569,0,30259164,18025508,170,1645188950,9,175,1,103880,0,33,54,62,177,60,192,0,0,103880,0,1023,-1,-1,-1,-1),(1842,909195569,0,30259156,18025433,170,1645188952,10,169,1,103881,0,33,54,62,177,60,192,0,0,103881,0,1023,-1,-1,-1,-1),(1843,909195569,0,30259083,18024852,169,1645188963,15,175,1,103882,0,33,54,62,177,60,192,0,0,103882,0,1023,-1,-1,-1,-1),(1844,959590964,0,30270702,18384171,106,1645189018,0,0,1,44944,0,1,53,141,97,88,240,0,0,44944,0,1023,-1,-1,-1,-1),(1845,909195569,0,30258456,18017140,169,1645189023,34,175,1,103883,0,33,54,46,177,60,192,0,0,103883,0,1023,-1,-1,-1,-1),(1846,959590964,0,30270702,18384171,106,1645189078,0,0,1,44945,0,1,53,141,97,89,0,0,0,44945,0,1023,-1,-1,-1,-1),(1847,909195569,0,30257765,18008479,173,1645189075,43,175,1,103884,0,33,54,14,177,60,192,0,0,103884,0,1023,-1,-1,-1,-1),(1848,909195569,0,30257077,17999684,182,1645189123,42,175,1,103885,0,33,53,222,177,60,176,0,0,103885,0,1023,-1,-1,-1,-1),(1849,959590964,0,30270702,18384171,106,1645189138,0,0,1,44946,0,1,53,141,97,89,0,0,0,44946,0,1023,-1,-1,-1,-1),(1850,909195569,0,30256469,17990850,181,1645189171,43,177,1,103886,0,33,53,174,177,60,160,0,0,103886,0,1023,-1,-1,-1,-1),(1851,959590964,0,30270702,18384171,106,1645189198,0,0,1,44947,0,1,53,141,97,89,0,0,0,44947,0,1023,-1,-1,-1,-1),(1852,909195569,0,30255971,17982003,180,1645189219,42,177,1,103887,0,33,53,142,177,60,144,0,0,103887,0,1023,-1,-1,-1,-1),(1853,959590964,0,30270702,18384171,106,1645189258,0,0,1,44948,0,1,53,125,97,89,16,0,0,44948,0,1023,-1,-1,-1,-1),(1854,909195569,0,30255468,17973159,166,1645189266,43,176,1,103888,0,33,53,110,177,60,112,0,0,103888,0,1023,-1,-1,-1,-1),(1855,959590964,0,30270702,18384171,106,1645189318,0,0,1,44949,0,1,53,125,97,89,16,0,0,44949,0,1023,-1,-1,-1,-1),(1856,909195569,0,30254915,17964322,171,1645189314,42,175,1,103889,0,33,53,94,177,60,96,0,0,103889,0,1023,-1,-1,-1,-1),(1857,909195569,0,30254363,17955530,172,1645189362,42,177,1,103890,0,33,53,46,177,60,96,0,0,103890,0,1023,-1,-1,-1,-1),(1858,959590964,0,30270702,18384171,106,1645189378,0,0,1,44950,0,1,53,125,97,89,32,0,0,44950,0,1023,-1,-1,-1,-1),(1859,909195569,0,30253832,17946709,171,1645189410,42,177,1,103891,0,33,53,46,177,60,96,0,0,103891,0,1023,-1,-1,-1,-1),(1860,959590964,0,30270702,18384171,106,1645189438,0,0,1,44951,0,1,53,125,97,89,32,0,0,44951,0,1023,-1,-1,-1,-1),(1861,909195569,0,30253322,17937891,165,1645189458,42,177,1,103892,0,33,52,254,177,60,80,0,0,103892,0,1023,-1,-1,-1,-1),(1862,959590964,0,30270702,18384171,106,1645189498,0,0,1,44952,0,1,53,125,97,89,32,0,0,44952,0,1023,-1,-1,-1,-1),(1863,909195569,0,30252794,17929056,169,1645189506,43,176,1,103893,0,33,52,222,177,60,48,0,0,103893,0,1023,-1,-1,-1,-1),(1864,959590964,0,30270702,18384171,106,1645189558,0,0,1,44953,0,1,53,125,97,89,48,0,0,44953,0,1023,-1,-1,-1,-1),(1865,909195569,0,30252259,17920205,173,1645189554,42,176,1,103894,0,33,52,190,177,60,32,0,0,103894,0,1023,-1,-1,-1,-1),(1866,909195569,0,30251751,17911392,178,1645189602,43,176,1,103895,0,33,52,142,177,60,16,0,0,103895,0,1023,-1,-1,-1,-1),(1867,959590964,0,30270702,18384171,106,1645189618,0,0,1,44954,0,1,53,109,113,89,48,0,0,44954,0,1023,-1,-1,-1,-1),(1868,909195569,0,30251222,17902543,173,1645189650,42,177,1,103896,0,33,52,110,177,60,0,0,0,103896,0,1023,-1,-1,-1,-1),(1869,959590964,0,30270702,18384171,106,1645189678,0,0,1,44955,0,1,53,109,113,89,48,0,0,44955,0,1023,-1,-1,-1,-1),(1870,909195569,0,30250907,17893655,171,1645189698,42,178,1,103897,0,33,52,62,177,59,224,0,0,103897,0,1023,-1,-1,-1,-1),(1871,959590964,0,30270702,18384171,106,1645189738,0,0,1,44956,0,1,53,109,113,89,64,0,0,44956,0,1023,-1,-1,-1,-1),(1872,909195569,0,30250661,17884877,162,1645189745,42,177,1,103898,0,33,52,46,177,59,208,0,0,103898,0,1023,-1,-1,-1,-1),(1873,959590964,0,30270702,18384171,106,1645189798,0,0,1,44957,0,1,53,109,113,89,64,0,0,44957,0,1023,-1,-1,-1,-1),(1874,909195569,0,30250372,17876029,172,1645189793,42,178,1,103899,0,33,52,46,193,59,208,0,0,103899,0,1023,-1,-1,-1,-1),(1875,909195569,0,30250094,17867165,172,1645189841,42,178,1,103900,0,33,52,14,193,59,208,0,0,103900,0,1023,-1,-1,-1,-1),(1876,959590964,0,30270702,18384171,106,1645189858,0,0,1,44958,0,1,53,109,113,89,80,0,0,44958,0,1023,-1,-1,-1,-1),(1877,909195569,0,30249815,17858322,168,1645189889,42,178,1,103901,0,33,51,222,177,59,192,0,0,103901,0,1023,-1,-1,-1,-1),(1878,959590964,0,30270702,18384171,106,1645189918,0,0,1,44959,0,1,53,109,113,89,80,0,0,44959,0,1023,-1,-1,-1,-1),(1879,909195569,0,30249801,17853678,164,1645189914,43,183,1,103902,0,33,51,174,177,59,176,0,0,103902,0,1023,-1,-1,-1,-1),(1880,909195569,0,30250241,17849566,157,1645189936,42,189,1,103903,0,33,51,174,193,59,176,0,0,103903,0,1023,-1,-1,-1,-1),(1881,959590964,0,30270702,18384171,106,1645189978,0,0,1,44960,0,1,53,109,113,89,80,0,0,44960,0,1023,-1,-1,-1,-1),(1882,909195569,0,30252087,17841173,152,1645189984,43,193,1,103904,0,33,51,142,193,59,176,0,0,103904,0,1023,-1,-1,-1,-1),(1883,959590964,0,30270702,18384171,106,1645190038,0,0,1,44961,0,1,53,109,113,89,80,0,0,44961,0,1023,-1,-1,-1,-1),(1884,909195569,0,30253946,17832788,155,1645190032,42,188,1,103905,0,33,51,110,193,59,160,0,0,103905,0,1023,-1,-1,-1,-1),(1885,909195569,0,30254065,17831510,155,1645190039,43,183,1,103906,0,33,51,110,193,59,160,0,0,103906,0,1023,-1,-1,-1,-1),(1886,909195569,0,30254210,17822675,170,1645190087,42,181,1,103907,0,33,51,62,177,59,160,0,0,103907,0,1023,-1,-1,-1,-1),(1887,959590964,0,30270702,18384171,106,1645190098,0,0,1,44962,0,1,53,109,113,89,80,0,0,44962,0,1023,-1,-1,-1,-1),(1888,909195569,0,30254338,17813817,175,1645190135,42,180,1,103908,0,33,51,14,193,59,144,0,0,103908,0,1023,-1,-1,-1,-1),(1889,959590964,0,30270702,18384171,106,1645190158,0,0,1,44963,0,1,53,109,113,89,96,0,0,44963,0,1023,-1,-1,-1,-1),(1890,909195569,0,30254461,17804935,179,1645190183,42,181,1,103909,0,33,50,222,177,59,128,0,0,103909,0,1023,-1,-1,-1,-1),(1891,909195569,0,30254422,17803479,175,1645190191,42,175,1,103910,0,33,50,222,177,59,128,0,0,103910,0,1023,-1,-1,-1,-1),(1892,959590964,0,30270702,18384171,106,1645190218,0,0,1,44964,0,1,53,93,113,89,96,0,0,44964,0,1023,-1,-1,-1,-1),(1893,909195569,0,30253489,17796429,164,1645190230,42,170,1,103911,0,33,50,222,177,59,128,0,0,103911,0,1023,-1,-1,-1,-1),(1894,959590964,0,30270702,18384171,106,1645190278,0,0,1,44965,0,1,53,93,113,89,96,0,0,44965,0,1023,-1,-1,-1,-1),(1895,909195569,0,30251871,17787928,178,1645190278,43,169,1,103912,0,33,50,190,177,59,96,0,0,103912,0,1023,-1,-1,-1,-1),(1896,909195569,0,30250234,17779427,184,1645190326,43,169,1,103913,0,33,50,142,193,59,80,0,0,103913,0,1023,-1,-1,-1,-1),(1897,959590964,0,30270702,18384171,106,1645190338,0,0,1,44966,0,1,53,93,113,89,96,0,0,44966,0,1023,-1,-1,-1,-1),(1898,909195569,0,30248576,17770935,177,1645190374,43,168,1,103914,0,33,50,94,193,59,48,0,0,103914,0,1023,-1,-1,-1,-1),(1899,959590964,0,30270702,18384171,106,1645190398,0,0,1,44967,0,1,53,93,113,89,112,0,0,44967,0,1023,-1,-1,-1,-1),(1900,909195569,0,30246928,17762435,171,1645190422,43,169,1,103915,0,33,50,62,193,59,32,0,0,103915,0,1023,-1,-1,-1,-1),(1901,959590964,0,30270702,18384171,106,1645190458,0,0,1,44968,0,1,53,77,113,89,112,0,0,44968,0,1023,-1,-1,-1,-1),(1902,909195569,0,30245291,17753945,167,1645190470,43,168,1,103916,0,33,50,30,193,59,16,0,0,103916,0,1023,-1,-1,-1,-1),(1903,959590964,0,30270702,18384171,106,1645190518,0,0,1,44969,0,1,53,77,113,89,112,0,0,44969,0,1023,-1,-1,-1,-1),(1904,909195569,0,30243628,17745502,170,1645190518,43,169,1,103917,0,33,49,238,193,59,0,0,0,103917,0,1023,-1,-1,-1,-1),(1905,909195569,0,30241987,17736999,172,1645190566,42,169,1,103918,0,33,49,190,193,59,0,0,0,103918,0,1023,-1,-1,-1,-1),(1906,959590964,0,30270702,18384171,106,1645190578,0,0,1,44970,0,1,53,77,113,89,112,0,0,44970,0,1023,-1,-1,-1,-1),(1907,909195569,0,30240332,17728512,177,1645190614,42,169,1,103919,0,33,49,190,193,58,240,0,0,103919,0,1023,-1,-1,-1,-1);
/*!40000 ALTER TABLE `online` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `online64`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `online64` (
  `DataGps_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) NOT NULL DEFAULT '0' COMMENT 'РљРѕРґ РўРµР»РµС‚СЂРµРєР°',
  `Latitude` int(11) NOT NULL DEFAULT '0' COMMENT 'РЁРёСЂРѕС‚Р°',
  `Longitude` int(11) NOT NULL DEFAULT '0' COMMENT 'Р”РѕР»РіРѕС‚Р°',
  `Direction` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT 'РіСЂР°РґСѓСЃС‹/1.5',
  `Acceleration` int(11) DEFAULT '0' COMMENT 'РР·РјРµРЅРµРЅРёРµ СЃРєРѕСЂРѕСЃС‚Рё РїРѕ GPS Р·Р° РїРѕСЃР»РµРґРЅСЋСЋ СЃРµРєСѓРЅРґСѓ',
  `UnixTime` int(11) NOT NULL DEFAULT '0',
  `Speed` smallint(6) NOT NULL DEFAULT '0' COMMENT 'РЎРѕС‚РµРЅ РјРµС‚СЂРѕРІ РІ С‡Р°СЃ (0,1 РєРј/С‡)',
  `Valid` tinyint(1) NOT NULL DEFAULT '1',
  `Satellites` tinyint(1) unsigned DEFAULT '0' COMMENT 'РљРѕР»РёС‡РµСЃС‚РІРѕ СЃРїСѓС‚РЅРёРєРѕРІ ',
  `RssiGsm` tinyint(1) unsigned DEFAULT '0' COMMENT 'РЈСЂРѕРІРµРЅСЊ GSM СЃРёРіРЅР°Р»Р°',
  `Events` int(11) DEFAULT '0' COMMENT 'Р¤Р»Р°РіРё СЃРѕР±С‹С‚РёР№',
  `SensorsSet` tinyint(1) DEFAULT '0' COMMENT 'РљРѕРґ РЅР°Р±РѕСЂР° РґР°С‚С‡РёРєРѕРІ',
  `Sensors` varbinary(50) DEFAULT '0' COMMENT 'Р—РЅР°С‡РµРЅРёСЏ РґР°С‚С‡РёРєРѕРІ',
  `Voltage` tinyint(4) unsigned DEFAULT '0' COMMENT 'РќР°РїСЂСЏР¶РµРЅРёРµ РїРёС‚Р°РЅРёСЏ С‚РµРєСѓС‰РµРіРѕ РёСЃС‚РѕС‡РЅРёРєР°/1.5 РѕС‚ 0 РґРѕ 38,2',
  `DGPS` varchar(32) DEFAULT NULL,
  `LogID` int(11) DEFAULT '0' COMMENT 'РРґРµРЅС‚РёС„РёРєР°С‚РѕСЂ Р·Р°РїРёСЃРё РІ Р¶СѓСЂРЅР°Р»Рµ РўРµР»РµС‚СЂРµРєР°',
  `SrvPacketID` bigint(20) NOT NULL DEFAULT '0' COMMENT 'ID СЃРµСЂРІРµСЂРЅРѕРіРѕ РїР°РєРµС‚Р° РІ СЃРѕСЃС‚Р°РІ РєРѕС‚РѕСЂРѕРіРѕ РІС…РѕРґРёС‚ СЌС‚Р° Р·Р°РїРёСЃСЊ',
  PRIMARY KEY (`DataGps_ID`),
  KEY `IDX_MobitelidUnixtimeValid64` (`Mobitel_ID`,`UnixTime`,`Valid`)
) ENGINE=InnoDB AUTO_INCREMENT=1153 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 */;
INSERT INTO `online64` VALUES (1053,942879027,505141650,304822116,0,0,1645185133,0,1,15,0,0,0,_binary 'AAALOZVNAAD0ZcgHtQOOAAAAAAAJFO0AAA==',174,'',30965,4049634585049331957),(1054,942879027,505141650,304822116,0,0,1645185193,0,1,14,0,0,0,_binary 'AAALOZVNAAD0ZSkHtQOOAAAAAAAJFO0AAA==',173,'',30966,4049634585049331958),(1055,942879027,505141650,304822116,0,0,1645185253,0,1,14,0,0,0,_binary 'AAALOZVNAAD0ZWAHtQOOAAAAAAAJFO0AAA==',173,'',30967,4049634585049331959),(1056,942879027,505141650,304822116,0,0,1645185313,0,1,15,0,0,0,_binary 'AAALOZVNAAD0ZX0HtQOOAAAAAAAJFO0AAA==',173,'',30968,4049634585049331960),(1057,942879027,505141650,304822116,0,0,1645185373,0,1,12,0,0,0,_binary 'AAALOZVNAAD0ZZEHtQOOAAAAAAAJFO0AAA==',173,'',30969,4049634585049331961),(1058,942879027,505141650,304822116,0,0,1645185433,0,1,15,0,0,0,_binary 'AAALOZVNAAD0ZZwHtQOOAAAAAAAJFO0AAA==',173,'',30970,4049634585049331962),(1059,942879027,505141650,304822116,0,0,1645185446,0,1,15,0,0,0,_binary 'EHQLOZVPAAAAZEcHtQOOAAAAAAAJFO0AAA==',171,'',30971,4049634585049331963),(1060,942879027,505141650,304822116,0,0,1645185506,0,1,15,0,0,0,_binary 'EHMLOZVVAADvcT0HtQOOAAAAAAAJFO0RQA==',193,'',30972,4049634585049331964),(1061,942879027,505139433,304822400,135,0,1645185510,50,1,14,0,0,0,_binary 'EHMLOZVWAADvcUEHtQOOAAAAAAAJFO0Sig==',193,'',30973,4049634585049331965),(1062,942879027,505137216,304821866,143,0,1645185531,50,1,15,0,0,0,_binary 'EHMLOZVbAADvcT0HtQOOAAAAAAAJFO0SVg==',193,'',30974,4049634585049331966),(1063,942879027,505137083,304821883,149,0,1645185533,50,1,15,0,0,0,_binary 'EHMLOZVbAADvcTgHtQOOAAAAAAAJFO0RtA==',193,'',30975,4049634585049331967),(1064,942879027,505137083,304821883,0,0,1645185593,0,1,12,0,0,0,_binary 'EHQLOZVeAADvcTQHtQOOAAAAAAAJFO0RTA==',193,'',30976,4049634585049331968),(1065,942879027,505137083,304821883,0,0,1645185609,0,1,15,0,0,0,_binary 'AHQLOZVeAADvZ8oHtQOOAAAAAAAJFO0AAA==',177,'',30977,4049634585049331969),(1066,942879027,505137083,304821883,0,0,1645185669,0,1,16,0,0,0,_binary 'AHQLOZVeAADvZwcHtQOSAAAAAAAJFO0AAA==',176,'',30978,4049634585049331970),(1067,942879027,505137083,304821883,0,0,1645185729,0,1,14,0,0,0,_binary 'AAALOZVeAADvZrIHtQOSAAAAAAAJFO0AAA==',175,'',30979,4049634585049331971),(1068,942879027,505137083,304821883,0,0,1645185789,0,1,15,0,0,0,_binary 'AAALOZVeAADvZmsHtQOSAAAAAAAJFO0AAA==',175,'',30980,4049634585049331972),(1069,942879027,505137083,304821883,0,0,1645185849,0,1,13,0,0,0,_binary 'AAALOZVeAADvZkIHtQOSAAAAAAAJFO0AAA==',175,'',30981,4049634585049331973),(1070,942879027,505137083,304821883,0,0,1645185909,0,1,14,0,0,0,_binary 'AAALOZVeAADvZd4HtQOSAAAAAAAJFO0AAA==',174,'',30982,4049634585049331974),(1071,942879027,505137083,304821883,0,0,1645185921,0,1,14,0,0,0,_binary 'EHILOZVeAAAAZKkHtQOSAAAAAAAJFO0AAA==',172,'',30983,4049634585049331975),(1072,942879027,505137083,304821883,0,0,1645185948,0,1,12,0,0,0,_binary 'AHMLOZVeAAAAZcIHtQOSAAAAAAAJFO0AAA==',173,'',30984,4049634585049331976),(1073,942879027,505137083,304821883,0,0,1645186007,0,1,14,0,0,0,_binary 'AHMLOZVeAAAAZQEHtQORAAAAAAAJFO0AAA==',173,'',30985,4049634585049331977),(1074,942879027,505137083,304821883,0,0,1645186067,0,1,15,0,0,0,_binary 'AAALOZVeAAAAZSoHtQOPAAAAAAAJFO0AAA==',173,'',30986,4049634585049331978),(1075,942879027,505137083,304821883,0,0,1645186127,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZS8HtQOPAAAAAAAJFO0AAA==',173,'',30987,4049634585049331979),(1076,942879027,505137083,304821883,0,0,1645186187,0,1,13,0,0,0,_binary 'AAALOZVeAAAAZPkHtQOPAAAAAAAJFO0AAA==',172,'',30988,4049634585049331980),(1077,942879027,505137083,304821883,0,0,1645186247,0,1,16,0,0,0,_binary 'AAALOZVeAAAAZRAHtQOPAAAAAAAJFO0AAA==',173,'',30989,4049634585049331981),(1078,942879027,505137083,304821883,0,0,1645186307,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZRsHtQOPAAAAAAAJFO0AAA==',173,'',30990,4049634585049331982),(1079,942879027,505137083,304821883,0,0,1645186367,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZQoHtQOPAAAAAAAJFO0AAA==',173,'',30991,4049634585049331983),(1080,942879027,505137083,304821883,0,0,1645186427,0,1,13,0,0,0,_binary 'AAALOZVeAAAAY3QHtQOPAAAAAAAJFO0AAA==',170,'',30992,4049634585049331984),(1081,942879027,505137083,304821883,0,0,1645186487,0,1,15,0,0,0,_binary 'AAALOZVeAAAAY2gHtQOPAAAAAAAJFO0AAA==',169,'',30993,4049634585049331985),(1082,942879027,505137083,304821883,0,0,1645186547,0,1,15,0,0,0,_binary 'AAALOZVeAAAAY3IHtQOPAAAAAAAJFO0AAA==',170,'',30994,4049634585049331986),(1083,942879027,505137083,304821883,0,0,1645186607,0,1,13,0,0,0,_binary 'AAALOZVeAAAAY2cHtQOPAAAAAAAJFO0AAA==',169,'',30995,4049634585049331987),(1084,942879027,505137083,304821883,0,0,1645186667,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZCIHtQOPAAAAAAAJFO0AAA==',171,'',30996,4049634585049331988),(1085,942879027,505137083,304821883,0,0,1645186727,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZAsHtQOPAAAAAAAJFO0AAA==',171,'',30997,4049634585049331989),(1086,942879027,505137083,304821883,0,0,1645186787,0,1,15,0,0,0,_binary 'AAALOZVeAAAAZBMHtQOPAAAAAAAJFO0AAA==',171,'',30998,4049634585049331990),(1087,942879027,505137083,304821883,0,0,1645186847,0,1,14,0,0,0,_binary 'AAALOZVeAAAAY68HtQOPAAAAAAAJFO0AAA==',170,'',30999,4049634585049331991),(1088,942879027,505137083,304821883,0,0,1645186907,0,1,13,0,0,0,_binary 'AAALOZVeAAAAY5UHtQOPAAAAAAAJFO0AAA==',170,'',31000,4049634585049331992),(1089,942879027,505137083,304821883,0,0,1645186967,0,1,15,0,0,0,_binary 'AAALOZVeAAAAY+0HtQOPAAAAAAAJFO0AAA==',171,'',31001,4049634585049331993),(1090,942879027,505137083,304821883,0,0,1645187027,0,1,14,0,0,0,_binary 'AAALOZVeAAAAY+0HtQOPAAAAAAAJFO0AAA==',171,'',31002,4049634585049331994),(1091,942879027,505137083,304821883,0,0,1645187087,0,1,15,0,0,0,_binary 'AAALOZVeAAAAY/AHtQOPAAAAAAAJFO0AAA==',171,'',31003,4049634585049331995),(1092,942879027,505137083,304821883,0,0,1645187147,0,1,14,0,0,0,_binary 'AAALOZVeAAAAY/kHtQOPAAAAAAAJFO0AAA==',171,'',31004,4049634585049331996),(1093,942879027,505137083,304821883,0,0,1645187207,0,1,14,0,0,0,_binary 'AAALOZVeAAAAY+wHtQOPAAAAAAAJFO0AAA==',171,'',31005,4049634585049331997),(1094,942879027,505137083,304821883,0,0,1645187267,0,1,15,0,0,0,_binary 'AAALOZVeAAAAY+wHtQOPAAAAAAAJFO0AAA==',171,'',31006,4049634585049331998),(1095,942879027,505137083,304821883,0,0,1645187327,0,1,14,0,0,0,_binary 'AAALOZVeAAAAY4kHtQOPAAAAAAAJFO0AAA==',170,'',31007,4049634585049331999),(1096,942879027,505137083,304821883,0,0,1645187387,0,1,13,0,0,0,_binary 'AAALOZVeAAAAY/sHtQOPAAAAAAAJFO0AAA==',171,'',31008,4049634585049332000),(1097,942879027,505137083,304821883,0,0,1645187447,0,1,13,0,0,0,_binary 'AAALOZVeAAAAZD8HtQOPAAAAAAAJFO0AAA==',171,'',31009,4049634585049332001),(1098,942879027,505137083,304821883,0,0,1645187507,0,1,13,0,0,0,_binary 'AAALOZVeAAAAZFgHtQOPAAAAAAAJFO0AAA==',171,'',31010,4049634585049332002),(1099,942879027,505137083,304821883,0,0,1645187567,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZHIHtQOPAAAAAAAJFO0AAA==',171,'',31011,4049634585049332003),(1100,942879027,505137083,304821883,0,0,1645187627,0,1,13,0,0,0,_binary 'AAALOZVeAAAAZHYHtQOPAAAAAAAJFO0AAA==',171,'',31012,4049634585049332004),(1101,942879027,505137083,304821883,0,0,1645187686,0,1,13,0,0,0,_binary 'AAALOZVeAAAAZHkHtQOPAAAAAAAJFO0AAA==',171,'',31013,4049634585049332005),(1102,942879027,505137083,304821883,0,0,1645187747,0,1,13,0,0,0,_binary 'AAALOZVeAAAAZA4HtQOPAAAAAAAJFO0AAA==',171,'',31014,4049634585049332006),(1103,942879027,505137083,304821883,0,0,1645187807,0,1,13,0,0,0,_binary 'AAALOZVeAAAAY+0HtQOPAAAAAAAJFO0AAA==',171,'',31015,4049634585049332007),(1104,942879027,505137083,304821883,0,0,1645187866,0,1,13,0,0,0,_binary 'AAALOZVeAAAAZFEHtQOPAAAAAAAJFO0AAA==',171,'',31016,4049634585049332008),(1105,942879027,505137083,304821883,0,0,1645187926,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZGMHtQOPAAAAAAAJFO0AAA==',171,'',31017,4049634585049332009),(1106,942879027,505137083,304821883,0,0,1645187986,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZGoHtQOPAAAAAAAJFO0AAA==',171,'',31018,4049634585049332010),(1107,942879027,505137083,304821883,0,0,1645188046,0,1,15,0,0,0,_binary 'AAALOZVeAAAAZGcHtQOPAAAAAAAJFO0AAA==',171,'',31019,4049634585049332011),(1108,942879027,505137083,304821883,0,0,1645188106,0,1,15,0,0,0,_binary 'AAALOZVeAAAAZFEHtQOPAAAAAAAJFO0AAA==',171,'',31020,4049634585049332012),(1109,942879027,505137083,304821883,0,0,1645188166,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZAkHtQOPAAAAAAAJFO0AAA==',171,'',31021,4049634585049332013),(1110,942879027,505137083,304821883,0,0,1645188226,0,1,13,0,0,0,_binary 'AAALOZVeAAAAY9UHtQOPAAAAAAAJFO0AAA==',171,'',31022,4049634585049332014),(1111,942879027,505137083,304821883,0,0,1645188286,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZCYHtQOPAAAAAAAJFO0AAA==',171,'',31023,4049634585049332015),(1112,942879027,505137083,304821883,0,0,1645188347,0,1,13,0,0,0,_binary 'AAALOZVeAAAAZEQHtQOPAAAAAAAJFO0AAA==',171,'',31024,4049634585049332016),(1113,942879027,505137083,304821883,0,0,1645188407,0,1,11,0,0,0,_binary 'AAALOZVeAAAAZEkHtQOPAAAAAAAJFO0AAA==',171,'',31025,4049634585049332017),(1114,942879027,505137083,304821883,0,0,1645188466,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZEoHtQOPAAAAAAAJFO0AAA==',171,'',31026,4049634585049332018),(1115,942879027,505137083,304821883,0,0,1645188526,0,1,14,0,0,0,_binary 'AAALOZVeAAAAZD8HtQOPAAAAAAAJFO0AAA==',171,'',31027,4049634585049332019),(1116,942879027,505137083,304821883,0,0,1645188587,0,1,15,0,0,0,_binary 'AAALOZVeAAAAY98HtQOPAAAAAAAJFO0AAA==',171,'',31028,4049634585049332020),(1117,942879027,505137083,304821883,0,0,1645188646,0,1,12,0,0,0,_binary 'AAALOZVeAAAAY5QHtQOPAAAAAAAJFO0AAA==',170,'',31029,4049634585049332021),(1118,942879027,505137083,304821883,0,0,1645188706,0,1,15,0,0,0,_binary 'AAALOZVeAAAAY7wHtQOPAAAAAAAJFO0AAA==',170,'',31030,4049634585049332022),(1119,942879027,505137083,304821883,0,0,1645188727,0,1,14,0,0,0,_binary 'EGYLOZVfAAAAYrcHtQOPAAAAAAAJFO0AAA==',169,'',31031,4049634585049332023),(1120,942879027,505137083,304821883,0,0,1645188786,0,1,15,0,0,0,_binary 'EGULOZVkAADwcO0HtQOPAAAAAAAJFO0RJg==',193,'',31032,4049634585049332024),(1121,942879027,505137083,304821883,0,0,1645188847,0,1,16,0,0,0,_binary 'EGcLOZVlAADwcJoHtQOMAAAAAAAJFO0RIA==',192,'',31033,4049634585049332025),(1122,942879027,505137083,304821883,0,0,1645188906,0,1,17,0,0,0,_binary 'EGgLOZVrAADwcLcHtQOKAAAAAAAJFO0RSg==',193,'',31034,4049634585049332026),(1123,942879027,505129716,304821983,94,0,1645188922,50,1,17,0,0,0,_binary 'EGgLOZVvAADwcNQHtQOKAAAAAAAJFO0TaA==',193,'',31035,4049634585049332027),(1124,942879027,505129550,304822216,0,0,1645188982,0,1,15,0,0,0,_binary 'EGoLOZV0AADvcIMHtQOKAAAAAAAJFO0ROg==',192,'',31036,4049634585049332028),(1125,942879027,505129550,304822216,0,0,1645189042,0,1,16,0,0,0,_binary 'EGoLOZV3AADvb/IHtQOKAAAAAAAJFO0RNg==',191,'',31037,4049634585049332029),(1126,942879027,505129550,304822216,0,0,1645189101,0,1,16,0,0,0,_binary 'EGsLOZV8AADvcLEHtQOKAAAAAAAJFO0Rog==',192,'',31038,4049634585049332030),(1127,942879027,505129550,304822216,0,0,1645189161,0,1,16,0,0,0,_binary 'EGwLOZV+AADucGUHtQODAAAAAAAJFO0RJA==',192,'',31039,4049634585049332031),(1128,942879027,505129550,304822216,0,0,1645189222,0,1,16,0,0,0,_binary 'EG0LOZWBAADucNsHtQN8AAAAAAAJFO0REg==',193,'',31040,4049634585049332032),(1129,942879027,505129550,304822216,0,0,1645189281,0,1,15,0,0,0,_binary 'EG0LOZWBAADtcQsHtQN6AAAAAAAJFO0RIg==',193,'',31041,4049634585049332033),(1130,942879027,505129550,304822216,0,0,1645189299,0,1,15,0,0,0,_binary 'AG0LOZWBAADtacYHtQN3AAAAAAAJFO0AAA==',181,'',31042,4049634585049332034),(1131,942879027,505129550,304822216,0,0,1645189358,0,1,14,0,0,0,_binary 'AG0LOZWBAADtZxEHtgNuAAAAAAAJFO0AAA==',176,'',31043,4049634585049332035),(1132,942879027,505129550,304822216,0,0,1645189418,0,1,15,0,0,0,_binary 'AAALOZWBAADtZZMHtgNtAAAAAAAJFO0AAA==',173,'',31044,4049634585049332036),(1133,942879027,505129550,304822216,0,0,1645189478,0,1,15,0,0,0,_binary 'AAALOZWBAADtZHYHtgNtAAAAAAAJFO0AAA==',171,'',31045,4049634585049332037),(1134,942879027,505129550,304822216,0,0,1645189538,0,1,15,0,0,0,_binary 'AAALOZWBAADtY70HtgNtAAAAAAAJFO0AAA==',170,'',31046,4049634585049332038),(1135,942879027,505129550,304822216,0,0,1645189598,0,1,15,0,0,0,_binary 'AAALOZWBAADtY34HtgNtAAAAAAAJFO0AAA==',170,'',31047,4049634585049332039),(1136,942879027,505129550,304822216,0,0,1645189658,0,1,15,0,0,0,_binary 'AAALOZWBAADtZPUHtgNtAAAAAAAJFO0AAA==',172,'',31048,4049634585049332040),(1137,942879027,505129550,304822216,0,0,1645189718,0,1,15,0,0,0,_binary 'AAALOZWBAADtZSsHtgNsAAAAAAAJFO0AAA==',173,'',31049,4049634585049332041),(1138,942879027,505129550,304822216,0,0,1645189778,0,1,15,0,0,0,_binary 'AAALOZWBAADtZTsHtgNsAAAAAAAJFO0AAA==',173,'',31050,4049634585049332042),(1139,942879027,505129550,304822216,0,0,1645189838,0,1,15,0,0,0,_binary 'AAALOZWBAADtZT8HtgNtAAAAAAAJFO0AAA==',173,'',31051,4049634585049332043),(1140,942879027,505129550,304822216,0,0,1645189898,0,1,15,0,0,0,_binary 'AAALOZWBAADtZMkHtgN3AAAAAAAJFO0AAA==',172,'',31052,4049634585049332044),(1141,942879027,505129550,304822216,0,0,1645189958,0,1,15,0,0,0,_binary 'AAALOZWBAADtZJAHtgN4AAAAAAAJFO0AAA==',171,'',31053,4049634585049332045),(1142,942879027,505129550,304822216,0,0,1645190018,0,1,15,0,0,0,_binary 'AAALOZWBAADtZOAHtgN9AAAAAAAJFO0AAA==',172,'',31054,4049634585049332046),(1143,942879027,505129550,304822216,0,0,1645190078,0,1,15,0,0,0,_binary 'AAALOZWBAADtZOQHtgOCAAAAAAAJFO0AAA==',172,'',31055,4049634585049332047),(1144,942879027,505129550,304822216,0,0,1645190138,0,1,16,0,0,0,_binary 'AAALOZWBAADtZJEHtgOFAAAAAAAJFO0AAA==',171,'',31056,4049634585049332048),(1145,942879027,505129550,304822216,0,0,1645190198,0,1,16,0,0,0,_binary 'AAALOZWBAADtZHIHtwOFAAAAAAAJFO0AAA==',171,'',31057,4049634585049332049),(1146,942879027,505129550,304822216,0,0,1645190258,0,1,16,0,0,0,_binary 'AAALOZWBAADtZI8HtwOFAAAAAAAJFO0AAA==',171,'',31058,4049634585049332050),(1147,942879027,505129550,304822216,0,0,1645190318,0,1,15,0,0,0,_binary 'AAALOZWBAADtZAEHtwOFAAAAAAAJFO0AAA==',171,'',31059,4049634585049332051),(1148,942879027,505129550,304822216,0,0,1645190378,0,1,16,0,0,0,_binary 'AAALOZWBAADtZBQHtwOFAAAAAAAJFO0AAA==',171,'',31060,4049634585049332052),(1149,942879027,505129550,304822216,0,0,1645190438,0,1,16,0,0,0,_binary 'AAALOZWBAADtZEwHtwOFAAAAAAAJFO0AAA==',171,'',31061,4049634585049332053),(1150,942879027,505129550,304822216,0,0,1645190498,0,1,16,0,0,0,_binary 'AAALOZWBAADtZFIHtwOFAAAAAAAJFO0AAA==',171,'',31062,4049634585049332054),(1151,942879027,505129550,304822216,0,0,1645190558,0,1,16,0,0,0,_binary 'AAALOZWBAADtZEcHtwOEAAAAAAAJFO0AAA==',171,'',31063,4049634585049332055),(1152,942879027,505129550,304822216,0,0,1645190618,0,1,15,0,0,0,_binary 'AAALOZWBAADtZEAHtwOEAAAAAAAJFO0AAA==',171,'',31064,4049634585049332056);
/*!40000 ALTER TABLE `online64` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `parameters`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `parameters` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Number` int(11) NOT NULL COMMENT 'Номер параметра',
  `Value` varchar(255) DEFAULT NULL COMMENT 'Значение',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `parameters` WRITE;
/*!40000 ALTER TABLE `parameters` DISABLE KEYS */;
INSERT INTO `parameters` VALUES (1,24,'False'),(2,18,'True'),(3,13,'True'),(4,22,'0'),(5,12,'False'),(6,21,'uk'),(7,19,'osm.lwco.biz'),(8,23,'11463759-726e-4630-a230-be407acd24a5'),(9,11,'0'),(10,6,'False'),(11,8,'False'),(12,9,'False'),(13,7,'0'),(14,1,'24'),(15,3,'5'),(16,10,'0'),(17,5,'False'),(18,2,'12'),(19,29,'960'),(20,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(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Индекс',
  `Typedata` varchar(255) NOT NULL DEFAULT ' ' COMMENT 'Тип данных',
  `koeffK` double NOT NULL DEFAULT '0' COMMENT 'Коеффициент К',
  `Startbit` int(11) NOT NULL DEFAULT '0' COMMENT 'Стартовый бит поля',
  `Lengthbit` int(11) NOT NULL DEFAULT '0' COMMENT 'Длина поля',
  `Comment` varchar(255) DEFAULT ' ' COMMENT 'Коментарий',
  `Idpcb` int(11) NOT NULL DEFAULT '0' COMMENT 'Индекс платы датчика',
  `NameVal` varchar(12) DEFAULT ' ' COMMENT 'Name meassurement value',
  `NumAlg` int(11) DEFAULT '0' COMMENT 'Number of algorithm',
  `Shifter` double DEFAULT '0' COMMENT 'Shift coefficient',
  `S` tinyint(1) DEFAULT '0' COMMENT 'Sign arifmetic',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=cp1251 AVG_ROW_LENGTH=2340 COMMENT='Описание платы датчиков';
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `points`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `points` (
  `Point_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Latitude` int(11) DEFAULT '0',
  `Longitude` int(11) DEFAULT '0',
  `Zone_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`Point_ID`),
  KEY `FK_points_zones` (`Zone_ID`),
  CONSTRAINT `FK_points_zones` FOREIGN KEY (`Zone_ID`) REFERENCES `zones` (`Zone_ID`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `relationalgorithms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `relationalgorithms` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `AlgorithmID` int(11) NOT NULL DEFAULT '0',
  `SensorID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `ID` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=28 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,7,1),(2,31,2),(3,5,3),(4,27,4),(5,4,5),(6,6,6),(7,2,7),(9,7,9),(10,4,10),(11,5,11),(12,7,12),(13,4,13),(14,5,14),(15,7,15),(16,7,16),(17,4,17),(18,5,18),(19,7,19),(20,4,20),(21,5,21),(22,7,22),(23,4,23),(24,5,24),(25,7,25),(26,7,26),(27,7,27);
/*!40000 ALTER TABLE `relationalgorithms` ENABLE KEYS */;
UNLOCK TABLES;

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

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

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

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

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

DROP TABLE IF EXISTS `route_items`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `route_items` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Seq` int(11) DEFAULT NULL,
  `Route_ID` int(11) DEFAULT NULL,
  `Zone_ID` int(11) DEFAULT NULL,
  `Zone_IO` int(11) DEFAULT NULL,
  `GoNext_Min` int(11) DEFAULT NULL,
  `GoNext_Max` int(11) DEFAULT NULL,
  `Link_Item` int(11) DEFAULT NULL,
  `Link_Info` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `route_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `route_list` (
  `Route_ID` int(11) NOT NULL AUTO_INCREMENT,
  `GIS` blob,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `Modified` int(11) DEFAULT NULL,
  PRIMARY KEY (`Route_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `route_lists`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `route_lists` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Parent` int(11) DEFAULT NULL,
  `Title` varchar(70) DEFAULT NULL,
  `Data` text,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `route_mobitel_links`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `route_mobitel_links` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `List_ID` int(11) DEFAULT NULL,
  `Route_ID` int(11) DEFAULT NULL,
  `Mobitel_ID` int(11) DEFAULT NULL,
  `Time1` int(11) DEFAULT NULL,
  `Time2` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `route_mobitel_plans`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `route_mobitel_plans` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Title` varchar(70) DEFAULT NULL,
  `Time1` int(11) DEFAULT NULL,
  `Time2` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `route_points`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `route_points` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Route_ID` int(11) DEFAULT NULL,
  `Zone_ID` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `rt_events`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `rt_events` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `rt_route_type`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `rt_route_type` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) NOT NULL COMMENT 'Тип маршрута',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `rules`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `rules` (
  `Rule_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Password` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) NOT NULL DEFAULT '0',
  `Rule1` tinyint(4) NOT NULL DEFAULT '0',
  `Rule2` tinyint(4) NOT NULL DEFAULT '0',
  `Rule3` tinyint(4) NOT NULL DEFAULT '0',
  `Rule4` tinyint(4) NOT NULL DEFAULT '0',
  `Rule5` tinyint(4) NOT NULL DEFAULT '0',
  `Rule6` tinyint(4) NOT NULL DEFAULT '0',
  `Rule7` tinyint(4) NOT NULL DEFAULT '0',
  `Rule8` tinyint(4) NOT NULL DEFAULT '0',
  `Rule9` tinyint(4) NOT NULL DEFAULT '0',
  `Rule10` tinyint(4) NOT NULL DEFAULT '0',
  `Rule11` tinyint(4) NOT NULL DEFAULT '0',
  `Rule12` tinyint(4) NOT NULL DEFAULT '0',
  `Rule13` tinyint(4) NOT NULL DEFAULT '0',
  `Rule14` tinyint(4) NOT NULL DEFAULT '0',
  `Rule15` tinyint(4) NOT NULL DEFAULT '0',
  `Rule16` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Rule_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `rules` WRITE;
/*!40000 ALTER TABLE `rules` DISABLE KEYS */;
INSERT INTO `rules` VALUES (1,'guest','guest','guest account',0,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0),(8,'power','power','Description for Power User Profile',0,1,1,1,1,1,0,0,1,1,0,0,0,0,0,0,0),(9,'root','root','Description for root  Profile',0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0);
/*!40000 ALTER TABLE `rules` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `sensor_hookups`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sensor_hookups` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Mobitel_ID` int(11) DEFAULT NULL,
  `Sensor_ID` int(11) DEFAULT NULL,
  `FirstBit` int(11) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `sensor_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sensor_list` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Title` varchar(70) DEFAULT NULL,
  `Kind` varchar(20) DEFAULT NULL,
  `BitsCount` int(11) DEFAULT NULL,
  `FirstBit` int(11) DEFAULT NULL,
  `Data` text,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `sensoralgorithms`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sensoralgorithms` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(45) NOT NULL,
  `Description` char(45) DEFAULT NULL,
  `AlgorithmID` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `ID` (`ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=32 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `sensorcoefficient`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sensorcoefficient` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Sensor_id` int(10) unsigned NOT NULL,
  `UserValue` double(10,5) NOT NULL,
  `SensorValue` double(10,5) NOT NULL,
  `K` double(10,5) NOT NULL DEFAULT '1.00000',
  `b` double NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `Index_2` (`Sensor_id`,`UserValue`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=406 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,1,0.00000,0.00000,0.65811,0),(2,1,10.00000,6431.00000,-0.06135,404.5398773006135),(3,1,30.00000,6105.00000,-0.06135,404.5398773006135),(4,1,50.00000,5799.00000,-0.06536,429.0196078431373),(5,1,70.00000,5507.00000,-0.06849,447.1917808219178),(6,1,90.00000,5206.00000,-0.06645,435.9136212624585),(7,1,140.00000,4490.00000,-0.06983,453.54748603351953),(8,1,190.00000,3778.00000,-0.07022,455.30898876404495),(9,1,240.00000,3080.00000,-0.07163,460.63037249283667),(10,1,290.00000,2370.00000,-0.07042,456.90140845070425),(11,1,340.00000,1645.00000,-0.06897,453.44827586206895),(12,1,360.00000,1344.00000,-0.06645,449.30232558139534),(13,1,380.00000,1032.00000,-0.06410,446.15384615384613),(14,1,394.00000,828.00000,-0.06863,450.8235294117647),(15,1,410.00000,623.00000,-0.07805,458.62439024390244),(16,9,0.00000,0.00000,1.35225,0),(17,9,10.00000,5980.00000,-0.18519,1117.4074074074074),(18,9,30.00000,5872.00000,-0.18519,1117.4074074074074),(19,9,50.00000,5718.00000,-0.12987,792.5974025974025),(20,9,70.00000,5573.00000,-0.13793,838.6896551724138),(21,9,90.00000,5440.00000,-0.15038,908.0451127819548),(22,9,110.00000,5303.00000,-0.14599,884.1605839416058),(23,9,160.00000,4956.00000,-0.14409,874.1210374639769),(24,9,210.00000,4624.00000,-0.15060,906.3855421686748),(25,9,260.00000,4304.00000,-0.15625,932.5),(26,9,310.00000,3972.00000,-0.15060,908.1927710843374),(27,9,360.00000,3643.00000,-0.15198,913.6474164133739),(28,9,410.00000,3317.00000,-0.15337,918.7423312883436),(29,9,460.00000,3000.00000,-0.15773,933.186119873817),(30,9,510.00000,2680.00000,-0.15625,928.75),(31,9,560.00000,2345.00000,-0.14925,910),(32,9,610.00000,2014.00000,-0.15106,914.2296072507553),(33,9,660.00000,1691.00000,-0.15480,921.7647058823529),(34,9,680.00000,1550.00000,-0.14184,899.8581560283687),(35,9,700.00000,1414.00000,-0.14706,907.9411764705883),(36,9,720.00000,1273.00000,-0.14184,900.5673758865248),(37,9,740.00000,1131.00000,-0.14085,899.2957746478874),(38,9,760.00000,985.00000,-0.13699,894.931506849315),(39,9,780.00000,840.00000,-0.13793,895.8620689655172),(40,9,790.00000,759.00000,-0.12346,883.7037037037037),(41,9,810.00000,599.00000,-0.12500,884.875),(120,22,0.00000,0.00000,0.00199,0),(121,22,1.00000,503.00000,0.11369,-56.185614849187935),(122,22,50.00000,934.00000,0.10989,-52.63736263736264),(123,22,70.00000,1116.00000,0.11299,-56.10169491525424),(124,22,90.00000,1293.00000,0.11905,-63.928571428571416),(125,22,100.00000,1377.00000,0.12346,-70),(126,22,150.00000,1782.00000,0.12048,-64.6987951807229),(127,22,200.00000,2197.00000,0.12151,-66.95018226002429),(128,22,300.00000,3020.00000,0.12195,-68.29268292682929),(129,22,400.00000,3840.00000,0.12755,-89.79591836734693),(130,22,450.00000,4232.00000,0.12165,-64.84184914841853),(131,22,500.00000,4643.00000,0.12407,-76.0545905707196),(132,22,550.00000,5046.00000,0.11299,-20.169491525423723),(133,22,570.00000,5223.00000,0.11834,-48.106508875739564),(134,22,590.00000,5392.00000,0.11905,-51.90476190476181),(135,22,610.00000,5560.00000,0.11905,-51.90476190476181),(136,22,630.00000,5728.00000,0.11834,-47.86982248520701),(137,22,650.00000,5897.00000,0.11299,-16.327683615819183),(138,22,670.00000,6074.00000,0.10753,16.88172043010752),(139,22,680.00000,6167.00000,0.11111,-5.222222222222172),(140,22,700.00000,6347.00000,0.11111,-5.222222222222172),(141,19,0.00000,0.00000,0.00200,0),(142,19,1.00000,500.00000,0.10615,-52.072625698324025),(143,19,20.00000,679.00000,0.09132,-42.00913242009132),(144,19,40.00000,898.00000,0.09709,-47.18446601941747),(145,19,60.00000,1104.00000,0.10256,-53.230769230769226),(146,19,80.00000,1299.00000,0.10471,-56.02094240837695),(147,19,100.00000,1490.00000,0.10695,-59.35828877005346),(148,19,120.00000,1677.00000,0.12121,-83.27272727272728),(149,19,140.00000,1842.00000,0.10870,-60.217391304347814),(150,19,160.00000,2026.00000,0.10753,-57.84946236559139),(151,19,180.00000,2212.00000,0.10870,-60.434782608695656),(152,19,200.00000,2396.00000,0.10929,-61.857923497267734),(153,19,220.00000,2579.00000,0.10929,-61.857923497267734),(154,19,240.00000,2762.00000,0.10870,-60.217391304347814),(155,19,260.00000,2946.00000,0.10811,-58.48648648648651),(156,19,280.00000,3131.00000,0.10929,-62.18579234972674),(157,19,300.00000,3314.00000,0.10929,-62.18579234972674),(158,19,320.00000,3497.00000,0.10870,-60.10869565217388),(159,19,340.00000,3681.00000,0.10929,-62.29508196721309),(160,19,360.00000,3864.00000,0.10929,-62.29508196721309),(161,19,380.00000,4047.00000,0.12346,-119.62962962962962),(162,19,400.00000,4209.00000,0.10870,-57.5),(163,19,420.00000,4393.00000,0.10753,-52.36559139784947),(164,19,440.00000,4579.00000,0.10870,-57.717391304347814),(165,19,460.00000,4763.00000,0.10811,-54.91891891891896),(166,19,480.00000,4948.00000,0.10695,-49.19786096256678),(167,19,500.00000,5135.00000,0.10753,-52.15053763440858),(168,19,520.00000,5321.00000,0.10582,-43.06878306878309),(169,19,540.00000,5510.00000,0.10363,-30.984455958549233),(170,19,560.00000,5703.00000,0.10417,-34.0625),(171,19,580.00000,5895.00000,0.04348,323.69565217391306),(172,19,590.00000,6125.00000,0.05000,283.75),(173,19,600.00000,6325.00000,0.05000,283.75),(248,12,0.00000,0.00000,0.00190,0),(249,12,1.00000,525.00000,0.05053,-25.529255319148934),(250,12,20.00000,901.00000,0.04878,-23.951219512195124),(251,12,40.00000,1311.00000,0.05141,-27.40359897172236),(252,12,60.00000,1700.00000,0.05587,-34.972067039106136),(253,12,80.00000,2058.00000,0.05263,-28.315789473684205),(254,12,100.00000,2438.00000,0.05305,-29.33687002652522),(255,12,120.00000,2815.00000,0.05305,-29.33687002652522),(256,12,140.00000,3192.00000,0.05319,-29.787234042553195),(257,12,160.00000,3568.00000,0.05333,-30.29333333333335),(258,12,180.00000,3943.00000,0.05634,-42.14084507042253),(259,12,200.00000,4298.00000,0.05277,-26.807387862796844),(260,12,220.00000,4677.00000,0.05249,-25.511811023622045),(261,12,240.00000,5058.00000,0.05208,-23.4375),(262,12,260.00000,5442.00000,0.05115,-18.363171355498707),(263,12,280.00000,5833.00000,0.04950,-8.762376237623755),(264,12,290.00000,6035.00000,0.04950,-8.762376237623755),(265,12,300.00000,6237.00000,0.04950,-8.762376237623755),(266,26,0.00000,0.00000,0.00189,0),(267,26,1.00000,528.00000,0.18447,-96.39805825242719),(268,26,20.00000,631.00000,0.10638,-47.12765957446808),(269,26,40.00000,819.00000,0.11111,-51),(270,26,60.00000,999.00000,0.11561,-55.49132947976878),(271,26,80.00000,1172.00000,0.11765,-57.882352941176464),(272,26,100.00000,1342.00000,0.12048,-61.68674698795181),(273,26,120.00000,1508.00000,0.12500,-68.5),(274,26,140.00000,1668.00000,0.13889,-91.66666666666669),(275,26,160.00000,1812.00000,0.12270,-62.33128834355827),(276,26,180.00000,1975.00000,0.12270,-62.33128834355827),(277,26,200.00000,2138.00000,0.12315,-63.300492610837466),(278,26,250.00000,2544.00000,0.12285,-62.53071253071255),(279,26,300.00000,2951.00000,0.12469,-67.9551122194514),(280,26,350.00000,3352.00000,0.12469,-67.9551122194514),(281,26,400.00000,3753.00000,0.12987,-87.40259740259734),(282,26,450.00000,4138.00000,0.12407,-63.39950372208443),(283,26,500.00000,4541.00000,0.12376,-62.00495049504946),(284,26,550.00000,4945.00000,0.12346,-60.493827160493765),(285,26,570.00000,5107.00000,0.12270,-56.62576687116564),(286,26,590.00000,5270.00000,0.12195,-52.68292682926824),(287,26,610.00000,5434.00000,0.11976,-40.77844311377248),(288,26,630.00000,5601.00000,0.12121,-48.90909090909088),(289,26,650.00000,5766.00000,0.11628,-20.465116279069775),(290,26,660.00000,5852.00000,0.11628,-20.465116279069775),(291,26,670.00000,5938.00000,0.11236,2.8089887640450115),(292,26,680.00000,6027.00000,0.11429,-8.799999999999955),(293,26,700.00000,6202.00000,0.11429,-8.799999999999955),(294,15,0.00000,0.00000,0.01582,0),(295,15,10.00000,632.00000,0.08811,-45.68281938325992),(296,15,30.00000,859.00000,0.10152,-57.20812182741116),(297,15,50.00000,1056.00000,0.10753,-63.54838709677419),(298,15,70.00000,1242.00000,0.11173,-68.77094972067039),(299,15,90.00000,1421.00000,0.11628,-75.23255813953489),(300,15,110.00000,1593.00000,0.12755,-93.1887755102041),(301,15,160.00000,1985.00000,0.12077,-79.73429951690821),(302,15,210.00000,2399.00000,0.12165,-81.8491484184915),(303,15,260.00000,2810.00000,0.12225,-83.52078239608801),(304,15,310.00000,3219.00000,0.12255,-84.48529411764702),(305,15,360.00000,3627.00000,0.12195,-82.3170731707317),(306,15,380.00000,3791.00000,0.12225,-83.44743276283617),(307,15,430.00000,4200.00000,0.12953,-114.04145077720204),(308,15,480.00000,4586.00000,0.12195,-79.26829268292681),(309,15,530.00000,4996.00000,0.12077,-73.38164251207729),(310,15,580.00000,5410.00000,0.12121,-75.75757575757575),(311,15,600.00000,5575.00000,0.11976,-67.66467065868267),(312,15,620.00000,5742.00000,0.11905,-63.571428571428555),(313,15,640.00000,5910.00000,0.11834,-59.40828402366856),(314,15,660.00000,6079.00000,0.11628,-46.8604651162791),(315,15,680.00000,6251.00000,0.11650,-48.27184466019423),(316,15,692.00000,6354.00000,0.08333,162.5),(317,15,700.00000,6450.00000,0.08333,162.5),(318,16,0.00000,0.00000,0.01582,0),(319,16,10.00000,632.00000,0.08811,-45.68281938325992),(320,16,30.00000,859.00000,0.10152,-57.20812182741116),(321,16,50.00000,1056.00000,0.10753,-63.54838709677419),(322,16,70.00000,1242.00000,0.11173,-68.77094972067039),(323,16,90.00000,1421.00000,0.11628,-75.23255813953489),(324,16,110.00000,1593.00000,0.12755,-93.1887755102041),(325,16,160.00000,1985.00000,0.12077,-79.73429951690821),(326,16,210.00000,2399.00000,0.12165,-81.8491484184915),(327,16,260.00000,2810.00000,0.12225,-83.52078239608801),(328,16,310.00000,3219.00000,0.12255,-84.48529411764702),(329,16,360.00000,3627.00000,0.12195,-82.3170731707317),(330,16,380.00000,3791.00000,0.12225,-83.44743276283617),(331,16,430.00000,4200.00000,0.12953,-114.04145077720204),(332,16,480.00000,4586.00000,0.12195,-79.26829268292681),(333,16,530.00000,4996.00000,0.12077,-73.38164251207729),(334,16,580.00000,5410.00000,0.12121,-75.75757575757575),(335,16,600.00000,5575.00000,0.11976,-67.66467065868267),(336,16,620.00000,5742.00000,0.11905,-63.571428571428555),(337,16,640.00000,5910.00000,0.11834,-59.40828402366856),(338,16,660.00000,6079.00000,0.11628,-46.8604651162791),(339,16,680.00000,6251.00000,0.11650,-48.27184466019423),(340,16,692.00000,6354.00000,0.08333,162.5),(341,16,700.00000,6450.00000,0.08333,162.5),(342,25,0.00000,0.00000,0.00200,0),(343,25,1.00000,500.00000,0.28788,-142.93939393939394),(344,25,20.00000,566.00000,0.13605,-57.00680272108845),(345,25,40.00000,713.00000,0.10582,-35.44973544973544),(346,25,60.00000,902.00000,0.11173,-40.78212290502793),(347,25,80.00000,1081.00000,0.11429,-43.542857142857144),(348,25,100.00000,1256.00000,0.11628,-46.046511627906966),(349,25,120.00000,1428.00000,0.14184,-82.55319148936172),(350,25,140.00000,1569.00000,0.11905,-46.78571428571428),(351,25,160.00000,1737.00000,0.11905,-46.78571428571428),(352,25,180.00000,1905.00000,0.11834,-45.4437869822485),(353,25,200.00000,2074.00000,0.12048,-49.87951807228916),(354,25,220.00000,2240.00000,0.11976,-48.2634730538922),(355,25,240.00000,2407.00000,0.12048,-50),(356,25,260.00000,2573.00000,0.12121,-51.878787878787875),(357,25,280.00000,2738.00000,0.11976,-47.90419161676647),(358,25,300.00000,2905.00000,0.12048,-50),(359,25,350.00000,3320.00000,0.12077,-50.96618357487921),(360,25,400.00000,3734.00000,0.12788,-77.49360613810745),(361,25,450.00000,4125.00000,0.11933,-42.24343675417657),(362,25,500.00000,4544.00000,0.11933,-42.24343675417663),(363,25,550.00000,4963.00000,0.11792,-35.25943396226421),(364,25,600.00000,5387.00000,0.11696,-30.058479532163688),(365,25,620.00000,5558.00000,0.11696,-30.058479532163688),(366,25,640.00000,5729.00000,0.11494,-18.505747126436745),(367,25,650.00000,5816.00000,0.11364,-10.909090909090878),(368,25,660.00000,5904.00000,0.11236,-3.3707865168539684),(369,25,670.00000,5993.00000,0.11111,4.1111111111111995),(370,25,680.00000,6083.00000,0.11111,4.1111111111111995),(371,25,685.00000,6128.00000,0.08000,194.76),(372,25,687.00000,6153.00000,0.14444,-201.76666666666654),(373,25,700.00000,6243.00000,0.14444,-201.76666666666654),(374,27,0.00000,0.00000,1.51471,0),(375,27,1.00000,7618.00000,-0.05960,455.05298013245033),(376,27,10.00000,7467.00000,-0.05960,455.05298013245033),(377,27,20.00000,7291.00000,-0.05682,434.2613636363636),(378,27,40.00000,6970.00000,-0.06231,474.26791277258565),(379,27,60.00000,6665.00000,-0.06557,497.0491803278689),(380,27,80.00000,6386.00000,-0.07168,537.7777777777778),(381,27,100.00000,6105.00000,-0.07117,534.5195729537368),(382,27,120.00000,5830.00000,-0.07273,544),(383,27,140.00000,5552.00000,-0.07194,539.4244604316547),(384,27,160.00000,5282.00000,-0.07407,551.2592592592592),(385,27,180.00000,5008.00000,-0.07299,545.5474452554745),(386,27,200.00000,4739.00000,-0.07435,552.3420074349442),(387,27,220.00000,4467.00000,-0.07353,548.4558823529412),(388,27,240.00000,4199.00000,-0.07463,553.3582089552239),(389,27,260.00000,3927.00000,-0.07353,548.75),(390,27,280.00000,3660.00000,-0.07491,554.1573033707865),(391,27,300.00000,3394.00000,-0.07519,555.187969924812),(392,27,320.00000,3118.00000,-0.07246,545.9420289855072),(393,27,340.00000,2852.00000,-0.07519,554.4360902255639),(394,27,360.00000,2579.00000,-0.07326,548.9377289377289),(395,27,380.00000,2313.00000,-0.07519,553.9097744360902),(396,27,400.00000,2038.00000,-0.07273,548.2181818181818),(397,27,420.00000,1764.00000,-0.07299,548.7591240875912),(398,27,440.00000,1487.00000,-0.07220,547.3646209386281),(399,27,460.00000,1205.00000,-0.07092,545.4609929078015),(400,27,470.00000,1058.00000,-0.06803,541.9727891156463),(401,27,480.00000,908.00000,-0.06667,540.5333333333333),(402,27,485.00000,825.00000,-0.06024,534.6987951807229),(403,27,490.00000,748.00000,-0.06494,538.5714285714286),(404,27,495.00000,660.00000,-0.05682,532.5),(405,27,515.00000,340.00000,-0.06250,536.25);
/*!40000 ALTER TABLE `sensorcoefficient` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `sensordata`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sensordata` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `datagps_id` int(10) unsigned NOT NULL,
  `sensor_id` int(10) unsigned NOT NULL,
  `Value` double(10,2) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `Index_2` (`datagps_id`,`sensor_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `sensors`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sensors` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mobitel_id` int(11) NOT NULL,
  `Name` varchar(45) NOT NULL,
  `Description` varchar(200) NOT NULL,
  `StartBit` int(10) unsigned NOT NULL,
  `Length` int(10) unsigned NOT NULL,
  `NameUnit` varchar(45) NOT NULL,
  `K` double(10,5) NOT NULL DEFAULT '0.00000',
  `B` double DEFAULT '0' COMMENT 'Shift coefficient',
  `S` tinyint(1) DEFAULT '0' COMMENT 'Sign arifmetic',
  PRIMARY KEY (`id`),
  KEY `Index_2` (`mobitel_id`)
) ENGINE=InnoDB AUTO_INCREMENT=28 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,942879027,'правий бак','',80,16,' л',1.00000,0,0),(2,942879027,'штатний ДРП','',128,8,' %',0.40000,0,0),(3,942879027,'оберти двигуна','',0,16,' rpm',0.12500,0,0),(4,942879027,'витрата','',16,64,' л',0.50000,0,0),(5,942879027,'бортмережа','',112,16,' В',0.00100,0,0),(6,942879027,'пробіг за тахографом','',152,32,' км',0.00500,0,0),(7,942879027,'запалювання','',196,1,' ',1.00000,0,0),(9,942879027,'лівий бак','',96,16,'л',1.00000,0,0),(10,959590964,'бортмережа','',36,8,'В',0.11810,0,0),(11,959590964,'запалювання','',60,1,'#',1.00000,0,0),(12,959590964,'лівий бак','',20,16,'л',1.00000,0,0),(13,909195569,'бортмережа','',36,8,'В',0.11810,0,0),(14,909195569,'запалювання','',60,1,'#',1.00000,0,0),(15,909195569,'правий бак','',20,16,'л',1.00000,0,0),(16,909195569,'лівий бак','Новая',44,16,'л',1.00000,0,0),(17,926431026,'бортмережа','',36,8,'В',0.11810,0,0),(18,926431026,'запалювання','',61,1,'#',1.00000,0,0),(19,926431026,'лівий бак','',20,16,'л',1.00000,0,0),(20,959590963,'бортмережа','',36,8,'В',0.11810,0,0),(21,959590963,'запалювання','',60,1,'#',1.00000,0,0),(22,959590963,'бак','',20,16,'л',1.00000,0,0),(23,959590965,'бортмережа','',36,8,'В',0.11810,0,0),(24,959590965,'запалювання','',60,1,'#',1.00000,0,0),(25,959590965,'бак','',20,16,'л',1.00000,0,0),(26,959590964,'правий бак','Новая',44,16,'л',1.00000,0,0),(27,926431026,'правий бак','Новая',44,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(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `ServiceType_ID` int(11) DEFAULT '0',
  `A1` char(50) DEFAULT NULL,
  `A2` char(50) DEFAULT NULL,
  `A3` char(50) DEFAULT NULL,
  `A4` char(50) DEFAULT NULL,
  `A5` char(50) DEFAULT NULL,
  `A6` char(50) DEFAULT NULL,
  `A7` char(50) DEFAULT NULL,
  `A8` char(50) DEFAULT NULL,
  `A9` char(50) DEFAULT NULL,
  `A10` char(200) DEFAULT NULL,
  `CAtoSAint` int(11) DEFAULT '0',
  `CAtoSAtime` int(11) DEFAULT '0',
  `SAtoCAint` int(11) DEFAULT '0',
  `SAtoCAtime` int(11) DEFAULT '0',
  `SAtoCAtext` char(50) DEFAULT 'STOPPED',
  `CAtoSAtext` char(50) DEFAULT 'STOPPED',
  `MobitelActive_ID` int(11) NOT NULL DEFAULT '0',
  `Active` tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`ServiceInit_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `servicesend`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `servicesend` (
  `ServiceSend_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(50) DEFAULT NULL,
  `Descr` varchar(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `telMobitel` varchar(64) DEFAULT NULL,
  `smsMobitel` varchar(64) DEFAULT NULL,
  `emailMobitel` varchar(64) DEFAULT NULL,
  `IPMobitel` varchar(64) DEFAULT NULL,
  `URLMobitel` varchar(64) DEFAULT NULL,
  `PortMobitel` int(11) DEFAULT '0',
  `RfMobitel` varchar(50) DEFAULT NULL,
  `Message_ID` int(11) DEFAULT '0',
  PRIMARY KEY (`ServiceSend_ID`),
  KEY `Index_2` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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,'105',NULL,NULL,NULL,NULL,0,NULL,0),(2,'','',2,0,'103',NULL,NULL,NULL,NULL,0,NULL,0),(3,'','',3,0,'102',NULL,NULL,NULL,NULL,0,NULL,0),(4,'','',4,0,'104',NULL,NULL,NULL,NULL,0,NULL,0),(5,'0023','Desctiption for Teletrack registered at 09.02.2022 10:15:15',5,0,'106',NULL,NULL,NULL,NULL,0,NULL,0),(6,'4739','Desctiption for Teletrack registered at 09.02.2022 10:15:56',6,0,'107',NULL,NULL,NULL,NULL,0,NULL,0);
/*!40000 ALTER TABLE `servicesend` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `servicetypes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `servicetypes` (
  `ServiceType_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `Flags` int(11) DEFAULT '0',
  `D1` char(200) DEFAULT NULL,
  `D2` char(200) DEFAULT NULL,
  `D3` char(200) DEFAULT NULL,
  `D4` char(200) DEFAULT NULL,
  `D5` char(200) DEFAULT NULL,
  `D6` char(200) DEFAULT NULL,
  `D7` char(200) DEFAULT NULL,
  `D8` char(200) DEFAULT NULL,
  `D9` char(200) DEFAULT NULL,
  `D10` char(200) DEFAULT NULL,
  PRIMARY KEY (`ServiceType_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

LOCK TABLES `setting` WRITE;
/*!40000 ALTER TABLE `setting` DISABLE KEYS */;
INSERT INTO `setting` VALUES (1,'00:01:00',100,100,15,0,7,1,1,80,0,0,'Настройка 1','Настройка по умолчанию',15.00000,'00:02:00','00:00:00','00:00:00','00:01:00',10,'00:02:00',1,0,1,0,'03:00:00',5,5,0,'00:00:00',0);
/*!40000 ALTER TABLE `setting` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `smsnumbers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `smsnumbers` (
  `SmsNumber_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `smsNumber` char(14) DEFAULT NULL,
  PRIMARY KEY (`SmsNumber_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=86 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `sources`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sources` (
  `Source_ID` int(11) NOT NULL AUTO_INCREMENT,
  `SourceText` char(200) DEFAULT NULL,
  `SourceError` char(200) DEFAULT NULL,
  PRIMARY KEY (`Source_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `specialmessages`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `specialmessages` (
  `SpecMessage_ID` int(11) NOT NULL AUTO_INCREMENT,
  `DataString` char(50) DEFAULT NULL,
  `DataInteger` int(11) DEFAULT '0',
  `unixtime` char(50) DEFAULT NULL,
  `isNew` int(11) DEFAULT '0',
  PRIMARY KEY (`SpecMessage_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `state`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `state` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `MinValue` double NOT NULL,
  `MaxValue` double NOT NULL,
  `Title` varchar(50) NOT NULL,
  `SensorId` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`),
  KEY `State_FK` (`SensorId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=13 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',7),(2,1,1.1,'1',7),(3,0,0.1,'0',11),(4,1,1.1,'1',11),(5,0,0.1,'0',14),(6,1,1.1,'1',14),(7,0,0.1,'0',18),(8,1,1.1,'1',18),(9,0,0.1,'0',21),(10,1,1.1,'1',21),(11,0,0.1,'0',24),(12,1,1.1,'1',24);
/*!40000 ALTER TABLE `state` ENABLE KEYS */;
UNLOCK TABLES;

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

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

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

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

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

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

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

LOCK TABLES `team` WRITE;
/*!40000 ALTER TABLE `team` DISABLE KEYS */;
INSERT INTO `team` VALUES (1,'Автомобиль',NULL,1,NULL,0,0),(2,'Трактор',NULL,1,NULL,0,0),(3,'Комбайн',NULL,1,NULL,0,0),(4,'Заправщик',NULL,1,NULL,0,0),(5,'Кран',NULL,1,NULL,0,0),(6,'Транспорт','',1,'',0,0);
/*!40000 ALTER TABLE `team` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `telnumbers`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `telnumbers` (
  `TelNumber_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Name` char(50) DEFAULT NULL,
  `Descr` char(200) DEFAULT NULL,
  `ID` int(11) DEFAULT '0',
  `Flags` int(11) DEFAULT '0',
  `TelNumber` char(50) DEFAULT NULL,
  PRIMARY KEY (`TelNumber_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=108 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,'+380671759643'),(103,'rcs','mtel',0,0,'+37259802990'),(104,'rcs','mtel',0,0,'+380671705160'),(105,'rcs','mtel',0,0,'+380676966892'),(106,'rcs','mtel',0,0,'+37259802991'),(107,'rcs','mtel',0,0,'+380671714817');
/*!40000 ALTER TABLE `telnumbers` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `temp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `temp` (
  `datagps_id` int(10) unsigned NOT NULL DEFAULT '0',
  `sensor_id` int(10) unsigned NOT NULL DEFAULT '0',
  `Value` double(10,2) NOT NULL DEFAULT '0.00'
) ENGINE=MEMORY DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `transition`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `transition` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `InitialStateId` int(11) DEFAULT NULL,
  `FinalStateId` int(11) DEFAULT NULL,
  `Title` varchar(50) NOT NULL,
  `SensorId` int(11) DEFAULT NULL,
  `IconName` varchar(50) NOT NULL,
  `SoundName` varchar(50) NOT NULL,
  `Enabled` tinyint(1) NOT NULL,
  `ViewInReport` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `Sensors_FK` (`SensorId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=13 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',7,'Default','Default',0,1),(2,2,1,'0',7,'Default','Default',0,1),(3,5,6,'1',14,'Default','Default',0,1),(4,6,5,'0',14,'Default','Default',0,1),(5,7,8,'1',18,'Default','Default',0,1),(6,8,7,'0',18,'Default','Default',0,1),(7,9,10,'1',21,'Default','Default',0,1),(8,10,9,'0',21,'Default','Default',0,1),(9,3,4,'1',11,'Default','Default',0,1),(10,4,3,'0',11,'Default','Default',0,1),(11,11,12,'1',24,'Default','Default',0,1),(12,12,11,'0',24,'Default','Default',0,1);
/*!40000 ALTER TABLE `transition` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `users_acs_objects`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users_acs_objects` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Id_role` int(11) NOT NULL,
  `Id_type` int(11) NOT NULL,
  `Id_object` int(11) NOT NULL,
  PRIMARY KEY (`Id`),
  KEY `FK_users_acs_objects_users_acs_roles_Id` (`Id_role`),
  CONSTRAINT `FK_users_acs_objects_users_acs_roles_Id` FOREIGN KEY (`Id_role`) REFERENCES `users_acs_roles` (`Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=10 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,10),(2,2,3,13),(3,2,3,14),(4,2,3,15),(5,2,3,16),(6,2,3,19),(7,2,3,20),(8,2,3,21),(9,2,3,22);
/*!40000 ALTER TABLE `users_acs_objects` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `users_acs_roles`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users_acs_roles` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `users_acs_roles` WRITE;
/*!40000 ALTER TABLE `users_acs_roles` DISABLE KEYS */;
INSERT INTO `users_acs_roles` VALUES (1,'Администратор'),(2,'Захід-Руно');
/*!40000 ALTER TABLE `users_acs_roles` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `users_actions_log`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users_actions_log` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `TypeLog` int(11) NOT NULL DEFAULT '0',
  `DateAction` datetime NOT NULL,
  `Id_document` int(11) NOT NULL DEFAULT '0',
  `TextLog` varchar(255) NOT NULL,
  `User` varchar(127) NOT NULL,
  `Computer` varchar(63) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=204 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,'2022-02-09 09:54:47',0,'25->0 Період згладжування','admin','MNK'),(2,8,'2022-02-09 09:54:47',0,'10->7 Поріг зливу','admin','MNK'),(3,8,'2022-02-09 09:54:47',0,'50->20 Поріг заправки','admin','MNK'),(4,8,'2022-02-09 09:54:47',0,'70->80 Максимальна швидкість руху, км/год','admin','MNK'),(5,8,'2022-02-09 09:54:47',0,'0->1 Не враховувати зливи у витратах','admin','MNK'),(6,9,'2022-02-09 10:53:22',1,'Вхід','admin','MNK'),(7,9,'2022-02-09 10:53:24',1,'Завантижити','admin','MNK'),(8,9,'2022-02-09 11:21:51',9,'Вхід','admin','MNK'),(9,9,'2022-02-09 11:21:52',9,'Завантижити','admin','MNK'),(10,9,'2022-02-09 13:35:41',15,'Вхід','admin','MNK'),(11,9,'2022-02-09 13:35:43',15,'Завантижити','admin','MNK'),(12,9,'2022-02-09 13:38:47',16,'Вхід','admin','MNK'),(13,9,'2022-02-09 13:38:48',16,'Завантижити','admin','MNK'),(14,9,'2022-02-09 13:42:57',15,'Вхід','admin','MNK'),(15,9,'2022-02-09 13:43:01',15,'Delete record 0','admin','MNK'),(16,9,'2022-02-09 13:43:01',15,'Delete record 0','admin','MNK'),(17,9,'2022-02-09 13:43:01',15,'Delete record 0','admin','MNK'),(18,9,'2022-02-09 13:43:01',15,'Delete record 0','admin','MNK'),(19,9,'2022-02-09 13:43:02',15,'Delete record 0','admin','MNK'),(20,9,'2022-02-09 13:43:02',15,'Delete record 0','admin','MNK'),(21,9,'2022-02-09 13:43:02',15,'Delete record 0','admin','MNK'),(22,9,'2022-02-09 13:43:02',15,'Delete record 0','admin','MNK'),(23,9,'2022-02-09 13:43:03',15,'Delete record 0','admin','MNK'),(24,9,'2022-02-09 13:43:03',15,'Delete record 0','admin','MNK'),(25,9,'2022-02-09 13:43:03',15,'Delete record 0','admin','MNK'),(26,9,'2022-02-09 13:43:03',15,'Delete record 0','admin','MNK'),(27,9,'2022-02-09 13:43:05',15,'Delete record 0','admin','MNK'),(28,9,'2022-02-09 13:43:06',15,'Delete record 0','admin','MNK'),(29,9,'2022-02-09 13:43:06',15,'Delete record 0','admin','MNK'),(30,9,'2022-02-09 13:43:06',15,'Delete record 0','admin','MNK'),(31,9,'2022-02-09 13:43:06',15,'Delete record 0','admin','MNK'),(32,9,'2022-02-09 13:43:06',15,'Delete record 0','admin','MNK'),(33,9,'2022-02-09 13:43:07',15,'Delete record 0','admin','MNK'),(34,9,'2022-02-09 13:43:07',15,'Delete record 0','admin','MNK'),(35,9,'2022-02-09 13:43:07',15,'Delete record 0','admin','MNK'),(36,9,'2022-02-09 13:43:11',16,'Вхід','admin','MNK'),(37,9,'2022-02-09 13:43:14',16,'Delete record 0','admin','MNK'),(38,9,'2022-02-09 13:43:14',16,'Delete record 0','admin','MNK'),(39,9,'2022-02-09 13:43:14',16,'Delete record 0','admin','MNK'),(40,9,'2022-02-09 13:43:14',16,'Delete record 0','admin','MNK'),(41,9,'2022-02-09 13:43:15',16,'Delete record 0','admin','MNK'),(42,9,'2022-02-09 13:43:15',16,'Delete record 0','admin','MNK'),(43,9,'2022-02-09 13:43:15',16,'Delete record 0','admin','MNK'),(44,9,'2022-02-09 13:43:15',16,'Delete record 0','admin','MNK'),(45,9,'2022-02-09 13:43:16',16,'Delete record 0','admin','MNK'),(46,9,'2022-02-09 13:43:18',16,'Delete record 0','admin','MNK'),(47,9,'2022-02-09 13:43:18',16,'Delete record 0','admin','MNK'),(48,9,'2022-02-09 13:43:19',16,'Delete record 0','admin','MNK'),(49,9,'2022-02-09 13:43:19',16,'Delete record 0','admin','MNK'),(50,9,'2022-02-09 13:43:19',16,'Delete record 0','admin','MNK'),(51,9,'2022-02-09 13:43:19',16,'Delete record 0','admin','MNK'),(52,9,'2022-02-09 13:43:19',16,'Delete record 0','admin','MNK'),(53,9,'2022-02-09 13:43:20',16,'Delete record 0','admin','MNK'),(54,9,'2022-02-09 13:43:20',16,'Delete record 0','admin','MNK'),(55,9,'2022-02-09 13:44:41',15,'Вхід','admin','MNK'),(56,9,'2022-02-09 13:44:43',15,'Завантижити','admin','MNK'),(57,9,'2022-02-09 13:44:57',16,'Вхід','admin','MNK'),(58,9,'2022-02-09 13:44:59',16,'Завантижити','admin','MNK'),(59,9,'2022-02-09 13:45:55',15,'Вхід','admin','MNK'),(60,9,'2022-02-09 13:45:58',15,'Delete record 0','admin','MNK'),(61,9,'2022-02-09 13:45:58',15,'Delete record 0','admin','MNK'),(62,9,'2022-02-09 13:45:59',15,'Delete record 0','admin','MNK'),(63,9,'2022-02-09 13:45:59',15,'Delete record 0','admin','MNK'),(64,9,'2022-02-09 13:45:59',15,'Delete record 0','admin','MNK'),(65,9,'2022-02-09 13:45:59',15,'Delete record 0','admin','MNK'),(66,9,'2022-02-09 13:45:59',15,'Delete record 0','admin','MNK'),(67,9,'2022-02-09 13:45:59',15,'Delete record 0','admin','MNK'),(68,9,'2022-02-09 13:46:00',15,'Delete record 0','admin','MNK'),(69,9,'2022-02-09 13:46:02',15,'Delete record 0','admin','MNK'),(70,9,'2022-02-09 13:46:02',15,'Delete record 0','admin','MNK'),(71,9,'2022-02-09 13:46:02',15,'Delete record 0','admin','MNK'),(72,9,'2022-02-09 13:46:03',15,'Delete record 0','admin','MNK'),(73,9,'2022-02-09 13:46:03',15,'Delete record 0','admin','MNK'),(74,9,'2022-02-09 13:46:03',15,'Delete record 0','admin','MNK'),(75,9,'2022-02-09 13:46:03',15,'Delete record 0','admin','MNK'),(76,9,'2022-02-09 13:46:03',15,'Delete record 0','admin','MNK'),(77,9,'2022-02-09 13:46:04',15,'Delete record 0','admin','MNK'),(78,9,'2022-02-09 13:46:07',16,'Вхід','admin','MNK'),(79,9,'2022-02-09 13:46:09',16,'Delete record 0','admin','MNK'),(80,9,'2022-02-09 13:46:09',16,'Delete record 0','admin','MNK'),(81,9,'2022-02-09 13:46:09',16,'Delete record 0','admin','MNK'),(82,9,'2022-02-09 13:46:10',16,'Delete record 0','admin','MNK'),(83,9,'2022-02-09 13:46:10',16,'Delete record 0','admin','MNK'),(84,9,'2022-02-09 13:46:10',16,'Delete record 0','admin','MNK'),(85,9,'2022-02-09 13:46:10',16,'Delete record 0','admin','MNK'),(86,9,'2022-02-09 13:46:10',16,'Delete record 0','admin','MNK'),(87,9,'2022-02-09 13:46:11',16,'Delete record 0','admin','MNK'),(88,9,'2022-02-09 13:46:11',16,'Delete record 0','admin','MNK'),(89,9,'2022-02-09 13:46:11',16,'Delete record 0','admin','MNK'),(90,9,'2022-02-09 13:46:11',16,'Delete record 0','admin','MNK'),(91,9,'2022-02-09 13:46:14',16,'Delete record 0','admin','MNK'),(92,9,'2022-02-09 13:46:14',16,'Delete record 0','admin','MNK'),(93,9,'2022-02-09 13:46:14',16,'Delete record 0','admin','MNK'),(94,9,'2022-02-09 13:46:14',16,'Delete record 0','admin','MNK'),(95,9,'2022-02-09 13:46:14',16,'Delete record 0','admin','MNK'),(96,9,'2022-02-09 13:46:15',16,'Delete record 0','admin','MNK'),(97,9,'2022-02-09 13:46:15',16,'Delete record 0','admin','MNK'),(98,9,'2022-02-09 13:46:15',16,'Delete record 0','admin','MNK'),(99,9,'2022-02-09 13:46:15',16,'Delete record 0','admin','MNK'),(100,9,'2022-02-09 13:49:18',22,'Вхід','admin','MNK'),(101,9,'2022-02-09 13:49:19',22,'Завантижити','admin','MNK'),(102,9,'2022-02-09 13:53:03',19,'Вхід','admin','MNK'),(103,9,'2022-02-09 13:53:04',19,'Завантижити','admin','MNK'),(104,9,'2022-02-18 12:59:59',10,'Вхід','admin','MNK'),(105,9,'2022-02-18 13:00:01',10,'Завантижити','admin','MNK'),(106,9,'2022-02-18 13:00:21',26,'Вхід','admin','MNK'),(107,9,'2022-02-18 13:00:22',26,'Завантижити','admin','MNK'),(108,9,'2022-02-18 13:03:51',10,'Вхід','admin','MNK'),(109,9,'2022-02-18 13:03:59',10,'Вхід','admin','MNK'),(110,9,'2022-02-18 13:04:02',10,'Delete record 0','admin','MNK'),(111,9,'2022-02-18 13:04:02',10,'Delete record 0','admin','MNK'),(112,9,'2022-02-18 13:04:03',10,'Delete record 0','admin','MNK'),(113,9,'2022-02-18 13:04:03',10,'Delete record 0','admin','MNK'),(114,9,'2022-02-18 13:04:03',10,'Delete record 0','admin','MNK'),(115,9,'2022-02-18 13:04:03',10,'Delete record 0','admin','MNK'),(116,9,'2022-02-18 13:04:04',10,'Delete record 0','admin','MNK'),(117,9,'2022-02-18 13:04:04',10,'Delete record 0','admin','MNK'),(118,9,'2022-02-18 13:04:04',10,'Delete record 0','admin','MNK'),(119,9,'2022-02-18 13:04:04',10,'Delete record 0','admin','MNK'),(120,9,'2022-02-18 13:04:04',10,'Delete record 0','admin','MNK'),(121,9,'2022-02-18 13:04:05',10,'Delete record 0','admin','MNK'),(122,9,'2022-02-18 13:04:05',10,'Delete record 0','admin','MNK'),(123,9,'2022-02-18 13:04:05',10,'Delete record 0','admin','MNK'),(124,9,'2022-02-18 13:04:05',10,'Delete record 0','admin','MNK'),(125,9,'2022-02-18 13:04:05',10,'Delete record 0','admin','MNK'),(126,9,'2022-02-18 13:04:06',10,'Delete record 0','admin','MNK'),(127,9,'2022-02-18 13:04:06',10,'Delete record 0','admin','MNK'),(128,9,'2022-02-18 13:04:09',26,'Вхід','admin','MNK'),(129,9,'2022-02-18 13:04:16',26,'Delete record 0','admin','MNK'),(130,9,'2022-02-18 13:04:16',26,'Delete record 0','admin','MNK'),(131,9,'2022-02-18 13:04:16',26,'Delete record 0','admin','MNK'),(132,9,'2022-02-18 13:04:17',26,'Delete record 0','admin','MNK'),(133,9,'2022-02-18 13:04:17',26,'Delete record 0','admin','MNK'),(134,9,'2022-02-18 13:04:17',26,'Delete record 0','admin','MNK'),(135,9,'2022-02-18 13:04:17',26,'Delete record 0','admin','MNK'),(136,9,'2022-02-18 13:04:17',26,'Delete record 0','admin','MNK'),(137,9,'2022-02-18 13:04:18',26,'Delete record 0','admin','MNK'),(138,9,'2022-02-18 13:04:18',26,'Delete record 0','admin','MNK'),(139,9,'2022-02-18 13:04:18',26,'Delete record 0','admin','MNK'),(140,9,'2022-02-18 13:04:18',26,'Delete record 0','admin','MNK'),(141,9,'2022-02-18 13:04:18',26,'Delete record 0','admin','MNK'),(142,9,'2022-02-18 13:04:19',26,'Delete record 0','admin','MNK'),(143,9,'2022-02-18 13:04:19',26,'Delete record 0','admin','MNK'),(144,9,'2022-02-18 13:04:19',26,'Delete record 0','admin','MNK'),(145,9,'2022-02-18 13:04:19',26,'Delete record 0','admin','MNK'),(146,9,'2022-02-18 13:04:19',26,'Delete record 0','admin','MNK'),(147,9,'2022-02-18 13:04:20',26,'Delete record 0','admin','MNK'),(148,9,'2022-02-18 13:04:22',26,'Delete record 0','admin','MNK'),(149,9,'2022-02-18 13:04:23',26,'Delete record 0','admin','MNK'),(150,9,'2022-02-18 13:04:23',26,'Delete record 0','admin','MNK'),(151,9,'2022-02-18 13:04:23',26,'Delete record 0','admin','MNK'),(152,9,'2022-02-18 13:04:23',26,'Delete record 0','admin','MNK'),(153,9,'2022-02-18 13:04:23',26,'Delete record 0','admin','MNK'),(154,9,'2022-02-18 13:04:24',26,'Delete record 0','admin','MNK'),(155,9,'2022-02-18 13:04:24',26,'Delete record 0','admin','MNK'),(156,9,'2022-02-18 13:04:24',26,'Delete record 0','admin','MNK'),(157,9,'2022-02-18 13:04:27',10,'Вхід','admin','MNK'),(158,9,'2022-02-18 13:04:28',10,'Завантижити','admin','MNK'),(159,9,'2022-02-18 13:05:09',12,'Вхід','admin','MNK'),(160,9,'2022-02-18 13:05:15',12,'Вхід','admin','MNK'),(161,9,'2022-02-18 13:05:25',10,'Вхід','admin','MNK'),(162,9,'2022-02-18 13:05:27',10,'Delete record 0','admin','MNK'),(163,9,'2022-02-18 13:05:28',10,'Delete record 0','admin','MNK'),(164,9,'2022-02-18 13:05:28',10,'Delete record 0','admin','MNK'),(165,9,'2022-02-18 13:05:28',10,'Delete record 0','admin','MNK'),(166,9,'2022-02-18 13:05:29',10,'Delete record 0','admin','MNK'),(167,9,'2022-02-18 13:05:29',10,'Delete record 0','admin','MNK'),(168,9,'2022-02-18 13:05:29',10,'Delete record 0','admin','MNK'),(169,9,'2022-02-18 13:05:29',10,'Delete record 0','admin','MNK'),(170,9,'2022-02-18 13:05:29',10,'Delete record 0','admin','MNK'),(171,9,'2022-02-18 13:05:29',10,'Delete record 0','admin','MNK'),(172,9,'2022-02-18 13:05:30',10,'Delete record 0','admin','MNK'),(173,9,'2022-02-18 13:05:30',10,'Delete record 0','admin','MNK'),(174,9,'2022-02-18 13:05:30',10,'Delete record 0','admin','MNK'),(175,9,'2022-02-18 13:05:30',10,'Delete record 0','admin','MNK'),(176,9,'2022-02-18 13:05:31',10,'Delete record 0','admin','MNK'),(177,9,'2022-02-18 13:05:31',10,'Delete record 0','admin','MNK'),(178,9,'2022-02-18 13:05:31',10,'Delete record 0','admin','MNK'),(179,9,'2022-02-18 13:05:32',10,'Delete record 0','admin','MNK'),(180,9,'2022-02-18 13:05:32',10,'Delete record 0','admin','MNK'),(181,9,'2022-02-18 13:05:32',10,'Delete record 0','admin','MNK'),(182,9,'2022-02-18 13:05:32',10,'Delete record 0','admin','MNK'),(183,9,'2022-02-18 13:05:33',10,'Delete record 0','admin','MNK'),(184,9,'2022-02-18 13:05:33',10,'Delete record 0','admin','MNK'),(185,9,'2022-02-18 13:05:33',10,'Delete record 0','admin','MNK'),(186,9,'2022-02-18 13:05:33',10,'Delete record 0','admin','MNK'),(187,9,'2022-02-18 13:05:33',10,'Delete record 0','admin','MNK'),(188,9,'2022-02-18 13:05:34',10,'Delete record 0','admin','MNK'),(189,9,'2022-02-18 13:05:34',10,'Delete record 0','admin','MNK'),(190,9,'2022-02-18 13:05:43',12,'Вхід','admin','MNK'),(191,9,'2022-02-18 13:05:44',12,'Завантижити','admin','MNK'),(192,9,'2022-02-18 13:05:54',26,'Вхід','admin','MNK'),(193,9,'2022-02-18 13:05:56',26,'Завантижити','admin','MNK'),(194,8,'2022-02-18 13:06:50',0,'20->15 Поріг заправки','admin','MNK'),(195,9,'2022-02-18 15:10:34',15,'Вхід','admin','MNK'),(196,9,'2022-02-18 15:10:35',15,'Завантижити','admin','MNK'),(197,9,'2022-02-18 15:11:01',16,'Вхід','admin','MNK'),(198,9,'2022-02-18 15:11:03',16,'Завантижити','admin','MNK'),(199,9,'2022-04-27 13:39:18',25,'Вхід','admin','MNK'),(200,9,'2022-04-27 13:39:19',25,'Завантижити','admin','MNK'),(201,9,'2023-09-06 15:23:16',25,'Вхід','admin','MNK_ROG'),(202,9,'2024-01-29 13:31:11',27,'Вхід','admin','MNK_ROG'),(203,9,'2024-01-29 13:31:13',27,'Завантижити','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(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL,
  `WinLogin` varchar(50) DEFAULT NULL,
  `Password` blob NOT NULL,
  `Admin` tinyint(1) NOT NULL DEFAULT '0',
  `Id_role` int(11) DEFAULT '0' COMMENT 'Код роли пользователя',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `users_reports_list`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users_reports_list` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `ReportType` varchar(127) NOT NULL,
  `ReportCaption` varchar(127) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `vehicle`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `MakeCar` text COMMENT 'Марка автомобиля',
  `NumberPlate` text COMMENT 'Номерной знак',
  `Team_id` int(11) DEFAULT NULL,
  `Mobitel_id` int(11) DEFAULT NULL,
  `Odometr` int(11) DEFAULT '0' COMMENT 'Показания одометра',
  `CarModel` text COMMENT 'Модель',
  `setting_id` int(11) DEFAULT '1',
  `odoTime` datetime DEFAULT NULL COMMENT 'Дата и время сверки одометра',
  `driver_id` int(11) DEFAULT '-1',
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  `Category_id` int(11) DEFAULT NULL COMMENT 'Категория транспортая',
  `Category_id2` int(11) DEFAULT NULL COMMENT 'Категория2 транспорта',
  `PcbVersionId` int(11) DEFAULT '-1' COMMENT 'Версия плат датчика назначенная на машину',
  `Category_id3` int(11) DEFAULT NULL COMMENT 'Категория3 транспорта',
  `Category_id4` int(11) DEFAULT NULL COMMENT 'Категория4 транспорта',
  `FuelWayLiter` double DEFAULT '0' COMMENT 'Расход топлива л/100 км',
  `FuelMotorLiter` double DEFAULT '0' COMMENT 'Расход топлива л/моточас',
  `Identifier` int(11) DEFAULT '0' COMMENT 'Идентификатор машины',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`) USING BTREE,
  KEY `Mobitel_id` (`Mobitel_id`) USING BTREE,
  KEY `Team_id` (`Team_id`) USING BTREE,
  KEY `setting_id` (`setting_id`) USING BTREE,
  KEY `FK_vehicle_vehicle_category_Id` (`Category_id`),
  KEY `FK_vehicle_vehicle_category_Id2` (`Category_id2`),
  KEY `FK_vehicle_vehicle_category_Id3` (`Category_id3`),
  KEY `FK_vehicle_vehicle_category_Id4` (`Category_id4`),
  CONSTRAINT `FK_vehicle_vehicle_category_Id` FOREIGN KEY (`Category_id`) REFERENCES `vehicle_category` (`Id`),
  CONSTRAINT `FK_vehicle_vehicle_category_Id2` FOREIGN KEY (`Category_id2`) REFERENCES `vehicle_category2` (`Id`),
  CONSTRAINT `FK_vehicle_vehicle_category_Id3` FOREIGN KEY (`Category_id3`) REFERENCES `vehicle_category3` (`Id`),
  CONSTRAINT `FK_vehicle_vehicle_category_Id4` FOREIGN KEY (`Category_id4`) REFERENCES `vehicle_category4` (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 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,'Scania','AC5873BX',6,959590963,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(2,'Scania','АС3215CА',6,909195569,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(3,'DAF','AC4450CM',6,942879027,0,'',1,NULL,1,'',NULL,NULL,19,NULL,NULL,0,0,0),(4,'Scania','AC9646CI',6,926431026,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(5,'Scania','AC4150BT',6,959590965,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0),(6,'Scania','AC3213CA',6,959590964,0,'',1,NULL,1,'',NULL,NULL,18,NULL,NULL,0,0,0);
/*!40000 ALTER TABLE `vehicle` ENABLE KEYS */;
UNLOCK TABLES;

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

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

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

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

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

DROP TABLE IF EXISTS `vehicle_category2`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_category2` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL COMMENT 'Категория2 транспортного средства',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `vehicle_category3`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_category3` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL COMMENT 'Категория3 транспортного средства',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `vehicle_category4`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_category4` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL COMMENT 'Категория4 транспортного средства',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `vehicle_commentary`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `vehicle_commentary` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Comment` varchar(255) DEFAULT NULL,
  `Mobitel_id` int(11) NOT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Комментарий для машины';
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

LOCK TABLES `ver` WRITE;
/*!40000 ALTER TABLE `ver` DISABLE KEYS */;
INSERT INTO `ver` VALUES (1,1,'Сборка от 9.12.2008','2008-12-09 00:00:00'),(2,2,'Сборка от 10.02.2009','2009-02-10 00:00:00');
/*!40000 ALTER TABLE `ver` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `zone_category`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `zone_category` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) DEFAULT NULL COMMENT 'Категория зоны',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Категории для зон';
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `zone_category2`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `zone_category2` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) DEFAULT NULL COMMENT 'Категория2 зоны',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 COMMENT='Категории2 для зон';
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

DROP TABLE IF EXISTS `zonerelations`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `zonerelations` (
  `ZoneRelation_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Zone_ID` int(11) DEFAULT '0',
  `ConfigZoneSet_ID` int(11) DEFAULT '0',
  `In_flag` tinyint(4) NOT NULL DEFAULT '0',
  `Out_flag` tinyint(4) NOT NULL DEFAULT '0',
  `In_flag2` tinyint(4) NOT NULL DEFAULT '0',
  `Out_flag2` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`ZoneRelation_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

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

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

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

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

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

DROP TABLE IF EXISTS `zonesgroup`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `zonesgroup` (
  `Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Title` varchar(50) NOT NULL,
  `Description` varchar(200) NOT NULL,
  `OutLinkId` varchar(20) DEFAULT NULL COMMENT 'Код внешней базы',
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=cp1251;
/*!40101 SET character_set_client = @saved_cs_client */;

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

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

--
-- Dumping events for database 'zr'
--

--
-- Dumping routines for database 'zr'
--
/*!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_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `BMCTransferBuffer`(IN DatagpsIsUpdated INT, IN Datagps64IsUpdated INT)
    COMMENT 'Обновление online* для BMC'
BEGIN
	DECLARE MobitelID INT;
	DECLARE done INT DEFAULT FALSE;
	DECLARE CursorMobitels CURSOR FOR SELECT Mobitel_ID FROM datagpsbuffer_bmc WHERE `Online`=1;
	DECLARE CursorMobitels64 CURSOR FOR SELECT Mobitel_ID FROM datagpsbuffer_bmc64 WHERE `Online`=1;
	DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
    
	/* datagps */
	IF DatagpsIsUpdated THEN
		OPEN CursorMobitels;
		read_loop: LOOP
			FETCH CursorMobitels INTO MobitelID;
			IF done THEN
				LEAVE read_loop;
			END IF;
			DELETE FROM `online` WHERE Mobitel_ID=MobitelID AND UnixTime <= (SELECT COALESCE(UnixTime, 0) FROM (SELECT UnixTime FROM `online` WHERE Mobitel_ID=MobitelID ORDER BY UnixTime DESC LIMIT 100, 1) o);
		END LOOP;
		CLOSE CursorMobitels;
		UPDATE mobitels m,datagpsbuffer_bmc b SET m.LastInsertTime=b.UnixTime WHERE m.Mobitel_ID=b.Mobitel_ID AND m.LastInsertTime<b.UnixTime;
	END IF;
	/* datagps64 */
	IF Datagps64IsUpdated THEN
		OPEN CursorMobitels64;
		read_loop: LOOP
			FETCH CursorMobitels64 INTO MobitelID;
			IF done THEN
				LEAVE read_loop;
			END IF;
			DELETE FROM `online64` WHERE Mobitel_ID=MobitelID AND UnixTime <= (SELECT COALESCE(UnixTime, 0) FROM (SELECT UnixTime FROM `online64` WHERE Mobitel_ID=MobitelID ORDER BY UnixTime DESC LIMIT 100, 1) o);
		END LOOP;
		CLOSE CursorMobitels64;
		UPDATE mobitels m,datagpsbuffer_bmc64 b SET m.LastInsertTime=b.UnixTime WHERE m.Mobitel_ID=b.Mobitel_ID AND m.LastInsertTime<b.UnixTime;
	END IF;
END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `CheckOdo` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CheckOdo`(IN m_id INTEGER(11), IN end_time DATETIME)
    SQL SECURITY INVOKER
BEGIN

  SELECT 

   FROM_UNIXTIME(datagps.UnixTime) AS `time` ,

   (datagps.Latitude / 600000.00000) AS Lat,

   (datagps.Longitude / 600000.00000) AS Lon

  FROM

    datagps

  WHERE

    datagps.Mobitel_ID = m_id AND 

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

    UNIX_TIMESTAMP(end_time) AND 

    Valid = 1;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `CleaningDataGpsLostOn` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `CleaningDataGpsLostOn`()
    SQL SECURITY INVOKER
    COMMENT 'Сия процедура удаляет не корректно оформленные диапазоны пропусков из таблицы datagpslost_on'
BEGIN

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

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

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

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

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



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

    CHARACTER SET cp1251

    COLLATE cp1251_general_ci

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



  INSERT INTO MobiTemp SELECT d.Id FROM datagpslost_on d WHERE 

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

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

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



  TRUNCATE MobiTemp;



  INSERT INTO MobiTemp SELECT d.Id FROM datagpslost_on d WHERE 

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

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

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



  DROP TEMPORARY TABLE MobiTemp;



  SELECT 1;

  

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `dataview` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `dataview`(

  IN m_id INTEGER(11), 

  IN val BOOL, 

  IN begin_time DATETIME, 

  IN end_time DATETIME)
    SQL SECURITY INVOKER
BEGIN

  SELECT DataGps_ID AS DataGps_ID,

    Mobitel_ID AS Mobitel_ID,

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

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

    Altitude AS Altitude,

    FROM_UNIXTIME(UnixTime) AS `time`,

    (Speed * 1.852) AS speed,

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

    Valid AS Valid,

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

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

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

    Events AS Events,

    LogID AS LogID 

  FROM datagps 

  WHERE Mobitel_ID = m_id AND  

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

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

  ORDER BY UnixTime;

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

DROP TEMPORARY TABLE IF EXISTS tmp64;

DROP TABLE IF EXISTS tmp64;



CREATE TEMPORARY TABLE tmp64 SELECT Mobitel_ID,

  Latitude,

  Longitude,

  Direction,

  Acceleration,

  UnixTime,

  Speed,

  Valid,

  Satellites,

  RssiGsm,

  `Events`,

  SensorsSet,

  Sensors,

  Voltage,

  DGPS,

  LogID,

  SrvPacketID

FROM datagpsbuffer_on64 d

GROUP BY d.SrvPacketID;



  TRUNCATE TABLE datagpsbuffer_on64;



  INSERT INTO datagpsbuffer_on64 SELECT Mobitel_ID,

  Latitude,

  Longitude,

  Direction,

  Acceleration,

  UnixTime,

  Speed,

  Valid,

  Satellites,

  RssiGsm,

  `Events`,

  SensorsSet,

  Sensors,

  Voltage,

  DGPS,

  LogID,

  SrvPacketID

FROM tmp64 d;



DROP TEMPORARY TABLE IF EXISTS tmp64;

DROP TABLE IF EXISTS tmp64;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getDiapasone` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getDiapasone`(

  IN mobile INTEGER(11),  

  IN prevLogId int, 

  IN currLogId int)
    SQL SECURITY INVOKER
BEGIN

  SELECT DataGps_ID AS DataGps_ID,

    Mobitel_ID AS Mobitel_ID,

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

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

    Altitude AS Altitude,

    FROM_UNIXTIME(UnixTime) AS `time`,

    (Speed * 1.852) AS speed,

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

    Valid AS Valid,

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

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

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

    Events AS Events,

    LogID AS LogID, 

    SrvPacketID AS srvPack

  FROM datagps 

  WHERE Mobitel_ID = mobile AND  Valid = 1 AND  

    (LogID BETWEEN prevLogId AND currLogId) ORDER BY UnixTime;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `getDiapasone64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `getDiapasone64`(

  IN mobile INTEGER(11),  

  IN prevLogId int, 

  IN currLogId int)
    SQL SECURITY INVOKER
BEGIN

  SELECT  DataGps_ID, Mobitel_ID,

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

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

    Acceleration , 

    FROM_UNIXTIME(UnixTime) AS `time` , 

    Speed /10 AS Speed, 

    Valid,

    Sensors AS sensor, 

  `Events`, 

  LogID ,

  Voltage,

  DGPS,

  Direction,

  Satellites,

  SensorsSet,

  RssiGsm,

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

    (LogID BETWEEN prevLogId AND currLogId) ORDER BY UnixTime;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `hystoryOnline` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `hystoryOnline`(IN id INTEGER(11))
    SQL SECURITY INVOKER
BEGIN

  SELECT LogID, Mobitel_Id, 

    FROM_UNIXTIME(unixtime)  AS `time`,

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

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

    Altitude  AS Altitude,

    (Speed * 1.852) AS speed,

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

    Valid AS Valid,

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

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

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

    Events AS Events,

    DataGPS_ID  AS 'DataGPS_ID'

  FROM online

  WHERE  datagps_id > id

  ORDER BY datagps_id DESC;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnCorrectInfotrackLogId` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnCorrectInfotrackLogId`()
    SQL SECURITY INVOKER
    COMMENT 'Корректировка значений LogId и InMobitelID в данных инфотреков'
BEGIN

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

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

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

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

    

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

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

  DECLARE CursorInfoTrack CURSOR FOR

    SELECT DISTINCT buf.Mobitel_ID

    FROM datagpsbuffer_on buf 

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

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

    WHERE (c.InternalMobitelConfig_ID = (

      SELECT intConf.InternalMobitelConfig_ID

      FROM internalmobitelconfig intConf

      WHERE (intConf.ID = c.ID) 

      ORDER BY intConf.InternalMobitelConfig_ID DESC

      LIMIT 1)) AND 

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

    ORDER BY 1;

    

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

  DECLARE CursorInfoTrackUpdateSet CURSOR FOR

    SELECT SrvPacketID 

    FROM datagpsbuffer_on

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

    ORDER BY UnixTime;  



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

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  

  OPEN CursorInfoTrack;

  FETCH CursorInfoTrack INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

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

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

    FROM DataGps

    WHERE Mobitel_ID = MobitelIDInCursor;



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

    OPEN CursorInfoTrackUpdateSet;

    FETCH CursorInfoTrackUpdateSet INTO SrvPacketIDInCursor;

    WHILE DataExists = 1 DO

      SET MaxLogId = MaxLogId + 1;



      UPDATE datagpsbuffer_on

      SET LogId = MaxLogId, InMobitelID = MaxLogId

      WHERE SrvPacketID = SrvPacketIDInCursor;



      FETCH CursorInfoTrackUpdateSet INTO SrvPacketIDInCursor;

    END WHILE;

    CLOSE CursorInfoTrackUpdateSet;

 

    SET DataExists = 1;

    FETCH CursorInfoTrack INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorInfoTrack;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnCorrectInfotrackLogId64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnCorrectInfotrackLogId64`()
    SQL SECURITY INVOKER
    COMMENT 'РљРѕСЂСЂРµРєС‚РёСЂРѕРІРєР° Р·РЅР°С‡РµРЅРёР№ LogId Рё InMobitelID РІ РґР°РЅРЅС‹С… РёРЅС„РѕС‚СЂРµРєРѕРІ'
BEGIN

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

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

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

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



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

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

  DECLARE CursorInfoTrack CURSOR FOR

  SELECT DISTINCT

    buf.Mobitel_ID

  FROM datagpsbuffer_on64 buf

    JOIN mobitels m

      ON (buf.mobitel_id = m.mobitel_id)

    JOIN internalmobitelconfig c

      ON (c.ID = m.InternalMobitelConfig_ID)

  WHERE (c.InternalMobitelConfig_ID = (SELECT

      intConf.InternalMobitelConfig_ID

    FROM internalmobitelconfig intConf

    WHERE (intConf.ID = c.ID)

    ORDER BY intConf.InternalMobitelConfig_ID DESC

    LIMIT 1)) AND

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

  ORDER BY 1;



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

  DECLARE CursorInfoTrackUpdateSet CURSOR FOR

  SELECT

    SrvPacketID

  FROM datagpsbuffer_on64

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

  ORDER BY UnixTime;



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

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  OPEN CursorInfoTrack;

  FETCH CursorInfoTrack INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

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

    SELECT

      COALESCE(MAX(LogID), 0) INTO MaxLogId

    FROM DataGps

    WHERE Mobitel_ID = MobitelIDInCursor;



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

    OPEN CursorInfoTrackUpdateSet;

    FETCH CursorInfoTrackUpdateSet INTO SrvPacketIDInCursor;

    WHILE DataExists = 1 DO

      SET MaxLogId = MaxLogId + 1;



      UPDATE datagpsbuffer_on64

      SET LogId = MaxLogId,

          InMobitelID = MaxLogId

      WHERE SrvPacketID = SrvPacketIDInCursor;



      FETCH CursorInfoTrackUpdateSet INTO SrvPacketIDInCursor;

    END WHILE;

    CLOSE CursorInfoTrackUpdateSet;



    SET DataExists = 1;

    FETCH CursorInfoTrack INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorInfoTrack;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnDeleteDuplicates` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnDeleteDuplicates`()
    SQL SECURITY INVOKER
    COMMENT 'Удаление повторяющихся строк из datagpsbuffer_on'
BEGIN

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

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

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

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

   

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

  DECLARE MobitelIdInCursor INT DEFAULT 0; 

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

  DECLARE LogIdInCursor INT DEFAULT 0; 

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

  DECLARE MaxSrvPacketId BIGINT DEFAULT 0; 

  DECLARE DataExists TINYINT DEFAULT 1;



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

  DECLARE CursorDuplicateGroups CURSOR FOR

    SELECT Mobitel_Id, LogId 

    FROM datagpsbuffer_on

    GROUP BY Mobitel_Id, LogId 

    HAVING COUNT(LogId) > 1;

    

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  SET DataExists = 1;

  OPEN CursorDuplicateGroups;

  FETCH CursorDuplicateGroups INTO MobitelIdInCursor, LogIdInCursor;

  WHILE DataExists = 1 DO

    SELECT MAX(SrvPacketID) INTO MaxSrvPacketId

    FROM datagpsbuffer_on 

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

         

    DELETE FROM datagpsbuffer_on  

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

      AND (SrvPacketID < MaxSrvPacketId);

        

    FETCH CursorDuplicateGroups INTO MobitelIdInCursor, LogIdInCursor;

  END WHILE;

  CLOSE CursorDuplicateGroups; 

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnDeleteDuplicates64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnDeleteDuplicates64`()
    SQL SECURITY INVOKER
    COMMENT 'РЈРґР°Р»РµРЅРёРµ РїРѕРІС‚РѕСЂСЏСЋС‰РёС…СЃСЏ СЃС‚СЂРѕРє РёР· datagpsbuffer_on64'
BEGIN

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

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

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

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



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

  DECLARE MobitelIdInCursor int DEFAULT 0;

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

  DECLARE LogIdInCursor int DEFAULT 0;

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

  DECLARE MaxSrvPacketId bigint DEFAULT 0;

  DECLARE DataExists tinyint DEFAULT 1;



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

  DECLARE CursorDuplicateGroups CURSOR FOR

  SELECT

    Mobitel_Id,

    LogId

  FROM datagpsbuffer_on64

  GROUP BY Mobitel_Id,

           LogId

  HAVING COUNT(LogId) > 1;



  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  SET DataExists = 1;

  OPEN CursorDuplicateGroups;

  FETCH CursorDuplicateGroups INTO MobitelIdInCursor, LogIdInCursor;

  WHILE DataExists = 1 DO

    SELECT

      MAX(SrvPacketID) INTO MaxSrvPacketId

    FROM datagpsbuffer_on64

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



    DELETE

      FROM datagpsbuffer_on64

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

      AND (SrvPacketID < MaxSrvPacketId);



    FETCH CursorDuplicateGroups INTO MobitelIdInCursor, LogIdInCursor;

  END WHILE;

  CLOSE CursorDuplicateGroups;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnDeleteLostRange` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnDeleteLostRange`(IN MobitelID INTEGER(11), IN BeginSrvPacketID BIGINT)
    SQL SECURITY INVOKER
    COMMENT 'Удаление указанного диапазона пропусков из datagpslost_on.'
BEGIN

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

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

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

     

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

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



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

  SELECT MIN(Begin_SrvPacketID) INTO MinBeginSrvPacketID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;

  

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

  IF MinBeginSrvPacketID IS NOT NULL THEN

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

    IF MinBeginSrvPacketID = BeginSrvPacketID  THEN

      SELECT End_LogID INTO NewConfirmedID

      FROM datagpslost_on

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

    END IF;

  

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

    DELETE FROM  datagpslost_on

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

    

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

    IF MinBeginSrvPacketID = BeginSrvPacketID  THEN

      UPDATE mobitels

      SET ConfirmedID = NewConfirmedID

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

    END IF;

  END IF;  

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnInsertDatagpsLost` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnInsertDatagpsLost`(

  IN MobitelID INT, 

  IN BeginLogID INT, 

  IN EndLogID INT,

  IN BeginSrvPacketID BIGINT, 

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

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

     в таблице datagpslost_on */

  DECLARE MobitelId_BeginLogID_Exists TINYINT DEFAULT 0; 

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

     в таблице datagpslost_on  */

  DECLARE MobitelId_BeginSrvPacketID_Exists TINYINT DEFAULT 0;

  

  DECLARE RowBeginSrvPacketID BIGINT; 

  

  IF EXISTS(

    SELECT NULL

    FROM datagpslost_on

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

  THEN

    SET MobitelId_BeginLogID_Exists = 1;

  END IF;



  IF EXISTS(

    SELECT NULL

    FROM datagpslost_on

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

  THEN

    SET MobitelId_BeginSrvPacketID_Exists = 1;

  END IF;



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

  THEN

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

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

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

  ELSE

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

    THEN

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

      UPDATE datagpslost_on

      SET End_LogID = EndLogID, End_SrvPacketID = EndSrvPacketID

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

    ELSE

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

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

      SELECT Begin_SrvPacketID

      INTO RowBeginSrvPacketID

      FROM datagpslost_on

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

      LIMIT 1;

      

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

        (BeginSrvPacketID < RowBeginSrvPacketID))

      THEN

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

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

        UPDATE datagpslost_on

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

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

      END IF;

    END IF;

  END IF;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `online` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `online`()
    SQL SECURITY INVOKER
BEGIN

  SELECT Log_ID, MobitelId, 

    (SELECT DataGPS_ID

    FROM `online` 

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

      (SELECT from_unixtime(unixtime) 

      FROM `online` 

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

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

        FROM `online` 

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

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

          FROM `online` 

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

            (SELECT `Altitude` 

            FROM `online` 

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

              (SELECT (`Speed` * 1.852)

              FROM `online` 

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

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

                FROM `online` 

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

                  (SELECT `Valid`

                  FROM `online` 

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

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

                    (`Sensor7` << 8)) + 

                    (`Sensor6` << 16)) + 

                    (`Sensor5` << 24)) + 

                    (`Sensor4` << 32)) + 

                    (`Sensor3` << 40)) + 

                    (`Sensor2` << 48)) + 

                    (`Sensor1` << 56)) 

                    FROM `online` 

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

                      (SELECT `Events`

                      FROM `online` 

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

   

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

        FROM `online` 

        GROUP BY `Mobitel_ID`) T1;

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnListMobitelConfig` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnListMobitelConfig`()
    SQL SECURITY INVOKER
    COMMENT 'Выборка настроек телетреков которые могут работать в online режиме'
BEGIN

  DECLARE MobitelIDInCursor INT;

  DECLARE DevIdShortInCursor CHAR(4);

  DECLARE DataExists TINYINT DEFAULT 1;



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

  DECLARE CursorMobitels CURSOR FOR

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

    FROM mobitels m

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

    WHERE (c.InternalMobitelConfig_ID = (

      SELECT intConf.InternalMobitelConfig_ID

      FROM internalmobitelconfig intConf

      WHERE (intConf.ID = c.ID)

      ORDER BY intConf.InternalMobitelConfig_ID DESC

      LIMIT 1)) AND

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

    ORDER BY m.Mobitel_ID;



  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



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

  CREATE TEMPORARY TABLE tmpMobitelsConfig (

    MobitelID INT NOT NULL,

    DevIdShort CHAR(4) NOT NULL,

    LastPacketID BIGINT NOT NULL) ENGINE = MEMORY;



  OPEN CursorMobitels;

  FETCH CursorMobitels INTO MobitelIDInCursor, DevIdShortInCursor;

  WHILE DataExists = 1 DO



    INSERT INTO tmpMobitelsConfig SELECT MobitelIDInCursor, DevIdShortInCursor,

      (SELECT COALESCE(MAX(SrvPacketID), 0)

       FROM datagps

       WHERE Mobitel_ID = MobitelIDInCursor) AS LastPacketID;



    FETCH CursorMobitels INTO MobitelIDInCursor, DevIdShortInCursor;

  END WHILE;

  CLOSE CursorMobitels;



  SELECT MobitelID, DevIdShort, LastPacketID

  FROM tmpMobitelsConfig;



  DROP TEMPORARY TABLE tmpMobitelsConfig;  

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnListMobitelConfig64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnListMobitelConfig64`()
    SQL SECURITY INVOKER
    COMMENT 'Выборка настроек телетреков которые могут работать в online режиме для datagps и datagps64'
BEGIN

  DECLARE MobitelIDInCursor INT;

  DECLARE Is64Cursor tinyint;

  DECLARE DevIdShortInCursor CHAR(4);

  DECLARE DataExists TINYINT DEFAULT 1;



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

  DECLARE CursorMobitels CURSOR FOR

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

    FROM mobitels m

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

    WHERE (c.InternalMobitelConfig_ID = (

      SELECT intConf.InternalMobitelConfig_ID

      FROM internalmobitelconfig intConf

      WHERE (intConf.ID = c.ID)

      ORDER BY intConf.InternalMobitelConfig_ID DESC

      LIMIT 1)) AND

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

    ORDER BY m.Mobitel_ID;



  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



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

  CREATE TEMPORARY TABLE tmpMobitelsConfig (

    MobitelID INT NOT NULL,

    Is64 tinyint NOT NULL,

    DevIdShort CHAR(4) NOT NULL,

    LastPacketID BIGINT NOT NULL,

    LastPacketID64 BIGINT NOT NULL) ENGINE = MEMORY;



  OPEN CursorMobitels;

  FETCH CursorMobitels INTO MobitelIDInCursor, Is64Cursor, DevIdShortInCursor;

  WHILE DataExists = 1 DO



    INSERT INTO tmpMobitelsConfig SELECT MobitelIDInCursor, Is64Cursor, DevIdShortInCursor,

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

       FROM datagps d

       WHERE d.Mobitel_ID = MobitelIDInCursor) AS LastPacketID,

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

       FROM datagps64 t

       WHERE t.Mobitel_ID = MobitelIDInCursor) AS LastPacketID64;



    FETCH CursorMobitels INTO MobitelIDInCursor, Is64Cursor, DevIdShortInCursor;

  END WHILE;

  CLOSE CursorMobitels;



  SELECT MobitelID, Is64, DevIdShort, LastPacketID, LastPacketID64

  FROM tmpMobitelsConfig;



  DROP TEMPORARY TABLE tmpMobitelsConfig;

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



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

  

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

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

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

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

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

  

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

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

  

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

    

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

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

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

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

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

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

  

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

  

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

  DECLARE CursorNewLogID CURSOR FOR

    SELECT LogID, SrvPacketID 

    FROM datagpslost_ontmp;

    

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

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  

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



  SET NeedOptimize = 0;

 

  SELECT COALESCE(ConfirmedID, 0) INTO CurrentConfirmedID

  FROM mobitels

  WHERE Mobitel_ID = MobitelID;



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

  SELECT MIN(LogID) INTO MinLogID_n

  FROM datagpsbuffer_on

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

  

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

  SELECT MAX(LogID) INTO MaxLogID_n

  FROM datagpsbuffer_on 

  WHERE Mobitel_ID = MobitelID;  

  

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

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

  FROM datagpslost_on 

  WHERE Mobitel_ID = MobitelID;  

  

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

  IF MinLogID_n IS NOT NULL THEN

  

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

    

    TRUNCATE TABLE datagpslost_ontmp;

  

    IF MinLogID_n < MaxEndLogID THEN

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

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

       

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

      SELECT COALESCE(Begin_LogID, MinLogID_n) INTO StartLogIDSelect

      FROM datagpslost_on

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

        AND (MinLogID_n < End_LogID);

      

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

      SELECT COALESCE(End_LogID, MaxLogID_n) INTO FinishLogIDSelect

      FROM datagpslost_on

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

        AND (MaxLogID_n < End_LogID);

       

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

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

      DELETE FROM datagpslost_on

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

        AND (Begin_LogID <= FinishLogIDSelect);

      

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

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

      IF (StartLogIDSelect = 0) AND (NOT EXISTS

        (Select 1 

         FROM datagps 

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

      

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

      END IF;       

    ELSE

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

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

      

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

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

      FROM datagpslost_on

      WHERE Mobitel_ID = MobitelID;   

         

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

      SELECT MAX(LogID)  INTO FinishLogIDSelect

      FROM datagpsbuffer_on

      WHERE Mobitel_ID = MobitelID;

      

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

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

      SELECT COALESCE(SrvPacketID, 0) INTO tmpSrvPacketID

      FROM datagps

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

      

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

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

      INSERT INTO datagpslost_ontmp(LogID, SrvPacketID)

      VALUES (StartLogIDSelect, tmpSrvPacketID);

    END IF; -- IF MinLogID_n < MaxEndLogID   

    

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

    

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

    

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

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

    INSERT INTO datagpslost_ontmp  (LogID, SrvPacketID)

      SELECT LogID, SrvPacketID

      FROM datagps

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

        AND (LogID <= FinishLogIDSelect)

      ORDER BY LogID;

            

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

    SET DataExists = 1;

    OPEN CursorNewLogID;

    FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

    WHILE DataExists = 1 DO

      IF FirstLogID = -9999999 THEN

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

        SET FirstLogID = NewLogID;

        SET FirstSrvPacketID = NewSrvPacketID;

      ELSE

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

        SET SecondLogID = NewLogID;

        SET SecondSrvPacketID = NewSrvPacketID;

        

        IF (SecondLogID - FirstLogID) > 1 THEN

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

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

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

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

          IF (SecondSrvPacketID > FirstSrvPacketID) THEN

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

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



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

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

                

              END IF;

            END IF;

          END IF;

        END IF;

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

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

        SET  FirstLogID = SecondLogID;

        SET FirstSrvPacketID = SecondSrvPacketID;

      END IF;  

      FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

    END WHILE;

    CLOSE CursorNewLogID;

 

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

               

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

    

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

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

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

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

    SELECT MIN(Begin_LogID) INTO NewConfirmedID

    FROM datagpslost_on

    WHERE Mobitel_ID = MobitelID;

       

    IF NewConfirmedID IS NULL THEN

      SELECT MAX(LogID) INTO NewConfirmedID

      FROM datagps

      WHERE Mobitel_ID = MobitelID;

    END IF;  

    

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

    UPDATE mobitels

    SET ConfirmedID = NewConfirmedID

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

    

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

        

    TRUNCATE TABLE datagpslost_ontmp;

  END IF; -- IF MaxEndLogID IS NOT NULL  

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

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

    

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

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

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

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

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

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

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

    

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

  DECLARE CursorLostRanges CURSOR FOR

    SELECT Begin_LogID, End_LogID, Begin_SrvPacketID, End_SrvPacketID 

    FROM datagpslost_on

    WHERE Mobitel_ID = MobitelID;    



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

  DECLARE CursorNewLogID CURSOR FOR

    SELECT LogID, SrvPacketID 

    FROM datagpslost_ontmp

    ORDER BY SrvPacketID;    

    

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

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  

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



  SET NeedOptimize = 0;

  

  TRUNCATE TABLE datagpslost_ontmp;

  

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

  SET DataExists = 1;

  OPEN CursorLostRanges;

  FETCH CursorLostRanges INTO BeginLogID, EndLogID, BeginSrvPacketID, EndSrvPacketID;

  WHILE DataExists = 1 DO

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

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

    INSERT INTO datagpslost_ontmp  (LogID, SrvPacketID)

      SELECT DISTINCT LogID, SrvPacketID

      FROM datagpsbuffer_ontmp

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

        AND (SrvPacketID < EndSrvPacketID)

      ORDER BY SrvPacketID;

      

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

    SELECT COUNT(1) INTO RowCountForAnalyze

    FROM datagpslost_ontmp;  

    

    IF RowCountForAnalyze > 0 THEN  

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

      INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

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

      

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

      DELETE FROM datagpslost_on

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

       

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

      BEGIN

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

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

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

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

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

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

        

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

        DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

        

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

        SET DataExists = 1;

        OPEN CursorNewLogID;

        FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

        WHILE DataExists = 1 DO

          IF FirstLogID = -9999999 THEN

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

            SET FirstLogID = NewLogID;

            SET FirstSrvPacketID = NewSrvPacketID;

          ELSE

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

            SET SecondLogID = NewLogID;

            SET SecondSrvPacketID = NewSrvPacketID;

            

            IF (SecondLogID - FirstLogID) > 1 THEN

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

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

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

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

          IF (SecondSrvPacketID > FirstSrvPacketID) THEN

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

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



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

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

                

              END IF;

            END IF;

          END IF;

        END IF;

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

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

            SET FirstLogID = SecondLogID;

            SET FirstSrvPacketID = SecondSrvPacketID;

          END IF;  

          FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

        END WHILE;

        CLOSE CursorNewLogID;

      END;

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



      TRUNCATE TABLE datagpslost_ontmp;

    END IF;

      

    FETCH CursorLostRanges INTO BeginLogID, EndLogID, BeginSrvPacketID, EndSrvPacketID;

  END WHILE;

  CLOSE CursorLostRanges;

  

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

    

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

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

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

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

  SELECT MIN(Begin_LogID) INTO NewConfirmedID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;

       

  IF NewConfirmedID IS NULL THEN

    SELECT MAX(LogID) INTO NewConfirmedID

    FROM datagps

    WHERE Mobitel_ID = MobitelID;

  END IF;  

    

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

  UPDATE mobitels

  SET ConfirmedID = NewConfirmedID

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

    

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

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

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



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

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

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

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

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

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

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



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

  DECLARE CursorLostRanges CURSOR FOR

  SELECT

    Begin_LogID,

    End_LogID,

    Begin_SrvPacketID,

    End_SrvPacketID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;



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

  DECLARE CursorNewLogID CURSOR FOR

  SELECT

    LogID,

    SrvPacketID

  FROM datagpslost_ontmp

  ORDER BY SrvPacketID;



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

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



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



  SET NeedOptimize = 0;



  TRUNCATE TABLE datagpslost_ontmp;



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

  SET DataExists = 1;

  OPEN CursorLostRanges;

  FETCH CursorLostRanges INTO BeginLogID, EndLogID, BeginSrvPacketID, EndSrvPacketID;

  WHILE DataExists = 1 DO

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

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

    INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

      SELECT DISTINCT

        LogID,

        SrvPacketID

      FROM datagpsbuffer_ontmp64

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

      AND (SrvPacketID < EndSrvPacketID)

      ORDER BY SrvPacketID;



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

    SELECT

      COUNT(1) INTO RowCountForAnalyze

    FROM datagpslost_ontmp;



    IF RowCountForAnalyze > 0 THEN

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

      INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

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



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

      DELETE

        FROM datagpslost_on

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



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

      BEGIN

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

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

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

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

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

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



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

        DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



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

        SET DataExists = 1;

        OPEN CursorNewLogID;

        FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

        WHILE DataExists = 1 DO

          IF FirstLogID = -9999999 THEN

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

            SET FirstLogID = NewLogID;

            SET FirstSrvPacketID = NewSrvPacketID;

          ELSE

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

            SET SecondLogID = NewLogID;

            SET SecondSrvPacketID = NewSrvPacketID;



            IF (SecondLogID - FirstLogID) > 1 THEN

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

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

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

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

          IF (SecondSrvPacketID > FirstSrvPacketID) THEN

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

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



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

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

                

              END IF;

            END IF;

          END IF;

        END IF;

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

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

            SET FirstLogID = SecondLogID;

            SET FirstSrvPacketID = SecondSrvPacketID;

          END IF;

          FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

        END WHILE;

        CLOSE CursorNewLogID;

      END;

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



      TRUNCATE TABLE datagpslost_ontmp;

    END IF;



    FETCH CursorLostRanges INTO BeginLogID, EndLogID, BeginSrvPacketID, EndSrvPacketID;

  END WHILE;

  CLOSE CursorLostRanges;



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



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

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

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

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

  SELECT

    MIN(Begin_LogID) INTO NewConfirmedID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;



  IF NewConfirmedID IS NULL THEN

    SELECT

      MAX(LogID) INTO NewConfirmedID

    FROM datagps64

    WHERE Mobitel_ID = MobitelID;

  END IF;



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

  UPDATE mobitels

  SET ConfirmedID = NewConfirmedID

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



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

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



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



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

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

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

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

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



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

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



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



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

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

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

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

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

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



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



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

  DECLARE CursorNewLogID CURSOR FOR

  SELECT

    LogID,

    SrvPacketID

  FROM datagpslost_ontmp;



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

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



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



  SET NeedOptimize = 0;



  SELECT

    COALESCE(ConfirmedID, 0) INTO CurrentConfirmedID

  FROM mobitels

  WHERE Mobitel_ID = MobitelID;



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

  SELECT

    MIN(LogID) INTO MinLogID_n

  FROM datagpsbuffer_on64

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



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

  SELECT

    MAX(LogID) INTO MaxLogID_n

  FROM datagpsbuffer_on64

  WHERE Mobitel_ID = MobitelID;



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

  SELECT

    COALESCE(MAX(End_LogID), 0) INTO MaxEndLogID

  FROM datagpslost_on

  WHERE Mobitel_ID = MobitelID;



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

  IF MinLogID_n IS NOT NULL THEN



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



    TRUNCATE TABLE datagpslost_ontmp;



    IF MinLogID_n < MaxEndLogID THEN

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

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



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

      SELECT

        COALESCE(Begin_LogID, MinLogID_n) INTO StartLogIDSelect

      FROM datagpslost_on

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

      AND (MinLogID_n < End_LogID);



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

      SELECT

        COALESCE(End_LogID, MaxLogID_n) INTO FinishLogIDSelect

      FROM datagpslost_on

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

      AND (MaxLogID_n < End_LogID);



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

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

      DELETE

        FROM datagpslost_on

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

        AND (Begin_LogID <= FinishLogIDSelect);



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

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

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

            1

          FROM datagps64

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



        INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

          VALUES (0, 0);

      END IF;

    ELSE

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

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



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

      SELECT

        COALESCE(MAX(End_LogID), CurrentConfirmedID) INTO StartLogIDSelect

      FROM datagpslost_on

      WHERE Mobitel_ID = MobitelID;



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

      SELECT

        MAX(LogID) INTO FinishLogIDSelect

      FROM datagpsbuffer_on64

      WHERE Mobitel_ID = MobitelID;



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

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

      SELECT

        COALESCE(SrvPacketID, 0) INTO tmpSrvPacketID

      FROM datagps64

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



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

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

      INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

        VALUES (StartLogIDSelect, tmpSrvPacketID);

    END IF; -- IF MinLogID_n < MaxEndLogID   



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



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



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

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

    INSERT INTO datagpslost_ontmp (LogID, SrvPacketID)

      SELECT

        LogID,

        SrvPacketID

      FROM datagps64

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

      AND (LogID <= FinishLogIDSelect)

      ORDER BY LogID;



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

    SET DataExists = 1;

    OPEN CursorNewLogID;

    FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

    WHILE DataExists = 1 DO

      IF FirstLogID = -9999999 THEN

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

        SET FirstLogID = NewLogID;

        SET FirstSrvPacketID = NewSrvPacketID;

      ELSE

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

        SET SecondLogID = NewLogID;

        SET SecondSrvPacketID = NewSrvPacketID;



        IF (SecondLogID - FirstLogID) > 1 THEN

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

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

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

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

          IF (SecondSrvPacketID > FirstSrvPacketID) THEN

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

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



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

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

                

              END IF;

            END IF;

          END IF;

        END IF;

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

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

        SET FirstLogID = SecondLogID;

        SET FirstSrvPacketID = SecondSrvPacketID;

      END IF;

      FETCH CursorNewLogID INTO NewLogID, NewSrvPacketID;

    END WHILE;

    CLOSE CursorNewLogID;



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



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



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

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

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

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

    SELECT

      MIN(Begin_LogID) INTO NewConfirmedID

    FROM datagpslost_on

    WHERE Mobitel_ID = MobitelID;



    IF NewConfirmedID IS NULL THEN

      SELECT

        MAX(LogID) INTO NewConfirmedID

      FROM datagps64

      WHERE Mobitel_ID = MobitelID;

    END IF;



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

    UPDATE mobitels

    SET ConfirmedID = NewConfirmedID

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



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



    TRUNCATE TABLE datagpslost_ontmp;

  END IF; -- IF MaxEndLogID IS NOT NULL  

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

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

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

  DECLARE NeedOptimize TINYINT DEFAULT 0; /* Нужна оптимизация или нет */

  DECLARE NeedOptimizeParam TINYINT;

  

  DECLARE TmpMaxUnixTime INT; /* Временная переменная для хранения Max UnixTime из таблицы online */



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

  DECLARE CursorMobitelsInsertSet CURSOR FOR

    SELECT DISTINCT(Mobitel_ID) FROM datagpsbuffer_on;

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

  DECLARE CursorMobitelsUpdateSet CURSOR FOR

    SELECT DISTINCT(Mobitel_ID) FROM datagpsbuffer_ontmp;  



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

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;



  CALL OnDeleteDuplicates();

  CALL OnCorrectInfotrackLogId();

  

  /* Сохраняем записи, которые уже есть в БД, для второго этапа анализа пропусков 

     Используется процедурой OnLostDataGPS2. */

  INSERT INTO datagpsbuffer_ontmp (Mobitel_ID, LogID, SrvPacketID)

    SELECT b.Mobitel_ID, b.LogID, b.SrvPacketID

    FROM datagpsbuffer_on b LEFT JOIN datagps d ON

      (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

    WHERE d.LogID IS NOT NULL;

       

  /* -------------------- Заполнение таблицы Online ---------------------- */  

  /* Удаление из таблицы online дублирующих строк таблицы datagpsbuffer_on */

  /* по полям Mobitel_ID и LogID */

  DELETE o

  FROM `online` o, datagpsbuffer_on dgb

  WHERE (o.Mobitel_ID = dgb.Mobitel_ID) AND (o.LogID = dgb.LogID);

  

  SET DataExists = 1;

  OPEN CursorMobitelsInsertSet;

  FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* Нахождение Max значения UnixTime в таблице online для заданного

       телетрека. p.s. UnixTime в таблице online только валидный */

    SELECT COALESCE(MAX(UnixTime), 0) INTO TmpMaxUnixTime

    FROM online FORCE INDEX (IDX_Mobitelid)

    WHERE Mobitel_ID = MobitelIDInCursor;



    /* Вставка новых записей (максимум 100)каждого телетрека в online */

    INSERT INTO `online` (

      Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Altitude,

      Direction, Speed, Valid, `Events`,

      Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6, Sensor7, Sensor8,

      Counter1, Counter2, Counter3, Counter4, whatIs)

    SELECT

      Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Altitude,

      Direction, Speed, Valid, `Events`,

      Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6, Sensor7, Sensor8,

      Counter1, Counter2, Counter3, Counter4, whatIs

    FROM (

      SELECT *

      FROM datagpsbuffer_on

      WHERE (Mobitel_ID = MobitelIDInCursor)  AND 

        (UnixTime > TmpMaxUnixTime) AND (Valid = 1)

      GROUP BY Mobitel_ID, LogID

      ORDER BY UnixTime DESC

      LIMIT 100) AS T

    ORDER BY UnixTime ASC;



    /* Удаление строк из таблицы оперативных данных не удовлетворяющие

       условиям хранения - не являются последними 100 строками */

    DELETE FROM `online`

    WHERE (Mobitel_ID = MobitelIDInCursor) AND (UnixTime < 

      (SELECT COALESCE(MIN(UnixTime), 0) 

       FROM (

         SELECT UnixTime

         FROM `online`

         WHERE Mobitel_ID = MobitelIDInCursor 

         ORDER BY UnixTime DESC

         LIMIT 100) T1)); 

  

    FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsInsertSet;

  /* ---------------- Online ---------------- */ 

  

  /* Зачем-то нужен апдейт ... */

  UPDATE datagps d, datagpsbuffer_on b SET

    d.Latitude = b.Latitude,

    d.Longitude = b.Longitude,

    d.Altitude = b.Altitude,

    d.UnixTime = b.UnixTime,

    d.Speed = b.Speed,

    d.Direction = b.Direction,

    d.Valid = b.Valid,

    d.InMobitelID = b.LogID,

    d.Events = b.Events,

    d.Sensor1 = b.Sensor1,

    d.Sensor2 = b.Sensor2,

    d.Sensor3 = b.Sensor3,

    d.Sensor4 = b.Sensor4,

    d.Sensor5 = b.Sensor5,

    d.Sensor6 = b.Sensor6,

    d.Sensor7 = b.Sensor7,

    d.Sensor8 = b.Sensor8,

    d.whatIs = b.whatIs,

    d.Counter1 = b.Counter1,

    d.Counter2 = b.Counter2,

    d.Counter3 = b.Counter3,

    d.Counter4 = b.Counter4,

    d.SrvPacketID = b.SrvPacketID

  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

    AND (d.SrvPacketID < b.SrvPacketID);



  /* Удалим записи которые участвовали в апдейте */

  DELETE b

  FROM datagps d, datagpsbuffer_on b

  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID);



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

  INSERT INTO datagps (

    Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Altitude,

    Direction, Speed, Valid, `Events`, InMobitelID,

    Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6, Sensor7, Sensor8,

    Counter1, Counter2, Counter3, Counter4, whatIs, SrvPacketID)

  SELECT

    Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Altitude,

    Direction, Speed, Valid, `Events`, LogID,

    Sensor1, Sensor2, Sensor3, Sensor4, Sensor5, Sensor6, Sensor7, Sensor8,

    Counter1, Counter2, Counter3, Counter4, whatIs, SrvPacketID

  FROM datagpsbuffer_on

  GROUP BY Mobitel_ID, LogID;



  /* ------------------- FETCH Mobitels (INSERT SET) ----------------------- */

  SET DataExists = 1;

  OPEN CursorMobitelsInsertSet;

  FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* ------ Обновление времени последней вставки записей ------- */

    UPDATE mobitels SET LastInsertTime = UNIX_TIMESTAMP(NOW())

    WHERE Mobitel_ID = MobitelIDInCursor;

       

    /* ------ Обновление списка пропущенных записей -------------- */

    CALL OnLostDataGPS(MobitelIDInCursor, NeedOptimizeParam);

    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);

    FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsInsertSet;



  /* Очистка буфера */

  TRUNCATE TABLE datagpsbuffer_on;

    

  /* ------------------- FETCH Mobitels (UPDATE SET) ---------------------- */

  SET DataExists = 1;

  OPEN CursorMobitelsUpdateSet;

  FETCH CursorMobitelsUpdateSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* ---- Обновление списка пропущенных записей по второму алгоритму --- */

    CALL OnLostDataGPS2(MobitelIDInCursor, NeedOptimizeParam);

    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);

    FETCH CursorMobitelsUpdateSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsUpdateSet;

  

  /* Очистка вспомогательного буфера */

  TRUNCATE TABLE datagpsbuffer_ontmp;



  /* Были изменения - сделаем оптимизацию */

  /*IF NeedOptimize = 1 THEN

    OPTIMIZE TABLE datagpslost_on;

  END IF; */           

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `OnTransferBuffer64` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `OnTransferBuffer64`()
    SQL SECURITY INVOKER
BEGIN

  DECLARE MobitelIDInCursor int; /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ MobitelID */

  DECLARE DataExists tinyint DEFAULT 1; /* пїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ */

  DECLARE NeedOptimize tinyint DEFAULT 0; /* пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅ */

  DECLARE NeedOptimizeParam tinyint;



  DECLARE TmpMaxUnixTime int; /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ Max UnixTime пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ online */



  /* пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  DECLARE CursorMobitelsInsertSet CURSOR FOR

  SELECT DISTINCT

    (Mobitel_ID)

  FROM datagpsbuffer_on64;

  /* пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  DECLARE CursorMobitelsUpdateSet CURSOR FOR

  SELECT DISTINCT

    (Mobitel_ID)

  FROM datagpsbuffer_ontmp64;



  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ FETCH пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET DataExists = 0;

  /*DECLARE EXIT HANDLER FOR SQLEXCEPTION 

  BEGIN

    ROLLBACK;

    SELECT 'An error has occurred, operation rollbacked and the stored procedure was terminated';

  end;*/



  CALL delDupSrvPacket();

  CALL OnDeleteDuplicates64();

  /*CALL OnCorrectInfotrackLogId64();*/



  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ, пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅ пїЅпїЅпїЅпїЅ пїЅ пїЅпїЅ, пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ 

     пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ OnLostDataGPS264. */

  /*INSERT INTO datagpsbuffer_ontmp64 (Mobitel_ID, LogID, SrvPacketID)

    SELECT

      b.Mobitel_ID,

      b.LogID,

      b.SrvPacketID

    FROM datagpsbuffer_on64 b

      LEFT JOIN datagps64 d

        ON (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

    WHERE d.LogID IS NOT NULL GROUP BY d.SrvPacketID;*/

 DROP TEMPORARY TABLE IF EXISTS temp1;

  DROP TABLE IF EXISTS temp1;

  CREATE TEMPORARY TABLE temp1  SELECT

      b.Mobitel_ID,

      b.LogID,

      b.SrvPacketID

    FROM datagpsbuffer_on64 b

      LEFT JOIN datagps64 d

        ON (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

    WHERE d.LogID IS NOT NULL GROUP BY d.SrvPacketID;



INSERT INTO datagpsbuffer_ontmp64 (Mobitel_ID, LogID, SrvPacketID) SELECT * FROM temp1 GROUP BY SrvPacketID;



DROP TEMPORARY TABLE IF EXISTS temp1;

DROP TABLE IF EXISTS temp1;

  /* -------------------- пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ Online ---------------------- */

  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ online пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ datagpsbuffer_on64 */

  /* пїЅпїЅ пїЅпїЅпїЅпїЅпїЅ Mobitel_ID пїЅ LogID */

  DELETE o

    FROM online64 o, datagpsbuffer_on64 dgb

  WHERE (o.Mobitel_ID = dgb.Mobitel_ID) AND (o.LogID = dgb.LogID);



  SET DataExists = 1;

  OPEN CursorMobitelsInsertSet;

  FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ Max пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ UnixTime пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ online пїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ

       пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ. p.s. UnixTime пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ online пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ */

    SELECT

      COALESCE(MAX(UnixTime), 0) INTO TmpMaxUnixTime

    FROM online64 FORCE INDEX (IDX_Mobitelid64)

    WHERE Mobitel_ID = MobitelIDInCursor;



    /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ (пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ 100)пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅ online */

    INSERT INTO online64 (Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Acceleration,

    Direction, Speed, Valid, `Events`,

    Satellites, RssiGsm, SensorsSet, Sensors, Voltage, DGPS)

      SELECT

        Mobitel_ID,

        LogID,

        UnixTime,

        Latitude,

        Longitude,

        Acceleration,

        Direction,

        Speed,

        Valid,

        `Events`,

        Satellites,

        RssiGsm,

        SensorsSet,

        Sensors,

        Voltage,

        DGPS

      FROM (SELECT

          *

        FROM datagpsbuffer_on64

        WHERE (Mobitel_ID = MobitelIDInCursor) AND

        (UnixTime > TmpMaxUnixTime) AND (Valid = 1)

        GROUP BY Mobitel_ID,

                 LogID

        ORDER BY UnixTime DESC

        LIMIT 100) AS T

      ORDER BY UnixTime ASC;



    /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ

       пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ - пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ 100 пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ */

    DELETE

      FROM online64

    WHERE (Mobitel_ID = MobitelIDInCursor) AND (UnixTime < (SELECT

          COALESCE(MIN(UnixTime), 0)

        FROM (SELECT

            UnixTime

          FROM online64

          WHERE Mobitel_ID = MobitelIDInCursor

          ORDER BY UnixTime DESC

          LIMIT 100) T1));



    FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsInsertSet;

  /* ---------------- Online ---------------- */

  /* пїЅпїЅпїЅпїЅпїЅ-пїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ ... */

  UPDATE datagps64 d, datagpsbuffer_on64 b

  SET d.Latitude = b.Latitude,

      d.Longitude = b.Longitude,

      d.Acceleration = b.Acceleration,

      d.UnixTime = b.UnixTime,

      d.Speed = b.Speed,

      d.Direction = b.Direction,

      d.Valid = b.Valid,

      d.LogID = b.LogID,

      d.`Events` = b.`Events`,

      d.Satellites = b.Satellites,

      d.RssiGsm = b.RssiGsm,

      d.SensorsSet = b.SensorsSet,

      d.Sensors = b.Sensors,

      d.Voltage = b.Voltage,

      d.DGPS = b.DGPS,

      d.SrvPacketID = b.SrvPacketID

  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID)

  AND (d.SrvPacketID < b.SrvPacketID);



  /* пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ */

  DELETE b

    FROM datagps64 d, datagpsbuffer_on64 b

  WHERE (d.Mobitel_ID = b.Mobitel_ID) AND (d.LogID = b.LogID);



    /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ */ 

  INSERT INTO datagps64 (Mobitel_ID, LogID, UnixTime, Latitude, Longitude, Acceleration,

  Direction, Speed, Valid, `Events`,

  Satellites, RssiGsm, SensorsSet, Sensors, Voltage, DGPS, SrvPacketID)

    SELECT

      Mobitel_ID,

      LogID,

      UnixTime,

      Latitude,

      Longitude,

      Acceleration,

      Direction,

      Speed,

      Valid,

      `Events`,

      Satellites,

      RssiGsm,

      SensorsSet,

      Sensors,

      Voltage,

      DGPS,

      SrvPacketID

    FROM datagpsbuffer_on64

    GROUP BY Mobitel_ID,

             LogID;



  /* ------------------- FETCH Mobitels (INSERT SET) ----------------------- */

  SET DataExists = 1;

  OPEN CursorMobitelsInsertSet;

  FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* ------ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ ------- */

    UPDATE mobitels

    SET LastInsertTime = UNIX_TIMESTAMP(NOW())

    WHERE Mobitel_ID = MobitelIDInCursor;



    /* ------ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ -------------- */

    CALL OnLostDataGPS64(MobitelIDInCursor, NeedOptimizeParam);

    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);

    FETCH CursorMobitelsInsertSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsInsertSet;



  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  TRUNCATE TABLE datagpsbuffer_on64;



  /* ------------------- FETCH Mobitels (UPDATE SET) ---------------------- */

  SET DataExists = 1;

  OPEN CursorMobitelsUpdateSet;

  FETCH CursorMobitelsUpdateSet INTO MobitelIDInCursor;

  WHILE DataExists = 1 DO

    /* ---- пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ --- */

    CALL OnLostDataGPS264(MobitelIDInCursor, NeedOptimizeParam);

    SET NeedOptimize = GREATEST(NeedOptimize, NeedOptimizeParam);

    FETCH CursorMobitelsUpdateSet INTO MobitelIDInCursor;

  END WHILE;

  CLOSE CursorMobitelsUpdateSet;



  /* пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅ */

  TRUNCATE TABLE datagpsbuffer_ontmp64;



  /* пїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ - пїЅпїЅпїЅпїЅпїЅпїЅпїЅ пїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅпїЅ */

  /*IF NeedOptimize = 1 THEN

    OPTIMIZE TABLE datagpslost_on;

  END IF;*/

END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!50003 DROP PROCEDURE IF EXISTS `SelectDataGpsPeriodAll` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `SelectDataGpsPeriodAll`(IN mobile int, IN beginperiod datetime, IN endperiod datetime,

IN timebegin varchar(9), IN timeend varchar(9), IN weekdays varchar(15), IN daymonth varchar(90))
BEGIN

  DECLARE time0 time DEFAULT '23:59:59';

  DECLARE time1 time DEFAULT '00:00:00'; 



  DROP TEMPORARY TABLE IF EXISTS tempperiod4;



  CREATE TEMPORARY TABLE tempperiod4 -- временная таблица выборок в указанном диапазоне

  SELECT

    DataGps_ID AS DataGps_ID,

    Mobitel_ID AS Mobitel_ID,

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

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

    Altitude AS Altitude,

    FROM_UNIXTIME(UnixTime) AS `time`,

    (Speed * 1.852) AS speed,

    Valid AS Valid,

    (Sensor8 + (Sensor7 << 8) + (Sensor6 << 16) + (Sensor5 << 24) + (Sensor4 << 32) + (Sensor3 << 40) + (Sensor2 << 48) + (Sensor1 << 56)) AS sensor,

    Events AS Events,

    LogID AS LogID

  FROM datagps

  WHERE Mobitel_ID = mobile AND

  (UnixTime BETWEEN UNIX_TIMESTAMP(beginperiod) AND UNIX_TIMESTAMP(endperiod)) AND

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

  ORDER BY UnixTime;



  DROP TEMPORARY TABLE IF EXISTS tempweeks;



  IF weekdays != '' THEN



    CREATE TEMPORARY TABLE tempweeks (

      shead varchar(2)

    );



    SET @saTail = weekdays;

    WHILE @saTail != '' DO

      SET @sHead = SUBSTRING_INDEX(@saTail, ';', 1);

      SET @saTail = SUBSTRING(@saTail, LENGTH(@sHead) + 2);

      INSERT INTO tempweeks (shead)

        VALUES (@sHead);

    END WHILE;

  END IF;



  DROP TEMPORARY TABLE IF EXISTS tempday0;



  IF daymonth != '' THEN



    CREATE TEMPORARY TABLE tempday0 (

      shead varchar(2)

    );



    SET @saTail = daymonth;

    WHILE @saTail != '' DO

      SET @sHead = SUBSTRING_INDEX(@saTail, ';', 1);

      SET @saTail = SUBSTRING(@saTail, LENGTH(@sHead) + 2);

      INSERT INTO tempday0 (shead)

        VALUES (@sHead);

    END WHILE;

  END IF;



  -- getting selecting data

  IF (daymonth != '') AND (weekdays != '') THEN

    IF TIME(timebegin) < TIME(timeend) then

    SELECT

      *

    FROM tempperiod4

    WHERE ((DAY(`time`) IN (SELECT

      *

    FROM tempday0)) AND -- чтение по дням месяца

    (WEEKDAY(`time`) IN (SELECT

      *

    FROM tempweeks)) AND -- чтение по дням недели

    (TIME(`time`) BETWEEN TIME(timebegin) AND TIME(timeend))); -- чтение дат

    END IF;



    IF TIME(timebegin) > TIME(timeend) then

    SELECT

      *

    FROM tempperiod4

    WHERE ((DAY(`time`) IN (SELECT

      *

    FROM tempday0)) AND -- чтение по дням месяца

    (WEEKDAY(`time`) IN (SELECT

      *

    FROM tempweeks)) AND -- чтение по дням недели

    ((time(`time`) > time(timebegin) and time(`time`) < time(time0))

    OR (time(`time`) > time(time1) AND time(`time`) < time(timeend)))); -- чтение дат

    END IF;

    END IF;



      IF (daymonth = '') AND (weekdays != '') THEN

        IF TIME(timebegin) < TIME(timeend) then

        SELECT

          *

        FROM tempperiod4

        WHERE ((WEEKDAY(`time`) IN (SELECT

          *

        FROM tempweeks)) AND -- чтение по дням недели

        (TIME(`time`) BETWEEN TIME(timebegin) AND TIME(timeend))); -- чтение дат

          end IF;



        IF TIME(timebegin) > TIME(timeend) then

        SELECT

          *

        FROM tempperiod4

        WHERE ((WEEKDAY(`time`) IN (SELECT

          *

        FROM tempweeks)) AND -- чтение по дням недели

        ((time(`time`) > time(timebegin) and time(`time`) < time(time0))

    OR (time(`time`) > time(time1) AND time(`time`) < time(timeend)))); -- чтение дат

          end IF;

        END IF;



          IF (daymonth != '') AND (weekdays = '') THEN

            IF TIME(timebegin) < TIME(timeend) then

            SELECT

              *

            FROM tempperiod4

            WHERE ((DAY(`time`) IN (SELECT

              *

            FROM tempday0)) AND -- чтение по дням месяца

            (TIME(`time`) BETWEEN TIME(timebegin) AND TIME(timeend))); -- чтение дат

              END IF;



            IF TIME(timebegin) > TIME(timeend) then

            SELECT

              *

            FROM tempperiod4

            WHERE ((DAY(`time`) IN (SELECT

              *

            FROM tempday0)) AND -- чтение по дням месяца

            ((time(`time`) > time(timebegin) and time(`time`) < time(time0))

              OR (time(`time`) > time(time1) AND time(`time`) < time(timeend)))); -- чтение дат

              END IF;

            END IF;



              IF (daymonth = '') AND (weekdays = '') THEN

                IF TIME(timebegin) < TIME(timeend) then

                SELECT

                  *

                FROM tempperiod4

                WHERE (TIME(`time`) BETWEEN TIME(timebegin) AND TIME(timeend)); -- чтение дат

                  end IF;



                IF TIME(timebegin) > TIME(timeend) then

                SELECT

                  *

                FROM tempperiod4

                WHERE ((time(`time`) > time(timebegin) and time(`time`) < time(time0))

                  OR (time(`time`) > time(time1) AND time(`time`) < time(timeend))); -- чтение дат

                  end IF;

              END IF;

            END ;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

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

-- Dump completed on 2024-01-29 13:31:38
