Method, device and medium for synchronizing chart data of terminal equipment and server
1. A method for synchronizing terminal equipment chart data and a server is characterized by comprising the following steps:
step 10, building a client server on the terminal equipment and appointing a first database, and building a background server on the shipborne equipment and appointing a second database;
step 20, the client server establishes connection with the background server;
step 30, when the data of the first database changes, acquiring differential data, encrypting the differential data, transmitting the encrypted differential data to a background server, decrypting the encrypted differential data by the background server, and storing the decrypted differential data in a second database;
and when the data of the second database changes, acquiring differential data, encrypting the differential data, transmitting the encrypted data to the client server, decrypting the encrypted differential data by the terminal equipment, and storing the decrypted differential data in the first database.
2. The method of claim 1, wherein: in the step 10, the client server is built by using ServerSocket.
3. The method of claim 1, wherein: the step 20 specifically includes:
the method comprises the steps that a client server of the terminal device is started, after the client server is started, a request is sent to a background server through TCP connection, a client service starting completion notice is sent to the background server after connection is successful, an IP address and a port required by connection are sent to the background server, and the background server is connected with the terminal device through the IP and the port, so that connection establishment is achieved.
4. The method of claim 1, wherein: and the encryption operation and the decryption operation are both carried out through an encryption library.
5. The method of claim 1, wherein: the first database is data _ syn and the second database is s _ data _ syn.
6. A device for synchronizing terminal equipment chart data and a server is characterized by comprising: the system comprises a construction module, a connection module and a synchronization module;
the building module is used for building a client server on the terminal equipment and appointing a first database, and building a background server on the shipborne equipment and appointing a second database;
the connection module is used for establishing connection between the client server and the background server;
the synchronization module is used for acquiring differential data when the data of the first database changes, transmitting the differential data to the background server after encryption, decrypting the encrypted differential data by the background server, and then storing the decrypted differential data in the second database;
and when the data of the second database changes, acquiring differential data, encrypting the differential data, transmitting the encrypted data to the client server, decrypting the encrypted differential data by the terminal equipment, and storing the decrypted differential data in the first database.
7. The apparatus of claim 6, wherein: in the building module, the client server is built by using a Serversocket.
8. The apparatus of claim 6, wherein: the connection module is specifically configured to:
the method comprises the steps that a client server of the terminal device is started, after the client server is started, a request is sent to a background server through TCP connection, a client service starting completion notice is sent to the background server after connection is successful, an IP address and a port required by connection are sent to the background server, and the background server is connected with the terminal device through the IP and the port, so that connection establishment is achieved.
9. The apparatus of claim 6, wherein: and the encryption operation and the decryption operation are both carried out through an encryption library.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 5.
Background
Android is a Linux-based operating system with free and open source codes, is mainly used for mobile devices such as smart phones and tablet computers, and is led and developed by Google corporation and the open mobile alliance. The platform consists of an operating system, middleware, a user interface and application software. The embedded type computer system is widely used in embedded type products due to the fact that source codes are open, hardware is rich and development is easy.
With the development of science and technology, more and more Android terminal devices are applied to navigation. However, in the current terminal devices used for navigation, navigation-related data are stored in the terminal devices. When data needs to be checked, copying the data from the terminal equipment by using a U disk or other mobile disk equipment; when the chart needs to be updated, the chart source is copied to the terminal equipment by using equipment such as a U disk. Such a method is rather cumbersome and inefficient.
Disclosure of Invention
The technical problem to be solved by the invention is to provide a method, a device and a medium for synchronizing terminal equipment chart data and a server, so as to realize synchronous interaction between the terminal chart data and a background server.
In a first aspect, the present invention provides a method for synchronizing a terminal device chart data with a server, including:
step 10, building a client server on the terminal equipment and appointing a first database, and building a background server on the shipborne equipment and appointing a second database;
step 20, the client server establishes connection with the background server;
step 30, when the data of the first database changes, acquiring differential data, encrypting the differential data, transmitting the encrypted differential data to a background server, decrypting the encrypted differential data by the background server, and storing the decrypted differential data in a second database;
and when the data of the second database changes, acquiring differential data, encrypting the differential data, transmitting the encrypted data to the client server, decrypting the encrypted differential data by the terminal equipment, and storing the decrypted differential data in the first database.
Further, in the step 10, the client server is built by using ServerSocket.
Further, the step 20 specifically includes:
the method comprises the steps that a client server of the terminal device is started, after the client server is started, a request is sent to a background server through TCP connection, a client service starting completion notice is sent to the background server after connection is successful, an IP address and a port required by connection are sent to the background server, and the background server is connected with the terminal device through the IP and the port, so that connection establishment is achieved.
Further, the encryption operation and the decryption operation are both performed by an encryption library.
Further, the first database is data _ syn, and the second database is s _ data _ syn.
In a second aspect, the present invention provides an apparatus for synchronizing a terminal device with a server, including: the system comprises a construction module, a connection module and a synchronization module;
the building module is used for building a client server on the terminal equipment and appointing a first database, and building a background server on the shipborne equipment and appointing a second database;
the connection module is used for establishing connection between the client server and the background server;
the synchronization module is used for acquiring differential data when the data of the first database changes, transmitting the differential data to the background server after encryption, decrypting the encrypted differential data by the background server, and then storing the decrypted differential data in the second database;
and when the data of the second database changes, acquiring differential data, encrypting the differential data, transmitting the encrypted data to the client server, decrypting the encrypted differential data by the terminal equipment, and storing the decrypted differential data in the first database.
Further, in the building module, the client server is built by using a ServerSocket.
Further, the connection module is specifically configured to:
the method comprises the steps that a client server of the terminal device is started, after the client server is started, a request is sent to a background server through TCP connection, a client service starting completion notice is sent to the background server after connection is successful, an IP address and a port required by connection are sent to the background server, and the background server is connected with the terminal device through the IP and the port, so that connection establishment is achieved.
Further, the encryption operation and the decryption operation are both performed by an encryption library.
Further, the first database is data _ syn, and the second database is s _ data _ syn.
In a third aspect, the invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the method of the first aspect.
The invention has the following advantages:
by the method, the terminal equipment and the background server can synchronously process specific data, the terminal data are changed, the background can acquire information in time, and the background needs to give the terminal data and can give the terminal data in time and conveniently; differential data updating is applied, retransmission of the same data is avoided, synchronization efficiency is greatly improved, and burden is relieved for a network;
the synchronized information can be utilized, the navigation state of the ship is monitored in real time in a background system, and the navigation information is updated and responded in time by combining with multi-party resources, so that the navigation is safer and more guaranteed, and the chart information is particularly convenient to update; if the rescue needs to be carried out in time in case of accidents and the like, the information can be mastered more quickly and accurately, and the rescue action can be carried out in time, so that the peace and the worry are brought to navigation;
with the development of science and technology, the network security awareness of people is higher and higher, the encryption library is supported, complete data can be obtained only by transmitting simple encrypted texts and decrypting the encrypted texts through the encryption library, so that even if the transmitted content is stolen by a person, the opposite side cannot know the real content in the transmitted content, the network security is well guaranteed, the purpose of absolute security is realized, and the leakage of commercial secrets is prevented.
Drawings
The invention will be further described with reference to the following examples with reference to the accompanying drawings.
FIG. 1 is a flow chart of a method performed by an embodiment of the present invention;
FIG. 2 is a system framework diagram according to an embodiment of the present invention;
FIG. 3 is a schematic structural diagram of a second apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a medium according to a third embodiment of the present invention.
Detailed Description
Example one
The embodiment provides a method for synchronizing a terminal device chart data and a server, as shown in fig. 1, the method includes:
step 10, building a client server on the terminal equipment and appointing a first database, and building a background server on the shipborne equipment and appointing a second database;
step 20, the client server establishes connection with the background server;
step 30, when the data of the first database changes, acquiring differential data, encrypting the differential data, transmitting the encrypted differential data to a background server, decrypting the encrypted differential data by the background server, and storing the decrypted differential data in a second database;
and when the data of the second database changes, acquiring differential data, encrypting the differential data, transmitting the encrypted data to the client server, decrypting the encrypted differential data by the terminal equipment, and storing the decrypted differential data in the first database.
By the method, the terminal equipment and the background server can synchronously process specific data, the terminal data are changed, the background can acquire information in time, and the background needs to give the terminal data in time and conveniently; differential data updating is applied, retransmission of the same data is avoided, synchronization efficiency is greatly improved, and burden is relieved for a network; the synchronized information can be utilized, the navigation state of the ship is monitored in real time in a background system, and the navigation information is updated and responded in time by combining with multi-party resources, so that the navigation is safer and more guaranteed, and the chart information is particularly convenient to update; if the rescue needs to be carried out in time in case of accidents and the like, the information can be mastered more quickly and accurately, the rescue action can be carried out in time, and the safety and the worry are brought to navigation.
In a possible implementation manner, in the step 10, the client server is built by using ServerSocket.
The step 20 specifically includes:
the method comprises the steps that a client server of the terminal device is started, after the client server is started, a request is sent to a background server through TCP connection, a client service starting completion notice is sent to the background server after connection is successful, an IP address and a port required by connection are sent to the background server, and the background server is connected with the terminal device through the IP and the port, so that connection establishment is achieved.
And the encryption operation and the decryption operation are both carried out through an encryption library.
With the development of science and technology, the network security awareness of people is higher and higher, the encryption library is supported, complete data can be obtained only by transmitting simple encrypted texts and decrypting the encrypted texts through the encryption library, so that even if the transmitted content is stolen by a person, the opposite side cannot know the real content in the transmitted content, the network security is well guaranteed, the purpose of absolute security is realized, and the leakage of commercial secrets is prevented.
The first database is data _ syn and the second database is s _ data _ syn.
In a specific implementation manner, the embodiment of the invention mainly develops an application related to a chart on an Android system, and related data on the chart can be synchronously interacted with a background server, so that safe driving of a ship can be monitored in real time at the background, and the server can also directly transmit the related data to a terminal.
The realization of the synchronization function mainly comprises the following two parts:
1. a background server is set up for the terminal equipment to transmit data;
2. and a client server is established on the terminal equipment and is used for the background server to transmit data.
The realization process is as follows:
1) after the terminal equipment starts the application, a server is started in the application to be connected with the background service, so that data are sent;
2) after the terminal equipment starts the server, the terminal equipment starts to be connected with the background server, so that the purpose of transmitting data is achieved; and sending a notification to the platform server after the connection is successful, and notifying the background that the connection terminal can start to send data.
In a system consisting of a ship-borne device and a terminal device as shown in fig. 2, the foundation is built as follows:
1. the terminal device designates a specific database data _ syn (i.e. the first database);
2. building a Client Server (CS) by using a Serversocket in an APP of the terminal equipment;
3. building a background server (SS) on the shipborne equipment;
4. the background server (SS) designates a specific database s _ data _ syn (i.e. the second database);
the method comprises the steps that when the APP is started, the CS is started immediately, after the CS is started, a TCP connection is used for initiating a request to the SS, after the connection is successful, a CS starting completion notification is sent to the SS, an IP address and a port required by the connection are sent to the SS, and the SS is connected with a terminal through the IP and the port, so that connection intercommunication is achieved. Carrying out differential processing on the change of the data through a special encryption library, and carrying out synchronous processing on the processed differential data; when the content in the data _ syn changes, the terminal sends differential data to the SS; similarly, when s _ data _ syn changes, the SS sends differential data to the terminal. Therefore, the data synchronization of the terminal and the server is realized.
Based on the same inventive concept, the application also provides a device corresponding to the method in the first embodiment, which is detailed in the second embodiment.
Example two
In this embodiment, an apparatus for synchronizing a terminal device chart data with a server is provided, as shown in fig. 3, including: the system comprises a construction module, a connection module and a synchronization module;
the building module is used for building a client server on the terminal equipment and appointing a first database, and building a background server on the shipborne equipment and appointing a second database;
the connection module is used for establishing connection between the client server and the background server;
the synchronization module is used for acquiring differential data when the data of the first database changes, transmitting the differential data to the background server after encryption, decrypting the encrypted differential data by the background server, and then storing the decrypted differential data in the second database;
and when the data of the second database changes, acquiring differential data, encrypting the differential data, transmitting the encrypted data to the client server, decrypting the encrypted differential data by the terminal equipment, and storing the decrypted differential data in the first database.
In a possible implementation manner, in the building module, the client server is built by using a ServerSocket.
The connection module is specifically configured to:
the method comprises the steps that a client server of the terminal device is started, after the client server is started, a request is sent to a background server through TCP connection, a client service starting completion notice is sent to the background server after connection is successful, an IP address and a port required by connection are sent to the background server, and the background server is connected with the terminal device through the IP and the port, so that connection establishment is achieved.
And the encryption operation and the decryption operation are both carried out through an encryption library.
Since the apparatus described in the second embodiment of the present invention is an apparatus used for implementing the method of the first embodiment of the present invention, based on the method described in the first embodiment of the present invention, a person skilled in the art can understand the specific structure and the deformation of the apparatus, and thus the details are not described herein. All the devices adopted in the method of the first embodiment of the present invention belong to the protection scope of the present invention.
Based on the same inventive concept, the application provides a storage medium corresponding to the third embodiment.
EXAMPLE III
The present embodiment provides a computer-readable storage medium, as shown in fig. 4, on which a computer program is stored, and when the computer program is executed by a processor, any one of the embodiments can be implemented.
Since the computer-readable storage medium described in this embodiment is a computer-readable storage medium used for implementing the method in the first embodiment of the present application, a person skilled in the art can understand a specific implementation manner of the computer-readable storage medium and various modifications thereof based on the method described in the first embodiment of the present application, and therefore, how to implement the method in the embodiment of the present application by using the computer-readable storage medium is not described in detail herein. Computer-readable storage media that can be used by those skilled in the art to implement the methods of the embodiments of the present application are all within the scope of the present application.
Although specific embodiments of the invention have been described above, it will be understood by those skilled in the art that the specific embodiments described are illustrative only and are not limiting upon the scope of the invention, and that equivalent modifications and variations can be made by those skilled in the art without departing from the spirit of the invention, which is to be limited only by the appended claims.