CN113138988B - Product code generation method and device - Google Patents

Product code generation method and device Download PDF

Info

Publication number
CN113138988B
CN113138988B CN202110474116.9A CN202110474116A CN113138988B CN 113138988 B CN113138988 B CN 113138988B CN 202110474116 A CN202110474116 A CN 202110474116A CN 113138988 B CN113138988 B CN 113138988B
Authority
CN
China
Prior art keywords
product code
code
enterprise
cache segment
maximum
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110474116.9A
Other languages
Chinese (zh)
Other versions
CN113138988A (en
Inventor
徐文铖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Wodong Tianjun Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Wodong Tianjun Information Technology Co Ltd
Priority to CN202110474116.9A priority Critical patent/CN113138988B/en
Publication of CN113138988A publication Critical patent/CN113138988A/en
Application granted granted Critical
Publication of CN113138988B publication Critical patent/CN113138988B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2291User-Defined Types; Storage management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/986Document structures and storage, e.g. HTML extensions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Data Mining & Analysis (AREA)
  • Finance (AREA)
  • Computational Linguistics (AREA)
  • Accounting & Taxation (AREA)
  • Development Economics (AREA)
  • Software Systems (AREA)
  • Strategic Management (AREA)
  • Economics (AREA)
  • General Business, Economics & Management (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Marketing (AREA)
  • General Health & Medical Sciences (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The invention discloses a method and a device for generating a product code, and relates to the technical field of computers. One embodiment of the method comprises the following steps: receiving a request of generating a product code transmitted by an enterprise, acquiring the enterprise code in the request, and determining a currently used product code corresponding to the enterprise code; obtaining a recorded maximum product code from a local cache segment corresponding to the enterprise code; and under the condition that the current product code is smaller than the maximum product code, accumulating the current product code to a first preset value to serve as a newly generated product code and returning. According to the embodiment, when the local cache segment exists and is not used up, a new product code is generated based on the local cache segment, the local cache segment is located in the memory, and the characteristic of high memory reading speed is utilized, so that data reading operation across networks each time can be avoided, and the processing performance of the system is improved.

Description

Product code generation method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for generating a product code.
Background
The internet e-commerce system comprises creation, release and purchase of products, and each product needs to be provided with a unique code. However, in the existing internet micro-service background, the creation service of one product code may be called by a plurality of other services at the same time, which brings pressure to the product code server and challenges to accurately and efficiently creating the product code.
Product codes are created by mainly using UUIDs (Universally Unique Identifier, universal unique identification codes) and relational databases at present, but the following problems exist in the modes:
1. The UUID is a disordered string, and does not meet the product coding requirement;
2. the codes generated by the relational database are unique and orderly, but the acquisition efficiency is low, and especially in a high concurrency scene, normal service can not be provided;
3. The current maximum code is obtained from the database, and then the mode of +1 can meet the common requirements, but calculation is possibly disordered in a concurrent scene, and if the database is locked for ensuring accuracy, the obtaining efficiency is reduced.
Disclosure of Invention
In view of this, the embodiment of the invention provides a method and a device for generating a product code, which at least can solve the problem that the current method for generating the product code cannot ensure the universality of all scenes.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a product code generation method including:
Receiving a request of generating a product code transmitted by an enterprise, acquiring the enterprise code in the request, and determining a currently used product code corresponding to the enterprise code;
obtaining a recorded maximum product code from a local cache segment corresponding to the enterprise code; the cache section is used for storing the product codes;
And under the condition that the current product code is smaller than the maximum product code, accumulating the current product code to a first preset value to serve as a newly generated product code and returning.
Optionally, the method further comprises: querying a complete cache segment corresponding to the enterprise code when no local cache segment corresponding to the enterprise code exists or the current product code is equal to the maximum product code;
pulling a next cache segment from the complete cache segment by taking the maximum product code plus a second preset value as a starting point and the maximum product code plus a preset step length as an ending point;
and updating the local cache segment based on the next cache segment, and taking the maximum product code plus a second preset value as a newly generated product code and returning.
Optionally, the product code consists of an enterprise code and a numerical value, and a complete cache section of each enterprise is stored in the cache database;
the querying the complete cache segment corresponding to the enterprise code further comprises:
If the complete cache segment corresponding to the enterprise code does not exist in the cache database, a product code is created for the enterprise by taking a third preset value as a starting point and combining with the enterprise code, and then a complete cache segment is generated based on the created product code.
Optionally, the accumulating the current product code to a first preset value as a newly generated product code and returning, and further includes:
acquiring a value in the newly generated product code, and judging whether the value is larger than a maximum value preset by the enterprise; the maximum numerical value is the maximum product quantity allowed to be created by the enterprise;
and if the judgment result is yes, returning the request quantity overrun information, otherwise, returning the newly generated product code.
Optionally, the first preset value is equal to the difference value of adjacent product codes.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided a product code generating apparatus including:
the receiving module is used for receiving a request of generating a product code transmitted by an enterprise, acquiring the enterprise code in the request, and determining a currently used product code corresponding to the enterprise code;
The query module is used for acquiring the recorded maximum product code from the local cache segment corresponding to the enterprise code; the cache section is used for storing the product codes;
And the generating module is used for accumulating the current product code into a first preset value as a newly generated product code and returning the newly generated product code under the condition that the current product code is smaller than the maximum product code.
Optionally, the method further comprises an initialization module for:
Querying a complete cache segment corresponding to the enterprise code when no local cache segment corresponding to the enterprise code exists or the current product code is equal to the maximum product code;
pulling a next cache segment from the complete cache segment by taking the maximum product code plus a second preset value as a starting point and the maximum product code plus a preset step length as an ending point;
and updating the local cache segment based on the next cache segment, and taking the maximum product code plus a second preset value as a newly generated product code and returning.
Optionally, the product code consists of an enterprise code and a numerical value, and a complete cache section of each enterprise is stored in the cache database;
the initialization module is further configured to:
If the complete cache segment corresponding to the enterprise code does not exist in the cache database, a product code is created for the enterprise by taking a third preset value as a starting point and combining with the enterprise code, and then a complete cache segment is generated based on the created product code.
Optionally, the generating module is further configured to:
acquiring a value in the newly generated product code, and judging whether the value is larger than a maximum value preset by the enterprise; the maximum numerical value is the maximum product quantity allowed to be created by the enterprise;
and if the judgment result is yes, returning the request quantity overrun information, otherwise, returning the newly generated product code.
Optionally, the first preset value is equal to the difference value of adjacent product codes.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided a product code generating electronic device.
The electronic equipment of the embodiment of the invention comprises: one or more processors; and a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement any of the product code generation methods described above.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided a computer-readable medium having stored thereon a computer program which, when executed by a processor, implements any one of the above-described product code generation methods.
According to the solution provided by the present invention, one embodiment of the above invention has the following advantages or beneficial effects: when the local cache segment exists and is not used up, a new product code is generated based on the local cache segment, and when the local cache segment does not exist or is used up, a new product code is generated based on the next cache segment, and the generated product codes are not repeated, have high accuracy and have universality; the local cache segment is positioned in the memory, and the characteristic of high memory reading speed is utilized, so that data reading operation across networks each time can be avoided, and the processing performance of the system is improved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic flow diagram of a method for generating a product code according to an embodiment of the present invention;
FIG. 2 is a flow chart of an alternative product code generation method according to an embodiment of the invention;
FIG. 3 is a flow chart of another alternative product code generation method according to an embodiment of the invention;
FIG. 4 is a schematic diagram of the main modules of a product code generating apparatus according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
Fig. 6 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Referring to fig. 1, a main flowchart of a method for generating a product code according to an embodiment of the present invention is shown, including the following steps:
S101: receiving a request of generating a product code transmitted by an enterprise, acquiring the enterprise code in the request, and determining a currently used product code corresponding to the enterprise code;
S102: obtaining a recorded maximum product code from a local cache segment corresponding to the enterprise code; the cache section is used for storing the product codes;
S103: and under the condition that the current product code is smaller than the maximum product code, accumulating the current product code to a first preset value to serve as a newly generated product code and returning.
In the above-described embodiment, for steps S101 to S102, in the existing internet e-commerce system, the product code is used to identify a unique one of the products, and thus creating a unique product code for each product is a necessary requirement.
The internet e-commerce system receives a request transmitted by an enterprise for generating a product code, and acquires parameters in the request: enterprise coding. The enterprise code is generally self-distributed by the system according to characteristic information such as enterprise property, for example SJ, when the enterprise registers in the internet e-commerce system.
According to the enterprise code, a local cache segment of the enterprise is obtained from a local hash table (key- > value structure, key is enterprise code), for example, SJ-100001-SJ-100100, and the maximum product code is SJ-100100. In addition, a local hash table can be independently created for each enterprise, or a plurality of or all cache segments of the enterprises can be stored in the same local hash table, and the scheme is not limited in this way, specifically according to the setting of staff.
Each local cache segment has a maximum product code, for example, the maximum product codes of SJ-100051-SJ-100100 are SJ-100100, and the maximum product codes of SJ-100001-SJ-100050 are SJ-100050. When a new cache segment is considered, the product codes in the cache segment are not used, so that the product codes which are currently used by the enterprise can be stored independently.
For step S103, after obtaining the currently used product code and the maximum product code of the local buffer segment, it is determined whether the two codes are equal to each other:
1) If the current product code is equal to the maximum product code, the buffer segment is used up, and the process enters the "product code initialization stage of the enterprise" to obtain the next product code segment of the enterprise, and the initialization process is described with reference to fig. 2.
2) If the current product code is smaller than the maximum product code, indicating that the buffer segment is not used up, generating a new product code of the enterprise by using the current product code plus a first preset value (e.g. 1), and entering a "product code maximum processing stage", which is specifically described with reference to fig. 3.
It should be noted that, the first preset value may be a value of 1,2, etc., specifically, a difference value between adjacent product codes in the buffer segment. For example, the differences between SJ-100001, SJ-100002, SJ-100003 are all 1, the first preset value is 1, and for SJ-100001, SJ-100002, SJ-100003 the differences are all 2, the first preset value is 2.
According to the method provided by the embodiment, when the local cache segment exists and is not used up, the new product code is generated based on the local cache segment, and the generation of the product code can be accurately, rapidly and non-repeatedly supported even in an extreme concurrency scene. And the local cache segment is stored in the memory of the local equipment, so that the data reading operation can be avoided every time in a cross-network manner by utilizing the characteristic of high memory reading speed, and the processing performance of the system is improved.
Referring to fig. 2, a flowchart of an alternative product code generation method according to an embodiment of the invention is shown, including the following steps:
s201: receiving a request of generating a product code transmitted by an enterprise, acquiring the enterprise code in the request, and determining a currently used product code corresponding to the enterprise code;
s202: inquiring whether a local cache segment corresponding to the enterprise code exists or not; the cache section is used for storing the product codes;
s203: if the query exists, acquiring the recorded maximum product code from the local cache segment corresponding to the enterprise code;
S204: comparing whether the current product code is less than the maximum product code;
S205: if the product code is smaller than the first preset value, accumulating the current product code as a newly generated product code and returning;
s206: when the query does not exist or the comparison result is equal to the comparison result, querying a complete cache segment corresponding to the enterprise code;
s207: pulling a next cache segment from the complete cache segment by taking the maximum product code plus a second preset value as a starting point and the maximum product code plus a preset step length as an ending point;
s208: and updating the local cache segment based on the next cache segment, and taking the maximum product code plus a second preset value as a newly generated product code and returning.
In the above embodiment, the descriptions of steps S201 to S205 refer to steps S101 to S103 shown in fig. 1, and are not repeated here.
In the above embodiment, for steps S206 to S208, after receiving the request for generating the product code transmitted by the enterprise, the internet e-commerce system obtains the local cache segment of the enterprise from the local hash table according to the enterprise code, but if the local cache segment does not exist or is used up, the internet e-commerce system enters the "initialization phase of the product code of the enterprise" to obtain the new next cache segment.
A cache database (such as Redis) is arranged in the Internet electronic commerce system and is used for caching the complete cache segments of all enterprises. Thus, in the initialization stage, whether a complete cache segment corresponding to the enterprise exists in the cache database can be queried according to the enterprise code:
1) If the query result is not present, a complete cache segment is created for the enterprise by taking 0,1 or other third numerical values preset by the enterprise as starting points and combining enterprise codes;
2) If the query result is present, executing HINCRBY command, designating enterprise code and preset step length, obtaining next buffer segment, and then storing the next buffer segment into local hash table to update local buffer segment. The next cache segment usually takes the maximum product code in the current local cache segment and the second preset value as the starting points, the maximum product code and the preset step length as the starting points, for example, the current used local cache segment is SJ-100051-SJ-100100, the preset step length is 50, the next cache segment is SJ-100101-SJ-100150, and the SJ-100101 is returned to the enterprise as the newly generated product code.
Here HINCRBY commands are used to accumulate specified increment values for field values in the hash table, the increment may be negative, corresponding to subtracting the specified field. If the key of the hash table does not exist, a new hash table is created and the HINCRBY command is executed. If the specified field does not exist, the value of the field is initialized to 0 before the command is executed. Execution HINCRBY of the command on a field storing the string value will cause an error. The value of this operation is limited to a 64-bit (bit) signed digital representation.
According to the method provided by the embodiment, when the local cache segment does not exist or the product code of the local cache segment is used up, the local cache segment can be updated based on the next cache segment of the enterprise, so that normal provision of the product code of the enterprise is ensured, and the generated product code is not repeated.
Referring to fig. 3, a flow chart of another alternative product code generation method according to an embodiment of the invention is shown, comprising the steps of:
S301: receiving a request of generating a product code transmitted by an enterprise, acquiring the enterprise code in the request, and determining a currently used product code corresponding to the enterprise code;
S302: obtaining a recorded maximum product code from a local cache segment corresponding to the enterprise code; the cache section is used for storing the product codes;
S303: accumulating the current product code to a first preset value as a newly generated product code under the condition that the current product code is smaller than the maximum product code;
s304: acquiring a value in the newly generated product code, and judging whether the value is larger than a maximum value preset by the enterprise; the maximum numerical value is the maximum product quantity allowed to be created by the enterprise;
s305: if the judgment result is yes, returning request quantity overrun information;
s306: otherwise, returning the newly generated product code.
In the above embodiment, for the steps S301 to S303, reference is made to the descriptions of the steps S101 to S103 shown in fig. 1, and the descriptions thereof are omitted here.
In the above embodiment, for steps S304 to S306, there are generally some requirements in the process of creating the product code, such as: 1. the enterprise code of the product attribution is combined with a series of serial numbers, the enterprise code is used as the beginning so as to quickly determine the enterprise of the product attribution, and the numbers are convenient for knowing the product quantity of the enterprise; 2. each enterprise will typically set a maximum number of products N that is allowed to be created, avoiding an infinite number of products, and facilitating management.
Therefore, after a new product code is generated, a product code maximum value processing stage is automatically entered, and whether the maximum value requirement is met is checked, namely whether the number M in the new product code is larger than N is judged. If M > N, the product quantity of the enterprise is over-limit, the request end quantity over-limit information or error information is returned, otherwise, the new product code is returned to the request end.
According to the method provided by the embodiment, in order to avoid the situation that the enterprise frequently applies to cause the excessive number of product codes, the maximum number of products is set so as to check and control whether the product codes can be returned or not.
The method provided by the embodiment of the invention comprises an enterprise product code initialization stage, a new product code generation stage and a product code maximum value verification stage, and can accurately, efficiently and non-repeatedly generate new product codes even under an extreme concurrency scene, and the whole operation is simple and easy to manage.
Referring to fig. 4, a schematic diagram of main modules of a product code generating apparatus 400 according to an embodiment of the present invention is shown, including:
A receiving module 401, configured to receive a request for generating a product code transmitted by an enterprise, obtain the enterprise code in the request, and determine a currently used product code corresponding to the enterprise code;
A query module 402, configured to obtain a recorded maximum product code from a local cache segment corresponding to the enterprise code; the cache section is used for storing the product codes;
And the generating module 403 is configured to accumulate the current product code to a first preset value as a newly generated product code and return the newly generated product code when the current product code is smaller than the maximum product code.
The implementation device of the invention also comprises an initialization module for:
Querying a complete cache segment corresponding to the enterprise code when no local cache segment corresponding to the enterprise code exists or the current product code is equal to the maximum product code;
pulling a next cache segment from the complete cache segment by taking the maximum product code plus a second preset value as a starting point and the maximum product code plus a preset step length as an ending point;
and updating the local cache segment based on the next cache segment, and taking the maximum product code plus a second preset value as a newly generated product code and returning.
In the implementation device of the invention, the product code consists of enterprise codes and numerical values, and the complete cache section of each enterprise is stored in the cache database;
the initialization module is further configured to:
If the complete cache segment corresponding to the enterprise code does not exist in the cache database, a product code is created for the enterprise by taking a third preset value as a starting point and combining with the enterprise code, and then a complete cache segment is generated based on the created product code.
In the embodiment of the present invention, the generating module 403 is further configured to:
acquiring a value in the newly generated product code, and judging whether the value is larger than a maximum value preset by the enterprise; the maximum numerical value is the maximum product quantity allowed to be created by the enterprise;
and if the judgment result is yes, returning the request quantity overrun information, otherwise, returning the newly generated product code.
In the implementation device of the invention, the first preset value is equal to the difference value of adjacent product codes.
In addition, the implementation of the apparatus in the embodiments of the present invention has been described in detail in the above method, so that the description is not repeated here.
Fig. 5 shows an exemplary system architecture 500, including terminal devices 501, 502, 503, a network 504, and a server 505 (by way of example only), to which embodiments of the invention may be applied.
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting web browsing, are installed with various communication client applications, and a user may interact with the server 505 through the network 504 using the terminal devices 501, 502, 503 to receive or transmit messages, etc.
The network 504 is used as a medium to provide communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The server 505 may be a server providing various services for performing operations of receiving requests, querying local cache segments, pulling a next cache segment, and generating product codes.
It should be noted that, the method provided by the embodiment of the present invention is generally performed by the server 505, and accordingly, the apparatus is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 6 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present invention are performed when the computer program is executed by the central processing unit (CP U) 601.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor comprises a receiving module, a query module and a generating module. The names of these modules do not in any way constitute a limitation of the module itself, for example, the receiving module may also be described as "receiving request module".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to include:
Receiving a request of generating a product code transmitted by an enterprise, acquiring the enterprise code in the request, and determining a currently used product code corresponding to the enterprise code;
obtaining a recorded maximum product code from a local cache segment corresponding to the enterprise code; the cache section is used for storing the product codes;
And under the condition that the current product code is smaller than the maximum product code, accumulating the current product code to a first preset value to serve as a newly generated product code and returning.
According to the technical scheme of the embodiment of the invention, when the local cache segment exists and is not used up, a new product code is generated based on the local cache segment, and when the local cache segment does not exist or is used up, a new product code is generated based on the next cache segment, so that the smooth progress of the generated product code is ensured. And the local cache segment is positioned in the memory, so that the data reading operation of each cross-network can be avoided by utilizing the characteristic of high memory reading speed, and the processing performance of the system is improved.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (8)

1. A method of generating a product code, comprising:
Receiving a request of generating a product code transmitted by an enterprise, acquiring the enterprise code in the request, and determining a currently used product code corresponding to the enterprise code;
obtaining a recorded maximum product code from a local cache segment corresponding to the enterprise code; the cache section is used for storing the product codes;
accumulating the current product code to a first preset value as a newly generated product code and returning the newly generated product code under the condition that the current product code is smaller than the maximum product code;
Querying a complete cache segment corresponding to the enterprise code when no local cache segment corresponding to the enterprise code exists or the current product code is equal to the maximum product code;
Pulling a next cache segment from the complete cache segment by taking the maximum product code plus a second preset value as a starting point and the maximum product code plus a preset step length as an ending point;
And updating the local cache segment based on the next cache segment, adding a second preset value to the maximum product code as a newly generated product code, and returning.
2. The method of claim 1, wherein the product code consists of an enterprise code and a numerical value, and wherein the cache database stores a complete cache segment for each enterprise;
the querying the complete cache segment corresponding to the enterprise code further comprises:
If the complete cache segment corresponding to the enterprise code does not exist in the cache database, a product code is created for the enterprise by taking a third preset value as a starting point and combining with the enterprise code, and then a complete cache segment is generated based on the created product code.
3. The method of claim 2, wherein accumulating the current product code by a first predetermined value as a newly generated product code and returning, further comprising:
acquiring a value in the newly generated product code, and judging whether the value is larger than a maximum value preset by the enterprise; the maximum numerical value is the maximum product quantity allowed to be created by the enterprise;
and if the judgment result is yes, returning the request quantity overrun information, otherwise, returning the newly generated product code.
4. The method of claim 1, wherein the first predetermined value is equal to a difference between adjacent product codes.
5. A product code generating apparatus, comprising:
the receiving module is used for receiving a request of generating a product code transmitted by an enterprise, acquiring the enterprise code in the request, and determining a currently used product code corresponding to the enterprise code;
The query module is used for acquiring the recorded maximum product code from the local cache segment corresponding to the enterprise code; the cache section is used for storing the product codes;
The generating module is used for accumulating the current product code into a first preset value as a newly generated product code and returning the newly generated product code under the condition that the current product code is smaller than the maximum product code;
The initialization module is used for inquiring the complete cache segment corresponding to the enterprise code when the local cache segment corresponding to the enterprise code does not exist or the current product code is equal to the maximum product code; pulling a next cache segment from the complete cache segment by taking the maximum product code plus a second preset value as a starting point and the maximum product code plus a preset step length as an ending point; and updating the local cache segment based on the next cache segment, adding a second preset value to the maximum product code as a newly generated product code, and returning.
6. The apparatus of claim 5, wherein the product code consists of an enterprise code and a number, and wherein the cache database stores a complete cache segment for each enterprise;
the initialization module is further configured to:
If the complete cache segment corresponding to the enterprise code does not exist in the cache database, a product code is created for the enterprise by taking a third preset value as a starting point and combining with the enterprise code, and then a complete cache segment is generated based on the created product code.
7. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs,
When executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-4.
8. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-4.
CN202110474116.9A 2021-04-29 2021-04-29 Product code generation method and device Active CN113138988B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110474116.9A CN113138988B (en) 2021-04-29 2021-04-29 Product code generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110474116.9A CN113138988B (en) 2021-04-29 2021-04-29 Product code generation method and device

Publications (2)

Publication Number Publication Date
CN113138988A CN113138988A (en) 2021-07-20
CN113138988B true CN113138988B (en) 2024-08-20

Family

ID=76817877

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110474116.9A Active CN113138988B (en) 2021-04-29 2021-04-29 Product code generation method and device

Country Status (1)

Country Link
CN (1) CN113138988B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103401853A (en) * 2013-07-24 2013-11-20 江苏晓山信息产业股份有限公司 Safe and efficient coding and resolving method for network of things
CN111225073A (en) * 2018-11-26 2020-06-02 北京京东尚科信息技术有限公司 Service code distribution method and device, storage medium and computer system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9471710B2 (en) * 2013-06-14 2016-10-18 International Business Machines Corporation On-the-fly encoding method for efficient grouping and aggregation
CN111368507A (en) * 2020-02-28 2020-07-03 煤炭科学技术研究院有限公司 Product code generation method and device, computer equipment and storage medium
CN112527846B (en) * 2020-12-31 2021-12-31 广东鑫兴科技有限公司 Warehouse entry code generation method and device, electronic equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103401853A (en) * 2013-07-24 2013-11-20 江苏晓山信息产业股份有限公司 Safe and efficient coding and resolving method for network of things
CN111225073A (en) * 2018-11-26 2020-06-02 北京京东尚科信息技术有限公司 Service code distribution method and device, storage medium and computer system

Also Published As

Publication number Publication date
CN113138988A (en) 2021-07-20

Similar Documents

Publication Publication Date Title
CN107704202B (en) Method and device for quickly reading and writing data
CN112445626B (en) Data processing method and device based on message middleware
CN111460129B (en) Method, device, electronic equipment and storage medium for generating identification
CN110109912B (en) Identifier generation method and device
CN113111626B (en) Sequence generation method, device, electronic equipment and storage medium
CN111949648B (en) Memory data caching system and data indexing method
CN113138988B (en) Product code generation method and device
CN113590543A (en) Method, apparatus and computer program product for information processing
CN116069725A (en) File migration method, device, apparatus, medium and program product
CN115982148A (en) Database table processing method and device, electronic equipment and storage medium
CN109213815B (en) Method, device, server terminal and readable medium for controlling execution times
CN113726885B (en) Flow quota adjusting method and device
CN112784139B (en) Query method, device, electronic equipment and computer readable medium
CN112711572B (en) Online capacity expansion method and device suitable for database and table division
CN113127416B (en) Data query method and device
CN113760876A (en) Data filtering method and device
CN113779082B (en) Method and device for updating data
CN111291038B (en) Data query method and device
CN111090530A (en) Distributed cross-interprocess communication bus system
CN113268488B (en) Method and device for data persistence
CN113722548B (en) Method and device for processing quotation relation in service system
CN113760965B (en) Data query method and device
CN110866002A (en) Method and device for processing sub-table data
CN113111119B (en) Method and device for operating data
CN111179097B (en) Method, device, electronic equipment and storage medium for modifying warranty

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant