Cost calculation restoration method and device supporting self-defined restoration range, equipment and medium

By creating intermediate tables and headers, defining the scope of cost centers, and establishing input, output, and intermediate calculation cache tables, the problem of inaccurate cost restoration scope in existing technologies is solved, and automated restoration and improved transparency of cost data across organizations are achieved.

CN121903789APending Publication Date: 2026-04-21INSPUR GENERSOFT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INSPUR GENERSOFT CO LTD
Filing Date
2026-01-12
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

The lack of structured constraints on the cost reduction scope in existing technologies leads to cross-organizational cost interference, data omissions, and difficulty in tracing the calculation process, making it impossible to fully reflect the cost of the entire product chain.

Method used

By creating intermediate tables and headers, the selectable range of cost centers is limited, and input, output, and intermediate calculation cache data tables are established. Cost data is matched and updated layer by layer to ensure data accuracy and transparency.

Benefits of technology

It enables automated reconstruction of cost data across organizations, improving the accuracy and transparency of cost calculations and supporting multi-organization cost management and decision-making.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121903789A_ABST
    Figure CN121903789A_ABST
Patent Text Reader

Abstract

The invention provides a cost calculation restoration method and device supporting a self-defined restoration range, equipment and a medium, belongs to the technical field of cost accounting, configures the cost restoration range, creates an intermediate table for cost restoration calculation, and defines input and output functions. Wherein the cost center selection range of the meter body is constrained by the accounting organization and the range type of the meter head. And receiving a to-be-restored cost calculation single header ID and a restoration range header ID, and initializing the maximum level to be 1. And updating the material unit price and the completion cost of the reset unit price record according to the hierarchy from high to low, summarizing the update header data and transmitting the latest cost price. And calculating a quantity / amount coefficient, and adjusting and inserting the associated table body data. And dumping the intermediate table data to a cost reduction calculation sheet, and filling missing source accounting organization / cost center information. According to the method, cross-organization automatic reduction of cost data is realized, the accuracy and transparency of cost calculation are improved, and multi-organization cost management and decision are effectively supported.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of cost accounting technology, and specifically relates to a cost calculation and restoration method, apparatus, equipment and medium that supports a custom restoration range. Background Technology

[0002] Cost management is a core aspect of business operations, especially in manufacturing, energy, and other production scenarios, where the accuracy of cost calculation directly impacts decision-making efficiency and resource allocation.

[0003] In related technologies, the scope of cost reduction is often based on subjective definition and lacks structured constraints. For example, when reduction is required within accounting organizations, cost centers of other accounting organizations may be mistakenly included, leading to cross-organizational cost interference; or when reducing across accounting organizations, external cost centers that should be included may be omitted.

[0004] The original data for cost restoration and the temporary data used in the calculation process are often stored in the same data table, and the original data is directly modified during the calculation. When the restoration result is abnormal, it is impossible to distinguish whether the error is in the original data or the calculation process, making it difficult to trace the root cause of the problem; multiple restoration operations may overwrite historical data, making the data unusable.

[0005] The relevant technologies are mostly based on manually querying the lower-level cost calculation sheets layer by layer, which is prone to overlooking or omitting a certain level. As a result, the restored cost only includes some levels and cannot fully reflect the cost of the entire product chain from raw materials to finished products. Summary of the Invention

[0006] This invention provides a cost calculation restoration method that supports custom restoration ranges, enabling automated restoration of cost data across organizations, improving the accuracy and transparency of cost calculations, and effectively supporting multi-organization cost management and decision-making.

[0007] The methods include: S101: Configure the cost restoration range, create an intermediate table for cost restoration calculation and the corresponding table header and body, and define input and output functions, wherein the cost center selection range of the table body is constrained by the accounting organization and range type of the table header; S102: Establish the input data table, output data table, and intermediate calculation cache data table required for cost reduction; S103: Receive the header ID of the cost calculation form to be restored and the header ID of the set restoration range as input parameters, and set the initial value of the maximum level to 1; S104: Insert the header and body data of the cost calculation sheet to be restored into the corresponding positions in the intermediate table and set the level to the initial maximum level. Recursively match the intermediate table body record with the cost calculation sheet header. If the match is successful, assign the source information to the table body and insert the associated data into the intermediate table. The level increases until the match fails. S105: Loop through the hierarchy from high to low, update the material unit price to the latest cost price for records in the intermediate table body that have their unit price reset to "yes", and recalculate the completion cost. Summarize the completion cost of the table body and update the current completion cost and unit price of the corresponding table header. Then, use the table header ID to match the matching cost of the table body to calculate the unit ID and update the latest cost price of the table body. S106: Loop through the hierarchy from high to low, calculate the single ID by matching the table body with the table header ID, calculate the quantity coefficient and amount coefficient for the matched table body records, delete the original records, adjust according to the coefficients and insert the associated table body data, and inherit the source information at the same time; S107: Transfer the data of the header ID of the cost calculation sheet to be restored in the intermediate table to the cost restoration calculation sheet. For rows in the body where the source accounting organization and source cost center are empty, fill in the accounting organization and cost center information corresponding to the header.

[0008] This application also provides a cost calculation and restoration system that supports a custom restoration range, the system comprising: The configuration management module is used to configure the cost restoration range, create intermediate tables for cost restoration calculations and their corresponding headers and bodies, and define input and output functions. The cost center selection range of the body is constrained by the accounting organization and range type of the header. The data table construction module is used to create the input data table, output data table, and intermediate calculation cache data table required for cost reduction. The parameter initialization module is used to receive the header ID of the cost calculation form to be restored and the header ID of the set restoration range as input parameters, and sets the initial value of the maximum level to 1. The data insertion and matching module is used to insert the header and body data of the cost calculation sheet to be restored into the corresponding positions in the intermediate table and set the level to the initial maximum level. It recursively matches the intermediate table body records with the cost calculation sheet header. If the match is successful, it assigns the source information to the table body and inserts the associated data into the intermediate table. The level increases until the match fails. The cost update summary module is used to cycle from high to low in the hierarchy, update the material unit price to the latest cost price for records in the intermediate table body that have their unit price reset to "yes", and recalculate the completion cost. The summary table body's completion cost updates the current period's completion cost and unit price in the corresponding table header, and then uses the table header ID to match the matching cost in the table body to calculate the unit ID and update the latest cost price in the table body. The data adjustment and inheritance module is used to cycle from high to low hierarchy, calculate the single ID by matching the table header ID with the matching cost of the table body, calculate the quantity coefficient and amount coefficient for the matched table body records, delete the original records, adjust according to the coefficients and insert the related table body data, and inherit the source information at the same time. The data dump and fill module is used to dump the data of the corresponding header ID of the cost calculation sheet to be restored in the intermediate table to the cost restoration calculation sheet. For rows in the table body where the source accounting organization and source cost center are empty, it fills in the accounting organization and cost center information corresponding to the header.

[0009] 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 cost calculation and restoration method supporting a custom restoration range.

[0010] According to another embodiment of this application, a storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the cost calculation and restoration method supporting a custom restoration range.

[0011] As can be seen from the above technical solutions, the present invention has the following advantages: This invention provides a cost calculation and restoration method that supports custom restoration ranges. By creating intermediate tables and corresponding headers and bodies for cost restoration calculations, it structurally limits the selectable range of cost centers, avoiding manual misselection and ensuring that the restoration range is completely consistent with preset requirements and that the starting point data is accurate. It establishes input data tables, intermediate calculation cache tables, and output data tables. Original data is not modified, intermediate processes are traceable, and result data is stored independently, facilitating troubleshooting and data reuse. Starting from the initial level of data to be restored, it matches lower-level cost calculation sheets based on material information and cost ranges, inserting intermediate tables layer by layer and increasing the level until matching fails. All related lower-level cost data are collected to form a complete multi-level cost chain, ensuring no omissions in the cost structure. For table body records where the source accounting organization differs from the header accounting organization, the material unit price is updated to the actual production cost of the lower-level cost calculation sheet, and the completed cost is recalculated and passed upwards with the corrected cost. Internal transaction markups are eliminated, allowing cross-organizational costs to reflect actual production costs, resulting in more objective restoration results and providing accurate data for cost analysis.

[0012] Calculate quantity and amount coefficients, adjust the lower-level table data according to the coefficients, and then replace the original records. The decomposed cost elements match the original summary data in terms of quantity and amount to avoid data contradictions and ensure the accuracy of cost composition decomposition. For rows in the table body where the source accounting organization and cost center are empty, populate the corresponding accounting organization and cost center in the table header.

[0013] This invention achieves accuracy, efficiency, and reliability in cost calculation and reconstruction, supports dynamic reconstruction of complex cost structures and cross-level data association, and improves the level of precision in enterprise cost management. Attached Figure Description

[0014] 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.

[0015] Figure 1 Flowchart of cost calculation restoration method to support custom restoration range; Figure 2 Flowchart of an embodiment of the cost calculation restoration method to support custom restoration range; Figure 3 A schematic diagram of the cost calculation restoration system to support custom restoration ranges; Figure 4 This is a schematic diagram of an electronic device. Detailed Implementation

[0016] The cost calculation and restoration method supporting custom restoration ranges involved in this application will be described in detail below. Specific details such as particular system architectures and technologies are presented for illustrative purposes and not for limitation, 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.

[0017] It should be understood that, when used in this specification, terms include indicating the presence of a described feature, integral, step, operation, element, and / or component, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof. The terms include, encompass, have, and variations thereof mean including but not limited to, unless otherwise specifically emphasized.

[0018] The statements such as "one embodiment" or "some embodiments" described in this application mean that one or more embodiments of this application include the specific features, structures, or characteristics described in that embodiment. Therefore, the statements such as "in one embodiment," "in some embodiments," "in other embodiments," and "in still other embodiments" in this application do not necessarily refer to the same embodiment, but rather mean one or more, but not all, embodiments, unless otherwise specifically emphasized.

[0019] 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, and 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.

[0020] Please see Figure 1 The diagram shows a flowchart of a cost calculation and restoration method supporting a custom restoration range in a specific embodiment. The method includes: S101: Configure the cost restoration range, create an intermediate table for cost restoration calculation, and define the corresponding table header and body. The cost center selection range of the table body is constrained by the accounting organization and range type of the table header.

[0021] In some embodiments, the cost reduction scope defines the accounting boundaries involved in the reduction, specifically including: The range identification information includes a unique range ID, a range name, and a range number used to distinguish different restoration scenarios.

[0022] The constraint parameters include specifying the primary accounting entity and the scope type; the scope type is divided into cross-accounting organization and non-cross-accounting organization. The former allows cost centers from multiple accounting organizations to be included, while the latter is limited to cost centers within the primary accounting organization.

[0023] The intermediate table header is used for top-level control of cost restoration calculation. Specifically, it includes the header ID, associated restoration scope ID, accounting organization, type of inherited scope configuration, accounting period of restoration calculation, and status identifier such as pending calculation / in progress / completed, which is used to track the restoration progress.

[0024] The intermediate table body is used to record specific cost data: it includes table body ID, associated header ID, cost center ID, cost element type, such as direct materials and manufacturing overhead used to classify cost items, initial cost value, which is the original cost data before restoration, and source mark.

[0025] In the input / output functions of this embodiment, the input function allows users to fill in range identifiers, constraint parameters, and initial data of intermediate tables through a form interface, with the form validating field formats in real time; batch import is also possible.

[0026] The output function can generate a scope configuration list, such as an Excel file, containing key information such as scope ID, accounting organization, and scope type, for approval and archiving; secondly, an intermediate table initialization report; and thirdly, a data relationship diagram.

[0027] In this embodiment, the constraint for selecting cost centers in the table body is based on the following: when the range type is "not across accounting organizations," the cost center ID in the table body satisfies the condition that the accounting organization to which it belongs equals the accounting organization in the intermediate table header. The system uses the cost center table at the database level. The accounting organization filters the available cost centers, and the front-end selection interface only displays options that meet the criteria.

[0028] When the scope type is cross-accounting organization, the above-mentioned accounting organization restrictions are removed.

[0029] S102: Establish the input data table, output data table, and intermediate calculation cache data table required for cost reduction.

[0030] In some embodiments, the input data table is a cost calculation table, including a header and a body, which stores the original cost data to be restored.

[0031] Optionally, the table header may include ID, cost period, accounting organization, cost center, material information, and quantity / cost / unit price of completed work. The table body may include main table ID, cost element, material information, and quantity / cost / unit price of completed work.

[0032] The output data table, also known as the cost reduction calculation table, has a similar structure to the input table, but adds fields for reduction scope, source accounting organization, and source cost center to store the final reduction results.

[0033] The intermediate calculation cache data table, also known as the cost restoration calculation intermediate table, includes a table header, which can add hierarchical fields, and a table body that can add fields such as matching cost calculation unit ID, source cost center, latest cost price, and reset unit price, used to temporarily store intermediate data during the restoration process.

[0034] This embodiment provides raw data through an input table, uses an intermediate table as a computational medium to temporarily store hierarchical information and matching relationships during processing, and stores the final result in an output table. The structure of the output table corresponds to that of the input table, facilitating comparison of cost data before and after restoration and improving the readability of the results.

[0035] S103: Receive the header ID of the cost calculation form to be restored and the header ID of the set restoration range as input parameters, and set the initial value of the maximum level to 1.

[0036] In some embodiments, input parameters are validated by checking whether the ID format conforms to the rules and whether it exists in the corresponding table to ensure the parameters are valid; the header ID of the cost calculation unit to be restored is used to locate the target cost data to be restored, and the header ID of the restoration range is used to limit the boundary of the restoration range. The initial value of the maximum level is set to 1, representing the initial level of the cost calculation unit to be restored, and the subsequent associated lower-level data levels increase sequentially.

[0037] In this way, the processing object and processing scope are accurately identified by two ID parameters, the initial value of the hierarchy provides the starting point for the recursive matching process, the explicit input parameters avoid confusion of the processing object, and ensure that the restoration process is performed on the specified cost calculation sheet.

[0038] S104: Insert the header and body data of the cost calculation sheet to be restored into the corresponding positions in the intermediate table and set the level to the initial maximum level. Recursively match the intermediate table body records with the cost calculation sheet header. If the match is successful, assign the source information to the table body and insert the associated data into the intermediate table. The level increases until the match fails.

[0039] In some embodiments, when inserting an intermediate table, the header level of the data to be restored is set to 1, and the table body data is associated with the corresponding header. Recursive matching uses the material information and cost period recorded in the intermediate table body as conditions to search for the associated header that matches the restoration range in the cost calculation sheet, that is, to match the cost calculation sheet ID.

[0040] In this embodiment, after a successful match, the table body is assigned information such as the cost center associated with the source cost center, the accounting organization associated with the source accounting organization, and the current cost unit price associated with the latest cost price. The associated header and body data are then inserted into the intermediate table, and the level is set to the current maximum level + 1. If no associated data is found, the recursion terminates.

[0041] Recursive matching automatically aggregates all relevant lower-level cost data, ensuring the completeness of cost reconstruction and avoiding omissions of indirect cost components; hierarchical identification clearly distinguishes cost data at different levels, making complex costs visible. Assigning source information provides a basis for cost traceability, clearly identifying the source entity of each level of cost.

[0042] S105: Loop through the hierarchy from high to low, update the material unit price to the latest cost price for records in the intermediate table body that have their unit price reset to "yes", and recalculate the completion cost. Summarize the completion cost of the table body and update the current completion cost and unit price of the corresponding table header. Then, use the table header ID to match the matching cost of the table body to calculate the unit ID and update the latest cost price of the table body.

[0043] In some embodiments, the hierarchy cycles from high to low, that is, from the highest level to 1, prioritizing the processing of the lowest level data to ensure that the upper level data is calculated based on the latest lower level data; for table records where the reset unit price is "yes", the material unit price is updated to the latest cost price, and the completion cost is recalculated as the material unit price × the completed quantity.

[0044] This embodiment summarizes the completion costs of all tables under the same header, updates the current period completion cost of the header, and then updates the current period cost unit price by dividing the current period completion cost by the current period completion quantity.

[0045] In this embodiment, the updated header ID is matched with the matching cost calculation unit ID of other table bodies, and the latest cost price of these table bodies is updated to the current cost unit price of the header.

[0046] As can be seen, the system corrects cross-organizational cost discrepancies starting from the lowest level. By updating unit prices and costs, it ensures that each layer of data reflects the true production costs. The corrected costs are then passed up the hierarchy, ultimately ensuring that the top-level data is calculated based on the latest costs from the lower levels. This top-down processing ensures the sequential transmission of cost data, with upper-level data always based on the corrected lower-level data, improving calculation accuracy. The linked updates of the table header and body ensure data consistency, preventing mismatches between table header and body costs.

[0047] S106: Loop through the hierarchy from high to low, calculate the single ID by matching the table body's matching cost through the table header ID, calculate the quantity coefficient and amount coefficient for the matched table body records, delete the original records, adjust according to the coefficients, and insert the associated table body data, while inheriting the source information.

[0048] In some embodiments, the hierarchy cycles from high to low, and for each level of the header, the cost of matching records in other body tables with the same ID is calculated by matching their IDs.

[0049] Quantity coefficient = Completed quantity of matching table body records ÷ Current completed quantity of current table header; Amount coefficient = Completion cost of matching table body record ÷ Current period completion cost of current table header; Delete the original matching table body record, adjust the table body data associated with the current table header according to the coefficients (completed usage = original usage × quantity coefficient, completed cost = original cost × amount coefficient), and insert it into the intermediate table. At the same time, it inherits the source accounting organization, source cost center and other information of the original record.

[0050] This embodiment replaces the summary record of the self-made part in the upper layer with the detailed cost structure of the lower layer. By adjusting the coefficients, it ensures that the quantity and amount are consistent with the consumption ratio of the upper layer, thus achieving a layer-by-layer decomposition of the cost structure. In this way, the adjustment ensures the consistency of the decomposed cost with the original summary data in terms of quantity and amount, avoiding data distortion; inheriting source information allows each cost record after decomposition to be traced back to the original cost center, improving cost transparency.

[0051] S107: Transfer the data of the header ID of the cost calculation sheet to be restored in the intermediate table to the cost restoration calculation sheet. For rows in the body where the source accounting organization and source cost center are empty, fill in the accounting organization and cost center information corresponding to the header.

[0052] In some embodiments, during the transfer, data whose header ID in the intermediate table matches the header ID of the cost calculation sheet to be restored is written into the cost restoration calculation sheet, i.e., the output table, according to the field mapping relationship. Rows in the output table body that are empty for the source accounting organization and source cost center are checked and filled with the corresponding accounting organization and cost center from the header.

[0053] In this way, the final processed target data is extracted from the intermediate table, organized into a standardized output format, and missing source information is supplemented to ensure the integrity and consistency of the output data. This echoes the structure of the input table, facilitating comparison of cost changes before and after the restoration process and demonstrating the restoration effect.

[0054] In one embodiment of the present invention, based on step S101, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner. Step S101 specifically includes the following methods: S1011: The input function adopts a data dictionary mapping architecture. Through a pre-defined association rule table between accounting organizations and scope types, the enterprise-level cost center library is activated when the user selects cross-accounting organization; when selecting no cross-accounting organization, the accounting organization ID and the cost center's ID are dynamically associated through an SQL view, forming a constraint expression. This architecture supports multi-level linked filtering, avoiding the static limitations of traditional dropdown menus.

[0055] S1012: Based on the CSV format, the semantic mapping relationship of the exported fields is defined through XML schema to ensure that cost data maintains business logic consistency when transmitted across systems. For example, the cost unit price field can be configured to retain two decimal places or an integer to meet the needs of different scenarios.

[0056] In this embodiment, users can customize the order, format, and precision of exported fields. For example, the unit cost price can be configured to retain two decimal places or an integer to meet different needs in financial accounting and business analysis. The XML schema definition ensures that field semantics remain consistent across systems, avoiding data ambiguity.

[0057] S1013: Table body constraints are implemented through database-level triggers. When a range-type field changes, the trigger checks whether the cost center ID conforms to the current accounting organization constraint rules. For cross-accounting organization scenarios, the trigger uses set operation logic to allow all cost centers; for non-cross-accounting organization scenarios, the trigger performs intersection operation to retain only cost centers within its own accounting organization, avoiding the limitations of traditional foreign key constraints.

[0058] The database trigger in this embodiment is written in PL / SQL and automatically executes constraint validation logic when a range type field changes. The trigger has a built-in anti-circular call mechanism to avoid performance issues caused by recursive triggering. For example, when the range type changes from "not spanning" to "spanning," the trigger automatically removes the accounting organization constraint, allowing the selection of a global cost center.

[0059] S1014: Input validation employs a non-linear data verification algorithm, using SHA-256 hash verification on the cost center number to ensure its uniqueness. Name format validation uses a regular expression library, supporting combined validation of Chinese characters, numbers, and special symbols, avoiding the limitations of traditional length validation.

[0060] S1015: Embed an invisible digital watermark in the exported file, recording metadata such as export time and operator ID. The watermark information includes the hash value of the operation log, which is embedded in the blank area of ​​the PDF file using the least significant bit (LSB) algorithm, enabling data leakage tracing without affecting the visual effect.

[0061] The nonlinear verification algorithm in this embodiment ensures the uniqueness of the number through hash collision probability theory, and the SHA-256 algorithm irreversibly encrypts the cost center number. Watermark information is associated with the operation log through a hash algorithm to ensure data integrity and verifiability. For example, if an exported file is illegally disseminated, the watermark information can be used to trace the operator and the export time, achieving secure data traceability.

[0062] In one embodiment of the present invention, based on step S104, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner. Step S104 specifically includes the following methods: S1041: Insert the header data of the cost calculation sheet to be restored into the intermediate header according to the field mapping rule table, and associate the body data with the main table ID through the association rule; for example, intermediate body - main table ID = cost calculation sheet header ID - inserted intermediate body. Add a matching status field and a matching trajectory field to the intermediate header and body to record the progress and process information of data matching, respectively.

[0063] In this embodiment, the field mapping rule table is stored in the database and includes source table fields, target table fields, and data transformation rules. The main table ID association rule is implemented through database foreign key constraints to ensure a one-to-one correspondence between the intermediate table body and the cost calculation single table header; the matching status field uses an enumeration type, and the matching trajectory field uses string concatenation to support fast parsing of the matching path.

[0064] S1042: Load the corresponding matching rule set from the rule configuration table based on the cross / non-cross accounting organization and accounting organization attributes of the restore range table header; When the cost center is located across accounting organizations, rules such as the organization to which it belongs ∈ the whitelist of the restoration scope and the association between material type and target product are loaded; when the cost center is located within the same accounting organization, rules such as the organization to which it belongs = the current restoration scope organization and the matching of material usage with target process are loaded; the rule set is parsed into executable logical expressions.

[0065] The rule configuration in this embodiment enables matching logic and business requirements to be processed, allowing enterprises to adapt to their organizational structure without modifying the code; the rule expressions are pre-parsed into SQL statements, avoiding the overhead of repeated parsing during each match and improving matching efficiency.

[0066] S1043: Starting from the intermediate table body record of the initial level, the database cursor is used to traverse each record one by one, extract key attributes such as material information and cost period of the current record, and substitute them into the parsed logical expression for matching and judgment; If a match is successful, update the matching status of the record to "matched" and append the current level identifier and matching rule number to the matching trajectory field; if a match fails, keep the unmatched status and append an identifier.

[0067] S1044: When an intermediate table body record is successfully matched, based on the matched cost calculation sheet header ID, extract the field values ​​such as cost element, completed usage, and latest cost price from the original cost calculation sheet and insert them into the associated fields of the intermediate table body; at the same time, increment the current maximum level value by 1 to generate a new level identifier, and insert the intermediate table header and table body corresponding to the new level into the database, with the parent trajectory field of the new table body pointing to the matching trajectory of the parent record.

[0068] S1045: When K consecutive intermediate table body records fail to match, check the matching trajectory of the previous level to identify whether there are matching branches that are not fully expanded; here K is the configured failure threshold, such as 3.

[0069] If there are unexpanded branches, adjust the matching conditions, such as relaxing the material type matching to fuzzy material type matching, and then re-execute the matching. If no match is found after M consecutive backtracking attempts, the recursive process terminates and a matching failure exception is returned to the business layer. The exception information includes detailed location data such as the failure level and failure trajectory. M is the configured maximum number of retries, such as 5.

[0070] In this embodiment, the failure threshold K and the maximum number of retries M are stored in the enterprise configuration table, allowing administrators to dynamically adjust them. The backtracking mechanism uses a trajectory backtracking algorithm to parse nodes in the parent trajectory, identify branches that are not fully expanded, and re-execute the matching. This embodiment, through thresholds, backtracking, and explicit termination conditions, enables the process to have adaptive fault recovery capabilities. While ensuring data accuracy, it also improves the process's fault tolerance.

[0071] In one embodiment of the present invention, based on step S106, the following will provide a possible embodiment and describe its specific implementation in a non-limiting manner. Step S106 specifically includes the following methods: S1061: Based on the hierarchy, material information, and cost period fields of the intermediate table header, and the hierarchy, material information, and cost period fields of the original cost calculation sheet header, establish a composite matching rule: first match the hierarchy, then match the material information, and finally match the cost period; the matching results are stored in the matching level field of the intermediate table body in three levels: complete match / partial match / no match.

[0072] In this embodiment, the first 8 digits of the material number are extracted for fuzzy matching when matching material information. The matching level field uses complete match, partial match, and no match, and is generated by the database CASEWHEN statement.

[0073] S1062: For records that match exactly, extract the completed usage and cost of the intermediate table body and calculate the standard usage and standard cost of the single table body by combining them with the original cost. Calculate the quantity coefficient and the amount coefficient; define the business weight as the final coefficient.

[0074] In this embodiment, the calculation coefficient K1 = current completed usage / standard usage, and the monetary coefficient K2 = current completed cost / standard cost. Business weights are defined by the enterprise configuration table, such as raw material weight 0.6 and labor weight 0.4. The final coefficient K = K1 × W1 + K2 × W2, where W1 and W2 are the business weights.

[0075] Business weights are stored in an enterprise configuration table, supporting dynamic adjustment of weights based on raw materials, labor, and manufacturing costs. The final coefficient K is calculated using a linear weighting formula; the coefficient calculation result is encapsulated in a database stored procedure to avoid application-layer code redundancy.

[0076] S1063: Before deleting the original intermediate table body record, generate a snapshot of the current data, including key fields such as record ID, completed usage, and completed cost; the deletion operation and the operation of inserting a new record are wrapped in the same transaction, and if the insertion fails, it will roll back to the snapshot state.

[0077] S1064: Newly inserted table body records inherit the source accounting organization and source cost center information. The inheritance priority is as follows: take the accounting organization and cost center of the matched original cost calculation sheet header; if the original header information is empty, take the accounting organization and cost center of the corresponding level of the intermediate header; if the level information is still empty, trigger the early warning mechanism and push the information missing notification to the business layer, and prohibit the insertion of invalid records.

[0078] In this embodiment, priority inheritance is implemented through the database CASEWHEN statement; missing information alarms are triggered by the database event listener, which calls the enterprise message service to push notifications to the business layer; and preventing the insertion of invalid records is implemented through the database CHECK constraint.

[0079] S1065: After inserting a new record, the data accuracy is verified through forward and reverse validation. If the validation fails, the original data in the transaction snapshot is extracted, and the rollback is completed through reverse operation. The rollback method achieves rapid data recovery through transaction snapshots, ensuring the reliability of the process. The validation results and rollback logs provide detailed evidence for subsequent troubleshooting, improving the maintainability of the system.

[0080] In this embodiment, the forward verification is used to check that the completed usage of the new record × K = new completed cost. The reverse verification is used to check that the total completed cost of the hierarchy = Σ new record completed cost to verify data accuracy; the reverse operation is to delete the new record and restore the original record to complete the rollback.

[0081] Furthermore, as a refinement and extension of the above-described embodiment of the cost calculation and restoration method supporting custom restoration ranges, in order to fully illustrate the specific implementation process in this embodiment, the method further includes the following specific steps: like Figure 2 As shown, S201: Configure the cost restoration range, create a cost center table, a cost restoration range header table, and a cost restoration range body table, and implement the input and output functions of the cost center table, the cost restoration range header table, and the cost restoration range body table; wherein, the cost center selection range of the cost restoration range body table is constrained by the [Accounting Organization] and [Range Type] of the cost restoration range header table.

[0082] When the scope type is not across accounting organizations, only cost centers whose "Accounting Organization" matches the "Accounting Organization" in the cost restoration scope - header table are selected; when the scope type is across accounting organizations, the cost center selection is not filtered by the cost restoration scope - header table "Accounting Organization".

[0083] As one embodiment of this application, a <Cost Center> table is created within the configuration cost restoration scope, and its basic attribute structure is as follows:

[0084] Create a table named <Cost Reduction Scope - Header> with the following basic attribute structure:

[0085] Create a table named <Cost Reduction Scope - Table Body> with the following basic attribute structure:

[0086] S202: Establish input data tables, output data tables, and intermediate calculation cache data tables for cost restoration. The input data tables are cost calculation unit tables, including a cost calculation unit header table and a cost calculation unit body table. The output data tables are cost restoration calculation unit tables, including a cost restoration calculation unit header table and a cost restoration calculation unit body table. The intermediate calculation cache data tables are intermediate cost restoration calculation table sets, including intermediate cost restoration calculation table header tables and intermediate cost restoration calculation table body tables.

[0087] As an example of this application, a data table is established for input, output, and intermediate calculation cache data. A <Cost Calculation Sheet - Header> table is created, with the following basic attribute structure:

[0088] Create a table named "Cost Calculation Sheet - Table Body" with the following basic attribute structure:

[0089] In this embodiment, the <Cost Reduction Calculation Sheet> table group is the output of cost reduction, mainly composed of two parts: the header and the body. The basic attribute structure of the <Cost Reduction Calculation Sheet - Header> table is as follows:

[0090] Create a table named "Cost Reduction Calculation Sheet - Table Body" with the following basic attribute structure:

[0091] The <Cost Reduction Calculation Intermediate Table> group table is a cache support table for cost reduction calculations, mainly composed of a table header and a table body. The basic attribute structure of the <Cost Reduction Calculation Intermediate Table - Table Header> table is as follows:

[0092] This embodiment creates a table named <Cost Reduction Calculation Intermediate Table - Table Body>, whose basic attribute structure is as follows:

[0093] S203: Receive the input parameters for cost restoration, the input parameters including the ID of the cost calculation sheet to be restored - header, and the ID of the set cost restoration range - header, and set the initial value of the maximum level to 1.

[0094] S204: Based on the ID of the cost calculation sheet header to be restored, insert the qualified cost calculation sheet header data and cost calculation sheet body data into the cost restoration calculation intermediate table header and cost restoration calculation intermediate table body, and set the [level] of the cost restoration calculation intermediate table header to the initial value of the maximum level.

[0095] S205: For the cost restoration calculation intermediate table where the [Level] is the current highest level, match and assign values ​​to its [Matching Cost Calculation Form ID] column based on the following conditions: [Cost Period] matches the [Cost Period] in the cost restoration calculation intermediate table header; [Material Information] matches the [Material Information] in the cost restoration calculation intermediate table body; and [Cost Center] is within the restoration range defined in the set cost restoration range header. If the match is successful, assign the [Source Cost Center] value to the cost restoration calculation intermediate table body data and retrieve the matched cost calculation form. The table retrieves the header data of the cost center and the source accounting organization (the cost center's corresponding accounting organization is retrieved; the latest cost price is retrieved from the header data of the matched cost calculation sheet; the reset unit price can be determined based on whether the source accounting organization is different from the header data of the intermediate cost restoration calculation table, otherwise it is not). It updates the maximum level, increments the current maximum level by 1, and inserts the matched cost calculation sheet header data and cost calculation sheet body data into the intermediate cost restoration calculation table. This matching and subsequent insertion operations are repeated until the matching fails.

[0096] S206: Loop through the cost restoration calculation intermediate table - header in order from the current maximum level down to 1. For the cost restoration calculation intermediate table - body data where the reset unit price is yes, reset its material unit price to the latest cost price and its completion cost to material unit price × completion quantity. Then, based on the reset cost restoration calculation intermediate table - body data, reset the current period completion cost (sum of completion costs for all rows in the cost restoration calculation intermediate table - body under this header) and current period cost unit price (current period completion cost ÷ current period completion quantity). After that, match the ID of the cost restoration calculation intermediate table - header with the matching cost calculation unit ID of the cost restoration calculation intermediate table - body, and update the latest cost price of the matched cost restoration calculation intermediate table - body to the current period cost unit price of the corresponding cost restoration calculation intermediate table - header.

[0097] S207: Loop through the [Level] of the cost restoration calculation intermediate table - header from the current maximum level down to 1, and match the [Matching Cost Calculation Unit ID] of the cost restoration calculation intermediate table - body with the ID of the current level's cost restoration calculation intermediate table - header; for the matched cost restoration calculation intermediate table - body row, calculate the quantity coefficient (the [Completed Quantity] of the body row ÷ the [Current Period Completed Quantity] of the current level's cost restoration calculation intermediate table - header) and the amount coefficient (the [Completed Cost] of the body row ÷ the [Current Period Completed Cost] of the current level's cost restoration calculation intermediate table - header), delete the cost restoration calculation intermediate table - body row, and insert the cost restoration calculation intermediate table - body data associated with its [Matching Cost Calculation Unit ID], and adjust the [Completed Quantity] of the inserted data according to the quantity coefficient (associated body [Completed Quantity] × quantity coefficient), and adjust the [Completed Cost] of the inserted data according to the amount coefficient (associated body [Completed Cost] × amount coefficient).

[0098] S208: Transfer the header data and body data of the cost calculation sheet-header corresponding to the ID of the cost calculation sheet to be restored in the intermediate cost restoration calculation table to the cost restoration calculation sheet group table; and assign values ​​to the rows in the cost restoration calculation sheet-body where the [Source Accounting Organization] and [Source Cost Center] are empty according to the [Accounting Organization] and [Cost Center] of the cost restoration calculation sheet-header.

[0099] 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.

[0100] The following are embodiments of a cost calculation and restoration system supporting a custom restoration range provided in this disclosure. This system and the cost calculation and restoration method supporting a custom restoration range in the above embodiments belong to the same inventive concept. For details not described in detail in the embodiments of the cost calculation and restoration system supporting a custom restoration range, please refer to the embodiments of the cost calculation and restoration method supporting a custom restoration range described above.

[0101] like Figure 3 As shown, the system includes: The configuration management module 201 is used to configure the cost restoration range, create intermediate tables for cost restoration calculations and their corresponding headers and bodies, and define input and output functions. The cost center selection range of the body is constrained by the accounting organization and range type of the header. Data table construction module 202 is used to create the input data table, output data table and intermediate calculation cache data table required for cost reduction; The parameter initialization module 203 is used to receive the header ID of the cost calculation form to be restored and the header ID of the set restoration range as input parameters, and set the initial value of the maximum level to 1. The data insertion and matching module 204 is used to insert the header and body data of the cost calculation sheet to be restored into the corresponding positions of the intermediate table and set the level to the initial maximum level. It recursively matches the intermediate table body records with the cost calculation sheet header. If the match is successful, it assigns the source information to the table body and inserts the associated data into the intermediate table. The level increases until the match fails. The cost update summary module 205 is used to cycle from high to low in the hierarchy, update the material unit price to the latest cost price for records in the intermediate table body that have their unit price reset to "yes", and recalculate the completion cost. The summary table body's completion cost updates the current period's completion cost and unit price in the corresponding table header, and then uses the table header ID to match the matching cost in the table body to calculate the unit ID to update the latest cost price in the table body. The data adjustment and inheritance module 206 is used to cycle from high to low in hierarchy, calculate the single ID by matching the table header ID with the matching cost of the table body, calculate the quantity coefficient and amount coefficient for the matched table body records, delete the original records, adjust according to the coefficients and insert the associated table body data, and inherit the source information at the same time. The data dump and fill module 207 is used to dump the data of the corresponding header ID of the cost calculation sheet to be restored in the intermediate table to the cost restoration calculation sheet, and to fill the accounting organization and cost center information corresponding to the header for rows in the table body where the source accounting organization and source cost center are empty.

[0102] like Figure 4 As shown, this application also provides an electronic device, including a display module 103, a memory 102, a processor 101, 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 cost calculation and restoration method that supports a custom restoration range.

[0103] 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 processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments described and / or claimed herein.

[0104] 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.

[0105] 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.

[0106] 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.

[0107] This application also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the cost calculation and restoration method that supports a custom restoration range.

[0108] 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 (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, 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.

[0109] In a storage medium, a readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying readable program code. This propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0110] 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 cost calculation and restoration method that supports a custom restoration range, characterized in that, The methods include: S101: Configure the cost restoration range, create an intermediate table for cost restoration calculation and the corresponding table header and body, and define input and output functions, wherein the cost center selection range of the table body is constrained by the accounting organization and range type of the table header; S102: Establish the input data table, output data table, and intermediate calculation cache data table required for cost reduction; S103: Receive the header ID of the cost calculation form to be restored and the header ID of the set restoration range as input parameters, and set the initial value of the maximum level to 1; S104: Insert the header and body data of the cost calculation sheet to be restored into the corresponding positions in the intermediate table and set the level to the initial maximum level. Recursively match the intermediate table body record with the cost calculation sheet header. If the match is successful, assign the source information to the table body and insert the associated data into the intermediate table. The level increases until the match fails. S105: Loop through the hierarchy from high to low, update the material unit price to the latest cost price for records in the intermediate table body that have their unit price reset to "yes", and recalculate the completion cost. Summarize the completion cost of the table body and update the current completion cost and unit price of the corresponding table header. Then, use the table header ID to match the matching cost of the table body to calculate the unit ID and update the latest cost price of the table body. S106: Loop through the hierarchy from high to low, calculate the single ID by matching the table body with the table header ID, calculate the quantity coefficient and amount coefficient for the matched table body records, delete the original records, adjust according to the coefficients and insert the associated table body data, and inherit the source information at the same time; S107: Transfer the data of the corresponding header ID of the cost calculation sheet to be restored in the intermediate table to the cost restoration calculation sheet. For rows in the body where the source accounting organization and source cost center are empty, fill in the accounting organization and cost center information corresponding to the header.

2. The cost calculation and restoration method supporting a custom restoration range according to claim 1, characterized in that, Step S101 specifically includes the following methods: The input function adopts a data dictionary mapping architecture. By pre-setting the association rule table between accounting organization and scope type, the enterprise-level cost center library is activated when the user selects cross-accounting organization, and when the user selects non-cross-accounting organization, the accounting organization ID and the ID to which the cost center belongs are dynamically associated through the SQL view to form a constraint expression. Based on the CSV format, the semantic mapping relationship of the exported fields is defined through XML schema to ensure that the cost data maintains business logic consistency when transmitted across systems; Table body constraints are implemented through database layer triggers. When a range type field changes, the trigger checks whether the cost center ID conforms to the current accounting organization constraint rules. Input validation employs a non-linear data verification algorithm, performing SHA-256 hash verification on the cost center number to ensure its uniqueness.

3. The cost calculation and restoration method supporting a custom restoration range according to claim 1, characterized in that, Step S104 specifically includes the following methods: Insert the header data of the cost calculation sheet to be restored into the intermediate header according to the field mapping rule table, and associate the body data with the main table ID rule; Based on the cross / non-cross accounting organization and accounting organization attributes in the restore range header, load the corresponding matching rule set from the rule configuration table; Starting from the intermediate table records at the initial level, the database cursor is used to traverse each record one by one, extracting the material information and key attributes of the cost period of the current record, and substituting them into the parsed logical expression for matching and judgment; If a match is successful, update the record's matching status to "matched" and append the current level identifier and matching rule number to the matching trajectory field.

4. The cost calculation and restoration method supporting a custom restoration range according to claim 3, characterized in that, When an intermediate table body record is successfully matched, the cost element, completed usage, and latest cost price field values ​​are extracted from the original cost calculation form table based on the matched cost calculation form table header ID and inserted into the associated fields of the intermediate table body. At the same time, the current maximum level value is incremented by 1 to generate a new level identifier, and the intermediate table header and table body corresponding to the new level are inserted into the database. The parent trajectory field of the new table body points to the matching trajectory of the parent record. When K consecutive intermediate table body records fail to match, check the matching trajectory of the previous level to identify whether there are matching branches that are not fully expanded. If there are unexpanded branches, adjust the matching conditions and then re-execute the matching; If no match is found after M consecutive backtracking attempts, terminate the recursive process and return a matching failure exception to the business layer.

5. The cost calculation and restoration method supporting a custom restoration range according to claim 1, characterized in that, Step S105 specifically includes the following methods: For the cost restoration calculation intermediate table - body data at the current highest level, match and assign its matching cost calculation single ID column according to the following conditions: the cost period is consistent with the cost period in the cost restoration calculation intermediate table - header; the material information is consistent with the material information in the cost restoration calculation intermediate table - body; and the cost center is within the restoration range limited by the set cost restoration range in the header. If a match is successful, the source cost center, source accounting organization, latest cost price, and reset unit price are assigned to the cost restoration calculation intermediate table - table body data. The maximum level is updated, and the matched cost calculation sheet - header data and cost calculation sheet - body data are inserted into the cost restoration calculation intermediate table. The matching and subsequent insertion operations are repeated until the matching fails.

6. The cost calculation and restoration method supporting a custom restoration range according to claim 1, characterized in that, Step S106 specifically includes the following methods: Based on the hierarchy, material information, and cost period fields of the intermediate table header, a composite matching rule is established with the hierarchy, material information, and cost period fields of the original cost calculation sheet header. For records that match exactly, extract the completed usage and cost from the intermediate table body and calculate the standard usage and standard cost of the single table body by combining them with the original cost; calculate the quantity coefficient and the amount coefficient; define the business weight as the final coefficient. Before deleting the original intermediate table body record, a snapshot of the current data is generated. The deletion operation and the operation of inserting a new record are wrapped in the same transaction. If the insertion fails, it will roll back to the snapshot state. The newly inserted table body record inherits the source accounting organization and source cost center information, with the inheritance priority being [priority]. After inserting the new record, the data accuracy is verified through forward and reverse validation. If the verification fails, extract the original data from the transaction snapshot and roll back by performing a reverse operation.

7. The cost calculation and restoration method supporting a custom restoration range according to claim 1, characterized in that, Step S107 specifically includes the following methods: The cost restoration calculation intermediate table - header level is cycled from the current maximum level down to 1, and the cost restoration calculation intermediate table - header ID of the current level is matched with the cost restoration calculation intermediate table - body matching cost calculation single ID. For the matched intermediate cost calculation table - body row, calculate the quantity coefficient and the amount coefficient, delete the intermediate cost calculation table - body row, and insert the intermediate cost calculation table - body data associated with the matched cost calculation single ID. Adjust the completed usage of the inserted data according to the quantity coefficient and adjust the completed cost of the inserted data according to the amount coefficient.

8. A cost calculation and restoration system that supports a custom restoration range, characterized in that, The system is used to implement the cost calculation and restoration method that supports a custom restoration range as described in any one of claims 1 to 7; The system includes: The configuration management module is used to configure the cost restoration range, create intermediate tables for cost restoration calculations and their corresponding headers and bodies, and define input and output functions. The cost center selection range of the body is constrained by the accounting organization and range type of the header. The data table construction module is used to create the input data table, output data table, and intermediate calculation cache data table required for cost reduction. The parameter initialization module is used to receive the header ID of the cost calculation form to be restored and the header ID of the set restoration range as input parameters, and sets the initial value of the maximum level to 1. The data insertion and matching module is used to insert the header and body data of the cost calculation sheet to be restored into the corresponding positions in the intermediate table and set the level to the initial maximum level. It recursively matches the intermediate table body records with the cost calculation sheet header. If the match is successful, it assigns the source information to the table body and inserts the associated data into the intermediate table. The level increases until the match fails. The cost update summary module is used to cycle from high to low in the hierarchy, update the material unit price to the latest cost price for records in the intermediate table body that have their unit price reset to "yes", and recalculate the completion cost. The summary table body's completion cost updates the current period's completion cost and unit price in the corresponding table header, and then uses the table header ID to match the matching cost in the table body to calculate the unit ID and update the latest cost price in the table body. The data adjustment and inheritance module is used to cycle from high to low hierarchy, calculate the single ID by matching the table header ID with the matching cost of the table body, calculate the quantity coefficient and amount coefficient for the matched table body records, delete the original records, adjust according to the coefficients and insert the related table body data, and inherit the source information at the same time. The data dump and fill module is used to dump the data of the corresponding header ID of the cost calculation sheet to be restored in the intermediate table to the cost restoration calculation sheet. For rows in the table body where the source accounting organization and source cost center are empty, it fills in the accounting organization and cost center information corresponding to the header.

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 cost calculation and restoration method supporting a custom restoration range as described in any one of claims 1 to 7.

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 cost calculation and restoration method supporting a custom restoration range as described in any one of claims 1 to 7.