A cross-platform power grid data conversion synchronization method and device, a terminal and a medium

By acquiring conversion rule configuration information and constructing an ID mapping table, the power grid data is synchronized in topology hierarchy order, solving the problems of low efficiency and high error rate in cross-platform power grid data synchronization of existing ETL tools, and achieving highly reliable and consistent data synchronization.

CN121636598BActive Publication Date: 2026-07-07ELECTRIC POWER RES INST CHINA SOUTHERN POWER GRID CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ELECTRIC POWER RES INST CHINA SOUTHERN POWER GRID CO LTD
Filing Date
2025-12-02
Publication Date
2026-07-07

Smart Images

  • Figure CN121636598B_ABST
    Figure CN121636598B_ABST
Patent Text Reader

Abstract

This application discloses a cross-platform power grid data conversion and synchronization method, device, terminal, and medium. First, the application synchronizes the master table in the source database to the target database based on the master-slave table dependency order information. During the synchronization process, an ID mapping table is constructed to record the mapping relationship between the first primary key ID and the second primary key ID of each piece of data in the master table. Based on the foreign key field of the slave table, combined with the foreign key mapping relationship information and the ID mapping table, the second primary key ID corresponding to the foreign key field is dynamically calculated for updating the foreign key field. Finally, after all the foreign key fields of the slave table have been updated, the data synchronization action of the slave table is executed in conjunction with the ORM data synchronization logic. This solution achieves dynamic remapping of primary key IDs by constructing an ID mapping table and updates the foreign key fields of the slave table based on the foreign key mapping relationship information, ensuring the integrity of foreign key references during cross-database synchronization. This effectively solves the problem of foreign key reference integrity caused by inconsistent primary key IDs during cross-database synchronization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of power grid big data technology, and in particular to a cross-platform power grid data conversion and synchronization method, device, terminal and medium. Background Technology

[0002] As power grid companies deepen their information technology infrastructure development, the number of business systems is increasing, such as dispatching systems and simulation computing platforms. These systems typically use different types of databases and are deployed independently, such as Oracle, MySQL, and SQL Server. To achieve data-driven business collaboration, such as synchronizing production dispatching data to the simulation computing platform for analysis, data conversion and synchronization between databases in different systems are often required.

[0003] Currently, there are various general-purpose ETL tools available on the market, which can perform basic data extraction, cleaning, and format conversion. However, in practical applications, these general-purpose ETL tools generally follow conventional database synchronization logic to perform data transformation and synchronization. But when dealing with data such as power grid data that has complex topological dependencies, there are technical problems with a high error rate in the synchronization results. For example, when synchronizing relational data, the primary key IDs of the same entity in the source database and the target database may be inconsistent. Existing ETL tools cannot automatically convert foreign key values, causing foreign key references in the table to become invalid. This requires users to manually modify the data, which is inefficient and error-prone, and cannot meet the high-reliability data synchronization requirements of relational databases between power grid business systems. Summary of the Invention

[0004] This application provides a cross-platform power grid data conversion and synchronization method, device, terminal, and medium to solve the technical problems of low efficiency and high error rate in existing cross-platform power grid data synchronization.

[0005] To address the aforementioned technical problems, the first aspect of this application provides a cross-platform power grid data conversion and synchronization method, comprising:

[0006] Obtain preset conversion rule configuration information, wherein the conversion rule configuration information includes: master-detail table dependency order information and foreign key mapping relationship information, wherein the foreign key mapping relationship information is used to determine the mapping relationship between the foreign key field in the detail table and the primary key field in the master table;

[0007] Based on the master-slave table dependency order information, the highest-level master table in the source database is determined, the master table is synchronized to the target database, and an ID mapping table is constructed. The ID mapping table is used to record the mapping relationship between the first primary key ID and the second primary key ID of each master table data. The first primary key ID is the primary key ID of the master table data in the source database, and the second primary key ID is the primary key ID of the master table data in the target database.

[0008] Based on the master-slave table dependency order information, the slave tables to be synchronized in the source database are determined in sequence. Then, based on the foreign key fields of the slave tables, combined with the foreign key mapping relationship information and the ID mapping table, the second primary key ID corresponding to the foreign key fields is determined, and the foreign key fields are updated based on the second primary key ID.

[0009] Once all foreign key fields in the slave table have been updated, the data synchronization action of the slave table is executed based on the updated foreign key fields and in conjunction with the ORM data synchronization logic.

[0010] Preferably, it further includes:

[0011] If any foreign key field in a sub-table does not match the corresponding second primary key ID, then the foreign key field is identified as abnormal data.

[0012] Preferably, the conversion rule configuration information further includes: power grid entity field mapping information, power grid dictionary mapping information, and synchronization data range filtering information, wherein the power grid dictionary mapping information is used to determine the field value mapping relationship of different databases for the same device status or device type.

[0013] Preferably, it further includes:

[0014] Based on the synchronization data range filtering information, determine the power grid entity objects covered by the synchronization data;

[0015] Based on the power grid entity objects, a search for associated objects is performed to obtain the associated device sets of each power grid entity object. Then, a topology integrity check is performed on the extended power grid topology formed by the power grid entity objects and the associated device sets. If the check result is successful, the synchronization data range filtering information is updated based on the extended power grid topology. If the check result is unsuccessful, the topology synchronization integrity is determined to be abnormal.

[0016] Preferably, it further includes:

[0017] Based on the power grid dictionary mapping information, the field values ​​in the source database are converted into field values ​​in the target database;

[0018] If a field value in the source database cannot be matched with a field value in the target database in the power grid dictionary mapping information, the record will be marked as dictionary mapping abnormal data.

[0019] Preferably, the method for constructing the master-slave table dependency order information includes:

[0020] Based on the power grid entities corresponding to each data table, the hierarchical dependency relationships between the data tables are determined according to the hierarchical topology of the power grid entities, and master-slave table dependency order information is generated based on the hierarchical dependency relationships.

[0021] Preferably, it further includes:

[0022] Abnormal data detected during the statistical synchronization process is used to generate abnormal data statistical records through the NPOI component.

[0023] A second aspect of this application provides a cross-platform power grid data conversion and synchronization device, comprising:

[0024] The configuration information acquisition unit is used to acquire preset conversion rule configuration information, wherein the conversion rule configuration information includes: master-slave table dependency order information and foreign key mapping relationship information, wherein the foreign key mapping relationship information is used to determine the mapping relationship between the foreign key field in the slave table and the primary key field in the master table;

[0025] The master table synchronization and ID mapping construction unit is used to determine the highest-level master table in the source database according to the master-slave table dependency order information, synchronize the master table to the target database, and construct an ID mapping table. The ID mapping table is used to record the mapping relationship between the first primary key ID and the second primary key ID of each master table data. The first primary key ID is the primary key ID of the master table data in the source database, and the second primary key ID is the primary key ID of the master table data in the target database.

[0026] The foreign key association unit is used to determine the slave tables to be synchronized in the source database in sequence according to the master-slave table dependency order information, and then determine the second primary key ID corresponding to the foreign key field based on the foreign key field of the slave table, combined with the foreign key mapping relationship information and the ID mapping table, and update the foreign key field based on the second primary key ID.

[0027] The batch synchronization unit for the slave table is used to perform data synchronization actions on the slave table based on the updated foreign key fields and in conjunction with ORM data synchronization logic after all foreign key fields of the slave table have been updated.

[0028] A third aspect of this application provides a cross-platform power grid data conversion and synchronization terminal, characterized in that it includes: a memory and a processor;

[0029] The memory is used to store program code, which corresponds to the cross-platform power grid data conversion and synchronization method provided in the first aspect of this application.

[0030] The processor is used to read and execute the program code to implement the cross-platform power grid data conversion and synchronization method.

[0031] The fourth aspect of this application provides a computer-readable storage medium storing program code, which is read and executed by a processor to implement the cross-platform power grid data conversion and synchronization method provided in the first aspect of this application.

[0032] As can be seen from the above technical solutions, this application has the following advantages:

[0033] The solution provided in this application first obtains conversion rule configuration information containing master-slave table dependency order information and foreign key mapping relationship information. Based on the master-slave table dependency order information, it determines the highest-level master table in the source database and synchronizes this master table to the target database. During the synchronization process, an ID mapping table is constructed to record the mapping relationship between the first primary key ID and the second primary key ID of each master table record. Then, based on the master-slave table dependency order information, the slave tables to be synchronized are determined according to the topological hierarchy. This order control ensures that when a slave table is synchronized, the master table data it depends on already exists in the target database. Based on the foreign key fields of the slave tables, combined with the foreign key mapping relationship information and the ID mapping table, the second primary key ID corresponding to the foreign key field is dynamically calculated, and the foreign key field is updated based on this second primary key ID. Finally, after all the foreign key fields of the slave tables have been updated, the data synchronization action of the slave tables is executed based on the updated foreign key fields and combined with the ORM data synchronization logic. This application, through topology-aware synchronization order control and dynamic foreign key conversion mechanism, ensures the integrity of foreign key references in the synchronized data, thereby meeting the high-reliability data synchronization requirements of the power grid business system. Attached Figure Description

[0034] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0035] Figure 1 This is a flowchart illustrating an embodiment of a cross-platform power grid data conversion and synchronization method provided in this application.

[0036] Figure 2 This is a schematic diagram of the architecture of an embodiment of a cross-platform power grid data conversion and synchronization device provided in this application.

[0037] Figure 3 This is a schematic diagram of the architecture of a cross-platform power grid data conversion and synchronization terminal embodiment provided in this application. Detailed Implementation

[0038] This application provides a cross-platform power grid data conversion and synchronization method, apparatus, terminal, and medium to solve the technical problems of low efficiency and high error rate in existing cross-platform power grid data synchronization.

[0039] To make the inventive objectives, features, and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0040] First, a detailed description of an embodiment of a cross-platform power grid data conversion and synchronization method provided in this application is as follows:

[0041] Please see Figure 1 This application provides an embodiment of a cross-platform power grid data conversion and synchronization method, the steps of which include:

[0042] Step 101: Obtain the preset conversion rule configuration information;

[0043] The conversion rule configuration information includes: master-slave table dependency order information and foreign key mapping relationship information. The foreign key mapping relationship information is used to determine the mapping relationship between the foreign key fields in the slave table and the primary key fields in the master table.

[0044] Step 102: Based on the master-slave table dependency order information, determine the highest-level master table in the source database, synchronize the master table to the target database, and build an ID mapping table;

[0045] The ID mapping table records the mapping relationship between the first primary key ID and the second primary key ID of each piece of data in the main table. The first primary key ID is the primary key ID of the main table data in the source database, and the second primary key ID is the primary key ID of the main table data in the target database.

[0046] Step 103: Based on the master-slave table dependency order information, determine the slave tables to be synchronized in the source database in sequence. Based on the foreign key fields of the slave tables, combined with the foreign key mapping relationship information and the ID mapping table, determine the second primary key ID corresponding to the foreign key fields, and update the foreign key fields based on the second primary key ID.

[0047] Step 104: After all foreign key fields in the slave table have been updated, based on the updated foreign key fields and combined with the ORM data synchronization logic, execute the data synchronization action of the slave table.

[0048] It's important to note that the conversion rule configuration information can be understood as a set of rules to guide the data synchronization process. Its main function is to define the inter-table dependencies and field mappings involved in the data synchronization process. For example, master-slave table dependency order information can be generated by analyzing the topology between data tables. Specifically, this can be done manually by specifying the dependencies between tables, or by using automated tools to scan the database schema to extract the inter-table dependencies. Furthermore, foreign key mapping information can be generated by parsing the database's foreign key constraint definitions, or it can be defined manually. Its main purpose is to clarify the correspondence between foreign key fields in the slave table and primary key fields in the master table, thus providing a basis for subsequent foreign key value conversions.

[0049] An ID mapping table can be understood as a data structure used to record the primary key ID mapping relationship between a source database and a target database. For example, this mapping table can be dynamically generated during the master table synchronization process or initialized through pre-loading. As a preferred implementation, the ID mapping table can be implemented as a hash table or a relational database table, its main purpose being to provide a unique mapping basis for dynamic conversions from foreign key fields in the table.

[0050] The update process for a foreign key field in a child table can be understood as a field value replacement operation based on mapping rules. For example, the target primary key ID can be obtained by querying the ID mapping table and then assigned to the foreign key field in the child table. Furthermore, the update process can be combined with batch processing techniques to improve synchronization efficiency.

[0051] The working principle of this application embodiment is as follows:

[0052] First, the pre-defined conversion rule configuration information is obtained, which includes master-slave table dependency order information and foreign key mapping relationship information. The master-slave table dependency order information defines the dependencies between tables based on the hierarchical topology of the power grid entities, ensuring that the synchronization order strictly follows the data topology hierarchy. The foreign key mapping relationship information clarifies the correspondence rules between foreign key fields in the slave table and primary key fields in the master table, providing a basis for subsequent dynamic conversion. This approach effectively avoids the problem of missing foreign key references caused by confused dependency relationships.

[0053] Next, based on the master-slave table dependency order information, the highest-level master table in the source database is determined, and this master table is synchronized to the target database. During the synchronization process, an ID mapping table is constructed to record the mapping relationship between the first primary key ID and the second primary key ID of each piece of data in the master table. This mapping mechanism directly addresses the problem of inconsistent primary key IDs, providing a unique conversion basis for the subsequent automatic remapping of foreign key values.

[0054] Next, based on the master-slave table dependency order information, the slave tables to be synchronized are determined according to the topological hierarchy. This order control ensures that when synchronizing a slave table, the data in its dependent master table already exists in the target database. Based on the foreign key fields of the slave tables, combined with foreign key mapping relationship information and the ID mapping table, the second primary key ID corresponding to the foreign key field is dynamically calculated, and the foreign key field is updated based on this second primary key ID. This process locates the related fields through foreign key mapping relationship information, and then uses the ID mapping table to convert the source foreign key ID to the target foreign key ID, realizing automatic remapping of foreign key values ​​and completely eliminating the problem of foreign key reference failure caused by primary key ID differences.

[0055] Once all foreign key fields in the slave table have been updated, the slave table is synchronized based on these updated fields, using ORM data synchronization logic such as SqlSugar. This ensures that data is written in accordance with the target database's specifications, while also guaranteeing the integrity of foreign key references and topological consistency of the synchronized data.

[0056] Therefore, the entire technical solution integrates the topological characteristics of power grid data into the synchronization process through a sequence-driven synchronization process and a dynamic conversion mechanism of the ID mapping table, fundamentally solving the reliability problem of synchronizing complex relational data between heterogeneous databases.

[0057] Based on the above basic embodiments, this application further proposes the following solution: when it is detected that any foreign key field in a sub-table does not match the corresponding second primary key ID, the foreign key field is determined to be abnormal data.

[0058] Specifically, anomalous data refers to data marked during cross-platform power grid data synchronization because the foreign key field cannot find a corresponding secondary primary key ID in the ID mapping table. In practical applications, the annomalous data detection mechanism can be implemented by real-time verification of the correspondence between foreign key fields in the table and the ID mapping table. The purpose is to ensure the validity of foreign key references and prevent invalid foreign keys from being incorrectly synchronized to the target database. Furthermore, the annomalous data marking mechanism can be implemented in various ways, such as by setting specific identifiers, logging, or generating reports. The aim is to provide clear evidence for subsequent centralized processing, thereby improving the efficiency and reliability of data synchronization.

[0059] In detail, during the synchronization process, the system verifies each foreign key field in the slave table based on the ID mapping table. If a foreign key field fails to match the corresponding second primary key ID, an anomaly marking process is immediately triggered, marking the foreign key field as an anomaly. This mechanism not only accurately identifies mismatches caused by missing source data, mapping errors, or topology inconsistencies, but also effectively avoids the tedious process of manual investigation. Furthermore, by combining master-slave table dependency order information and foreign key mapping relationship information, the integrity of the power grid data topology and the reliability of the synchronization process are further ensured. Simultaneously, this scheme, together with other technical features in the aforementioned cross-platform power grid data conversion and synchronization method, enhances the accurate conversion capability of dependencies between complex power grid entities, meeting the high-reliability data synchronization requirements of power grid operations.

[0060] In some embodiments, the conversion rule configuration information mentioned in the above embodiments may also include the following information: power grid entity field mapping information, power grid dictionary mapping information, and synchronization data range filtering information.

[0061] Specifically, power grid entity field mapping information refers to the structured mapping relationship of the same power grid entity fields in different databases. This can be implemented using field name lookup tables or field type conversion rules, aiming to solve data migration interruptions caused by mismatched field names or data types. Power grid dictionary mapping information can be understood as a semantic mapping mechanism, which can be implemented using predefined encoding lookup tables or dynamic mapping algorithms, aiming to ensure semantic consistency of equipment status or equipment type during cross-platform synchronization. Synchronization data range filtering information refers to a set of rules that automatically expands the range of associated devices based on initial conditions. This can be implemented using topology dependency rules or associated device search algorithms, aiming to avoid the generation of isolated data and ensure the topological integrity of synchronized data.

[0062] Based on this, this application further proposes the following technical solution: determine the power grid entity objects covered by the synchronized data according to the synchronization data range filtering information; perform associated object search based on the power grid entity objects to obtain the associated device sets of each power grid entity object; then perform topology integrity verification based on the extended power grid topology formed by the power grid entity objects and the associated device sets; if the verification result is passed, update the synchronization data range filtering information based on the extended power grid topology; if the verification result is not passed, determine that the topology synchronization integrity is abnormal.

[0063] It should be noted that the data synchronization range filtering information refers to a set of rules or conditions pre-defined by the user to limit the data synchronization range. It can be implemented using filtering dimensions such as time range, equipment type, and regional division. The purpose is to accurately locate the core dataset that needs to be synchronized and avoid the waste of resources caused by full data synchronization. Among them, the power grid entity object can be understood as a device or node in the power grid with independent physical or logical significance. Specifically, it can be a transformer, circuit breaker, or other equipment entity. In this application, it specifically refers to the object selected according to the data synchronization range filtering information, whose data needs to be synchronized from the source database to the target database. Its purpose is to serve as the starting point for expanding the synchronization range and ensure that the synchronization process focuses on key equipment.

[0064] In practical applications, the associated device set refers to the collection of all devices that have a direct topological connection with a certain power grid entity. It can be implemented through data structures such as power grid topology diagrams or adjacency lists. The purpose is to dynamically explore the dependencies between devices, thereby comprehensively covering the data of related devices.

[0065] Furthermore, the extended power grid topology can be understood as a local power grid logical model composed of power grid entities and their associated equipment sets. It can be represented using a directed acyclic graph or tree structure in graph theory, with the aim of providing a structured foundation for subsequent integrity verification.

[0066] In detail, the above scheme operates as follows: First, power grid entities are identified based on the synchronization data range filtering information. This step clarifies the core synchronization objective and avoids blindly expanding the synchronization range. Second, a search for associated objects is performed based on the power grid entities to obtain a set of associated devices. This process dynamically identifies connections between devices using power grid topology relationships, ensuring that all directly associated devices are considered. Next, an extended power grid topology is formed based on the power grid entities and the set of associated devices. This structured model provides the necessary logical support for subsequent integrity verification. Then, topology integrity verification is performed to check whether the extended topology conforms to power grid logic rules, identifying missing or contradictory data in advance, thereby avoiding foreign key reference invalidation issues after synchronization. Finally, if the verification passes, the synchronization data range filtering information is updated, and the expanded dataset is used as the new synchronization range, ensuring that the synchronization action includes all necessary associated data. If the verification fails, the topology synchronization integrity is determined to be abnormal, and incomplete datasets are intercepted in time to prevent risks caused by erroneous synchronization. Overall, this scheme solves the "isolated data" problem caused by not considering the topology dependencies of power grid entities through dynamically expanding the synchronization range and a topology-aware verification mechanism.

[0067] By combining the aforementioned technical solutions with master-slave table dependency order information and foreign key mapping information, the reliability of synchronization can be further improved. For example, when processing complex power grid data, combining master-slave table dependency order information can ensure that the synchronization order conforms to the power grid topology hierarchy, thereby avoiding data reference failures due to improper synchronization order. Simultaneously, combining foreign key mapping information can automatically convert foreign key values ​​during synchronization, ensuring the consistency of foreign key references in the slave table. This multi-layered technical integration effectively improves the accuracy and efficiency of cross-platform power grid data synchronization.

[0068] Based on the above embodiments, this application also proposes to convert field values ​​in the source database into field values ​​in the target database according to the power grid dictionary mapping information; if the field values ​​in the source database cannot be matched with the field values ​​in the target database in the power grid dictionary mapping information, the record is marked as dictionary mapping abnormal data.

[0069] Specifically, power grid dictionary mapping information refers to information used to determine the mapping relationship between field values ​​of the same equipment status or equipment type in different databases. This can be implemented using predefined mapping tables, rule engines, or machine learning-based semantic matching models, with the aim of ensuring semantic consistency during cross-platform synchronization. In practical applications, field value conversion refers to replacing field values ​​in the source database with corresponding standardized values ​​in the target database by querying the power grid dictionary mapping information; for example, mapping the "running" status code to "RUN". Furthermore, dictionary mapping anomalies refer to data records where the corresponding target value could not be found during the mapping process. These can be handled by marking specific identifiers or writing to anomaly logs, with the aim of preventing erroneous data from polluting the target database and providing a basis for subsequent manual intervention.

[0070] In detail, the above solution automates the resolution of inconsistencies in device status and type encoding during cross-platform power grid data synchronization by combining power grid dictionary mapping information and an anomaly marking mechanism. First, predefined domain-specific mapping rules are used to convert field values. These rules accurately adapt to power grid business logic, avoiding the shortcomings of general tools that cannot recognize proprietary coding systems. Second, in scenarios with missing mappings, abnormal data is automatically captured and handled by marking rather than forcibly converting or discarding it. This ensures the integrity of the target database data and provides a clear basis for manual intervention. Building on this, the solution, combined with master-slave table dependency order information and foreign key mapping relationship information, further improves the reliability of complex relational data synchronization, resolves semantic breaks caused by inconsistent encoding rules, and thus enhances the overall performance of cross-platform data synchronization.

[0071] The above technical solution effectively solves the semantic breakage problem caused by inconsistent equipment status or type encoding in cross-platform power grid data synchronization, while ensuring the integrity and traceability of synchronized data.

[0072] More specifically, this application also proposes a method for constructing master-slave table dependency order information, which includes: determining the hierarchical dependency relationship between each data table according to the power grid entity corresponding to each data table and the hierarchical topology relationship of the power grid entity, and generating master-slave table dependency order information based on the hierarchical dependency relationship.

[0073] Specifically, a power grid entity refers to a business object related to power grid equipment or structure, which can be an abstract representation of actual physical equipment such as substations, lines, and feeders. The hierarchical topology can be understood as the inherent subordinate relationships between power grid entities, such as the tree-like hierarchical structure formed by a higher-level substation and its subordinate feeders and equipment. This relationship can be extracted through the topology analysis module in the power grid management system, or it can be derived through a combination of manual configuration and automated tools. Its purpose is to ensure that the synchronization sequence strictly follows the hierarchical logic of the power grid's physical structure, avoiding sequence errors caused by ignoring topology depth.

[0074] In practical applications, hierarchical dependency refers to the rule that higher-level entity tables are processed before lower-level entity tables during the synchronization process. This can be implemented using topological sorting algorithms, such as depth-first search or breadth-first search, to ensure the correctness of the synchronization sequence. The process of generating master-slave table dependency order information based on hierarchical dependency can be modeled using graph theory, treating power grid entities as nodes and the hierarchical relationships between entities as edges, thus forming a directed acyclic graph. Finally, dependency order information is generated through topological sorting.

[0075] Specifically, the above technical solution achieves automated construction of master-slave table dependency order information by combining the hierarchical topology of power grid entities. First, based on the power grid entities corresponding to each data table, the database tables are mapped to actual power grid objects, ensuring that dependency determination is based on business semantics rather than purely technical foreign key constraints. On this basis, according to the hierarchical topology of the power grid entities, the synchronization order logic of the data tables is automatically derived using the inherent tree-like structure of the power grid. This process ensures that higher-level entity tables are processed first, providing a correct temporal basis for the construction of the ID mapping table. Simultaneously, the generated master-slave table dependency order information directly drives the synchronization engine to execute operations in topological order, making foreign key field updates strictly dependent on the primary key ID mapping result, effectively solving the reference breakage problem caused by inconsistent primary key IDs between heterogeneous databases.

[0076] The above technical solution not only solves the problem of insufficient integration of the power grid entity hierarchical topology during the construction process relying on sequential information, but also fundamentally ensures the integrity and consistency of power grid topology data during cross-platform synchronization. Furthermore, this solution, combined with steps such as obtaining preset conversion rule configuration information, synchronizing the master table to the target database and constructing an ID mapping table, and synchronizing data from slave tables, forms a complete cross-platform power grid data conversion and synchronization mechanism, improving the reliability and efficiency of synchronization.

[0077] Furthermore, this application also proposes to generate statistical records of abnormal data detected during the statistical synchronization process using the NPOI component.

[0078] Specifically, statistical anomaly data in the synchronization process refers to the process of centrally aggregating scattered anomalies in the power grid data conversion and synchronization flow, based on identified anomalies such as mismatched foreign key fields or failed dictionary mappings. In practical applications, this statistical process can be implemented by traversing log files, analyzing database status markers, or monitoring the return values ​​of the synchronization interface in real time. The goal is to ensure that all anomaly data is completely captured and serves as a reliable data source for generating subsequent structured reports. The NPOI component is an open-source library that supports reading and writing Microsoft Office format files. Specifically, its Excel file processing capabilities can be used to output statistical results in tabular form. The purpose of choosing this component is to provide multi-dimensional sorting, filtering, and export functions, enabling maintenance personnel to quickly grasp the types, distribution, and quantities of anomalies without requiring technical background.

[0079] In detail, the above solution achieves centralized management and visualization of abnormal data through systematic handling of issues such as foreign key mismatches or dictionary mapping failures. First, based on the abnormal information identified during the synchronization process, this information is categorized and summarized according to preset rules to form a unified abnormal data set. Second, the NPOI component is used to convert the summarized abnormal data into intuitive and easy-to-read Excel spreadsheet records. This tabular recording method not only simplifies the problem analysis process but also avoids the complexity of traditional log queries. Furthermore, combined with the abnormal data detection mechanism in the aforementioned cross-platform power grid data conversion and synchronization method, the efficiency of maintenance personnel in locating the root cause of synchronization faults can be significantly improved, thereby effectively compensating for the lack of abnormal information management during the synchronization process. In this way, it is ensured that power grid data synchronization anomalies can be responded to and handled in a timely manner, greatly improving the reliability and maintainability of the synchronization process.

[0080] The above is a detailed description of an embodiment of a cross-platform power grid data conversion and synchronization method provided in this application. The following is a detailed description of related embodiments of a cross-platform power grid data conversion and synchronization device, terminal, and storage medium provided in this application.

[0081] Please see Figure 2 This application provides a cross-platform power grid data conversion and synchronization device, comprising:

[0082] The configuration information acquisition unit 201 is used to acquire preset conversion rule configuration information, wherein the conversion rule configuration information includes: master-detail table dependency order information and foreign key mapping relationship information, and the foreign key mapping relationship information is used to determine the mapping relationship between the foreign key field in the sub-table and the primary key field in the master table;

[0083] The master table synchronization and ID mapping construction unit 202 is used to determine the highest-level master table in the source database according to the master-slave table dependency order information, synchronize the master table to the target database, and construct an ID mapping table. The ID mapping table is used to record the mapping relationship between the first primary key ID and the second primary key ID of each master table data. The first primary key ID is the primary key ID of the master table data in the source database, and the second primary key ID is the primary key ID of the master table data in the target database.

[0084] Foreign key association unit 203 is used to determine the slave tables to be synchronized in the source database in order according to the master-slave table dependency order information, and then determine the second primary key ID corresponding to the foreign key field based on the foreign key field of the slave table, combined with the foreign key mapping relationship information and the ID mapping table, and update the foreign key field based on the second primary key ID.

[0085] The batch synchronization unit 204 is used to perform data synchronization actions on the slave table based on the updated foreign key fields and in conjunction with the ORM data synchronization logic after all foreign key fields of the slave table have been updated.

[0086] This embodiment solves the problem of foreign key reference failure caused by inconsistent primary key IDs during cross-platform power grid data synchronization by dynamically mapping the dependency order information of master and slave tables with foreign key mapping relationship information and introducing an ID mapping table as the core conversion basis. This ensures the integrity of foreign key references and topology consistency after synchronization. Specifically, this technical solution avoids synchronization errors caused by chaotic dependencies by strictly adhering to the hierarchical topology of the power grid entity to define the synchronization order. Simultaneously, the ID mapping table enables a unique mapping of primary key IDs between the source and target databases, providing a reliable foundation for the dynamic remapping of foreign key fields in slave tables, thus effectively preventing foreign key reference failure.

[0087] In another implementation, such as Figure 3As shown, this application also discloses a cross-platform power grid data conversion and synchronization terminal, including: a memory 33 and a processor 31, which can be connected to each other via a communication bus 34; the memory 33 is used to store program code, which corresponds to the cross-platform power grid data conversion and synchronization method; the processor 31 is used to read and execute the program code to implement the cross-platform power grid data conversion and synchronization method.

[0088] This embodiment achieves automated handling of primary key ID inconsistencies during cross-platform data synchronization of power grid data by co-designing the memory and processor, and combining the master-slave table dependency order processing logic, ID mapping table construction mechanism, and foreign key mapping relationship information embedded in the program code. This design ensures the integrity of foreign key references and significantly improves the reliability of data synchronization in heterogeneous database environments. Furthermore, by introducing a topology-hierarchical synchronization order control and dynamic foreign key conversion mechanism, it overcomes the technical bottleneck of existing general-purpose ETL tools' inability to automatically adapt to primary key ID differences, thus meeting the high-reliability data synchronization requirements of power grid business systems.

[0089] In another embodiment, this application also discloses a computer-readable storage medium storing program code, which is used to be read and executed by a processor to implement the aforementioned cross-platform power grid data conversion and synchronization method.

[0090] In practical applications, this computer-readable storage medium serves as the physical carrier of the program code, ensuring that the method logic can be stably deployed and invoked on different computing devices, avoiding execution interruptions caused by environmental differences. The stored program code fully encapsulates core logic such as obtaining conversion rule configuration information, determining the master-slave table dependency order, constructing an ID mapping table, and updating foreign key fields. This enables the automatic identification of the correspondence between the foreign key fields of the slave table and the primary key fields of the master table based on the foreign key mapping relationship information during the synchronization process, thereby dynamically adjusting the foreign key values. When the program code is read and executed by the processor, the data tables are processed according to the topological hierarchy order based on the master-slave table dependency order information, ensuring that the ID mapping table is constructed immediately after synchronizing the highest-level master table, and the foreign key fields of the slave table are updated based on this mapping table. This effectively solves the reference invalidation problem caused by the inconsistency of primary key IDs between the source database and the target database. By implementing the above method, this solution automatically completes ID remapping and foreign key conversion without manual intervention, ensuring the integrity of the power grid data topology, preventing the generation of isolated data, and meeting the requirements for high-reliability data synchronization between heterogeneous databases.

[0091] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the terminals, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0092] In the several embodiments provided in this application, it should be understood that the disclosed terminals, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or units through some interfaces, and may be electrical, mechanical, or other forms.

[0093] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0094] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0095] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0096] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0097] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0098] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A cross-platform power grid data conversion and synchronization method, characterized in that, include: Obtain preset conversion rule configuration information, wherein the conversion rule configuration information includes: master-slave table dependency order information, synchronization data range filtering information, and foreign key mapping relationship information. The foreign key mapping relationship information is used to determine the mapping relationship between the foreign key field in the slave table and the primary key field in the master table. The construction method of the master-slave table dependency order information includes: determining the hierarchical dependency relationship between the data tables according to the power grid entity corresponding to each data table and the hierarchical topology relationship of the power grid entity, and generating master-slave table dependency order information based on the hierarchical dependency relationship. Based on the synchronization data range filtering information, determine the power grid entity objects covered by the synchronization data; Based on the power grid entity objects, a search for associated objects is performed to obtain the associated device sets of each power grid entity object. Then, a topology integrity check is performed on the extended power grid topology formed by the power grid entity objects and the associated device sets. If the check result is passed, the synchronization data range filtering information is updated based on the extended power grid topology. If the check result is not passed, the topology synchronization integrity is determined to be abnormal. Based on the master-slave table dependency order information, the highest-level master table in the source database is determined, the master table is synchronized to the target database, and an ID mapping table is constructed. The ID mapping table is used to record the mapping relationship between the first primary key ID and the second primary key ID of each master table data. The first primary key ID is the primary key ID of the master table data in the source database, and the second primary key ID is the primary key ID of the master table data in the target database. Based on the master-slave table dependency order information, the slave tables to be synchronized in the source database are determined in sequence. Then, based on the foreign key fields of the slave tables, combined with the foreign key mapping relationship information and the ID mapping table, the second primary key ID corresponding to the foreign key fields is determined, and the foreign key fields are updated based on the second primary key ID. Once all foreign key fields in the slave table have been updated, the data synchronization action of the slave table is executed based on the updated foreign key fields and in conjunction with the ORM data synchronization logic.

2. The cross-platform power grid data conversion and synchronization method according to claim 1, characterized in that, Also includes: If any foreign key field in a sub-table does not match the corresponding second primary key ID, then the foreign key field is identified as abnormal data.

3. The cross-platform power grid data conversion and synchronization method according to claim 1, characterized in that, The conversion rule configuration information also includes: power grid entity field mapping information and power grid dictionary mapping information, wherein the power grid dictionary mapping information is used to determine the field value mapping relationship of different databases for the same device status or device type.

4. The cross-platform power grid data conversion and synchronization method according to claim 3, characterized in that, Also includes: Based on the power grid dictionary mapping information, the field values ​​in the source database are converted into field values ​​in the target database; If a field value in the source database cannot be matched with a field value in the target database in the power grid dictionary mapping information, the field value in the source database will be marked as dictionary mapping abnormal data.

5. A cross-platform power grid data conversion and synchronization method according to any one of claims 2 to 4, characterized in that, Also includes: Abnormal data detected during the statistical synchronization process is used to generate abnormal data statistical records through the NPOI component.

6. A cross-platform power grid data conversion and synchronization device, characterized in that, include: The configuration information acquisition unit is used to acquire preset conversion rule configuration information, wherein the conversion rule configuration information includes: master-slave table dependency order information, synchronization data range filtering information, and foreign key mapping relationship information. The foreign key mapping relationship information is used to determine the mapping relationship between the foreign key field in the slave table and the primary key field in the master table. The construction method of the master-slave table dependency order information includes: determining the hierarchical dependency relationship between the data tables according to the power grid entity corresponding to each data table and the hierarchical topology relationship of the power grid entity, and generating master-slave table dependency order information based on the hierarchical dependency relationship. Based on the synchronization data range filtering information, determine the power grid entity objects covered by the synchronization data; Based on the power grid entity objects, a search for associated objects is performed to obtain the associated device sets of each power grid entity object. Then, a topology integrity check is performed on the extended power grid topology formed by the power grid entity objects and the associated device sets. If the check result is passed, the synchronization data range filtering information is updated based on the extended power grid topology. If the check result is not passed, the topology synchronization integrity is determined to be abnormal. The master table synchronization and ID mapping construction unit is used to determine the highest-level master table in the source database according to the master-slave table dependency order information, synchronize the master table to the target database, and construct an ID mapping table. The ID mapping table is used to record the mapping relationship between the first primary key ID and the second primary key ID of each master table data. The first primary key ID is the primary key ID of the master table data in the source database, and the second primary key ID is the primary key ID of the master table data in the target database. The foreign key association unit is used to determine the slave tables to be synchronized in the source database in sequence according to the master-slave table dependency order information, and then determine the second primary key ID corresponding to the foreign key field based on the foreign key field of the slave table, combined with the foreign key mapping relationship information and the ID mapping table, and update the foreign key field based on the second primary key ID. The batch synchronization unit for the slave table is used to perform data synchronization actions on the slave table based on the updated foreign key fields and in conjunction with ORM data synchronization logic after all foreign key fields of the slave table have been updated.

7. A cross-platform power grid data conversion and synchronization terminal, characterized in that, include: Memory and processor; The memory is used to store program code, which corresponds to the cross-platform power grid data conversion and synchronization method as described in any one of claims 1 to 5; The processor is used to read and execute the program code to implement the cross-platform power grid data conversion and synchronization method.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium contains program code that is read and executed by a processor to implement the cross-platform power grid data conversion and synchronization method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data synchronization method and device based on update time and primary key and medium

    CN114741401A

  • Enhanced database structure configuration

    US20090300037A1