[go: up one dir, main page]

CN114581008B - Inventory deduction method, device, computer equipment and storage medium - Google Patents

Inventory deduction method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN114581008B
CN114581008B CN202210202605.3A CN202210202605A CN114581008B CN 114581008 B CN114581008 B CN 114581008B CN 202210202605 A CN202210202605 A CN 202210202605A CN 114581008 B CN114581008 B CN 114581008B
Authority
CN
China
Prior art keywords
inventory
block
objects
request
blocks
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
CN202210202605.3A
Other languages
Chinese (zh)
Other versions
CN114581008A (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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202210202605.3A priority Critical patent/CN114581008B/en
Publication of CN114581008A publication Critical patent/CN114581008A/en
Application granted granted Critical
Publication of CN114581008B publication Critical patent/CN114581008B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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
    • G06Q10/00Administration; Management
    • G06Q10/08Logistics, e.g. warehousing, loading or distribution; Inventory or stock management
    • G06Q10/087Inventory or stock management, e.g. order filling, procurement or balancing against orders

Landscapes

  • Business, Economics & Management (AREA)
  • Economics (AREA)
  • Engineering & Computer Science (AREA)
  • Marketing (AREA)
  • Quality & Reliability (AREA)
  • Finance (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Human Resources & Organizations (AREA)
  • Accounting & Taxation (AREA)
  • Operations Research (AREA)
  • Development Economics (AREA)
  • Strategic Management (AREA)
  • Tourism & Hospitality (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

本申请涉及一种库存扣减方法、装置、计算机设备、存储介质和计算机程序产品。方法包括:获取至少两个对象获取请求;各对象获取请求用于请求扣减总库存中的至少一个对象;根据对象获取请求的数量和总库存的对象数量,确定库存分块数量;根据库存分块数量对总库存进行分块,并对总库存的对象进行对应的分配,得到总库存对应的至少两个库存块;并行处理至少两个对象获取请求,对于每处理一个对象获取请求,相应扣减对象数量最大值对应的库存块,得到各对象获取请求对应的请求处理结果;根据各对象获取请求对应的请求处理结果,调整每一个库存块中的对象数量以及库存块的数量。采用本方法采用并行处理的方案能够提高减库存的效率。

The present application relates to a method, device, computer equipment, storage medium and computer program product for inventory deduction. The method comprises: obtaining at least two object acquisition requests; each object acquisition request is used to request the deduction of at least one object in the total inventory; determining the number of inventory blocks according to the number of object acquisition requests and the number of objects in the total inventory; dividing the total inventory into blocks according to the number of inventory blocks, and making corresponding allocations to the objects in the total inventory to obtain at least two inventory blocks corresponding to the total inventory; processing at least two object acquisition requests in parallel, and for each object acquisition request processed, deducting the inventory block corresponding to the maximum number of objects to obtain the request processing results corresponding to each object acquisition request; adjusting the number of objects in each inventory block and the number of inventory blocks according to the request processing results corresponding to each object acquisition request. The method adopts a parallel processing scheme to improve the efficiency of inventory reduction.

Description

Inventory deduction method, inventory deduction device, computer equipment and storage medium
Technical Field
The present application relates to the field of artificial intelligence, and in particular, to a method, an apparatus, a computer device, and a storage medium for inventory deduction.
Background
With the development of artificial intelligence technology, high concurrency scenes occur, for example, large electronic commerce platforms often have discounted promotion and second killing activities, so that a large number of service requests are input into a computer.
The large-scale internet application is oriented to a large number of users, is a large-scale distributed clustering and is used as a basic framework, wherein a large number of cases of inaccurate inventory deduction and lower efficiency are encountered when inventory problems are handled by adopting a distributed lock based on a database, realizing the distributed lock based on a cache (Redis and the like) and realizing the distributed lock based on a Zookeeper under a high concurrency scene.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an inventory deduction method, apparatus, computer device, computer readable storage medium, and computer program product that can improve efficiency in parallel.
In a first aspect, the present application provides a stock deduction method. The method comprises the steps of obtaining at least two object obtaining requests, wherein each object obtaining request is used for requesting deduction of at least one object in a total inventory, determining the inventory partition number according to the object obtaining requests and the object number of the total inventory, partitioning the total inventory according to the inventory partition number to obtain at least two inventory blocks corresponding to the total inventory, executing the partitioning while executing corresponding distribution on the objects of the total inventory, processing the at least two object obtaining requests in parallel, correspondingly deducting the inventory blocks of which the object number meets preset conditions for each object obtaining request to obtain a request processing result corresponding to each object obtaining request, and adjusting the object number and the inventory block number in each inventory block according to the request processing result corresponding to each object obtaining request.
In one embodiment, the determining the inventory partition number according to the number of the object obtaining requests and the number of the objects in the total inventory includes obtaining the minimum number of objects corresponding to each inventory block, determining a total inventory partition proportion based on the number of the object obtaining requests and the minimum number of objects corresponding to each inventory block, wherein the total inventory partition proportion is used for dividing the total inventory partition proportion, and inputting the number of the object obtaining requests and the number of the objects in the total inventory into an inventory partition optimization algorithm based on the total inventory partition proportion to determine the inventory partition number.
In one embodiment, the parallel processing of the at least two object obtaining requests, for each processing of one object obtaining request, correspondingly deducting the inventory blocks of which the number of the objects meets a preset condition, to obtain a request processing result corresponding to each object obtaining request, includes identifying each inventory block by using an identity identifier to obtain an inventory block identifier corresponding to each inventory block, for each processing of each object obtaining request, searching for inventory blocks of which the number of the objects meets the preset condition according to the inventory block identifier, as a target inventory block, and deducting the objects in the target inventory block to obtain a request processing result corresponding to each object obtaining request.
In one embodiment, for each processing of the object acquisition request, searching for an inventory block whose number meets a preset condition according to the inventory block identification number as a target inventory block, deducting objects in the target inventory block to obtain a request processing result corresponding to each object acquisition request, where for the current object acquisition request, searching for the target inventory block whose number meets a preset condition according to the inventory block identification number, deducting objects in the target inventory block to obtain a request processing result corresponding to the current object acquisition request, taking a next object acquisition request of the current object acquisition request as the current object acquisition request, and executing the steps repeatedly until the request processing result corresponding to each object acquisition request is obtained.
In one embodiment, the searching the target stock blocks, the number of which meets the preset condition, according to the stock block identification number includes directly deducting the stock blocks, the number of which meets the preset condition, if the result of searching the stock blocks, corresponding to the preset condition, according to the stock block identification number is one, and if the result of searching the stock blocks, corresponding to the preset condition, according to the stock block identification number is at least two, deducting the stock blocks, corresponding to the maximum number of the objects.
In one embodiment, the adjusting the number of the objects and the number of the inventory blocks in each inventory block according to the request processing result corresponding to each object obtaining request includes analyzing according to the request processing result corresponding to each object obtaining request to obtain an inventory block analysis result, and adjusting the number of the objects and the number of the inventory blocks in each inventory block based on the inventory block analysis result to obtain the number of the objects and the number of the updated inventory blocks.
In a second aspect, the application further provides an inventory deduction device. The device comprises an object acquisition request acquisition module, an inventory partition number determination module, an inventory block obtaining module and an inventory block adjusting module, wherein the object acquisition request acquisition module is used for acquiring at least two object acquisition requests, each object acquisition request is used for requesting deduction of at least one object in a total inventory, the inventory partition number determination module is used for determining the inventory partition number according to the number of the object acquisition requests and the number of the objects in the total inventory, the inventory block obtaining module is used for partitioning the total inventory according to the inventory partition number to obtain at least two inventory blocks corresponding to the total inventory, the partitioning is executed and the corresponding distribution is executed on the objects in the total inventory, the request processing result obtaining module is used for parallelly processing the at least two object acquisition requests, and for each object acquisition request, the inventory blocks corresponding to the deduction of the number of the objects meet the preset condition are obtained to obtain the request processing result corresponding to each object acquisition request, and the inventory block adjusting module is used for adjusting the number of the objects in each inventory block and the number of the inventory blocks according to the request processing result corresponding to each object acquisition request.
In one embodiment, the inventory block number determining module is configured to obtain a minimum number of objects corresponding to each inventory block, determine a total inventory block proportion based on the number of object obtaining requests and the minimum number of objects corresponding to each inventory block, where the total inventory block proportion is used to divide the total inventory block proportion, and input the number of object obtaining requests and the number of objects in the total inventory to an inventory block optimization algorithm based on the total inventory block proportion, and determine the inventory block number.
In one embodiment, the request processing result obtaining module is configured to identify each of the inventory blocks by using an identification number to obtain an inventory block identification number corresponding to each of the inventory blocks, search, for each of the object obtaining requests, inventory blocks whose number of objects meets a preset condition according to the inventory block identification number as target inventory blocks, and deduct objects in the target inventory blocks to obtain a request processing result corresponding to each of the object obtaining requests.
In one embodiment, a request processing result obtaining module is configured to find, for the current object obtaining request, the target inventory block for which the number of objects corresponding to the current object obtaining request meets a preset condition according to the inventory block identification number, deduct the objects in the target inventory block to obtain a request processing result corresponding to the current object obtaining request, take a next object obtaining request of the current object obtaining request as the current object obtaining request, and execute repeatedly the above steps until the request processing result corresponding to each object obtaining request is obtained.
In one embodiment, the request processing result obtaining module is configured to directly deduct the inventory blocks corresponding to the number of the objects meeting the preset condition if the result of searching the inventory blocks corresponding to the number of the objects meeting the preset condition according to the inventory block identification number is one, and deduct the inventory blocks corresponding to the maximum number of the objects if the result of searching the inventory blocks corresponding to the number of the objects meeting the preset condition according to the inventory block identification number is at least two.
In one embodiment, the inventory block adjustment module is configured to analyze a request processing result corresponding to each object acquisition request to obtain an inventory block analysis result, and adjust the number of objects of each inventory block and the number of inventory blocks based on the inventory block analysis result to obtain the number of objects of each updated inventory block and the number of updated inventory blocks.
In a third aspect, the present application also provides a computer device. The computer equipment comprises a memory and a processor, wherein the memory stores a computer program, the processor executes the computer program to realize the following steps of acquiring at least two object acquisition requests, each object acquisition request is used for requesting deduction of at least one object in a total stock, determining the number of stock blocks according to the number of the object acquisition requests and the number of the objects in the total stock, partitioning the total stock according to the number of the stock blocks to obtain at least two stock blocks corresponding to the total stock, executing the partitioning while executing corresponding allocation to the objects in the total stock, processing the at least two object acquisition requests in parallel, correspondingly deducting the stock blocks of which the number of the objects meets preset conditions for each object acquisition request to obtain a request processing result corresponding to each object acquisition request, and adjusting the number of the objects and the number of the stock blocks in each stock block according to a request processing result corresponding to each object acquisition request.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium is stored with a computer program, when the computer program is executed by a processor, the method comprises the steps of obtaining at least two object obtaining requests, each object obtaining request is used for requesting deduction of at least one object in a total stock, determining the number of stock blocks according to the number of the object obtaining requests and the number of the objects in the total stock, dividing the total stock according to the number of the stock blocks to obtain at least two stock blocks corresponding to the total stock, executing the dividing and simultaneously executing corresponding distribution on the objects in the total stock, parallel processing the at least two object obtaining requests, correspondingly deducting the stock blocks of which the number of the objects meets preset conditions for each object obtaining request processing result corresponding to each object obtaining request, and adjusting the number of the objects in each stock block and the number of the stock blocks according to the request processing result corresponding to each object obtaining request.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program, wherein the computer program is executed by a processor and comprises the following steps of acquiring at least two object acquisition requests, each object acquisition request is used for requesting deduction of at least one object in a total stock, determining the number of stock blocks according to the number of the object acquisition requests and the number of the objects in the total stock, dividing the total stock according to the number of the stock blocks to obtain at least two stock blocks corresponding to the total stock, executing the blocks and simultaneously executing corresponding allocation to the objects in the total stock, parallel processing the at least two object acquisition requests, correspondingly deducting the stock blocks of which the number of the objects meets a preset condition for each object acquisition request, obtaining a request processing result corresponding to each object acquisition request, and adjusting the number of the objects and the number of the stock blocks in each stock block according to the request processing result corresponding to each object acquisition request.
The inventory deduction method, the inventory deduction device, the computer equipment, the storage medium and the computer program product are characterized by acquiring at least two object acquisition requests, wherein each object acquisition request is used for requesting deduction of at least one object in the total inventory, determining the inventory partition number according to the number of the object acquisition requests and the number of the objects in the total inventory, partitioning the total inventory according to the inventory partition number and correspondingly distributing the objects in the total inventory to obtain at least two inventory blocks corresponding to the total inventory, processing the at least two object acquisition requests in parallel, correspondingly deducting the inventory blocks of which the number of the objects meets the preset condition for each object acquisition request to obtain a request processing result corresponding to each object acquisition request, and adjusting the number of the objects in each inventory block and the number of the inventory blocks according to the request processing result corresponding to each object acquisition request.
The server can process different object acquisition requests in parallel by acquiring at least two object acquisition requests from the terminal, processing time can be greatly reduced, the number of the blocks to be processed can be accurately calculated according to the number of the object acquisition requests and the number of the objects in the total stock, the total stock can be changed from processing only one object acquisition request to processing a plurality of object acquisition requests at the same time by executing the block division on the total stock while the block division is executed on the total stock, the efficiency of processing the object acquisition requests can be improved, errors caused by the insufficient number of the objects can be reduced while the unbalance of system resources is avoided, the stability of the system is maintained, and the resource occupying a computer can be reduced and the resource allocation of the computer is optimized by adjusting the number of the objects in the stock blocks and the number of the stock blocks according to the request processing result.
The total stock is split according to the number of the object acquisition requests and the number of the objects in the total stock, so that the asynchronous multithreading stock reduction effect is realized, the problem of low stock reduction efficiency of all stock serial is solved, meanwhile, the stock is split and recombined, the relative average in each stock block is realized, the processing requests are more uniform, the problems that one thread has excessive requests and other threads are idle are avoided.
Drawings
FIG. 1 is a diagram of an application environment for an inventory deduction method in one embodiment;
FIG. 2 is a flow chart of a stock deduction method according to an embodiment;
FIG. 3 is a flow chart of a stock deduction step in one embodiment;
FIG. 4 is a flow chart of a method for inventory deduction according to another embodiment;
FIG. 5 is a flow chart of a method for inventory deduction according to yet another embodiment;
FIG. 6 is a flow chart of a stock deduction method according to yet another embodiment;
FIG. 7 is another flow diagram of a stock deduction method in one embodiment;
FIG. 8 is an overall block diagram of an inventory deduction method in one embodiment;
FIG. 9 is a schematic diagram of a snowflake algorithm generating ID identifying each inventory chunk, according to one embodiment;
FIG. 10 is a block diagram of an inventory deduction device according to one embodiment;
FIG. 11 is an internal block diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The inventory deduction method provided by the embodiment of the application can be applied to an application environment shown in fig. 1. The terminal 102 sends a request to the server 104, the terminal 102 communicates with the server 104 through a network, the server 104 calculates corresponding to the request of the terminal 102, and the server 104 returns the calculation result to the terminal 102 after the calculation is completed. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on a cloud or other network server. The method comprises the steps of obtaining at least two object obtaining requests, obtaining at least one object in a total stock by each object obtaining request, determining the stock partition number according to the number of the object obtaining requests and the number of the objects in the total stock, partitioning the total stock according to the stock partition number, correspondingly distributing the objects in the total stock to obtain at least two stock blocks corresponding to the total stock, processing the at least two object obtaining requests in parallel, correspondingly deducting the stock blocks of which the number of the objects meets the preset condition for each object obtaining request to obtain a request processing result corresponding to each object obtaining request, and adjusting the number of the objects in each stock block and the number of the stock blocks according to the request processing result corresponding to each object obtaining request. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
In one embodiment, as shown in fig. 2, there is provided an inventory deduction method, which is illustrated by taking the server in fig. 1 as an example, and includes the following steps:
Step 202, at least two object acquisition requests are acquired.
Wherein, at least two can be two or more, and the description is more than or equal to two by mathematical language.
The total stock may be a way of indicating the number of the same article, something or an object, for example, the total stock of the mobile phone indicates the number of the article.
The object may be an abstract term of an item stored in the main memory, such as clothes in the main memory, telephone in the main memory, quilt in the main memory or medal in the main memory, etc.
The object obtaining request may be an instruction sent from the terminal to instruct the server to operate on the object in the total repository, where the operation may be deduction on a corresponding object in the total repository.
Specifically, the server responds to the instruction of the terminal to deduct the object corresponding to the master repository stored in the storage unit of the server, at least one deduction is performed on the object, the object acquisition request can be sequentially and serially input to the server or can be simultaneously input to the server in a parallel mode, and the inventory coordinator in the server manages the object acquisition request acquired from the terminal, so that the processing efficiency of the object-oriented acquisition request of the server is greatly improved.
For example, the server obtains 10 object obtaining requests from the terminal, and the objects to be deducted in each object obtaining request are different from 1 to 5, the 10 object obtaining requests are input to the server in a parallel manner, the inventory coordinator in the server manages the 10 object obtaining requests, and reasonably invokes the computer resource to process the 10 object obtaining requests.
Step 204, determining the inventory blocking number according to the number of the object acquisition requests and the number of the objects in the total inventory.
The number of inventory blocks may be the number of inventory blocks required to be divided into a plurality of inventory blocks according to the number of object acquisition requests and the number of objects in the total inventory, which are obtained by calculating the total inventory through an inventory block optimization algorithm.
The inventory block may be a sub-inventory obtained by dividing the total inventory according to the number of inventory dividing blocks, and the total number of the sets of the plurality of sub-inventories is equal to the total inventory.
Specifically, according to the number of object acquisition requests and the number of objects in the total inventory, the inventory blocking optimization algorithm is calculated, and the blocking optimization algorithm can be a preset mathematical model, or a computer can intelligently select one from the built-in mathematical models according to the number of object acquisition requests and the number of objects in the total inventory, so as to obtain the inventory blocking number for blocking the total inventory, and because the total inventory is blocked, the value of the inventory blocking number is greater than or equal to 2, the calculation of the inventory blocking number is the responsibility of an inventory coordinator in a server, and after the calculation is finished, the result is sent to the next module.
For example, the number of object acquisition requests is 100, and the number of objects in the total inventory is 1000, and the number of inventory blocks is 20 by calculating through a linear congruence random number algorithm preset in the inventory coordinator, and the obtained result is input into the next module for further processing.
And 206, partitioning the total inventory according to the inventory partitioning number, and correspondingly distributing the objects of the total inventory to obtain at least two inventory blocks corresponding to the total inventory.
The partitioning can be performed by splitting the total stock according to the stock partitioning quantity, the split total stock comprises at least two stock blocks, and each stock block is provided with a corresponding identifier, so that the computer can conveniently call.
The corresponding allocation of the objects of the total inventory can be that the objects of the total inventory are allocated when the total inventory is split according to the inventory partition number, each inventory block can obtain a certain number of objects, and the objects in each inventory block can be evenly allocated or differentially allocated according to the requirement.
Specifically, the total inventory is partitioned according to the inventory partition number calculated by using the inventory partition optimization algorithm, at least two inventory blocks corresponding to the total inventory can be obtained after the partitioning, the partitioning of the total inventory is performed, and meanwhile, the distribution of the objects in the total inventory is also performed, wherein the distribution can be performed according to the average distribution or the difference distribution of the inventory blocks, the distributed objects are stored in the corresponding inventory blocks, and at least one object is distributed in each inventory block.
For example, the number of object acquisition requests is 100, and the number of objects in the total inventory is 1000, and the number of inventory blocks is 20 by calculating through a linear congruence random number algorithm preset in the inventory coordinator, so that the total inventory is divided into 20 inventory blocks, the distribution of the objects is performed while the block division is performed, and the distribution of the objects in this example adopts the principle of average distribution, so that 50 objects can be distributed in each inventory block.
Step 208, processing at least two object acquisition requests in parallel, and for each object acquisition request, correspondingly deducting inventory blocks of which the number of objects meets a preset condition, so as to obtain a request processing result corresponding to each object acquisition request.
The parallel processing may be a calculation method capable of executing two or more processes simultaneously in a computer system, the parallel processing may work on different aspects of the same program simultaneously, the main purpose of the parallel processing is to save the time for solving large and complex problems, and the execution speed of n parallel processing may be n times of the speed of serial execution in theoretical calculation.
The inventory blocks with the number of the objects meeting the preset conditions can be all inventory blocks with the number of the objects meeting the preset conditions after the total inventory is split, and if the number of the objects in the inventory blocks meets the preset conditions at the same time, the inventory blocks are all inventory blocks with the number of the objects meeting the preset conditions at the same time.
The request processing result may be a deduction result corresponding to the inventory block after the number of objects meets the preset condition and the inventory block has performed corresponding deduction on the objects, and if the number of objects in a certain inventory block is always equal to the preset condition, the plurality of deduction results may be corresponding to the same inventory block.
Specifically, the number of preset objects satisfies the condition, processing a plurality of object acquisition requests in a parallel processing mode, for the number of object acquisition requests being greater than or equal to two, searching for an inventory block with the number of current objects satisfying the preset condition for object number deduction corresponding to each object acquisition request, if only one inventory block is deducted by the number of objects and still belongs to the inventory block with the number of objects satisfying the preset condition, still selecting the inventory block for next object number deduction, and if a plurality of inventory blocks are simultaneously inventory blocks with the number of objects satisfying the preset condition, selecting one inventory block with the number of objects being the maximum value for object number deduction, thereby obtaining the request processing result corresponding to each object acquisition request.
For example, an inventory block with the maximum number of deducted objects is preset, the number of objects of the inventory block a is 10, the number of objects of the inventory block B is 15, the number of objects of the inventory block C is 12, 5 object obtaining requests are processed in parallel, each object obtaining request needs to deduct two object numbers, then for a first object obtaining request, the inventory block corresponding to the maximum number of deducted objects, that is, the inventory block B is deducted, the number of objects of the inventory block B after deduction is 13, while a second object obtaining request still deducts the number of objects of the inventory block B, when the second object obtaining request deducts, the number of objects of the inventory block B is 11, a third object obtaining request selects the inventory block C for deduction, the number of objects of the inventory block C after deduction is 10, a fourth object obtaining request selects the inventory block B for deduction, so that the number of objects of the inventory block B after deduction is 9, when a fifth object obtaining request is processed, the number of objects of the inventory block a and the inventory block C is 10 at the same time, and a computer obtains a result corresponding to each of the deducted objects from the inventory block a.
Step 210, according to the request processing result corresponding to each object obtaining request, the number of objects in each inventory block and the number of inventory blocks are adjusted.
The adjustment may be to change the number of objects in each inventory block and the number of inventory blocks according to the requirement, so that the available resources are more even, and the stability of the system is increased.
Specifically, according to the request processing result corresponding to each object obtaining request, the number of objects in the inventory blocks with the object number reduced and the number of inventory blocks are adjusted, if the object number in the inventory blocks is found to be close to the threshold value or even lower than the threshold value, the inventory in the inventory blocks with the inventory number higher than the threshold value is split and distributed into the inventory blocks with lower inventory number, and if a large number of objects are already reduced and even the object number in some inventory blocks is 0, the number of inventory blocks is adjusted.
For example, the server obtains 5 object obtaining requests from the terminal, wherein 4 object obtaining requests need to deduct 2 object numbers, one object obtaining request needs to deduct 20 object numbers, so as to obtain 5 request processing results, wherein the 4 processing results contain information of deducting 2 object numbers, the 1 processing result contains information of deducting 20 object numbers, and the inventory block A is obviously lower than a threshold value because of deducting 20 object numbers, so that the computer adjusts the object numbers in the inventory block B and the inventory block C into the inventory block A, the object numbers of three inventory blocks are relatively close, and the average allocation of resources of the system is maintained.
The inventory deduction method comprises the steps of obtaining at least two object obtaining requests, obtaining at least one object in a total inventory by each object obtaining request, determining the inventory blocking number according to the number of the object obtaining requests and the number of the objects in the total inventory, blocking the total inventory according to the inventory blocking number, correspondingly distributing the objects in the total inventory to obtain at least two inventory blocks corresponding to the total inventory, processing the at least two object obtaining requests in parallel, obtaining a request processing result corresponding to each object obtaining request by corresponding deduction of the number of the objects to the inventory blocks meeting preset conditions, and adjusting the number of the objects in each inventory block and the number of the inventory blocks according to the request processing result corresponding to each object obtaining request.
The server can process different object acquisition requests in parallel by acquiring at least two object acquisition requests from the terminal, processing time can be greatly reduced, the number of the blocks to be processed can be accurately calculated according to the number of the object acquisition requests and the number of the objects in the total stock, the total stock can be changed from processing only one object acquisition request to processing a plurality of object acquisition requests at the same time by executing the block division on the total stock while the block division is executed on the total stock, the efficiency of processing the object acquisition requests can be improved, errors caused by the insufficient number of the objects can be reduced while the unbalance of system resources is avoided, the stability of the system is maintained, and the resource occupying a computer can be reduced and the resource allocation of the computer is optimized by adjusting the number of the objects in the stock blocks and the number of the stock blocks according to the request processing result.
The total stock is split according to the number of the object acquisition requests and the number of the objects in the total stock, so that the asynchronous multithreading stock reduction effect is realized, the problem of low stock reduction efficiency of all stock serial is solved, meanwhile, the stock is split and recombined, the relative average in each stock block is realized, the processing requests are more uniform, the problems that one thread has excessive requests and other threads are idle are avoided.
In one embodiment, as shown in FIG. 3, determining the number of inventory chunks based on the number of object acquisition requests and the number of objects in the total inventory includes:
step 302, obtaining the minimum number of objects corresponding to each inventory block.
The minimum number of objects corresponding to each inventory block may be a minimum number of objects preset according to the requirement in each inventory block, and the minimum number of objects may be a threshold value, which indicates that the number of objects in the inventory block needs to be greater than or equal to the threshold value, otherwise, the computer will adjust the objects in the inventory block or adjust the inventory block.
Specifically, the computer obtains the minimum number of objects corresponding to each inventory block, the minimum number of objects corresponding to each inventory block can be consistent, different thresholds can be set according to requirements, the setting of the minimum number of objects can be manually set, the computer can judge according to the conditions of the inventory blocks and the object obtaining requests, and the computer can set the minimum number of objects generally, so that the operation efficiency of the system can be greatly improved.
For example, the minimum number of objects is set for inventory block a, inventory block B, and inventory block C in the server, the threshold for inventory block a is 10, the threshold for inventory block B is 8, and the threshold for inventory block C is 12.
Step 304, determining the total stock partition proportion based on the number of the object acquisition requests and the minimum number of objects corresponding to each stock block.
The proportion of the total stock memory blocks can be the proportion of the parts which are called to be blocked to the total stock, the proportion is changed in real time and can be determined according to the number of different object acquisition requests and the minimum object number corresponding to each stock block, and the proportion of the specific total stock memory blocks is the whole stock or half of the total stock.
Specifically, according to the number of object acquisition requests acquired by the server and the minimum number of objects corresponding to each inventory block, an internal computer algorithm is used for determining the proportion of the total inventory for blocking by using an inventory coordinator in the system, for example, the proportion for blocking is one third, one fourth, and the like of the total inventory.
For example, the number of object acquisition requests acquired by the server is X, and the minimum number of objects of three inventory blocks, namely, inventory block a, inventory block B and inventory block C, is determined according to the four data to occupy the total inventory, and the blocks are partitioned, for example, seven tenths, five nineths and the like.
Step 306, based on the total stock blocking proportion, inputting the number of the object acquisition requests and the number of the objects in the total stock into the stock blocking optimization algorithm, and determining the stock blocking number.
The inventory blocking optimization algorithm can be a mathematical algorithm for calculating the inventory blocking number according to the number of object acquisition requests and the number of objects in the total inventory, and can give a relatively reasonable value to a specific value of the inventory blocking number, so that the occupation of computer resources can be reduced while the processing speed can be ensured.
Specifically, according to the block proportion of the total inventory, two parameters, namely the number of object acquisition requests and the number of objects in the total inventory, are used and input into an inventory block optimization algorithm for calculation, wherein the inventory block optimization algorithm can be a random number algorithm, such as a linear congruence random number algorithm, a pseudo-random number algorithm and the like, the relatively reasonable inventory block number is obtained after calculation, and through the inventory block number, further optimization can be performed by using another algorithm to obtain an optimal solution.
For example, the total stock partition proportion is calculated to be one half, the object acquisition request number X and the total stock object number Y are input into a linear congruence random number algorithm to calculate a specific value of the stock partition number, and the calculated value of the stock partition number is Z, which is a relatively reasonable stock partition number, so that the service requirement can be met.
In this embodiment, the number of object acquisition requests and the minimum number of objects corresponding to each inventory block are used to determine the total inventory blocking proportion, and the total inventory is partially blocked, so that the number in the inventory blocks is smaller, and the efficiency of processing the object acquisition requests by the computer is improved.
In one embodiment, as shown in fig. 4, at least two object acquisition requests are processed in parallel, for each object acquisition request, the inventory blocks whose number of objects satisfies a preset condition are correspondingly deducted, so as to obtain a request processing result corresponding to each object acquisition request, where the request processing result includes:
step 402, identifying each inventory block by using an identification number to obtain an inventory block identification number corresponding to each inventory block.
The identification number may be a code for identifying each stock block, each code corresponds to one stock block, the code can accurately represent information in the stock block, and the code may be generated by a computer algorithm, for example, a snowflake algorithm.
The identification number of the stock block may be a number that has been used to identify the stock block by using the identification number to obtain that each stock block has a unique identification, that is, the identification number becomes the identification number of the stock block after identification.
Specifically, a plurality of identification numbers are generated by using a computer algorithm, the number of the identification numbers is required to be larger than or equal to the number of the stock blocks, each identification number corresponds to each stock block, after identification, each stock block obtains the stock block identification number corresponding to the identification number one by one, the identification numbers can be stored in a cache and are associated with the lowest threshold value of the stock number in the stock block, the real-time stock number and the like, the identification numbers are generated independently of a database, the operation is completely carried out in a memory, millions of self-increasing identification numbers can be generated in each second, and the efficiency is very high.
For example, the total inventory is divided into M inventory blocks by partitioning, a snowflake algorithm is used to generate M identification numbers, the M inventory blocks are identified one by using the identification numbers, and the inventory block identification numbers corresponding to each M inventory blocks are obtained.
Step 404, for each object acquisition request, searching for the inventory blocks with the number of objects meeting the preset condition according to the inventory block identification number, as a target inventory block, and deducting the objects in the target inventory block to obtain the request processing result corresponding to each object acquisition request.
The preset condition may be that the number of objects in the stock block meets a preset setting condition, the condition may be that the setting is performed manually, or that the setting is performed by a computer according to actual conditions, the condition is a dynamic parameter, and the dynamic parameter changes in real time along with the change of the parameter of the system.
The target stock block may be a stock block which satisfies a preset condition but is not deducted, if a plurality of stock blocks satisfy the condition, the stock block with the largest number of selected objects is used as the target stock block, and deduction is performed from the stock block with the largest number of selected objects.
Specifically, for each object acquisition request, the computer searches for an inventory block with the number of objects meeting a preset condition according to the inventory block identification number, and takes the inventory block as a target inventory block, if a plurality of inventory blocks meet the condition, the inventory block with the largest number of objects is selected as the target inventory block, and then the objects in the target inventory block are deducted according to the data in the object acquisition request, so as to obtain the request processing result corresponding to each object acquisition request.
For example, the number of object acquisition requests obtained by the server is X, the number of objects of the inventory blocks involved in object deduction is preset to be not less than 100, for one object acquisition request, the computer searches for inventory blocks with the number of objects greater than or equal to 100 as target inventory blocks, and the obtained result is that the number of objects in 8 target inventory blocks meets the preset condition, so that the server selects the target inventory block with the largest number of objects from the 8 target inventory blocks to deduct, and obtains the request processing result corresponding to the object acquisition request after deduction, and for each object acquisition request, the above process is repeatedly executed, so as to obtain the request processing result corresponding to each object acquisition request.
In this embodiment, by using the identification number to identify each inventory block, it is possible to quickly and accurately locate inventory blocks that can meet the preset condition, and subject deduction is performed on these inventory blocks, so that the subject deduction efficiency and accuracy are greatly improved, and meanwhile, excessive deduction of inventory blocks with low subject number is avoided.
In one embodiment, as shown in fig. 5, for each object acquisition request, searching for an inventory block whose number of objects meets a preset condition according to an inventory block identification number as a target inventory block, and deducting objects in the target inventory block to obtain a request processing result corresponding to each object acquisition request, where the request processing result includes:
Step 502, for the current object obtaining request, searching a target inventory block, corresponding to the current object obtaining request, of which the number of objects meets a preset condition according to the inventory block identification number, deducting the objects in the target inventory block, and obtaining a request processing result corresponding to the current object obtaining request.
The current object acquisition request may be an object acquisition request that the server is currently processing, or that the server is currently idle and ready to process.
Specifically, a condition of an inventory block capable of being a deduction object is preset, for an object acquisition request to be processed currently, a target inventory block, the number of which can meet the preset condition, is searched according to the inventory block identification number in the identified inventory block to process the current object acquisition request, and then the object in the target inventory block is deducted to obtain a request processing result corresponding to the current object acquisition request.
For example, inventory blocks with the number of objects greater than or equal to 1000 can be preset as deduction objects, for the object acquisition request H to be processed currently, a target inventory block a capable of meeting the object acquisition request for deducting the object to be processed currently is found according to the inventory block identification number, and then deduction is performed on the objects in the target inventory block a to obtain a request processing result corresponding to the current object acquisition request H.
Step 504, taking the next object acquisition request of the current object acquisition request as the current object acquisition request, and executing the steps repeatedly until the request processing result corresponding to each object acquisition request is obtained.
The next object obtaining request may be an object obtaining request to be processed next in the processing sequence from the server relative to the current object obtaining request, and the two object obtaining requests have the same property and need the same processing steps.
Specifically, after all the steps of processing the current object acquisition request are completed, the next object acquisition request is taken as the current object acquisition request, that is, the server is about to process the next object acquisition request, then all the steps are repeatedly executed to obtain a request processing result corresponding to the next object acquisition request, and the same processing is performed on all the object acquisition requests until a request processing result corresponding to each object acquisition request is obtained.
For example, an inventory block with the number of objects greater than or equal to 1000 can be preset as a deduction object, the next object acquisition request I to be processed is taken as the current object acquisition request to be processed, and then the steps are repeatedly executed to obtain a request processing result corresponding to the next object acquisition request I to be processed, and the same processing is performed on all the object acquisition requests until a request processing result corresponding to each object acquisition request is obtained.
In this embodiment, each object acquisition request is processed in a cyclic manner, and the target inventory blocks meeting the preset conditions are deducted each time a deduction operation is performed until the request processing results corresponding to all the object acquisition requests are obtained, so that the deduction of each object acquisition request from the target inventory blocks meeting the preset conditions can be achieved, the resources of the computer system are relatively balanced, and the stability of computer processing is maintained.
In one embodiment, as shown in fig. 6, searching for a target inventory block with the number of objects corresponding to the current object obtaining request meeting a preset condition according to the inventory block identification number, deducting the objects in the target inventory block, including:
step 602, if the result of searching for the inventory blocks corresponding to the number of objects satisfying the preset condition according to the inventory block identification number is one, directly deducting the inventory blocks corresponding to the number of objects satisfying the preset condition.
Specifically, if the number of objects found according to the inventory block identification number can meet the result of the inventory block corresponding to the preset condition, then for the object acquisition request to be processed currently, the objects in the inventory block corresponding to the preset condition are directly deducted, and then the processing of the object acquisition request to be processed currently can be completed.
For example, an inventory block with the number of objects greater than or equal to 1000 can be preset as the deduction object, the number of objects found by the inventory block identification number can satisfy the result of the inventory block corresponding to the preset condition, and the result is an inventory block a, and then the inventory block a is the only choice for the object to be processed currently to obtain the request H, so that the object in the inventory block a is selected to be deducted, and the processing of the object to be processed currently to obtain the request H can be completed.
Step 604, if the number of the objects found according to the inventory block identification number satisfies at least two inventory blocks corresponding to the preset condition, deducting the inventory block corresponding to the maximum number of the objects.
Specifically, if the number of the objects found according to the inventory block identification number can meet at least two inventory blocks corresponding to the preset condition, then for the object acquisition request to be processed currently, the object of the inventory block with the maximum number of the objects in the inventory block corresponding to the preset condition is deducted, and then the processing of the object acquisition request to be processed currently can be completed.
For example, if the number of the preset objects is greater than or equal to 1000, and the number of the objects found by the inventory block identification number can satisfy the result of the inventory blocks corresponding to the preset condition, for example, 2000 objects in the inventory block a, 2100 objects in the inventory block B, 2050 objects in the inventory block C, and 2080 objects in the inventory block D, then the current object to be processed is acquired, and the inventory block with the largest number of the objects in the inventory block is selected for deduction, so that the object in the inventory block B is selected for deduction, and the current object to be processed is acquired.
In this embodiment, the inventory blocks which are deducted under different conditions are identified by the computer, so that the inventory blocks with the largest quantity of deducted objects can be always obtained when the object acquisition request is processed, and the situation that the quantity of objects is insufficient when deducted is ensured.
In one embodiment, as shown in fig. 7, according to a request processing result corresponding to each object acquisition request, adjusting the number of objects in each inventory block and the number of inventory blocks includes:
step 702, analyzing according to the request processing result corresponding to each object acquisition request to obtain an inventory block analysis result.
The inventory block analysis result may be a result including characteristics of each request processing result obtained by analyzing a request processing result corresponding to each object acquisition request by using a mathematical model.
Specifically, the request processing result corresponding to each object acquisition request is input into a preset mathematical model for analysis, at least two mathematical models are preset in a computer, automatic calling is performed according to actual conditions when the object acquisition request is needed, manual intervention can be used for selection, and an inventory block analysis result is obtained after analysis.
For example, a mathematical analysis model 1, a mathematical analysis model 2 and a mathematical analysis model 3 are preset in a computer, the request processing results corresponding to each object acquisition request are input into a value computer at the same time, and the computer selects the mathematical analysis model 3 according to the actual situation to analyze each request processing result, so as to obtain the analyzed stock block analysis result.
Step 704, adjusting the object number of each inventory block and the number of the inventory blocks based on the analysis result of the inventory blocks to obtain the object number of each updated inventory block and the number of updated inventory blocks.
The updated inventory block object number may be the object number of each inventory block obtained by properly adjusting the current inventory block object number according to the inventory block analysis result.
The updated inventory block number may be the number of inventory blocks obtained by appropriately adjusting the current inventory block number according to the inventory block analysis result.
Specifically, the number of objects of the inventory blocks and the number of inventory blocks after the object acquisition request is processed are adjusted according to the analysis result of the inventory blocks, wherein the adjustment can be the steps of splitting, reorganizing, extracting, newly creating and the like, and the number of objects of each updated inventory block and the number of updated inventory blocks are obtained after the adjustment.
For example, the inventory block analysis result Q is obtained after analysis, and the object number of the inventory blocks and the number of the inventory blocks are split, extracted and reorganized according to the inventory block analysis result Q, so that the relatively average updated inventory block object number and updated inventory block number are obtained after adjustment.
In this embodiment, by analyzing the processing result of each request and then adjusting the number of objects in the stock block and the number of stock blocks by using the analysis result of the stock block, the adjustment of computer resources can be achieved, and a good system environment is provided for the next processing.
In one embodiment, for the present technical solution, a specific method is implemented as follows. According to the technical scheme, the inventory coordinator is used for uniformly distributing the total inventory into N inventory blocks based on a snowflake algorithm, for example, the inventory is 100, 10 requests are simultaneously initiated, the total inventory is uniformly divided into 10 inventory blocks, each inventory is 10, each request is calculated in the corresponding inventory block, the inventory is deducted through a distributed lock in the inventory block of each thread, which is equivalent to the parallel operation of 10 threads, the problem of overstock is avoided, the asynchronous inventory deduction method is realized, the efficiency is greatly improved, and the mentioned distributed locks comprise the following types, namely a database lock, a cache lock and a Zookeeper lock, and the overall structure is shown in figure 8.
The inventory coordinator uniformly distributes the total inventory into inventory blocks with corresponding quantity, monitors the inventory quantity in the inventory blocks in real time, uniformly distributes the request to the corresponding inventory blocks, can supplement the inventory in advance to the inventory blocks which are rapidly consumed, can adjust the inventory quantity in each inventory block in real time when the request is increased, extracts a certain inventory quantity to newly increase the inventory blocks, can delete a certain quantity of inventory blocks when the request is reduced, and uniformly distributes the inventory quantity to other inventory blocks.
1. And the inventory distribution device is used for dividing the inventory into a plurality of inventory blocks by using a linear congruence random number algorithm.
Equation RandSeed = (a. RandSeed + B)% M
The linear congruence method is most important to define three integers, multiplier a, increment B and modulus M, where a, B, M are constants set by the generator. The period of LCG is max M, but most cases will be less than M. To maximize the period of LCG, the following conditions should be met:
① B. M is mutually mass;
② All prime factors of M can divide A-1;
③ If M is a multiple of 4, A-1 is also;
④ A. B, N [0] are all smaller than M;
⑤ A. B is a positive integer.
The algorithm is the oldest and most widely known bit random number generator algorithm, which generates pseudo-random numbers by a recursive formula. Because the number of the total stock is variable and needs to be determined according to specific requirements, the algorithm can split the stock blocks according to the specific total stock number and the request number, can split the total stock completely, and can split only half of the stock if the request is less.
For example, the total stock is 100, we set the minimum stock number of each stock block to 10 and the maximum stock number to 20. If the current request number is 10, the whole inventory is split into 10 inventory blocks, and the inventory number in each inventory block is 10. If the current request number is 5, the whole inventory can be split into 5 inventory blocks, the inventory number of each inventory block is 20, or half of the total inventory can be split into 5 inventory blocks, and the inventory number of each inventory block is 10. When the latter is more efficient, the waiting time for locking and unlocking will be much less because the latter has a small number of stock blocks.
And receiving the notification of the monitoring device in real time, and splitting or reorganizing the inventory. If the stock number in the stock block is found to be close to the threshold value or even lower than the threshold value, the stock in the stock block with the stock number higher than the threshold value is split and distributed into the stock blocks with lower stock numbers. If the number of real-time requests is increased and the number of existing stock blocks cannot meet the requirement, the stock number is extracted from the stock blocks with higher stock number, and the new stock blocks are built, which is equivalent to adding threads to process the requests, so that the stock reorganization is realized.
2. The snowflake algorithm generates an ID (structured as shown in fig. 9) to identify each inventory chunk.
The ID is saved in the cache and a minimum threshold for the amount of inventory within the inventory block, the real-time inventory number, etc. is set in association therewith. The ID generation process is independent of a database, is completely operated in a memory, can generate millions of self-increment IDs per second, and has high efficiency.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
3. The monitoring device processes the inventory in real time.
And monitoring the request number in real time, informing the inventory allocation device, and carrying out inventory reorganization operation by the allocation device according to the real-time request number.
The real-time monitoring of the number of the stock in the existing stock block through the ID is compared with the lowest threshold value, and if the threshold value is found to be close to or even lower than the threshold value, the stock distributing device is informed to carry out the stock splitting operation.
According to the technical scheme, the inventory coordinator is used for splitting the total inventory, so that the asynchronous multithreading inventory reduction effect is realized, and the problem of low inventory reduction efficiency of all the inventories in series in the prior art is solved. And the inventory can be monitored, split and reorganized in real time, so that the relative average in each inventory block is realized, the processing request is more uniform, and the problems that one thread requests too much and other threads are idle are avoided.
Based on the same inventive concept, the embodiment of the application also provides an inventory deduction device for realizing the inventory deduction method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation of the embodiment of the inventory deduction device or embodiments provided below may refer to the limitation of the inventory deduction method hereinabove, and will not be repeated here.
In one embodiment, as shown in fig. 10, there is provided an inventory deduction device, which includes an object obtaining request obtaining module, an inventory partition number determining module, an inventory block obtaining module, a request processing result obtaining module, and an inventory block adjusting module, wherein:
An object acquisition request acquisition module 1002, configured to acquire at least two object acquisition requests, where each object acquisition request is used to request deduction of at least one object in the total inventory;
an inventory partition number determining module 1004, configured to determine an inventory partition number according to the number of object acquisition requests and the number of objects in the total inventory;
the inventory block obtaining module 1006 is configured to block the total inventory according to the number of inventory blocks, and perform corresponding allocation on the objects of the total inventory to obtain at least two inventory blocks corresponding to the total inventory;
A request processing result obtaining module 1008, configured to process at least two object obtaining requests in parallel, and for each object obtaining request, correspondingly deduct inventory blocks whose number of objects meets a preset condition, to obtain a request processing result corresponding to each object obtaining request;
The inventory block adjusting module 1010 is configured to adjust the number of objects in each inventory block and the number of inventory blocks according to a request processing result corresponding to each object acquisition request.
In one embodiment, the inventory block number determining module is configured to obtain a minimum number of objects corresponding to each inventory block, determine a total inventory block proportion based on the number of object obtaining requests and the minimum number of objects corresponding to each inventory block, the total inventory block proportion is used for dividing the total inventory block proportion, and input the number of object obtaining requests and the total inventory number of objects to the inventory block optimization algorithm based on the total inventory block proportion, to determine the inventory block number.
In one embodiment, the request processing result obtaining module is used for identifying each inventory block by using an identity number to obtain an inventory block identification number corresponding to each inventory block, searching inventory blocks with the number meeting the preset condition according to the inventory block identification number as target inventory blocks for each object acquisition request, and deducting the objects in the target inventory blocks to obtain a request processing result corresponding to each object acquisition request.
In one embodiment, the request processing result obtaining module is configured to find, for the current object obtaining request, a target inventory block, corresponding to the current object obtaining request, according to the inventory block identification number, where the number of objects corresponding to the current object obtaining request meets a preset condition, deduct objects in the target inventory block to obtain a request processing result corresponding to the current object obtaining request, take a next object obtaining request of the current object obtaining request as the current object obtaining request, and execute repeatedly the steps until obtaining the request processing result corresponding to each object obtaining request.
In one embodiment, the request processing result obtaining module is configured to directly deduct the inventory blocks corresponding to the preset condition if the number of the objects found according to the inventory block identification number satisfies one inventory block corresponding to the preset condition, and deduct the inventory blocks corresponding to the maximum number of the objects if the number of the objects found according to the inventory block identification number satisfies at least two inventory blocks corresponding to the preset condition.
In one embodiment, the inventory block adjusting module is configured to analyze a request processing result corresponding to each object obtaining request to obtain an inventory block analysis result, and adjust the number of objects and the number of inventory blocks of each inventory block based on the inventory block analysis result to obtain the number of objects of each updated inventory block and the number of updated inventory blocks.
The various modules in the inventory deduction device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 11. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing server data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a stock deduction method.
It will be appreciated by those skilled in the art that the structure shown in FIG. 11 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, storing a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-described method embodiments.
The user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magneto-resistive random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (9)

1. A stock deduction method, the method comprising:
Acquiring at least two object acquisition requests, wherein each object acquisition request is used for requesting deduction of at least one object in the total inventory;
acquiring the minimum object number corresponding to each inventory block;
Determining a total stock blocking proportion based on the number of the object acquisition requests and the minimum object number corresponding to each stock block, wherein the total stock blocking proportion is used for dividing the total stock blocking proportion;
Inputting the number of the object acquisition requests and the number of the objects in the total library into an inventory blocking optimization algorithm based on the total library blocking proportion, and determining the inventory blocking number;
Partitioning the total inventory according to the inventory partitioning number, and correspondingly distributing the objects of the total inventory to obtain at least two inventory blocks corresponding to the total inventory;
Processing the at least two object acquisition requests in parallel, and correspondingly deducting inventory blocks of which the number of objects meets a preset condition for each object acquisition request to obtain a request processing result corresponding to each object acquisition request;
and adjusting the number of objects in each stock block and the number of stock blocks according to a request processing result corresponding to each object acquisition request.
2. The method according to claim 1, wherein the parallel processing of the at least two object acquisition requests, for each processing of one object acquisition request, correspondingly deducting the inventory blocks whose number of objects satisfies a preset condition, to obtain a request processing result corresponding to each object acquisition request, includes:
identifying each stock block by using an identification number to obtain a stock block identification number corresponding to each stock block;
For each object acquisition request, searching inventory blocks, the number of which meets preset conditions, according to the inventory block identification numbers, as target inventory blocks, and deducting objects in the target inventory blocks to obtain request processing results corresponding to each object acquisition request.
3. The method according to claim 2, wherein the object obtaining request is a current object obtaining request, the searching, for each processing of the object obtaining request, for an inventory block whose number meets a preset condition according to the inventory block identification number as a target inventory block, and deducting objects in the target inventory block, to obtain a request processing result corresponding to each object obtaining request, includes:
for the current object acquisition request, searching the target inventory blocks, corresponding to the current object acquisition request, of which the number of objects meets a preset condition according to the inventory block identification number, deducting the objects in the target inventory blocks to obtain a request processing result corresponding to the current object acquisition request;
and taking the next object acquisition request of the current object acquisition request as the current object acquisition request, and executing the steps repeatedly until the request processing result corresponding to each object acquisition request is obtained.
4. The method of claim 3, wherein searching the target inventory block for which the number of objects corresponding to the current object acquisition request satisfies a preset condition according to the inventory block identification number, deducting the objects in the target inventory block, includes:
If the result of searching the inventory blocks corresponding to the number of the objects meeting the preset condition is one according to the inventory block identification number, directly deducting the inventory blocks corresponding to the number of the objects meeting the preset condition;
If at least two inventory blocks corresponding to the preset conditions are found according to the inventory block identification numbers, deducting the inventory blocks corresponding to the maximum number of the objects.
5. The method according to claim 1, wherein adjusting the number of objects in each inventory block and the number of inventory blocks according to the request processing result corresponding to each object acquisition request comprises:
Analyzing according to the request processing results corresponding to the object acquisition requests to obtain an inventory block analysis result;
And adjusting the object number of each inventory block and the number of the inventory blocks based on the analysis result of the inventory blocks to obtain the object number of each updated inventory block and the number of the updated inventory blocks.
6. An inventory deduction device, the device comprising:
the system comprises an object acquisition request acquisition module, a storage module and a storage module, wherein the object acquisition request acquisition module is used for acquiring at least two object acquisition requests, and each object acquisition request is used for requesting deduction of at least one object in the total inventory;
The inventory partition number determining module is used for determining the inventory partition number according to the number of the object acquisition requests and the number of the objects in the total inventory;
the inventory block obtaining module is used for partitioning the total inventory according to the inventory partitioning quantity to obtain at least two inventory blocks corresponding to the total inventory, and executing the partitioning and simultaneously executing the corresponding allocation to the objects of the total inventory;
the request processing result obtaining module is used for processing the at least two object obtaining requests in parallel, and correspondingly deducting inventory blocks of which the number of objects meets preset conditions for each object obtaining request to obtain a request processing result corresponding to each object obtaining request;
The inventory block adjusting module is used for adjusting the number of the objects in each inventory block and the number of the inventory blocks according to a request processing result corresponding to each object acquisition request;
The inventory block quantity determining module is specifically configured to obtain a minimum object quantity corresponding to each inventory block, determine a total inventory block proportion based on the object obtaining request quantity and the minimum object quantity corresponding to each inventory block, wherein the total inventory block proportion is used for dividing the total inventory block proportion, and input the object obtaining request quantity and the total inventory object quantity into an inventory block optimization algorithm based on the total inventory block proportion to determine the inventory block quantity.
7. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 5 when the computer program is executed.
8. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 5.
9. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any one of claims 1 to 5.
CN202210202605.3A 2022-03-02 2022-03-02 Inventory deduction method, device, computer equipment and storage medium Active CN114581008B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210202605.3A CN114581008B (en) 2022-03-02 2022-03-02 Inventory deduction method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210202605.3A CN114581008B (en) 2022-03-02 2022-03-02 Inventory deduction method, device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114581008A CN114581008A (en) 2022-06-03
CN114581008B true CN114581008B (en) 2025-04-11

Family

ID=81776501

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210202605.3A Active CN114581008B (en) 2022-03-02 2022-03-02 Inventory deduction method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114581008B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115098598B (en) * 2022-06-06 2025-07-04 南京邮电大学 Internet flash sale method and system

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110310060A (en) * 2019-05-27 2019-10-08 阿里巴巴集团控股有限公司 Inventory management method and device based on fragment

Family Cites Families (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6182053B1 (en) * 1996-03-26 2001-01-30 Recovery Sales Corporation Method and apparatus for managing inventory
US20030014317A1 (en) * 2001-07-12 2003-01-16 Siegel Stanley M. Client-side E-commerce and inventory management system, and method
US20030140023A1 (en) * 2002-01-18 2003-07-24 Bruce Ferguson System and method for pre-processing input data to a non-linear model for use in electronic commerce
US20080046344A1 (en) * 2006-07-31 2008-02-21 Caterpillar Inc. System and method for managing inventory control processes
CN107767164B (en) * 2016-08-23 2020-09-11 腾讯科技(北京)有限公司 Information processing method, distribution method and device for push information order
US11100565B2 (en) * 2017-05-23 2021-08-24 Mercato, Inc. Systems and methods for allocating and distributing inventory
CN107316234A (en) * 2017-07-21 2017-11-03 北京京东尚科信息技术有限公司 Personalized commercial Forecasting Methodology and device
CN109544072A (en) * 2018-11-21 2019-03-29 北京京东尚科信息技术有限公司 Method, system, equipment and medium are reduced in hot spot inventory localization
CN110188139B (en) * 2019-05-05 2021-10-22 苏宁易购集团股份有限公司 Stock number synchronization method and device, computer equipment and storage medium
CN110147974A (en) * 2019-05-22 2019-08-20 北京云杉世界信息技术有限公司 Inventory's sharing method and device between distributed warehouse
CN111539662A (en) * 2020-07-10 2020-08-14 南京新研协同定位导航研究院有限公司 Dynamic inventory allocation method based on MR (magnetic resonance) glasses leasing business
CN112988812B (en) * 2021-03-10 2024-02-06 京东科技控股股份有限公司 Inventory data processing method, device, equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110310060A (en) * 2019-05-27 2019-10-08 阿里巴巴集团控股有限公司 Inventory management method and device based on fragment

Also Published As

Publication number Publication date
CN114581008A (en) 2022-06-03

Similar Documents

Publication Publication Date Title
US11922221B2 (en) System and method for automatic dependency analysis for use with a multidimensional database
US11514045B2 (en) Structured cluster execution for data streams
CN110199273B (en) System and method for loading, aggregating and bulk computing in one scan in a multidimensional database environment
US10956380B2 (en) System and method for parallel support of multidimensional slices with a multidimensional database
Šikšnys et al. Aggregating and disaggregating flexibility objects
CN108600321A (en) A kind of diagram data storage method and system based on distributed memory cloud
US7353218B2 (en) Methods and apparatus for clustering evolving data streams through online and offline components
CN106250457B (en) The inquiry processing method and system of big data platform Materialized View
US20240176657A1 (en) Task processing method and apparatus, electronic device, storage medium and program product
Yu et al. Sketch-based data placement among geo-distributed datacenters for cloud storages
CN114581008B (en) Inventory deduction method, device, computer equipment and storage medium
CN110390563A (en) Quantization method, device, computer equipment and the storage medium of user's value
CN110471935B (en) Data operation execution method, device, equipment and storage medium
CN112000478A (en) Job operation resource allocation method and device
CN114546652B (en) Parameter estimation method, device and electronic equipment
CN114297260B (en) Distributed RDF data query method, device and computer equipment
CN119544509A (en) Bandwidth planning method, device and computer equipment
CN109947736B (en) Method and system for real-time computing
CN117082143A (en) Resource scheduling method, device, computer equipment and storage medium
CN116485096A (en) Resource processing method, device, computer equipment and storage medium
CN112764935A (en) Big data processing method and device, electronic equipment and storage medium
CN114676675B (en) Data processing method, device, computer equipment and storage medium
CN104598618A (en) Cloud platform incomplete large data filling method based on complete compatible classes
CN114265701B (en) Resource processing method, device, computer equipment and storage medium
CN117009094B (en) Data oblique scattering method and device, electronic equipment and storage medium

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