Inventory snapshot generation method and device

By storing historical inventory snapshots in the cache and querying online, the problem of slow inventory snapshot calculation in large data volume scenarios is solved, and the method of online real-time statistics of transaction flow inventory snapshots is realized, which improves the system's response speed and accuracy.

CN119149590APending Publication Date: 2024-12-17BEIJING JINGDONG QIANSHITECHNOLOGY CO LTD

Patent Information

Application Number
CN202310722144.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-16
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

When processing large data volume scenarios, inventory snapshot calculations are slow or cannot work properly, and offline timing statistics methods cannot obtain accurate transaction inventory snapshots.

Method used

By storing historical inventory snapshots in the cache, querying historical inventory snapshots of transaction flows from the cache, determining inventory snapshots in combination with transaction flows, and updating historical inventory snapshots in the cache, real-time online statistics of transaction flows inventory snapshots.

Benefits of technology

When receiving the inventory snapshot generation request, the cache can be quickly queried to determine the inventory snapshot of the transaction flow, meeting actual needs, and improving the system's response speed and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149590A_ABST
    Figure CN119149590A_ABST
Patent Text Reader

Abstract

The invention discloses an inventory snapshot generation method and device, and relates to the technical field of computers. A specific embodiment of the method comprises the steps of obtaining a corresponding transaction flow in response to a received inventory snapshot generation request; querying a historical inventory snapshot corresponding to the transaction flow from a cache, and determining an inventory snapshot of the transaction flow according to the historical inventory snapshot and the transaction flow; and carrying out persistence on the inventory snapshots, and updating the historical inventory snapshots in the cache by using the inventory snapshots. According to the embodiment, the historical inventory snapshots are stored in the cache, and when the inventory snapshot generation request is received, the inventory snapshots of the transaction flow can be quickly determined by querying the cache, so that the method for performing online real-time statistics on the inventory snapshots of the transaction flow is realized, and actual requirements can be better met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating an inventory snapshot. Background Art

[0002] In existing warehouse management, inventory data is usually a dynamic current value, that is, only the inventory data of the current time can be viewed through the inventory model data. If you need to obtain the inventory snapshot corresponding to the real-time transaction flow, you must query the historical data from the database every time you consume the transaction flow, calculate the inventory quantity based on the historical data, and write the calculated inventory quantity into the database so that the front-end can query and obtain the inventory snapshot corresponding to the transaction flow.

[0003] In the process of implementing the present invention, the inventors found that the prior art has the following problems:

[0004] This conventional full inventory calculation method is only applicable to systems with small data volumes, good database performance, and sufficient computing resources. For scenarios with larger data volumes, this method may result in slow calculations at best, or even cause the system to malfunction. The method of using offline scheduled statistics on inventory within a specified time period can only infer the corresponding inventory quantity based on the initial inventory volume and the transaction flow within this time period, and cannot obtain an accurate transaction flow inventory snapshot. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and device for generating an inventory snapshot, which queries the historical inventory snapshot corresponding to the transaction flow from the cache, combines the transaction flow, determines the corresponding inventory snapshot, and uses the determined inventory snapshot to update the historical inventory snapshot in the cache. The embodiment of the present invention stores the historical inventory snapshot in the cache, and when receiving an inventory snapshot generation request, the inventory snapshot of the transaction flow can be quickly determined by querying the cache, thereby realizing a method for online real-time statistics of transaction flow inventory snapshots, which can better meet actual needs.

[0006] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for generating an inventory snapshot is provided, comprising:

[0007] In response to receiving the inventory snapshot generation request, obtaining a corresponding transaction flow;

[0008] Querying the historical inventory snapshot corresponding to the transaction flow from the cache, and determining the inventory snapshot of the transaction flow according to the historical inventory snapshot and the transaction flow;

[0009] The inventory snapshot is persisted, and the historical inventory snapshot in the cache is updated using the inventory snapshot.

[0010] Optionally, the transaction flow is constructed in the following manner: acquiring transaction information, and warehouse information and item information corresponding to the transaction information from a database; and constructing a transaction flow based on the transaction information, the warehouse information and the item information.

[0011] Optionally, querying the historical inventory snapshot corresponding to the transaction flow from the cache includes: querying a matching inventory snapshot that matches the inventory attribute information from the cached inventory information according to the inventory attribute information in the transaction flow; and using the matching inventory snapshot as the historical inventory snapshot corresponding to the transaction flow.

[0012] Optionally, the inventory information is stored in the cache in a data structure of a directed graph, and the inventory attribute information exists in the form of a collection; before querying the historical inventory snapshot corresponding to the transaction flow from the cache, the method further includes: determining a structure graph of the directed graph according to the inventory attribute information in the historical transaction flow, the structure graph including a root node and each child node of the root node; locating and storing the inventory quantity in the inventory information and the attribute information corresponding to the inventory quantity step by step according to the structure graph to obtain the directed graph; querying a matching inventory snapshot that matches the inventory attribute information from the cached inventory information according to the inventory attribute information in the transaction flow, including: starting from the starting node of the directed graph, querying the nodes that match the inventory attribute information step by step according to the direction of the directed graph until all the inventory attribute information are matched, thereby obtaining a matching inventory snapshot.

[0013] Optionally, the method further includes: determining the inventory snapshot of the transaction flow according to the current inventory in the transaction flow when the historical inventory snapshot corresponding to the transaction flow is not found from the cache.

[0014] Optionally, the matching inventory snapshot includes a historical serial number; before determining the inventory snapshot of the transaction flow based on the historical inventory snapshot and the transaction flow, the method includes: confirming that the historical serial number in the matching inventory snapshot does not include the serial number of the transaction flow.

[0015] Optionally, persisting the inventory snapshot includes: according to a preset routing rule, hashing and partitioning the inventory snapshot of the transaction flow to obtain a hashed inventory snapshot; according to the partition where the hashed inventory snapshot is located, storing the hashed inventory snapshot in a data sub-library corresponding to the partition, so that the sub-library can query the inventory snapshot of the transaction flow.

[0016] According to a second aspect of an embodiment of the present invention, a device for generating an inventory snapshot is provided, comprising:

[0017] A transaction flow acquisition module, configured to acquire corresponding transaction flow in response to receiving an inventory snapshot generation request;

[0018] An inventory snapshot determination module, configured to query a historical inventory snapshot corresponding to the transaction flow from a cache, and determine an inventory snapshot of the transaction flow according to the historical inventory snapshot and the transaction flow;

[0019] The inventory snapshot update module is used to persist the inventory snapshot and use the inventory snapshot to update the historical inventory snapshot in the cache.

[0020] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for generating an inventory snapshot, comprising:

[0021] one or more processors;

[0022] a storage device for storing one or more programs,

[0023] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.

[0024] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.

[0025] An embodiment of the invention has the following advantages or beneficial effects: by responding to receiving an inventory snapshot generation request, the corresponding transaction flow is obtained; the historical inventory snapshot corresponding to the transaction flow is queried from the cache, and the inventory snapshot of the transaction flow is determined according to the historical inventory snapshot and the transaction flow; the inventory snapshot is persisted, and the inventory snapshot is used to update the historical inventory snapshot in the cache. The historical inventory snapshot is stored in the cache. When the inventory snapshot generation request is received, the inventory snapshot of the transaction flow can be quickly determined by querying the cache, thereby realizing an online real-time method for counting transaction flow inventory snapshots, which can better meet actual needs. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0027] Figure 1 is a schematic diagram of the main process of a method for generating an inventory snapshot according to an embodiment of the present invention;

[0028] Figure 2 It is a detailed flow chart of generating transaction flow according to an embodiment of the present invention;

[0029] Figure 3It is a schematic diagram of constructing a transaction flow according to an embodiment of the present invention;

[0030] Figure 4 is a detailed flowchart of a method for generating an inventory snapshot according to an embodiment of the present invention;

[0031] Figure 5 is a schematic diagram of main modules of a device for generating an inventory snapshot according to an embodiment of the present invention;

[0032] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0033] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0034] It should be noted that in the technical solution of the present invention, the collection / collection, update, analysis, use, transmission, storage and other aspects of user personal information involved are in compliance with the provisions of relevant laws and regulations, are used for legal and reasonable purposes, are not shared, leaked or sold outside of these legal uses, and are subject to supervision and management by national regulatory authorities. Necessary measures should be taken for user personal information to selectively block the use or access to personal information data to prevent illegal access to such personal information data, ensure that persons who have access to personal information data comply with the provisions of relevant laws and regulations, and ensure the security of user personal information. In addition, once these user personal information data are no longer needed, the risks should be minimized by limiting or even prohibiting data collection and / or deleting data.

[0035] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0036] The existing conventional full inventory calculation method is only applicable to systems with small data volume, good database performance, and sufficient computing resources. For scenarios with large data volume, this method may result in slow calculation at best and may even cause the system to fail to work properly. The method of using offline scheduled statistics on inventory within a specified time period can only infer the corresponding inventory quantity based on the initial inventory quantity and the transaction flow within this time period, and cannot obtain an accurate transaction flow inventory snapshot, which cannot meet actual needs well.

[0037] In order to solve the above problems existing in the prior art, the present invention proposes a method and device for generating an inventory snapshot, which queries the historical inventory snapshot corresponding to the transaction flow from the cache, combines the transaction flow, determines the corresponding inventory snapshot, and uses the determined inventory snapshot to update the historical inventory snapshot in the cache. The embodiment of the present invention stores the historical inventory snapshot in the cache, and when receiving the inventory snapshot generation request, the inventory snapshot of the transaction flow can be quickly determined by querying the cache, realizing a method for online real-time statistics of transaction flow inventory snapshots, which can better meet actual needs.

[0038] In the introduction to the embodiments of the present invention, the terms and their meanings are as follows:

[0039] Bloom filter: is a data structure used to quickly check whether an element belongs to a set. It can quickly determine whether an element is in a large set, and the judgment speed is very fast and does not take up much memory space;

[0040] Consistent hashing: Consistent hashing is a special hashing algorithm that aims to solve the problem of distributed caching. When removing or adding a server, the mapping relationship between existing service requests and the servers that process the requests can be changed as little as possible.

[0041] Figure 1 FIG. 1 is a schematic diagram of the main process of the method for generating an inventory snapshot according to an embodiment of the present invention. Figure 1 As shown, the method for generating an inventory snapshot according to the embodiment of the present invention includes the following steps S101 to S103.

[0042] Step S101: in response to receiving a request to generate an inventory snapshot, obtain a corresponding transaction flow.

[0043] Specifically, in order to meet the needs of merchant users for inventory snapshots of transaction flows, the embodiments of the present invention support the generation of transaction flow inventory snapshots of multiple dimensions, for example, using the warehouse as the dimension of the inventory snapshot, and generating the inventory snapshot in the order of the transaction flows involved in the same warehouse number; or using the geographical area to which the warehouse belongs as the dimension of the inventory snapshot, and generating the inventory snapshot in the order of the transaction flows involved in the same area, etc. Merchant users can set the dimensions of multiple inventory snapshots in the system in advance. It should be noted that according to the set dimensions, in the production, consumption, calculation and storage process of the specific transaction flow, it is necessary to ensure that the same dimension rules are executed.

[0044] Furthermore, for transaction information involving inventory change operations, an embodiment of the present invention generates transaction information within a specified frequency based on a sliding window. After the transaction information is generated, the transaction information is written into a database. The transaction information includes flow data. The system constructs a production transaction flow based on the transaction information and sends each transaction flow to a message queue. The system consumer consumes the transaction flow in sequence from the queue composed of the transaction flow according to the frequency of generating the transaction information.

[0045] According to one embodiment of the present invention, the transaction flow is constructed in the following manner: acquiring transaction information, as well as warehouse information and item information corresponding to the transaction information from a database; and constructing a transaction flow based on the transaction information, the warehouse information and the item information.

[0046] Specifically, considering that the embodiments of the present invention support the generation of multi-dimensional inventory snapshots, in the process of constructing the transaction flow, as much data related to the transaction information as possible is associated, so that the transaction flow has the characteristics of "multi-dimensional" data. After obtaining the traceable transaction information such as the transaction timestamp, transaction flow number, and transaction quantity from the database, the associated warehouse information and item information are obtained according to the transaction information, wherein the warehouse information includes but is not limited to the warehouse number, and the item information includes but is not limited to the item code, the storage location of the warehouse where the item is located, and the current inventory of the item. Based on the obtained associated information, the transaction flow corresponding to the transaction information is constructed. In addition, considering that the storage of large-scale transaction information may use a distributed architecture with sub-libraries and sub-tables, the embodiments of the present invention can be deployed horizontally in parallel for the processing of such large-scale transaction information, and the transaction flow of each transaction information can be asynchronously constructed.

[0047] Figure 2 It is a detailed flow chart of generating transaction flow in the embodiment of the present invention. For the transaction information generated by a transaction, after receiving the transaction information, the system stores the transaction information in the database. If the storage fails, the transaction information processing ends; if the storage succeeds, a transaction flow including transaction information, warehouse information and item information is constructed and produced, which can be realized by constructing a transaction flow object; the constructed transaction flow is sent to the message queue to obtain the transaction flow queue; the system consumer obtains the transaction flow through the transaction flow queue.

[0048] Figure 3 The transaction flow diagram of the embodiment of the present invention is shown in FIG. The transaction flow includes warehouse information, item information and transaction information, wherein the warehouse information includes information such as the warehouse number, the item information includes information such as the item code, the storage location of the item, the current inventory of the item, etc., and the transaction information includes information such as the transaction timestamp, the transaction quantity and the transaction document.

[0049] Through the construction of the above transaction flow, basic data support is provided for the calculation and storage of subsequent transaction flows.

[0050] Step S102: query the historical inventory snapshot corresponding to the transaction flow from the cache, and determine the inventory snapshot of the transaction flow according to the historical inventory snapshot and the transaction flow.

[0051] Specifically, the embodiment of the present invention establishes inventory information for storing historical inventory snapshots of generated transaction flows in the cache, and the historical inventory snapshot is the inventory snapshot of the last transaction flow under the dimension corresponding to the current transaction flow. The historical inventory snapshot corresponding to the transaction flow is searched from the inventory information, and the transaction quantity in the transaction flow is subtracted from the historical inventory snapshot to obtain the inventory snapshot of the transaction flow.

[0052] According to one embodiment of the present invention, querying the historical inventory snapshot corresponding to the transaction flow from the cache includes: querying the matching inventory snapshot that matches the inventory attribute information from the cached inventory information according to the inventory attribute information in the transaction flow; and using the matching inventory snapshot as the historical inventory snapshot corresponding to the transaction flow.

[0053] Specifically, the transaction flow includes warehouses, items, and transaction information related to the transaction. The inventory attribute information is mainly used to index and find the historical inventory snapshot corresponding to the transaction flow from the cache. Different dimensions correspond to different inventory attribute information. Taking the warehouse dimension as an example, the inventory attribute information in the transaction flow includes the warehouse number, item code, and storage location. According to the inventory attribute information, the matching inventory snapshot that matches the inventory attribute information is queried from the cached inventory information to obtain the corresponding historical inventory snapshot. For example, the inventory attribute information of the transaction flow: the warehouse number is 2, the item code is 11203, and the storage location number is A9. A matching query is performed from the inventory information with warehouse 2, item code 11203, and storage location A9 to find the inventory information with the same warehouse 2, item code 11203, and storage location A9. The inventory snapshot in the inventory information is the matching inventory snapshot. Accordingly, the matching inventory snapshot is used as the historical inventory snapshot for the query.

[0054] According to another embodiment of the present invention, the inventory information is stored in the cache in a data structure of a directed graph, and the inventory attribute information exists in the form of a collection; before querying the historical inventory snapshot corresponding to the transaction flow from the cache, the method also includes: determining a structure graph of the directed graph according to the inventory attribute information in the historical transaction flow, the structure graph including a root node and each child node of the root node; locating and storing the inventory quantity in the inventory information and the attribute information corresponding to the inventory quantity step by step according to the structure graph to obtain the directed graph; querying the matching inventory snapshot that matches the inventory attribute information from the cached inventory information according to the inventory attribute information in the transaction flow, including: starting from the starting node of the directed graph, querying the nodes that match the inventory attribute information step by step according to the direction of the directed graph until all the inventory attribute information are matched to obtain a matching inventory snapshot.

[0055] Specifically, in order to improve the efficiency of the above matching query, the inventory information in the embodiment of the present invention is stored in the cache in the data structure of a directed graph. The directed graph is a graph with directionality, which is composed of a group of vertices and a number of directed edges, and each directed edge is connected to two ordered vertices. Before querying the historical inventory snapshot from the cache, the historical transaction flow in the database is obtained. The acquisition of the historical transaction flow is preferably selected from the historical transaction flow that is closer to the generation request time of the current inventory snapshot, so as to ensure that the inventory attribute information of the historical transaction flow is consistent with the inventory attribute information of the transaction flow obtained by the current inventory snapshot generation request. According to the inventory attribute information in the historical transaction flow, the root node of the directed graph to be constructed and each child node are determined. For example, the inventory attribute information includes: warehouse number, item code and storage location. According to the organizational structure of the warehouse, the warehouse number can be used as the root node, the item code can be used as the child node of the root node, and the storage location can be used as the child node of the item code, so that a three-level structure diagram of the directed graph can be obtained. Each inventory quantity in the inventory information has corresponding attribute information, which includes the inventory attribute information of the transaction flow. The specific attribute information may include: recording time, item level, item code, warehouse number and storage location. The attribute information corresponding to the inventory quantity is located and stored in a specific node according to the definition of each level in the structure diagram, and the corresponding inventory quantity is stored in the node at the last level of the structure diagram where the attribute information is stored, to obtain a directed graph of inventory information.

[0056] Furthermore, starting from the starting node of the directed graph, for the warehouse dimension, the starting node is generally the warehouse number. First, the starting node with the same warehouse number as the transaction flow is queried from the directed graph; then, according to the next-level item number node of the starting node in the directed graph, the second-level node with the same item number as the transaction flow is queried; then, according to the next-level storage location node of the second-level node in the directed graph, the third-level node with the same storage location information as the transaction flow is found. At this time, the matching query of the inventory attribute information is completed, and the inventory snapshot corresponding to the third-level node is the matching inventory snapshot.

[0057] According to another embodiment of the present invention, the method further includes: if the historical inventory snapshot corresponding to the transaction flow is not queried from the cache, determining the inventory snapshot of the transaction flow according to the current inventory in the transaction flow.

[0058] Specifically, the embodiment of the present invention fully considers the query result of querying the historical inventory snapshot, and performs the existence check and verification of the historical inventory snapshot in the cached inventory information according to the transaction flow. Specifically, the check can be performed through a Bloom filter. If the historical inventory snapshot is queried according to the above method, the inventory snapshot of the transaction flow is determined according to the historical inventory snapshot and the transaction flow; if the historical inventory snapshot is not queried, it means that the transaction flow is the first transaction flow generated, and there is no historical inventory snapshot. The current inventory in the transaction flow can be directly used as the inventory snapshot of the transaction flow.

[0059] According to another embodiment of the present invention, the matching inventory snapshot includes historical serial number; before determining the inventory snapshot of the transaction flow based on the historical inventory snapshot and the transaction flow, the method includes: confirming that the historical serial number in the matching inventory snapshot does not include the serial number of the transaction flow.

[0060] Specifically, since the inventory of the same item may generate a large number of concurrent transactions in a short period of time, and the inventory quantity operations may be relatively frequent, such as limited-time flash sales, in this scenario, in order to ensure that all transaction flows will trigger inventory changes and cannot be repeated, the embodiment of the present invention imposes unique constraints on the inventory snapshot of the transaction flow, and utilizes the uniqueness of the transaction flow serial number. After each inventory snapshot of the transaction flow is determined, the transaction flow serial number is stored in the historical serial number of the corresponding matching inventory snapshot. Before determining the inventory snapshot of the transaction flow based on the historical inventory snapshot and the transaction flow, it is necessary to confirm that the transaction flow serial number does not exist in the historical serial number in the matching inventory snapshot, so as to avoid repeated inventory quantity operations for the same transaction flow.

[0061] Step S103: persist the inventory snapshot, and use the inventory snapshot to update the historical inventory snapshot in the cache.

[0062] Specifically, based on the above-determined inventory snapshot, for subsequent call queries, the inventory snapshot is persisted to the database, and the historical inventory snapshot in the cache is updated, and the corresponding historical inventory snapshot is replaced with the newly determined inventory snapshot, so that subsequent transaction flows can perform inventory quantity operations based on this inventory snapshot.

[0063] According to one embodiment of the present invention, persisting the inventory snapshot includes: according to a preset routing rule, performing hash partition storage on the inventory snapshot of the transaction flow to obtain a hashed inventory snapshot; according to the partition where the hashed inventory snapshot is located, storing the hashed inventory snapshot in a data sub-library corresponding to the partition, so that the sub-library can query the inventory snapshot of the transaction flow.

[0064] Specifically, after the inventory snapshot of the transaction flow is determined, the inventory snapshot needs to be persisted. Usually, there are many inventory snapshots of the transaction flow, especially in high-concurrency scenarios. Directly storing the inventory snapshot in the database is not conducive to the query of subsequent inventory snapshots. In order to improve the efficiency of querying and reading inventory snapshots from the database, the inventory snapshot is stored in a sub-database. Specifically, after the inventory snapshot of the transaction flow is determined, the inventory snapshot is hashed and partitioned according to the agreed routing rules, and the inventory snapshot of the transaction flow is stored in the corresponding storage partition. Then, according to the storage partition where the hashed inventory snapshot is located, the corresponding database sub-database is determined. The database sub-database has a corresponding relationship with the storage partition, and the hashed inventory snapshot is stored in the corresponding database sub-database. It should be noted that the routing rules of hashed distributed storage need to be determined according to the dimensions of the inventory snapshot agreed in the early stage. For example, the inventory snapshot of the transaction flow can be stored in the storage partition of the corresponding warehouse number according to the warehouse number. The specific implementation technical means can use a consistent hash algorithm. Accordingly, according to the determined storage partition, the corresponding sub-database is determined so that the inventory snapshot of the transaction flow can be queried from the sub-database.

[0065] Figure 4It is a detailed flow chart of the method for generating an inventory snapshot of an embodiment of the present invention. The system consumer end consumes the transaction flow through the consumption processing link and constructs a corresponding inventory snapshot object; according to the transaction flow in the inventory snapshot object, the existence check and verification of the historical inventory snapshot is performed in the cache, and the existence check can be performed specifically through a Bloom filter; if the historical inventory snapshot corresponding to the transaction flow is not queried from the cache, the current inventory in the transaction flow is used as the inventory snapshot of the transaction flow; if the historical inventory snapshot corresponding to the transaction flow is queried, the historical inventory snapshot is subtracted from the transaction number in the transaction flow to obtain the inventory snapshot of the transaction flow; the hash storage partition of the inventory snapshot is determined according to the routing rule, and the inventory snapshot of the transaction flow is hashed and stored; finally, the corresponding sub-library is determined according to the storage partition, and the hashed inventory snapshot of the hash storage is stored in the sub-library to obtain the inventory snapshot stored in the sub-library (inventory snapshot-1, inventory snapshot-2, ..., inventory snapshot-n).

[0066] Through the above-mentioned method for generating inventory snapshots of transaction flows, it is possible to orderly generate transaction flows, consumption transaction flows, inventory snapshots of calculation transaction flows, and inventory snapshots of storage transaction flows under the agreed inventory snapshot dimensions. After the merchant user selects the query dimension of the transaction flow through the system, the system can quickly query the transaction flow with inventory snapshots from the corresponding sub-database according to the selected dimension, which not only meets the merchant's demand for obtaining inventory snapshots, but can also be used to compare the differences between the inventory in the merchant's ERP (Enterprise Resource Planning) system and the inventory in the actual warehouse, and quickly locate the time and documents when the inventory differences occur.

[0067] Figure 5 FIG. 2 is a schematic diagram of the main modules of the device for generating an inventory snapshot according to an embodiment of the present invention. Figure 5 As shown, the inventory snapshot generation device 500 mainly includes a transaction flow acquisition module 501, an inventory snapshot determination module 502 and an inventory snapshot update module 503.

[0068] The transaction flow acquisition module 501 is used to acquire the corresponding transaction flow in response to receiving the inventory snapshot generation request;

[0069] An inventory snapshot determination module 502 is used to query the historical inventory snapshot corresponding to the transaction flow from the cache, and determine the inventory snapshot of the transaction flow according to the historical inventory snapshot and the transaction flow;

[0070] The inventory snapshot updating module 503 is used to persist the inventory snapshot and use the inventory snapshot to update the historical inventory snapshot in the cache.

[0071] According to one embodiment of the present invention, the transaction flow is constructed in the following manner: acquiring transaction information, as well as warehouse information and item information corresponding to the transaction information from a database; and constructing a transaction flow based on the transaction information, the warehouse information and the item information.

[0072] According to another embodiment of the present invention, the inventory snapshot determination module 502 is further used to: query a matching inventory snapshot that matches the inventory attribute information from the cached inventory information according to the inventory attribute information in the transaction flow; and use the matching inventory snapshot as a historical inventory snapshot corresponding to the transaction flow.

[0073] According to another embodiment of the present invention, the inventory information is stored in the cache in a data structure of a directed graph, and the inventory attribute information exists in the form of a collection; the inventory snapshot generation device 500 also includes a directed graph generation module (not shown in the figure), which is used to: before querying the historical inventory snapshot corresponding to the transaction flow from the cache, determine the structure diagram of the directed graph according to the inventory attribute information in the historical transaction flow, the structure diagram including a root node and each child node of the root node; locate and store the inventory quantity in the inventory information and the attribute information corresponding to the inventory quantity step by step according to the structure diagram to obtain the directed graph; the inventory snapshot determination module 502 is also used to: start from the starting node of the directed graph and query the nodes matching the inventory attribute information step by step according to the direction of the directed graph until all the inventory attribute information are matched to obtain a matching inventory snapshot.

[0074] According to another embodiment of the present invention, the inventory snapshot generating device 500 also includes an inventory snapshot first determining module (not shown in the figure), which is used to: when the historical inventory snapshot corresponding to the transaction flow is not queried from the cache, determine the inventory snapshot of the transaction flow according to the current inventory in the transaction flow.

[0075] According to another embodiment of the present invention, the matching inventory snapshot includes historical serial numbers; the inventory snapshot generation device 500 also includes a serial number confirmation module (not shown in the figure), which is used to: before determining the inventory snapshot of the transaction flow based on the historical inventory snapshot and the transaction flow, confirm that the serial number of the transaction flow is not included in the historical serial numbers in the matching inventory snapshot.

[0076] According to another embodiment of the present invention, the inventory snapshot update module 503 is further used to: perform hash partition storage on the inventory snapshot of the transaction flow according to a preset routing rule to obtain a hashed inventory snapshot; based on the partition where the hashed inventory snapshot is located, store the hashed inventory snapshot in a data sub-library corresponding to the partition, so that the sub-library can query the inventory snapshot of the transaction flow.

[0077] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention can be applied.

[0078] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0079] Users can use terminal devices 601, 602, 603 to interact with server 605 through network 604 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 601, 602, 603, such as inventory snapshot applications, etc. (only as an example).

[0080] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0081] The server 605 may be a server that provides various services, such as a background management server (only an example) that provides support for inventory snapshots taken by users using the terminal devices 601, 602, and 603. In response to receiving an inventory snapshot generation request, the background management server may obtain the corresponding transaction flow; query the historical inventory snapshot corresponding to the transaction flow from the cache, determine the inventory snapshot of the transaction flow based on the historical inventory snapshot and the transaction flow; persist the inventory snapshot, and use the inventory snapshot to update the historical inventory snapshot in the cache, and feed back the processing result (such as the inventory snapshot, etc. - only an example) to the terminal device.

[0082] It should be noted that the method for generating an inventory snapshot provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the device for generating an inventory snapshot is generally disposed in the server 605 .

[0083] It should be understood that Figure 6The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0084] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 7 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0085] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0086] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.

[0087] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.

[0088] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination thereof.

[0089] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0090] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as follows: a processor includes: a transaction flow acquisition module, an inventory snapshot determination module, and an inventory snapshot update module.

[0091] The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, a transaction flow acquisition module may also be described as a "module for acquiring corresponding transaction flows in response to receiving an inventory snapshot generation request."

[0092] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiment; or may exist independently without being assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device includes: in response to receiving an inventory snapshot generation request, obtaining a corresponding transaction flow; querying a historical inventory snapshot corresponding to the transaction flow from a cache, and determining an inventory snapshot of the transaction flow based on the historical inventory snapshot and the transaction flow; persisting the inventory snapshot, and using the inventory snapshot to update the historical inventory snapshot in the cache.

[0093] The technical solution according to the embodiment of the present invention has the following advantages or beneficial effects: by responding to receiving an inventory snapshot generation request, the corresponding transaction flow is obtained; the historical inventory snapshot corresponding to the transaction flow is queried from the cache, and the inventory snapshot of the transaction flow is determined according to the historical inventory snapshot and the transaction flow; the inventory snapshot is persisted, and the inventory snapshot is used to update the historical inventory snapshot in the cache. The technical solution stores the historical inventory snapshot in the cache, and when the inventory snapshot generation request is received, the inventory snapshot of the transaction flow can be quickly determined by querying the cache, realizing a method for online real-time statistics of transaction flow inventory snapshots, which can better meet actual needs.

[0094] The specific implementation methods described herein do not constitute limitations on the scope of protection of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.

Claims

1. A method for generating an inventory snapshot, characterized in that: include: In response to receiving the inventory snapshot generation request, obtaining a corresponding transaction flow; Querying the historical inventory snapshot corresponding to the transaction flow from the cache, and determining the inventory snapshot of the transaction flow according to the historical inventory snapshot and the transaction flow; The inventory snapshot is persisted, and the historical inventory snapshot in the cache is updated using the inventory snapshot.

2. The method according to claim 1, characterized in that The transaction flow is constructed in the following way: Acquire transaction information, as well as warehouse information and item information corresponding to the transaction information from a database; A transaction flow is constructed according to the transaction information, the warehouse information and the item information.

3. The method according to claim 1, characterized in that Query the historical inventory snapshot corresponding to the transaction flow from the cache, including: According to the inventory attribute information in the transaction flow, querying the cached inventory information for a matching inventory snapshot that matches the inventory attribute information; The matching inventory snapshot is used as the historical inventory snapshot corresponding to the transaction flow.

4. The method according to claim 3, characterized in that The inventory information is stored in the cache in a directed graph data structure, and the inventory attribute information exists in the form of a set; Before querying the historical inventory snapshot corresponding to the transaction flow from the cache, the method further includes: determining a structure diagram of the directed graph according to the inventory attribute information in the historical transaction flow, the structure diagram including a root node and each child node of the root node; locating and storing the inventory quantity in the inventory information and the attribute information corresponding to the inventory quantity step by step according to the structure diagram to obtain the directed graph; According to the inventory attribute information in the transaction flow, querying the cached inventory information for a matching inventory snapshot that matches the inventory attribute information includes: Starting from the start node of the directed graph, nodes matching the inventory attribute information are queried level by level in the direction of the directed graph until all nodes matching the inventory attribute information are found, thereby obtaining a matching inventory snapshot.

5. The method according to claim 1, characterized in that The method further comprises: When no historical inventory snapshot corresponding to the transaction flow is found in the cache, the inventory snapshot of the transaction flow is determined according to the current inventory in the transaction flow.

6. The method according to claim 3, characterized in that The matching inventory snapshot includes historical serial number; Before determining the inventory snapshot of the transaction flow according to the historical inventory snapshot and the transaction flow, the method includes: Confirm that the historical serial number in the matching inventory snapshot does not include the serial number of the transaction flow.

7. The method according to claim 1, characterized in that Persisting the inventory snapshot, including: According to a preset routing rule, the inventory snapshot of the transaction flow is hashed and partitioned to obtain a hashed inventory snapshot; According to the partition where the hashed inventory snapshot is located, the hashed inventory snapshot is stored in a data sub-database corresponding to the partition, so that the sub-database can query the inventory snapshot of the transaction flow.

8. A device for generating an inventory snapshot, characterized in that: include: A transaction flow acquisition module, configured to acquire corresponding transaction flow in response to receiving an inventory snapshot generation request; An inventory snapshot determination module, configured to query a historical inventory snapshot corresponding to the transaction flow from a cache, and determine an inventory snapshot of the transaction flow according to the historical inventory snapshot and the transaction flow; The inventory snapshot update module is used to persist the inventory snapshot and use the inventory snapshot to update the historical inventory snapshot in the cache.

9. A mobile electronic device terminal, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Inventory data account checking method and inventory data account checking device

    CN106447246A

  • Pipeline data processing method and system

    CN109144970A

  • High-concurrency transaction request processing method, system and device, and storage medium

    CN109949135A

  • Reconciliation method and system for physical inventory and logical inventory of e-commerce platform

    CN110322192A

  • Data recovery method and device

    CN114896100A

Cited By

  • Material dosage traceability method and device in MRP system and storage medium

    CN119477354A

  • Inventory transfer method and system, intelligent terminal and storage medium

    CN120822910A