Order information processing method and device, computer device, and storage medium
By creating multiple backup databases from the primary database and defining auto-incrementing fields, the problem of limited order information writes during database failures was solved, enabling automatic numbering maintenance and simplified switching processes, thus ensuring the normal writing of order information.
Patent Information
- Application Number
- CN202111520621.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-13
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2041-12-13
AI Technical Summary
In the event of a database failure, the number of switching operations during the order information writing process is limited in existing technologies, which affects normal writing.
Multiple backup databases are created by creating a primary database. Each backup database is pre-assigned an address and a blank data table. The number field is defined as an auto-incrementing field. When the primary database fails, the address of the backup database is obtained, the starting number of the blank data table is extracted, order information is read one by one from the data source, normalized and sorted according to the preset order type, and written into the blank data table according to the sorting result.
It enables automatic maintenance of the serial number field in the event of a database failure, reducing the possibility of serial number errors, simplifying the switching process, and ensuring the normal writing of order information.
Smart Images

Figure CN114187073B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular, the present application relates to an order information processing method and device, computer equipment and storage medium. BACKGROUND
[0002] The transaction of the bidding platform is declared through the bidding software, and the process of the transaction declaration processing is roughly as follows: the transaction system of the member institution writes the order information into the data table of the database, the bidding software reads the order information from the data table, and transmits the order information to the transaction system of the exchange through the TCP / IP protocol.
[0003] In order to ensure that the background does not lose or duplicate the order information submitted by the member institution when processing the order information, the exchange generally defines a number field in the data table, and requires that the value of this field in the declaration record must be "continuous and unique".
[0004] However, if the data table of the database is completely damaged, then in order to complete the writing of the subsequent order information, the subsequent order information needs to be directly inserted in the new empty data table. When switching, the number of the subsequent order information must exceed the number of the order information sent to the exchange to avoid duplication, but the number of switching is limited, which affects the normal writing of the order information. For example, the first order information is to 8978, the database fails and needs to be switched, then only needs to be directly inserted from the number 10000001 in the data table to avoid duplication. If it needs to be switched again, then directly write the new order information from the number 20000001. Similarly. However, since the number field in the original interface design is 10 8 Therefore, the number of switching is limited. SUMMARY
[0005] The main purpose of the present application is to provide an order information processing method and device, computer equipment and storage medium, to ensure the normal writing of the order information.
[0006] In order to achieve the above-mentioned purpose of the application, the present application provides an order information processing method, which comprises:
[0007] When detecting the failure of the main database, the address of the standby database corresponding to the main database is obtained;
[0008] According to the address, the standby database is queried, the pre-stored empty data table in the standby database is extracted, and the starting number of the empty data table is determined; wherein the number field of the empty data table is a self-incrementing field;
[0009] The order information to be written is read from the data source piece by piece; wherein the order information comprises an order type;
[0010] The read order information is normalized and sorted according to the preset order type to obtain the sorting result;
[0011] According to the sorting result, the order information is sequentially written into the blank data table starting from the starting number to obtain the target data table.
[0012] Furthermore, prior to detecting a main database failure, the process also includes:
[0013] Obtain the number of primary databases, and create multiple standby databases for each primary database;
[0014] Each of the backup databases is assigned an address and several blank data tables, and the fields of the blank data tables are defined as auto-incrementing fields.
[0015] Set a starting number for each blank data table corresponding to the backup database.
[0016] Preferably, the step of normalizing and sorting the read order information according to a preset order type to obtain a sorting result includes:
[0017] Extract the order type from each order's information;
[0018] Filter out order information that belongs to the preset order type to obtain multiple target order information;
[0019] The multiple target order information is prioritized and sorted adjacently, and the remaining order information that does not belong to the preset order type is placed after the multiple target order information to obtain the sorting result.
[0020] Preferably, the step of normalizing and sorting the read order information according to a preset order type to obtain a sorting result includes:
[0021] Extract the order type from each order's information;
[0022] Calculate the similarity between the order type of each order and the preset order type;
[0023] The order information is sorted according to the degree of similarity to obtain the sorting result.
[0024] Preferably, calculating the similarity between the order type of each order and the preset order type includes:
[0025] Extract the keywords for the order type from each order information to obtain the first keyword for each order information;
[0026] Extract keywords from the preset order type to obtain the second keyword;
[0027] Calculate the similarity between the first keyword and the second keyword for each order.
[0028] Preferably, calculating the similarity between the first keyword and the second keyword for each order information includes:
[0029] The first keyword of each order information is converted into a word vector using a preset word vector tool, thus obtaining the first word vector of each order information;
[0030] The second keyword is converted into a word vector using a preset word vector tool to obtain the second word vector;
[0031] Calculate the cosine distance between the first word vector and the second word vector for each order information to obtain the similarity between the first keyword and the second keyword for each order information.
[0032] Furthermore, after sequentially writing the order information into the blank data table starting from the starting number, the method further includes:
[0033] The order information written into the blank data table is grouped according to preset rules; wherein each group of order information has commonalities or similarities.
[0034] Determine if there are duplicate data in the order information within each group;
[0035] If so, remove the duplicate data from the order information within each group.
[0036] This application also provides an order information processing apparatus, which includes:
[0037] The acquisition module is used to acquire the address of the backup database corresponding to the primary database when a primary database failure is detected.
[0038] The query module is used to query the backup database based on the address, extract the pre-stored blank data table in the backup database, and determine the starting number of the blank data table; wherein, the number field of the blank data table is an auto-incrementing field;
[0039] The reading module is used to read the order information to be written from the data source one by one; wherein, the order information includes the order type;
[0040] The sorting module is used to normalize and sort the read order information according to the preset order type to obtain the sorting result;
[0041] The writing module is used to sequentially write the order information into the blank data table according to the sorting result, starting from the starting number, to obtain the target data table.
[0042] This application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of any of the methods described above.
[0043] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the methods described above.
[0044] This application provides an order information processing method, apparatus, computer equipment, and storage medium. When a primary database failure is detected, the address of the corresponding backup database is obtained. The backup database is queried based on the address, and a pre-stored blank data table is extracted. The starting number of the blank data table is determined. Order information to be written is read one by one from the data source. The read order information is normalized and sorted according to a preset order type to obtain a sorting result. Based on the sorting result, the order information is sequentially written into the blank data table starting from the starting number to obtain the target data table. This achieves automatic maintenance of the number field. When the service abnormally exits and restarts, there is no need to restore the number, minimizing the possibility of sequence number errors. Furthermore, since the number is maintained by the database, the program does not need to re-arrange subsequent numbers when a certain order information has an error, allowing it to focus on business processing and simplifying the overall processing flow. Moreover, when a database failure requires switching, there is no need to query the last written maximum number; it only needs to be written to the pre-stored blank table, reducing the possibility of errors, simplifying the switching process, and ensuring the normal writing of order information. Attached Figure Description
[0045] Figure 1 This is a flowchart illustrating an order information processing method according to an embodiment of this application;
[0046] Figure 2 This is a schematic block diagram of the structure of an order information processing device according to an embodiment of this application;
[0047] Figure 3 This is a schematic block diagram of the structure of a computer device according to an embodiment of this application.
[0048] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0050] The order information processing method proposed in this application uses a server as the execution entity. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0051] This order information processing method addresses the technical issue of limited switchover opportunities during order information writing due to database failures, which hinders the normal writing of order information. (Reference) Figure 1 In one embodiment, the order information processing method includes:
[0052] S11. When a primary database failure is detected, obtain the address of the backup database corresponding to the primary database;
[0053] S12. Query the backup database according to the address, extract the pre-stored blank data table in the backup database, and determine the starting number of the blank data table; wherein, the number field of the blank data table is an auto-incrementing field;
[0054] S13. Read the order information to be written from the data source one by one; wherein, the order information includes the order type;
[0055] S14. Normalize and sort the read order information according to the preset order type to obtain the sorting result;
[0056] S15. According to the sorting result, starting from the starting number, write the order information sequentially into the blank data table to obtain the target data table.
[0057] As described in steps S11-S12 above, in this embodiment, the main database and the backup database can be an offer database, used to store order information such as declaration data. An offer, also called a quotation, is when the seller proactively provides product information to the buyer, or responds to an inquiry. It is a offer made by the seller to the buyer based on the buyer's letter, and its content may include product name, specifications, quantity, packaging conditions, price, payment method, and delivery period. After the offer is made, corresponding order information is generated and stored in the database's data table for the transaction system to access when needed.
[0058] In this embodiment, multiple backup databases are pre-created for each primary database. Each backup database stores at least one blank data table. The number of blank data tables can be increased as needed. These tables are used to store order information that needs to be written subsequently in the event of a primary database failure. Therefore, multiple switching is possible to ensure the normal writing of order information. For example, when a database failure requires switching data tables, the system checks whether the backup database contains a blank data table. If not, a blank data table is retrieved from the backup database, and a new blank data table is created in that backup database for subsequent order information writing. If a blank data table exists, it is retrieved from the backup database, and the order information to be written subsequently is stored in that blank data table. Therefore, it is not necessary to query the maximum number written last time; the information is simply written to the pre-stored blank table, reducing the possibility of errors.
[0059] When creating a blank data table, this application defines the table's number field as an auto-incrementing field. For blank data tables in different backup databases, a starting number can be pre-assigned, so that when the primary database fails and a switchover is needed, minimal manual intervention is required, as the database itself can guarantee the skipping of the sequence number range.
[0060] Specifically, when the server detects a failure in the primary database, it obtains the address of the corresponding backup database. This address is used to query the backup database. The server then retrieves blank data tables from the backup database based on the address and determines the starting number of the blank data tables.
[0061] As described in steps S13-S15 above, the data source can be a unified interface for users to upload order information. In this embodiment, all order information to be written is read from the data source one by one, the order type of each order information is determined, and all read order information can be normalized and sorted according to the preset order type to obtain the sorting result. The preset order type can be customized. Taking the order types in the securities field as an example, a mature securities market generally has six order types: market buy, market sell, limit buy, limit sell, stop-loss buy, and stop-loss sell. If the preset order type is market buy, then the order information with the order type of market buy is selected from all read order information, and the market buy order information is ranked first, while the order information of the other order types is ranked last, thus completing the sorting of all order information and obtaining the sorting result. Furthermore, the sorting of all order information can be further subdivided, such as assigning a number to each order information and sorting according to this number, so that the required order information can be retrieved later based on this number.
[0062] In this embodiment, all order information is sequentially written into the blank data table according to the sorting result, starting from the starting number of the blank data table, to obtain the target data table. Subsequently, order information can be obtained from the target data table that has been pre-written into the database. Only the database address accessed by the quoting program needs to be modified. After switching, subsequent order information will be automatically numbered according to the starting number set in the new database.
[0063] For example, if the order information to be written later includes A, B, and C, and the corresponding order is A>B>C, then order information A is written to the position corresponding to the starting number in the blank data table, order information B is written to the position after order information A in the blank data table, and order information C is written to the position after order information B in the blank data table, thus completing the writing of all order information.
[0064] The order information processing method provided in this application involves obtaining the address of the corresponding backup database when a primary database failure is detected. The backup database is then queried based on the address, and a pre-stored blank data table is extracted. The starting number of the blank data table is determined, and order information to be written is read sequentially from the data source. The read order information is then normalized and sorted according to a preset order type to obtain a sorting result. Based on the sorting result, the order information is sequentially written into the blank data table starting from the starting number, resulting in the target data table. This achieves automatic maintenance of the number field, eliminating the need to restore the numbering when the service abnormally exits and restarts, thus minimizing the possibility of sequence number errors. Furthermore, since the numbering is maintained by the database, the program does not need to re-arrange subsequent numbers when an order information error occurs, allowing it to focus on business processing and simplifying the overall processing flow. Moreover, when a database failure requires a switchover, there is no need to query the last written maximum number; the information is simply written to the pre-stored blank table, reducing the possibility of errors, simplifying the switchover process, and ensuring the normal writing of order information.
[0065] In one embodiment, prior to detecting a primary database failure, the process may further include:
[0066] Obtain the number of primary databases, and create multiple standby databases for each primary database;
[0067] Each of the backup databases is assigned an address and several blank data tables, and the fields of the blank data tables are defined as auto-incrementing fields.
[0068] Set a starting number for each blank data table corresponding to the backup database.
[0069] In this embodiment, a primary database and a backup database can be created. One to N backup databases can be created for switching purposes. In the creation script, the numbers of the blank data tables in the backup databases can be defined as auto-incrementing types. At the same time, a reasonable starting number is assigned to the auto-incrementing sequence number of each data table in each database, greatly simplifying the writing of order information. When a database failure requires switching, only the database address accessed by the program needs to be modified. After the switch, subsequent order information will be automatically written according to the initial number set in the blank data tables of the backup database. Specifically, this can be done using the following SQL commands:
[0070] DBCC CHECKIDENT(ordwth); ---- View the current number of the auto-incrementing sequence number in the ordwth table;
[0071] DBCC CHECKIDENT(ordwth,RESEED,10000000); ---- Sets the current auto-incrementing serial number in a blank data table to 10000000.
[0072] Specifically, in this embodiment, the number of primary databases is obtained, and multiple backup databases are created for each primary database, such as three backup databases corresponding to one primary database. Then, an address and several blank data tables are assigned to each backup database. The number of blank data tables can be set according to the number of failures that have occurred in the history of the primary database. The fields of the blank data tables are defined as auto-incrementing fields, and a starting number is set for the blank data tables corresponding to each backup database.
[0073] In one embodiment, the step of normalizing and sorting the read order information according to a preset order type to obtain a sorting result may specifically include:
[0074] Extract the order type from each order's information;
[0075] Filter out order information that belongs to the preset order type to obtain multiple target order information;
[0076] The multiple target order information is prioritized and sorted adjacently, and the remaining order information that does not belong to the preset order type is placed after the multiple target order information to obtain the sorting result.
[0077] This embodiment obtains order information by selecting order types that belong to preset order types from the order information, resulting in multiple target order information. These target order information is then prioritized and sorted, such as by ranking the top-ranked orders and by placing them adjacent to each other. The remaining order information that does not belong to the preset order types is then obtained and placed after the target order information, ultimately resulting in a sorted order result. This sorted order information is then systematically extracted according to the sorting result and written into a blank data table starting from the initial number. This systematic writing of order information facilitates the subsequent extraction of order information from the target data table by the transaction system.
[0078] In one embodiment, the step of normalizing and sorting the read order information according to a preset order type to obtain a sorting result may specifically include:
[0079] Extract the order type from each order's information;
[0080] Calculate the similarity between the order type of each order and the preset order type;
[0081] The order information is sorted according to the degree of similarity to obtain the sorting result.
[0082] In this embodiment, the order type of each order information is extracted, and then the similarity between the order type of each order information and the preset order type is calculated. The order information is sorted according to the similarity between the order type of each order information and the preset order type, and finally the sorting result is obtained so that the order information with higher similarity to the preset order type is ranked first, which is convenient for subsequent extraction.
[0083] Similarity is used to compare the similarity between two things. It's generally calculated by determining the distance between features of the items; a smaller distance indicates higher similarity, and a larger distance indicates lower similarity. For example, for two fruits, similarity might be compared based on features such as color, size, and vitamin content. Similarly, the similarity can be calculated by comparing the Euclidean or cosine distance between the order type of each order and a preset order type.
[0084] Euclidean distance is the most commonly used distance calculation formula, measuring the absolute distance between points in a multidimensional space. It performs well when the data is dense and continuous. Because the calculation is based on the absolute values of features in each dimension, Euclidean metric requires that all dimensions be on the same scale. For example, using Euclidean distance for indicators with different units, such as height and weight, may invalidate the results. Cosine similarity uses the cosine of the angle between two vectors in a vector space to measure the difference between two individuals. Compared to distance metrics, cosine similarity focuses more on the difference in direction between two vectors, rather than distance or length.
[0085] In one embodiment, calculating the similarity between the order type of each order and the preset order type may specifically include:
[0086] Extract the keywords for the order type from each order information to obtain the first keyword for each order information;
[0087] Extract keywords from the preset order type to obtain the second keyword;
[0088] Calculate the similarity between the first keyword and the second keyword for each order.
[0089] In this embodiment, keywords for the order type of each order information are extracted to obtain the first keyword for each order information. The first keyword is a key word used to characterize the order type and is generally a noun. Keywords for a preset order type are also extracted to obtain the second keyword. The second keyword is a key word used to characterize the preset order type and is also generally a noun. Then, the similarity between the first keyword and the second keyword for each order information is calculated to accurately compare the similarity between the order type of each order information and the preset order type.
[0090] In one embodiment, calculating the similarity between the first keyword and the second keyword for each order information may specifically include:
[0091] The first keyword of each order information is converted into a word vector using a preset word vector tool, thus obtaining the first word vector of each order information;
[0092] The second keyword is converted into a word vector using a preset word vector tool to obtain the second word vector;
[0093] Calculate the cosine distance between the first word vector and the second word vector for each order information to obtain the similarity between the first keyword and the second keyword for each order information.
[0094] In this embodiment, the word vector tool word2vec is used to convert the first keyword of each order information into a word vector, thus obtaining the first word vector of each order information. At the same time, the word vector tool word2vec is used to convert the second keyword into a word vector, thus obtaining the second word vector. Then, the cosine distance between each first word vector and the second word vector is calculated and used as the similarity between the first keyword and the second keyword of each order information.
[0095] Word vectors are a representation of words that enable computers to process them. In natural language processing tasks, to hand natural language over to machine learning algorithms, it is usually necessary to first mathematically represent the language so that the machine can recognize and process it. Vectors are abstractions of things from nature that humans use to process machines; essentially, vectors are the primary way humans input information into machines.
[0096] Word2vec's output word vectors can be used for many natural language processing tasks, such as clustering, finding synonyms, and part-of-speech tagging. If words are treated as features, Word2vec can map these features to a K-dimensional vector space, allowing for deeper feature representations of text data. Specifically, Word2vec takes the words in the context of a given word as input and the word itself as output; that is, given a context, it aims to roughly infer the word and its meaning. Through training on a large corpus, a weighted model from the input layer to the hidden layer is obtained. After training, the weights of each word in each dimension of the hidden layer are obtained, resulting in the word's vector.
[0097] In one embodiment, when each order information includes multiple first keywords, the word vector tool word2vec is used to convert each first keyword into a word vector to obtain multiple target word vectors. The average value of the multiple target word vectors is calculated and used as the first word vector of each order information.
[0098] Similarly, when the preset order type includes multiple secondary keywords, the word vector tool word2vec is used to convert each secondary keyword into a word vector, resulting in multiple reference word vectors. The average value of the multiple reference word vectors is calculated and used as the second word vector for the preset order type.
[0099] In one embodiment, after sequentially writing the order information into the blank data table starting from the starting number, the process may further include:
[0100] The order information written into the blank data table is grouped according to preset rules; wherein each group of order information has commonalities or similarities.
[0101] Determine if there are duplicate data in the order information within each group;
[0102] If so, remove the duplicate data from the order information within each group.
[0103] In this embodiment, the order information written into the blank data table is grouped according to a preset rule. The preset rule may be to assign order information of the same order type to the same group, so that each group of order information has commonalities or similarities. Then, the data of each order information is traversed to determine whether there is duplicate data in the order information in each group. If so, the duplicate data in the order information in each group is removed.
[0104] Reference Figure 2 This application also provides an order information processing device, including:
[0105] The acquisition module 11 is used to acquire the address of the backup database corresponding to the main database when a failure of the main database is detected;
[0106] The query module 12 is used to query the backup database according to the address, extract the pre-stored blank data table in the backup database, and determine the starting number of the blank data table; wherein, the number field of the blank data table is an auto-incrementing field;
[0107] The reading module 13 is used to read the order information to be written from the data source one by one; wherein, the order information includes the order type;
[0108] Sorting module 14 is used to normalize and sort the read order information according to the preset order type to obtain the sorting result;
[0109] The writing module 15 is used to write the order information sequentially into the blank data table according to the sorting result, starting from the starting number, to obtain the target data table.
[0110] In this embodiment, the primary database and the backup database can be an offer database, used to store order information such as declaration data. An offer, also called a quotation, is when the seller proactively provides product information to the buyer, or responds to an inquiry. It is a offer made by the seller to the buyer based on the buyer's letter, and its content may include product name, specifications, quantity, packaging conditions, price, payment method, and delivery deadline. After an offer is made, corresponding order information is generated and stored in a data table in the database for the transaction system to access when needed.
[0111] In this embodiment, multiple backup databases are pre-created for each primary database. Each backup database stores at least one blank data table. The number of blank data tables can be increased as needed. These tables are used to store order information that needs to be written subsequently in the event of a primary database failure. Therefore, multiple switching is possible to ensure the normal writing of order information. For example, when a database failure requires switching data tables, the system checks whether the backup database contains a blank data table. If not, a blank data table is retrieved from the backup database, and a new blank data table is created in that backup database for subsequent order information writing. If a blank data table exists, it is retrieved from the backup database, and the order information to be written subsequently is stored in that blank data table. Therefore, it is not necessary to query the maximum number written last time; the information is simply written to the pre-stored blank table, reducing the possibility of errors.
[0112] When creating a blank data table, this application defines the table's number field as an auto-incrementing field. For blank data tables in different backup databases, a starting number can be pre-assigned, so that when the primary database fails and a switchover is needed, minimal manual intervention is required, as the database itself can guarantee the skipping of the sequence number range.
[0113] Specifically, when the server detects a failure in the primary database, it obtains the address of the corresponding backup database. This address is used to query the backup database. The server then retrieves blank data tables from the backup database based on the address and determines the starting number of the blank data tables.
[0114] The data source can be a unified interface for users to upload order information. In this embodiment, all order information to be written is read from the data source one by one, the order type of each order is determined, and all read order information can be normalized and sorted according to a preset order type to obtain a sorting result. The preset order type can be customized. Taking the order types in the securities field as an example, a mature securities market generally has six order types: market buy, market sell, limit buy, limit sell, stop-loss buy, and stop-loss sell. If the preset order type is market buy, then the order information with the order type of market buy is selected from all read order information, and the market buy order information is ranked first, while the order information of the other order types is ranked last, thus completing the sorting of all order information and obtaining a sorting result. Furthermore, the sorting of all order information can be further subdivided, such as assigning a number to each order information and sorting according to this number, so that the required order information can be retrieved later based on this number.
[0115] In this embodiment, all order information is sequentially written into the blank data table according to the sorting result, starting from the starting number of the blank data table, to obtain the target data table. Subsequently, order information can be obtained from the target data table that has been pre-written into the database. Only the database address accessed by the quoting program needs to be modified. After switching, subsequent order information will be automatically numbered according to the starting number set in the new database.
[0116] For example, if the order information to be written later includes A, B, and C, and the corresponding order is A>B>C, then order information A is written to the position corresponding to the starting number in the blank data table, order information B is written to the position after order information A in the blank data table, and order information C is written to the position after order information B in the blank data table, thus completing the writing of all order information.
[0117] As described above, it is understood that each component of the order information processing apparatus proposed in this application can realize the function of any of the order information processing methods described above, and the specific structure will not be described in detail.
[0118] Reference Figure 3 This application also provides a computer device whose internal structure can be as follows: Figure 3 As shown. The computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes a storage medium and internal memory. The storage medium stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the storage medium. The database stores data related to the order information processing method. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements an order information processing method.
[0119] The processor described above executes the order information processing method described above, including:
[0120] When a primary database failure is detected, obtain the address of the backup database corresponding to the primary database;
[0121] The backup database is queried based on the address, and a pre-stored blank data table is extracted from the backup database to determine the starting number of the blank data table; wherein, the number field of the blank data table is an auto-incrementing field;
[0122] Read the order information to be written one by one from the data source; wherein, the order information includes the order type;
[0123] The read order information is normalized and sorted according to the preset order type to obtain the sorting result;
[0124] According to the sorting result, the order information is sequentially written into the blank data table starting from the starting number to obtain the target data table.
[0125] One embodiment of this application also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements an order information processing method, including the following steps:
[0126] When a primary database failure is detected, obtain the address of the backup database corresponding to the primary database;
[0127] The backup database is queried based on the address, and a pre-stored blank data table is extracted from the backup database to determine the starting number of the blank data table; wherein, the number field of the blank data table is an auto-incrementing field;
[0128] Read the order information to be written one by one from the data source; wherein, the order information includes the order type;
[0129] The read order information is normalized and sorted according to the preset order type to obtain the sorting result;
[0130] According to the sorting result, the order information is sequentially written into the blank data table starting from the starting number to obtain the target data table.
[0131] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media provided in this application and used in the embodiments can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0132] In summary, the greatest benefit of this application is that:
[0133] This application provides an order information processing method, apparatus, computer equipment, and storage medium. When a primary database failure is detected, the address of the corresponding backup database is obtained. The backup database is queried based on the address, and a pre-stored blank data table is extracted. The starting number of the blank data table is determined. Order information to be written is read one by one from the data source. The read order information is normalized and sorted according to a preset order type to obtain a sorting result. Based on the sorting result, the order information is sequentially written into the blank data table starting from the starting number to obtain the target data table. This achieves automatic maintenance of the number field. When the service abnormally exits and restarts, there is no need to restore the number, minimizing the possibility of sequence number errors. Furthermore, since the number is maintained by the database, the program does not need to re-arrange subsequent numbers when a certain order information has an error, allowing it to focus on business processing and simplifying the overall processing flow. Moreover, when a database failure requires switching, there is no need to query the last written maximum number; it only needs to be written to the pre-stored blank table, reducing the possibility of errors, simplifying the switching process, and ensuring the normal writing of order information.
[0134] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, apparatus, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, apparatus, article, or method that includes that element.
[0135] The above description is only a preferred embodiment of this application and does not limit the patent scope of this application. Any equivalent structural or procedural changes made based on the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for processing order information, characterized in that, include: When a primary database failure is detected, obtain the address of the backup database corresponding to the primary database; The backup database is queried based on the address, and a pre-stored blank data table is extracted from the backup database to determine the starting number of the blank data table; wherein, the number field of the blank data table is an auto-incrementing field; Read the order information to be written one by one from the data source; wherein, the order information includes the order type; The read order information is normalized and sorted according to the similarity between the order type of the order information and the preset order type to obtain the sorting result; wherein, the keywords of the order type of each order information are extracted to obtain the first keyword of each order information; the keywords of the preset order type are extracted to obtain the second keyword; the similarity between the first keyword and the second keyword of each order information is calculated, that is, the similarity between the order type of the order information and the preset order type is obtained. The calculation of the similarity between the first keyword and the second keyword of each order information includes: converting the first keyword of each order information into a word vector using a preset word vector tool to obtain the first word vector of each order information; converting the second keyword into a word vector using a preset word vector tool to obtain the second word vector; and calculating the cosine distance between the first word vector and the second word vector of each order information to obtain the similarity between the first keyword and the second keyword of each order information. When each order information includes multiple first keywords and / or second keywords, the word vector tool word2vec is used to convert each first keyword and / or second keyword into a word vector, resulting in multiple target word vectors. The average value of the multiple corresponding target word vectors is calculated, and the corresponding average value is used as the first word vector and / or second word vector of each order information. According to the sorting result, the order information is sequentially written into the blank data table starting from the starting number to obtain the target data table.
2. The method according to claim 1, characterized in that, Before detecting a primary database failure, the process also includes: Obtain the number of primary databases, and create multiple standby databases for each primary database; Each of the backup databases is assigned an address and several blank data tables, and the fields of the blank data tables are defined as auto-incrementing fields. Set a starting number for each blank data table corresponding to the backup database.
3. The method according to claim 1, characterized in that, The step of normalizing and sorting the read order information according to the order type and the preset order type to obtain the sorting result includes: Extract the order type from each order's information; Filter out order information that belongs to the preset order type to obtain multiple target order information; The multiple target order information is prioritized and sorted adjacently, and the remaining order information that does not belong to the preset order type is placed after the multiple target order information to obtain the sorting result.
4. The method according to claim 1, characterized in that, The step of normalizing and sorting the read order information according to the order type and the preset order type to obtain the sorting result includes: Extract the order type from each order's information; Calculate the similarity between the order type of each order and the preset order type; The order information is sorted according to the degree of similarity to obtain the sorting result.
5. The method according to claim 1, characterized in that, After writing the order information sequentially into the blank data table starting from the starting number, the method further includes: The order information written into the blank data table is grouped according to preset rules; wherein each group of order information has commonalities or similarities. Determine if there are duplicate data in the order information within each group; If so, remove the duplicate data from the order information within each group.
6. An order information processing apparatus, used to perform the method according to any one of claims 1-5, characterized in that, include: The acquisition module is used to acquire the address of the backup database corresponding to the primary database when a primary database failure is detected. The query module is used to query the backup database based on the address, extract the pre-stored blank data table in the backup database, and determine the starting number of the blank data table; wherein, the number field of the blank data table is an auto-incrementing field; The reading module is used to read the order information to be written from the data source one by one; wherein, the order information includes the order type; The sorting module is used to normalize and sort the read order information according to the order type and the preset order type to obtain the sorting result; The writing module is used to sequentially write the order information into the blank data table according to the sorting result, starting from the starting number, to obtain the target data table.
7. A computer device, characterized in that, include: processor; Memory; The memory stores a computer program, and the processor executes the computer program to implement the order information processing method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the order information processing method according to any one of claims 1-5.
Citation Information
Patent Citations
Method and system for processing orders
CN106372994A
Data guarantee method and device, equipment and storage medium
CN117076211A