Interface data conversion method and system, electronic equipment and storage medium
By identifying and converting interface data, using enumeration mapping relationship tables and conversion scripts, the API conversion framework has solved the problems of high configuration and maintenance costs and slow response speed, and achieved efficient conversion of interface data and the absence of multiple company interfaces seam butt.
Patent Information
- Application Number
- CN202411516320.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-07
AI Technical Summary
The prior art realizes the conversion of interface data through the API conversion framework, which has problems such as high configuration and maintenance costs and slow response speed.
Provides a method of converting interface data, including receiving interface data of the current interface, identifying the data format and converting the data format into the required format of the target interface through an enumeration mapping relationship table, and preprocessing and conversion based on the conversion script.
It realizes seamless docking with multiple company interfaces, simplifies data conversion workload, enhances system scalability and maintenance, reduces configuration and maintenance costs, and improves response speed.
Smart Images

Figure CN119396916A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, system, electronic device and storage medium for converting interface data. Background Art
[0002] In the insurance intermediary industry, intermediary companies are faced with the need to exchange data and conduct business operations with multiple insurance companies. However, the API (Application Programming Interface) interfaces provided by different insurance companies have significant differences in parameter settings and technical specifications, which poses a challenge to the technical connection of intermediary companies. Traditional solutions often rely on customized coding and a large amount of manual configuration, which not only increases the burden on developers, but also increases the cost of subsequent maintenance. Especially when faced with frequent changes in API interfaces, traditional integration methods require recompiling and deploying the entire system, which further affects maintenance efficiency.
[0003] In the related technologies, the conversion of interface data is generally achieved through API conversion frameworks (including Apache Camel, Spring Integration, etc.). Although a certain degree of universal conversion mechanism is provided, a lot of configuration and coding are required in actual applications to adapt to the API interfaces of different insurance companies, which increases the burden and workload of developers and also increases the cost of subsequent maintenance. In addition, the conversion logic of these frameworks is relatively complex, so its conversion and adaptation capabilities are relatively limited, the response speed is slow, and it cannot meet the real-time requirements. Summary of the invention
[0004] The present application provides an interface data conversion method, system, electronic device and storage medium to solve the problems of high configuration and maintenance costs and slow response speed in the related art of implementing interface data conversion through an API conversion framework.
[0005] The first aspect of the present application provides a method for converting interface data, comprising the following steps: receiving interface data of a current interface; identifying a first data format of the interface data and a docking target interface, and enumerating and mapping the first data format into a second data format of the target interface; and converting the interface data of the current interface based on the second data format to match the target interface.
[0006] Optionally, before enumerating and mapping the first data format to the second data format of the target interface, it includes: obtaining an enumeration mapping relationship table between the first data format of the current interface and the second data format of the target interface; and determining the second data format of the target interface according to the first data format of the current interface and the enumeration mapping relationship table.
[0007] Optionally, obtaining an enumeration mapping relationship table between a first data format of a current interface and a second data format of a target interface includes: obtaining the field meaning of each field in the first data format and the field meaning of each field in the second data format; identifying fields having the same field meaning in the first data format and the second data format; and establishing an enumeration mapping relationship table based on the fields having the same field meaning.
[0008] Optionally, converting the interface data of the current interface based on the second data format includes: creating a conversion script; preprocessing the interface data of the current interface based on the conversion script and the second data format, and converting the processed interface data.
[0009] The second aspect of the present application provides an interface data conversion system, including: an interface management module, used to manage and maintain interface information of different companies; a data conversion module, used to convert the received interface data of the current interface into a data format that meets the requirements of the target interface; and an interface adaptation module, used to send the converted data to the corresponding target interface.
[0010] Optionally, the interface management module provides interface information query and interface operation functions.
[0011] Optionally, the data conversion module implements conversion logic through a conversion script to adapt to data formats of different company interfaces.
[0012] Optionally, the interface data conversion system further includes: a data processing and analysis module, which is used to process and analyze the interface data according to the business rules of the target interface.
[0013] The third aspect of the present application provides an electronic device, 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 a method for converting interface data as described in the above embodiment.
[0014] The fourth aspect of the present application provides a computer-readable storage medium on which a computer program or instruction is stored. When the computer program or instruction is executed, it is used to implement the interface data conversion method as described in the above embodiment.
[0015] Therefore, this application has at least the following beneficial effects:
[0016] The embodiment of the present application can convert the data of the current interface into a format adapted to the docking target interface when receiving the data of the current interface based on different target interface requirements, thereby achieving seamless docking with multiple company interfaces, which not only simplifies the workload of data conversion, but also enhances the scalability and maintainability of the system. Thus, the problems of high configuration and maintenance costs and slow response speed in the related art of implementing interface data conversion through an API conversion framework are solved.
[0017] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0019] Figure 1 A flowchart of a method for converting interface data provided according to an embodiment of the present application;
[0020] Figure 2 is a block diagram of a system for converting interface data according to an embodiment of the present application;
[0021] Figure 3 Schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0022] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0023] The following describes the interface data conversion method, system, electronic device and storage medium of the embodiment of the present application with reference to the accompanying drawings. In response to the problems mentioned in the above background technology, the present application provides an interface data conversion method, in which, based on different target interface requirements, when receiving the data of the current interface, the data of the current interface can be converted into a format adapted to the docked target interface, thereby achieving seamless docking with multiple company interfaces, which not only simplifies the workload of data conversion, but also enhances the scalability and maintainability of the system. As a result, the problem of high configuration and maintenance costs and slow response speed in the related art of realizing the conversion of interface data by means of an API conversion framework is solved.
[0024] Specifically, Figure 1A flowchart of a method for converting interface data provided in an embodiment of the present application.
[0025] like Figure 1 As shown, the method for converting the interface data includes the following steps:
[0026] In step S101, interface data of the current interface is received.
[0027] In an embodiment of the present application, the current interface refers to an API interface of a company that is triggered by a user or a system and requires interaction. The embodiment of the present application receives interface data of the current interface and performs preliminary data verification and preprocessing to ensure the accuracy and completeness of the data, thereby avoiding invalid or erroneous data from entering subsequent processing links.
[0028] In step S102, a first data format of the interface data and a docking target interface are identified, and the first data format is enumerated and mapped into a second data format of the target interface.
[0029] It is understandable that different insurance companies may use different data formats (such as JSON, XML, etc.). The embodiment of the present application can load the corresponding conversion scripts through the data conversion module, and use the Nashorn script engine to execute these scripts to convert the received first data format (such as the JSON format standardized by the intermediary company) into a second data format required to adapt to the target insurance company's API interface (such as the XML format that may be required by some insurance companies).
[0030] In one embodiment of the present application, before enumerating and mapping the first data format to the second data format of the target interface, it includes: obtaining an enumeration mapping relationship table between the first data format of the current interface and the second data format of the target interface; determining the second data format of the target interface according to the first data format of the current interface and the enumeration mapping relationship table.
[0031] The enumerated mapping relationship table includes the corresponding relationship between the source data format (first data format) and the target data format (second data format), and is used to guide the data conversion module on how to convert the source data into a data format that meets the requirements of the target interface.
[0032] During the actual execution process, the embodiment of the present application obtains an enumeration mapping relationship table between the first data format of the current interface and the second data format of the target interface. This mapping relationship table is pre-set and contains the correspondence between the two sets of data formats, so that the system can decide how to convert the data format based on this table. If there is an enumeration field in the data format of the intermediary company to represent the status, there may be values such as "active", "inactive", etc., and the API interface of the target insurance company may require corresponding values such as "1" for "active" and "0" for "inactive". In this case, the enumeration mapping relationship table will contain mapping relationships such as "active":"1","inactive":"0".
[0033] Furthermore, the embodiment of the present application can determine the second data format of the target interface data based on the enumeration mapping relationship table and the first data format of the current interface data. This means that the system will convert the field values in the current interface data into the format expected by the target interface according to the conversion rules defined in the mapping table. In this way, the data of the intermediary company can be automatically converted into a data format that conforms to the API interface of the target insurance company, ensuring that the data can be correctly understood and processed. This not only reduces the need for manual intervention, but also improves the accuracy and efficiency of data processing.
[0034] In one embodiment of the present application, an enumeration mapping relationship table between a first data format of a current interface and a second data format of a target interface is obtained, including: obtaining the field meaning of each field in the first data format and the field meaning of each field in the second data format; identifying fields with the same field meaning in the first data format and the second data format; and establishing an enumeration mapping relationship table based on the fields with the same field meaning.
[0035] It is understandable that the embodiment of the present application first obtains the field meaning of each field in the first data format and the field meaning of each field in the second data format. These meanings are usually defined in the interface document or data dictionary, which describes the meaning and function of each field. For example, the field "PolicyID" may mean "policy number" in the first data format, and also has a similar meaning in the second data format. By comparing the meanings of the fields in the two data formats, fields with the same meaning are identified. For example, if "PolicyID" in the first data format and "PolicyNo" in the second data format both mean "policy number", then these two fields can be considered to have the same meaning.
[0036] After identifying fields with the same meaning, an embodiment of the present application can establish an enumeration mapping relationship table based on these fields. The enumeration mapping relationship table records the correspondence between the field values in the first data format and the field values in the second data format. For example, if the enumeration value "active" in the first data format represents an active state, and the enumeration value "1" in the second data format also represents the same state, the mapping relationship of "active"->"1" will be recorded in the mapping table. This ensures that during the data conversion process, the field values in the first data format are correctly mapped to the corresponding field values in the second data format, ensuring the consistency and accuracy of the data.
[0037] In step S103, the interface data of the current interface is converted based on the second data format to match the target interface.
[0038] In one embodiment of the present application, converting the interface data of the current interface based on the second data format includes: creating a conversion script; preprocessing the interface data of the current interface based on the conversion script and the second data format, and converting the processed interface data.
[0039] The embodiment of the present application can create a conversion script (such as a Nashorn script) to achieve data conversion for API interfaces of different insurance companies.
[0040] Specifically, the embodiment of the present application standardizes the field content of the interface, and the intermediary company passes it into the system with standardized fields. The script written is loaded and parsed through the JAVA service, and the data returned by the API interface is read and processed. Enumeration mapping is performed between the intermediary company and the insurance company, and different fields with the same meaning are mapped to each other, and the first data format of the interface data is adjusted to the second data format required by the insurance company.
[0041] In the actual execution process, the embodiment of the present application needs to check whether the input data is complete, whether it contains all the required fields, and whether the field values conform to the expected format. For example, any unnecessary data items are removed or erroneous data items are corrected to ensure that only clean and valid data enters the next step of conversion. For data items that are missing but required by the target interface, the system may fill in default values or calculated values according to the rules.
[0042] Furthermore, after completing the preprocessing, the embodiment of the present application can load the conversion script into the Java environment (such as using the Nashorn engine), run the conversion script, process the data according to the logic defined in the script, and after the script is executed, output the data that meets the requirements of the second data format and is in a format that the target interface can understand and process, so that the tasks of data conversion and interface adaptation can be completed more efficiently. This can greatly reduce the amount of code that developers need to write and maintain, and improve the performance and response speed of the entire system.
[0043] According to the interface data conversion method proposed in the embodiment of the present application, based on different target interface requirements, when data of the current interface is received, the data of the current interface can be converted into a format adapted to the docking target interface, thereby achieving seamless docking with multiple company interfaces, which not only simplifies the workload of data conversion, but also enhances the scalability and maintainability of the system.
[0044] Next, the interface data conversion system proposed in accordance with the embodiment of the present application is described with reference to the accompanying drawings.
[0045] Figure 2 It is a block diagram of the interface data conversion system of the embodiment of the present application.
[0046] like Figure 2 As shown, the interface data conversion system 10 includes: an interface management module 101 , a data conversion module 102 and an interface adaptation module 103 .
[0047] Among them, the interface management module 101 is used to manage and maintain the interface information of different companies; the data conversion module 102 is used to convert the received interface data of the current interface into a data format that meets the requirements of the target interface; the interface adaptation module 103 is used to send the converted data to the corresponding target interface.
[0048] Specifically, the interface management module 101 is used to manage the API interface information of different insurance companies. It is classified according to different companies, and provides a unified interface management interface for the development of interfaces, which can easily add, modify and delete API interface information. Its main function is to maintain and manage the database of company interface information, and provide query and operation interfaces of interface information for use by other modules. The data conversion module 102 realizes the conversion of API interface data of different insurance companies by loading and parsing scripts and using the Nashorn script engine. It is responsible for converting the original data into the data format required by the insurance company's API interface. And provide the converted data to the interface adapter module 103 for use. The interface adapter module 103 is responsible for converting the data of the intermediary company into the data required by the target insurance company interface and sending it to the corresponding API interface. Through the relevant connection with the API interface management module, the address and parameter specifications of the target interface are obtained.
[0049] Furthermore, after completing the conversion of the data format, the embodiment of the present application can also generate a form suitable for user viewing, and the user obtains the processed result data through an interface or other means, and views and analyzes it.
[0050] It should be noted that the association and connection between the various modules of the interface data conversion system of the embodiment of the present application is carried out through the interface. The data conversion module 102 provides the converted data to the interface adapter module 103, and the interface adapter module 103 sends the data to the target interface according to the address and parameter specifications of the target interface. The API interface management module 101 provides the necessary interface information for the data conversion module and the interface adapter module.
[0051] In one embodiment of the present application, the data conversion module 102 implements conversion logic through a conversion script to adapt to the data formats of different company interfaces.
[0052] In one embodiment of the present application, the interface data conversion system 10 further includes: a data processing and analysis module for processing and analyzing the interface data according to the business rules of the target interface.
[0053] Specifically, there are usually several ways to handle it according to the insurance company's business rules:
[0054] 1) Encrypt and sign the requested parameters, and decrypt and verify the returned parameters. Usually there are several forms of encryption, such as symmetric encryption, non-complex encryption, and MD5 encryption.
[0055] 2) Verify the format and content of the incoming data, and verify the incorrect format and incorrect content.
[0056] 3) Execute different strategies for the incoming data, implement different interface distribution according to the incoming content and the company's requirements, and be compatible with different companies using different interfaces but the same processing logic.
[0057] For example, by verifying the ID, we can determine whether there are repeated requests to the interface, thereby achieving the idempotence of the interface. By processing data asynchronously through asynchronous threads, customers do not need to wait online for real-time results, but only need to wait for notification of processing results after the processing is completed.
[0058] It should be noted that the interface management module 101 of the embodiment of the present application can be different according to the specific implementation situation, for example, different data structures, implementation methods, security policies, etc. can be used. Therefore, different API interface management modules can be selected to implement similar data processing processes. For example, through a format conversion tool, the JSON format of the intermediary company is converted into the XML format required by the insurance company. Through different request tools, such as HTTP, WEBSERVICE and other tools, the message data is transmitted to the insurance company. Through different encryption tools, such as AES, DES and other encryption tool classes, the encryption of the request message and the decryption of the return message are realized. The data processing and analysis module can be different according to different implementation schemes, for example, different data processing algorithms can be used. Therefore, different data processing and analysis modules can be selected to implement similar data processing processes. For example, for interfaces that require a long processing time, distributed processing is performed by implementing multi-threading, which greatly reduces the timeliness of processing data.
[0059] FIG3 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device may include:
[0060] A memory 301 , a processor 302 , and a computer program stored in the memory 301 and executable on the processor 302 .
[0061] When the processor 302 executes the program, the interface data conversion method provided in the above embodiment is implemented.
[0062] Furthermore, the electronic device further comprises:
[0063] The communication interface 303 is used for communication between the memory 301 and the processor 302 .
[0064] The memory 301 is used to store computer programs that can be run on the processor 302 .
[0065] The memory 301 may include a high-speed RAM (Random Access Memory) memory, and may also include a non-volatile memory, such as at least one disk memory.
[0066] If the memory 301, the processor 302 and the communication interface 303 are implemented independently, the communication interface 303, the memory 301 and the processor 302 can be connected to each other through a bus and communicate with each other. The bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0067] Optionally, in a specific implementation, if the memory 301, the processor 302 and the communication interface 303 are integrated on a chip, the memory 301, the processor 302 and the communication interface 303 can communicate with each other through an internal interface.
[0068] The processor 302 may be a CPU (Central Processing Unit), or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application.
[0069] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned method for converting interface data is implemented.
[0070] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms are not necessarily directed to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or N embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0071] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, "N" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0072] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0073] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiment, the N steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array, a field programmable gate array, etc.
[0074] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0075] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for converting interface data, characterized in that: The following steps are involved: Receive interface data of the current interface; Identify a first data format of the interface data and a docking target interface, and enumerate and map the first data format into a second data format of the target interface; The interface data of the current interface is converted based on the second data format to match the target interface.
2. The method for converting interface data according to claim 1, characterized in that: Before enumerating and mapping the first data format into the second data format of the target interface, the method includes: Obtain an enumerated mapping relationship table between a first data format of a current interface and a second data format of a target interface; The second data format of the target interface is determined according to the first data format of the current interface and the enumeration mapping relationship table.
3. The method for converting interface data according to claim 2, characterized in that: The step of obtaining an enumerated mapping relationship table between a first data format of a current interface and a second data format of a target interface includes: Acquire the field meaning of each field in the first data format and the field meaning of each field in the second data format; Identify fields in the first data format and in the second data format that have the same field meaning; The enumeration mapping relationship table is established according to the fields with the same field meaning.
4. The method for converting interface data according to claim 1, characterized in that: The converting the interface data of the current interface based on the second data format includes: Create conversion scripts; The interface data of the current interface is preprocessed based on the conversion script and the second data format, and the processed interface data is converted.
5. A conversion system for interface data, characterized in that: include: Interface management module, used to manage and maintain interface information of different companies; A data conversion module, used to convert the received interface data of the current interface into a data format that meets the requirements of the target interface; The interface adapter module is used to send the converted data to the corresponding target interface.
6. The interface data conversion system according to claim 5, characterized in that: The interface management module provides the interface information query and interface operation functions.
7. The interface data conversion system according to claim 5, characterized in that: The data conversion module implements conversion logic through conversion scripts to adapt to the data formats of different company interfaces.
8. The interface data conversion system according to claim 5, characterized in that: Also includes: The data processing and analysis module is used to process and analyze the interface data according to the business rules of the target interface.
9. An electronic device, characterized in that: include: 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 method for converting interface data as described in any one of claims 1 to 4.
10. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed, the method for converting interface data described in any one of claims 1 to 4 is implemented.
Citation Information
Cited By
Interface mapping method and electronic equipment
CN121255501A