CN113407635B - Multi-terminal data synchronization method and system for intelligent manufacturing - Google Patents

Multi-terminal data synchronization method and system for intelligent manufacturing Download PDF

Info

Publication number
CN113407635B
CN113407635B CN202110777577.3A CN202110777577A CN113407635B CN 113407635 B CN113407635 B CN 113407635B CN 202110777577 A CN202110777577 A CN 202110777577A CN 113407635 B CN113407635 B CN 113407635B
Authority
CN
China
Prior art keywords
terminal
server
request
record
incremental file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110777577.3A
Other languages
Chinese (zh)
Other versions
CN113407635A (en
Inventor
方禺
徐寒松
李凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mingdu Zhiyun Zhejiang Technology Co Ltd
Original Assignee
Mingdu Zhiyun Zhejiang Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mingdu Zhiyun Zhejiang Technology Co Ltd filed Critical Mingdu Zhiyun Zhejiang Technology Co Ltd
Priority to CN202110777577.3A priority Critical patent/CN113407635B/en
Publication of CN113407635A publication Critical patent/CN113407635A/en
Application granted granted Critical
Publication of CN113407635B publication Critical patent/CN113407635B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2315Optimistic concurrency control
    • G06F16/2322Optimistic concurrency control using timestamps
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2372Updates performed during offline database operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • G06F21/6227Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database where protection concerns the structure of data, e.g. records, types, queries
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Abstract

The invention discloses a multi-terminal data synchronization method and a multi-terminal data synchronization system for intelligent manufacturing, which comprise the following steps: the first terminal downloads a complete table structure and SQL sentences from the server and imports the table structure and the SQL sentences into a local database; judging the network state after acquiring the deletion record instruction; if the server receives the locking record request, the server returns first response information and refuses to respond to the record deletion request sent by other terminals before receiving an unlocking record request sent by a subsequent first terminal; the server operates according to the deletion updating request, if the operation is successful, the server immediately returns second response information and puts the deletion updating forwarding request into a queue, and if the first terminal does not receive the first or second response information replied by the server, the local database of the first terminal is not updated. The invention realizes the uploading and synchronization of the operation records and the operation results of each mobile terminal and each fixed terminal to the system database, and keeps the data synchronization of the server system database and each terminal local database.

Description

Multi-terminal data synchronization method and system for intelligent manufacturing
Technical Field
The invention relates to the field of intelligent manufacturing, in particular to a multi-terminal data synchronization method and system for intelligent manufacturing.
Background
In the existing equipment production workshops of a factory, a plurality of workshops do not have wireless networks, so that when the related services of equipment are processed, records can only be recorded on a paper carrier, and recording deviation or omission is easily caused, thereby causing management confusion. For example, when a worker performs a device operation in a workshop, such as maintenance, inspection, and the like, the worker may need to refer to the history. In addition, when the staff operates in the workshop, the execution equipment needs to be checked, the equipment number is generally long and complicated, and if the mobile terminal of the staff cannot be connected with the network, the mobile terminal can only retrieve and query the relevant equipment information on the paper record, so that the query efficiency is low. And a factory establishes a network for a workshop, and particularly, huge cost is needed to ensure that each area of the factory covers the wireless network. However, even if a wireless network is established for each workshop in a park, due to the obstruction of various large-scale production devices, the problem that network signals become poor or even the connection of mobile terminals of workers is impossible often exists when the mobile terminals enter the production devices or other special areas, so that effective recording operation cannot be finally performed on the mobile terminals, and the recorded data of operation, inspection and the like of each worker cannot be effectively kept synchronous, thereby greatly influencing the operation and guarantee efficiency in the production and manufacturing process.
Disclosure of Invention
Aiming at the defects in the prior art, the invention provides a multi-terminal data synchronization method for intelligent manufacturing, which comprises the following steps:
s1, the first terminal downloads the complete table structure and SQL sentences from the server and imports the table structure and SQL sentences into a local database;
s2, the first terminal judges the network state after obtaining the deletion record instruction, if the first terminal is in the non-network state, the first terminal saves the deleted SQL statement and the timestamp into the local database, and if the first terminal is in the network connection state, the first terminal sends a record locking request to the server through the http protocol;
s3, if the server receives the locking record request, the server returns first response information, and refuses response to the record deleting request sent by other terminals before receiving the unlocking record request sent by the subsequent first terminal, meanwhile, the locking record request is put into a memory queue and is forwarded to other terminals through websocket after next heartbeat arrives, if partial terminals fail to forward, the SQL incremental file with the timestamp is stored for the corresponding terminal, and the locking record request is configured to prohibit the terminal receiving the request from deleting the record before receiving the unlocking record request;
s4, if the first terminal receives the first response information replied by the server, the first terminal sends a deletion and update request to the server through an http protocol;
s5, the server operates according to the deletion, update and request, if the operation is successful, the server immediately returns second response information, and simultaneously puts the deletion, update and forwarding request into a queue, forwards the next heartbeat to other terminals through websocket for updating respective local databases, if partial terminal forwarding fails, the server saves SQL incremental files with time stamps for the corresponding terminals;
and S6, if the first terminal does not receive the first response information or the second response information replied by the server, the first terminal does not update the local database of the first terminal, otherwise, the first terminal sends an unlocking request to the server after updating the local database.
Preferably, the multi-terminal data synchronization method for smart manufacturing further includes the steps of:
the first terminal updates the local database after acquiring the newly added recording instruction, and sends a newly added updating request to the server through an http protocol if the first terminal is in a network connection state;
and the server operates according to the newly-added updating request, if the operation is successful, second response information is immediately returned, the newly-added updating request is put into a queue, the newly-added updating request is forwarded to other terminals through websocket after the next heartbeat is reached for updating the local databases of the terminals, and if the forwarding failure of the second terminal exists, the corresponding SQL incremental file with the timestamp is stored for the second terminal.
Preferably, the multi-terminal data synchronization method for smart manufacturing further includes the steps of:
after acquiring a newly added recording instruction, the first terminal saves the added or modified SQL statement and a timestamp as an incremental file to a local database, and if the first terminal is in a network-free state, the first terminal suspends sending a newly added updating request to the server;
the first terminal requests the server to upload the first incremental file through the http protocol after being switched to the network connection state again, and queries whether a downloadable second incremental file corresponding to the terminal exists in the server or not;
the first terminal uploads the first incremental file to the server according to the incremental file uploading and downloading path replied by the server, downloads the second incremental file at the same time, reorganizes the incremental files according to the SQL timestamp sequence, then imports the incremental files into the local database, and stops responding to a locking record request, a locking table request, a deletion update request or an addition update request sent to the terminal by the server before the incremental files are imported.
Preferably, the multi-terminal data synchronization method for smart manufacturing further includes the steps of: the method comprises the steps that a server continues to wait for a plurality of heartbeat cycles after receiving a first incremental file uploaded by a first terminal, if an incremental file uploading request of other terminals is not received, a lock table request broadcast is sent to all terminals, a response of a new increase or deletion updating request sent by each terminal is stopped, all incremental files are recombined according to an SQL time stamp sequence and then are led into a database, and the lock table request broadcast is configured to prohibit the terminals from sending new increase or deletion updating requests to the server until receiving an unlocking request broadcast.
Preferably, the multi-terminal data synchronization method for smart manufacturing further includes the steps of:
after the first terminal downloads the second incremental file, if the first incremental file to be uploaded in the terminal has the same record to be updated as the second incremental file, acquiring a first user ID for deleting the record from the first incremental file, acquiring a second user ID for deleting the record from the second incremental file, and acquiring the authority level corresponding to the user ID from the database according to the user IDs;
if the first user authority level is higher than the second user authority level, deleting and updating the record without adopting the content in the second incremental file;
if the first user permission level is not higher than the second user permission level, acquiring first time of the record deletion from the first incremental file timestamp, and acquiring second time of the record deletion from the second incremental file timestamp;
and if the first user permission level is lower than or equal to the second user permission level and the first time is earlier than the second time, adopting the content in the second incremental file to delete and update the record.
The invention also discloses a multi-terminal data synchronization system for intelligent manufacturing, which comprises:
the first terminal is configured to download a complete table structure and SQL sentences from the server, import the table structure and the SQL sentences into a local database, judge the network state after acquiring a deletion record instruction, save the deleted SQL sentences and a timestamp into the local database if the deleted SQL sentences and the timestamp are in a non-network state, and send a record locking request to the server through an http protocol if the deleted SQL sentences and the timestamp are in a network connection state; after receiving first response information replied by the server, sending a deletion and modification updating request to the server through an http protocol; when the first response information or the second response information replied by the server is not received, the local database of the first terminal is not updated;
the server is configured to reject response to a record deletion request sent by other terminals before receiving an unlocking record request sent by a subsequent first terminal after returning first response information after receiving the locking record request, simultaneously place the locking record request into a memory queue and forward the locking record request to other terminals through websocket after next heartbeat arrives, if partial terminals fail to forward, the server stores an SQL incremental file with a timestamp for the corresponding terminal, and the locking record request is configured to prohibit the terminal receiving the request from deleting the record before receiving the unlocking record request; and operating according to the deletion and modification updating request, if the operation is successful, immediately returning second response information, simultaneously putting the deletion and modification updating forwarding request into a queue, and after the next heartbeat arrives, forwarding the deletion and modification updating forwarding request to other terminals through websocket for updating respective local databases, and if partial terminals fail to forward, saving the SQL incremental files with the time stamps for the corresponding terminals.
Preferably, the first terminal is further configured to update the local database after acquiring the new record instruction, and send a new update request to the server through an http protocol if the local database is in a network connection state; and the server is also configured to operate according to the newly-added updating request, if the operation is successful, second response information is immediately returned, the newly-added updating request is put into a queue, the newly-added updating request is forwarded to other terminals through the websocket after the next heartbeat is reached for updating the local databases of the terminals, and if the forwarding failure of the second terminal exists, the corresponding SQL incremental file with the timestamp is stored for the second terminal.
Preferably, the first terminal is further configured to: after a newly added recording instruction is obtained, adding a timestamp to the added or modified SQL statement as an incremental file and storing the incremental file to a local database, and pausing to send a newly added updating request to a server when the SQL statement is in a network-free state; after the network connection state is switched to the network connection state again, the first incremental file is requested to be uploaded to the server through an http protocol, and whether a downloadable second incremental file corresponding to the terminal exists in the server or not is inquired; uploading the first incremental file to a server according to an incremental file uploading and downloading path replied by the server, downloading a second incremental file at the same time, recombining the incremental files according to the SQL timestamp sequence, importing the incremental files into a local database, and stopping responding to a locking record request, a locking list request, a deletion update request or an addition update request sent by the server to the terminal before the incremental files are imported.
Preferably, the server is configured to continue to wait for multiple heartbeat cycles after receiving the first incremental file uploaded by the first terminal, send a lock table request broadcast to all terminals and stop responding to a new or modified update request sent by each terminal if an incremental file upload request of other terminals is not received, reassemble all the incremental files according to an SQL timestamp sequence and then import the reassembled incremental files into the database, and the lock table request broadcast is configured to prohibit the terminal from sending a new or modified update request to the server until receiving an unlock request broadcast.
Preferably, the first terminal is further configured to: after downloading the second incremental file, if the first incremental file to be uploaded in the terminal has the same record to be updated as the second incremental file, acquiring a first user ID for deleting the record from the first incremental file, acquiring a second user ID for deleting the record from the second incremental file, and acquiring the authority level corresponding to the user ID from a database according to each user ID;
if the first user authority level is higher than the second user authority level, deleting and updating the record without adopting the content in the second incremental file;
if the first user permission level is not higher than the second user permission level, acquiring first time of the record deletion from the first incremental file timestamp, and acquiring second time of the record deletion from the second incremental file timestamp;
and if the first user permission level is lower than or equal to the second user permission level and the first time is earlier than the second time, adopting the content in the second incremental file to delete and update the record.
The method only has a relation with a local sqlite database and does not have any relation with a server through any increasing, deleting, modifying and checking operation of the mobile terminal in a network-free environment, and the method saves the increment files in the form of the sql sentences to a local flash storage and uploads the increment files to the server after network recovery. After the network is recovered, the mobile terminal uploads the incremental file to a server to update the database, and conversely, if the server has the incremental file, the server issues the incremental file to the mobile terminal, and the mobile terminal updates the sqlite database; any adding, deleting and modifying operations of the mobile terminal are completed in the server database and the local sqlite database synchronously. The business operation process of the electronic information system in the non-network environment of a factory workshop at the lowest cost is realized, the operation records and the operation results of each mobile terminal and each fixed terminal can be uploaded and synchronized to the system database, and the data synchronization of the server system database and each terminal local database is kept.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a schematic flowchart of a multi-terminal data synchronization method for intelligent manufacturing according to this embodiment.
FIG. 2 is another schematic flow chart of the multi-terminal data synchronization method for intelligent manufacturing according to the embodiment
Fig. 3 is a schematic flowchart of another method for synchronizing data of multiple terminals for smart manufacturing according to the present embodiment.
Fig. 4 is a schematic frame diagram of the multi-terminal data synchronization system for intelligent manufacturing according to the embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the drawings of the embodiments of the present invention. It is to be understood that the embodiments described are only a few embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the described embodiments of the invention without any inventive step, are within the scope of protection of the invention.
In the description of the present invention, it is to be understood that the terms "first", "second" and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present invention, "a plurality" means two or more unless specifically defined otherwise.
In the present invention, unless otherwise expressly specified or limited, the terms "mounted," "connected," "secured," and the like are to be construed broadly and can, for example, be fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meanings of the above terms in the present invention can be understood by those skilled in the art according to specific situations.
In the present invention, unless otherwise expressly stated or limited, "above" or "below" a first feature means that the first and second features are in direct contact, or that the first and second features are not in direct contact but are in contact with each other via another feature therebetween. Also, the first feature being "on," "above" and "over" the second feature includes the first feature being directly on and obliquely above the second feature, or merely indicating that the first feature is at a higher level than the second feature. A first feature being "under," "below," and "beneath" a second feature includes the first feature being directly under and obliquely below the second feature, or simply meaning that the first feature is at a lesser elevation than the second feature.
Fig. 1 is a block diagram of a multi-terminal data synchronization method for intelligent manufacturing according to this embodiment, where the method can implement a business operation process of an electronic information system in a workshop non-network environment at the lowest cost in a factory, and can upload and synchronize operation records and results to a system database, and the method specifically includes the following steps:
in step S1, the first terminal downloads the complete table structure and SQL statement from the server and imports the table structure and SQL statement into the local database. When the first terminal operates for the first time, the complete table structure and the SQL statements are downloaded from the server and imported into a local database, wherein the local database can be an SQLite database in the terminal, or the step is executed after a reset button of the first terminal is operated.
And step S2, the first terminal judges the network state after obtaining the deleting record instruction, if the first terminal is in the non-network state, the first terminal saves the deleted SQL statement and the timestamp into a local database, and if the first terminal is in the network connection state, the first terminal sends a record locking request to the server through the http protocol.
Step S3, if the server receives the locking record request, the server returns the first response information, and refuses the response to the record deleting request sent by other terminals before receiving the unlocking record request sent by the subsequent first terminal, meanwhile, the locking record request is put into the memory queue and is forwarded to other terminals through websocket after the next heartbeat arrives, if partial terminals fail to forward, the SQL incremental file with the timestamp is saved for the corresponding terminal, and the locking record request is configured to prohibit the terminal receiving the request from deleting the record before receiving the unlocking record request.
And step S4, if the first terminal receives the response information replied by the server, the first terminal sends a deletion and update request to the server through the http protocol.
And step S5, the server operates according to the deletion update request, if the operation is successful, the server immediately returns second response information, and simultaneously puts the deletion update forwarding request into a queue, and forwards the deletion update forwarding request to other terminals through websocket for updating respective local databases after the next heartbeat is reached, and if partial terminal forwarding fails, the server saves the SQL incremental files with the timestamps for the corresponding terminals.
Step S6, if the first terminal does not receive the first response information or the second response information replied by the server, the first terminal does not update the local database of the first terminal, otherwise, the first terminal sends an unlocking request to the server after updating the local database.
Specifically, before deletion and modification, the first terminal sends a record locking request to the server through http, the server forwards the request to other terminals through websocket, the other terminals can be mobile terminals or immovable fixed terminals, and any other terminal cannot delete and modify the record after the locking is successful. And then the first terminal sends a deletion update request to the server through http, the first terminal updates the local SQLite database after the server is updated successfully, meanwhile, the server side forwards the deletion update request to other mobile terminals through websocket and updates the SQLite database of each terminal, and finally the first terminal sends an unlocking request to the server.
In some specific embodiments, if the first terminal does not receive the first response signal sent by the server, the recording request is continuously locked to the server for multiple times at preset intervals, and when the first response signal sent by the server is not received, the network state of the first terminal is determined to be a no-network state, the deleted SQL statement and the timestamp are stored in the local database as an SQL incremental file of the server, and when the first terminal is in a network connection state, the corresponding SQL incremental file is sent to the server through an http protocol. Specifically, after a first terminal sends a locking record request to a server, a server side forwards the locking record request to other terminals through a websocket, because the heartbeat of the websocket is sent once every 20 seconds, the forwarding request is firstly put into a memory queue and is forwarded after the next heartbeat request arrives, the server responds to the locking request successfully without worrying whether other terminals successfully receive the request or not, even if some terminals do not receive the locking forwarding request and send a deletion request in the period, the server side can respond refused by corresponding operation error codes, and only one terminal is allowed to request in the same time for deletion operation of one record, so that the consistency of data is ensured; if the server times out and does not respond to the locking request in time, the first terminal will send the request again.
In some embodiments, if the first terminal sends a deletion, modification and update request to the server after receiving the first response signal sent by the server but does not receive the second response signal within the set time, the first terminal suspends subsequent deletion, modification and locking of the record in the local database, and unlocks the record in the local database after receiving the second response signal or the forwarded unlocking request of the server. Specifically, after the first terminal sends the deletion request to the server, if the operation of the server fails, the first terminal will not update the local SQLite database. And if the server is successfully operated, immediately returning successful response information, namely a second response signal, simultaneously putting the forwarding request into a queue, forwarding to other mobile terminals when the next heartbeat arrives, and if the forwarding fails, saving a SQL incremental file with a timestamp for the corresponding terminal to the file server.
In this embodiment, in a network-free environment, any add, delete, modify, and check operation of the mobile terminal is only related to the local sql lite database, and is not related to the server, and the increment file in the form of sql statement is stored in the local flash storage, and is uploaded to the server after network recovery. After the network is recovered, the mobile terminal uploads the incremental file to a server updating database, and conversely, if the server has the incremental file, the incremental file is issued to the mobile terminal, and the mobile terminal updates the sqlite database; any adding, deleting and modifying operations of the mobile terminal are completed in the server database and the local sqlite database synchronously. The business operation process of the electronic information system in the non-network environment of the factory workshop at the lowest cost is realized, the operation records and the operation results of all the mobile terminals and the fixed terminals can be uploaded and synchronized to the system database, and the data synchronization of the server system database and the local databases of all the terminals is kept.
As shown in fig. 2, in some embodiments, the multi-terminal data synchronization method for intelligent manufacturing further includes the following steps:
and step S701, the first terminal updates the local database after acquiring the new record instruction, and sends a new update request to the server through an http protocol if the first terminal is in a network connection state.
And S702, the server operates according to the newly increased updating request, if the operation is successful, second response information is immediately returned, the newly increased updating request is put into a queue, the newly increased updating request is forwarded to other terminals through a websocket after the next heartbeat is reached for updating local databases of the terminals, and if the forwarding failure of the second terminal exists, the corresponding SQL incremental file with the timestamp is stored for the second terminal.
Specifically, when the first terminal performs the new operation, a locking record request does not need to be sent in advance, the local SQLite database can be directly updated, then a new update request is sent to the server through http, after the new update is successful, the request is forwarded to other mobile terminals through websocket, and meanwhile, a message of successful operation is responded to the first terminal.
In this embodiment, the second terminal queries whether a downloadable SQL incremental file corresponding to the second terminal exists in the server after restoring the network connection, if so, downloads the SQL incremental file according to an incremental file download path replied by the server, reassembles the incremental file according to the SQL timestamp sequence, and then imports the incremental file into the local database, and during the import, rejects a notification about lock table/lock record or deletion and modification from the server.
As shown in fig. 3, in some embodiments, the multi-terminal data synchronization method for intelligent manufacturing further includes the following steps:
step S801, after acquiring the new record instruction, the first terminal saves the added or modified SQL statement and the timestamp as an incremental file in the local database, and if the first terminal is in a no-network state, the first terminal suspends sending the new update request to the server. Specifically, the first terminal determines whether the first terminal is in a no-network state or not according to whether Android broadcastrcerechiver receives a system broadcast with or without a network or whether the websocket connection is successful or whether the server has no response after more than 10 heartbeat requests or the like, and the first terminal can be considered to be in the no-network state as long as the terminal is determined to be in the no-network state through any of the above manners.
When the first terminal is in a non-network state, deleting, adding, inquiring and other operations of the first terminal directly access the local SQLite database, no relation is generated between the first terminal and the server, SQL sentences of the deleting, adding, inquiring and other operations are added with time stamps and then serve as incremental files to be stored in local flash storage, and the SQL sentences are uploaded to the server after network recovery and are forwarded to other terminals by the server.
Step S802, after the first terminal is switched to the network connection state again, the first terminal requests the server to upload the first incremental file through the http protocol, and whether a downloadable second incremental file corresponding to the terminal exists in the server or not is inquired. Specifically, when the first terminal is switched from a network-free state to a network connection state, the first terminal uploads an incremental file, namely a first incremental file, which is originally stored in a local flash memory in the network-free state, to the server and forwards the incremental file to other terminals. Meanwhile, when the first terminal is in a non-network state, any deletion, addition, query and other operations performed by other terminals in the time period store the incremental text with the time stamp, namely the second incremental file, corresponding to the first terminal on the server, and the second incremental file is issued to the first terminal when the first terminal is in a network connection state. The network recovery judgment of the first terminal can receive a broadcast of system network connection according to Android broadcastrechiveriver, then resend websocket connection, and after a heartbeat request response is monitored, network recovery can be judged.
And step S803, the first terminal uploads the first incremental file to the server according to the incremental file uploading and downloading path replied by the server, downloads the second incremental file at the same time, reorganizes the incremental files according to the SQL timestamp sequence, then imports the incremental files into the local database, and stops responding to a locking record request, a locking table request, a deletion update request or a new addition update request sent to the terminal by the server before the incremental files are imported.
Specifically, the server sends a message for downloading the incremental file to the first terminal through the websocket heartbeat, and then the first terminal downloads the corresponding incremental file, that is, the second incremental file, from the file server after sending a request for downloading the incremental file through http. After the incremental file is successfully downloaded by the first terminal, the incremental file is recombined according to the SQL timestamp sequence and is imported into a local SQLite database, and the response to the locking record request, the locking table request, the deletion update request or the addition update request sent by the server to the terminal is stopped before the incremental file is imported, namely, the notification about the locking table/locking record or the deletion and addition update is refused from the server during the import.
Step S804, the server continues to wait for a plurality of heartbeat cycles after receiving the first increment file uploaded by the first terminal, if the request of uploading the increment files of other terminals is not received, the server sends a lock table request broadcast to all the terminals and stops responding to the newly increased or deleted update request sent by each terminal, all the increment files are recombined according to the SQL time stamp sequence and then are led into the database, and the lock table request broadcast is configured to prohibit the terminals from sending the newly increased or deleted update request to the server until receiving the unlocking request broadcast.
Specifically, the server waits for a plurality of heartbeats, for example, within 10 heartbeats, if there is no incremental file request uploaded by other terminals, the server sends a lock table request broadcast to all mobile terminals and non-mobile terminals, and after the broadcast is finished, the server reassembles the incremental files corresponding to all terminals according to the SQL timestamp sequence and then imports the incremental files into the database, and stops responding to the lock record request, the deletion update request or the new addition update request sent to each terminal before the incremental file import is finished, that is, rejects the addition and deletion update request of any terminal during the import period, and sends an unlock message after the import is finished.
When the first incremental file and the second incremental file both have deletion and modification of the same record, the record deletion and modification information in the first incremental file and the second incremental file can be screened according to a preset rule to judge whether the second incremental file is finally adopted to update the relevant record of the first terminal.
In one embodiment, the predetermined rule may be a judgment filtering according to the operator authority level of the related record in the incremental file. Specifically, after the first terminal downloads the second incremental file, if the first incremental file to be uploaded in the terminal has the same record object to be updated as the second incremental file, a first user ID for deleting the record is acquired from the first incremental file, a second user ID for deleting the record is acquired from the second incremental file, and the authority level corresponding to the user ID is acquired from the authority database according to each user ID; the authority database stores user ID and corresponding authority level for logging in each terminal to perform operations such as adding, deleting and the like on data. More core or more important staff can distribute higher authority, and in addition, the user with higher authority can modify, approve or reject the operation of the operation records of the user with lower authority, newly added records or deleted records and the like.
And if the first user authority level is higher than the second user authority level, deleting and updating the record without adopting the content in the second incremental file.
And if the first user permission level is lower than or equal to the second user permission level, sequentially recombining the incremental files according to the timestamps in the first incremental file and the second incremental file and importing the incremental files into a local SQLite database. Specifically, a first time corresponding to the occurrence of record deletion is obtained from a timestamp of the first incremental file, and a second time corresponding to the occurrence of record deletion is obtained from a timestamp of the second incremental file.
And if the first user permission level is lower than or equal to the second user permission level and the first time is earlier than the second time, adopting the content in the second incremental file to delete and update the record.
And if the first user permission level is lower than or equal to the second user permission level and the first time is later than the second time, sending a record updating prompt, deleting and updating the record by using the content in the second incremental file after the updating permission is obtained, and otherwise, not deleting and updating the record.
In another embodiment, the preset rule may be determined according to the running level of the generation time period of the relevant record in the delta file. Specifically, after the first terminal downloads the second incremental file, if the same record object to be updated in the second incremental file is in the first incremental file to be uploaded in the terminal, the first time of the corresponding record deletion occurrence is obtained from the timestamp of the first incremental file, the second time of the corresponding record deletion occurrence is obtained from the timestamp of the second incremental file, the operation grades of the time periods of the first time and the second time are compared, and the operation grades are the polling intensity and/or the working intensity of each time period in which the mobile terminal is located. For example, each cooperative department is in an efficient working state in the working time period in the daytime, the check of each device is more systematic and standard, and various modification records generated by each department are more accurate due to the participation of each department. And the night is often in the duty time period, only local information can be checked and adjusted, and because the number of the participating departments and equipment is small, various modification records generated by the department are often more comprehensive and cannot be compared with the records of the formal working time period in the day, so if two completely independent modification records for one equipment exist, the records of the day time period are often better than the records of the night duty time period, and the importance is stronger.
And if the first time is earlier than the second time and the running grade of the first time is higher than that of the second time, the record is not updated by adopting the content in the second incremental file.
And if the first time is earlier than the second time, but the running grade of the first time is not higher than that of the second time, adopting the content in the second incremental file to update the record by deletion.
And if the first time is later than the second time and the running grade of the first time is higher than or equal to that of the second time, the content in the second incremental file is not adopted to update the record.
And if the first time is later than the second time and the operation level of the first time is lower than that of the second time, updating the record by adopting the content in the second incremental file. In other embodiments, if the first time is later than the second time and the running level of the first time is lower than that of the second time, the record updating prompt is sent out and the record is updated by deleting the content in the second incremental file after the updating permission is obtained, otherwise, the record is not updated by deleting the content.
In another embodiment, a plurality of preset rules may be used in combination to determine whether the record related to the first terminal needs to be updated by using the second incremental file. For example, the above-mentioned judgment may be performed in cooperation with the recorded operator authority level and the recorded generation time period operation level, wherein the generation time period operation level may be mainly judged, and the operator authority level may be used as an auxiliary, specifically as follows.
After the first terminal downloads the second incremental file, if the same record object to be updated in the second incremental file exists in the first incremental file to be uploaded in the terminal, acquiring first time corresponding to record deletion from a timestamp of the first incremental file, acquiring second time corresponding to record deletion from a timestamp of the second incremental file, and comparing the running grades of the time periods of the first time and the second time, wherein the running grades are the polling intensity and/or the working intensity of each time period in which the mobile terminal is located.
And if the first time is earlier than the second time and the running grade of the first time is higher than that of the second time, the record is not updated by adopting the content in the second incremental file.
And if the first time is earlier than the second time but the running level of the first time is not higher than that of the second time, deleting and updating the record by adopting the content in the second incremental file.
And if the first time is later than the second time and the running grade of the first time is higher than or equal to the running grade of the second time, not adopting the content in the second incremental file to update the record.
If the first time is later than the second time and the operation level of the first time is lower than that of the second time, acquiring a first user ID for deleting the record from the first incremental file, acquiring a second user ID for deleting the record from the second incremental file, and acquiring the authority level corresponding to the user ID from the authority database according to each user ID; the authority database stores user ID and corresponding authority level for logging in each terminal to perform operations such as adding, deleting and the like on data. And if the first user authority level is higher than the second user authority level, deleting and updating the record without adopting the content in the second incremental file, otherwise deleting and updating the record again by adopting the content in the second incremental file. That is, although the first time is later than the second time, if the operation level of the first time is lower than the operation level of the second time and the first user permission level is also lower than the second user permission level, the content in the second incremental file is used to update the record by deletion again.
In this embodiment, when the first terminal modifies a part of records in an offline state to generate a first incremental file, and then subsequently switches to a network connection state, the first incremental file is downloaded from the server to obtain a second incremental file corresponding to the first terminal, and when both the first incremental file and the second incremental file have deletion and modification of the same record, the record deletion and modification information in the first incremental file and the second incremental file may be screened according to a preset rule to determine whether the record related to the first terminal needs to be updated by using the second incremental file. The preset rule may be as follows:
and acquiring a timestamp of the earliest deleted record in the first incremental file, calculating the minimum value of the offline duration of the first terminal according to the earliest timestamp, judging whether the minimum value of the offline duration is greater than a set time threshold, and updating the related record of the first terminal by adopting the second incremental file if the minimum value of the offline duration is greater than the set time threshold.
And if the minimum value of the offline duration time is not greater than the set time threshold, acquiring the first time of the same record deletion from the time stamp of the first incremental file, and acquiring the second time of the same record deletion from the time stamp of the second incremental file.
And if the first time is earlier than the second time, updating the same record in the first terminal by adopting a second incremental file.
If the first time is equal to the second time, the number of records to be updated and the time stamp which are contained in the second incremental file are obtained, if the number of records to be updated in the time period of the same record exceeds a preset value, the same record in the first terminal is updated by adopting the second incremental file, otherwise, the same record deleting and modifying information in the second incremental file is not adopted to update the first terminal.
And if the first time is later than the second time, the same record deletion and modification information in the second incremental file is not adopted to update the first terminal.
In the screening rule of the same record information in the incremental file adopted in this embodiment, the value of the minimum time for the duration of the offline state of the first terminal is obtained by determining the earliest record timestamp deleted in the first incremental file, and when the offline time of the first terminal is greater than a certain time, that is, a set time threshold value, it may be determined that the offline time of the first terminal is too long, the recorded data may be inaccurate, and at this time, it is preferable to update the offline time of the first terminal based on the second incremental file of the server. When the offline state of the first terminal is within the acceptable range, two same record deletion information with the same timestamp in the first incremental file and the second incremental file is generally based on the deletion information of the first terminal, but when the number of records to be updated in the time period of the record exceeds a preset value, it indicates that the time period may be that each terminal and server perform systematic record check, and at this time, the corresponding record of the first terminal is updated based on the same record deletion information in the second incremental file, where the time period span may be several preset hours, and is only a preset time span interval.
In other embodiments, after receiving the first incremental file uploaded by the first terminal and forwarded by the server, the other terminals that are always in an online state may also adopt a preset rule similar to that described in the above embodiments to filter the record deletion and modification information in the incremental file.
According to the method, under the network-free environment, any adding, deleting, modifying and checking operation of the mobile terminal only has a relation with a local sqlite database and does not have any relation with the server, and the incremental file in the form of the sql statement is stored in a local flash storage and uploaded to the server after the network is recovered. After the network is recovered, the mobile terminal uploads the incremental file to a server to update the database, and conversely, if the server has the incremental file, the server issues the incremental file to the mobile terminal, and the mobile terminal updates the sqlite database; any adding, deleting and modifying operations of the mobile terminal are completed in the server database and the local sqlite database synchronously. The business operation process of the electronic information system in the non-network environment of the factory workshop at the lowest cost is realized, the operation records and the operation results of all the mobile terminals and the fixed terminals can be uploaded and synchronized to the system database, and the data synchronization of the server system database and the local databases of all the terminals is kept.
Fig. 4 is a schematic diagram of another embodiment of a multi-terminal data synchronization system for intelligent manufacturing, including a server 1 and a plurality of terminals 2 connected to the server, where the terminals 2 may be mobile terminals or fixed terminals, a first terminal 21 is configured to download a complete table structure and SQL statements from the server and import the SQL statements into a local database, determine a network state after acquiring a deletion record instruction, store the deleted SQL statements and a timestamp into the local database if the deleted SQL statements are in a non-network state, and send a record locking request to the server through an http protocol if the deleted SQL statements are in a network connection state; after first response information replied by the server is received, a deletion and modification updating request is sent to the server through an http protocol; and the local database of the first terminal is not updated when the first response information or the second response information replied by the server is not received.
The server is configured to reject response to a record deletion request sent by other terminals before receiving an unlocking record request sent by a subsequent first terminal after returning first response information after receiving the locking record request, simultaneously place the locking record request into a memory queue and forward the locking record request to other terminals through websocket after next heartbeat arrives, if partial terminals fail to forward, the server stores an SQL incremental file with a timestamp for the corresponding terminal, and the locking record request is configured to prohibit the terminal receiving the request from deleting the record before receiving the unlocking record request; and operating according to the deletion and modification updating request, if the operation is successful, immediately returning second response information, simultaneously putting the deletion and modification updating forwarding request into a queue, and after the next heartbeat arrives, forwarding the deletion and modification updating forwarding request to other terminals through websocket for updating respective local databases, and if partial terminals fail to forward, saving the SQL incremental files with the time stamps for the corresponding terminals.
In this embodiment, the first terminal is further configured to update the local database after acquiring the new record instruction, and send a new update request to the server through an http protocol if the local database is in the network connection state. The server is further configured to operate according to the newly added update request, if the operation is successful, second response information is immediately returned, the newly added update request is placed in a queue, the newly added update request is forwarded to other terminals through the websocket after the next heartbeat is reached, the local databases of the terminals are used for updating, and if the forwarding of the second terminal 22 fails, the corresponding SQL incremental file with the timestamp is stored for the second terminal.
In this embodiment, the first terminal is further configured to, after acquiring the new record instruction, save the added or modified SQL statement and the timestamp as an incremental file to the local database, and suspend sending the new update request to the server when the terminal is in the no-network state; and requesting to upload the first incremental file to the server through an http protocol after the network connection state is switched to the network connection state again, and inquiring whether a downloadable second incremental file corresponding to the terminal exists in the server or not. And uploading the first incremental file to the server according to the uploading and downloading paths of the incremental files replied by the server, downloading the second incremental file at the same time, recombining the incremental files according to the SQL timestamp sequence, importing the incremental files into a local database, and stopping responding to a locking record request, a locking list request, a deletion update request or an addition update request sent by the server to the terminal before the incremental files are imported.
In this embodiment, the server is configured to continue to wait for multiple heartbeat cycles after receiving a first incremental file uploaded by the first terminal, send a lock table request broadcast to all terminals and stop responding to a new or modified update request sent by each terminal if an incremental file upload request of another terminal is not received, reassemble all incremental files according to an SQL timestamp sequence and then import the reassembled incremental files into the database, where the lock table request broadcast is configured to prohibit the terminal from sending a new or modified update request to the server until receiving an unlock request broadcast.
In this embodiment, after downloading the second incremental file, if the first incremental file to be uploaded in the terminal has the same record to be updated as that in the second incremental file, the first terminal is further configured to obtain a first user ID for deleting the record from the first incremental file, obtain a second user ID for deleting the record from the second incremental file, and obtain an authority level corresponding to the user ID from the database according to each user ID; if the first user authority level is higher than the second user authority level, deleting and updating the record without adopting the content in the second incremental file; if the first user permission level is not higher than the second user permission level, acquiring first time of the record deletion from the first incremental file timestamp, and acquiring second time of the record deletion from the second incremental file timestamp; and if the first user permission level is lower than or equal to the second user permission level and the first time is earlier than the second time, adopting the content in the second incremental file to delete and update the record.
The specific functions and implementation methods of the server and the first terminal of the multi-terminal data synchronization system for intelligent manufacturing correspond to the multi-terminal data synchronization method for intelligent manufacturing disclosed in the foregoing embodiments one-to-one, so that detailed descriptions are omitted again, and specific references may be made to the embodiments of the multi-terminal data synchronization method for intelligent manufacturing disclosed in the foregoing embodiments.
It should be noted that, in the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. The multi-terminal data synchronization system for intelligent manufacturing disclosed by the embodiment corresponds to the multi-terminal data synchronization method disclosed by the embodiment, so that the description is relatively simple, and the relevant points can be referred to the description of the method part.
In still other embodiments, there is provided a multi-terminal data synchronization apparatus for intelligent manufacturing, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the multi-terminal data synchronization method for intelligent manufacturing described in the above embodiments.
The multi-terminal data synchronization device for intelligent manufacturing can include, but is not limited to, a processor and a memory. It will be understood by those skilled in the art that the schematic diagram is merely an example of a multi-terminal data synchronizer for intelligent manufacturing and does not constitute a limitation of the multi-terminal data synchronizer for intelligent manufacturing, and may include more or fewer components than those shown, or combine certain components, or different components, for example, the multi-terminal data synchronizer for intelligent manufacturing may further include input-output devices, network access devices, buses, etc.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like, the processor is a control center of the apparatus for multi-terminal data synchronization for smart manufacturing, and various interfaces and lines are used to connect various parts of the entire apparatus for multi-terminal data synchronization for smart manufacturing.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the apparatus for multi-terminal data synchronization for smart manufacturing by executing or executing the computer programs and/or modules stored in the memory and calling the data stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function, and the like, and the memory may include a high speed random access memory, and may further include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
The multi-terminal data synchronization apparatus for smart manufacturing, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, all or part of the flow in the method according to the above embodiment may be realized by a computer program, which may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may realize the steps of the above-mentioned embodiments of the multi-terminal data synchronization method for intelligent manufacturing. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer-readable medium may contain suitable additions or subtractions depending on the requirements of legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer-readable media may not include electrical carrier signals or telecommunication signals in accordance with legislation and patent practice.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.
In summary, the above description is only a preferred embodiment of the present invention, and all the equivalent changes and modifications made according to the claims of the present invention should be covered by the present invention.

Claims (6)

1. A multi-terminal data synchronization method for intelligent manufacturing is characterized by comprising the following steps:
s1, the first terminal downloads the complete table structure and SQL sentences from the server and imports the table structure and SQL sentences into a local database;
s2, the first terminal judges the network state after obtaining the deletion record instruction, if the first terminal is in the non-network state, the first terminal saves the deleted SQL statement and the timestamp into the local database, and if the first terminal is in the network connection state, the first terminal sends a record locking request to the server through the http protocol;
s3, if the server receives the locking record request, it returns the first response information, and refuses the response to the record deleting request sent by other terminals before receiving the unlocking record request sent by the first terminal, at the same time, it puts the locking record request into the memory queue and forwards it to other terminals through websocket after the next heartbeat arrives, if there is some terminal forwarding failure, it saves the SQL increment file with time stamp for the corresponding terminal, the locking record request is configured to prohibit the terminal receiving the request from deleting the record before receiving the unlocking record request;
s4, if the first terminal receives the first response information replied by the server, the first terminal sends a deletion and update request to the server through an http protocol;
s5, the server operates according to the deletion, update and request, if the operation is successful, the server immediately returns second response information, and simultaneously puts the deletion, update and forwarding request into a queue, forwards the next heartbeat to other terminals through websocket for updating respective local databases, if partial terminal forwarding fails, the server saves SQL incremental files with time stamps for the corresponding terminals;
s6, if the first terminal does not receive the first response information or the second response information replied by the server, the local database of the first terminal is not updated, otherwise, an unlocking request is sent to the server after the local database is updated;
after acquiring a newly added recording instruction, the first terminal saves the added or modified SQL statement and a timestamp as an incremental file to a local database, and if the first terminal is in a network-free state, the first terminal suspends sending a newly added updating request to the server;
the first terminal requests the server to upload the first incremental file through the http protocol after being switched to the network connection state again, and queries whether a downloadable second incremental file corresponding to the terminal exists in the server or not;
the method comprises the steps that a first terminal uploads a first incremental file to a server according to an incremental file uploading and downloading path replied by the server, downloads a second incremental file at the same time, reorganizes the incremental files according to an SQL timestamp sequence, then imports the incremental files into a local database, and stops responding to a locking record request, a locking table request, a deletion update request or an addition update request sent to the terminal by the server before the incremental files are imported;
the method comprises the steps that a server continues to wait for a plurality of heartbeat cycles after receiving a first incremental file uploaded by a first terminal, if an incremental file uploading request of other terminals is not received, a lock table request broadcast is sent to all terminals, a response of a new increase or deletion updating request sent by each terminal is stopped, all incremental files are recombined according to an SQL time stamp sequence and then are led into a database, and the lock table request broadcast is configured to prohibit the terminals from sending new increase or deletion updating requests to the server until receiving an unlocking request broadcast.
2. The multi-terminal data synchronization method for smart manufacturing according to claim 1, further comprising the steps of:
the first terminal updates the local database after acquiring the newly added recording instruction, and sends a newly added updating request to the server through an http protocol if the first terminal is in a network connection state;
and the server operates according to the newly-added updating request, immediately returns second response information if the operation is successful, simultaneously places the newly-added updating request into a queue, forwards the newly-added updating request to other terminals through websocket after the next heartbeat arrives for updating local databases of all terminals, and stores corresponding SQL incremental files with time stamps for the second terminal if the transmission failure of the second terminal exists.
3. The multi-terminal data synchronization method for smart manufacturing of claim 2, further comprising the steps of:
after the first terminal downloads the second incremental file, if the first incremental file to be uploaded in the terminal has the same record to be updated as the second incremental file, acquiring a first user ID for deleting the record from the first incremental file, acquiring a second user ID for deleting the record from the second incremental file, and acquiring the authority level corresponding to the user ID from the database according to the user IDs;
if the first user authority level is higher than the second user authority level, deleting and updating the record without adopting the content in the second incremental file;
if the first user permission level is not higher than the second user permission level, acquiring first time of the record deletion from the first incremental file timestamp, and acquiring second time of the record deletion from the second incremental file timestamp;
and if the first user permission level is lower than or equal to the second user permission level and the first time is earlier than the second time, adopting the content in the second incremental file to delete and update the record.
4. A multi-terminal data synchronization system for smart manufacturing, comprising:
the first terminal is configured to download a complete table structure and SQL sentences from the server, import the table structure and the SQL sentences into a local database, judge the network state after acquiring a deletion record instruction, save the deleted SQL sentences and a timestamp into the local database if the deleted SQL sentences and the timestamp are in a non-network state, and send a record locking request to the server through an http protocol if the deleted SQL sentences and the timestamp are in a network connection state; after receiving first response information replied by the server, sending a deletion and modification updating request to the server through an http protocol; when the first response information or the second response information replied by the server is not received, the local database of the first terminal is not updated; after a newly added recording instruction is obtained, adding a timestamp to the added or modified SQL statement as an incremental file and storing the incremental file to a local database, and pausing to send a newly added updating request to a server when the SQL statement is in a network-free state; after the network connection state is switched to the network connection state again, the first incremental file is requested to be uploaded to the server through an http protocol, and whether a downloadable second incremental file corresponding to the terminal exists in the server or not is inquired; uploading the first incremental file to a server according to an incremental file uploading and downloading path replied by the server, simultaneously downloading a second incremental file, recombining the incremental files according to the SQL timestamp sequence, importing the incremental files into a local database, and stopping responding to a locking record request, a locking list request, a deletion update request or an addition update request sent by the server to the terminal before the incremental files are imported;
the server is configured to reject response to a record deletion request sent by other terminals before receiving an unlocking record request sent by a subsequent first terminal after returning first response information after receiving the locking record request, simultaneously place the locking record request into a memory queue and forward the locking record request to other terminals through websocket after next heartbeat arrives, if partial terminals fail to forward, the server stores an SQL incremental file with a timestamp for the corresponding terminal, and the locking record request is configured to prohibit the terminal receiving the request from deleting the record before receiving the unlocking record request; the operation is carried out according to the deletion update request, if the operation is successful, second response information is immediately returned, the deletion update forwarding request is put into a queue, the deletion update forwarding request is forwarded to other terminals through websocket after the next heartbeat is reached for updating respective local databases, and if partial terminal forwarding fails, SQL incremental files with timestamps are stored for the corresponding terminals; the method comprises the steps that a plurality of heartbeat cycles are continuously waited after a first increment file uploaded by a first terminal is received, if increment file uploading requests of other terminals are not received, a lock table request broadcast is sent to all terminals, responses to newly added or deleted updating requests sent by all terminals are stopped, all increment files are recombined according to an SQL time stamp sequence and then are led into a database, and the lock table request broadcast is configured to prohibit the terminals from sending the newly added or deleted updating requests to a server until unlocking request broadcast is received.
5. The multi-terminal data synchronization system for smart manufacturing of claim 4, wherein:
the first terminal is also configured to update the local database after acquiring the new record instruction, and if the first terminal is in a network connection state, a new update request is sent to the server through an http protocol;
and the server is also configured to operate according to the newly-added updating request, if the operation is successful, second response information is immediately returned, the newly-added updating request is put into a queue, the newly-added updating request is forwarded to other terminals through the websocket after the next heartbeat is reached for updating the local databases of the terminals, and if the second terminal fails to forward, the corresponding SQL incremental file with the timestamp is stored for the second terminal.
6. The multi-terminal data synchronization system for intelligent manufacturing of claim 5, wherein the first terminal is further configured to:
after downloading the second incremental file, if the first incremental file to be uploaded in the terminal has the same record to be updated as the second incremental file, acquiring a first user ID for deleting the record from the first incremental file, acquiring a second user ID for deleting the record from the second incremental file, and acquiring the authority level corresponding to the user ID from a database according to each user ID;
if the first user authority level is higher than the second user authority level, deleting and updating the record without adopting the content in the second incremental file;
if the first user permission level is not higher than the second user permission level, acquiring first time of the record deletion from the first incremental file timestamp, and acquiring second time of the record deletion from the second incremental file timestamp;
and if the first user permission level is lower than or equal to the second user permission level and the first time is earlier than the second time, adopting the content in the second incremental file to delete and update the record.
CN202110777577.3A 2021-07-09 2021-07-09 Multi-terminal data synchronization method and system for intelligent manufacturing Active CN113407635B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110777577.3A CN113407635B (en) 2021-07-09 2021-07-09 Multi-terminal data synchronization method and system for intelligent manufacturing

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110777577.3A CN113407635B (en) 2021-07-09 2021-07-09 Multi-terminal data synchronization method and system for intelligent manufacturing

Publications (2)

Publication Number Publication Date
CN113407635A CN113407635A (en) 2021-09-17
CN113407635B true CN113407635B (en) 2022-06-03

Family

ID=77685726

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110777577.3A Active CN113407635B (en) 2021-07-09 2021-07-09 Multi-terminal data synchronization method and system for intelligent manufacturing

Country Status (1)

Country Link
CN (1) CN113407635B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114116842B (en) * 2021-11-25 2023-05-19 上海柯林布瑞信息技术有限公司 Multidimensional medical data real-time acquisition method and device, electronic equipment and storage medium
CN116011026B (en) * 2023-03-23 2023-06-16 西安热工研究院有限公司 Database configuration security rapid verification method, system, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515935A (en) * 2009-03-17 2009-08-26 深圳华为通信技术有限公司 Data synchronization method and server
CN101901237A (en) * 2009-12-04 2010-12-01 四川川大智胜软件股份有限公司 Type-Index-Value distributed database built based on SQIite
CN109873857A (en) * 2018-12-26 2019-06-11 广州凡象科技有限公司 Mobile terminal method of data synchronization and device under a kind of no network state
CN111756794A (en) * 2020-05-06 2020-10-09 上海明略人工智能(集团)有限公司 Data synchronization method and mobile terminal
CN111881150A (en) * 2020-09-24 2020-11-03 深圳市互联工场科技有限公司 Web application program offline data processing method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2004036344A2 (en) * 2002-10-15 2004-04-29 Active-Base Ltd. System and method for the optimization of database
US9626250B2 (en) * 2015-03-16 2017-04-18 International Business Machines Corporation Data synchronization of block-level backup

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515935A (en) * 2009-03-17 2009-08-26 深圳华为通信技术有限公司 Data synchronization method and server
CN101901237A (en) * 2009-12-04 2010-12-01 四川川大智胜软件股份有限公司 Type-Index-Value distributed database built based on SQIite
CN109873857A (en) * 2018-12-26 2019-06-11 广州凡象科技有限公司 Mobile terminal method of data synchronization and device under a kind of no network state
CN111756794A (en) * 2020-05-06 2020-10-09 上海明略人工智能(集团)有限公司 Data synchronization method and mobile terminal
CN111881150A (en) * 2020-09-24 2020-11-03 深圳市互联工场科技有限公司 Web application program offline data processing method and device

Also Published As

Publication number Publication date
CN113407635A (en) 2021-09-17

Similar Documents

Publication Publication Date Title
US10764369B2 (en) Data storage method and server applicable to distributed server cluster
CN113407635B (en) Multi-terminal data synchronization method and system for intelligent manufacturing
CN107332876B (en) Method and device for synchronizing block chain state
CN113407555B (en) Operation data updating method and system of equipment handheld terminal
CN113407636B (en) Offline data synchronization method and device for digital factory and server
EP2706719B1 (en) File synchronization method and device
CN111291000B (en) File acquisition method, equipment and storage medium based on block chain
EP3480686B1 (en) Data processing method, cluster manager, resource manager and data processing system
CN112039718B (en) Upgrade state detection method, server, equipment and storage medium
CN113837636A (en) Service data acquisition method, device, equipment and storage medium
CN114363313A (en) Device control method, server, and storage medium
CN110545207B (en) Synchronous automatic intelligent DNS system and configuration method
CN113779153A (en) Data synchronization method and device, electronic equipment and storage medium
CN111008209B (en) Data reconciliation method, device and system, storage medium and electronic device
US20120054157A1 (en) Database apparatus, database consistency system, and database consistency method
CN115002507A (en) Video data updating method, device, equipment and readable storage medium
CN113064906B (en) Binlog log data adaptive migration method and system
CN112968921B (en) Data updating method, device and computer readable storage medium
CN111240933B (en) Method, system, device and medium for monitoring performance data of multiple data centers
CN110266536B (en) Internet of vehicles resource management method and device
CN112749142B (en) Handle management method and system
CN115114303A (en) Service data auditing method, platform and system
CN110740192A (en) mirror image distribution method and system in P2P network-based virtualization environment
CN108184141B (en) Processing method of monitoring video task and server
CN114697985A (en) Wireless operation and maintenance system registration method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
CB02 Change of applicant information

Address after: 310056 room 1701, 17th floor, building 3, No. 316, Jianghong South Road, Changhe street, Binjiang District, Hangzhou, Zhejiang

Applicant after: Mingdu Zhiyun (Zhejiang) Technology Co.,Ltd.

Address before: 310000 1, 3 building, No. 316 Jianghong Road, Changhe street, Binjiang District, Hangzhou, Zhejiang.

Applicant before: ZHEJIANG MINGDU INTELLIGENT CONTROL TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant