A method, device, and medium for dynamic reconstruction of hierarchical codes in cost accounting BOM.
By dynamically reconstructing the hierarchical code, the circular nodes and paths in the cost calculation BOM are identified and adjusted, which solves the cost calculation errors caused by circular references and repeated accesses, and achieves more efficient and accurate cost accounting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INSPUR GENERSOFT CO LTD
- Filing Date
- 2026-04-21
- Publication Date
- 2026-06-02
Smart Images

Figure CN122134052A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of production cost management and cost accounting, and specifically relates to a method, equipment and medium for dynamic reconstruction of hierarchical codes of cost calculation BOM. Background Technology
[0002] In the field of manufacturing cost accounting, the Bill of Materials (BOM) structure is the fundamental data carrier for cost convolution calculation. Cost convolution calculation involves aggregating material costs, labor costs, and manufacturing overhead layer by layer along the BOM hierarchy from bottom to top, ultimately forming the complete product cost. The hierarchical codes of the BOM nodes define the calculation path for cost aggregation, and the numerical relationships of the hierarchical codes directly affect the calculation order and accuracy of the cost convolution results.
[0003] In the cost calculation of the Bill of Materials (BOM), the selection of hierarchical code adjustment strategies is independent of the quality status of the BOM data itself. When anomalies such as circular references or duplicate node accesses exist in the BOM structure, optimization strategies such as hierarchical merging will modify the hierarchical codes of the abnormal areas. These modifications often propagate existing circular relationships to a wider range, causing the cost convolution calculation to fail to complete the aggregation due to incorrect topological order. Some systems directly interrupt the calculation process after detecting circular nodes, requiring manual data cleanup before re-execution, thus disrupting the automated calculation chain.
[0004] Furthermore, in cost calculation Bill of Materials (BOMs), the same material may appear at different levels in the BOM tree due to being referenced by multiple upper-level components. Existing technologies typically determine the level code based on the material's physical depth within the tree structure during level code allocation, resulting in the same material obtaining different level code values on different paths. When cost convolution calculations aggregate the level codes layer by layer in ascending order, the same material is repeatedly calculated at multiple levels, leading to inflated costs. Summary of the Invention
[0005] This invention provides a method for dynamic reconstruction of the hierarchical code of a cost bill of materials (BOM). The method uses strategy-driven dynamic reconstruction to compress the depth of the BOM hierarchy, shorten the cost convolution calculation path, and improve the efficiency of large-scale cost accounting while ensuring the accuracy of the calculation.
[0006] Includes the following steps: S1. Based on the product objects to be calculated and their material requisition relationships, construct the BOM header information, generate the BOM body information, identify and mark the main product node, the associated sub-product node, the object group node, and the object group associated material node, and complete the construction of the cost calculation BOM structure. S2. Based on the constructed cost calculation BOM structure, and to fully reflect the hierarchical relationship of the material composition, starting from each untraversed root node, an initial level code is assigned to each BOM node in a hierarchical progressive manner. S3. When the same BOM node is detected to be accessed repeatedly, the BOM node is marked as a circular material node and the product node access path is recorded; when the same product node is detected to be accessed repeatedly, the product node is marked as a circular node of the cost convolution calculation path. S4. Obtain the cost convolution calculation requirement parameters and the marked cost convolution calculation path loop node information, and determine the hierarchical code adjustment strategy based on the cost convolution calculation requirement parameters and loop node information. S5. Based on the determined hierarchical code adjustment strategy, the initial hierarchical code is reconstructed. When the hierarchical code adjustment strategy is the cost convolution calculation path optimization strategy based on material code consistency, the set of nodes with the same material code in the constructed BOM is identified, the hierarchical codes of all nodes in the node set are uniformly reconstructed to the maximum hierarchical code in the set, and the hierarchical codes of its child nodes are recursively updated to achieve the optimization of redundant levels. When the hierarchical code adjustment strategy is to optimize the cost convolution calculation path based on the combination of cost center and material code, the set of nodes with the same cost center and the same material code is identified, the hierarchical codes of all nodes in the set are uniformly reconstructed to the maximum hierarchical code in the set, and the hierarchical codes of its child nodes are recursively updated.
[0007] According to another embodiment of this application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the hierarchical code dynamic reconstruction method for calculating the cost BOM.
[0008] According to another embodiment of this application, a storage medium is also provided, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of a method for dynamic reconstruction of the hierarchical code of a cost calculation BOM are implemented.
[0009] As can be seen from the above technical solutions, the present invention has the following advantages: The method for dynamically reconstructing the hierarchical code of a cost calculation BOM provided by this invention embeds cost center, batch, and order information into the BOM header structure, binding the hierarchical code system to the cost accounting dimension from the initial construction stage. Employing a linear mapping rule between root node distance and hierarchical code, the initial hierarchical code allocation directly reflects the physical depth of the material's tree structure, providing a traceable benchmark for adjustments. During hierarchical allocation, node access paths are recorded synchronously, and cyclic material nodes and path cycle nodes are marked, isolating data anomalies in the BOM structure in advance and preventing abnormal nodes from interfering with the hierarchical calculation of normal nodes during subsequent reconstruction.
[0010] This invention uses loop node information as a pre-constraint for strategy selection, enabling the strategy determination process to dynamically adjust the selection range based on BOM data quality. In scenarios with loop nodes, it forcibly switches to a conservative strategy that maintains the initial level; in scenarios with normal data quality, it opens up the selection space for optimized strategies. This invention links strategy selection with data quality status, eliminating the need for additional assessment of the impact of abnormal data on strategy execution. It effectively avoids computational deadlocks caused by loop nodes, ensuring a high degree of match between strategy selection and computational needs, and reducing strategy determination bias.
[0011] This invention also designs a hierarchical unification method for material coding dimension and cost center plus material coding dimension for different strategies. During the reconstruction process, the same material nodes scattered in various parts of the BOM tree are flattened to the same depth through maximum level code alignment and recursive update of child nodes, eliminating the repeated aggregation path of the same material during cost convolution due to different nesting depths. Attached Figure Description
[0012] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 Flowchart of the method for dynamic reconstruction of hierarchical codes in cost calculation BOM; Figure 2 A flowchart illustrating an embodiment of a method for dynamically reconstructing the hierarchical code of a cost calculation BOM; Figure 3 This is a schematic diagram of an electronic device. Detailed Implementation
[0014] The following describes in detail the hierarchical code dynamic reconstruction method for cost calculation BOM involved in this application. Specific details such as particular system structures and technologies are presented for illustrative purposes rather than limiting, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application can also be implemented in other embodiments without these specific details.
[0015] Please see Figure 1 and Figure 2 The diagram shows a flowchart of a method for dynamically reconstructing the hierarchical code of a cost BOM in a specific embodiment. The method includes: S1. Based on the product objects to be calculated and their material requisition relationships, construct the BOM header information containing cost center, product, batch, and order information, generate BOM body information based on product structure, identify and mark the main product node, related sub-product node, object group node, and object group associated material node, and complete the construction of the cost calculation BOM structure.
[0016] In some embodiments, the scope of the product objects to be calculated is determined. By retrieving material requisition records and production order data from the enterprise's ERP system, the requisition dependencies between products and materials are sorted out, and the requisition quantity, requisition time, and corresponding production process of each material are clarified.
[0017] Furthermore, when constructing the BOM header information, cost center codes, product unique identifiers, production batch numbers, and order numbers are integrated to ensure that the header information covers the basic dimensions required for cost accounting, and that each information item is consistent with the company's existing coding system.
[0018] Furthermore, when generating BOM information, the product structure is the main focus. The root node corresponds to the final product, the intermediate nodes correspond to the semi-finished products, and the terminal nodes correspond to the components. The material information, specifications, units of measurement, and parent node relationships of each node are entered one by one to form a tree-shaped BOM structure.
[0019] S2. Based on the cost calculation BOM structure constructed in S1, and based on fully reflecting the hierarchical relationship of material composition, starting from each untraversed root node, an initial level code is assigned to each BOM node in a hierarchical progressive manner. The initial level code of the parent node is determined based on its distance from the root node in the BOM structure, and the initial level code of the child node is generated incrementally based on the level code of the parent node, until all BOM nodes have completed the initial level code assignment.
[0020] In some embodiments, based on the tree-shaped BOM structure constructed by S1, all untraversed root nodes, i.e. nodes without parent nodes, are first selected as final product nodes, and hierarchical code allocation is carried out sequentially according to the number of root nodes.
[0021] Furthermore, the initial level code of a parent node is determined based on its distance from the root node in the BOM structure. The root node itself has a root node distance of 0 and an initial level code of 1. Child nodes directly associated with the root node are considered first-level child nodes. Their root node distance is 1 and their initial level code is 2. Second-level child nodes have a root node distance of 2 and an initial level code of 3, and so on. For every increase of 1 in the root node distance, the initial level code increases by 1.
[0022] Furthermore, during the allocation process, a traversal algorithm is used to proceed level by level. First, the allocation of the level codes of all child nodes corresponding to a root node is completed, and then the process switches to the next untraversed root node. For nodes with branches, the child nodes of each branch are generated incrementally based on the level code of their parent node to ensure that the level codes of all child nodes corresponding to the same parent node are consistent.
[0023] Furthermore, after the allocation is completed, an initial hierarchical code allocation list is generated, specifying each node ID, material code, parent node ID, initial hierarchical code, and root node distance. The correspondence between the hierarchical code of each node and the root node distance is checked. If there is a mismatch between the hierarchical code and the root node distance, the allocation is readjusted until all BOM nodes have completed the initial hierarchical code allocation and the hierarchical code allocation is accurate.
[0024] The initial hierarchical identifier is assigned to each BOM node. The node's hierarchical position within the BOM structure is quantified by its distance from the root node, ensuring that the hierarchical code accurately reflects the material composition hierarchy of the node. A traversal algorithm enables full coverage assignment to all nodes. The hierarchical codes of child nodes corresponding to the same parent node are uniformly incremented, ensuring consistent hierarchical relationships. A post-assignment verification process promptly corrects assignment errors, ensuring the accuracy of the initial hierarchical code.
[0025] S3. During the initial hierarchical code allocation process in S2, record the BOM node access path. When the same BOM node is detected to be accessed repeatedly, mark the BOM node as a circular material node and record the product node access path. When the same product node is detected to be accessed repeatedly, mark the product node as a circular node of the cost convolution calculation path.
[0026] In some embodiments, during the synchronization process of S2 initial hierarchical code allocation, the node access path recording module is started to record the access order, access time and parent node access trajectory of each BOM node in real time, forming a node access path log. The log contains node ID, access sequence number, parent node access sequence and access timestamp.
[0027] Furthermore, for BOM nodes, by comparing the node access path logs, if the same node ID is detected to appear in different access sequences and its parent node access sequence is different, it is determined that the BOM node is accessed repeatedly, and it is marked as a circular material node. The number of times the node is accessed repeatedly and the path trajectory of each access are also recorded.
[0028] Furthermore, for product nodes, namely primary product and associated secondary product nodes, the access path of each product node is recorded separately, with a focus on tracking the access frequency. If the same product node ID is detected to appear two or more times in the access path log, and the hierarchical positions of the two visits are different, it is determined that the product node has been accessed repeatedly and is marked as a cycle node in the cost convolution calculation path. The repeated access time and hierarchical position change of this node are recorded. After marking, a cycle node marking list is generated, which clearly defines the ID, marking type, and repeated access information of cycle material nodes and cycle nodes in the cost convolution calculation path. The marking information is also associated with the database and bound to information such as the node's hierarchical code and material code for easy retrieval.
[0029] S4. Obtain the cost convolution calculation requirement parameters and the cost convolution calculation path loop node information marked in S3. Determine the hierarchical code adjustment strategy based on the cost convolution calculation requirement parameters and loop node information.
[0030] Specifically, when there is a product node that is marked as a cycle node in the cost convolution calculation path, the hierarchical code adjustment strategy is forcibly determined to maintain the initial hierarchy in order to preserve the original cost convolution calculation path strategy.
[0031] When there are no product nodes marked as cycle nodes of the cost convolution calculation path, the hierarchy code adjustment strategy is selected from the preset strategy set. The preset strategy set includes maintaining the initial hierarchy to maintain the original cost convolution calculation path strategy, optimizing the cost convolution calculation path based on material code consistency strategy, and optimizing the cost convolution calculation path based on the combination of cost center and material code strategy.
[0032] In some embodiments, the cost convolution calculation requirements parameters mainly include parameters such as cost accounting accuracy threshold, computational efficiency threshold, and cost allocation weight. Then, the S3-marked cost convolution calculation path loop node information is retrieved from the database, and the number of loop nodes, node IDs, and marking information are checked to confirm the validity of the loop nodes.
[0033] Furthermore, an alternative approach is to determine the hierarchical code adjustment strategy based on the above two types of information: if, after verification, there is at least one cost convolution calculation path loop node, the hierarchical code adjustment strategy is determined to maintain the initial level to preserve the original cost convolution calculation path strategy, ensuring that the original calculation path is not destroyed.
[0034] If no loop node exists in the cost convolution calculation path, select a suitable strategy from the preset strategy set. The selection should consider the cost convolution calculation requirements. If high cost accounting accuracy is required but low computational efficiency is required, prioritize the strategy that optimizes the cost convolution calculation path based on the combination of cost centers and material codes. If moderate cost accounting accuracy is required but high computational efficiency is required, prioritize the strategy that optimizes the cost convolution calculation path based on material code consistency.
[0035] If there are no special requirements for accuracy and efficiency, the strategy of maintaining the initial level to preserve the original cost convolution calculation path is selected. After the strategy is determined, a strategy determination report is generated, specifying the strategy type, selection criteria, loop node information, and required parameters. This approach combines accuracy and efficiency requirements to achieve targeted optimization of the cost convolution calculation path, meeting different computational needs. The generated strategy determination report clarifies the basis for strategy selection, facilitating subsequent traceability and verification. A preset strategy set provides multiple options, enhancing strategy flexibility and adapting to different cost accounting scenarios.
[0036] S5. Based on the hierarchical code adjustment strategy determined in S4, the initial hierarchical code allocated in S2 is dynamically reconstructed. When the hierarchical code adjustment strategy is a cost convolution calculation path optimization strategy based on material code consistency, the set of nodes with the same material code in the BOM constructed in S1 is identified, the hierarchical codes of all nodes in the set are uniformly reconstructed to the maximum hierarchical code in the set, and the hierarchical codes of its child nodes are recursively updated to compress redundant levels in the cost convolution calculation path.
[0037] When the hierarchical code adjustment strategy is to optimize the cost convolution calculation path based on the combination of cost center and material code, the set of nodes with the same cost center and the same material code is identified, the hierarchical code of all nodes in the set is uniformly reconstructed to the maximum hierarchical code in the set, and the hierarchical code of its child nodes is recursively updated. Among them, product nodes that are marked by S3 as cost convolution calculation path loop nodes are filtered out.
[0038] In some embodiments, the initial hierarchical code is reconstructed in a targeted manner according to a determined adjustment strategy to optimize the cost convolution calculation path. Different strategies correspond to different reconstruction logics, and maintaining the initial hierarchical strategy ensures the stability of the calculation path in cyclic node scenarios. Based on the material coding consistency strategy, clustering is used to identify identical coding nodes, unifying the hierarchical code and compressing redundancy. A cost center dimension is added based on a two-dimensional strategy to improve the targeting of the reconstruction. The verification process ensures the accuracy of the reconstruction results, and the recursive update of child nodes ensures the continuity of hierarchical relationships, providing a reliable hierarchical code system for adjustment.
[0039] S6. Identify the associated sub-product nodes marked in S1, find the corresponding main product BOM list for the associated sub-product node, and based on the hierarchical code system reconstructed in S5, adjust the hierarchical code of the associated sub-product node to the minimum hierarchical code in the main product BOM list, so that the associated sub-product maintains the same level parallel relationship with the main product in the cost convolution calculation path, and avoids repeated aggregation or hierarchical misalignment in the cost convolution calculation.
[0040] In some embodiments, the associated product nodes are accurately identified by node markers, and the corresponding main product is matched based on the association identifier. The minimum level code of the main product is extracted as the adjustment target to ensure that the associated products and the main product maintain a parallel relationship at the same level. Recursive updates of child nodes ensure the continuity of the hierarchical relationship between the associated product nodes and their child nodes, and the verification process ensures the accuracy of the adjustment results, guaranteeing the accurate cost aggregation of associated products in the cost convolution calculation.
[0041] Optionally, step S7 follows S6. Step S7 identifies the object group associated material nodes marked in S1, locates the corresponding object group BOM for these nodes, and, based on the hierarchical code system reconstructed in S5, aligns and adjusts the hierarchical codes of the object group associated material nodes to match the hierarchical codes of the corresponding object group BOM. This ensures that the associated materials in the object group maintain a consistent hierarchical level with their respective object group in the cost convolution calculation path, guaranteeing consistency between process configuration and cost accounting in cost convolution calculation. The hierarchical codes, target values, and child node updates before and after adjustment are determined, completing the entire dynamic reconstruction process of the BOM hierarchical codes. Identifying object group associated material nodes through markers ensures that associated materials maintain a consistent hierarchical level with their respective object groups, guaranteeing consistency between process configuration and cost accounting in cost convolution calculation.
[0042] In some specific embodiments, the determination of the hierarchical code adjustment strategy in S4 further includes the following steps: S411. Obtain the information of the cycle nodes in the cost convolution calculation path marked in S3, and extract the node identifier, parent node identifier sequence, number of direct child nodes, and number of indirect child nodes for each cycle node; extract the complete parent node link sequence from each cycle node to the root node from the cost calculation BOM structure constructed in S1, and count the total number of nodes in the link sequence as the link node count; traverse all downstream branches of each cycle node and count the number of direct child nodes and indirect child nodes; obtain the calculation depth threshold and path breadth threshold in the cost convolution calculation requirement parameters.
[0043] In some embodiments, the cost convolution calculation path loop node set output by step S3 is received, and each element of the set contains a unique identifier of the product node marked as a loop node.
[0044] Furthermore, for each loop node in the set, the following data acquisition operations are performed: from the relational data table of the cost calculation BOM structure constructed in S1, query the parent node identifier field of the loop node, recursively query until the parent node identifier is null, and form a parent node identifier sequence by arranging all the parent node identifiers obtained in the query process in the query order; count the number of elements in the parent node identifier sequence to obtain the link node count.
[0045] From the relational data table of the cost calculation BOM structure constructed in S1, query the child node identifier field of the circular node to distinguish between direct child nodes and indirect child nodes.
[0046] Furthermore, direct child nodes are the direct subordinate nodes of the cycle node, and indirect child nodes are the subordinate nodes of the direct child nodes and nodes at deeper levels.
[0047] Count the number of direct child nodes and the number of indirect child nodes separately. Read the cost convolution calculation requirement parameters from the external system interface, parse the parameter structure, and extract the calculation depth threshold field value and the path breadth threshold field value.
[0048] The node identifier, parent node identifier sequence, link node count, number of direct child nodes, number of indirect child nodes, calculation depth threshold, and path breadth threshold collected above are defined as cyclic node link feature data records.
[0049] S412. Compare the link node count obtained in S411 with the calculation depth threshold, and compare the number of direct child nodes with the path breadth threshold.
[0050] When the number of link nodes is greater than or equal to the calculation depth threshold, and the number of direct child nodes is greater than or equal to the path breadth threshold, the loop node is identified as a critical path loop node.
[0051] When the number of link nodes is less than the calculation depth threshold, or the number of direct child nodes is less than the path breadth threshold, the loop node is determined to be a non-critical path loop node.
[0052] Nodes identified as critical path cycle nodes are marked as critical path nodes, and nodes identified as non-critical path cycle nodes are marked as non-critical path nodes.
[0053] S413. When S412 determines that there is a loop node with a critical path marker, the hierarchical code adjustment strategy is determined to be the strategy of maintaining the initial hierarchical level.
[0054] From the initial hierarchical code data obtained from S2, the initial hierarchical codes of all nodes on the link sequence of the cyclic node with critical path marker and its parent node are extracted to form the hierarchical code locking dataset.
[0055] Mark the hierarchical code locked dataset as immutable, preventing subsequent steps from performing hierarchical code reconstruction operations on the nodes in this dataset.
[0056] S414. When all the loop nodes determined in S412 have non-critical path markers, the hierarchical code adjustment strategy is determined to be the branch isolation strategy.
[0057] Traverse the cost calculation BOM structure constructed by S1, identify branch paths containing loop nodes with non-critical path markers, and mark the branch path as an isolated and maintained branch.
[0058] Branch paths in the BOM structure that do not contain any circular nodes are marked as open optimization branches; initial hierarchical code preservation operations are performed on isolated preservation branches, and hierarchical code reconstruction operations based on material code consistency are performed on open optimization branches.
[0059] In some embodiments, the data record set output by step S412 is detected: if all records in the set have non-critical path marker fields, the branch isolation strategy execution process is triggered.
[0060] If the collection contains records with a critical path marker field, skip this step.
[0061] In the branch isolation strategy execution process, the level code adjustment strategy is determined to be the branch isolation strategy, and the identifier of the branch isolation strategy is written into the strategy type field of the strategy determination record.
[0062] From the cost calculation BOM structure constructed in step S1, extract all root node identifiers, perform branch traversal for each root node, traverse downwards along the child node links of the root node, and check whether there are loop nodes with non-critical path markers on the traversal path.
[0063] Furthermore, if there are loop nodes with non-critical path markers on the traversal path, then the traversal path is marked as an isolated branch, and the root node identifier of the branch and the identifiers of all nodes on the branch path are recorded.
[0064] Furthermore, if there are no loop nodes on the traversal path, the traversal path is marked as an open optimization branch, and the root node identifier of the branch and the identifiers of all nodes on the branch path are recorded.
[0065] For each branch marked as an isolation-preserving branch, extract the initial hierarchical code of all nodes on that branch from the initial hierarchical code dataset output in step S2, keep the initial hierarchical code unchanged, and do not perform any hierarchical code reconstruction operation on that branch. Preserving the initial hierarchical code of an isolation-preserving branch essentially limits the influence range of non-critical path loop nodes, thus stabilizing the hierarchical structure of the branch.
[0066] Furthermore, for each branch marked as an open optimization branch, the set of nodes with the same material code within that branch is identified. The initial hierarchical codes of each node in this set are extracted from the initial hierarchical code dataset output from step S2. The maximum initial hierarchical code value is determined, and the hierarchical codes of all nodes in this set are uniformly updated to this maximum initial hierarchical code value. The hierarchical codes of the child nodes of each node in this set are then recursively updated. The material code consistency reconstruction of open optimization branches essentially compresses redundant hierarchies within branches without cycle risk, reducing the number of cost calculation iterations.
[0067] In some specific embodiments, the following steps are included after step S4: S421. Obtain the hierarchical code adjustment strategy and parse the strategy type code corresponding to the strategy identifier; obtain the cost convolution calculation path loop node information marked by S3, and extract the node identifier, parent node identifier sequence, and child node identifier set of each loop node.
[0068] Extract the current level code value of each loop node, its parent node, and its child nodes from the initial level code dataset obtained from S2. Obtain the material code field value and cost center field value of each node in the cost calculation BOM structure constructed in S1.
[0069] S422. Based on the strategy type code collected in S421, when the strategy type code corresponds to the strategy of optimizing the cost convolution calculation path based on material code consistency, identify the set of nodes with the same material code in the BOM constructed in S1, traverse each pair of nodes in the set of nodes, and detect whether the nearest common parent node of the pair of nodes is one of the cyclic nodes extracted in S421, or whether the connection path of the pair of nodes passes through one of the cyclic nodes extracted in S421.
[0070] When the strategy type code corresponds to the cost convolution calculation path optimization strategy based on the combination of cost center and material code, identify the set of nodes with the same cost center and the same material code, traverse each pair of nodes in the node set, and check whether there is an intersection between the hierarchical code reconstruction operation area of the node and the child node identifier set of the cyclic node extracted by S421; when any of the above conditions are detected, generate a conflict risk mark record.
[0071] It should be noted that the conflict determination rule base contains two independent rule chains: rule chain A corresponds to the cost convolution calculation path optimization strategy based on material code consistency, and rule chain B corresponds to the cost convolution calculation path optimization strategy based on the combination of cost center and material code.
[0072] When the rule chain being invoked is rule chain A, the following decision operation is performed: Read all material code field values from the node attribute storage slot, group and count the node identifier sets with the same material code, perform pairwise combination traversal for each node identifier set with the same material code, and for each pair of node identifiers, query the nearest common parent node identifier of the pair of nodes from the circular node information storage slot, check whether the nearest common parent node identifier exists in the node identifier field of the circular node information storage slot, or check whether there is an intersection between the connection path node identifier sequence of the pair of nodes and the node identifier field of the circular node information storage slot. When either detection result is yes, generate a conflict risk mark record containing the pair of node identifiers, conflict type code, and conflict associated circular node identifier.
[0073] When the rule chain being invoked is rule chain B, the following decision operation is performed: Read all cost center field values and material code field values from the node attribute storage slot. Group and statistically analyze the node identifier sets with the same cost center and the same material code. Perform pairwise combination traversal on each node identifier set. For each pair of node identifiers, read the current level code value of the pair of nodes from the level code value storage slot. Calculate the level code reconstruction operation area as the range from the smaller level code value to the larger level code value. Read the child node identifier sets of each cycle node from the cycle node information storage slot. Check if there is an intersection between the node identifier range corresponding to the level code reconstruction operation area and the child node identifier set. If the detection result is yes, generate a conflict risk mark record containing the pair of node identifiers, conflict type code, and conflict-related cycle node identifiers. Write all conflict risk mark records into the conflict risk mark record set.
[0074] S423. Count the number of conflict risk marker records generated in S422. When the number of conflict risk marker records is greater than zero, force the hierarchical code adjustment strategy to maintain the initial hierarchical strategy and generate a strategy downgrade execution record.
[0075] When the number of conflict risk marker records is zero, the hierarchical code adjustment strategy determined by S4 remains unchanged, and a strategy maintenance execution record is generated; the changed hierarchical code adjustment strategy or the maintained hierarchical code adjustment strategy is bound to the strategy downgrade execution record or the strategy maintenance execution record.
[0076] S424. Receive the hierarchical code adjustment strategy and associated execution records. When the hierarchical code adjustment strategy is to maintain the initial hierarchical strategy, extract the initial hierarchical codes of all nodes from the obtained initial hierarchical code dataset and mark them as the final execution hierarchical code dataset.
[0077] When the hierarchical code adjustment strategy is a cost convolution calculation path optimization strategy based on material code consistency or a cost convolution calculation path optimization strategy based on cost center and material code combination, the node set without conflict risk is extracted from the traversal detection results of S422, the node set is marked as the node set that can be reconstructed, the cyclic node extracted in S421 and its parent node and child node are marked as the node set that cannot be reconstructed, and the boundary data of the division between the node set that can be reconstructed and the node set that cannot be reconstructed is written into the strategy execution range boundary record.
[0078] In some embodiments, the policy identifier and associated execution record output in step S423 are received, and the current execution record is identified as a policy downgrade execution record or a policy maintenance execution record from the record type field of the execution record.
[0079] Furthermore, when a policy downgrade execution record is identified, the value of the changed policy identifier field in the record is read. This field value indicates that the initial hierarchical policy is maintained, and at this time, the final execution hierarchical code dataset is established.
[0080] Furthermore, from the initial hierarchical code dataset obtained in step S2, the mapping relationship between the node identifiers of all nodes and the initial hierarchical code values is extracted. This mapping relationship is copied and written into the final execution hierarchical code dataset as is. A policy source marker field is added to each mapping relationship entry. The field value indicates that it comes from the policy downgrade operation in step S423. The final execution hierarchical code dataset is output to the alternative input interface of step S5, skipping the dynamic reconstruction operation in step S5.
[0081] Furthermore, when a strategy maintenance execution record is identified, the maintenance strategy identifier field value in the record is read, and the strategy type code subfield of the field value is parsed. When the strategy type code corresponds to the cost convolution calculation path optimization strategy based on material code consistency or the cost convolution calculation path optimization strategy based on cost center and material code combination, a division method for the set of nodes that can be reconstructed and the set of nodes that cannot be reconstructed is established.
[0082] Extract all node identifiers with no conflict risk from the traversal detection results in step S422, and write these node identifiers into the set of nodes that can be reconstructed. Extract all cyclic node identifiers from the cyclic node information in step S421, as well as all parent node identifiers in the parent node identifier sequence and all child node identifiers in the child node identifier set. Merge and deduplicate these identifiers, and write them into the set of nodes that cannot be reconstructed.
[0083] Establish a policy execution scope boundary record, which includes references to the set of nodes allowed to be reconstructed, references to the set of nodes prohibited from being reconstructed, the result of the intersection operation of the two sets, and the boundary division timestamp. Bind the policy execution scope boundary record to the maintenance policy identifier and output it to the constraint input interface of step S5, instructing the dynamic reconstruction operation of step S5 to be executed only within the set of nodes allowed to be reconstructed.
[0084] It can be seen that the final execution level code dataset generation process triggered by the policy degradation execution record is essentially constructing a bypass data channel for step S5, thus shielding the reconstruction logic of step S5 and directly outputting the initial level code as the final result. This bypass processing method ensures that the forced activation of the degradation policy is not interfered with by the original logic of step S5. The set partitioning process triggered by the policy maintenance execution record adds constraints to the input data of step S5. The set of allowed reconstruction nodes defines the permitted scope of reconstruction operations, and the set of prohibited reconstruction nodes defines the excluded scope of reconstruction operations. The intersection operation of the two sets is used to check the correctness of the partitioning logic. An empty intersection indicates that the partitioning has no overlap.
[0085] In some specific embodiments, based on step S5, according to the hierarchical code adjustment strategy determined in S4, the initial hierarchical code allocated in S2 is dynamically reconstructed. When the hierarchical code adjustment strategy is a cost convolution calculation path optimization strategy based on material code consistency, the set of nodes with the same material code in the BOM constructed in S1 is identified, the hierarchical codes of all nodes in the set are uniformly reconstructed to the maximum hierarchical code in the set, and the hierarchical codes of their child nodes are recursively updated to compress redundant levels in the cost convolution calculation path. Specifically, this includes the following steps: S511. From the cost calculation BOM structure constructed in S1, read the material code field values of all nodes and establish a mapping dictionary from material codes to node identifier lists; for each material code, treat its corresponding node identifier list as a set of nodes with the same material code; extract the initial level code values corresponding to each node identifier in the node set from the initial level code data to form a level code value list; calculate the difference between the maximum and minimum values in the level code value list to obtain the level code dispersion index; define the material code, node identifier list, level code value list, and level code dispersion index as node set records.
[0086] S512. Based on the node set record, read the level code dispersion index; establish a reconstruction judgment threshold; when the level code dispersion index is greater than the reconstruction judgment threshold, extract the maximum value from the level code value list as the reconstruction target level code. When the hierarchical code dispersion index is not greater than the reconstruction judgment threshold, skip the subsequent reconstruction operation of the node set; For the set of nodes that determine the target hierarchical code for reconstruction, traverse each node identifier in the node identifier list and query the set of child node identifiers of the node identifier from the relational data table of the constructed cost calculation BOM structure; mark the union of the node identifier list and all child node identifier sets as the node set of the reconstruction operation scope; write the mapping relationship between the target hierarchical code for reconstruction, the node set of the reconstruction operation scope, and the original hierarchical code value list into the reconstruction task record.
[0087] S513: Receive the reconstruction task record output by S512, read the reconstruction target level code and the reconstruction operation scope node set; for each node identifier in the reconstruction operation scope node set, distinguish whether the node identifier belongs to the original node or the child node.
[0088] When it belongs to the original node, its level code is directly updated to the level code of the reconstruction target.
[0089] When a node is a child node, the difference between the original hierarchical code of the child node and its parent node is calculated, and the difference is added to the target hierarchical code to obtain the updated hierarchical code of the child node.
[0090] Write the updated hierarchical code value into the hierarchical code update record. The record includes the node identifier, the hierarchical code before the update, the hierarchical code after the update, and the update type flag. Output the hierarchical code update record to step S6 as the reconstructed hierarchical code system data.
[0091] In some embodiments, selecting the maximum value for the target hierarchical code in step S512 unifies the dispersed node hierarchies to the highest position, ensuring that the reconstructed hierarchical code will not be lower than any of the original hierarchical codes. The union construction of the node set within the scope of the reconstruction operation identifies the impact range of the hierarchical code change. The promotion of a parent node's hierarchies will trigger a linked adjustment of its child node hierarchies. While the child nodes' child nodes are not directly affected, they may be indirectly affected. Step S512 only defines the directly affected range; indirect effects are handled by the recursive update in step S513. This ensures that the update operation in step S513 has clear input boundaries, avoiding the performance overhead of a full traversal of the BOM structure.
[0092] In some embodiments, step S513 distinguishes between different update methods for the original node and its child nodes. The direct update of the original node is based on the absolute assignment of the target hierarchical code, which uniformly elevates the scattered hierarchies to the target height. The recursive update of the child node is based on the relative superposition of the original hierarchical differences, which keeps the hierarchical distance between the child node and its parent node unchanged, ensuring that the relative parent-child hierarchical relationship of the BOM structure is maintained after the absolute hierarchical elevation. The priority query method for the parent node's hierarchical code ensures that the recursive calculation of the child node is based on the latest parent node hierarchy. The deduplication process for the hierarchical code update records solves the problem of duplicate updates where the same child node may appear in multiple sets of child nodes of multiple parent nodes, retaining the last record to ensure that the final hierarchical code is the correct superposition result, and ensuring that the final hierarchical code of each node is uniquely determined.
[0093] In some specific embodiments, based on S5, when the hierarchical code adjustment strategy is a cost convolution calculation path optimization strategy based on the combination of cost center and material code, the following steps are specifically included: Identifying a set of nodes with the same cost center and the same material code, uniformly reconstructing the hierarchical codes of all nodes in the set to the maximum hierarchical code in the set, and recursively updating the hierarchical codes of their child nodes: S521. From the node attribute data table of the cost calculation BOM structure constructed in S1, read the cost center field value and material code field value of all nodes, and concatenate the cost center field value and material code field value according to the preset separator to form a composite key string. Establish a composite key index data structure, where the key is the composite key string and the value is a list of node identifiers.
[0094] Iterate through all nodes, appending the unique identifier of each node to the node identifier list corresponding to the composite key value. For each node identifier list corresponding to a composite key value, extract the initial hierarchical code value corresponding to each node identifier from the initial hierarchical code dataset obtained in S2, forming a hierarchical code value list. Calculate the maximum, minimum, and arithmetic mean values in the hierarchical code value list to obtain the hierarchical code distribution statistical index group. Define the composite key string, node identifier list, hierarchical code value list, and hierarchical code distribution statistical index group as a composite key node set record.
[0095] S522: Receive the composite key node set record list output by S521, and read the hierarchical code distribution statistical index group in each record. Calculate the hierarchical code distribution span value as the difference between the maximum and minimum values, and calculate the hierarchical code distribution density as the ratio of the number of elements in the node identifier list to the hierarchical code distribution span value.
[0096] The reconstruction priority evaluation value is established as the product of the hierarchical code distribution span and the hierarchical code distribution density. The composite key node set record list is sorted in descending order of reconstruction priority evaluation value. The maximum number of nodes processed per batch threshold in the system configuration parameters is read, and the sorted composite key node set record list is divided into several reconstruction batches according to this threshold. The total number of node identifiers in each reconstruction batch does not exceed this threshold.
[0097] For each reconstruction batch, the maximum value is extracted from the list of hierarchical code values and used as the batch reconstruction target hierarchical code for that batch. The list of reconstruction batches, the batch reconstruction target hierarchical codes for each batch, and the references to the set of composite key nodes contained in each batch are written into the batch reconstruction task description record.
[0098] S523: Receive the batch reconstruction task description record output by S522, and process each reconstruction batch in the order of the reconstruction batch list.
[0099] For the current reconstruction batch, read its batch reconstruction target level code and the set of all composite key nodes contained in the batch. Traverse each set of composite key nodes in the batch, and for each node identifier in the set, determine whether the node identifier exists in the cost convolution calculation path loop node information marked by S3.
[0100] If it exists, skip the level code update operation for that node.
[0101] If it does not exist, update the hierarchical code of the node identifier to the batch reconstruction target hierarchical code, and query the set of child node identifiers of the node identifier from the relational data table of the cost calculation BOM structure constructed in S1.
[0102] For each child node identifier in the child node identifier set, calculate the difference between the original hierarchical code of the child node identifier and the original hierarchical code of its parent node, and add the difference to the target hierarchical code of the batch reconstruction to obtain the updated hierarchical code of the child node.
[0103] Write the node identifier and its updated hierarchical code, as well as the child node identifiers and their updated hierarchical codes, into the batch hierarchical code update record. After the current reconstruction batch is processed, append the batch hierarchical code update record to the global hierarchical code update record list. After all reconstruction batches are processed, output the global hierarchical code update record list to step S6.
[0104] It can be seen that the loop node filtering check in step S523 intercepts nodes marked as loop nodes in step S3 before the hierarchical code update operation. The interception is consistent with the constraint in step S5 that filters out product nodes marked as loop nodes of cost convolution calculation path in step S3.
[0105] The direct assignment update of the original node writes the batch reconstruction target level code as an absolute value. The recursive update of the child node is based on the superposition of the original level difference, keeping the level distance between the child node and the parent node unchanged. The invariance ensures that the parent-child relationship of the BOM structure is maintained after reconstruction.
[0106] Furthermore, the cross-batch accumulation of the global hierarchical code update record list allows the update results from different batches to converge into the output data. The maximum value is retained during deduplication, ensuring that the final hierarchical code is the highest value in each update path, consistent with the upward alignment method, thus ensuring the consistency of the final hierarchical code system.
[0107] In some specific embodiments, based on S6, identifying the associated sub-product nodes marked in S1, searching the main product BOM list corresponding to the associated sub-product node, and based on the hierarchical code system reconstructed in S5, adjusting the hierarchical codes of the associated sub-product nodes to the minimum hierarchical code in the main product BOM list, so that the associated sub-products maintain a parallel relationship with the main product at the same level in the cost convolution calculation path, specifically includes the following steps: S61. Read all node identifiers marked as joint product nodes from the node marker data area of the cost calculation BOM structure constructed in S1.
[0108] Based on the identifier of each associated product node, the relational data table of the constructed cost calculation BOM structure is retrieved, and the sequence of all ancestor node identifiers of the associated product nodes is parsed.
[0109] In the ancestor node identifier sequence, identify the node identifier marked as the main product node, and determine the main product node identifier as the associated main product identifier of the associated secondary product node.
[0110] Furthermore, from the BOM header information data area of the cost calculation BOM structure constructed in S1, query the main product BOM identifier corresponding to the associated main product identifier, and establish a mapping entry between the associated sub-product node identifier and the main product BOM identifier; define all mapping entries as the associated mapping table of associated sub-product and main product.
[0111] S62. Receive the associated mapping table of main and secondary products output by S61, and establish the main product BOM level code cache area.
[0112] Based on each main product BOM identifier in the mapping table, query the reconstructed hierarchical code system output by S5, extract the hierarchical code values of all main product nodes under the main product BOM identifier, and form a list of main product node hierarchical codes.
[0113] Furthermore, iterate through all the level code values in the list, identify the minimum value, and determine the minimum level code of the main product corresponding to the main product BOM identifier.
[0114] Furthermore, the correspondence between the main product BOM identifier and the main product minimum level code is written into the main product BOM level code cache. The associated mapping table of linked and sub-product main products is traversed. For each linked and sub-product node identifier, its associated main product BOM identifier is queried. The main product minimum level code corresponding to the main product BOM identifier is read from the main product BOM level code cache, and the main product minimum level code is determined as the aggregation target level code for that linked and sub-product node identifier.
[0115] Establish a record for the collection of associated and sub-products, which includes the node identifier of the associated and sub-product, the BOM identifier of the associated main product, the collection target level code, and the original level code.
[0116] S63. Receive the list of associated and sub-product collection task records output by S62, and for each collection task record, read the associated and sub-product node identifier, collection target level code, and original level code fields.
[0117] Furthermore, the hierarchical code value of the joint and sub-product node identifier in the reconstructed hierarchical code system output by S5 is updated from the original hierarchical code field value to the aggregation target hierarchical code field value. The relational data table of the cost calculation BOM structure constructed by S1 is queried to obtain the set of parent node identifiers and child node identifiers of the joint and sub-product node identifiers.
[0118] Furthermore, the current level code value of the parent node identifier is read, the difference between the target level code and the parent node level code is calculated, and the level distance of the joint product relative to the parent node is obtained.
[0119] Furthermore, the set of child node identifiers is traversed. For each child node identifier, its original hierarchical code value is read, and the difference between the original hierarchical code value and the original hierarchical code of the joint product is calculated to obtain the original hierarchical distance of the child node relative to the joint product.
[0120] Furthermore, the original hierarchical distance is superimposed on the target hierarchical code to obtain the adjusted hierarchical code value of the child node.
[0121] Write the adjusted hierarchical code value of the child node identifier into the hierarchical code update record. Define the aggregation update record of the joint and sub-product node identifier and the hierarchical code update record of the child node identifier as the joint and sub-product aggregation update record group.
[0122] As can be seen, the hierarchical code of the joint product node in step S63 is directly updated, and the hierarchical code of the aggregation target determined in step S62 is written into the hierarchical code system to realize the downward aggregation of the hierarchical code. The parent node hierarchical distance is calculated to verify that the aggregated joint product node is still located in the downstream level of its parent node, maintaining the parent-child hierarchical order constraint of the BOM structure and ensuring that the aggregation operation does not destroy the rationality of the hierarchical relationship.
[0123] Furthermore, the recursive update of child nodes is based on the superposition of the original hierarchical distances, keeping the hierarchical distance of the child node relative to the joint product unchanged. This invariance ensures that the relative relationship of the subtree structure of the joint product is maintained after aggregation, and ensures that the final hierarchical code of each node is uniquely determined.
[0124] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0125] like Figure 3 As shown, this application also provides an electronic device, including a display module 103, a memory 102, a processor 101, a communication module 104, and a computer program stored in the memory and executable on the processor 101. When the processor 101 executes the program, it implements the steps of a hierarchical code dynamic reconstruction method for cost calculation BOM.
[0126] In embodiments of the present invention, electronic devices include, but are not limited to, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the embodiments described and / or claimed herein.
[0127] In this embodiment, processor 101 may be implemented using at least one of an application-specific integrated circuit, a programmable logic device, a field-programmable gate array, a processor, a controller, a microcontroller, a microprocessor, or an electronic unit designed to perform the functions described herein. In some cases, such an implementation may be implemented within a controller. For software implementation, implementations such as processes or functions may be implemented with separate software modules that allow the performance of at least one function or operation. Software code may be implemented by a software application (or program) written in any suitable programming language, and the software code may be stored in memory and executed by the controller.
[0128] The display module 103 is used to display information input by the user or information provided to the user. The display module 103 may include a display panel, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like.
[0129] The memory 102 can be used to store software programs and various data. The memory 102 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0130] The communication module 104 transmits radio signals to and / or receives radio signals from at least one of a base station, an external terminal, and a server. Such radio signals may include voice call signals, video call signals, or various types of data sent and / or received according to text and / or multimedia messages.
[0131] The present invention also provides a storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the steps of the method for dynamic reconstruction of the hierarchical code of the cost calculation BOM.
[0132] The storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example,, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0133] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for dynamic reconstruction of hierarchical codes in a cost calculation BOM, characterized in that, Includes the following steps: S1. Based on the product objects to be calculated and their material requisition relationships, construct the BOM header information, generate the BOM body information, identify and mark the main product node, the associated sub-product node, the object group node, and the object group associated material node, and complete the construction of the cost calculation BOM structure. S2. Based on the constructed cost calculation BOM structure, and to fully reflect the hierarchical relationship of the material composition, starting from each untraversed root node, an initial level code is assigned to each BOM node in a hierarchical progressive manner. S3. When the same BOM node is detected to be accessed repeatedly, the BOM node is marked as a circular material node and the product node access path is recorded; when the same product node is detected to be accessed repeatedly, the product node is marked as a circular node of the cost convolution calculation path. S4. Obtain the cost convolution calculation requirement parameters and the marked cost convolution calculation path loop node information, and determine the hierarchical code adjustment strategy based on the cost convolution calculation requirement parameters and loop node information. S5. Based on the determined hierarchical code adjustment strategy, the initial hierarchical code is reconstructed. When the hierarchical code adjustment strategy is the cost convolution calculation path optimization strategy based on material code consistency, the set of nodes with the same material code in the constructed BOM is identified, the hierarchical codes of all nodes in the node set are uniformly reconstructed to the maximum hierarchical code in the set, and the hierarchical codes of its child nodes are recursively updated to achieve the optimization of redundant levels. When the hierarchical code adjustment strategy is to optimize the cost convolution calculation path based on the combination of cost center and material code, the set of nodes with the same cost center and the same material code is identified, the hierarchical codes of all nodes in the set are uniformly reconstructed to the maximum hierarchical code in the set, and the hierarchical codes of its child nodes are recursively updated.
2. The method for dynamic reconstruction of hierarchical codes in cost calculation BOM according to claim 1, characterized in that, The specific steps involved in determining the hierarchical code adjustment strategy in S4 are as follows: When there is a product node that is marked as a cycle node of the cost convolution calculation path, the hierarchical code adjustment strategy is forced to maintain the initial hierarchy in order to preserve the original cost convolution calculation path strategy. When there are no product nodes marked as cycle nodes of the cost convolution calculation path, the hierarchy code adjustment strategy is selected from the preset strategy set. The preset strategy set includes maintaining the initial hierarchy to maintain the original cost convolution calculation path strategy, optimizing the cost convolution calculation path based on material code consistency strategy, and optimizing the cost convolution calculation path based on the combination of cost center and material code strategy.
3. The method for dynamic reconstruction of hierarchical codes in cost calculation BOM according to claim 1, characterized in that, The strategy for determining the hierarchical code adjustment in S4 also includes the following steps: S411. Obtain the link node count, direct child node count, and indirect child node count of the loop node in the cost convolution calculation path, and read the calculation depth threshold and path breadth threshold. S412. Compare the link node count with the calculation depth threshold, compare the number of direct child nodes with the path breadth threshold, and divide the cyclic nodes into cyclic nodes with critical path labels or cyclic nodes with non-critical path labels according to the comparison results. S413. When there is a cyclic node with a critical path marker, the hierarchical code adjustment strategy is determined to maintain the initial hierarchical strategy, and the initial hierarchical codes of the cyclic node with the critical path marker and all nodes on its parent node link sequence are set to an unchangeable state. S414. When all loop nodes have non-critical path markers, the hierarchical code adjustment strategy is determined as the branch isolation strategy. The branch paths containing loop nodes with non-critical path markers are set as isolated and maintained branches, and the branch paths not containing loop nodes are set as open and optimized branches.
4. The method for dynamic reconstruction of hierarchical codes in cost calculation BOM according to claim 1, characterized in that, Step S4 is followed by the following steps: S421. Obtain the strategy type code of the hierarchical code adjustment strategy, and extract the node identifier, parent node identifier sequence, child node identifier set, initial hierarchical code value, material code field value and cost center field value of each node in the cost calculation BOM structure of the cost convolution calculation path loop node. S422. Identify the corresponding node set according to the strategy type encoding, traverse each pair of nodes in the node set, detect the association between the node pair and the loop node of the cost convolution calculation path, and generate a risk label record based on the detection result. S423. Count the number of risk mark records. When the number of risk mark records is greater than zero, change the hierarchical code adjustment strategy to maintain the initial hierarchical strategy. When the number of risk mark records is equal to zero, keep the hierarchical code adjustment strategy unchanged. S424. Receive the hierarchical code adjustment strategy and associated execution record. When the hierarchical code adjustment strategy is to maintain the initial hierarchical strategy, extract the initial hierarchical codes of all nodes as the final execution hierarchical code dataset. When the hierarchical code adjustment strategy is to optimize the strategy, extract the risk-free node set as the set of nodes that can be reconstructed, and write the partition boundary between the set of nodes that can be reconstructed and the cost convolution calculation path loop nodes and their associated nodes into the strategy execution range boundary record.
5. The method for dynamic reconstruction of hierarchical codes in cost calculation BOM according to claim 1, characterized in that, In S5, the initial hierarchical code is reconstructed according to the determined hierarchical code adjustment strategy. When the hierarchical code adjustment strategy is a cost convolution calculation path optimization strategy based on material code consistency, the set of nodes with the same material code in the constructed BOM is identified, the hierarchical codes of all nodes in the set are uniformly reconstructed to the maximum hierarchical code in the set, and the hierarchical codes of its child nodes are recursively updated to achieve the optimization of redundant hierarchies. The specific steps include the following: S511: Construct a mapping dictionary from material codes to node identifier lists, extract an initial hierarchical code value list based on the node set corresponding to each material code and calculate the hierarchical code dispersion, and integrate the material code, node identifier list, hierarchical code value list and dispersion index into a node set record; S512: Compare the level code dispersion index in the node set record with the preset reconstruction judgment threshold. When the dispersion index is greater than the threshold, select the maximum value of the initial level code in the node set as the reconstruction target level code, determine the node set of the reconstruction operation range by the union of the node identifier list and its child node identifier set, and generate a reconstruction task record. When the dispersion index is not greater than the threshold, terminate the subsequent processing of the node set. S513: Process the reconstruction task record, and update the level code of the original node in the node set of the reconstruction operation scope to the level code of the reconstruction target. For child nodes, calculate the difference between the original hierarchical codes of the child node and its parent node, add the difference to the reconstructed target hierarchical code to obtain the updated hierarchical code, and generate a hierarchical code update record.
6. The method for dynamic reconstruction of hierarchical codes in cost calculation BOM according to claim 1, characterized in that, In S5, when the hierarchical code adjustment strategy is a cost convolution calculation path optimization strategy based on the combination of cost center and material code, the following steps are taken: Identify the set of nodes with the same cost center and the same material code, reconstruct the hierarchical code of all nodes in the set to the maximum hierarchical code in the set, and recursively update the hierarchical codes of their child nodes. S521. Read the cost center field value and material code field value from the node attribute data table of the cost calculation BOM structure, concatenate them to form a composite key string and establish a composite key index data structure, traverse all nodes to form a node identifier list corresponding to the composite key value, extract the initial level code value of each node identifier and calculate the level code distribution statistical index group, and define it as the composite key node set. S522. Based on the set of composite key nodes, calculate the distribution span value and distribution density of the hierarchical code and establish a reconstruction priority evaluation value. After sorting according to the reconstruction priority evaluation value, divide into reconstruction batches according to the threshold of the maximum number of processing nodes in a single batch, and determine the batch reconstruction target hierarchical code of each reconstruction batch. S523. Process each reconstruction batch in the order of the reconstruction batch list, distinguish whether the node identifier exists in the cost convolution calculation path loop node information, skip the update operation for the node identifier that exists, update the node identifier that does not exist to the batch reconstruction target level code and calculate the updated level code of the child node.
7. The method for dynamic reconstruction of hierarchical codes in cost calculation BOM according to claim 1, characterized in that, Following S5 are: S61. Read the joint and sub-product node identifiers from the node marker data area of the cost calculation BOM structure, parse the ancestor node identifier sequence of each joint and sub-product node and identify the main product node identifier, query the associated main product BOM identifier and establish the mapping relationship between the joint and sub-product node identifiers and the main product BOM identifiers to form a joint and sub-product main product association mapping table. S62. Extract the level code values of the main product nodes under each main product BOM identifier and identify the minimum value as the minimum level code of the main product. Establish a main product BOM level code cache area. For each joint sub-product node identifier, query the associated main product BOM identifier and read the corresponding minimum level code of the main product as the collection target level code to form a joint sub-product collection task. S63. Based on the task of collecting joint and sub-products, update the hierarchical code value of the joint and sub-product node identifier to the collection target hierarchical code, obtain the set of parent node identifiers and child node identifiers of the joint and sub-product node identifiers, calculate the hierarchical distance of the joint and sub-product relative to the parent node and the original hierarchical distance of the child node relative to the joint and sub-product, and add the original hierarchical distance to the collection target hierarchical code to obtain the adjusted hierarchical code value of the child node, forming a joint and sub-product collection update record group.
8. The method for dynamic reconstruction of hierarchical codes in cost calculation BOM according to claim 1, characterized in that, S2 specifically includes the following steps: Filter all root nodes in the cost calculation BOM structure, query the node records with empty parent node identifiers from the relational data table of the constructed cost calculation BOM structure, and store the unique identifier of the node in the root node queue. Take a root node identifier sequentially from the root node queue, set the root node distance to 0, set the initial level code of the root node to 1, and write the correspondence between the root node distance and the initial level code into the level code allocation record table. Starting from the current root node, traverse all child nodes under the root node in a hierarchical manner. For each child node traversed, read the initial level code of its parent node, set the initial level code of the child node to the initial level code of the parent node plus 1, set the root node distance of the child node to the root node distance of the parent node plus 1, and write the child node information into the level code allocation record table. Once all child nodes under the current root node have completed their hierarchical code assignments, the next root node identifier is retrieved from the root node queue, and the above operation is repeated until the root node queue is empty.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the hierarchical code dynamic reconstruction method for cost calculation BOM as described in any one of claims 1 to 8.
10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the hierarchical code dynamic reconstruction method for cost calculation BOM as described in any one of claims 1 to 8.