Numbering method and system for software system
By combining timestamps, self-increase, random and cumulative downtime generation numbers, the problems of excessively long number length, insufficient capacity and insufficient security in the prior art are solved, and efficient, safe and applicable numbers are generated.
Patent Information
- Application Number
- CN202111327780.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-10
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2041-11-10
AI Technical Summary
In the prior art, the number generated by UUID and snowflake algorithms is long in length and the capacity is insufficient, and the number generated by the database primary key is self-increasing and is easily exploited by the destroyer, resulting in insecure information.
By obtaining the timestamp, self-increment value, random value and cumulative number of downtime, a number is generated based on the preset binary (such as 62 or 88). The timestamp bits ensure the timing of the number, the self-increment bits ensure the number increments, the random bits avoid the same number within a single second, and the cumulative number of downtime digits are used to alert and prevent time fallback.
The generated numbers have a short length, large capacity, and strong timing, which avoids the number being destroyed and improves information security. They are suitable for systems with large numbering requirements.
Smart Images

Figure CN114254589B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a numbering method and system for software systems. Background Art
[0002] Currently, in order to make the target easy to find, it is usually necessary to mark the target. For example, the target can be an order, a flow, or a machine.
[0003] When marking the target, a universally unique identifier (UUID) is usually used for marking, and the target number can also be automatically generated by a computer. For example, the computer can automatically generate the target number by using a database primary key self-increment method or a snowflake algorithm.
[0004] However, the length of the target number generated by UUID and the snowflake algorithm is usually long, and the number capacity that can be generated is not large enough, so it cannot be applied to systems with large numbering requirements. The target number generated by the database primary key self-increment method is easy to be exploited by saboteurs because the numbering regularity of different targets is obvious, making the target-related information unsafe. Summary of the invention
[0005] The present invention provides a numbering method and system applied to a software system, so as to solve the defects existing in the prior art.
[0006] The present invention provides a number generation method applied to a software system, comprising:
[0007] Obtain the first value of the timestamp bit at the current moment, the second value of the self-increment bit, and the third value of the random bit;
[0008] Generate a number of the target in the software system based on the first value, the second value, and the third value;
[0009] The first value, the second value and the third value are all data in a preset base, and the base of the preset base includes numbers and letters, or includes numbers, letters and special characters.
[0010] According to a numbering method for a software system provided by the present invention, a numbering of a target in the software system is generated based on the first value, the second value, and the third value, and the method also includes:
[0011] Obtaining a fourth value of the cumulative number of downtimes at the current moment, wherein the fourth value is data in the preset base;
[0012] Accordingly, generating a number of the target in the software system based on the first value, the second value, and the third value specifically includes:
[0013] The number is generated based on the first value, the second value, the third value, and the fourth value.
[0014] According to a numbering method for a software system provided by the present invention, the number of bits of the timestamp bit, the self-increment bit, the random bit, and the cumulative number of downtime bits is determined based on the following method:
[0015] determining a target number of digits for the number;
[0016] The number of bits of the timestamp bit, the auto-increment bit, the random bit, and the cumulative number of downtime bits is determined based on the target number of bits and the preset base system.
[0017] According to a numbering method for a software system provided by the present invention, the preset base is base 62, the number of bits of the timestamp bit is 7, the number of bits of the random bit is 3, the number of bits of the accumulated number of downtimes bit is 1, and the number of bits of the self-increment bit is determined based on the target number of bits, the number of bits of the timestamp bit, the number of bits of the random bit and the number of bits of the accumulated number of downtimes bit.
[0018] According to a numbering method for a software system provided by the present invention, the preset base is base 88, the number of bits of the timestamp bit is 7, the number of bits of the random bit is 3, the number of bits of the cumulative number of downtimes bit is 1, and the number of bits of the self-increment bit is determined based on the target number of bits, the number of bits of the timestamp bit, the number of bits of the random bit and the number of bits of the cumulative number of downtimes bit.
[0019] According to a numbering method for a software system provided by the present invention, the second value is determined based on the following method:
[0020] Obtaining the fifth value of the self-incrementing bit at a moment before the current moment;
[0021] The second value is determined based on the fifth value and any random number corresponding to the preset base.
[0022] According to a numbering method for a software system provided by the present invention, generating a number of a target in the software system based on the first value, the second value, and the third value specifically includes:
[0023] The number is generated based on the first value, the second value, and the third value by adopting the NIO asynchronous distribution strategy.
[0024] The present invention also provides a numbering system applied to a software system, comprising:
[0025] An acquisition module, used to acquire a first value of a timestamp bit at a current moment, a second value of a self-increment bit, and a third value of a random bit;
[0026] A generating module, configured to generate a number of a target in a software system based on the first value, the second value, and the third value;
[0027] The first value, the second value and the third value are all data in a preset base, and the base of the preset base includes numbers and letters, or includes numbers, letters and special characters.
[0028] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-described numbering methods applied to a software system are implemented.
[0029] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described numbering generation methods applied to a software system.
[0030] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the steps of any of the above-mentioned numbering generation methods applied to a software system are implemented.
[0031] The numbering generation method and system for software systems provided by the present invention first obtain the first value of the timestamp bit at the current moment, the second value of the self-increment bit, and the third value of the random bit; then, based on the first value, the second value, and the third value, the numbering of the target in the software system is generated; wherein, the first value, the second value, and the third value are all data of a preset base, and the preset base includes a 62-base or an 88-base. By setting the timestamp bit, the obtained numbering can be made time-sequential, which is convenient for quick query of the target. By setting the self-increment bit, it can be ensured that the numbering is incremented within a single second. By setting the random bit, the same numbering within a single second can be avoided. In addition, since the first value, the second value, and the third value are all data of the 62-base or 88-base, not only can the length of the numbering be greatly shortened, but also the numbering quantity that can be generated can be increased, which can be applied to systems with large numbering requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0033] Figure 1 It is a flow chart of a number generation method applied to a software system provided by the present invention;
[0034] Figure 2 It is a structural schematic diagram of a number generation system applied to a software system provided by the present invention;
[0035] Figure 3 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] Figure 1 FIG. 1 is a flow chart of a method for generating a number applied to a software system provided in an embodiment of the present invention. Figure 1 As shown, the method includes:
[0038] S1, obtaining a first value of the timestamp bit at the current moment, a second value of the self-increment bit, and a third value of the random bit;
[0039] S2, generating a number of the target in the software system based on the first value, the second value and the third value;
[0040] The first value, the second value and the third value are all data in a preset base, and the base of the preset base includes numbers and letters, or includes numbers, letters and special characters.
[0041] Specifically, the numbering generation method applied to the software system provided in the embodiment of the present invention has a numbering generation system as its execution subject, which can be configured in a server, which can be a local server or a cloud server. The local server can be a computer, a tablet computer, and a smart phone, etc., which is not specifically limited in the embodiment of the present invention. The numbering generation method provided in the embodiment of the present invention can be applied to the software system to obtain the number of the target in the software system, and the target can be identified by the number, so as to track, query, and search the target later. The software system can be an order system, a flow system, etc., or a system for storing and managing machine equipment information, or a database system, etc., which is not specifically limited in the embodiment of the present invention. Accordingly, the target can be an order, a flow, a machine equipment, a database data, etc. Furthermore, the number of the target can be an order number, a flow number, a machine equipment identification, and a database primary key (index), etc.
[0042] First, step S1 is performed to obtain a first value of the timestamp bit at the current moment, a second value of the self-increment bit, and a third value of the random bit, wherein the current moment refers to the moment when the number is generated.
[0043] The composition structure of the number may include a timestamp bit, a self-increment bit and a random bit. The positions of the timestamp bit, the self-increment bit and the random bit in the number can be set as needed. For example, they can be arranged in the order of timestamp bit, self-increment bit and random bit, or the timestamp bit, self-increment bit and random bit can be arranged in other random orders. This is not specifically limited in the embodiments of the present invention.
[0044] The first value of the timestamp bit is used to represent the timestamp of the current moment. The timestamp can be accurate to seconds, which can ensure that the production numbers are sequential and facilitate quick query of the target.
[0045] The second value of the self-increment bit is used to represent the self-increment data at the current moment. The second value can be incremented within a single second, and the form of increase can be set as needed. For example, it can be a continuous increase or a discontinuous increase. That is, for two codes generated successively, the second data of the self-increment bit of the first code generated later is based on the second data of the self-increment bit of the second code generated earlier, plus a number in a random base.
[0046] The third value of the random bit is used to represent the random data at the current moment, and the third value can completely avoid conflicts with the same number within a single second.
[0047] It should be noted that, in order to reduce the length of the generated number, the base numbers of the first value, the second value and the third value can be set to a preset base, that is, the first value, the second value and the third value are all data of the preset base. The preset base can be set as needed, and the base of the preset base includes numbers and letters, or includes numbers, letters and special characters.
[0048] When the base of the preset base includes numbers and letters, there are 10 numbers and 26 uppercase letters and 26 lowercase letters, for a total of 52. Therefore, the preset base can be up to 62 bases at this time, and the value of the preset base can be adjusted by increasing or decreasing the base of the preset base.
[0049] When the base of the preset base includes numbers, letters and special characters, there are 10 numbers, 26 uppercase letters and 26 lowercase letters, a total of 52, and 26 special characters. Therefore, the preset base can be up to 88 bases, and the value of the preset base can be adjusted by increasing or decreasing the base of the preset base.
[0050] Taking the preset base 62 as an example, the base may include 62 elements, including 10 numbers, 26 lowercase letters, and 26 uppercase letters, that is, the base may include: “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”.
[0051] Taking the preset base 88 as an example, its base can include 88 elements such as 10 numbers, 26 lowercase letters, 26 uppercase letters and 26 special symbols, namely: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_-+={}[]|\ / ?<>.".
[0052] Since the base number of the number is adjustable, the n-base can be switched to the m-base at will by increasing or decreasing the base. Since the base code table of the n-base can generate a new code table by randomly shuffling the order without increasing or decreasing the base, theoretically there are a total of n! (n factorial) code tables in the n-base, which enriches the code table.
[0053] Then, step S2 is executed to automatically generate the number of the target in the software system according to the first value of the timestamp bit, the second value of the self-increment bit, and the third value of the random bit. The timestamp bit, the self-increment bit, and the random bit all correspond to a fixed number of bits, so when automatically generating the number, the first value, the second value, and the third value can be represented by the number of bits of the corresponding bits to obtain the number of the target in the software system.
[0054] The numbering generation method applied to the software system provided in the embodiment of the present invention first obtains the first value of the timestamp bit at the current moment, the second value of the self-increment bit, and the third value of the random bit; then, based on the first value, the second value, and the third value, the numbering of the target in the software system is generated; wherein, the first value, the second value, and the third value are all data of a preset base, and the preset base includes a 62-base or an 88-base. By setting the timestamp bit, the obtained numbering can be made time-sequential, which is convenient for quick query of the target. By setting the self-increment bit, it can be ensured that the numbering is incremented within a single second. By setting the random bit, the same numbering within a single second can be avoided. In addition, since the first value, the second value, and the third value are all data of a 62-base or an 88-base, not only can the length of the numbering be greatly shortened, but also the numbering quantity that can be generated can be increased, which can be applied to systems with large numbering requirements.
[0055] On the basis of the above embodiment, the numbering method for a software system provided in the embodiment of the present invention generates a number of a target in the software system based on the first value, the second value, and the third value, and also includes:
[0056] Obtaining a fourth value of the cumulative number of downtimes at the current moment, wherein the fourth value is data in the preset base;
[0057] Accordingly, generating a number of the target in the software system based on the first value, the second value, and the third value specifically includes:
[0058] The number is generated based on the first value, the second value, the third value, and the fourth value.
[0059] Specifically, in the embodiment of the present invention, before generating the number of the target in the software system, the fourth value of the current cumulative number of downtimes can also be obtained. The fourth value of the cumulative number of downtimes is used to represent the cumulative number of downtimes of the number generation system before the current moment.
[0060] The position of the cumulative number of downtimes in the number can be set as needed, for example, it can be after the random bit, or it can be set at any position, which is not specifically limited in the embodiment of the present invention.
[0061] It should be noted that the fourth value and the aforementioned first value, second value and third value are all data of a preset base, so that the consistency of the base of the number can be ensured.
[0062] After that, when generating the number of the target in the software system, the number can be generated according to the first value, the second value, the third value and the fourth value. Since the number of cumulative downtimes also corresponds to a fixed number of bits, when automatically generating the number, the first value, the second value, the third value and the fourth value can be simultaneously represented by the corresponding number of bits to obtain the number of the target in the software system.
[0063] In the embodiment of the present invention, the fourth value of the cumulative number of downtimes can be used to warn of the downtime status of the number generation system, so that the user can check whether the fourth value of the cumulative number of downtimes has changed, and thus grasp the working status of the number generation system. Moreover, since the cumulative number of downtimes is different before the number generation system crashes and when it restarts after the crash, the occurrence of time rollback caused by the crash of the number generation system can be further prevented. This method can be applied to a one-master-multiple-slave cluster to prevent the number generation system from crashing and being unable to provide external services.
[0064] On the basis of the above embodiment, the numbering method applied to the software system provided in the embodiment of the present invention further includes:
[0065] Monitor the working status of the number generation system and obtain monitoring results;
[0066] If the monitoring result shows that the number generation system is in a downtime state, the cumulative number of downtimes is increased by 1 to obtain a new cumulative number of downtimes;
[0067] When the number generation system is restarted, the new cumulative number of downtimes is used as the fourth value of the cumulative number of downtimes.
[0068] On the basis of the above-mentioned embodiment, in the numbering method for software system provided in the embodiment of the present invention, the number of bits of the timestamp bit, the self-increment bit, the random bit and the cumulative number of downtime bits is determined based on the following method:
[0069] determining a target number of digits for the number;
[0070] The number of bits of the timestamp bit, the auto-increment bit, the random bit, and the cumulative number of downtime bits is determined based on the target number of bits and the preset base system.
[0071] Specifically, in the embodiment of the present invention, when determining the number of bits of the timestamp bit, the auto-increment bit, the random bit, and the cumulative number of downtime bits, the target number of bits of the number can be determined first. The target number of bits can be set by the user as needed, for example, it can be set to 12, 15, etc.
[0072] Then, according to the target number of bits and the preset base, the number of bits of the timestamp bit, the self-increment bit, the random bit and the cumulative number of downtime bits are determined. Among them, the number of bits of the timestamp bit, the random bit and the cumulative number of downtime bits can be fixed values given by the user according to the value of the preset base, and then based on the target number of bits and the given number of bits of the timestamp bit, the number of bits of the self-increment bit is obtained.
[0073] In the embodiment of the present invention, it is necessary to first determine the target number of digits of the number so that the length of the number can be adjusted, and the length can be adjusted according to the specific actual situation.
[0074] On the basis of the above-mentioned embodiments, the number generation method applied to the software system provided in the embodiments of the present invention can realize the number generation through single-process memory processing, and can realize the high performance of the number generation system.
[0075] On the basis of the above-mentioned embodiments, the numbering generation method applied to the software system provided in the embodiments of the present invention has been tested by tens of thousands of threads, and the test results are all good, indicating that the method has high concurrency performance.
[0076] On the basis of the above embodiments, the numbering method for generating numbers applied to software systems provided in the embodiments of the present invention may have a preset base of 62, the number of bits of the timestamp bit may be 7, the number of bits of the random bit may be 3, the number of bits of the accumulated number of downtimes bit may be 1, and the number of bits of the self-increment bit may be determined based on the target number of bits, the number of bits of the timestamp bit, the number of bits of the random bit and the number of bits of the accumulated number of downtimes bit.
[0077] Specifically, in the embodiment of the present invention, the number of bits of the timestamp bit, the random bit, and the cumulative number of downtime bits can be given by the user in advance according to actual needs in the case of determining the preset base. Thereafter, the number of bits of the self-increment bit is determined by calculating the difference between the target number of bits and the number of bits of the timestamp bit, the random bit, and the cumulative number of downtime bits. For example, if the preset base is 62, the number of bits of the timestamp bit can be 7, the number of bits of the random bit can be 3, the number of bits of the cumulative number of downtime bits can be 1, and the target number of bits is n (n>11), then the number of bits of the self-increment bit is n-7-3-1.
[0078] In particular, when the preset base is 62, and n is 16, at least the following data numbers can be generated per second: Generally, 3.52 trillion to 218.34 trillion data numbers can be generated.
[0079] 62 16-7-1-1 =3.52 trillion
[0080] For example, the numbering could be "sH5K74a 000xy zDa 0", "sH5K74a 000xJ uTK 0", "sH5K74a000yF 41Q 0".
[0081] On the basis of the above embodiments, the numbering method for software system provided in the embodiments of the present invention, the preset base is base 88, the number of bits of the timestamp bit is 7, the number of bits of the random bit is 3, the number of bits of the cumulative number of downtimes bit is 1, and the number of bits of the self-increment bit is determined based on the target number of bits, the number of bits of the timestamp bit, the number of bits of the random bit and the number of bits of the cumulative number of downtimes bit.
[0082] Specifically, in the embodiment of the present invention, the number of bits of the timestamp bit, the random bit, and the cumulative number of downtime bits can be given by the user in advance according to actual needs in the case of determining the preset base. Thereafter, the number of bits of the self-increment bit is determined by calculating the difference between the target number of bits and the number of bits of the timestamp bit, the random bit, and the cumulative number of downtime bits. For example, if the preset base is 88, the number of bits of the timestamp bit can be 7, the number of bits of the random bit can be 3, the number of bits of the cumulative number of downtime bits can be 1, and the target number of bits is n (n>10), then the number of bits of the self-increment bit is n-7-3-1.
[0083] In particular, when the preset base is 88, and n is 24, at least the following data amount numbers can be generated per second.
[0084] 88 24-7-1-1 =1.47E+29≈14700
[0085] For example, the number may be "3Je2Rlu 0000000D / ykoOkf 0", "3Je2Ro6 0000000EZ&B.~4V0", "3Je2Roa 0000000FX kd9N05 0", "3Je2Roa 0000000Gb u8DZ)U 0".
[0086] On the basis of the above embodiment, in the numbering method applied to the software system provided in the embodiment of the present invention, the second value is determined based on the following method:
[0087] Obtaining the fifth value of the self-incrementing bit at a moment before the current moment;
[0088] The second value is determined based on the fifth value and any random number corresponding to the preset base.
[0089] Specifically, in the embodiment of the present invention, when determining the second value of the self-increment bit, the fifth value of the self-increment bit at a moment before the current moment may be obtained first.
[0090] Then, on the basis of the fifth value, any random number corresponding to the preset base can be added to obtain the second value of the self-incrementing digit at the current moment.
[0091] In an embodiment of the present invention, when determining the second value of the self-increment digit at the current moment, any random number corresponding to a preset base is introduced, which can ensure that the second value of the self-increment digit increases within a single second and is discontinuous before and after, thereby ensuring the irregularity of the generated numbering.
[0092] On the basis of the above embodiment, the method for generating a number applied to a software system provided in the embodiment of the present invention, wherein the method for generating a number of a target in the software system based on the first value, the second value, and the third value specifically includes:
[0093] The number is generated based on the first value, the second value, and the third value by adopting the NIO asynchronous distribution strategy.
[0094] Specifically, in the embodiment of the present invention, when generating the number of the target in the software system, the NIO asynchronous distribution strategy can be adopted to implement it, so that multiple masters and multiple slaves can be implemented, greatly increasing the numbering production efficiency.
[0095] like Figure 2 As shown, based on the above embodiment, an embodiment of the present invention provides a numbering system applied to a software system, including:
[0096] An acquisition module 21, used to acquire a first value of a timestamp bit at a current moment, a second value of a self-increment bit, and a third value of a random bit;
[0097] A generating module 22, configured to generate a number of a target in a software system based on the first value, the second value and the third value;
[0098] The first value, the second value and the third value are all data in a preset base, and the base of the preset base includes numbers and letters, or includes numbers, letters and special characters.
[0099] On the basis of the above-mentioned embodiment, in the numbering system for a software system provided in the embodiment of the present invention, the acquisition module is further used for:
[0100] Obtaining a fourth value of the cumulative number of downtimes at the current moment, wherein the fourth value is data in the preset base;
[0101] Accordingly, the generating module is specifically used for:
[0102] The number is generated based on the first value, the second value, the third value, and the fourth value.
[0103] On the basis of the above embodiment, the numbering system for a software system provided in the embodiment of the present invention further includes a first determining module, which is used to:
[0104] determining a target number of digits for the number;
[0105] The number of bits of the timestamp bit, the auto-increment bit, the random bit, and the cumulative number of downtime bits is determined based on the target number of bits and the preset base system.
[0106] On the basis of the above embodiments, the numbering system for software systems provided in the embodiments of the present invention, wherein the preset base is 62, the number of bits of the timestamp bit is 7, the number of bits of the random bit is 3, the number of bits of the cumulative number of downtimes bit is 1, and the number of bits of the self-increment bit is determined based on the target number of bits, the number of bits of the timestamp bit, the number of bits of the random bit and the number of bits of the cumulative number of downtimes bit.
[0107] On the basis of the above embodiments, the numbering system for software systems provided in the embodiments of the present invention, the preset base is base 88, the number of bits of the timestamp bit is 7, the number of bits of the random bit is 3, the number of bits of the cumulative number of downtimes bit is 1, and the number of bits of the self-increment bit is determined based on the target number of bits, the number of bits of the timestamp bit, the number of bits of the random bit and the number of bits of the cumulative number of downtimes bit.
[0108] On the basis of the above embodiment, the numbering system for a software system provided in the embodiment of the present invention further includes a second determining module, which is used to:
[0109] Obtaining the fifth value of the self-incrementing bit at a moment before the current moment;
[0110] The second value is determined based on the fifth value and any random number corresponding to the preset base.
[0111] On the basis of the above-mentioned embodiment, the number generation system applied to the software system provided in the embodiment of the present invention is used for:
[0112] The number is generated based on the first value, the second value, and the third value by adopting the NIO asynchronous distribution strategy.
[0113] Specifically, the functions of each module in the numbering generation system applied to the software system provided in the embodiment of the present invention correspond one-to-one to the operation process of each step in the above-mentioned method embodiment, and the effects achieved are also consistent. Please refer to the above-mentioned embodiment for details, and no further details will be given in the embodiment of the present invention.
[0114] Figure 3 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 3 As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other through the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute the number generation method applied to the software system provided in the above embodiments, the method comprising: obtaining the first value of the timestamp bit at the current moment, the second value of the self-increment bit and the third value of the random bit; based on the first value, the second value and the third value, generating the number of the target in the software system; wherein the first value, the second value and the third value are all data of a preset base, and the base of the preset base includes numbers and letters, or includes numbers, letters and special characters.
[0115] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0116] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the numbering method applied to the software system provided in the above embodiments, the method including: obtaining a first value of the timestamp bit at the current moment, a second value of the self-increment bit, and a third value of the random bit; based on the first value, the second value, and the third value, generating a number for the target in the software system; wherein the first value, the second value, and the third value are all data in a preset base, and the base of the preset base includes numbers and letters, or includes numbers, letters, and special characters.
[0117] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the numbering method applied to the software system provided in the above-mentioned embodiments, the method comprising: obtaining a first value of a timestamp bit at a current moment, a second value of a self-increment bit, and a third value of a random bit; based on the first value, the second value, and the third value, generating a number of the target in the software system; wherein the first value, the second value, and the third value are all data in a preset base, and the base of the preset base includes numbers and letters, or includes numbers, letters, and special characters.
[0118] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0119] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0120] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A numbering method applied to a software system, characterized in that: include: Obtain the first value of the timestamp bit at the current moment, the second value of the self-increment bit, and the third value of the random bit; Generate a number of the target in the software system based on the first value, the second value, and the third value; The first value, the second value and the third value are all data of a preset base, and the base of the preset base includes numbers and letters, or includes numbers, letters and special characters; Based on the first value, the second value, and the third value, a number of the target in the software system is generated, which also includes: Obtaining a fourth value of the cumulative number of downtimes at the current moment, wherein the fourth value is data in the preset base; Accordingly, generating a number of the target in the software system based on the first value, the second value, and the third value specifically includes: generating the serial number based on the first value, the second value, the third value, and the fourth value; The second value is determined based on the following method: Obtaining the fifth value of the self-incrementing bit at a moment before the current moment; The second value is determined based on the fifth value and any random number corresponding to the preset base.
2. The numbering method applied to a software system according to claim 1, characterized in that: The number of bits of the timestamp bit, the self-increment bit, the random bit, and the cumulative number of downtime bits is determined based on the following method: determining a target number of digits for the number; The number of bits of the timestamp bit, the auto-increment bit, the random bit, and the cumulative number of downtime bits is determined based on the target number of bits and the preset base system.
3. The numbering method applied to a software system according to claim 2, characterized in that: The preset base is base 62, the number of bits of the timestamp bit is 7, the number of bits of the random bit is 3, the number of bits of the accumulated number of downtimes bit is 1, and the number of bits of the self-increment bit is determined based on the target number of bits, the number of bits of the timestamp bit, the number of bits of the random bit and the number of bits of the accumulated number of downtimes bit.
4. The numbering method applied to a software system according to claim 2, characterized in that: The preset base is base 88, the number of bits of the timestamp bit is 7, the number of bits of the random bit is 3, the number of bits of the accumulated number of downtimes bit is 1, and the number of bits of the self-increment bit is determined based on the target number of bits, the number of bits of the timestamp bit, the number of bits of the random bit and the number of bits of the accumulated number of downtimes bit.
5. The numbering method applied to a software system according to any one of claims 1 to 4, characterized in that: The generating a number of the target in the software system based on the first value, the second value, and the third value specifically includes: The number is generated based on the first value, the second value, and the third value by adopting the NIO asynchronous distribution strategy.
6. A numbering system for a software system, characterized in that: include: An acquisition module, used to acquire a first value of a timestamp bit at a current moment, a second value of a self-increment bit, and a third value of a random bit; A generating module, configured to generate a number of a target in a software system based on the first value, the second value, and the third value; The first value, the second value and the third value are all data of a preset base, and the base of the preset base includes numbers and letters, or includes numbers, letters and special characters; The Get module is also used to: Obtaining a fourth value of the cumulative number of downtimes at the current moment, wherein the fourth value is data in the preset base; Accordingly, the generating module is specifically used for: generating the serial number based on the first value, the second value, the third value, and the fourth value; Also included is a second determining module, configured to: Obtaining the fifth value of the self-incrementing bit at a moment before the current moment; The second value is determined based on the fifth value and any random number corresponding to the preset base.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the numbering method applied to a software system as claimed in any one of claims 1 to 5 are implemented.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the numbering method applied to a software system as claimed in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Transmitting method and device capable of improving safety and reliability of communication data and reducing byte streams
CN105871896A
Serial number generation method and device, terminal device, and storage medium
CN109002276A
Method and device for generating order number by distributed architecture
CN110634052A