A method and system for generating voucher numbers

The method and system address the challenge of duplicate certificate number assignments in ERP systems by serializing and checking for duplicates, ensuring unique and continuous certificate numbers in high-concurrency environments.

CN114297212BActive Publication Date: 2025-07-15金蝶云科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111633075.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2025-07-15
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

In the high concurrency scenarios of existing ERP systems, duplication and untimely updates are prone to problems when generating credential numbers, which makes it difficult to guarantee the uniqueness and continuity of credential numbers.

Method used

By obtaining parallel vouchers, serializing them with a servo conveyor belt, and using the re-decision algorithm to determine whether the voucher number is duplicated, calling the available voucher number generation algorithm to generate non-repetitive voucher numbers for duplicate vouchers, and in multiple server scenarios, the uniqueness of the voucher number is ensured.

Benefits of technology

In high concurrency scenarios, the uniqueness and continuity of the voucher number of each voucher is ensured, the occurrence of duplicate numbers is avoided, and the stability and efficiency of the system are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114297212B_ABST
    Figure CN114297212B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a method and system for generating voucher numbers to ensure the uniqueness of the voucher numbers obtained for each voucher in a high-concurrency scenario. The method of the embodiments of the present application includes: obtaining parallel vouchers from multiple parallel sources, where each voucher carries its own voucher number; sending the parallel vouchers to a servo conveyor belt so that the servo conveyor belt serializes the parallel vouchers to generate serial vouchers; taking out a preset number of vouchers from the serial vouchers, and using an integrator to integrate the multiple vouchers into a processing set; determining whether the voucher number of each voucher in the processing set is repeated with the existing voucher numbers in the database; if so, obtaining a first voucher whose voucher number is repeated with the existing voucher number; calling an available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data quantity, and in particular to a method and system for generating voucher numbers. Background Art

[0002] When existing ERP systems generate voucher numbers for existing vouchers, the following general method is usually adopted:

[0003] A table of available voucher numbers, called a number pool, is established in advance. When a voucher is saved, the first number in the number pool is directly taken as the voucher number for use. The numbers in the number pool are maintained by a background program. Therefore, the uniqueness and continuity of the voucher numbers are completely determined by this maintenance program. The maintenance program needs to prepare a certain amount of voucher numbers in the number pool and delete them from the pool in a timely manner after the numbers are used. When a voucher is deleted or a voucher number is modified, the voucher number should be recycled to the number pool in a timely manner.

[0004] However, the above method places high requirements on the maintenance program. It must ensure that the numbers in the number pool can reflect the actual usage of the current voucher numbers in real time and accurately. Moreover, in a high-concurrency scenario, the number pool is prone to being updated untimely, resulting in duplicate numbers being retrieved. Summary of the Invention

[0005] Embodiments of this application provide a method and system for generating voucher numbers to ensure the uniqueness of the voucher numbers obtained for each voucher in a high-concurrency scenario.

[0006] In a first aspect, an embodiment of this application provides a method for generating voucher numbers, including:

[0007] Obtain parallel vouchers from multiple parallel sources, where each voucher carries its own voucher number;

[0008] Send the parallel vouchers to a servo conveyor belt so that the servo conveyor belt serializes the parallel vouchers to generate serial vouchers;

[0009] Take out a preset number of vouchers from the serial vouchers, and use an integrator to integrate the multiple vouchers into a processing set;

[0010] Determine whether the voucher number of each voucher in the processing set is repeated with the existing voucher numbers in the database;

[0011] If so, obtain a first voucher whose voucher number is repeated with the existing voucher number;

[0012] Call an available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher.

[0013] Preferably, after obtaining the first voucher that duplicates an existing voucher number and before calling the available voucher number generation algorithm to generate a first voucher number that does not duplicate the existing voucher number, the method further includes:

[0014] Determine whether the voucher numbers in the processing set are processed by multiple servers simultaneously, where there is only one voucher number processor instance in each server;

[0015] If so, start a database lock to perform a locking operation on the data file where the serial voucher is located, so that the voucher number of the serial voucher is processed by only one server at the same time.

[0016] Preferably, after starting the database lock and before calling the available voucher number generation algorithm to generate a first voucher number that does not duplicate the existing voucher number, the method further includes:

[0017] Determine whether the classification items where the voucher number of the first voucher is located are the same, where the classification items include the data file where the first voucher is located, the time interval to which the first voucher belongs, and the category of the first voucher;

[0018] If not, group the first vouchers according to the classification items to divide the first vouchers into at least two independent groups, where the voucher numbers in the at least two independent groups can be repeated.

[0019] Preferably, calling the available voucher number generation algorithm to generate a first voucher number that does not duplicate the existing voucher number includes:

[0020] Call the available voucher number generation algorithm and the broken number generation algorithm to generate a first voucher number that is consecutive and does not duplicate the existing voucher number for the first vouchers in each independent group.

[0021] Preferably, the method further includes:

[0022] Update the voucher numbers in the serial vouchers that do not duplicate the existing voucher numbers in the database and the first voucher number to the database.

[0023] Preferably, the method further includes:

[0024] Determine whether the child thread where the serial voucher is located needs to notify the parent thread;

[0025] If so, notify the parent thread of the voucher numbers in the serial vouchers that do not duplicate the existing voucher numbers in the database and the first voucher number.

[0026] Preferably, the servo conveyor belt includes: a loop statement and a queue, or a loop statement and a list, or a loop statement and an array set.

[0027] In a second aspect of the embodiments of the present application, a system for generating voucher numbers is provided, including:

[0028] An acquisition unit, configured to acquire parallel vouchers from multiple parallel external sources, where each voucher carries its own voucher number;

[0029] A serial unit, configured to send the parallel vouchers to a servo conveyor belt, so that the servo conveyor belt serializes the parallel vouchers to generate serial vouchers;

[0030] An integration unit, configured to extract a preset number of vouchers from the serial vouchers, and use an integrator to integrate the multiple vouchers into a processing set;

[0031] A duplicate-checking unit, configured to determine whether the voucher numbers of each voucher in the processing set are repeated with the existing voucher numbers in the database;

[0032] The acquisition unit is further configured to, when the voucher number of each voucher in the processing set is repeated with the existing voucher number in the database, acquire a first voucher whose voucher number is repeated with the existing voucher number;

[0033] A generation unit, configured to call an available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher.

[0034] Preferably, the system further includes:

[0035] A judgment unit, configured to, after acquiring the first voucher whose voucher number is repeated with the existing voucher number and before calling the available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher, determine whether the voucher numbers in the processing set are processed by multiple servers at the same time, where there is only one voucher number processor instance in each server;

[0036] A start unit, configured to, when the voucher numbers of the serial vouchers are processed by multiple servers at the same time, start a database lock to perform a locking operation on the data file where the serial vouchers are located, so that the voucher numbers of the serial vouchers are processed by only one server at the same time.

[0037] Preferably, the judgment unit is further configured to:

[0038] After starting the database lock, before calling the available voucher number generation algorithm to generate a first voucher number that is non-duplicate with the existing voucher numbers for the first voucher, it is determined whether the classification items where the voucher number of the first voucher is located are the same, where the classification items include the data file where the first voucher is located, the time interval to which the first voucher belongs, and the category of the first voucher;

[0039] The system further includes:

[0040] A grouping unit, configured to group the first vouchers according to the classification items when the classification items where the voucher numbers of the first vouchers are located are different, so as to divide the first vouchers into at least two independent groups, where the voucher numbers in the at least two independent groups may be repeated.

[0041] Preferably, the generating unit is specifically configured to:

[0042] Call the available voucher number generation algorithm and the discontinuous number generation algorithm to generate a first voucher number that is continuous and non-duplicate with the existing voucher numbers for the first vouchers in each independent group.

[0043] Preferably, the system further includes:

[0044] A storage unit, configured to update the voucher numbers that are non-duplicate with the existing voucher numbers in the database in the serial vouchers and the first voucher numbers to the database.

[0045] Preferably, the judging unit is further configured to:

[0046] Judge whether the child thread where the serial vouchers are located needs to notify the parent thread;

[0047] The system further includes:

[0048] A notification unit, configured to notify the parent thread of the voucher numbers that are non-duplicate with the existing voucher numbers in the database in the serial vouchers and the first voucher numbers when the child thread where the serial vouchers are located needs to notify the parent thread.

[0049] Preferably, the servo conveyor belt includes: a loop statement and a queue, or a loop statement and a list, or a loop statement and an array set.

[0050] A third aspect of the embodiments of the present application provides a computer device, including a processor, and when the processor executes a computer program stored in a memory, it is configured to implement the method for generating voucher numbers described in the first aspect of the embodiments of the present application.

[0051] A fourth aspect of the embodiments of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it is configured to implement the method for generating voucher numbers described in the first aspect of the embodiments of the present application.

[0052] In the fifth aspect of the embodiments of the present application, a computer program product is provided. When the computer program product is executed by a computer, it is used to implement the method for generating voucher numbers described in the first aspect of the embodiments of the present application.

[0053] As can be seen from the above technical solutions, the embodiments of the present application have the following advantages:

[0054] In the embodiments of the present application, after obtaining parallel vouchers from multiple sources, the parallel vouchers are serialized, and a duplicate checking algorithm is used to perform a duplicate checking operation on the voucher numbers of the parallel vouchers and the voucher numbers in the database. If there is a first voucher in the serialized vouchers that has the same voucher number as an existing voucher number in the database, an available voucher number generation algorithm is called to generate a first voucher number that is not duplicate with the existing voucher number for the first voucher, thereby ensuring the uniqueness of the voucher number for each voucher in the high-concurrency scenario of vouchers. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 It is a schematic diagram of an embodiment of the method for generating voucher numbers in the embodiments of the present application;

[0056] Figure 2 It is a schematic diagram of another embodiment of the method for generating voucher numbers in the embodiments of the present application;

[0057] Figure 3 It is a schematic diagram of the process of generating voucher numbers in the embodiments of the present application;

[0058] Figure 4 It is a schematic diagram of an embodiment of the system for generating voucher numbers in the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0059] The embodiments of the present application provide a method and a system for generating voucher numbers, which are used to ensure the uniqueness of the voucher identification codes obtained for each voucher in a high-concurrency scenario.

[0060] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present application.

[0061] In the description and claims of this application and the above-mentioned drawings, terms such as "first", "second", "third", "fourth", etc. are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0062] For ease of understanding, the following first explains the professional terms in this application and uses this explanation in the subsequent description:

[0063] ERP: The abbreviation of Enterprise Resource Planning, which refers to a management platform that is based on information technology, integrates information technology and advanced management concepts, and provides decision-making means for enterprise employees and the decision-making level with a systematic management concept.

[0064] Voucher: Also known as accounting voucher, it refers to a written proof that can be used to prove the occurrence of economic business matters, clarify economic responsibilities, and be used for registering accounts, and has legal effect. It usually contains information such as date, voucher number, summary, accounting subject, debit and credit amounts, etc.

[0065] Voucher number: It is a consecutive and unique numerical number on the voucher. Through the voucher number, the corresponding voucher can be found conveniently and quickly. In the ERP system, financial personnel can uniquely determine a voucher through the ledger (if there are multiple ledgers), year, period, voucher type, and voucher number.

[0066] Singleton pattern: A system design pattern that can ensure that there is only one instance of a class in the entire system. This pattern can ensure that in an application server system, there is only one instance of the voucher number processor working.

[0067] Servo conveyor belt: A logic unit similar to a conveyor belt composed of a loop statement and a queue. The loop statement is equivalent to the driving wheel of the conveyor belt, and the queue is equivalent to the conveyor belt. When a batch of vouchers is placed in the queue, the loop statement can drive the code to obtain the vouchers placed in the queue from the queue. The system can intelligently control its start and stop according to the situation of the queue to save system resources and achieve the effect of servoing at any time and stopping automatically when idle.

[0068] Integrator: A logic unit that performs the operation of integrating the fragmented parts into a whole.

[0069] Parallel operation serialization: In a concurrent scenario, it refers to the process of turning multiple batches of vouchers generated in parallel into multiple batches with a sequential order after passing through a queue.

[0070] Database lock: In a scenario where multiple application services are deployed, a dedicated physical table pre-set with all enabled accounting books is used as a carrier. When processing voucher numbers, a row-level exclusive lock is added according to the accounting book where the voucher is located to ensure that only one can execute subsequent tasks at the same time. It can prevent concurrent problems caused by multiple application services (multiple system instances) operating simultaneously.

[0071] Thread synchronizer: A tool used to synchronize the parent thread and child threads in a multi-threaded task to achieve the purpose of two threads working together. In this case, when the business unit on the parent thread needs to know the voucher number in real time, the thread synchronizer enables the parent thread to wait in place after calling the voucher number processor in the child thread until the voucher number processor finishes processing the task submitted by the parent thread and then continues to execute the subsequent code.

[0072] Based on the problem in the prior art that in a high-concurrency scenario, the method of distributing voucher numbers to each voucher through a number pool and a maintenance program cannot ensure that the voucher numbers obtained by each voucher are non-duplicate, the embodiment of this application proposes a method for generating voucher numbers to ensure the uniqueness of the voucher numbers of each voucher in a high-concurrency scenario.

[0073] For ease of understanding, the method for generating voucher numbers in the embodiment of this application is described below. Please refer to Figure 1 , an embodiment of the method for generating voucher numbers in the embodiment of this application includes:

[0074] 101. Obtain parallel vouchers from multiple parallel sources, where each voucher carries its own voucher number;

[0075] In an ERP system, the sources of generating vouchers are diverse. Commonly, there are manual creation, intelligent generation of business documents, generation during period-end processing (including period-end exchange rate adjustment, profit and loss transfer, automatic transfer, etc.), voucher transfer and storage, file import, API input, etc. Except for manually created vouchers, which are generally saved one by one at a time, other methods all have the problem of batch saving of vouchers.

[0076] For various vouchers from multiple sources, the embodiment of this application first obtains parallel vouchers from multiple parallel sources, where each voucher carries its own voucher number, for uniquely determining a voucher according to the accounting book (if there are multiple accounting books), year, period, voucher type, and voucher number.

[0077] Because for parallel vouchers from multiple parallel sources, when obtaining their respective voucher numbers, there may be a problem that one voucher number is used by multiple vouchers.

[0078] 102. Send the parallel vouchers to the servo conveyor belt so that the servo conveyor belt serializes the parallel vouchers to generate serial vouchers.

[0079] For the convenience of processing parallel vouchers, in the embodiments of the present application, the parallel vouchers are sent to the servo conveyor belt so that the servo conveyor belt serializes the parallel vouchers to generate serial vouchers.

[0080] Specifically, the servo conveyor belt in the embodiments of the present application can be in the form of a loop statement and a queue, or a loop statement and a list, or a loop statement and an array set. Among them, the loop statement is equivalent to the driving wheel of the conveyor belt, and the queue, list, and array set are equivalent to the conveyor belt. When parallel vouchers are put into the queue, list, or array set, the loop statement can drive the code to sequentially obtain the vouchers put in from the queue, list, or array set, thereby serializing the parallel vouchers.

[0081] The execution entity of this method can also intelligently control its start and stop according to the situation of the queue, list, or array set to save system resources and achieve the effect of servoing at any time and stopping automatically when idle.

[0082] 103. Take out a preset number of vouchers from the serial vouchers and use an integrator to integrate the multiple vouchers into a processing set.

[0083] Driven by the loop statement, the execution entity can take out a preset number of serial vouchers from the serial vouchers and use an integrator to integrate the multiple serial vouchers into a processing set.

[0084] For example, when the preset data is 1000, the execution entity takes out 1000 serial vouchers from the queue of the servo conveyor belt. If the number of serial vouchers in the queue of the servo conveyor belt is less than 1000, all of them are taken out and these serial vouchers are integrated into a processing set, so that when performing the duplicate check operation, the voucher numbers in this processing set can be obtained at one time, and the voucher numbers in this processing set can be compared with the voucher numbers in the database to perform the judgment operation, thereby improving the efficiency of duplicate checking of serial voucher numbers.

[0085] 104. Judge whether the voucher number of each voucher in the processing set is repeated with the voucher numbers already existing in the database. If so, execute step 105; if not, end the process.

[0086] After obtaining the serialized vouchers, the execution entity further uses the duplicate check algorithm to first obtain the voucher number of each voucher in the serial vouchers, and then judge whether the voucher number of each voucher in the serial vouchers exists in the database. If so, execute step 105; if not, end the process.

[0087] 105. Obtain the first voucher with a voucher number that duplicates an existing voucher number;

[0088] If there is a situation where the voucher number of the serial voucher duplicates the voucher number in the database, obtain the first voucher in the serial voucher that duplicates the existing voucher number in the database, and perform step 106.

[0089] 106. Invoke the available voucher number generation algorithm to generate a first voucher number for the first voucher that does not duplicate the existing voucher number.

[0090] After obtaining the first voucher, invoke the available voucher number generation algorithm to generate a first voucher number for the above-mentioned first voucher that does not duplicate the existing voucher number and is as consecutive as possible.

[0091] In the embodiment of the present application, after obtaining parallel vouchers from multiple sources, the parallel vouchers are serialized, and a duplicate checking algorithm is used to perform a duplicate checking operation on the voucher numbers of the parallel vouchers and the voucher numbers in the database. If there is a first voucher in the serial voucher that duplicates the existing voucher number in the database, the available voucher number generation algorithm is invoked to generate a first voucher number for the first voucher that does not duplicate the existing voucher number, thereby ensuring the uniqueness of the voucher number of each voucher in the high-concurrency scenario of vouchers.

[0092] Based on Figure 1 the above-mentioned embodiment, after obtaining the first voucher with a voucher number that duplicates an existing voucher number and before invoking the available voucher number generation algorithm to generate a first voucher number for the first voucher that does not duplicate the existing voucher number, in order to prevent the voucher numbers of the serial vouchers from being processed by multiple servers simultaneously, thereby causing the problem of duplicate voucher numbers in the database, the embodiment of the present application may further perform the following steps. Please refer to Figure 3 :

[0093] 201. Determine whether the voucher numbers in the processing set are processed by multiple servers simultaneously, where each server has only one voucher number processor instance. If so, perform step 202. If not, perform step 203;

[0094] In order to ensure that only one voucher number processor instance on one server is working at the same time, that is, the voucher numbers of the serial vouchers are processed by only one server at the same time, the embodiment of the present application further determines whether the voucher numbers of the serial vouchers are processed by multiple servers simultaneously, where each server has only one voucher number processor instance.

[0095] For easy understanding, an example is given below: Suppose the voucher numbers of serial vouchers in a processing set are processed by two application servers, A and B, at the same time, and the two application servers, A and B, are connected to the same database. It is possible that the two application servers, A and B, access the database simultaneously to obtain the voucher numbers in the database. If there are already voucher numbers 1, 2, and 3 in the database at this time, then the two servers, A and B, may simultaneously obtain the 4th voucher number, resulting in two 4th voucher numbers being saved into the database at the same time.

[0096] Therefore, the embodiment of the present application needs to determine whether the voucher numbers of serial vouchers are processed by multiple servers at the same time to prevent the problem of duplicate voucher numbers in the database.

[0097] If so, execute step 202; if not, execute step 203.

[0098] 202. Start a database lock to perform a locking operation on the data file where the serial voucher is located, so that the voucher number of the serial voucher is processed by only one server at the same time.

[0099] To ensure that the voucher number of the serial voucher is processed by only one server at the same time, the embodiment of the present application starts a database lock to perform a locking operation on the data file where the serial voucher is located, so that the voucher number of the serial voucher is only applied to one server.

[0100] Specifically, the database lock in the embodiment of the present application can be a row exclusive lock or a table exclusive lock of the database. The embodiment of the present application is mainly to perform a locking operation on the data file where the serial voucher is located. Therefore, if the data file where the serial voucher is located is stored in the form of rows in the database, the row exclusive lock of the database is used; if the data file where the serial voucher is located is stored in the form of a table in the database, the table exclusive lock of the database is used.

[0101] 203. Determine whether the distinguishing items where the first voucher is located are the same, where the distinguishing items include the data file where the first voucher is located, the time interval to which the first voucher belongs, and the category of the first voucher. If not, execute step 204; if so, execute step 206.

[0102] It should be noted that when generating voucher numbers, it is generally required that there be no duplicates between any two voucher numbers. However, in actual situations, if the distinguishing items where the voucher number of the first voucher is located are different, then voucher numbers under different distinguishing items are allowed to be the same, because when identifying a voucher, the voucher is identified by the combination of the distinguishing item and the voucher number. Therefore, when the distinguishing items where the voucher number of the first voucher is located are different, it is allowed that the corresponding voucher numbers are the same, because the vouchers can be identified by different distinguishing items.

[0103] Specifically, the classification items in the embodiments of the present application include the data file where the first voucher is located (such as a ledger), the time interval to which the first voucher belongs (such as a year, a period), and the category (such as the voucher type).

[0104] For ease of understanding, the following is an example: When identifying a voucher, generally, the voucher is identified by ledger + year + period + voucher type + voucher number. Therefore, when any one of the items in ledger + year + period + voucher type is different, the voucher numbers are allowed to be the same, while when all the items in ledger + year + period + voucher type are the same, the voucher numbers are required to be different.

[0105] 204. Group the first vouchers according to the classification items to divide the first vouchers into at least two independent groups, where the voucher numbers in the at least two independent groups can be repeated;

[0106] In an actual application scenario, if the first vouchers belong to different data files, such as belonging to different ledgers, or belonging to the same ledger, different years, or belonging to the same ledger, the same year and different periods, or belonging to the same ledger, the same year, the same period and different voucher types, the voucher numbers in the first vouchers are allowed to be the same because ultimately, when determining a voucher, it can be confirmed according to ledger + year + period + voucher type + voucher number.

[0107] Therefore, after grouping the first vouchers according to the classification items, the voucher numbers in different groups are allowed to be repeated.

[0108] 205. Invoke an available voucher number generation algorithm to generate a first voucher number that is non-repetitive with the existing voucher numbers for each independent group;

[0109] Because after grouping the first vouchers according to the classification items, generally, the voucher numbers in each independent group are required to be non-repetitive, but the voucher numbers in at least two groups are allowed to be repeated. Therefore, after grouping the first vouchers, an available voucher number generation algorithm is invoked to generate a first voucher number that is non-repetitive with the existing voucher numbers for each independent group, but there is no restriction on whether the voucher numbers in at least two groups are repeated.

[0110] 206. Invoke an available voucher number generation algorithm to generate a first voucher number that is non-repetitive with the existing voucher numbers for the first vouchers.

[0111] If the voucher numbers of the serial vouchers are not applied to multiple servers, that is, the voucher numbers of the serial vouchers are only applied to a single server, or the classification items where the first vouchers are located are the same, then an available voucher number generation algorithm is used to generate a first voucher number that is non-repetitive with the existing voucher numbers for the first vouchers.

[0112] Further, when invoking the available voucher number generation algorithm, in order to ensure the continuity between the first voucher number and the existing voucher numbers, it is also possible to call the available voucher number generation algorithm and the discontinuous number generation algorithm to generate a non-repetitive first voucher number for the first voucher that is continuous with the existing voucher numbers.

[0113] In the embodiments of the present application, the process of ensuring the uniqueness of the first voucher number corresponding to the first voucher in the scenario of applying serial vouchers to multiple servers is described in detail, thereby ensuring the uniqueness of the voucher identification code corresponding to each voucher even in the multi-server application scenario.

[0114] Based on Figures 1 to 2 In the described embodiments, after generating the first voucher identification, it is further possible to determine whether the child thread where the serial voucher is located needs to notify the parent thread. If so, the voucher numbers in the serial voucher in the processing set that are non-repetitive with the existing voucher numbers in the database and the first voucher number are notified to the parent thread.

[0115] It is easy to understand that in a multi-threaded task, if the business unit in the parent thread needs to obtain the voucher number in real time, after generating the first voucher number, all the voucher numbers in the processing set can be notified to the parent thread. Among them, all the voucher numbers in the processing set include: the voucher numbers in the serial voucher that are non-repetitive with the existing voucher numbers in the database and the first voucher number generated by calling the available voucher number generation algorithm and the discontinuous number generation algorithm for the first voucher.

[0116] Further, after generating the first voucher number, it is also necessary to update the voucher numbers in the serial voucher that are non-repetitive with the existing voucher numbers in the database and the first voucher number to the database to update the existing voucher numbers in the database.

[0117] For easy understanding, Figure 3 a process schematic diagram of the method for generating voucher numbers in a complex scenario is given, where the complex scenario includes a multi-application server scenario and a multi-thread scenario. Among them, regarding Figure 3 the method for generating voucher numbers in the scenario can refer to Figures 1 to 2 the method for generating voucher numbers in the embodiments, which will not be elaborated here.

[0118] The above has described in detail the method for generating voucher numbers in the present application. Next, the system for generating voucher numbers in the embodiments of the present application will be described. Please refer to Figure 4 , an embodiment of the system for generating voucher numbers in the present application includes:

[0119] An acquisition unit 401, configured to acquire parallel vouchers from multiple parallel external sources, where each voucher carries its own voucher number;

[0120] A serial unit 402 for sending the parallel vouchers to a servo conveyor belt so that the servo conveyor belt serializes the parallel vouchers to generate serial vouchers;

[0121] An integration unit 403 for taking out a preset number of vouchers from the serial vouchers and integrating the vouchers into a processing set by using an integrator;

[0122] A duplicate checking unit 404 for judging whether the voucher numbers of each voucher in the processing set are repeated with the existing voucher numbers in a database;

[0123] The obtaining unit 401 is further configured to, when the voucher numbers of each voucher in the processing set are repeated with the existing voucher numbers in the database, obtain a first voucher whose voucher number is repeated with the existing voucher number;

[0124] A generating unit 405 for calling an available voucher number generating algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher.

[0125] Preferably, the system further includes:

[0126] A judging unit 406 for, after obtaining the first voucher whose voucher number is repeated with the existing voucher number and before calling the available voucher number generating algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher, judging whether the voucher numbers of the serial vouchers are processed by multiple servers at the same time, where each server has only one voucher number processor instance;

[0127] A starting unit 407 for, when the voucher numbers of the serial vouchers are processed by multiple servers at the same time, starting a database lock to perform a locking operation on the data file where the serial vouchers are located, so that the voucher numbers of the serial vouchers are processed by only one server at the same time.

[0128] Preferably, the judging unit 406 is further configured to:

[0129] After starting the database lock and before calling the available voucher number generating algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher, judge whether the classification items where the voucher number of the first voucher is located are the same, where the classification items include the data file where the first voucher is located, the year and period to which the first voucher belongs, and the voucher type of the first voucher;

[0130] The system further includes:

[0131] A grouping unit 408 for, when the classification items where the voucher number of the first voucher is located are different, grouping the first vouchers according to the classification items to divide the first vouchers into at least two independent groups, where the voucher numbers in the at least two independent groups may be repeated.

[0132] Preferably, the generating unit 405 is specifically configured to:

[0133] Call the available voucher number generation algorithm and the discontinuous number generation algorithm to generate a first voucher number that is consecutive and non-repetitive with the existing voucher numbers for the first vouchers in each independent group.

[0134] Preferably, the system further includes:

[0135] A storage unit 409, configured to update the voucher numbers in the serial vouchers that are non-repetitive with the existing voucher numbers in the database and the first voucher numbers to the database.

[0136] Preferably, the determining unit 406 is further configured to:

[0137] Determine whether the child thread where the serial voucher is located needs to notify the parent thread;

[0138] The system further includes:

[0139] A notification unit 410, configured to, when there is a parent thread for the child thread where the serial voucher is located, notify the parent thread of the voucher numbers in the serial vouchers that are non-repetitive with the existing voucher numbers in the database and the first voucher numbers.

[0140] Preferably, the servo conveyor belt includes: a loop statement and a queue, or a loop statement and a list, or a loop statement and an array set.

[0141] In the embodiment of the present application, after obtaining parallel vouchers from multiple sources, the parallel vouchers are serialized by the serial unit 402, and the voucher numbers of the parallel vouchers are compared with the voucher numbers in the database by the duplicate checking unit 404 using the duplicate checking algorithm. If there is a first voucher in the serial vouchers that has the same voucher number as an existing voucher number in the database, the available voucher number generation algorithm is called to generate a first voucher number that is non-repetitive with the existing voucher number for the first voucher, thereby ensuring the uniqueness of the voucher numbers of each voucher in the high-concurrency scenario of vouchers.

[0142] Above, the system for generating voucher numbers in the embodiment of the present application has been described from the perspective of modular functional entities. Below, the computer device in the embodiment of the present application will be described from the perspective of hardware processing:

[0143] This computer device is used to implement the functions of the system for generating voucher numbers. An embodiment of the computer device in the embodiment of the present application includes:

[0144] A processor and a memory;

[0145] The memory is used to store a computer program, and when the processor executes the computer program stored in the memory, the following steps can be implemented:

[0146] Obtain parallel vouchers from multiple parallel sources, where each voucher carries its own voucher number;

[0147] Send the parallel vouchers to a servo conveyor belt so that the servo conveyor belt serializes the parallel vouchers to generate serialized vouchers;

[0148] Take out a preset number of vouchers from the serialized vouchers and use an integrator to integrate the multiple vouchers into a processing set.

[0149] Use a duplicate checking algorithm to determine whether the voucher number of each voucher in the processing set is repeated with the voucher numbers already existing in the database;

[0150] If so, obtain a first voucher whose voucher number is repeated with the existing voucher number;

[0151] Call an available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher.

[0152] In some embodiments of the present application, after obtaining the first voucher whose voucher number is repeated with the existing voucher number and before calling the available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher, the processor can also be used to implement the following steps:

[0153] Determine whether the voucher numbers in the processing set are processed by multiple servers at the same time, where there is only one voucher number processor instance in each server;

[0154] If so, start a database lock to perform a locking operation on the data file where the serialized vouchers are located, so that the voucher numbers of the serialized vouchers are processed by only one server at the same time.

[0155] In some embodiments of the present application, after starting the database lock and before calling the available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher, the processor can also be used to implement the following steps:

[0156] Determine whether the differentiation items where the voucher number of the first voucher is located are the same, where the differentiation items include the data file where the first voucher is located, the time interval to which the first voucher belongs, and the category of the first voucher;

[0157] If not, group the first vouchers according to the differentiation items to divide the first vouchers into at least two independent groups, where the voucher numbers in the at least two independent groups can be repeated.

[0158] In some embodiments of the present application, the processor can also be used to implement the following steps:

[0159] Call the available voucher number generation algorithm and the broken number generation algorithm to generate a first voucher number that is consecutive and non-duplicate with the existing voucher numbers for the first voucher in each independent group.

[0160] In some embodiments of the present application, the processor can also be used to implement the following steps:

[0161] Update the voucher numbers that are non-duplicate with the existing voucher numbers in the database in the serial vouchers and the first voucher number to the database.

[0162] In some embodiments of the present application, the processor can also be used to implement the following steps:

[0163] Determine whether the child thread where the serial voucher is located needs to notify the parent thread;

[0164] If so, notify the parent thread of the voucher numbers that are non-duplicate with the existing voucher numbers in the database in the serial vouchers and the first voucher number.

[0165] It can be understood that when the processor in the above-described computer device executes the computer program, it can also implement the functions of each unit in the corresponding device embodiments above, which will not be elaborated here. Exemplarily, the computer program can be divided into one or more modules / units, and the one or more modules / units are stored in the memory and executed by the processor to complete the present application. The one or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and this instruction segment is used to describe the execution process of the computer program in the voucher number generation system. For example, the computer program can be divided into the respective units in the above-described voucher number generation system, and each unit can implement the specific functions described in the corresponding voucher number generation system above.

[0166] The computer device can be a computing device such as a desktop computer, a notebook, a palm computer, and a cloud server. The computer device can include but is not limited to a processor and a memory. Those skilled in the art can understand that the processor and the memory are only examples of the computer device, and do not constitute a limitation on the computer device. It can include more or fewer components, or combine some components, or different components. For example, the computer device can also include input / output devices, network access devices, buses, etc.

[0167] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. The processor is the control center of the computer device, connecting various parts of the entire computer device through various interfaces and circuits.

[0168] The memory can be used to store the computer program and / or modules. By running or executing the computer program and / or modules stored in the memory, and by calling the data stored in the memory, the processor realizes various functions of the computer device. The memory mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function, etc.; the data storage area can store data created according to the use of the terminal, etc. In addition, the memory can include high-speed random access memory, and can also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage devices.

[0169] This application also provides a computer-readable storage medium, which is used to implement the functions of the system for generating voucher numbers. A computer program is stored thereon. When the computer program is executed by a processor, the processor can be used to perform the following steps:

[0170] Obtain parallel vouchers from multiple parallel sources, where each voucher carries its own voucher number;

[0171] Send the parallel vouchers to a servo conveyor belt so that the servo conveyor belt serializes the parallel vouchers to generate serial vouchers;

[0172] Take out a preset number of vouchers from the serial vouchers, and use an integrator to integrate the multiple vouchers into a processing set;

[0173] Determine whether the voucher number of each voucher in the processing set is repeated with the voucher numbers already existing in the database;

[0174] If so, obtain the first voucher that duplicates the existing voucher number;

[0175] Call the available voucher number generation algorithm to generate a first voucher number that does not duplicate the existing voucher number for the first voucher.

[0176] In some embodiments of the present application, after obtaining the first voucher that duplicates the existing voucher number and before calling the available voucher number generation algorithm to generate a first voucher number that does not duplicate the existing voucher number for the first voucher, when the computer program stored in the computer-readable storage medium is executed by the processor, the processor can specifically be used to perform the following steps:

[0177] Determine whether the voucher numbers in the processing set are processed by multiple servers at the same time, where there is only one voucher number processor instance in each server;

[0178] If so, start a database lock to perform a locking operation on the data file where the serial voucher is located, so that the voucher number of the serial voucher is only processed by one server at the same time.

[0179] In some embodiments of the present application, after starting the database lock and before calling the available voucher number generation algorithm to generate a first voucher number that does not duplicate the existing voucher number for the first voucher, when the computer program stored in the computer-readable storage medium is executed by the processor, the processor can specifically be used to perform the following steps:

[0180] Determine whether the classification items where the voucher number of the first voucher is located are the same, where the classification items include the data file where the first voucher is located, the time interval to which the first voucher belongs, and the category of the first voucher;

[0181] If not, group the first vouchers according to the classification items to divide the first vouchers into at least two independent groups, where the voucher numbers in the at least two independent groups can be repeated.

[0182] In some embodiments of the present application, when the computer program stored in the computer-readable storage medium is executed by the processor, the processor can specifically be used to perform the following steps:

[0183] Call the available voucher number generation algorithm and the broken number generation algorithm to generate a first voucher number that is consecutive and does not duplicate the existing voucher number for the first voucher in each independent group.

[0184] In some embodiments of the present application, when the computer program stored in the computer-readable storage medium is executed by the processor, the processor can specifically be used to perform the following steps:

[0185] Update the voucher numbers in the serial vouchers that are non-duplicate with the existing voucher numbers in the database and the first voucher number to the database.

[0186] In some embodiments of the present application, when the computer program stored in the computer-readable storage medium is executed by the processor, the processor can specifically be used to perform the following steps:

[0187] Determine whether the child thread where the serial voucher is located needs to notify the parent thread;

[0188] If so, notify the parent thread of the voucher numbers in the serial vouchers that are non-duplicate with the existing voucher numbers in the database and the first voucher number.

[0189] It can be understood that if the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a corresponding computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above corresponding embodiment methods of the present application, it can also be completed by instructing related hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0190] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling, direct coupling, or communication connection can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be in electrical, mechanical, or other forms.

[0191] The unit described as a separation component may or may not be physically separated. The component displayed as a unit may or may not be a physical unit, that is, it may be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0192] In addition, each functional unit in various embodiments of the present application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0193] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of each embodiment of the present application.

Claims

1. A method for generating voucher numbers, characterized in that, Including: Obtain parallel vouchers from multiple parallel sources, where each voucher carries its own voucher number; Send the parallel vouchers to a servo conveyor belt so that the servo conveyor belt serializes the parallel vouchers to generate serial vouchers. The servo conveyor belt includes a loop statement and a queue, or includes a loop statement and a list, or includes a loop statement and an array set. When the parallel vouchers are placed in the queue, the list, or the array set, the loop statement is used to drive the code to sequentially obtain the parallel vouchers from the queue, the list, or the array set, so that the parallel vouchers are serialized to generate serial vouchers; Take out a preset number of vouchers from the serial vouchers and use an integrator to integrate the multiple vouchers into a processing set; Judge whether the voucher number of each voucher in the processing set is repeated with the voucher numbers already existing in the database; If so, obtain a first voucher whose voucher number is repeated with the existing voucher number; Call an available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher.

2. The method according to claim 1, wherein After obtaining the first voucher whose voucher number is repeated with the existing voucher number and before calling the available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher, the method further includes: Judge whether the voucher numbers in the processing set are processed by multiple servers at the same time, where each server has only one voucher number processor instance; If so, start a database lock to perform a locking operation on the data file where the serial vouchers are located, so that the voucher numbers of the serial vouchers are processed by only one server at the same time.

3. The method according to claim 2, wherein After starting the database lock and before calling the available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher, the method further includes: Judge whether the classification items where the first voucher is located are the same, where the classification items include the data file where the first voucher is located, the time interval to which the first voucher belongs, and the category of the first voucher; If not, group the first vouchers according to the classification items to divide the first vouchers into at least two independent groups, where the voucher numbers in the at least two independent groups can be repeated.

4. The method according to claim 3, wherein The step of calling the available voucher number generation algorithm to generate a first voucher number that is not repeated with the existing voucher number for the first voucher includes: Call the available voucher number generation algorithm and the discontinuous number generation algorithm to generate a first voucher number that is continuous and not repeated with the existing voucher number for the first voucher in each independent group.

5. The method according to claim 4, wherein The method further includes: Update the voucher numbers that are not repeated with the voucher numbers already existing in the database and the first voucher number in the serial vouchers to the database.

6. The method according to claim 4, wherein The method further includes: Judge whether the child thread where the serial vouchers are located needs to notify the parent thread; If so, notify the parent thread of the voucher numbers that are not repeated with the voucher numbers already existing in the database and the first voucher number in the serial vouchers.

7. A system for generating voucher numbers, characterized in that, Including: An acquisition unit for acquiring parallel vouchers from multiple parallel external sources, where each voucher carries its own voucher number; A serial unit for sending the parallel vouchers to a servo conveyor belt so that the servo conveyor belt serializes the parallel vouchers to generate serial vouchers, where the servo conveyor belt includes a loop statement and a queue, or includes a loop statement and a list, or includes a loop statement and an array set. When the parallel vouchers are placed in the queue, the list, or the array set, the loop statement is used to drive the code to sequentially obtain the parallel vouchers from the queue, the list, or the array set so that the parallel vouchers are serialized to generate serial vouchers; An integration unit for taking out a preset number of vouchers from the serial vouchers and integrating the multiple vouchers into a processing set by using an integrator; A duplicate-checking unit for determining whether the voucher numbers of each voucher in the processing set are duplicate with the existing voucher numbers in a database; The obtaining unit is further configured to obtain a first voucher whose voucher number is duplicate with an existing voucher number when the voucher numbers of each voucher in the processing set are duplicate with the existing voucher numbers in the database; A generating unit for calling an available voucher number generation algorithm to generate a first voucher number that is not duplicate with the existing voucher number for the first voucher; 8. A computer device, comprising a processor, characterized in that, When the processor executes a computer program stored in a memory, it is configured to implement the method for generating a voucher number according to any one of claims 1 to 6; 9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it is configured to implement the method for generating a voucher number according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Document number generating method and document number generating system

    CN102609330A

  • Processing method and system for number with unified certificate number and private certificate number

    CN104112191A