A multi-service system-oriented cost data collection and cleaning method and system
By constructing an event fingerprint chain and node-based cleaning rules, the problems of lack of traceability of events and inability of rules to dynamically adapt during the cost data collection and cleaning process in multi-business systems were solved. This enabled segment-by-segment traceability of cost events and accurate location of anomaly markers, improving the consistency and maintainability of data processing.
Patent Information
- Application Number
- CN202611663840.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-27
- Publication Date
- 2026-11-27
AI Technical Summary
During the cost data collection and cleaning process of multiple business systems, cost events lack event-level traceability identifiers, and cleaning rules cannot be dynamically adapted to cost elements, making it difficult to accurately locate and process abnormal data. Furthermore, as the number of business systems increases, maintenance complexity rises, and the risks of channel mismatch and rule omissions increase.
A cost event description body is constructed, and business domain identifiers, cost object identifiers, expense element identifiers, and time sequence identifiers are assigned to form an event fingerprint chain. Through aggregation routing, temporary storage partitioning, and cleaning rule tree node processing, the correspondence between field conversion and anomaly marking is realized.
It enables step-by-step traceability of cost events during the collection and cleaning process, and refines the granularity of anomaly marking from batch or channel to specific cost event descriptions, thereby enhancing the consistency and traceability of data processing and reducing maintenance complexity.
Smart Images

Figure CN123178386A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cost data processing technology, specifically to a method and system for cost data collection and cleaning for multi-business systems. Background Technology
[0002] Cost data collection and cleaning across multiple business systems typically involves extracting fields such as cost objects, expense elements, and business time from interface messages of various business systems, and then importing the data into the database according to a preset collection channel or a unified mapping table. Different business system interface messages differ in field naming, units of measurement, expense element classification, and cost object encoding methods. The same expense element may use different field names and units of measurement in different business systems, and the cost object encoding hierarchy may also be inconsistent. Some messages carry expense fields in text form, while others carry them in numerical form. Current collection processes generally configure fixed routes based on business domains or cost objects, and the cleaning process uses static field transformation and validation rules.
[0003] Before cost events are aggregated, they lack structured chain-like identifiers for source systems, business times, cost objects, and expense elements. During the aggregation process, when inconsistencies in fields, deviations in units, or write anomalies occur, it's difficult to trace the abnormal data back to specific interface messages and events; typically, only batch or channel identification is possible. Static cleaning rules cannot dynamically adjust field mapping logic and validation dependency order based on expense element types. The execution granularity of name normalization, unit normalization, null value validation, and cross-validation is coarse, and anomaly markers cannot accurately fall into the corresponding cost event descriptor position. Inconsistent records also cannot be correlated with event sources. After cost events are written to the cost aggregation database, there is a lack of chain relationships between cost events, making it impossible to form a verifiable chain summary based on the write results, and consistency in the processing process is difficult to verify. As the number of multi-business system accesses increases and the types of expense elements expand, the complexity of maintaining fixed routes and static rules increases, and the risks of channel mismatch and rule omissions increase. The cost data aggregation and cleaning process needs event-level traceability and requires field conversion and validation based on expense element differences to ensure that anomaly markers can be mapped to specific cost event descriptor positions. Summary of the Invention
[0004] This invention proposes a method and system for cost data collection and cleaning for multi-business systems. The purpose is to address the problems of lack of event-level traceable identifiers for cost events and the inability of cleaning rules to be dynamically adapted to cost elements during the cost data collection and cleaning process of multi-business systems. By constructing a cost event descriptor and forming an event fingerprint chain, and by using collection routing, temporary storage partitioning, and node-based processing of cleaning rule trees, cost events can be traced section by section during the collection and cleaning process. Field conversion and anomaly marking correspond to specific cost elements and the location of the event descriptor.
[0005] To achieve the above objectives, the present invention provides the following technical solution: a method for cost data collection and cleaning for multi-service systems, comprising:
[0006] Construct a cost event description body for multiple business system interfaces, and assign business domain identifiers, cost object identifiers, expense element identifiers, and time sequence identifiers to form an event fingerprint chain;
[0007] Based on the business domain identifier and cost object identifier in the event fingerprint chain, determine the aggregation channel in the aggregation routing table;
[0008] In the collection channel, the cost event descriptions are written sequentially to the temporary storage partition to generate the cleaning task description.
[0009] Based on the cost element identifier in the cleaning task description body, the field mapping node and verification node in the cleaning rule tree are called to perform field conversion and anomaly marking on the cost event description body in the temporary storage partition.
[0010] Write the processed cost event description into the cost aggregation library and update the event fingerprint chain.
[0011] Preferably, the step of determining the aggregation channel in the aggregation routing table based on the service domain identifier and cost object identifier in the event fingerprint chain specifically involves:
[0012] Read the business domain identifier and cost object identifier from the event fingerprint chain, and search for the first route segment corresponding to the business domain identifier and the second route segment corresponding to the cost object identifier in the aggregation routing table;
[0013] The first route segment and the second route segment are concatenated in segment order to obtain the aggregation channel;
[0014] Write the timing identifier in the aggregation channel and event fingerprint chain into the routing receipt, and return the routing receipt to the cost event description body.
[0015] Preferably, the step of sequentially writing the cost event description body into the temporary storage partition in the collection channel to generate the cleaning task description body specifically involves:
[0016] A temporary storage partition is created according to the channel number in the collection channel, and the timing identifier in the cost event description body is read.
[0017] Write the cost event description body into the time slot of the temporary storage partition according to the time sequence identifier to obtain the slot occupancy record;
[0018] A cleaning task description body is generated based on the slot occupancy record. The cleaning task description body carries the temporary storage partition address and cost element identifier.
[0019] Preferably, the step of calling the field mapping node and verification node in the cleaning rule tree based on the cost element identifier in the cleaning task description body to perform field conversion and anomaly marking on the cost event description body in the temporary storage partition is as follows:
[0020] Using the cost element identifier in the cleaning task description body as an index, select field mapping nodes and verification nodes in the cleaning rule tree;
[0021] Load the mapping table corresponding to the field mapping node into the temporary storage partition, and normalize the name and dimension of the cost field in the cost event description body to obtain the normalized field.
[0022] Input the normalized field into the validation node. The validation node performs null value validation and cross-validation according to the field dependency order, and writes an exception flag in the cost event descriptor.
[0023] Preferably, the step of writing the processed cost event description into the cost aggregation library and updating the event fingerprint chain specifically involves:
[0024] Extract the cost event description body after field transformation and exception marking from the temporary storage partition, and read the business domain identifier and cost object identifier from the cost event description body;
[0025] Locate the collection primary key corresponding to the business domain identifier and cost object identifier in the cost collection library, and write the cost event description body into the cost collection library according to the collection primary key.
[0026] Calculate the chain summary of the cost event descriptor based on the write result, and append the chain summary to the event fingerprint chain.
[0027] Preferably, the construction of the multi-service system interface cost event descriptor, assigning business domain identifiers, cost object identifiers, expense element identifiers, and time sequence identifiers to form an event fingerprint chain, specifically involves:
[0028] Obtain the interface messages of multiple business system interfaces, and extract the cost object field, expense element field, and business time field from the interface messages;
[0029] Write the system code to which the interface message belongs to the business domain identifier, write the cost object field to the cost object identifier, write the expense element field to the expense element identifier, and convert the business time field to a time sequence identifier.
[0030] The chain is generated by concatenating the business domain identifier, cost object identifier, expense element identifier, and time sequence identifier, and the chain is sorted by the business time field to form an event fingerprint chain.
[0031] Preferably, the step of concatenating the first routing segment and the second routing segment to obtain the aggregation channel specifically involves:
[0032] Read the service domain hierarchy code from the first routing segment and the cost object hierarchy code from the second routing segment;
[0033] Based on the hierarchical depth of the business domain hierarchical code and the cost object hierarchical code, the business domain hierarchical code is set to the front end of the collection channel, and the cost object hierarchical code is set to the back end of the collection channel.
[0034] A channel separator is written between the front and back of the aggregation channel, and a channel check bit is used to verify the front, the channel separator, and the back of the aggregation channel to obtain the aggregation channel.
[0035] Preferably, the step of generating a cleaning task description body based on the slot occupancy record specifically includes:
[0036] Read the temporary partition address, slot number, and slot capacity from the slot occupancy record;
[0037] Write the temporary partition address to the partition pointer of the cleaning task description body, write the slot sequence number to the batch number of the cleaning task description body, and write the slot capacity to the processing granularity of the cleaning task description body.
[0038] Read the cost element identifier from the cost event description body, and assemble the cost element identifier, partition pointer, batch number, and processing granularity into a cleaning task description body according to the task template.
[0039] Preferably, the step of inputting the normalized field into the validation node, the validation node performing null value validation and cross-validation according to the field dependency order, and writing an exception flag in the cost event description body, specifically:
[0040] Read the field dependency order corresponding to the verification node from the cleaning rule tree. The field dependency order includes the sequential reference relationship between the cost field and the cost object field.
[0041] Extract the cost field value and cost object field value from the normalized field according to the field dependency order, and perform cross-validation on the cost field value and cost object field value;
[0042] When cross-validation generates an inconsistent record, an exception flag is written to the cost event descriptor corresponding to the inconsistent record, and the inconsistent record is written to the pending review queue of the cleaning rule tree.
[0043] Preferably, the present invention also includes a cost data collection and cleaning system for multi-business systems, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of the cost data collection and cleaning method for multi-business systems described above.
[0044] The technical effects and advantages provided by the present invention in the above technical solution are as follows:
[0045] A multi-business system interface cost event descriptor is constructed, assigning business domain identifiers, cost object identifiers, expense element identifiers, and time sequence identifiers. These identifiers are then linked together in the order of business domain, cost object, expense element, and time sequence to form a chain of event fingerprints, sorted by the business time field. Cost events carry structured chain identifiers before entering the aggregation routing. Even if the field names and dimensions of multi-business system interface messages differ significantly, the source of the cost event can still be distinguished by the business domain identifier and time sequence identifier. Cost objects and expense elements maintain their correspondence through independent identifiers. Compared to recording cost data only by batch or channel, the event fingerprint chain allows abnormal records during the aggregation process to be directly located to the specific interface event, without needing to review the original messages from multiple business systems. After the cost event is written to the cost aggregation database, a chain summary of the cost event descriptor is calculated based on the writing result and appended to the event fingerprint chain. A segment-by-segment verification relationship is established between the writing action and the event fingerprint chain. The link from interface extraction, temporary storage and cleaning to aggregation and writing of cost data can be traced segment by segment, and changes in the chain summary before and after writing reflect the consistency of the processing process.
[0046] By identifying the cost element identifier in the task description body, field mapping nodes and verification nodes are selected in the cleaning rule tree. The mapping tables corresponding to the field mapping nodes are then loaded to normalize the names and dimensions of the cost fields. Each field mapping node corresponds to a cost element identifier; different cost elements can load different field mapping tables. The conversion of cost field names and dimensions does not rely on a unified static mapping table across the entire business domain, avoiding incorrect field conversion due to differences in cost element types. After the normalized field enters the verification node, null value verification and cross-validation are performed according to the field dependency order. This field dependency order includes the sequential reference relationship between cost fields and cost object fields. The verification process is executed according to the actual dependency relationship of the cost elements, rather than using a fixed verification order. When cross-validation generates inconsistent records, an anomaly marker is directly written to the cost event description body corresponding to the inconsistent record, and the inconsistent record is written to the pending review queue in the cleaning rule tree. The granularity of the anomaly marker is refined from batch or channel to the specific cost event description body. Inconsistent records in the pending review queue can be jointly located with the event fingerprint chain, aggregation channel, and temporary storage partition address to pinpoint the source of the problem. When adding new cost elements or adjusting validation dependencies, the node-based cleaning rules only require adding or adjusting the corresponding field mapping nodes and validation nodes, without affecting the mapping and validation process of other cost elements. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0048] Figure 1 This is a flowchart of a cost data collection and cleaning method for multi-business systems;
[0049] Figure 2 This is a schematic diagram of the process for generating a task description body for cost data collection and cleaning. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0051] See Figure 1 This invention provides a method for cost data collection and cleaning for multi-business systems. It constructs a cost event descriptor for the interfaces of multiple business systems, assigning business domain identifiers, cost object identifiers, expense element identifiers, and time sequence identifiers to form an event fingerprint chain. Based on the business domain identifier and cost object identifier in the event fingerprint chain, a collection channel is determined in the collection routing table. The cost event descriptors are sequentially written to a temporary storage partition within the collection channel, generating a cleaning task descriptor. Based on the expense element identifier in the cleaning task descriptor, the field mapping node and verification node in the cleaning rule tree are invoked to perform field transformation and anomaly marking on the cost event descriptors in the temporary storage partition. The processed cost event descriptors are written to the cost collection library, updating the event fingerprint chain.
[0052] In practice, the event fingerprint chain consists of multiple links, each generated in the order of concatenating the business domain identifier, cost object identifier, expense element identifier, and time sequence identifier. When reading the business domain identifier and cost object identifier from the event fingerprint chain, the business domain identifier field and cost object identifier field are located in the current link of the event fingerprint chain. The value of the business domain identifier field is used as the business domain identifier, and the value of the cost object identifier field is used as the cost object identifier.
[0053] The first route segment corresponding to the service domain identifier and the second route segment corresponding to the cost object identifier are searched in the aggregated routing table. The aggregated routing table stores the first and second route segments using the service domain identifier and the cost object identifier as a composite index key. In some embodiments, the aggregated routing table adopts a hash table structure, where the service domain identifier is mapped to a first hash bucket using a first hash function, and the cost object identifier is mapped to a second hash bucket using a second hash function. The first route segment matching the service domain identifier is read from the first hash bucket, and the second route segment matching the cost object identifier is read from the second hash bucket.
[0054] When reading the service domain level code in the first routing segment and the cost object level code in the second routing segment, the first routing segment consists of the service domain level code and a routing segment extension field, while the second routing segment consists of the cost object level code and a routing segment extension field. The service domain level code occupies the first few bits of the first routing segment, and the cost object level code occupies the first few bits of the second routing segment.
[0055] Based on the hierarchical depth of the business domain hierarchical code and the cost object hierarchical code, the business domain hierarchical code is placed at the front of the aggregation channel, and the cost object hierarchical code is placed at the back of the aggregation channel. The hierarchical depth of the business domain hierarchical code is the number of levels in the business domain hierarchical code, and the hierarchical depth of the cost object hierarchical code is the number of levels in the cost object hierarchical code. In specific implementations, the hierarchical depth is determined by the number of separators in the code, or by a preset hierarchical bit depth table.
[0056] Write a channel separator between the beginning and end of the aggregation channel. The channel separator is the ASCII character "|", inserted between the end of the beginning of the aggregation channel and the beginning of the end of the aggregation channel.
[0057] Channel check bits are used to verify the beginning, end, and end of the aggregation channel. The channel check bits are calculated using the following formula:
[0058]
[0059] in, Indicates the channel check bit; This represents the decimal value corresponding to the business domain level code. Represents the decimal value corresponding to the cost object level code; The ASCII encoding value of the channel separator; This represents the first verification weight, with a value of 31; This represents the second verification weight, with a value of 17. This represents the third verification weight, with a value of 11; This represents the modulus, with a value of 256. This indicates the modulo operation. The method for obtaining it is to expand each level of the business domain hierarchical code bit by bit, convert it to decimal level by level, and then sum it up. The method for obtaining it is: expand each level of the cost object hierarchy code bit by bit, convert it to decimal level by level, and then sum it up; The method for obtaining the parity bit is as follows: take the ASCII code value 124 of the channel separator "|". The first parity weight, the second parity weight, and the third parity weight are set to three different prime numbers to reduce linear collisions between different level code combinations. The modulus 256 is used to limit the channel parity bit to one byte of storage space.
[0060] After obtaining the channel check bit, the collection channel front section, channel separator, collection channel back section, and channel check bit are combined in sequence to form the collection channel.
[0061] The aggregation channel and the timing identifier in the event fingerprint chain are written into the routing receipt, which is then returned to the cost event descriptor. The routing receipt contains an aggregation channel field and a timing identifier field; the aggregation channel field is written to the aggregation channel, and the timing identifier field is written to the timing identifier in the event fingerprint chain. After receiving the routing receipt, the cost event descriptor writes the aggregation channel and timing identifier from the routing receipt into the routing extension area of the cost event descriptor.
[0062] In specific implementation, please refer to Figure 2 The collection channel includes a channel sequence number field, which records the sequential number of the collection channel within the cost data collection system. When creating a temporary storage partition based on the channel sequence number in the collection channel, the channel sequence number field is read, and the corresponding decimal value is used as the temporary storage partition identifier. The temporary storage area is then divided into multiple temporary storage partitions, each with an independent partition address and capacity.
[0063] When reading the timing identifier from the cost event descriptor body, the timing identifier field is located in the event header of the cost event descriptor body. The timing identifier field is a fixed-length field with a fixed offset in the event header of the cost event descriptor body. A fixed-length sequence of bytes is read starting from the fixed offset, and the read byte sequence is converted into the timing identifier.
[0064] When a cost event descriptor is written to a timing slot in a temporary partition according to its timing identifier, the temporary partition is divided into multiple timing slots, each with a slot number and a slot capacity. A timing slot is used to store a single cost event descriptor or a fixed number of cost event descriptors. In some embodiments, the slot capacity of a timing slot is configured to be the maximum byte length of a single serialized cost event descriptor.
[0065] Calculate the time slot number based on the time sequence identifier, and write the cost event description body into the corresponding time slot. The time slot number is calculated using the following formula:
[0066]
[0067] in, Indicates the timing slot number; The decimal value representing the timing identifier read from the cost event description body; This represents the slot mapping coefficient, with a value of 37. This indicates the slot offset, with a value of 0. This represents the total number of timing slots in the temporary storage partition, which is obtained by dividing the capacity of the temporary storage partition by the capacity of a single timing slot and then rounding down. This indicates a modulo operation. The slot mapping coefficient 37 is obtained by selecting a prime number greater than the total number of timing slots in the temporary storage partition. This prime number is used as the slot mapping coefficient to distribute timing identifiers to different timing slots, reducing the probability of adjacent timing identifiers falling into the same timing slot. A slot offset of 0 indicates that the timing slot numbering starts from 0.
[0068] After writing the cost event descriptor to the timing slot, update the slot occupancy status. The slot occupancy status includes the slot number, slot capacity, used slot capacity, and number of writes. Generate a slot occupancy record based on the slot occupancy status. The slot occupancy record contains the temporary storage partition address, slot number, slot capacity, and timing identifier.
[0069] When generating the cleaning task descriptor based on the slot occupancy record, the temporary partition address, slot number, and slot capacity are read from the slot occupancy record. The temporary partition address is written to the partition pointer of the cleaning task descriptor, the slot number is written to the batch number of the cleaning task descriptor, and the slot capacity is written to the processing granularity of the cleaning task descriptor.
[0070] In some embodiments, the partition pointer is a reference to the temporary partition address in memory, the batch number is the decimal representation of the slot sequence number, and the processing granularity is the number of bytes corresponding to the slot capacity.
[0071] When reading the cost element identifier from the cost event description body, the cost element identifier field is located in the event header of the cost event description body. The cost element identifier field has a fixed offset and a fixed length. The content corresponding to the cost element identifier field is read and converted into a cost element identifier.
[0072] The cost element identifier, partition pointer, batch number, and processing granularity are assembled into a cleaning task description body according to the task template. The task template includes field order and field separators. The field order is cost element identifier, partition pointer, batch number, and processing granularity. The corresponding content is written field by field according to the field order in the task template, with field separators inserted between adjacent fields to form the cleaning task description body. The cleaning task description body carries the temporary partition address and cost element identifier. The temporary partition address is represented by the partition pointer, and the cost element identifier is the cost element identifier read from the cost event description body.
[0073] In practice, the cost element identifier is read from the cleaning task description body. The cleaning task description body consists of a partition pointer, batch number, processing granularity, and cost element identifier, which is located in a fixed field position within the cleaning task description body. The content of the cost element identifier field in the cleaning task description body is read and converted into a cost element identifier.
[0074] The cleaning rule tree uses the cost element identifier as the index key. Each node in the cleaning rule tree contains a node type, node rules, and pointers to child nodes. Node types include field mapping nodes and validation nodes. When searching in the cleaning rule tree using the cost element identifier as the index, starting from the root node, the cost element identifier is matched against the index key in the root node's child nodes. If a match is found, the search proceeds to the field mapping node, and then from the field mapping node, it proceeds to the validation node corresponding to the cost element identifier. The field mapping node corresponds to a mapping table that stores the mapping relationship between the original name and the standard name of the cost field, as well as the conversion relationship between the original and standard dimensions of the cost field, including the dimension conversion coefficient and dimension offset.
[0075] When loading the mapping table corresponding to the field mapping node into the temporary storage partition, the mapping table address is read from the field mapping node, and the mapping table data is loaded into the temporary storage partition based on the mapping table address. A mapping is established between the temporary storage partition and the mapping table data in memory, and subsequently, the cost fields in the cost event descriptor are normalized in name and dimension.
[0076] During the name normalization process, the expense field is extracted from the cost event description body. The original name of the expense field is then searched in the mapping table. When the original name of the expense field matches the original name in the mapping table, the matched standard name is used as the normalized expense field name, replacing the original name of the expense field in the cost event description body. The name-normalized expense field becomes part of the normalized field.
[0077] During the dimension normalization process, the original values of the expense field are read from the cost event description body and used as the original expense field values. The dimension conversion coefficients and dimension offsets corresponding to the original and standard dimensions are read from the mapping table. The expense field values in the normalized field are calculated using the following formula:
[0078]
[0079] in, This represents the cost field value in the normalized field; This represents the dimensional conversion factor, which is a positive real number. It is determined by the corresponding dimensional dictionary entry of the cost element in the cleaning rule tree. It is obtained by reading the conversion ratio between the original and standard dimensions in the dimensional dictionary. This represents the dimensional offset, which is a non-negative real number and is determined by the reference offset in the dimensional dictionary entry. It is 0 when the original dimension and the standard dimension have the same starting point. This indicates the original cost field value read from the cost event description body.
[0080] After obtaining the normalized field, it is input into the validation node. The validation node performs null value validation and cross-validation according to the field dependency order. The field dependency order is read from the cleaning rule tree. When reading the field dependency order corresponding to the validation node, the field dependency order field stored in the validation node is located. The field dependency order includes the sequential reference relationship between the cost field and the cost object field, that is, the cost field is referenced first, and the cost object field is referenced later.
[0081] During null value validation, the cost field value and cost object field value in the normalized field are checked for null values respectively. When the cost field value or the cost object field value is null, an exception flag is written to the cost event descriptor. The exception flag is written to the exception flag bit in the cost event descriptor. The initial value of the exception flag bit is 0, and the value of the exception flag bit is set to 1 when the exception flag is written.
[0082] During cross-validation, the cost field value and cost object field value are extracted from the normalized field according to the field dependency order, and then cross-validated between them. Cross-validation includes determining whether the cost field value and cost object field value satisfy the predefined association rules in the cleansing rule tree. These association rules are provided by the validation rule table under the field mapping node. When the cost field value and cost object field value do not satisfy the association rules, an inconsistent record is generated.
[0083] Inconsistent records contain the index position of the cost event descriptor, the cost field value, and the cost object field value. When cross-validation generates an inconsistent record, an exception flag is written to the corresponding cost event descriptor position, and the inconsistent record is written to the pending review queue of the cleaning rule tree. The pending review queue is a queue structure maintained by the validation nodes in the cleaning rule tree. The pending review queue stores the contents of inconsistent records for subsequent manual review or secondary cleaning.
[0084] In some embodiments, the exception flag is written as follows: based on the index position of the cost event descriptor in the inconsistent record, the corresponding cost event descriptor is located in the temporary storage partition, and an exception flag is written to the exception flag bit of the cost event descriptor. The exception flag types include null value exception flags and cross-validation exception flags, each corresponding to different values of the exception flag bit. The null value exception flag corresponds to a value of 1, and the cross-validation exception flag corresponds to a value of 2. When both null value exceptions and cross-validation exceptions exist simultaneously, the exception flag bit value is 3.
[0085] It is understandable that the exception flag occupies one byte of storage space in the cost event descriptor body and has a fixed offset in the event header of the cost event descriptor body.
[0086] In practice, the cost event descriptor body, after field transformation and anomaly marking, is extracted from the temporary storage partition. Based on the partition pointer and batch number in the cleaning task descriptor body, the corresponding time slot is located in the temporary storage partition. The partition pointer is a memory reference of the temporary storage partition address, and the batch number is the time slot sequence number. The cost event descriptor body data length field stored in the time slot is read. This field is located at a fixed offset in the event header, recording the total number of bytes in the cost event descriptor body from the start of the event header to the end of the event body. Based on the value of the cost event descriptor body data length field, the complete cost event descriptor body is extracted from the time slot. After extraction, the anomaly marker bit in the cost event descriptor body is checked. This marker bit is located at a fixed offset in the event header, with an initial value of 0. A value of 1 indicates a null value anomaly; a value of 2 indicates a cross-validation anomaly; and a value of 3 indicates both a null value anomaly and a cross-validation anomaly.
[0087] When reading the business domain identifier and cost object identifier from the cost event descriptor body, the business domain identifier field and cost object identifier field are located from the extracted event header of the cost event descriptor body. The offset and length of the business domain identifier field and the cost object identifier field in the event header are predefined. The content of the business domain identifier field is read and converted into a business domain identifier, and the content of the cost object identifier field is read and converted into a cost object identifier.
[0088] Locate the aggregation primary key corresponding to the business domain identifier and cost object identifier in the cost aggregation library. The cost aggregation library maintains an aggregation primary key index, which uses the business domain identifier and cost object identifier as a composite index key. In some embodiments, the aggregation primary key index adopts a B+ tree structure, with the composite value of the business domain identifier and cost object identifier as the key value of the B+ tree. Starting from the root node of the aggregation primary key index, compare the composite key of the business domain identifier and cost object identifier with the key value in the B+ tree node, and proceed downwards to the corresponding child node based on the comparison result until a leaf node is reached. The leaf node stores the data row address corresponding to the aggregation primary key; the aggregation primary key value corresponding to the data row address is read out to obtain the aggregation primary key.
[0089] The cost event descriptor is written to the cost aggregation database according to the aggregation primary key. The write row is located in the cost aggregation database's data table based on the aggregation primary key, where the primary key is defined as the aggregation primary key. The complete byte sequence of the cost event descriptor is written as the data column content to the corresponding row. The write operation uses a database transaction method; the write operation is executed after the transaction begins, and the transaction is committed upon successful write. The write result includes a write status code and a write position offset. The write status code indicates whether the write was successful, and the write position offset indicates the physical location of the cost event descriptor in the cost aggregation database data file.
[0090] Calculate the link digest of the cost event descriptor based on the write result. Serialize the write status code, write position offset, and the storage record of the cost event descriptor in the cost aggregation library to obtain a data snapshot after the cost event descriptor is written. Calculate the link digest using the following formula:
[0091]
[0092] in, This represents the chain segment digest, calculated using the SM3 hash algorithm to obtain a 256-bit digest value; This represents a binary sequence of data snapshots after the cost event descriptor is written. It is obtained by serializing the complete record after the cost event descriptor is written to the cost aggregation library. The serialization order is event header, cost field, and exception flag bit. The binary sequence representing the primary key is obtained by converting the integer value of the primary key into a big-endian binary representation. This represents the chain segment number, which can be a positive integer. It is obtained by reading the total number of current chain segments in the event fingerprint chain and then adding 1. express Hash algorithms; This indicates a binary concatenation operation, which will... , and The binary sequence is concatenated from beginning to end in order.
[0093] In some embodiments, the SM3 hash algorithm uses the hash function specified in the national standard GB / T32905-2016, with input being a binary sequence of arbitrary length and output being a 256-bit digest value.
[0094] The link digest is appended to the event fingerprint chain. The event fingerprint chain is a chain structure, where each link contains a previous link digest, a current link digest, and a link timestamp. The calculated link digest is used as the current link digest, and the link digest of the last link in the event fingerprint chain is read as the previous link digest. When the event fingerprint chain is empty, the previous link digest is set to all zeros. The link timestamp is taken as the current system time, and combined with the previous and current link digests to form a new link. This new link is then written to the end of the event fingerprint chain.
[0095] Optionally, the event fingerprint chain uses an append-only write mode, where new links can only be written to the end of the event fingerprint chain and existing links cannot be modified or deleted. Each link in the event fingerprint chain forms a sequential dependency through the digest of the previous link. After the link digest is appended, the length of the event fingerprint chain increases by 1.
[0096] In specific implementation, interface messages from multiple business system interfaces are obtained. These interfaces serve as data interaction interfaces between the cost data collection system and external business systems. Each interface message includes a header, body, and trailer. The header contains the system code, message type, message length, and timestamp. The body contains cost object fields, expense element fields, and business time fields. In some embodiments, the interface message uses JSON format, with fields in the body represented as key-value pairs. In other embodiments, the interface message uses a fixed-length field format, with each field in the body having a fixed offset and fixed length. Interface messages are obtained by subscribing to interface messages reported by business systems via a message queue or by receiving interface messages sent by business systems via an HTTP interface. After obtaining the interface message, it is cached in an interface message buffer.
[0097] The cost object field, expense element field, and business time field are extracted from the interface message. The interface message in the interface message buffer is first parsed, and the message length and message type are read from the header. The message type is used to determine the field layout in the message body. When the interface message is in JSON format, a JSON parser is used to read the message body and extract the cost object field, expense element field, and business time field according to preset field names. The cost object field identifies the object to which the cost belongs, the expense element field identifies the expense category, and the business time field records the time when the business occurred. When the interface message uses a fixed-length field format, the cost object field, expense element field, and business time field content are extracted from the message body according to the field offset and field length. The extracted cost object field, expense element field, and business time field are stored in separate memory variables.
[0098] The system code to which the interface message belongs is written into the business domain identifier. The system code to which the interface message belongs is defined in the message header. The content of the system code field is read from the message header; the system code field is a fixed-length field in the message header. The content of the system code field is directly written into the business domain identifier, which is an identifier field in the cost event description body, used to distinguish cost events generated by different business systems. The encoding rules for the business domain identifier are the same as those for the system code to which the interface message belongs, and the business domain identifier occupies a fixed length of storage space in the cost event description body.
[0099] Write the cost object field to the cost object identifier. Read the content of the cost object field from the extracted cost object field. The content of the cost object field can be the cost center code, project code, or product code. Write the content of the cost object field directly to the cost object identifier. The cost object identifier occupies a fixed amount of storage space in the cost event description body. Write the expense element field to the expense element identifier. Read the content of the expense element field from the extracted expense element field. The content of the expense element field is the classification code of the expense account. Write the content of the expense element field directly to the expense element identifier. The expense element identifier occupies a fixed amount of storage space in the cost event description body.
[0100] Convert the business time field into a time sequence identifier. First, parse the year, month, day, hour, minute, and second values from the business time field. The parsing method depends on the format of the business time field. When the business time field format is "YYYY-MM-DDHH:MM:SS", the year value is obtained from the 1st to 4th characters of the business time field, the month value from the 6th to 7th characters, the day value from the 9th to 10th characters, the hour value from the 12th to 13th characters, the minute value from the 15th to 16th characters, and the second value from the 18th to 19th characters. After obtaining the year, month, day, hour, minute, and second values, calculate the time sequence identifier using the following formula:
[0101]
[0102] in, The timing identifier is a non-negative integer. This represents the year value in the business time field, and the value range is a four-digit integer. It is obtained by parsing the business time field. This represents the month value in the business time field, ranging from 1 to 12, and is obtained by parsing the business time field. This represents the date value in the business time field, with a value range from 1 to 31, obtained by parsing the business time field. This represents the hour value in the business time field, ranging from 0 to 23, and is obtained by parsing the business time field. This represents the minute value in the business time field, ranging from 0 to 59, and is obtained by parsing the business time field. This represents the second value in the business time field, ranging from 0 to 59, obtained by parsing the business time field. In the formula, multiplier 12 combines the year and month into a month-based time measure, multiplier 31 incorporates dates within the month into a unified time scale, multiplier 24 converts hours into a day-based sequence, and multiplier 60 unifies minutes and seconds into a time scale with seconds as the lowest granularity.
[0103] In some embodiments, the business time field is formatted as a Unix timestamp, and the time sequence identifier is directly taken from the value of the business time field. In other embodiments, the business time field is formatted as a Beijing time string, and the parsing method is the same as that for the “YYYY-MM-DDHH:MM:SS” format.
[0104] Links are generated according to the concatenation order of the business domain identifier, cost object identifier, expense element identifier, and time sequence identifier. Each link is a fixed-length binary sequence, and its total length is the sum of the storage lengths of the business domain identifier, cost object identifier, expense element identifier, and time sequence identifier. During concatenation, the binary content of the business domain identifier is placed at the beginning of the link, followed by the binary content of the cost object identifier, then the binary content of the expense element identifier, and finally the binary content of the time sequence identifier. In some embodiments, the identifier fields and time sequence identifiers do not use separators within the link and are positioned based on their fixed storage lengths. The business domain identifier, cost object identifier, and expense element identifier are all encoded as fixed-length strings, while the time sequence identifier is encoded as an 8-byte unsigned integer.
[0105] The event fingerprint chain is formed by sorting the links according to the business time field. Sorting is based on comparing the business time field value of each link. The business time field value can be the original content of the business time field or the value of the time sequence identifier in the corresponding link. The links are sorted in ascending order according to the business time field value, with the link with the earliest business time at the beginning and the link with the latest business time at the end. After sorting, each link is sequentially written into the event fingerprint chain. The event fingerprint chain is a sequential storage structure, and each element in the event fingerprint chain is a link. Optionally, when multiple links have the same business time field value, they are sorted according to the lexicographical order of the business domain identifier, cost object identifier, and expense element identifier in the link. After the event fingerprint chain is formed, it is stored together with the event header and event body of the cost event description body as part of the cost event description body.
[0106] It is understandable that the business domain identifier, cost object identifier, expense element identifier, and time sequence identifier in the chain have been written into their respective fields before the chain is generated. The chain generation process and sorting process are both completed in memory, and the event fingerprint chain is written into the storage area of the cost event descriptor after it is formed.
[0107] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for cost data collection and cleaning for multi-business systems, characterized in that, include: Construct a cost event description body for multiple business system interfaces, and assign business domain identifiers, cost object identifiers, expense element identifiers, and time sequence identifiers to form an event fingerprint chain; Based on the business domain identifier and cost object identifier in the event fingerprint chain, determine the aggregation channel in the aggregation routing table; In the collection channel, the cost event descriptions are written sequentially to the temporary storage partition to generate the cleaning task description. Based on the cost element identifier in the cleaning task description body, the field mapping node and verification node in the cleaning rule tree are called to perform field conversion and anomaly marking on the cost event description body in the temporary storage partition. Write the processed cost event description into the cost aggregation library and update the event fingerprint chain.
2. The method for cost data collection and cleaning for multi-business systems according to claim 1, characterized in that, The step of determining the aggregation channel in the aggregation routing table based on the service domain identifier and cost object identifier in the event fingerprint chain is as follows: Read the business domain identifier and cost object identifier from the event fingerprint chain, and search for the first route segment corresponding to the business domain identifier and the second route segment corresponding to the cost object identifier in the aggregation routing table; The first route segment and the second route segment are concatenated in segment order to obtain the aggregation channel; Write the timing identifier in the aggregation channel and event fingerprint chain into the routing receipt, and return the routing receipt to the cost event description body.
3. The method for cost data collection and cleaning for multi-business systems according to claim 1, characterized in that, The step of sequentially writing cost event descriptions into a temporary storage partition in the aggregation channel to generate a cleaning task description is as follows: A temporary storage partition is created according to the channel number in the collection channel, and the timing identifier in the cost event description body is read. Write the cost event description body into the time slot of the temporary storage partition according to the time sequence identifier to obtain the slot occupancy record; A cleaning task description body is generated based on the slot occupancy record. The cleaning task description body carries the temporary storage partition address and cost element identifier.
4. The method for cost data collection and cleaning for multi-business systems according to claim 1, characterized in that, The step involves calling the field mapping node and verification node in the cleaning rule tree, based on the cost element identifier in the cleaning task description body, to perform field transformation and anomaly marking on the cost event description body in the temporary storage partition. Specifically: Using the cost element identifier in the cleaning task description body as an index, select field mapping nodes and verification nodes in the cleaning rule tree; Load the mapping table corresponding to the field mapping node into the temporary storage partition, and normalize the name and dimension of the cost field in the cost event description body to obtain the normalized field. Input the normalized field into the validation node. The validation node performs null value validation and cross-validation according to the field dependency order, and writes an exception flag in the cost event descriptor.
5. The method for cost data collection and cleaning for multi-business systems according to claim 1, characterized in that, The step of writing the processed cost event descriptor into the cost aggregation library and updating the event fingerprint chain specifically involves: Extract the cost event description body after field transformation and exception marking from the temporary storage partition, and read the business domain identifier and cost object identifier from the cost event description body; Locate the collection primary key corresponding to the business domain identifier and cost object identifier in the cost collection library, and write the cost event description body into the cost collection library according to the collection primary key. Calculate the chain summary of the cost event descriptor based on the write result, and append the chain summary to the event fingerprint chain.
6. The method for cost data collection and cleaning for multi-business systems according to claim 1, characterized in that, The construction of the multi-business system interface cost event descriptor involves assigning business domain identifiers, cost object identifiers, expense element identifiers, and time sequence identifiers to form an event fingerprint chain. Specifically: Obtain the interface messages of multiple business system interfaces, and extract the cost object field, expense element field, and business time field from the interface messages; Write the system code to which the interface message belongs to the business domain identifier, write the cost object field to the cost object identifier, write the expense element field to the expense element identifier, and convert the business time field to a time sequence identifier. The chain is generated by concatenating the business domain identifier, cost object identifier, expense element identifier, and time sequence identifier, and the chain is sorted by the business time field to form an event fingerprint chain.
7. The method for cost data collection and cleaning for multi-business systems according to claim 2, characterized in that, The step of concatenating the first routing segment and the second routing segment to obtain the aggregation channel is as follows: Read the service domain hierarchy code from the first routing segment and the cost object hierarchy code from the second routing segment; Based on the hierarchical depth of the business domain hierarchical code and the cost object hierarchical code, the business domain hierarchical code is set to the front end of the collection channel, and the cost object hierarchical code is set to the back end of the collection channel. A channel separator is written between the front and back of the aggregation channel, and a channel check bit is used to verify the front, the channel separator, and the back of the aggregation channel to obtain the aggregation channel.
8. A method for cost data collection and cleaning for multi-business systems according to claim 3, characterized in that, The process of generating a cleaning task description body based on the slot occupancy record is as follows: Read the temporary partition address, slot number, and slot capacity from the slot occupancy record; Write the temporary partition address to the partition pointer of the cleaning task description body, write the slot sequence number to the batch number of the cleaning task description body, and write the slot capacity to the processing granularity of the cleaning task description body. Read the cost element identifier from the cost event description body, and assemble the cost element identifier, partition pointer, batch number, and processing granularity into a cleaning task description body according to the task template.
9. A method for cost data collection and cleaning for multi-business systems according to claim 4, characterized in that, The process involves inputting the normalized field into the validation node, which then performs null value validation and cross-validation according to the field dependency order, and writes an exception flag in the cost event descriptor. Specifically: Read the field dependency order corresponding to the verification node from the cleaning rule tree. The field dependency order includes the sequential reference relationship between the cost field and the cost object field. Extract the cost field value and cost object field value from the normalized field according to the field dependency order, and perform cross-validation on the cost field value and cost object field value; When cross-validation generates an inconsistent record, an exception flag is written to the cost event descriptor corresponding to the inconsistent record, and the inconsistent record is written to the pending review queue of the cleaning rule tree.
10. A cost data collection and cleaning system for multi-service systems, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the cost data collection and cleaning method for multi-service systems as described in any one of claims 1 to 9.
