Service identification code generation method, device, storage medium and electronic device

By receiving the service identification code generation request and calculating the current serial number, a unique service identification code is generated, and the problem of low identification code generation efficiency in the prior art is solved, efficient identification code generation is achieved, and the throughput of the application system is improved.

CN111722918BActive Publication Date: 2025-02-21BEIJING WODONG TIANJUN INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910218029.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-03-21
Publication Date
2025-02-21
Estimated Expiration
2039-03-21

AI Technical Summary

Technical Problem

In the prior art, business identification code generation depends on the read and write performance and computing capabilities of the database. When the database performance is poor, the identification code generation efficiency is low, which affects the throughput of the application system.

Method used

By receiving the service identification code generation request, determine the service type information and date information, calculate the current serial number, and generate a unique service identification code based on the service type, date and serial number, avoiding direct dependence on the database for read and write operations.

Benefits of technology

Generating unique business identification codes without relying on the database significantly improves the efficiency of identification code generation, reduces dependence on database performance, and thus improves the throughput of the application system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111722918B_ABST
    Figure CN111722918B_ABST
Patent Text Reader

Abstract

The present invention provides a method, device, storage medium and electronic device for generating a service identification code. The service identification code generation method provided by an embodiment of the present invention comprises: receiving an identification code generation request of a first service, and determining service type information and service date information according to the received identification code generation request, and then determining the original serial number according to the service type information and service date information, and calculating the current serial number corresponding to the first service according to the original serial number and a preset coding isolation rule, and then determining the first coding segment of the service according to the service type information, determining the second coding segment according to the service date information, generating the third coding segment according to the current serial number, and determining the unique first service identification code corresponding to the first service through the first coding segment, the second coding segment and the third coding segment. The service identification code generation method provided by an embodiment of the present invention greatly improves the generation efficiency of the identification code on the basis of ensuring the generation of a unique identification code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of e-commerce technology, and in particular to a method, device, storage medium and electronic device for generating a business identification code. Background Art

[0002] With the development of Internet technology, each application system needs to generate a unique identification code when performing business processing to distinguish the same business operations of different users. For example, a unique identification code is generated as an order identification to distinguish orders for different users, different types and different dates; a unique identification code is generated as an outbound order identification to distinguish outbound orders from different users and different dates; a unique identification code is generated as a transaction identification to distinguish transaction operations of different types and different dates.

[0003] Currently, the business identification code is generated by utilizing the characteristics of the database's self-incrementing identification code primary key to perform read and write operations on the database. After each read and write operation, a unique identification code is obtained, and then the identification code is used as a unique mark for different businesses.

[0004] However, the identification code generation method in the prior art requires reading and writing the database each time a unique identification code is generated. Therefore, the efficiency of generating identification codes by the above method depends on the read-write performance and computing power of the database. When the read-write performance or computing power of the database is poor, the unique identification code generation efficiency is low, which will seriously affect the throughput of application systems such as order splitting and transfer out of warehouse. Summary of the invention

[0005] The present invention provides a method, device, storage medium and electronic device for generating a service identification code, so that the service identification code can be generated without relying on the characteristics of a database, and the generation efficiency of the identification code can be greatly improved on the basis of ensuring the generation of a unique identification code.

[0006] In a first aspect, an embodiment of the present invention provides a method for generating a service identification code, comprising:

[0007] receiving an identification code generation request for a first service, and determining service type information and service date information according to the identification code generation request;

[0008] Determine an original sequence number according to the business type information and the business date information, and calculate a current sequence number corresponding to the first business according to the original sequence number and a preset coding isolation rule, wherein the original sequence number is a sequence number corresponding to a second business, the second business has the same business date as the first business, and the second business is the closest to the first business and has the same business type as the first business;

[0009] Determine a first coding segment of the service according to the service type information, determine a second coding segment according to the service date information, and generate a third coding segment according to the current sequence number;

[0010] A first service identification code corresponding to the first service is determined according to the first coding segment, the second coding segment and the third coding segment.

[0011] In a possible design, after receiving the identification code generation request of the first service and determining the service type information and the service date information according to the identification code generation request, the method further includes:

[0012] Determine the application system name information and the service identification code name information corresponding to the first service according to the identification code generation request;

[0013] Determine a constant segment coding segment according to the application system name information and the service identification code name information, determine a date segment coding segment according to the service date information, and determine a service object attribute coding segment according to the service type information;

[0014] Determine a dynamic isolation factor according to the constant segment code segment, the business object attribute code segment and the date code segment;

[0015] A first service node is determined according to the dynamic isolation factor, where the first service node is a service node in a service node set, and the first service node is used to calculate the current sequence number and the first service identification code.

[0016] In a possible design, determining the first service node according to the dynamic isolation factor includes:

[0017] Determine a first check value according to the dynamic isolation factor and a preset check algorithm;

[0018] Determine a first computing slot according to the first check value and a preset number of slots, the first computing slot being a computing slot in a computing slot set, and the number of computing slots included in the computing slot set being the preset number of slots;

[0019] A first shard group is determined according to the first computing slot and preset computing slot mapping data, and the first service node in the first shard group is used to calculate the current sequence number and the first service identification code.

[0020] In one possible design, determining the first computing slot according to the first check value and a preset number of slots includes:

[0021] Calculate a first remainder of dividing the first check value by the preset number of slots;

[0022] The first calculation slot is determined according to the first remainder.

[0023] In a possible design, after determining the first shard group according to the first computing slot and preset computing slot mapping data, the method further includes:

[0024] Determine the first service node with the lowest utilization rate in the first shard group, where the first service node is used to calculate the current sequence number and the first service identification code.

[0025] In a possible design, after determining the original sequence number according to the service type information and the service date information, and calculating the current sequence number corresponding to the first service according to the original sequence number and a preset coding isolation rule, the method further includes:

[0026] Determine a first usage rate in a first sequence number segment in a first local cache according to the current sequence number;

[0027] Determining whether the first usage rate is greater than a preset ratio threshold;

[0028] If the judgment result is yes, the second thread is started according to the first serial number segment and the preset incremental step to cache the first serial number segment into the second local cache, wherein the first thread is used to calculate the current serial number corresponding to the first business, and the first thread and the second thread are parallel threads.

[0029] In a possible design, before determining a first usage rate in a first sequence number segment in a first local cache according to the current sequence number, the method further includes:

[0030] Querying whether there is an available sequence number segment in the local cache server according to the dynamic isolation factor;

[0031] If the judgment result is no, the first serial number segment is obtained from the cache server.

[0032] In a second aspect, an embodiment of the present invention further provides a service identification code generating device, comprising:

[0033] A request receiving module, used for receiving a request for generating an identification code of a first service;

[0034] An information determination module, used to determine the service type information and service date information according to the identification code generation request;

[0035] a sequence number determination module, configured to determine an original sequence number according to the service type information and the service date information, and calculate a current sequence number corresponding to the first service according to the original sequence number and a preset coding isolation rule, wherein the original sequence number is a sequence number corresponding to a second service, the second service has the same service date as the first service, and the second service is the service closest to the first service and has the same service type as the first service;

[0036] A coding segment determination module, used to determine a first coding segment of a service according to the service type information, determine a second coding segment according to the service date information, and generate a third coding segment according to the current sequence number;

[0037] An identification code determination module is used to determine a first service identification code corresponding to the first service according to the first coding segment, the second coding segment and the third coding segment.

[0038] In a possible design, the information determination module is further used to determine the application system name information and the service identification code name information corresponding to the first service according to the identification code generation request;

[0039] The coding segment determination module is further used to determine the constant segment coding segment according to the application system name information and the service identification code name information, determine the date segment coding segment according to the service date information, and determine the service object attribute coding segment according to the service type information;

[0040] The service identification code generating device further comprises:

[0041] An isolation factor determination module, used to determine a dynamic isolation factor according to the constant segment code segment, the business object attribute code segment and the date code segment;

[0042] The service node determination module is used to determine a first service node according to the dynamic isolation factor, wherein the first service node is a service node in a service node set, and the first service node is used to calculate the current sequence number and the first service identification code.

[0043] In a possible design, the service node determination module is specifically used to:

[0044] Determine a first check value according to the dynamic isolation factor and a preset check algorithm;

[0045] Determine a first computing slot according to the first check value and a preset number of slots, the first computing slot being a computing slot in a computing slot set, and the number of computing slots included in the computing slot set being the preset number of slots;

[0046] A first shard group is determined according to the first computing slot and preset computing slot mapping data, and the first service node in the first shard group is used to calculate the current sequence number and the first service identification code.

[0047] In a possible design, the service node determination module is further specifically used to:

[0048] Calculate a first remainder of dividing the first check value by the preset number of slots;

[0049] The first calculation slot is determined according to the first remainder.

[0050] In a possible design, the service node determination module is further specifically used to:

[0051] Determine the first service node with the lowest utilization rate in the first shard group, where the first service node is used to calculate the current sequence number and the first service identification code.

[0052] In a possible design, the serial number determination module is specifically used to:

[0053] Determine a first usage rate in a first sequence number segment in a first local cache according to the current sequence number;

[0054] Determining whether the first usage rate is greater than a preset ratio threshold;

[0055] If the judgment result is yes, the second thread is started according to the first serial number segment and the preset incremental step to cache the first serial number segment into the second local cache, wherein the first thread is used to calculate the current serial number corresponding to the first business, and the first thread and the second thread are parallel threads.

[0056] In a possible design, the serial number determination module is further specifically used for:

[0057] Querying whether there is an available sequence number segment in the local cache server according to the dynamic isolation factor;

[0058] If the judgment result is no, the first serial number segment is obtained from the cache server.

[0059] In a third aspect, an embodiment of the present invention further provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements any possible service identification code generation method in the first aspect.

[0060] In a fourth aspect, an embodiment of the present invention further provides an electronic device, including:

[0061] processor; and,

[0062] A memory, configured to store executable instructions of the processor;

[0063] The processor is configured to execute any possible service identification code generation method in the first aspect by executing the executable instructions.

[0064] The embodiments of the present invention provide a method, device, storage medium and electronic device for generating a business identification code. The method determines the business type information and the business date information according to the received identification code generation request, and then determines the original serial number according to the business type information and the business date information, and calculates the current serial number corresponding to the first business according to the original serial number and the preset coding isolation rule. In addition, the first coding segment of the business is determined according to the business type information, the second coding segment is determined according to the business date information, and the third coding segment is generated according to the current serial number. The unique first business identification code corresponding to the first business is determined through the first coding segment, the second coding segment and the third coding segment. The business identification code that is jointly unique by the business type, the business date and the unique current serial number is used to efficiently generate the business identification code, and the generation efficiency of the identification code is greatly improved on the basis of ensuring the generation of a unique identification code. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces 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 creative labor.

[0066] Figure 1 is a schematic diagram of an application scenario of a method for generating a service identification code according to an exemplary embodiment of the present invention;

[0067] Figure 2 is a flow chart of a method for generating a service identification code according to an exemplary embodiment of the present invention;

[0068] Figure 3 is a flow chart of a method for generating a service identification code according to another exemplary embodiment of the present invention;

[0069] Figure 4 yes Figure 3 A possible flow chart of step 206 in the illustrated embodiment;

[0070] Figure 5 yes Figure 3 Schematic diagram of node server determination principle in the illustrated embodiment;

[0071] Figure 6is a structural schematic diagram of a device for generating a service identification code according to an exemplary embodiment of the present invention;

[0072] Figure 7 is a structural schematic diagram of a device for generating a service identification code according to another exemplary embodiment of the present invention;

[0073] Figure 8 It is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0074] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments 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.

[0075] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0076] Figure 1 FIG. 1 is a schematic diagram of an application scenario of a method for generating a service identification code according to an exemplary embodiment of the present invention. Figure 1As shown, the service identification code generation method provided in the embodiment of the present invention can be applied to a distributed system, which can be composed of a downstream service 101, a routing proxy service 102, an identification code generation service 103 and a cache server 104. Among them, the dynamic isolation factor refers to an identifier used to distinguish each unique identification code that needs to be generated, which can be arbitrarily combined and passed in by the downstream service 101. The downstream service 101 can be a service belonging to an external system. The downstream service 101 calls the distributed identification code generation system, passes in the dynamic isolation factor, and obtains the generated distributed unique identification code. The routing proxy service 102 uses the dynamic isolation factor as a key to determine which specific shard group 103 to route to through a preset verification algorithm, and dynamically determines to call a certain service node 1031 according to the CPU and memory load of each node in the shard group. Multiple nodes in each shard group 103 can process the same dynamic isolation factor to generate a corresponding unique identification code. The service node 1031 in the shard group 103 obtains the sequence number segment corresponding to the dynamic isolation factor through the cache server 104, wherein, for example, the corresponding step length can be 1000 sequence numbers at a time, and the service node 1031 uses a double buffer area to ensure smooth acquisition of the sequence number. By vertically splitting the dynamic isolation factor shards, the service node 1031 in the shard group 103 is horizontally split according to the sequence number segment, and the unique identification code is determined by the identification code segment of the double buffer in the memory, the concurrent processing capability of the distributed identification code generation system is expanded, and the problem of efficiently generating unique identification codes in the case of high concurrency and massive data is solved.

[0077] Figure 2 FIG. 1 is a flow chart of a method for generating a service identification code according to an exemplary embodiment of the present invention. Figure 2 As shown, the service identification code generation method provided in this embodiment includes:

[0078] 101. Receive an identification code generation request for a first service.

[0079] Specifically, an identification code of the first business may be input for a user downstream service to generate a request, for example, an order request and a shipment request sent by a user through a terminal.

[0080] Step 102: Determine the service type information and service date information according to the identification code generation request.

[0081] Specifically, after receiving the identification code generation request of the first service, the service type information and service date information can be determined according to the identification code generation request. For example, the service type information is an order request, and the service date information can be 20181001

[0082] Step 103: determine the original serial number according to the business type information and the business date information, and calculate the current serial number corresponding to the first business according to the original serial number and the preset coding isolation rule.

[0083] Specifically, the original serial number can be determined based on the business type information and the business date information. It is worth understanding that the original serial number is the latest serial number used for the business type on that date. For example, the latest serial number used for the order business corresponding to the date 20181001 is 1000, and 1000 is the original serial number corresponding to the next serial number generation operation.

[0084] Then, the current serial number corresponding to the first business is calculated according to the original serial number and the preset coding isolation rule, wherein the original serial number is the serial number corresponding to the second business, the second business has the same business date as the first business, and the second business is the business closest to the first business and has the same business type as the first business. It is worth understanding that the preset coding isolation rule can be a digital iteration rule, for example, it can be an equal step increment method, and its step size can be adaptively selected according to actual conditions. For example, the step size can be selected as 1, then when the serial number corresponding to the second business is 1000, the current serial number corresponding to the current business is 1001. However, the above-mentioned preset coding isolation rule can be any other calculation rule based on numbers, symbols, letters and any sum thereof. It is not specifically limited in this embodiment. It is only necessary to ensure that the serial number generated on the same date according to the preset coding isolation rule is unique.

[0085] Step 104: determine the first coding segment of the service according to the service type information, determine the second coding segment according to the service date information, and generate the third coding segment according to the current sequence number.

[0086] In addition, the coding isolation rule is the rule source for generating the unique identification code, specifically, it can be composed of multiple coding segments, which can be divided into the first coding segment, the second coding segment, the third coding segment and the sequence coding segment, wherein the first coding segment can be the business type coding segment, the second coding segment is the date segment coding segment, and the third coding segment is the current serial number generated in step 103. For example, the current corresponding current serial number value is 13256, the value of the first coding segment is order_type=SO, that is, the business type is order business, the value of the second coding segment is the current date 20181001, and the value of the third coding segment is the current available serial number value 13256. In addition, the number of digits of the serial number can also be set to 10 digits, so it can be padded to the left to obtain the value 0000013256.

[0087] Step 105: Determine a first service identification code corresponding to the first service according to the first coding segment, the second coding segment, and the third coding segment.

[0088] After determining the first coding segment of the service according to the service type information, determining the second coding segment according to the service date information, and generating the third coding segment according to the current serial number, the first service identification code corresponding to the first service can be determined according to the first coding segment, the second coding segment and the third coding segment, for example, a corresponding unique first service identification code = SO201810010000013256 is generated, and the first service identification code is returned to the downstream service.

[0089] In this embodiment, the business type information and the business date information are determined according to the received identification code generation request, and then the original serial number is determined according to the business type information and the business date information, and the current serial number corresponding to the first business is calculated according to the original serial number and the preset coding isolation rule. In addition, the first coding segment of the business is determined according to the business type information, the second coding segment is determined according to the business date information, and the third coding segment is generated according to the current serial number. The unique first business identification code corresponding to the first business is determined through the first coding segment, the second coding segment and the third coding segment. The business identification code that is jointly unique by the business type, the business date and the unique current serial number is used to efficiently generate the business identification code, and the generation efficiency of the identification code is greatly improved on the basis of ensuring the generation of a unique identification code.

[0090] Figure 3 FIG. 1 is a flow chart of a method for generating a service identification code according to another exemplary embodiment of the present invention. Figure 3 As shown, the service identification code generation method provided in this embodiment includes:

[0091] Step 201: Receive a request for generating an identification code of a first service.

[0092] Step 202: Determine the service type information and service date information according to the identification code generation request.

[0093] It is worth noting that the specific implementation of steps 201-202 refers to the description of steps 101-102 in embodiment 1, which will not be repeated here.

[0094] Step 203: Determine the application system name information and the service identification code name information corresponding to the first service according to the identification code generation request.

[0095] Step 204: determine the constant segment coding segment according to the application system name information and the service identification code name information, determine the date segment coding segment according to the service date information, and determine the service object attribute coding segment according to the service type information.

[0096] Specifically, the constant segment coding segment can be determined based on the application system name information and the business identification code name information, wherein the constant segment coding segment returns a constant information as part of the generated coding information. The composition of the constant segment includes the segment sequence number, the constant segment type, and the content. The date segment coding segment is determined based on the business date information, wherein the date segment coding segment returns the current date in the specified date format as part of the generated coding information. The composition of the date segment includes the sequence number, the date segment type, and the current date format. The business object attribute coding segment is determined based on the business type information, wherein the business object attribute coding segment returns the value of the attribute of the specified business object as part of the generated coding information. The composition of the business object attribute segment includes the segment sequence number, the business object attribute segment type, and the business object attribute name.

[0097] Step 205: Determine a dynamic isolation factor according to the constant segment code segment, the business object attribute code segment, and the date code segment.

[0098] After determining the constant segment code segment according to the application system name information and the business identification code name information, determining the date segment code segment according to the business date information, and determining the business object attribute code segment according to the business type information, the dynamic isolation factor can be determined according to the constant segment code segment, the business object attribute code segment, and the date code segment. For example, after parsing, the corresponding dynamic isolation factor can be obtained as follows: "app1.order_id.SO.20181001", app1 is the constant segment code segment, order_id.SO is the business object attribute code segment, and 20181001 is the date segment code segment.

[0099] Step 206: Determine a first service node according to the dynamic isolation factor, where the first service node is used to calculate a current sequence number and a first service identification code.

[0100] In order to expand the concurrent processing capability of the distributed identification code generation system and solve the problem of efficiently generating unique identification codes in the case of high concurrency and massive data, a service node set can be set, and then the first service node can be determined according to the dynamic isolation factor. The first service node is used to calculate the current sequence number and the first business identification code, wherein the first service node is a service node in the service node set, and the first service node is used to calculate the current sequence number and the first business identification code. By using the dynamic isolation factor to determine the service node, different businesses can be assigned to different service nodes for processing, thereby effectively improving the computing speed.

[0101] Regarding the specific method of determining the first service node, Figure 4 yes Figure 3 A possible flow chart of step 206 in the embodiment shown. Figure 4 As shown, step 206 in this implementation includes:

[0102] Step 2061: Determine a first verification value according to the dynamic isolation factor and a preset verification algorithm.

[0103] Step 2062: Determine the first calculation slot according to the first check value and the preset number of slots.

[0104] Specifically, the input dynamic isolation factor is used as a key, and then a preset verification algorithm is used to implement data sharding, wherein the preset verification algorithm may be a CRC32 algorithm. It is worth noting that the CRC32 algorithm is an existing general algorithm and is widely used in the fields of data storage and data communication. Its specific operating principle will not be elaborated in this embodiment.

[0105] Then, a first computing slot is determined according to the first check value and the preset number of slots. The first computing slot is a computing slot in a computing slot set. The number of computing slots included in the computing slot set is the preset number of slots.

[0106] Figure 5 yes Figure 3 The schematic diagram of the node server determination principle in the embodiment shown. Figure 5 As shown, the preset number of slots in the computing slot set can be set to 4096, that is, 4096 computing slots are set, and the computing slots are numbered from 0 to 4095. Then, the first check value is divided by the first remainder of the preset number of slots. It is worth understanding that when the preset number of slots is set to 4096, the first remainder varies from 0 to 4095. For example, if the first check value calculated by crc32 (key) is 4097, the result of crc32 (key) % 4096 is 1. If the first check value calculated by crc32 (key) is 4098, the result of crc32 (key) % 4096 is 2.

[0107] When the preset number of slots is set to 4096, the first remainder may be matched to the computing slot with the same number to determine the first computing slot.

[0108] Step 2063: Determine a first shard group according to the first computing slot and preset computing slot mapping data.

[0109] After determining the first computing slot, the first shard group can also be determined according to the first computing slot and the preset computing slot mapping data, wherein the preset computing slot mapping data can be the correspondence between the number of the computing slot and the shard group. For example, when the preset number of slots is set to 4096, the computing slots numbered 0-1364 can be corresponded to one shard group, the computing slots numbered 1365-2730 can be corresponded to another shard group, and the computing slots numbered 2731-4095 can be corresponded to yet another shard group. It is worth noting that in this embodiment, the specific value of the preset number of slots is not specifically limited, nor is the specific number of shard groups or the number of service nodes in each shard group limited.

[0110] Step 2064: Determine the first service node with the lowest utilization in the first shard group.

[0111] Specifically, the first service node with the lowest utilization in the first shard group is determined. The first service node is used to calculate the current serial number and the first service identification code. For the routing allocation algorithm of multiple computing nodes in the same shard group, the node to be allocated is determined based on the CPU and memory utilization of the computing node. Each node obtains a list of routing proxy services based on a distributed application coordination service, such as Zookeeper, and periodically feeds back the current CPU and memory utilization to the routing proxy service every 10 seconds. The routing proxy service prioritizes the node with the lowest current utilization based on the utilization information fed back by the computing node in the shard group to which the key is routed, calls the identification code generation service node, and generates a distributed unique identification code.

[0112] Step 207: determine the original serial number according to the business type information and the business date information, and calculate the current serial number corresponding to the first business according to the original serial number and the preset coding isolation rule.

[0113] Step 208: Determine the first coding segment of the service according to the service type information, determine the second coding segment according to the service date information, and generate the third coding segment according to the current sequence number.

[0114] Step 209: Determine a first service identification code corresponding to the first service according to the first coding segment, the second coding segment, and the third coding segment.

[0115] It is worth noting that the specific implementation of steps 207-209 refers to the description of steps 103-105 in embodiment 1, and will not be repeated here.

[0116] In addition, based on the above embodiment, in order to improve the call response speed of the calculation process, a double cache mechanism can be adopted. In the prior art, a single cache mechanism is adopted, that is, when a single cache segment is used up, the identification code generation center will directly access the backend cache service. At this time, it is necessary to synchronously request the cache service, which may cause the call response time to slow down. Specifically, for the double cache mechanism, it can be that there is no need to synchronously request when taking the segment, and when the segment is consumed to a certain point, the next segment is asynchronously loaded into the memory.

[0117] In a possible implementation, it is possible to first query whether there is an available serial number segment in the local cache server based on the dynamic isolation factor. If the judgment result is no, then obtain the first serial number segment from the cache server. Then, determine the first usage rate of the first serial number segment in the first local cache based on the current serial number, and determine whether the first usage rate is greater than the preset ratio threshold. If the judgment result is yes, start the second thread according to the first serial number segment and the preset incremental step to cache the first serial number segment into the second local cache, wherein the first thread is used to calculate the current serial number corresponding to the first business, and the first thread and the second thread are parallel threads. It is worth understanding that the above-mentioned preset ratio threshold can be 50%, 80% or 90%, which is not specifically limited in the present embodiment.

[0118] In a specific implementation example, the identification code generation center queries the local cache according to the current dynamic isolation factor. If the query is null, the incremental command is used from the cache server to obtain a certain range of incremental identification code intervals, such as 1000, according to the set incremental step length, and put them into the first local cache. If the usage rate of the first local cache segment exceeds a certain threshold, such as 50% has been used, the identification code generation center automatically and asynchronously obtains the next incremental identification code interval from the cache server and puts it into the second local cache area. In order to reduce the number of synchronous calls to the cache server and improve the calling speed.

[0119] The double buffering method is adopted, and there are two number segment buffers inside the identification code generation center service. When the current number segment has been issued to a preset ratio threshold, for example, 50%, if the next number segment has not been updated, another update thread is started to update the next number segment. After all the current number segments have been issued, if the next number segment is ready, it will switch to the next number segment in the current buffer area and continue to issue, and the cycle will repeat.

[0120] It can be seen that in this embodiment, by sharding based on dynamic isolation factors and using double cache for optimization, the generation of distributed unique identification codes in high-concurrency and massive data is achieved. Based on the dynamic isolation factor, vertical sharding is performed using a preset verification algorithm. By divide and conquer, the high performance of the identification code generation system is guaranteed. The concept of sharding group is proposed. Each sharding group can horizontally expand multiple identification code generation services to ensure the high availability of the system. At the same time, the unique identification code is determined based on the identification code segment of the memory double cache, and space is exchanged for time, which effectively solves the problem of low efficiency of distributed unique identification code generation in the prior art and affects the throughput of the core application system.

[0121] Figure 6 FIG. 1 is a schematic diagram of a structure of a device for generating a service identification code according to an exemplary embodiment of the present invention. Figure 6 As shown, the service identification code generating device provided in this embodiment includes:

[0122] A request receiving module 301, configured to receive a request for generating an identification code of a first service;

[0123] An information determination module 302, configured to determine the service type information and service date information according to the identification code generation request;

[0124] A sequence number determination module 303 is used to determine an original sequence number according to the business type information and the business date information, and calculate a current sequence number corresponding to the first business according to the original sequence number and a preset coding isolation rule, wherein the original sequence number is a sequence number corresponding to a second business, the second business has the same business date as the first business, and the second business is the business closest to the first business and has the same business type as the first business;

[0125] A coding segment determination module 304, configured to determine a first coding segment of a service according to the service type information, determine a second coding segment according to the service date information, and generate a third coding segment according to the current sequence number;

[0126] The identification code determination module 305 is used to determine the first service identification code corresponding to the first service according to the first coding segment, the second coding segment and the third coding segment.

[0127] exist Figure 6 Based on the embodiment shown, Figure 7 FIG. 1 is a schematic diagram of a structure of a device for generating a service identification code according to another exemplary embodiment of the present invention. Figure 7 As shown, the information determination module 302 is further used to determine the application system name information and the service identification code name information corresponding to the first service according to the identification code generation request;

[0128] The coding segment determination module 304 is further used to determine a constant segment coding segment according to the application system name information and the service identification code name information, determine a date segment coding segment according to the service date information, and determine a service object attribute coding segment according to the service type information;

[0129] The service identification code generating device further comprises:

[0130] An isolation factor determination module 306, configured to determine a dynamic isolation factor according to the constant segment code segment, the business object attribute code segment and the date code segment;

[0131] The service node determination module 307 is used to determine a first service node according to the dynamic isolation factor, where the first service node is a service node in a service node set, and the first service node is used to calculate the current sequence number and the first service identification code.

[0132] In a possible design, the service node determination module 307 is specifically configured to:

[0133] Determine a first check value according to the dynamic isolation factor and a preset check algorithm;

[0134] Determine a first computing slot according to the first check value and a preset number of slots, the first computing slot being a computing slot in a computing slot set, and the number of computing slots included in the computing slot set being the preset number of slots;

[0135] A first shard group is determined according to the first computing slot and preset computing slot mapping data, and the first service node in the first shard group is used to calculate the current sequence number and the first service identification code.

[0136] In a possible design, the service node determination module 307 is further specifically configured to:

[0137] Calculate a first remainder of dividing the first check value by the preset number of slots;

[0138] The first calculation slot is determined according to the first remainder.

[0139] In a possible design, the service node determination module 307 is further specifically configured to:

[0140] Determine the first service node with the lowest utilization rate in the first shard group, where the first service node is used to calculate the current sequence number and the first service identification code.

[0141] In a possible design, the sequence number determination module 303 is specifically used to:

[0142] Determine a first usage rate in a first sequence number segment in a first local cache according to the current sequence number;

[0143] Determining whether the first usage rate is greater than a preset ratio threshold;

[0144] If the judgment result is yes, the second thread is started according to the first serial number segment and the preset incremental step to cache the first serial number segment into the second local cache, wherein the first thread is used to calculate the current serial number corresponding to the first business, and the first thread and the second thread are parallel threads.

[0145] In a possible design, the sequence number determination module 303 is further specifically used for:

[0146] Querying whether there is an available sequence number segment in the local cache server according to the dynamic isolation factor;

[0147] If the judgment result is no, the first serial number segment is obtained from the cache server.

[0148] It is worth mentioning that Figure 6-7 The service identification code generating device provided in the embodiment shown can be used to perform the above Figure 2-Figure 4 The service identification code generation method provided in the illustrated embodiment has similar specific implementation methods and technical effects, which will not be described in detail here.

[0149] Figure 8 FIG. 1 is a schematic diagram of the structure of an electronic device according to an exemplary embodiment of the present invention. Figure 8 As shown, the electronic device 40 provided in this embodiment includes:

[0150] Processor 401;

[0151] A memory 402, used to store a computer program of the processor;

[0152] The processor 401 is configured to implement the inventory management method provided by any implementation manner in the aforementioned method embodiments by executing the computer program.

[0153] In the embodiment, the processor 401 is configured to execute the technical solution described in any of the above-mentioned method embodiments by executing the executable instructions. The implementation principle and technical effect are similar and will not be repeated here.

[0154] This embodiment further provides a readable storage medium, in which a computer program is stored. When at least one processor of an electronic device executes the computer program, the electronic device executes the methods provided in the above-mentioned various implementation modes.

[0155] This embodiment also provides a program product, which includes a computer program stored in a readable storage medium. At least one processor of the electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program so that the electronic device implements the methods provided in the above various embodiments.

[0156] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0157] 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 replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for generating a service identification code, characterized in that: include: receiving an identification code generation request for a first service, and determining service type information and service date information according to the identification code generation request; Determine the application system name information and the service identification code name information corresponding to the first service according to the identification code generation request; Determine a constant segment coding segment according to the application system name information and the service identification code name information, determine a date segment coding segment according to the service date information, and determine a service object attribute coding segment according to the service type information; Determine a dynamic isolation factor according to the constant segment code segment, the business object attribute code segment and the date code segment; Determine a first service node according to the dynamic isolation factor, where the first service node is a service node in a service node set, and the first service node is used to calculate a current sequence number and the first service identification code; Determine an original sequence number according to the business type information and the business date information, and calculate a current sequence number corresponding to the first business according to the original sequence number and a preset coding isolation rule, wherein the original sequence number is a sequence number corresponding to a second business, the second business has the same business date as the first business, and the second business is the closest to the first business and has the same business type as the first business; Determine a first coding segment of the service according to the service type information, determine a second coding segment according to the service date information, and generate a third coding segment according to the current sequence number; A first service identification code corresponding to the first service is determined according to the first coding segment, the second coding segment and the third coding segment.

2. The method for generating a service identification code according to claim 1, characterized in that: The determining the first service node according to the dynamic isolation factor includes: Determine a first check value according to the dynamic isolation factor and a preset check algorithm; Determine a first computing slot according to the first check value and a preset number of slots, the first computing slot being a computing slot in a computing slot set, and the number of computing slots included in the computing slot set being the preset number of slots; A first shard group is determined according to the first computing slot and preset computing slot mapping data, and the first service node in the first shard group is used to calculate the current sequence number and the first service identification code.

3. The method for generating a service identification code according to claim 2, characterized in that: The determining the first computing slot according to the first check value and a preset number of slots includes: Calculate a first remainder of dividing the first check value by the preset number of slots; The first calculation slot is determined according to the first remainder.

4. The method for generating a service identification code according to claim 2, characterized in that: After determining the first shard group according to the first computing slot and the preset computing slot mapping data, the method further includes: Determine the first service node with the lowest utilization rate in the first shard group, where the first service node is used to calculate the current sequence number and the first service identification code.

5. The method for generating a service identification code according to any one of claims 2 to 4, characterized in that: After determining the original sequence number according to the service type information and the service date information, and calculating the current sequence number corresponding to the first service according to the original sequence number and a preset coding isolation rule, the method further includes: Determine a first usage rate in a first sequence number segment in a first local cache according to the current sequence number; Determining whether the first usage rate is greater than a preset ratio threshold; If the judgment result is yes, the second thread is started according to the first serial number segment and the preset incremental step to cache the first serial number segment into the second local cache, wherein the first thread is used to calculate the current serial number corresponding to the first business, and the first thread and the second thread are parallel threads.

6. The method for generating a service identification code according to claim 5, characterized in that: Before determining the first usage rate in the first sequence number segment in the first local cache according to the current sequence number, the method further includes: Querying whether there is an available sequence number segment in the local cache server according to the dynamic isolation factor; If the judgment result is no, the first serial number segment is obtained from the cache server.

7. A device for generating a service identification code, characterized in that: include: A request receiving module, used for receiving a request for generating an identification code of a first service; An information determination module, used to determine the application system name information and the service identification code name information corresponding to the first service according to the identification code generation request; A coding segment determination module, used to determine a constant segment coding segment according to the application system name information and the service identification code name information, determine a date segment coding segment according to the service date information, and determine a service object attribute coding segment according to the service type information; An isolation factor determination module, used to determine a dynamic isolation factor according to the constant segment code segment, the business object attribute code segment and the date code segment; A service node determination module, configured to determine a first service node according to the dynamic isolation factor, wherein the first service node is a service node in a service node set, and the first service node is configured to calculate a current sequence number and the first service identification code; The information determination module is further used to determine the service type information and service date information according to the identification code generation request; a sequence number determination module, configured to determine an original sequence number according to the service type information and the service date information, and calculate a current sequence number corresponding to the first service according to the original sequence number and a preset coding isolation rule, wherein the original sequence number is a sequence number corresponding to a second service, the second service has the same service date as the first service, and the second service is the service closest to the first service and has the same service type as the first service; The coding segment determination module is further used to determine a first coding segment of a service according to the service type information, determine a second coding segment according to the service date information, and generate a third coding segment according to the current sequence number; An identification code determination module is used to determine a first service identification code corresponding to the first service according to the first coding segment, the second coding segment and the third coding segment.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the service identification code generation method described in any one of claims 1 to 7 is implemented.

9. An electronic device, characterized in that: include: processor; as well as, A memory, configured to store executable instructions of the processor; The processor is configured to execute the service identification code generation method according to any one of claims 1 to 7 by executing the executable instructions.

Citation Information

Patent Citations

  • Identification generation method and device

    CN107229555A