Disclosure of Invention
The invention aims to solve the defects that the existing recorder alarm information processing method is low in query speed and difficult to respond to large data volume in real time, and provides a recorder management platform-based real-time alarm data analysis method.
A real-time analysis alarm data method based on a recorder management platform comprises the following steps:
the method comprises the steps of firstly, receiving vehicle coordinate data, wherein the vehicle coordinate data comprise alarm zone bits;
analyzing the vehicle coordinate data, and packaging the analyzed alarm data into a new data packet;
step three, caching the new data packet by using a cache region;
and step four, reading the data of the buffer area at regular time according to the setting of the timer, and storing the data into an alarm temporary table in the database.
And step five, reading all data from the temporary alarm table, counting the alarm times according to the preset information type, and updating the counting result into the alarm information table in the database.
A real-time analysis alarm data system based on a recorder management platform comprises:
the data receiving module is used for receiving the vehicle coordinate data; the vehicle coordinate data comprises an alarm zone bit;
the analysis module is used for analyzing the vehicle coordinate data and packaging the analyzed alarm data into a new data packet;
the cache module is used for caching the new data packet by using the cache region;
the storage module is used for regularly reading the data of the cache region according to the setting of the timer and storing the data into an alarm temporary table in the database;
and the data updating module is used for reading all data from the temporary alarm table, counting the alarm times according to the preset information type and updating the counting result into the alarm information table in the database.
The invention has the beneficial effects that:
1) the embodiment of the invention effectively solves the problem of slow speed of inquiring and processing the alarm information of the recorder management platform; compared with the existing method, the query speed of the method is improved by at least 10%.
2) In one embodiment of the invention, the coordinate data is pushed by the zeroMQ, the receiving end can receive the coordinate data in a multi-thread mode, the processing capacity of the system is increased, the thread number can be modified in the configuration file, and the system is convenient to deploy;
3) when the alarm information is stored, a cache mechanism, a timer and a timeout batch data insertion mode are adopted, so that the pressure of operating timeout is greatly reduced;
4) the embodiment of the invention supports multi-server multi-process deployment and can effectively solve the bottleneck of continuous increase of the number of real-time coordinates.
Detailed Description
The first embodiment is as follows: as shown in fig. 1, the method for analyzing alarm data in real time based on a recorder management platform of the embodiment includes:
the method comprises the steps of firstly, receiving vehicle coordinate data, wherein the vehicle coordinate data comprise alarm zone bits.
And step two, analyzing the vehicle coordinate data, and packaging the analyzed alarm data into a new data packet.
And step three, caching the new data packet by using a cache region.
And step four, reading the data of the buffer area at regular time according to the setting of the timer, and storing the data into an alarm temporary table in the database.
And step five, reading all data from the temporary alarm table, counting the alarm times according to the preset information type, and updating the counting result into the alarm information table in the database.
The temporary alarm table and the alarm information table are two different tables, and the arrangement is to avoid the phenomenon of table deadlock caused by updating operation.
The specific meaning of the method is that the preset information is four items, namely, vehicle, alarm type, driver and date, the four same items are integrated into one type, then the item of the alarm frequency is added, 1 is added to each four items, and when the alarm information table is specifically updated, the four items are not only updated, but also all the rest information, such as longitude and latitude information and the like, is updated. The alarm information inquiry speed can be increased by the arrangement.
The second embodiment is as follows: the first difference between the present embodiment and the specific embodiment is: in the first step, the vehicle coordinate data is received in a multithreading mode through a multithreading network base zeroMQ based on a message queue.
Other steps and parameters are the same as those in the first embodiment.
The third concrete implementation mode: the present embodiment differs from the first or second embodiment in that: and in the second step, analyzing the vehicle coordinate data, specifically analyzing the coordinate data according to a TJ/T808 protocol.
Other steps and parameters are the same as those in the first or second embodiment.
The fourth concrete implementation mode: the difference between this embodiment mode and one of the first to third embodiment modes is: in the second step, the analyzed alarm data comprises vehicle, longitude, latitude, speed, altitude, direction, alarm time, alarm type and driver information. And step five, the preset information includes the vehicle, the alarm type, the driver and the date.
Other steps and parameters are the same as those in one of the first to third embodiments.
The fifth concrete implementation mode: the difference between this embodiment and one of the first to fourth embodiments is: counting the alarm times according to the preset information type, and updating the counting result into an alarm information table in a database specifically comprises the following steps:
and counting the alarm times according to the vehicle, the alarm type, the driver and the date, judging whether a record with the same vehicle, alarm type, driver and date as the statistical result exists in the alarm information table, if so, updating the record, and if not, inserting the statistical result into the alarm information table.
Other steps and parameters are the same as in one of the first to fourth embodiments.
The sixth specific implementation mode: the difference between this embodiment and one of the first to fifth embodiments is: in the fourth step, the database is a timesten database.
Other steps and parameters are the same as those in one of the first to fifth embodiments.
The seventh embodiment: this embodiment provides a real-time analysis alarm data system based on record appearance management platform, includes:
the data receiving module is used for receiving the vehicle coordinate data; the vehicle coordinate data includes an alarm flag bit.
And the analysis module is used for analyzing the vehicle coordinate data and packaging the analyzed alarm data into a new data packet.
And the cache module is used for caching the new data packet by using the cache region.
And the storage module is used for regularly reading the data of the cache region according to the setting of the timer and storing the data into an alarm temporary table in the database.
And the data updating module is used for reading all data from the temporary alarm table, counting the alarm times according to the preset information type and updating the counting result into the alarm information table in the database.
The specific implementation mode is eight: the seventh embodiment is different from the seventh embodiment in that: in the data receiving module, multithreading receiving is carried out on the vehicle coordinate data through a multithreading network base zeroMQ based on a message queue;
in the analysis module, coordinate data are analyzed through a TJ/T808 protocol; the analyzed alarm data comprises vehicle, longitude, latitude, speed, altitude, direction, alarm time, alarm type and driver information; in the storage module, the preset information includes a vehicle, an alarm type, a driver and a date.
Other steps and parameters are the same as those in the seventh embodiment.
The specific implementation method nine: the eighth embodiment is different from the eighth embodiment in that: in the cache module, the buffer area is a ring buffer area.
Other steps and parameters are the same as those of the seventh or eighth embodiment.
The detailed implementation mode is ten: the present embodiment differs from the ninth embodiment in that: in the storage module, the process of counting the alarm times according to the preset information type and updating the counting result into the alarm information table in the database specifically comprises the following steps:
and counting the alarm times according to the vehicle, the alarm type, the driver and the date, judging whether a record with the same vehicle, alarm type, driver and date as the statistical result exists in the alarm information table, if so, updating the record, and if not, inserting the statistical result into the alarm information table, wherein other steps and parameters are the same as those in one of the seventh to ninth specific implementation modes.
The concrete implementation mode eleven: in this embodiment, the data required by this system comes from the information push to the coordinate data of the recorder management platform, the vehicle coordinate data is received to this system by the message push of ZeroMQ, the coordinate data contains the alarm flag bit, the alarm is analyzed according to the part mark TJ/T808 protocol, the alarm information that can be analyzed includes vehicle, longitude, latitude, speed, altitude, direction, alarm time, alarm type, driver, etc., and is packaged into a new data packet, a buffer is opened up to buffer the analyzed alarm information, the alarm data in the buffer is read regularly by using a timer, and is stored in the temporary alarm table of the timeten database in batch.
The timing task is responsible for reading all data of the temporary alarm table, counting alarm times according to the vehicle, the alarm type, the driver and the date, updating the counting result into the alarm table, judging whether the alarm table has the alarm record in the updating process (the judgment of the alarm record is according to the vehicle, the alarm type, the driver and the date), if the alarm record exists, operating the record by the update, if the alarm record does not exist, deleting the new record by insert, and deleting the counted data in the temporary table to a buffer area by adopting a ring buffer area (ring buffer). The alarm analysis service adopts multithreading to receive coordinate data and multithreading to process alarm data, the number of threads can be adjusted according to the configuration of the server and the actual data volume, and only the configuration file needs to be modified, so that the method is fast in aspect.
The present invention is capable of other embodiments and its several details are capable of modifications in various obvious respects, all without departing from the spirit and scope of the present invention.