Bill generation method and device
By obtaining database data partition information and performing settlement sub-tasks in parallel, using overlay index and application memory to process data, the problems of low bill generation efficiency and high database pressure in the prior art are solved, and a more efficient and stable bill generation process is achieved.
Patent Information
- Application Number
- CN202411147553.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-11-26
AI Technical Summary
The existing technology is inefficient when generating large bills and has a high risk of system crash. High concurrent operations put huge pressure on database resources, affecting query performance and efficiency, and frequent database operations affect other businesses.
By obtaining the data partition information of the pending data table in the database, a settlement sub-task that executes multiple data partitions in parallel is generated, and data processing is performed using overlay indexes and application memory, which reduces frequent operations on the database, and adopts a parent-child task hierarchical model and distributed method Locking technology, partitioning and batch processing data.
It improves the efficiency and stability of bill generation, reduces the utilization rate of database resources, reduces the risk of system crashes, and optimizes query performance and bill generation process.
Smart Images

Figure CN119027253A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a bill generation method and device. Background Art
[0002] When an e-commerce platform settles fees with its partners (such as carriers or suppliers), the settlement personnel need to generate an invoice (or settlement statement).
[0003] In the related art, the bill generation method includes: 1. The settlement personnel inputs the settlement instructions in the interactive interface of the settlement system; 2. The settlement system filters, labels, and summarizes the data in the database according to the settlement instructions to obtain the required bill data and save it; 3. If more bill details are needed, the bill number (or settlement order number) is used to traverse the database, and the external bill extension field service is called according to the traversal results to generate a bill detail table. Summary of the invention
[0004] The present disclosure provides a bill generation method and device.
[0005] According to a first aspect of the present disclosure, a bill generation method is provided, comprising: in response to a bill generation instruction, obtaining data partition information of a data table to be processed in a database, the data partition information indicating that the data table to be processed contains multiple data partitions; generating a settlement subtask corresponding to each of the multiple data partitions according to the data partition information and the bill generation instruction; executing settlement subtasks corresponding to different data partitions in the multiple data partitions in parallel to obtain settlement results corresponding to each data partition; and aggregating the settlement results of the multiple data partitions to obtain bill data.
[0006] In some embodiments, generating a settlement subtask corresponding to each of the multiple data partitions according to the data partition information and the bill generation instruction includes: determining the multiple data partitions according to the data partition information; determining a time range for a settlement business according to the bill generation instruction, the time range for the settlement business including multiple unit time periods; for each of the multiple data partitions, generating multiple task queues according to the time range for the settlement business, and using the multiple task queues as settlement subtasks corresponding to the data partitions, different task queues among the multiple task queues being used to perform settlement processing on data in different unit time periods among the multiple unit time periods.
[0007] In some embodiments, different task queues among the multiple task queues are executed serially by a thread pool.
[0008] In some embodiments, the bill generation instruction includes a first query field and a second query field, the first query field is an indexed field, and the second query field is an unindexed field, and the parallel execution of settlement subtasks corresponding to different data partitions in the multiple data partitions to obtain the settlement results corresponding to each data partition includes: according to the first query field, using a covering index method, selecting a first data set from the index corresponding to each data partition in the data table to be processed, and saving the first data set to other modules other than the database; according to the second query field, selecting a second data set from the first data set; and aggregating the second data set to obtain the settlement results corresponding to each data partition.
[0009] In some embodiments, the other module is application memory.
[0010] In some embodiments, the aggregating processing of the second data set to obtain the settlement result corresponding to each data partition includes: determining the aggregation field according to the bill generation instruction; aggregating the second data set according to the aggregation field, and writing the settlement order number into the second data set to obtain the settlement result corresponding to each data partition.
[0011] In some embodiments, the parallel execution of settlement subtasks corresponding to different data partitions in the multiple data partitions also includes: obtaining primary key information of an associated data table from the second data set; generating an associated data file index based on the primary key information of the associated data table, and the associated data file index is used to generate a bill detail table.
[0012] In some embodiments, the bill generation method further includes: uploading the associated data file index to a cloud storage service; and / or generating a bill detail list based on the bill data and the associated data file index.
[0013] In some embodiments, generating a bill detail table based on the bill data and the associated data file index includes: generating multiple query subtasks for the associated data table based on the associated data file index; executing the multiple query subtasks in parallel to obtain associated data query results; and generating a bill detail table based on the associated data query results and the bill data.
[0014] According to a second aspect of the present disclosure, a bill generation device is proposed, comprising: a determination module, configured to obtain data partition information of a data table to be processed in a database in response to a bill generation instruction, wherein the data partition information indicates that the data table to be processed contains multiple data partitions; a generation module, configured to generate a settlement subtask corresponding to each of the multiple data partitions according to the data partition information and the bill generation instruction; an execution module, configured to execute settlement subtasks corresponding to different data partitions in the multiple data partitions in parallel to obtain a settlement result corresponding to each data partition; and an aggregation module, configured to aggregate the settlement results of the multiple data partitions to obtain bill data.
[0015] According to a third aspect of the present disclosure, a bill generating device is proposed, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute the bill generating method as described above based on instructions stored in the memory.
[0016] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored, and when the instructions are executed by a processor, the bill generation method as described above is implemented.
[0017] According to a fifth aspect of the present disclosure, a computer program product is proposed, on which computer program instructions are stored, and when the instructions are executed by a processor, the bill generation method as described above is implemented.
[0018] Other features and advantages of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0020] Figure 1 is a flowchart of a bill generation method according to some embodiments of the present disclosure;
[0021] Figure 2 is a flowchart of generating a settlement subtask corresponding to each data partition according to some embodiments of the present disclosure;
[0022] Figure 3 is a flowchart of executing a settlement subtask for each data partition according to some embodiments of the present disclosure;
[0023] Figure 4 is a flowchart of a bill generation method according to other embodiments of the present disclosure;
[0024] Figure 5is a flowchart of executing a settlement subtask corresponding to each data partition according to other embodiments of the present disclosure;
[0025] Figure 6 is a schematic diagram of the structure of a bill generating device according to some embodiments of the present disclosure;
[0026] Figure 7 is a schematic diagram of the structure of a bill generating device according to other embodiments of the present disclosure;
[0027] Figure 8 It is a structural diagram of a bill generating device according to some further embodiments of the present disclosure.
[0028] The present disclosure can be more clearly understood from the following detailed description with reference to the accompanying drawings. DETAILED DESCRIPTION
[0029] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.
[0030] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0031] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0032] Technologies, methods, and apparatus known to ordinary technicians in the relevant field may not be discussed in detail, but where appropriate, such technologies, methods, and apparatus should be considered part of the authorization specification.
[0033] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0034] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0035] In order to make the objectives, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0036] The bill generation method in the related technology has the following main deficiencies: 1. When generating large bills based on massive data, there are problems of low bill generation efficiency and increased risk of system crash; 2. Highly concurrent bill generation operations may cause tremendous pressure on database resources, which may lead to database performance degradation, slow database response or even downtime; 3. When settlement personnel perform personalized settlement, they often involve operations of querying the database without indexes, which will affect the performance and efficiency of the query, and thus affect the efficiency of bill generation; 4. Due to frequent database operations during the bill generation process, the database operations of other businesses may be affected, causing business delays or abnormalities.
[0037] In view of this, the present disclosure proposes a bill generation method and device, which can reduce the frequent operations on the database, reduce the utilization rate of database resources, and improve the efficiency and stability of bill generation.
[0038] Figure 1 FIG. 1 is a flow chart of a bill generation method according to some embodiments of the present disclosure. Figure 1 As shown, the bill generating method includes steps S10 to S16.
[0039] In step S10, in response to the bill generation instruction, data partition information of the to-be-processed data table in the database is obtained.
[0040] The bill generation method can be executed by a bill generation device. The bill generation device can be set at the front end or at the back end. For example, after receiving the bill generation instruction input by the settlement personnel in the front end interactive interface, the back end bill generation device is triggered to asynchronously execute the bill generation method.
[0041] The bill generation instruction may include query fields and aggregation fields entered by the settlement personnel on the front-end interactive interface. The query field is used to filter the data table to be processed in the database (such as a relational database) to limit the data scope involved in the settlement business. For example, the query field includes the merchant code (such as the supplier code, the carrier code, etc.), the time range of the settlement business, etc. The aggregation field is used to specify which data fields are to be aggregated (or summarized). For example, the aggregation field includes the amount, quantity, etc.
[0042] After receiving the bill generation instruction, the data partition information can be obtained in a variety of ways. In the first exemplary method, obtaining the data partition information includes: determining the identifier of the data table to be processed according to the bill generation instruction; and querying the correspondence between the pre-stored data table identifier and the data partition according to the identifier of the data table to be processed to obtain the data partition information of the data table to be processed. In this way, it is convenient to flexibly set the data partition information of different data tables, thereby improving the flexibility of bill generation.
[0043] In the second exemplary manner, the same data partition information is pre-set for all data tables. In this example, the pre-set data partition information is directly used as the data partition information of the data table to be processed.
[0044] In some embodiments, the bill generation method may further include: before step S10, dividing the data table to be processed into a plurality of data partitions, and writing the numbers of the data partitions in the data table to be processed.
[0045] The number of data partitions may be a fixed value or a dynamically changing value. For example, the number of data partitions may be periodically determined based on the amount of data in the data table and the processing capacity of the bill generating device. The amount of data in the data table may be represented by indicators such as the number of data records in the data table, and the processing capacity of the bill generating device may be represented by indicators such as the CPU usage rate. By dynamically determining the number of data partitions, the data partition division method may be determined more reasonably, thereby improving the bill generating efficiency.
[0046] Among them, the labeling method of the data partitions can be a random labeling method. For example, assuming that the number of data partitions to be divided is 64, the data partition number can be written in the data table to be processed according to the following method: for each data record in the data table to be processed, a positive integer in the range of 0 to 63 is generated by a random function, and the positive integer is written into the data record as the data partition label, and iterative processing is performed in the above manner, so that the data table to be processed is divided into 64 data partitions. In addition, the labeling method of the data partitions can also be a sequential labeling method, or other labeling methods. For example, assuming that the number of data partitions to be divided is 64, according to the sequential labeling method, the data partition number of the first data record is set to 0, the data partition number of the second data record is set to 1, and so on, the data partition number of the 64th data record is set to 63, and the data partition number of the 65th data record is set to 0.
[0047] In step S12, a settlement subtask corresponding to each of the multiple data partitions is generated.
[0048] In this step, a settlement subtask corresponding to each data partition is generated according to the data partition information and the bill generation instruction. The settlement subtask is used to perform operations such as filtering and aggregation on the data in the data table to be processed.
[0049] In specific implementation, a variety of methods can be used to generate the settlement subtask corresponding to each data partition. Two methods of generating settlement subtasks are given below for exemplary description.
[0050] The first way to generate settlement subtasks is as follows Figure 2As shown, it includes: step S121, determining multiple data partitions according to data partition information; step S122, determining the time range of the settlement business according to the bill generation instruction; step S123, generating multiple task queues corresponding to each data partition according to the time range of the settlement business. Among them, multiple task queues can be understood as the settlement subtasks corresponding to each of the aforementioned data partitions. The time range of the settlement business includes multiple unit time periods, and different task queues in the multiple queues corresponding to the same data partition are used to settle data in different unit time periods.
[0051] In the first method of generating a settlement subtask, the bill generation instruction can carry the time range of the settlement business. After receiving the bill generation instruction, the time range of the settlement business is determined by parsing the instruction. Then, the number of unit time periods included in the time range of the settlement business is used as the number of task queues corresponding to each data partition. Next, all task queues corresponding to each data partition are generated. Among them, the unit time period can be one hour, one day, one week or other.
[0052] In the first method of generating a settlement subtask, the bill generation instruction may not carry the time range of the settlement business. After receiving the bill generation instruction, the default settlement business time range (such as 30 days, or 20 days, etc.) is used as the time range of the settlement business. Then, the number of unit time periods included in the time range of the settlement business is used as the number of task queues corresponding to each data partition. Next, all task queues corresponding to each data partition are generated.
[0053] The second method of generating a settlement subtask includes: determining a merchant code set of a settlement business according to a bill generation instruction; generating multiple task queues according to the merchant code set for each data partition in the data table to be processed, and using the multiple task queues as settlement subtasks corresponding to the data partition. The merchant code set includes multiple merchant codes, and different task queues in the multiple task queues corresponding to the same data partition are used to perform settlement processing on data of different merchant codes.
[0054] In the embodiment of the present disclosure, by performing a preliminary division of settlement subtasks according to the number of data partitions, and then further dividing the settlement subtasks according to the time range or other dimensions of the settlement business, the data processing volume corresponding to the settlement subtasks can be further reduced, which helps to improve the efficiency of bill generation.
[0055] In step S14, the settlement subtask corresponding to each data partition is executed to obtain the settlement result corresponding to each data partition.
[0056] In the embodiment of the present disclosure, in order to improve the bill generation efficiency, when executing step S14, the settlement subtasks corresponding to different data partitions in the multiple data partitions are executed in parallel. For example, assuming that there are 3 data partitions in total, the settlement subtasks of data partition 1, data partition 2, and data partition 3 are executed in parallel.
[0057] In order to further optimize the bill generation effect, in some examples, multiple task queues are generated for each data. And when executing step S14, in addition to executing the task queues corresponding to different data partitions in parallel, the task queues corresponding to the same data partition are also executed in series. In this way, the data processing amount of each settlement subtask can be reduced while reducing the number of concurrent settlement subtasks, thereby improving the bill generation efficiency while reducing the pressure on the database and improving the stability of bill generation.
[0058] The settlement subtask is used to filter and aggregate the data in the data table to be processed. The process of executing the settlement subtask is to implement the process of filtering and aggregating the data in the data table to be processed. Figure 3 The process of executing the settlement subtask (i.e., step S14) is exemplarily described. Figure 3 As shown, the process of executing the settlement subtask includes steps S141 to S143.
[0059] In step S141, according to the first query field, a first data set is selected from the index corresponding to each data partition in the data table to be processed by using a covering index method, and the first data set is saved in the application memory.
[0060] In order to meet personalized settlement needs, a variety of query fields are provided for settlement personnel to choose from through the front-end interactive interface. These query fields include both indexed fields and non-indexed fields. For example, the indexed fields provided include merchant codes (such as carrier codes, supplier codes, etc.), time ranges for settlement business, etc., and the non-indexed fields provided include business types, service areas, etc. In specific implementation, it can be determined which fields are set as indexed fields and which fields are set as non-indexed fields according to actual needs.
[0061] After the settlement personnel select the query field and other operations on the front-end interactive interface, they submit the bill generation instruction. The bill generation instruction includes one or more first query fields and one or more second query fields. The first query field is an indexed field in the database, and the second query field is an unindexed field in the database.
[0062] After receiving the bill generation instruction and generating the settlement subtask through steps S10 and S12, first select the first data set from the index (database index) corresponding to the data partition in the data table to be processed according to the first query field carried by the bill generation instruction and use the covering index method, and save it to the application memory.
[0063] It should be noted that when executing step S141, the data to be queried corresponding to the settlement subtask matches the division method of the settlement subtask. For example, if a task queue is generated for a single data partition, when the task queue is executed, the data to be queried is the index data corresponding to the data partition; if multiple task queues are generated for a single data partition, when each task queue is executed, the data to be queried is the index data corresponding to a part of the data in the data partition (such as the data within a unit time period in the data partition).
[0064] In step S142, according to the second query field, a second data set is selected from the first data set in the application memory.
[0065] In step S143, the second data set is aggregated to obtain a settlement result corresponding to each data partition.
[0066] In some examples, the bill generation instruction carries an aggregation field. In these examples, step S143 includes: determining the aggregation field according to the bill generation instruction; and performing aggregation processing on the second data set according to the aggregation field.
[0067] In other examples, the bill generation instruction does not carry an aggregation field. In these examples, step S143 includes: performing aggregation processing on the second data set according to the aggregation field set by default. The aggregation field can be set flexibly. For example, the amount, quantity, etc. are used as aggregation fields. The aggregation processing performed on the aggregation field may include one or more data calculations such as summing (such as calculating the sum of the amount and the sum of the quantity in the settlement order dimension, calculating the sum of the amount and the sum of the data in the dimension of each expense item), and calculating the average value.
[0068] Furthermore, in addition to the data aggregation operation, step S143 may also include writing a settlement order number into the second data set.
[0069] For example, assume that three task queues are generated for data partition A, namely task queues 1, 2 and 3. Task queue 1 is used to settle the data on May 1 in data partition A, task queue 2 is used to settle the data on May 2 in data partition A, and task queue 3 is used to settle the data on May 3 in data partition A. Then executing task queue 1 includes: first filtering the index data on May 1 in data partition A in the to-be-processed data table according to the first query field to obtain data set a1, and saving data set a1 to the application memory, then filtering data set a1 according to the second query field in the application memory, and then aggregating and marking the filtered data set a2 to obtain the settlement result of task queue 1. Similarly, task queue 2 and task queue 3 can be executed in the above manner. Then, the settlement results of task queue 1, task queue 2 and task queue 3 are summarized to obtain the settlement result of data partition A.
[0070] In the embodiment of the present disclosure, by Figure 3 The process shown implements the execution process of the settlement subtask. By first performing an index query on the data table to be processed in the database to obtain the first data set, and then performing non-index query, aggregation and other operations on the first data set in the application memory, the frequency of database operations can be reduced, the utilization rate of database resources can be reduced, and the efficiency and stability of bill generation can be improved. Furthermore, by marking the settlement order number in different areas and batches, the problem of marking failure due to excessive data volume can be alleviated, and the stability of bill generation can be further improved.
[0071] Back to Figure 1 In step S16, the settlement results of the multiple data partitions are aggregated to obtain billing data.
[0072] For example, the settlement results of all data partitions are aggregated on aggregation dimensions such as the total amount of the bill and the total amount of each settlement item dimension to obtain the bill data.
[0073] Further, after obtaining the bill data, the bill data is saved. For example, the bill data is saved in a bill data table. For another example, the bill data is saved in an Excel file.
[0074] In the disclosed embodiment, the above process can effectively improve the efficiency of bill generation and improve the stability of bill generation.
[0075] Figure 4 FIG. 1 is a flow chart of a bill generation method according to other embodiments of the present disclosure. Figure 4 As shown, the bill generating method includes steps 41 to 45.
[0076] In step 41, the subtask is initialized.
[0077] In the disclosed embodiment, a parent-child task hierarchy model is adopted, and the settlement subtasks are split according to the number of data partitions. The parent-child task hierarchy model includes a main task and subtasks. Among them, the main task is mainly responsible for initializing the subtasks and aggregating the execution results of the partitioned subtasks. The subtasks are mainly responsible for data filtering, aggregation, labeling and other operations.
[0078] In some examples, the initialization subtask includes: determining all data partitions included in the data table to be processed; and generating a settlement subtask for each of all the data partitions. For example, assuming that the data table to be processed includes 64 data partitions, a settlement subtask is generated for each of the 64 data partitions.
[0079] In some embodiments, in order to improve the consistency and security of data during task execution,
[0080] The bill generation method further includes: before executing step 41, using a distributed lock to lock the data in the database. For example, in the merchant code (such as supplier code) dimension, the data in the to-be-processed data table is locked.
[0081] In step 42, the partition executes the business logic.
[0082] In some examples, the business logic executed by the partition mainly involves data filtering, aggregation, and tagging operations. Through the above operations, the settlement results of each data partition can be obtained.
[0083] In addition, considering the need to generate a detailed billing table in some cases, the business logic of partition execution also includes: extracting the primary key information of the associated data table from the filtered data (such as the second data set); generating an associated data file index based on the primary key information of the associated data table. The primary key information of the associated data table includes a primary key identifier.
[0084] For example, suppose that the data table to be processed contains three data partitions, namely data partition A, data partition B, and data partition C. When executing the settlement subtask of data partition A, the settlement result corresponding to data partition A is first obtained through filtering, aggregation, and labeling, and then the primary key identifier of associated data table 1 and the primary key identifier of associated data table 2 are extracted from the settlement result, and the primary key identifier of associated data table 1 and the primary key identifier of associated data table 2 are saved to a file (such as an Excel file or a text file) to obtain the associated data file index corresponding to data partition A. Similarly, the associated data file index corresponding to data partition B and the associated data file index corresponding to data partition C can be obtained.
[0085] In step 43, the execution results of the subtasks are aggregated.
[0086] In this step, the main task is used to aggregate the settlement results of the partitions to obtain billing data, and the associated data file indexes of each partition are aggregated.
[0087] In step 44, the billing data is saved in a database table.
[0088] In step 45, the associated data file index of each data partition is uploaded to the cloud storage service.
[0089] In the disclosed embodiment, by generating an associated data file index, a more efficient and flexible data access method is provided for subsequent bill processing services, which facilitates the subsequent direct query of the associated data table according to the file index, and generates a bill detail table accordingly, thereby improving the efficiency and convenience of generating a bill detail table. Moreover, compared with generating a database index, by generating an associated data file index, the access pressure on database resources in the process of generating a bill detail table is reduced.
[0090] In some embodiments, the bill generation method includes, in addition to Figure 4 In addition to the steps shown, the method also includes: uploading the associated data file index to the cloud storage service; and / or generating a billing statement based on the billing data and the associated data file index.
[0091] In order to further improve the efficiency of generating the bill detail table, in some examples, the bill detail table is generated according to the following method: based on the associated data file index, multiple query subtasks are generated for the associated data table; multiple query subtasks are executed in parallel to obtain the associated data query results; and a detail table is generated based on the associated data query results and the bill data.
[0092] In the disclosed embodiment, by further generating a bill detail table based on the bill data, it is possible to provide the settlement personnel with more abundant bill information and improve the settlement experience. Furthermore, by querying the associated data table in regions and batches based on the associated data file index to obtain the bill detail table, the overall efficiency of the bill generation method can be further improved.
[0093] Figure 5 1 is a flow chart of executing the settlement subtask corresponding to each data partition according to other embodiments of the present disclosure. Figure 5 right Figure 4 Step 42 in FIG. Figure 5 As shown, step 42 includes steps 421 to 423.
[0094] In step 421, multiple task queues are generated according to the time range of the settlement business.
[0095] For example, assuming that the time range of the settlement business includes M days, M task queues are generated, and each task queue includes a settlement subtask corresponding to the data of one day in the data partition.
[0096] In some examples, settlement subtasks of different data partitions are executed in parallel, and different task queues of the same data partition are executed serially by the thread pool. In this way, the amount of data to be processed by each settlement subtask and the number of concurrent settlement subtasks can be taken into account, thereby better improving the efficiency and stability of bill generation.
[0097] In some embodiments, Figure 4 The process shown also includes: using distributed lock technology (such as Redis distributed lock) to lock the settlement subtask in the merchant code field dimension. In this way, during the execution of the settlement subtask, the settlement subtasks with the same merchant code can be executed serially, effectively preventing multiple settlement subtasks from operating the same batch of data at the same time, and improving the consistency and security of data in the bill generation process.
[0098] In step 422, a single task queue is executed.
[0099] Among them, executing the settlement subtask in a single task queue includes: querying the data table to be processed, further filtering the queried data in memory, aggregating the filtered data in memory, and writing the settlement order number to the aggregated data.
[0100] For example, the bill generation instruction includes a first query field and a second query field. The first query field is an indexed field in the database, and the second query field is an unindexed field in the database. In this example, executing a single task queue includes: according to the first query field, using the covering index method, querying the index data of the unit time period in the data partition to obtain the first data set, and saving the first data set to the application memory; according to the second query field, querying the first data set in the application memory to obtain the second data set; aggregating the second data set in the application memory, and marking the second data set with a settlement order to obtain the execution result corresponding to the task queue.
[0101] In the above example, the first query field may include one or more of a merchant code, a district code, a business date, a deletion flag, and an ID range.
[0102] In the disclosed embodiment, by dividing the filtering operation into two steps, namely, first querying the database according to the indexed field to obtain the first data set, and then querying the first data set in the application memory according to the non-indexed field, the memory can be effectively used for processing during the bill generation process, reducing the frequent operations on the database, reducing the utilization rate of database resources, and improving the efficiency and stability of bill generation. Furthermore, by using a covering index method to query the database, there is no need to query the table back, which further improves the data query efficiency.
[0103] In step 423, the execution results of multiple task queues are aggregated to obtain the execution result of a single partition.
[0104] In the disclosed embodiment, the above process can more efficiently and stably process the settlement of each data partition, which helps to improve the overall efficiency of bill generation, reduce frequent operations on the database, and reduce the utilization rate of database resources.
[0105] Figure 6 is a schematic diagram of the structure of a bill generating device according to some embodiments of the present disclosure. Figure 6 As shown, the bill generating device 60 includes an acquisition module 61 , a generation module 62 , an execution module 63 , and an aggregation module 64 .
[0106] The acquisition module 61 is configured to acquire data partition information of the data table to be processed in the database in response to the bill generation instruction, wherein the data partition information indicates that the data table to be processed includes multiple data partitions.
[0107] The generating module 62 is configured to generate a settlement subtask corresponding to each data partition in the plurality of data partitions according to the data partition information and the bill generating instruction.
[0108] In some examples, the generation module 62 generates a settlement subtask corresponding to each data in the following manner: determining multiple data partitions based on data partition information; determining a time range for the settlement business based on the bill generation instruction, and the time range for the settlement business includes multiple unit time periods; for each data partition in the multiple data partitions, generating multiple task queues according to the time range of the settlement business, and different task queues in the multiple task queues are used to perform settlement processing on data in different unit time periods in the multiple unit time periods.
[0109] The execution module 63 is configured to execute the settlement subtasks corresponding to different data partitions in the multiple data partitions in parallel to obtain the settlement result corresponding to each data partition.
[0110] In some examples, the bill generation instruction includes a first query field and a second query field, the first query field is an indexed field, and the second query field is an unindexed field. In these examples, the execution module 63 is configured to execute the settlement subtask corresponding to each data partition in the following manner: according to the first query field, using the covering index method, select the first data set from the index data corresponding to each data partition, and save the first data set to the application memory; according to the second query field, select the second data set from the first data set in the application memory; aggregate the second data set in the application memory to obtain the settlement result corresponding to each data partition.
[0111] In specific implementation, when selecting the first data set according to the first query field, in addition to querying in combination with the data partition field, other fields may also be combined for querying. For example, assuming that task queue 1 and task queue 2 are generated for data partition 1, task queue 1 includes the settlement subtask corresponding to the data on May 1 in the data partition, and task queue 2 includes the settlement subtask corresponding to the data on May 2 in the data partition. When executing the settlement subtask in task queue 1, the index data of the data table to be processed is queried according to the first query field to obtain the first data set.
[0112] In the above example, the execution module 63 can perform aggregation processing according to the following exemplary method: determine the aggregation field according to the bill generation instruction; aggregate the second data set according to the aggregation field, and perform settlement order writing processing on the second data set to obtain the settlement result corresponding to each data partition.
[0113] In some embodiments, the execution module 63 is further configured to: obtain primary key information of the associated data table from the second data set; and generate an associated data file index according to the primary key information of the associated data table.
[0114] Furthermore, in some of the above embodiments, the bill generating device 60 may also include: a detailed list generating module, configured to generate a detailed bill list according to the bill data and the associated data file index.
[0115] The aggregation module 64 is configured to aggregate the settlement results of multiple data partitions to obtain billing data.
[0116] In the embodiments of the present disclosure, the above device can effectively improve the efficiency of bill generation and improve the stability of bill generation.
[0117] Figure 7 It is a structural schematic diagram of a bill generating device according to other embodiments of the present disclosure.
[0118] like Figure 7As shown, the bill generating device 70 includes a memory 71 and a processor 72 coupled to the memory 71. The memory 71 is used to store instructions for executing the corresponding embodiments of the bill generating method. The processor 72 is configured to execute the bill generating method in any of the embodiments of the present disclosure based on the instructions stored in the memory 71.
[0119] Figure 8 Schematic diagram of the structure of the bill generating device 80 according to some embodiments of the present disclosure.
[0120] like Figure 8 As shown, the bill generating apparatus 80 may be in the form of a general purpose computing device. The bill generating apparatus 80 includes a memory 81, a processor 82, and a bus 83 for connecting different system components.
[0121] The memory 81 may include, for example, a system memory, a non-volatile storage medium, etc. The system memory may store, for example, an operating system, an application program, a boot loader, and other programs. The system memory may include a volatile storage medium, such as a random access memory (RAM) and / or a cache memory. The non-volatile storage medium may store, for example, instructions for executing at least one of the corresponding embodiments of the bill generation method. The non-volatile storage medium includes, but is not limited to, a disk memory, an optical memory, a flash memory, etc.
[0122] The processor 82 may be implemented by a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistors, and other discrete hardware components. Accordingly, each module such as the acquisition module, the generation module, the execution module, and the aggregation module may be implemented by a central processing unit (CPU) running instructions in a memory for executing corresponding steps, or may be implemented by a dedicated circuit for executing corresponding steps.
[0123] The bus 83 may use any of a variety of bus structures, including, but not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MCA) bus, and a Peripheral Component Interconnect (PCI) bus.
[0124] The interfaces 84, 85, 86 in the bill generating device 80 and the memory 81 and the processor 82 can be connected via a bus 83. The input / output interface 84 can provide a connection interface for input / output devices such as a display, a mouse, and a keyboard. The network interface 85 provides a connection interface for various networked devices. The storage interface 86 provides a connection interface for external storage devices such as a floppy disk, a USB flash drive, and an SD card.
[0125] Here, various aspects of the present disclosure are described with reference to flowcharts and / or block diagrams of methods, devices, and computer program products according to embodiments of the present disclosure. It should be understood that each frame of the flowchart and / or block diagram and the combination of frames can be implemented by computer-readable program instructions.
[0126] These computer-readable program instructions may be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable device to produce a machine, so that the processor executes the instructions to produce means for implementing the functions specified in one or more blocks in the flowchart and / or block diagram.
[0127] These computer-readable program instructions may also be stored in a computer-readable memory, which cause the computer to work in a specific manner to produce an article of manufacture, including instructions for implementing the functions specified in one or more blocks in the flowchart and / or block diagram.
[0128] The present disclosure can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects.
[0129] The bill generation method and device in the above embodiments can improve the bill generation efficiency and the stability of bill generation.
[0130] So far, the bill generation method and device according to the present disclosure have been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solution disclosed here.
Claims
1. A bill generation method, comprising: In response to the bill generation instruction, obtaining data partition information of a data table to be processed in a database, wherein the data partition information indicates that the data table to be processed includes multiple data partitions; Generate a settlement subtask corresponding to each of the multiple data partitions according to the data partition information and the bill generation instruction; Executing settlement subtasks corresponding to different data partitions in the multiple data partitions in parallel to obtain a settlement result corresponding to each data partition; The settlement results of the multiple data partitions are aggregated to obtain billing data.
2. The bill generation method according to claim 1, wherein: Generating a settlement subtask corresponding to each of the multiple data partitions according to the data partition information and the bill generation instruction includes: Determine the multiple data partitions according to the data partition information; Determine a time range for a settlement service according to the bill generation instruction, wherein the time range for the settlement service includes a plurality of unit time periods; For each data partition among the multiple data partitions, multiple task queues are generated according to the time range of the settlement business, and the multiple task queues are used as settlement subtasks corresponding to the data partitions. Different task queues among the multiple task queues are used to perform settlement processing on data in different unit time periods among the multiple unit time periods.
3. The bill generation method according to claim 2, wherein: Different task queues in the multiple task queues are executed serially by the thread pool.
4. The bill generation method according to any one of claims 1 to 3, wherein: The bill generation instruction includes a first query field and a second query field, the first query field is an indexed field, and the second query field is a non-indexed field, and the parallel execution of settlement subtasks corresponding to different data partitions in the multiple data partitions to obtain the settlement result corresponding to each data partition includes: According to the first query field, using a covering index method, selecting a first data set from the index corresponding to each data partition in the to-be-processed data table, and saving the first data set to other modules except the database; selecting a second data set from the first data set according to the second query field; Aggregation processing is performed on the second data set to obtain a settlement result corresponding to each data partition.
5. The bill generation method according to claim 4, wherein: The other module is application memory.
6. The bill generation method according to claim 4, wherein: The aggregating the second data set to obtain the settlement result corresponding to each data partition includes: Determine the aggregation field according to the bill generation instruction; The second data set is aggregated according to the aggregation field, and the settlement order number is written into the second data set to obtain the settlement result corresponding to each data partition.
7. The bill generation method according to claim 4, wherein: The parallel execution of settlement subtasks corresponding to different data partitions in the multiple data partitions also includes: Acquire primary key information of the associated data table from the second data set; An associated data file index is generated according to the primary key information of the associated data table, and the associated data file index is used to generate a bill detail table.
8. The bill generation method according to claim 7, further comprising: Indexing the associated data files and uploading them to a cloud storage service; and / or, Generate a billing details table based on the billing data and the associated data file index.
9. The bill generation method according to claim 8, wherein: Generating a billing detail table according to the billing data and the associated data file index includes: Generating a plurality of query subtasks for the associated data table according to the associated data file index; Executing the multiple query subtasks in parallel to obtain the associated data query result; Generate a bill details table based on the associated data query result and the bill data.
10. A bill generating device, comprising: A determination module is configured to obtain data partition information of a data table to be processed in a database in response to a bill generation instruction, wherein the data partition information indicates that the data table to be processed includes multiple data partitions; A generation module, configured to generate a settlement subtask corresponding to each of the multiple data partitions according to the data partition information and the bill generation instruction; an execution module, configured to execute settlement subtasks corresponding to different data partitions in the multiple data partitions in parallel to obtain a settlement result corresponding to each data partition; The aggregation module is configured to aggregate the settlement results of the multiple data partitions to obtain billing data.
11. A bill generating device, comprising: Memory; as well as A processor coupled to the memory, wherein the processor is configured to execute the bill generating method according to any one of claims 1 to 9 based on instructions stored in the memory.
12. A computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implement the bill generation method according to any one of claims 1 to 9.
13. A computer program product having computer program instructions stored thereon, which, when executed by a processor, implement the bill generation method according to any one of claims 1 to 9.
