Method, device and system for acquiring single number

文档序号:8248 发布日期:2021-09-17 浏览:51次 中文

1. A method of obtaining a ticket number, comprising:

analyzing the single number rule configuration input by the user;

configuring and generating a single number according to the analyzed single number rule;

when a single number acquisition request is received, sending a single number;

wherein, the single number rule configuration at least comprises a batch number segment and a random number segment.

2. The method of acquiring a ticket number according to claim 1,

the single number rule configuration further comprises one or more of a prefix, a suffix, and a custom segment.

3. The method of acquiring a ticket number according to claim 2,

when the single number rule configuration comprises a prefix, a suffix and a custom section, the sequence of the single number rule configuration sequentially comprises the prefix, the batch number section, the custom section, a random number section and the suffix.

4. The method of acquiring a ticket number according to claim 1,

each batch number segment corresponds to at least two random numbers, and the number of the random numbers corresponding to each batch number segment is random.

5. The method of acquiring a ticket number according to claim 4,

and when the number of the remaining random numbers corresponding to the current batch number segment is less than the preset number, triggering to generate the random number corresponding to the next batch number segment.

6. The method of acquiring a ticket number according to claim 1,

and the random number segment is stored in a bit two-dimensional array mode.

7. An apparatus for obtaining a ticket number, comprising:

the rule analysis unit is used for analyzing the single number rule configuration input by the user;

the single number generating unit is used for configuring and generating a single number according to the analyzed single number rule;

the single number sending unit is used for sending the single number when receiving the single number obtaining request;

wherein, the single number rule configuration at least comprises a batch number segment and a random number segment.

8. The apparatus for acquiring the ticket number according to claim 7, further comprising:

and the trigger is used for triggering and generating the random number corresponding to the next batch number segment when the number of the residual random numbers corresponding to the current batch number segment is less than the preset number.

9. The apparatus for acquiring the ticket number according to claim 7, further comprising:

and the memory is used for storing the random number segment in a bit two-dimensional array mode.

10. A system for obtaining a ticket number, comprising: a user terminal and a device for acquiring the single number,

the user side is used for inputting the single number rule configuration and sending a single number acquisition request to the device for acquiring the single number;

the device for acquiring the single number is used for analyzing the single number rule configuration input by the user side, generating the single number according to the analyzed single number rule configuration, and sending the single number to the user side when receiving a single number acquisition request;

wherein, the single number rule configuration at least comprises a batch number segment and a random number segment.

Background

With diversification of business modes, such as bank transactions, logistics transportation, product sales and the like, a unique single number is required for each transaction in an application scene so as to manage various types of businesses. The current unique single number is generally generated by adopting a self-increment mode or a snowflake algorithm, the self-increment mode is to customize a data table of a maximum number mechanism, on the basis that the maximum number is not exceeded, the current single number is increased by 1 each time to be used as a new single number, and the single number is stored in the maximum data table at the same time, the order rule and the quantity of the single number generated by the self-increment mode are predictable, a user can calculate the service volume of a service end according to the order number, and the risk of service information leakage exists; the single number generated by the snowflake algorithm can avoid the problems, but the length of the single number is too long, so that adverse effects are caused on storage and query, and the single number rule has no meaning.

Disclosure of Invention

In order to solve the problems in the prior art, the invention provides a method, a device and a system for acquiring a single number, which are suitable for different service scenes.

In order to achieve the object, the present invention provides a method for acquiring a single number, comprising:

analyzing the single number rule configuration input by the user;

configuring and generating a single number according to the analyzed single number rule;

when a single number acquisition request is received, sending a single number;

wherein, the single number rule configuration at least comprises a batch number segment and a random number segment.

Preferably, the single number rule configuration further comprises one or more of a prefix, a suffix, and a custom segment.

Preferably, when the single number rule configuration comprises a prefix, a suffix and a custom section, the sequence of the single number rule configuration is the prefix, the batch number section, the custom section, the random number section and the suffix.

Preferably, in the method for acquiring the single number,

each batch number segment corresponds to at least two random numbers, and the number of the random numbers corresponding to each batch number segment is random.

Preferably, when the number of the remaining random numbers corresponding to the current batch number segment is less than the preset number, the random number corresponding to the next batch number segment is generated by triggering.

Preferably, in the method for obtaining the single number,

and the random number segment is stored in a bit two-dimensional array mode.

The invention also provides a device for acquiring the single number, which is characterized by comprising the following components:

the rule analysis unit is used for analyzing the single number rule configuration input by the user;

the single number generating unit is used for configuring and generating a single number according to the analyzed single number rule;

the single number sending unit is used for sending the single number when receiving the single number obtaining request;

wherein, the single number rule configuration at least comprises a batch number segment and a random number segment.

Preferably, the apparatus for acquiring a ticket number further includes:

and the trigger is used for triggering and generating the random number corresponding to the next batch number segment when the number of the residual random numbers corresponding to the current batch number segment is less than the preset number.

Preferably, the apparatus for acquiring a ticket number further includes:

and the memory is used for storing the random number segment in a bit two-dimensional array mode.

The invention also provides a system for acquiring the single number, which comprises: a user terminal and a device for acquiring the single number,

the user side is used for inputting the single number rule configuration and sending a single number acquisition request to the device for acquiring the single number;

the device for acquiring the single number is used for analyzing the single number rule configuration input by the user side, generating the single number according to the analyzed single number rule configuration, and sending the single number to the user side when receiving a single number acquisition request;

wherein, the single number rule configuration at least comprises a batch number segment and a random number segment.

The method, the device and the system for acquiring the single number can enable a user to define the rule and the length of the single number by himself, and are convenient for configuring different single numbers according to different service scenes; furthermore, the method, the device and the system for acquiring the single number can effectively avoid the problem of service information leakage while generating the batch number section in a self-increment mode and generating the random number section by a random algorithm to generate a sufficient number of non-repeated single numbers.

Drawings

FIG. 1 is a schematic flow chart of a method for acquiring a single number according to an embodiment of the present invention;

fig. 2 is a schematic diagram of a user-side operation interface according to an embodiment of the present invention;

FIG. 3 is a diagram illustrating a single number rule configuration according to an embodiment of the present invention;

FIG. 4 is a schematic diagram of a bit two-dimensional array storage method according to an embodiment of the present invention;

FIG. 5 is a schematic structural diagram of an apparatus for acquiring a ticket number according to an embodiment of the present invention;

fig. 6 is a schematic structural diagram of a system for acquiring a ticket number according to an embodiment of the present invention.

Detailed Description

The following description of the embodiments of the present invention is provided for illustrative purposes, and other advantages and effects of the present invention will become apparent to those skilled in the art from the present disclosure. While the invention will be described in conjunction with the preferred embodiments, it is not intended that features of the invention be limited to these embodiments. Rather, the invention has been described in connection with embodiments thereof for the purpose of covering all alternatives and modifications which may fall within the scope of the invention as defined by the appended claims. In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present invention. The invention may be practiced without these particulars. Moreover, some of the specific details have been left out of the description in order to avoid obscuring or obscuring the focus of the present invention.

At present, the generation of the single number generally adopts a self-increment mode or a snowflake algorithm mode, the rule and the quantity of the single number generated by adopting the self-increment mode are predictable, a user can calculate the service volume of a server according to the single number, and the risk of business information leakage exists; the single number generated by adopting the snowflake algorithm can avoid the problems, but the single number is too long in length, needs to be generated immediately, is unfavorable for storage and query of the single number, and has no meaning in the single number rule.

In order to solve the problems in the prior art, the invention provides a method, a device and a system for acquiring a single number, which have strong confidentiality and are convenient to store and query. The technical scheme of the invention is explained in detail in the following with the accompanying drawings.

Fig. 1 is a schematic flowchart of a method for acquiring a single number according to an embodiment of the present invention. As shown in fig. 1, the method for acquiring a single number includes:

s10, analyzing the single number rule configuration input by the user;

s20, generating a single number according to the analyzed single number rule configuration;

s30, when a single number acquisition request is received, sending a single number;

wherein, the single number rule configuration at least comprises a batch number segment and a random number segment.

And executing S10 to analyze the single number rule configuration input by the user. The user inputs the single number rule configuration through the operation of the user side, the user side can be a portable intelligent terminal or a designated terminal, the user side comprises an operation interface, the user sets the single number rule configuration through the operation interface, and fig. 2 is a schematic diagram of the user side operation interface of the embodiment of the invention. As shown in fig. 2, the operation interface includes but is not limited to: the method comprises the following steps of inputting items such as a single number name (name), a code, a current batch initial value (current value), a single number format rule configuration (format), whether to generate an ordered single number (sequencing) and the like. Wherein, the single number rule configuration is realized by editing a 'format' column.

In this embodiment, the single number rule configuration at least includes a batch number segment and a random number segment. In this embodiment, the batch number segment set by the user may be generated in a self-increment manner, and the random number segment may be generated by a random algorithm.

Specifically, in practical application, the batch number can be 1-3 digits, and a user can specify the batch number according to own requirements. In this embodiment, the self-increment mode is to customize a data table of the maximum number mechanism, and based on the maximum number, the current single number is increased by 1 each time to be used as a new single number. As will be appreciated by those skilled in the art, the batch number segment may also be generated in a self-decreasing manner, and is not limited herein.

In practical applications, the random number may be generated by a random number generator that generates a random number by a random number generation function provided in software and a program language such as C language, C + +, C #, Java, Matlab, PHP, C51, and similarly, a user may specify the number of digits of the random number according to his/her needs.

In this embodiment, the single number rule configuration may further include one or more of a prefix, a suffix, and a custom segment.

When the single number rule configuration comprises a prefix, a suffix and a custom section, the sequence of the single number rule configuration can be the prefix, the batch number section, the custom section, the random number section and the suffix in turn. The prefix, the custom section and the suffix are also values designated by a user, and specifically can be used for representing the time of a single number, the type of the single number, the machine room identifier and other contents. The format rule configuration of the single number may also be in other orders, and is not limited herein.

Fig. 3 is a schematic diagram of a single number rule configuration according to an embodiment of the present invention. As shown in fig. 3, when the single sign rule input by the user is configured as P [% 07d ] 01% 02d s, it can be analyzed that P is a prefix, [% 07d ] is a lot number segment ([ ] is a truncated symbol), 01 is a custom segment,% 02d is a random number segment, and s is a suffix. Through the setting, the user can define the single number rule and the length by himself, and different single numbers can be configured conveniently according to different service scenes.

And executing S20 to generate the single number according to the analyzed single number rule configuration.

In this embodiment, when the single number is generated, each batch number segment corresponds to at least two random numbers, and the number of the random numbers corresponding to each batch number segment is also random. As described above, the batch number is self-increasing, the batch number is automatically increased by 1 after the random number corresponding to the current batch number is used, so as to form a new batch number, in order to increase the unpredictability of a single number, the number of random numbers corresponding to each batch number is not fixed, and the random number generator calculates an unfixed value smaller than the maximum value represented by the length according to the length of the random numbers configured by the user as the number of random numbers corresponding to the batch number. Therefore, when the random number segment generates a sufficient number of non-repeated single numbers, the problem of service information leakage is effectively avoided.

Further, in this embodiment, when the number of the remaining random numbers corresponding to the current batch number is less than the preset number, the generation of the random number corresponding to the next batch number is triggered. The random number can adopt a preloading mode, and when the random number corresponding to the previous batch number is used, the random number corresponding to the next batch number is generated in advance; the specific process may be that point points to segment (data space) currently in use, segment is currently in use as _ segment1, and when the random number in segment1 is to be obtained, and the remainder is less than a certain proportion, the next segment _2 is automatically triggered to generate the next random number in advance; when segment1 is completely used, point will switch to point to segment 2; when the single number is acquired again, the single number is acquired from the segment2, and the acquisition is sequentially carried out. The previously generated random numbers of the next batch before the previous batch is completely used refers to the random numbers of the next batch generated in advance when N (N is a natural number greater than or equal to 1) of the random numbers corresponding to the current batch remain or when the remaining number percentage is lower than a specified threshold. When the user obtains the single number, a random number can be taken out from the current segment and the complete single number can be generated by combining the current batch number and the single number rule.

In this embodiment, the random number segment may be stored in a bit two-dimensional array manner. FIG. 4 is a schematic diagram of a bit two-dimensional array storage method according to an embodiment of the present invention. In this embodiment, in order to reduce the occupation of a large number of random numbers on the memory, the random numbers are stored in a bit two-dimensional array mode, each random number occupies 1 bit, and the index of the bit in the two-dimensional array represents the value of the random number. The value of the bit array index corresponding to the generated random number is marked as 1, and as shown in fig. 4, the gray marking block is the position of the bit two-dimensional array where the random number is stored. In this embodiment, the length of the bit array in each row is 64, and the bit two-dimensional array index corresponding to a certain numerical value can be quickly calculated according to the displacement operation.

Based on the same inventive concept, the invention also provides a device for acquiring the single number. Fig. 5 is a schematic structural diagram of an apparatus for acquiring a ticket number according to an embodiment of the present invention, and as shown in fig. 5, the apparatus includes:

a rule analysis unit 21, configured to analyze a single number rule configuration input by a user;

a single number generating unit 22, configured to generate a single number according to the parsed single number rule;

a single number sending unit 23, configured to send a single number when receiving a single number obtaining request;

wherein, the single number rule configuration at least comprises a batch number segment and a random number segment.

Further, the apparatus for acquiring a single number further includes: and the trigger is used for triggering and generating the random number corresponding to the next batch number section when the residual random number corresponding to the current batch number section is less than the preset number.

Further, the apparatus for acquiring a single number further includes: and the memory is used for storing the random number segment in a bit two-dimensional array mode.

For the implementation of the apparatus for acquiring a ticket number in this embodiment, please refer to the implementation of the method for acquiring a ticket number, which is not described herein again.

Based on the same inventive concept, the invention also provides a system for acquiring the single number. Fig. 6 is a schematic structural diagram of a system for acquiring a ticket number according to an embodiment of the present invention, and as shown in fig. 6, the system includes: a user terminal 10 and a device 20 for acquiring a single number; the user terminal 10 is configured to input a single number rule configuration, and send a single number obtaining request to the device 20 for obtaining a single number; the device 20 for acquiring the single number is configured to parse the single number rule configuration input by the user end and generate the single number according to the parsed single number rule configuration, and when receiving a single number acquisition request, send the single number to the user end, where the single number rule configuration at least includes a batch number segment and a random number segment.

In this embodiment, the user terminal 10 may be a portable intelligent terminal or a designated terminal, and the user terminal 10 and the device 20 for acquiring a single number are connected through a Restful interface. The user terminal 10 includes an operation interface, and the user sets the rule configuration of the single number and sends a request for the single number to the device for acquiring the single number through the operation interface. The device 20 for acquiring the single number comprises a rule analysis unit 21, a single number rule configuration unit and a single number processing unit, wherein the rule analysis unit 21 is used for analyzing the single number rule configuration input by a user; a single number generating unit 22, configured to generate a single number according to the parsed single number rule; and a single number sending unit 23, configured to send a single number when receiving the single number obtaining request.

The method, the device and the system for acquiring the single number in the embodiment of the invention can enable a user to define the rule and the length of the single number by himself, so that the user can configure different single numbers according to different service scenes; furthermore, the method, the device and the system for acquiring the single number effectively avoid the problem of service information leakage while generating the batch number section in a self-increment mode and generating the random number section by a random algorithm to generate a sufficient number of unrepeated single numbers; furthermore, the method, the device and the system for acquiring the single number store the random number in a bit two-dimensional array mode, so that the occupation of a large number of random numbers on a memory is reduced.

Based on the same technical concept, embodiments of the present invention provide a computer device, which includes at least one processor and at least one memory, wherein the memory stores a computer program, and when the program is executed by the processor, the processor is enabled to execute the above-mentioned method for acquiring a single number.

Based on the same technical concept, embodiments of the present invention provide a computer-readable storage medium, wherein instructions of the storage medium, when executed by a processor in a device, enable the device to perform the above-mentioned method of acquiring a single number.

Optionally, a memory for storing a program; a Memory, which may include a volatile Memory (RAM), such as a Random Access Memory (SRAM), a Double Data Rate Synchronous Dynamic Random Access Memory (DDR SDRAM), and the like; the memory may also comprise a non-volatile memory, such as a flash memory. The memories are used to store computer programs (e.g., applications, functional modules, etc. that implement the above-described methods), computer instructions, etc., which may be stored in partition in the memory or memories. And the computer programs, computer instructions, data, etc. described above may be invoked by a processor.

The computer programs, computer instructions, etc. described above may be stored in one or more memories in a partitioned manner. And the computer programs, computer instructions, data, etc. described above may be invoked by a processor.

A processor for executing the computer program stored in the memory to implement the steps of the method according to the above embodiments. Reference may be made in particular to the description relating to the preceding method embodiment.

The processor and the memory may be separate structures or may be an integrated structure integrated together. When the processor and the memory are separate structures, the memory, the processor may be coupled by a bus.

It should be noted that, the steps in the method provided by the present invention may be implemented by using corresponding modules, devices, units, and the like in the system, and those skilled in the art may implement the composition of the system by referring to the technical solution of the method, that is, the embodiment in the method may be understood as a preferred example for constructing the system, and will not be described herein again.

Those skilled in the art will appreciate that, in addition to implementing the system and its various devices provided by the present invention in purely computer readable program code means, the method steps can be fully programmed to implement the same functions by implementing the system and its various devices in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Therefore, the system and various devices thereof provided by the present invention can be regarded as a hardware component, and the devices included in the system and various devices thereof for realizing various functions can also be regarded as structures in the hardware component; means for performing the functions may also be regarded as structures within both software modules and hardware components for performing the methods.

The embodiments of the invention are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or change the above-mentioned embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:水利工程测量中的编码转换及数据处理方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!