Bill data difference comparison method and device, equipment and storage medium
Patent Information
- Application Number
- CN202510575995.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-06
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-05-06
AI Technical Summary
[0003]本申请的主要目的在于提供一种账单数据差异对比方法、装置、设备及存储介质,旨在解决现有的账单数据差异对比耗时较长的技术问题
[0034] The present application proposes a method for comparing differences in bill data, which creates a first multidimensional hash table and a second multidimensional hash table based on the bill group data to be compared, wherein the first multidimensional hash table and the second multidimensional hash table both contain a number of outer keys and corresponding field mapping tables; determines whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, and deletes the matching item in the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table; simplifies the outer keys of the updated first multidimensional hash table and the updated second multidimensional hash table; determines whether each simplified outer key of the updated first multidimensional hash table has a matching item in the updated second multidimensional hash table, and generates a bill data comparison result based on the determination result. The present application reduces the time complexity of bill data comparison from the traditional O(n) to O(n) by using multidimensional hash tables. 2 ) is reduced to O(n), significantly improving comparison efficiency and making it particularly suitable for rapid comparison of large-scale billing data. Furthermore, by concatenating and simplifying outer keys, it can comprehensively and accurately identify differences between bills, ensuring the accuracy and reliability of comparison results and effectively safeguarding the consistency and integrity of financial data.
Smart Images

Figure CN120634747A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, apparatus, device and storage medium for comparing bill data differences. Background Art
[0002] With the increasing informatization of enterprises, automated comparison of billing data in financial management systems has become a key component in ensuring transaction accounting accuracy. During cross-version system upgrades or parallel testing scenarios, developers must frequently compare billing data generated by the old and new systems to verify whether changes to business logic have caused financial record anomalies. However, traditional technical solutions typically employ nested loop traversal, which is time-consuming and complex. When faced with billing data with an average daily transaction volume of millions, a single comparison takes a long time, impacting system software development and delivery cycles. Summary of the Invention
[0003] The main purpose of this application is to provide a bill data difference comparison method, device, equipment and storage medium, aiming to solve the technical problem that the existing bill data difference comparison takes a long time.
[0004] To achieve the above objectives, the present application proposes a bill data difference comparison method, which includes:
[0005] Creating a first multidimensional hash table and a second multidimensional hash table based on the bill group data to be compared, wherein the first multidimensional hash table and the second multidimensional hash table both contain a plurality of outer keys and corresponding field mapping tables;
[0006] Determine whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, and delete the matching item in the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table;
[0007] Performing outer key simplification on the updated first multidimensional hash table and the updated second multidimensional hash table;
[0008] It is determined whether each simplified outer key of the updated first multidimensional hash table has a matching item in the updated second multidimensional hash table, and a bill data comparison result is generated according to the determination result.
[0009] In one embodiment, the step of creating a first multidimensional hash table and a second multidimensional hash table based on the bill group data to be compared includes:
[0010] Get the first set of bill data and the second set of bill data;
[0011] Splitting each account data item in the first set of bill data / the second set of bill data at the field level, and performing string concatenation based on the split field names and field values to obtain a plurality of strings;
[0012] Determine each of the character strings as an outer key, and create a field mapping table corresponding to the outer key according to the field name and the field value;
[0013] A first multidimensional hash table / a second multidimensional hash table is generated according to each of the outer keys and the corresponding field mapping table.
[0014] In one embodiment, the step of determining whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, deleting the matching item in the first multidimensional hash table and the second multidimensional hash table, and obtaining an updated first multidimensional hash table and an updated second multidimensional hash table includes:
[0015] Traversing each of the outer keys in the first multidimensional hash table, and querying whether there is an identical outer key in the second multidimensional hash table;
[0016] The same outer key and the corresponding field mapping table are deleted from the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table.
[0017] In one embodiment, the step of simplifying outer keys of the updated first multidimensional hash table and the updated second multidimensional hash table includes:
[0018] A preset simplified template is obtained, and outer keys in the updated first multidimensional hash table and the updated second multidimensional hash table are simplified according to the preset simplified template to obtain simplified outer keys.
[0019] In one embodiment, the step of generating a bill data comparison result based on the judgment result includes:
[0020] Based on the judgment result, the difference outer keys are determined in the updated first multidimensional hash table, and each of the difference outer keys and the corresponding field mapping table are added to the bill data comparison result table.
[0021] In one embodiment, the step of generating a bill data comparison result based on the judgment result includes:
[0022] Determine a matching outer key in the updated first multidimensional hash table based on the judgment result, and obtain a first field mapping table and a second field mapping table of the matching outer primary key in the updated first multidimensional hash table and the updated second multidimensional hash table respectively;
[0023] Perform a differential comparison on the first field mapping table and the second field mapping table to obtain difference fields, and record the difference fields in the bill data comparison result table.
[0024] In one embodiment, after the step of recording the difference fields in the bill data comparison result table, the method further includes:
[0025] Deleting the matching outer key in the updated second multidimensional hash table, and after traversing all the simplified outer keys in the updated first multidimensional hash table, determining whether there are any remaining simplified outer keys in the updated second multidimensional hash table;
[0026] If so, the remaining simplified outer keys and the corresponding field mapping table are added to the bill data comparison result table.
[0027] In addition, to achieve the above-mentioned purpose, the present application also proposes a bill data difference comparison device, which includes:
[0028] A hash mapping module, configured to create a first multidimensional hash table and a second multidimensional hash table according to the bill group data to be compared, wherein the first multidimensional hash table and the second multidimensional hash table both contain a plurality of outer keys and corresponding field mapping tables;
[0029] a hash comparison module, configured to determine whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, and to delete the matching item in the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table;
[0030] A primary key simplification module, configured to simplify outer keys of the updated first multidimensional hash table and the updated second multidimensional hash table;
[0031] The result generating module is used to determine whether each simplified outer key of the updated first multidimensional hash table has a matching item in the updated second multidimensional hash table, and generate a bill data comparison result according to the determination result.
[0032] In addition, to achieve the above-mentioned purpose, the present application also proposes a bill data difference comparison device, which includes: a memory, a processor, and a bill data difference comparison program stored on the memory and runnable on the processor, and the bill data difference comparison program is configured to implement the steps of the bill data difference comparison method described above.
[0033] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a bill data difference comparison program is stored on the storage medium. When the bill data difference comparison program is executed by the processor, the steps of the bill data difference comparison method described above are implemented.
[0034] The present application proposes a method for comparing differences in bill data, which creates a first multidimensional hash table and a second multidimensional hash table based on the bill group data to be compared, wherein the first multidimensional hash table and the second multidimensional hash table both contain a number of outer keys and corresponding field mapping tables; determines whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, and deletes the matching item in the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table; simplifies the outer keys of the updated first multidimensional hash table and the updated second multidimensional hash table; determines whether each simplified outer key of the updated first multidimensional hash table has a matching item in the updated second multidimensional hash table, and generates a bill data comparison result based on the determination result. The present application reduces the time complexity of bill data comparison from the traditional O(n) to O(n) by using multidimensional hash tables. 2 ) is reduced to O(n), significantly improving comparison efficiency and making it particularly suitable for rapid comparison of large-scale billing data. Furthermore, by concatenating and simplifying outer keys, it can comprehensively and accurately identify differences between bills, ensuring the accuracy and reliability of comparison results and effectively safeguarding the consistency and integrity of financial data. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0037] Figure 1 This is a flowchart of the first embodiment of the bill data difference comparison method of this application;
[0038] Figure 2 This is a flowchart of the second embodiment of the bill data difference comparison method of this application;
[0039] Figure 3 This is a flowchart of the third embodiment of the bill data difference comparison method of this application;
[0040] Figure 4This is a schematic diagram of the entire process of the bill data difference comparison method for this application;
[0041] Figure 5 This is a schematic diagram of the module structure of the first embodiment of the bill data difference comparison device of this application;
[0042] Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the bill data difference comparison method in the embodiment of the present application.
[0043] The purpose, features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0044] It should be understood that the specific embodiments described herein are merely used to explain the technical solutions of the present application and are not intended to limit the present application.
[0045] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0046] This application embodiment provides a method for comparing bill data differences. Figure 1 , Figure 1 This is a flow chart of the first embodiment of the bill data difference comparison method of this application. In this embodiment, the method includes: steps S10 to S40:
[0047] Step S10: creating a first multidimensional hash table and a second multidimensional hash table according to the bill group data to be compared, wherein the first multidimensional hash table and the second multidimensional hash table both contain a plurality of outer keys and corresponding field mapping tables.
[0048] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, mobile phone, data management server, etc., or other electronic device capable of performing the above functions, such as a bill data difference comparison device. The following uses the bill data difference comparison device (hereinafter referred to as the "comparison device") as an example to illustrate this embodiment and the following embodiments.
[0049] It is understandable that the bill data set to be compared can be bill data generated by the system during a cross-version system upgrade or parallel testing. For example, bill A can be generated in a system without adding new functions, and bill B can be generated in a system with adding new functions.
[0050] Since a bill may be composed of multiple accounts, the bill data in bill A and bill B may be composed of several account data.
[0051] It should be noted that a multidimensional hash table is a data structure that allows for the storage and retrieval of data as key-value pairs. It uses a hash function to map keys to locations in the table, speeding up data retrieval. Each multidimensional hash table consists of multiple outer keys (keys) and a mapping table of fields (values) corresponding to these outer keys.
[0052] In each multidimensional hash table, each outer key corresponds to a single account data entry. This means the number of outer keys can match the number of account data entries. The outer key is composed of field-level account data and uniquely identifies the bill. The field mapping table (value) maps each bill field name to its corresponding value, forming a set of key-value pairs.
[0053] In a specific implementation, two multidimensional hash tables (a first multidimensional hash table and a second multidimensional hash table) may be created respectively according to the two sets of bill data (bill A data and bill B data) that need to be compared.
[0054] Step S20: Determine whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, and delete the matching item in the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table.
[0055] It should be understood that each outer key in the first multidimensional hash table can be traversed to determine whether these outer keys also exist in the second multidimensional hash table.
[0056] For an outer key that does not have a matching item, it means that the account data corresponding to the outer key in the first multidimensional hash table does not exist in the second multidimensional hash table, so the account data is retained in the first multidimensional hash table.
[0057] For any matching outer keys, this indicates that the account data corresponding to the outer keys in the two invoices is identical. Therefore, the matching account data can be deleted from the two multidimensional hash tables, resulting in updated first and second multidimensional hash tables. These updated multidimensional hash tables retain only the inconsistent account data from the two sets of invoice data.
[0058] Step S30: performing outer key simplification on the updated first multidimensional hash table and the updated second multidimensional hash table.
[0059] It should be noted that an outer key simplification template can be pre-configured, and the outer key simplification template can be pre-configured with key fields that need to be retained. The key field is a field combination that can be used to uniquely identify an account data, including the key field name and the combination order of each key field.
[0060] Exemplarily, the key fields may include account date, account period, and bill subject.
[0061] It should be understood that by trimming the fields of the updated hash table outer key, retaining the key fields, and obtaining a simplified outer key, it is possible to filter out non-key fields that are easy to change, such as addresses and notes, to avoid minor differences (such as decimal point precision) affecting the core comparison results, and ensure that difference detection focuses on the key fields of each account data.
[0062] Step S40: Determine whether each simplified outer key of the updated first multidimensional hash table has a matching item in the updated second multidimensional hash table, and generate a bill data comparison result based on the determination result.
[0063] It should be understood that after the multidimensional hash table is updated, each simplified outer key in the updated first multidimensional hash table may be traversed again to determine whether these simplified outer keys exist in the updated second multidimensional hash table.
[0064] Similarly, for a simplified outer key that does not have a matching item, it means that the account data corresponding to the simplified outer key in the first multidimensional hash table still does not exist in the second multidimensional hash table. Therefore, the account data is the difference data between the two bills and can be recorded.
[0065] If there is a matching simplified outer key, it means that the corresponding account data in the two invoices are the same in the core fields. In this case, different treatments can be made based on the company's difference comparison accuracy requirements:
[0066] When the comparison accuracy requirement is low, the account data corresponding to the simplified outer key in the two bills can be directly regarded as the same, and these account data can be deleted from the two multidimensional hash tables.
[0067] When higher precision is required, the two field mapping tables corresponding to the simplified outer key can be further compared to identify and record value changes, new fields, or missing fields field by field.
[0068] In addition, after matching the simplified outer keys in the first multidimensional hash table, if there are any remaining simplified outer keys in the second hash table, these are newly added bill entries and are recorded in the comparison results.
[0069] It should be understood that, based on the above comparison process, the final comparison results may include: deleted records, added records, and changed records. Deleted records are account data that exists only in the first multidimensional hash table, added records are account data that exists only in the second multidimensional hash table, and changed records are records with the same key fields but inconsistent values for some fields.
[0070] This embodiment uses a multi-dimensional hash table to reduce the time complexity of bill data comparison from the traditional O(n 2 ) is reduced to O(n), significantly improving comparison efficiency and making it particularly suitable for rapid comparison of large-scale billing data. Furthermore, by concatenating and simplifying outer keys, it can comprehensively and accurately identify differences between bills, ensuring the accuracy and reliability of comparison results and effectively safeguarding the consistency and integrity of financial data.
[0071] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above embodiment 1 can be referred to the above introduction and will not be described in detail later. Figure 2 , Figure 2 This is a flow chart of the second embodiment of the bill data difference comparison method of this application.
[0072] In this embodiment, in order to specifically illustrate the process of creating a multi-dimensional hash table, step S10 specifically includes steps S101 to S104:
[0073] Step S101: Obtain a first set of bill data and a second set of bill data.
[0074] It should be understood that the first set of bill data may be bill A generated before the system change, and the second set of bill data may be bill B generated after the system change. Bill A and bill B may each include several items of account data.
[0075] After obtaining bill A and bill B, you can use make(map[string]map[string]string) in the Go language to create corresponding multi-dimensional hash map structures, denoted as Am and Bm respectively.
[0076] Step S102: split each account data in the first set of bill data / the second set of bill data at the field level, and perform string concatenation based on the split field names and field values to obtain a plurality of character strings.
[0077] Step S103: determining each of the character strings as an outer key, and creating a field mapping table corresponding to the outer key according to the field name and the field value.
[0078] Step S104: Generate a first multidimensional hash table / a second multidimensional hash table according to each of the outer keys and the corresponding field mapping table.
[0079] It should be understood that the above multi-dimensional hash map allows all fields of each bill to be concatenated into a unique identifier as an outer key, while each field and its value are stored as an inner map.
[0080] First, we can concatenate the data of all fields of each account data in bill A to form a long string, which will be used as a key for Am. The number of account data items in bill A is the number of keys for Am.
[0081] Next, each account data item is split at the field level. The account data item includes several fields, each consisting of a field name and a field value. A new mapping table, the field mapping table, can be constructed based on the account data and used as the value of Am.
[0082] For example, if an account data in bill A is "Date: 2025-02-02, Account Period: 2025-03-02, Amount: 100,000, Billing Entity: Company A, Revenue and Expenditure: Income".
[0083] The corresponding key can be: "Date 20250205_Amount 1000_Account Period 20250302_Billing Entity Company A_Income and Expenditure".
[0084] The corresponding value can be: ["Date":"2025-02-02";"Account Period":"2025-03-02";"Amount":"100000";"Billing Entity":"Company A";"Income and Expenditure":"Income"]
[0085] It should be understood that for different account data, when string concatenation is performed to obtain a key, the concatenation order of each field data can be pre-set based on the field name; at the same time, when generating a value, the row and column order of each field mapping relationship in the field mapping table can also be pre-set based on the field name.
[0086] Finally, repeat the above process to generate the outer key and field mapping table corresponding to each account data in bill A. This determines the key and value of Am and obtains the first multidimensional hash table. Similarly, the key and value of Bm can be determined to obtain the second multidimensional hash table.
[0087] In this embodiment, the global uniqueness of the outer key is ensured by splicing all fields, thereby avoiding misjudgment caused by field order or selective comparison.
[0088] Furthermore, in order to specifically illustrate how to perform fast matching based on outer keys, step S20 specifically includes: steps S201 to S202:
[0089] Step S201: traverse each outer key in the first multidimensional hash table, and query whether the same outer key exists in the second multidimensional hash table.
[0090] It should be understood that a for loop may be used to sequentially traverse each outer key in the first multidimensional hash table to determine whether the same outer key exists in the second multidimensional hash table.
[0091] It should be noted that since the time complexity of searching for a key in a hash table is O(1), based on the fast search feature of the hash table, it can be seen that the time consumption of traversing and comparing all (number n) outer keys in the first multidimensional hash table is O(n). Therefore, compared with the traditional for loop to obtain each account data in bill A, and then for loop each account data in bill B, the time complexity is O(n). 2 ), greatly reducing bill comparison time.
[0092] Step S202: deleting the same outer key and the corresponding field mapping table in the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table.
[0093] In a specific implementation, identical outer keys and corresponding character mapping tables are deleted from both the first and second multidimensional hash tables to complete a preliminary comparison, ensuring that the first and second multidimensional hash tables obtained after the deletion store the difference between the two bills.
[0094] Furthermore, after outer-layer keys are simplified based on the updated first multidimensional hash table and the updated second multidimensional hash table, a number of simplified outer-layer keys corresponding to the first multidimensional hash table and the second multidimensional hash table are obtained respectively.
[0095] Compared with the aforementioned outer key, the simplified outer key has a shorter string length, and only retains the key field used to uniquely identify an account data item.
[0096] For example, if the outer key "date 20250205_amount 1000_account period 20250302_bill subject company A_income and expenditure" in the above example is still retained in the updated first multi-dimensional hash table.
[0097] Set the simplified outer key template to retain only the fields of account date, account period, and billing entity, and generate a simplified outer key in the order of "account date_account period_billing entity".
[0098] The simplified outer key obtained is "Date 20250205_Account Period 20250302_Billing Entity Company A".
[0099] Thus, each simplified outer key in the updated first multidimensional hash table can be traversed again to determine whether these simplified outer keys exist in the updated second multidimensional hash table, and the final difference comparison results can be obtained.
[0100] This embodiment traverses the outer keys of the first multidimensional hash table and queries each one for its existence in the second multidimensional hash table. If a match is found, the corresponding primary key and associated field mapping table are simultaneously deleted from both hash tables. This completes initial deduplication between the two bills, reducing the scope of subsequent comparison to only the difference data. Furthermore, after deleting duplicate data, the memory usage of the comparison device is significantly reduced, thus avoiding the performance loss caused by storing the entire data.
[0101] Based on the first and second embodiments of the present application, in the third embodiment of the present application, the same or similar contents as those in the first and second embodiments can be referred to above and will not be described in detail. Figure 3 , Figure 3 This is a flow chart of the third embodiment of the bill data difference comparison method of this application.
[0102] In this embodiment, in order to specifically illustrate how to obtain the comparison results of different categories, step S40 specifically includes: steps S401 to S405:
[0103] Step S401: determining the difference outer keys in the updated first multidimensional hash table based on the judgment result, and adding each of the difference outer keys and the corresponding field mapping table to the bill data comparison result table.
[0104] It should be noted that the difference outer key is a simplified outer key among the simplified outer keys in the first multidimensional hash table that has no matching item in the second multidimensional hash table. That is, the difference outer key only exists in the first multidimensional hash table and not in the second multidimensional hash table.
[0105] The account data to which the difference outer key belongs has been deleted in bill B. Therefore, the difference outer key and the corresponding field mapping table can be added to the bill data comparison result table as a deletion record.
[0106] Step S402: Determine the matching outer key in the updated first multidimensional hash table based on the judgment result, and obtain the first field mapping table and the second field mapping table of the matching outer primary key in the updated first multidimensional hash table and the updated second multidimensional hash table respectively.
[0107] Step S403: performing a differential comparison on the first field mapping table and the second field mapping table to obtain difference fields, and recording the difference fields in the bill data comparison result table.
[0108] It should be understood that, for a simplified outer key with a matching item, in order to further determine its data consistency, the field mapping tables corresponding to the simplified outer key in the two multidimensional hash tables may be further compared.
[0109] In the specific implementation, for any simplified outer key with a matching item, the corresponding first field mapping table and the second field mapping table are compared one by one to see whether there are field-level differences. For example, the field values corresponding to the same field name are different, the field name only exists in the first field mapping table, and the field name only exists in the second field mapping table, so as to determine the difference field, and add the difference field data to the bill data comparison result table as a change record.
[0110] Step S404: Delete the matching outer key in the updated second multidimensional hash table, and after traversing all the simplified outer keys in the updated first multidimensional hash table, determine whether there are any remaining simplified outer keys in the updated second multidimensional hash table.
[0111] Step S405: If yes, then the remaining simplified outer keys and corresponding field mapping tables are added to the bill data comparison result table.
[0112] It should be noted that the same simplified outer-layer keys as those in the first multidimensional hash table can be deleted one by one in the second multidimensional hash table, thereby ensuring that only the differences from the first multidimensional hash table are retained in the second multidimensional hash table. Once all simplified outer-layer keys in the first multidimensional hash table have been traversed, the second multidimensional hash table no longer contains any identical simplified outer-layer keys in the first multidimensional hash table. At this point, it can be determined whether the second multidimensional hash table is empty, that is, whether there are any remaining simplified outer-layer keys and corresponding field mapping tables.
[0113] If so, the remaining simplified outer key exists only in the second multidimensional hash table but not in the first multidimensional hash table.
[0114] The account data to which the remaining simplified outer layer belongs is the new data in bill B. Therefore, the remaining simplified outer layer key and the corresponding field mapping table can be added to the bill data comparison result table as a new record.
[0115] In a specific implementation, the bill data comparison result can be expressed in a table form, and based on the above process, a bill data comparison result table containing deleted records, newly added records and changed records can be obtained.
[0116] In addition, you can refer to Figure 4 The whole process of the bill data difference comparison method of this application is explained. Figure 4 This is a schematic diagram of the entire process of the bill data difference comparison method for this application.
[0117] based on Figure 4 It can be seen that first, bill A and bill B are generated based on the original system and the system with new functions added respectively; then the data of the two bills are read and processed in turn to generate a multidimensional hash map-Am (first multidimensional hash table) and a multidimensional hash map-Bm (second multidimensional hash table).
[0118] Next, traverse each key in Am and determine whether it exists in Bm. If so, delete the key and the corresponding value in Am and Bm; if not, keep them in Am and Bm.
[0119] After traversing all the keys in Am, the remaining Am and Bm are the differences between the two bills.
[0120] Then, based on the remaining Am and Bm, a simplified key is regenerated, in which only the key fields that can identify a unique account data are retained.
[0121] Then, traverse each simplified key in Am and determine whether it exists in Bm;
[0122] If it does not exist, it means that the account data to which the simplified key belongs does not exist in Bm, and the record is considered deleted and added to the comparison result;
[0123] If so, the field mapping tables in the two multidimensional hash tables are compared to determine if there are any field-level differences. The difference field data is recorded as a change record and added to the comparison result. After being added to the comparison result, the difference field data is deleted from Bm.
[0124] In addition, after traversing all simplified keys in Am, if Bm is still not empty, the remaining simplified keys in Bm and the account data to which they belong can be regarded as new records and added to the comparison results.
[0125] In this embodiment, since all field data of the bill is retained in the multidimensional hash table by means of a field mapping table, when comparing bills, all account data can be compared at the field level, thereby ensuring the comprehensiveness of the bill data comparison.
[0126] It should be noted that the above examples are only used to understand this application and do not constitute a limitation on the bill data difference comparison method of this application. More forms of simple transformations based on this technical concept are all within the scope of protection of this application.
[0127] In addition, this application also provides a bill data difference comparison device, referring to Figure 5 , Figure 5 This is a structural block diagram of the first embodiment of the bill data difference comparison device of this application; Figure 5As shown, the device includes:
[0128] A hash mapping module 501 is configured to create a first multidimensional hash table and a second multidimensional hash table based on the bill group data to be compared, wherein the first multidimensional hash table and the second multidimensional hash table each contain a plurality of outer keys and corresponding field mapping tables;
[0129] a hash comparison module 502 configured to determine whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, and to delete the matching item from the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table;
[0130] A primary key simplification module 503 is configured to simplify outer keys of the updated first multidimensional hash table and the updated second multidimensional hash table;
[0131] The result generating module 504 is configured to determine whether each simplified outer key of the updated first multidimensional hash table has a matching item in the updated second multidimensional hash table, and generate a bill data comparison result based on the determination result.
[0132] Furthermore, the hash mapping module 501 is used to obtain a first set of bill data and a second set of bill data; split each account data in the first set of bill data / the second set of bill data at the field level, and perform string concatenation based on the split field names and field values to obtain several strings; determine each of the strings as an outer key, and create a field mapping table corresponding to the outer key based on the field name and the field value; generate a first multidimensional hash table / a second multidimensional hash table based on each of the outer keys and the corresponding field mapping table.
[0133] Furthermore, the hash comparison module 502 is also used to traverse each of the outer keys in the first multidimensional hash table, and query whether the same outer key exists in the second multidimensional hash table; delete the same outer key and the corresponding field mapping table in the first multidimensional hash table and the second multidimensional hash table, and obtain an updated first multidimensional hash table and an updated second multidimensional hash table.
[0134] Furthermore, the primary key simplification module 503 is further configured to obtain a preset simplification template, and simplify the outer keys in the updated first multidimensional hash table and the updated second multidimensional hash table according to the preset simplification template to obtain simplified outer keys.
[0135] Furthermore, the result generation module 504 is further configured to determine the difference outer keys in the updated first multidimensional hash table based on the judgment result, and add each of the difference outer keys and the corresponding field mapping table to the bill data comparison result table.
[0136] Furthermore, the result generation module 504 is also used to determine the matching outer key in the updated first multidimensional hash table based on the judgment result, and obtain the first field mapping table and the second field mapping table of the matching outer primary key in the updated first multidimensional hash table and the updated second multidimensional hash table respectively; perform differential comparison on the first field mapping table and the second field mapping table to obtain the difference field, and record the difference field in the bill data comparison result table.
[0137] Furthermore, the result generation module 504 is also used to delete the matching outer key in the updated second multidimensional hash table, and after traversing all the simplified outer keys in the updated first multidimensional hash table, determine whether there are any remaining simplified outer keys in the updated second multidimensional hash table; if so, add the remaining simplified outer keys and the corresponding field mapping table to the bill data comparison result table.
[0138] This embodiment uses a multi-dimensional hash table to reduce the time complexity of bill data comparison from the traditional O(n 2 ) is reduced to O(n), significantly improving comparison efficiency and making it particularly suitable for rapid comparison of large-scale billing data. Furthermore, by concatenating and simplifying outer keys, it can comprehensively and accurately identify differences between bills, ensuring the accuracy and reliability of comparison results and effectively safeguarding the consistency and integrity of financial data.
[0139] Other embodiments or specific implementation methods of the bill data difference comparison device described in this application can refer to the above-mentioned method embodiments and will not be repeated here.
[0140] The present application also provides a bill data difference comparison device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the bill data difference comparison method in the above-mentioned embodiment one.
[0141] Reference below Figure 6 , Figure 6The following is a schematic diagram of the structure of the bill data difference comparison device of the present application. The bill data difference comparison device in the embodiments of the present application may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), etc., as well as fixed terminals such as digital TVs and desktop computers. Figure 6 The bill data difference comparison device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0142] like Figure 6 As shown, the bill data difference comparison device may include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage device 1003 into a random access memory (RAM) 1004. RAM 1004 also stores various programs and data required for the operation of the bill data difference comparison device. Processing device 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input device 1007 including, for example, a touch screen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output device 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage device 1003 including, for example, a magnetic tape, hard disk, etc.; and communication device 1009. The communication device 1009 can allow the bill data difference comparison device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a bill data difference comparison device with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented or have alternatively.
[0143] The bill data difference comparison device provided in this application utilizes the bill data difference comparison method described in the above-mentioned embodiments to solve the technical problems associated with bill data difference comparison. Compared to the prior art, the beneficial effects of the bill data difference comparison device provided in this application are the same as those of the bill data difference comparison method described in the above-mentioned embodiments. Other technical features of the bill data difference comparison device are the same as those disclosed in the above-mentioned embodiments and are not further elaborated here.
[0144] The present application also provides a computer-readable storage medium having computer-readable program instructions (ie, a computer program) stored thereon, the computer-readable program instructions being used to execute the bill data difference comparison method in the above-mentioned embodiment.
[0145] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination thereof. 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 thereof. In this embodiment, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0146] The computer-readable storage medium provided in this application stores computer-readable program instructions (i.e., a computer program) for executing the aforementioned bill data difference comparison method, thereby resolving the technical problem of bill data difference comparison. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the bill data difference comparison method provided in the aforementioned embodiment, and are not further elaborated here.
[0147] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional elements in the process, method, article, or system comprising the element.
[0148] The serial numbers of the above-mentioned embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments. Moreover, they are only some embodiments of the present application and do not limit the patent scope of the present application. All equivalent structural transformations made by using the contents of the description and drawings of the present application under the technical concept of the present application, or direct / indirect application in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A method for comparing bill data differences, characterized in that: The method comprises: Creating a first multidimensional hash table and a second multidimensional hash table based on the bill group data to be compared, wherein the first multidimensional hash table and the second multidimensional hash table both contain a plurality of outer keys and corresponding field mapping tables; Determine whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, and delete the matching item in the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table; Performing outer key simplification on the updated first multidimensional hash table and the updated second multidimensional hash table; It is determined whether each simplified outer key of the updated first multidimensional hash table has a matching item in the updated second multidimensional hash table, and a bill data comparison result is generated according to the determination result.
2. The method according to claim 1, wherein The step of creating a first multidimensional hash table and a second multidimensional hash table based on the bill group data to be compared includes: Get the first set of bill data and the second set of bill data; Splitting each account data item in the first set of bill data / the second set of bill data at the field level, and performing string concatenation based on the split field names and field values to obtain a plurality of strings; Determine each of the character strings as an outer key, and create a field mapping table corresponding to the outer key according to the field name and the field value; A first multidimensional hash table / a second multidimensional hash table is generated according to each of the outer keys and the corresponding field mapping table.
3. The method according to claim 1, wherein The step of determining whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, deleting the matching item in the first multidimensional hash table and the second multidimensional hash table, and obtaining an updated first multidimensional hash table and an updated second multidimensional hash table includes: Traversing each of the outer keys in the first multidimensional hash table, and querying whether there is an identical outer key in the second multidimensional hash table; The same outer key and the corresponding field mapping table are deleted from the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table.
4. The method according to claim 1, wherein The step of simplifying outer keys of the updated first multidimensional hash table and the updated second multidimensional hash table includes: A preset simplified template is obtained, and outer keys in the updated first multidimensional hash table and the updated second multidimensional hash table are simplified according to the preset simplified template to obtain simplified outer keys.
5. The method according to claim 1, wherein The step of generating a bill data comparison result based on the judgment result includes: Based on the judgment result, the difference outer keys are determined in the updated first multidimensional hash table, and each of the difference outer keys and the corresponding field mapping table are added to the bill data comparison result table.
6. The method according to claim 5, wherein The step of generating a bill data comparison result based on the judgment result includes: Determine a matching outer key in the updated first multidimensional hash table based on the judgment result, and obtain a first field mapping table and a second field mapping table of the matching outer primary key in the updated first multidimensional hash table and the updated second multidimensional hash table respectively; Perform a differential comparison on the first field mapping table and the second field mapping table to obtain difference fields, and record the difference fields in the bill data comparison result table.
7. The method according to claim 6, wherein After the step of recording the difference fields into the bill data comparison result table, the method further includes: Deleting the matching outer key in the updated second multidimensional hash table, and after traversing all the simplified outer keys in the updated first multidimensional hash table, determining whether there are any remaining simplified outer keys in the updated second multidimensional hash table; If so, the remaining simplified outer keys and the corresponding field mapping table are added to the bill data comparison result table.
8. A bill data difference comparison device, characterized in that: The device comprises: A hash mapping module, configured to create a first multidimensional hash table and a second multidimensional hash table according to the bill group data to be compared, wherein the first multidimensional hash table and the second multidimensional hash table both contain a plurality of outer keys and corresponding field mapping tables; a hash comparison module, configured to determine whether each outer key in the first multidimensional hash table has a matching item in the second multidimensional hash table, and to delete the matching item in the first multidimensional hash table and the second multidimensional hash table to obtain an updated first multidimensional hash table and an updated second multidimensional hash table; A primary key simplification module, configured to simplify outer keys of the updated first multidimensional hash table and the updated second multidimensional hash table; The result generating module is used to determine whether each simplified outer key of the updated first multidimensional hash table has a matching item in the updated second multidimensional hash table, and generate a bill data comparison result according to the determination result.
9. A bill data difference comparison device, characterized in that: The device includes a memory, a processor, and a bill data difference comparison program stored in the memory and executable on the processor. When the bill data difference comparison program is executed by the processor, the steps of the bill data difference comparison method according to any one of claims 1 to 7 are implemented.
10. A storage medium, characterized in that: The storage medium stores a bill data difference comparison program, which, when executed by a processor, implements the steps of the bill data difference comparison method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data comparison method and device and storage medium
CN109656964A
File content difference identification method and device, equipment and storage medium
CN119067092A