CN111970267B - Data protocol conversion method and device, electronic equipment and storage medium - Google Patents

Data protocol conversion method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111970267B
CN111970267B CN202010811812.XA CN202010811812A CN111970267B CN 111970267 B CN111970267 B CN 111970267B CN 202010811812 A CN202010811812 A CN 202010811812A CN 111970267 B CN111970267 B CN 111970267B
Authority
CN
China
Prior art keywords
data
target
field
format
annotation
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010811812.XA
Other languages
Chinese (zh)
Other versions
CN111970267A (en
Inventor
张宾
孙喜民
周晶
刘坤
王春风
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
State Grid Digital Technology Holdings Co ltd
State Grid E Commerce Technology Co Ltd
Original Assignee
State Grid E Commerce Co Ltd
State Grid E Commerce Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by State Grid E Commerce Co Ltd, State Grid E Commerce Technology Co Ltd filed Critical State Grid E Commerce Co Ltd
Priority to CN202010811812.XA priority Critical patent/CN111970267B/en
Publication of CN111970267A publication Critical patent/CN111970267A/en
Application granted granted Critical
Publication of CN111970267B publication Critical patent/CN111970267B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/08Protocols for interworking; Protocol conversion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/03Protocol definition or specification 
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Communication Control (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the application provides a data protocol conversion method, a data protocol conversion device, electronic equipment and a storage medium, and data generated by a first system according to a target data protocol format is determined, wherein the target data protocol format is generated by annotating a field of an original data protocol format of the first system; acquiring a target field carrying annotation in data; determining a preset target data format corresponding to the annotation carried by the target field, wherein the target data format represents the data format requirement of the second system on the target field; converting the data format of the data information of the target field in the data into a target data format to generate target data; and sending the target data to a second system, wherein the second system is a shared platform, and the first system is different from the second system. On the basis of achieving the purpose that the first system is accessed to the sharing platform, the development time and the development cost of the data protocol conversion tool are reduced, and the usability and the expandability of the data protocol conversion tool are improved.

Description

Data protocol conversion method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of protocol conversion technologies, and in particular, to a data protocol conversion method and apparatus, an electronic device, and a storage medium.
Background
At present, the application of the sharing platform is more and more extensive, and more systems begin to access the sharing platform and use the convenient functions provided by the sharing platform. The data protocol format of the system is often different from that of the sharing platform, and if the system is to access the sharing platform, a data protocol conversion tool needs to be constructed to convert the data protocol of the system into the data protocol of the sharing platform.
Because data protocols of different systems are different, each system needs to separately construct a data protocol conversion tool, the data protocol conversion tools of the systems cannot be used universally, but the functions of the data protocol conversion tools are all the same and different, and a large amount of codes are repeated.
Each system needs a lot of time to construct a data protocol conversion tool, and problems are easy to occur; moreover, when the data protocol of the shared platform has new content, each system also needs to update its own data protocol conversion tool, which results in a large amount of development time and development cost, and the usability and expandability of the data protocol conversion tool are not strong.
Disclosure of Invention
In view of this, the present application provides a data protocol conversion method, an apparatus, an electronic device, and a storage medium, so as to reduce development time and development cost of a data protocol conversion tool and increase usability and expandability of the data protocol conversion tool. The technical scheme is as follows:
a data protocol conversion method, comprising:
determining data generated by a first system according to a target data protocol format, wherein the target data protocol format is generated by annotating a field of an original data protocol format of the first system;
acquiring a target field carrying annotation in the data;
determining a preset target data format corresponding to the annotation carried by the target field, wherein the target data format represents the data format requirement of a second system on the target field;
converting the data format of the data information of the target field in the data into the target data format to generate target data;
and sending the target data to a second system, wherein the second system is a shared platform, and the first system is different from the second system.
Preferably, the target data protocol format generating method includes:
acquiring at least one piece of preset configuration information, wherein the configuration information indicates fields and notes, and different configuration information indicates different fields;
and responding to the operation that a user marks the annotation indicated by the configuration information to the field indicated by the configuration information in the original data protocol format in the first system, and generating the target data protocol format of the first system.
Preferably, the determining a preset target data format corresponding to the annotation carried by the target field includes:
determining an annotation type to which the annotation carried by the target field belongs;
searching a preset corresponding relation between the annotation type and the strategy information, and acquiring target strategy information corresponding to the annotation type to which the annotation carried by the target field belongs;
and determining the data format indicated by the target policy information as a target data format corresponding to the annotation carried by the target field.
Preferably, the determining the data format indicated by the target policy information as the target data format corresponding to the annotation carried by the target field includes:
and analyzing the target strategy information, and determining the data format indicated by the acquired target strategy information as a target data format corresponding to the annotation carried by the target field.
Preferably, the number of the target fields carrying annotations in the data is one or more, and the converting the data format of the data information of the target fields in the data into the target data format to generate the target data includes:
determining data information of the target field in the data;
and converting the data format of the data information of the target field in the data into a target data format corresponding to the annotation carried by the target field to obtain target data.
Preferably, the annotation type to which the annotation carried by the target field belongs is related to the field attribute of the target field.
Preferably, different field attributes correspond to different annotation types, the field attributes being attributes characterizing equal to conditions, attributes characterizing containing conditions, attributes characterizing fuzzy conditions, attributes characterizing query conditions, attributes characterizing general range conditions, attributes characterizing time range conditions, or attributes characterizing conditions in which no field is used.
A data protocol conversion apparatus comprising:
the data determining unit is used for determining data generated by a first system according to a target data protocol format, wherein the target data protocol format is generated by annotating a field of an original data protocol format of the first system;
a target field obtaining unit, configured to obtain a target field carrying an annotation in the data;
the target data format determining unit is used for determining a preset target data format corresponding to the annotation carried by the target field, and the target data format represents the data format requirement of a second system on the target field;
the data format conversion unit is used for converting the data format of the data information of the target field in the data into the target data format to generate target data;
and the data sending unit is used for sending the target data to the second system, the second system is a shared platform, and the first system is different from the second system.
An electronic device, comprising: the system comprises a processor and a memory, wherein the processor and the memory are connected through a communication bus; the processor is used for calling and executing the program stored in the memory; the memory is used for storing programs, and the programs are used for realizing the data protocol conversion method.
A computer-readable storage medium having stored therein computer-executable instructions for the data protocol conversion method.
The application provides a data protocol conversion method, a data protocol conversion device, electronic equipment and a storage medium, wherein a field of an original data protocol format of a first system is annotated by using a data format requirement of a shared platform for the field, so that each first system obtains a target data protocol format corresponding to the first system; based on the data format, each first system can automatically convert the data into the target data meeting the data format requirement of the shared platform and send the target data to the shared platform when sending the data to the shared platform based on the respective target data protocol format. Therefore, each first system does not need to independently construct a data protocol conversion tool, the working difficulty is simplified, and the development time is reduced; and when a new protocol needs to be converted, the original code of the data protocol conversion method provided by the application does not need to be modified, and only the expansion is needed on the current basis, so that the usability and the expandability of the data protocol conversion method are improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart illustrating a conventional method for converting the data protocol of the present system to the data protocol of the shared platform;
fig. 2 is a flowchart of a data protocol conversion method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a data protocol conversion apparatus according to an embodiment of the present application;
fig. 4 is a block diagram of a hardware structure of an electronic device to which a data protocol conversion method provided in the embodiment of the present application is applied.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example (b):
in order to facilitate understanding of a data protocol conversion method provided in the embodiments of the present application, related terms related to the data protocol conversion method provided in the embodiments of the present application will be explained first.
Data communication protocols: also known as data communication control protocol. The system is a series of appointments which are specified for ensuring that two communication parties in a data communication network can effectively and reliably communicate. These conventions include the format, order and rate of data, the acknowledgement or rejection of data transmissions, error detection, retransmission control and interrogation. Data communication protocols fall into two categories: one type is called basic type communication control protocol, which is used for data transmission with character as basic unit, such as BSC protocol (binary synchronous communication protocol); the other is called a high-level key control protocol for data transmission in bit basis units, such as HDLC (high-level data key control protocol) and SDLC (synchronous data key control protocol).
Annotations (java annotations): from JDK5, Java adds support for metadata, i.e. annotations, which are distinguishable from annotations, and can be understood as special markers in the code, which can be read during compilation, class loading, runtime, and corresponding processing. The developer can embed supplemental information in the source code without changing the original code and logic by annotating.
Protocol conversion is a mapping that maps a sequence of information (or events) transmitted and received from one protocol to a sequence of information transmitted and received from another protocol. The information that needs to be mapped is important information, so the protocol conversion can be regarded as mapping between the important information of the two protocols. The important information and the non-important information are relative, and are determined according to specific needs, different important information is selected for mapping, and different converters can be obtained.
At present, the application of the sharing platform is more and more extensive, and more systems begin to access the sharing platform and use the convenient functions provided by the sharing platform. However, when each system accesses the shared platform, the data protocol of the system is in a format different from that of the shared platform, and each system needs to write its own data protocol conversion tool (i.e., converter) to convert the data protocol of the system into the shared platform data protocol.
Referring to fig. 1, a process of converting a data protocol of the system into a shared platform data protocol by an existing user is specifically as follows: 1) the user defines a data protocol of the system of the user, and the data protocol is used for receiving data of the system of the user; 2) comparing the user with the own data protocol according to the format of the data protocol of the sharing platform; 3) writing a self-defined data protocol conversion tool; 4) converting the system data protocol into a shared platform data protocol by using a data protocol conversion tool; 5) and returning the converted shared platform data protocol.
In the data protocol conversion mode, each system develops a data protocol conversion tool respectively, the data protocol conversion tools among the systems cannot be used universally, but the functions of each conversion tool are different, codes are repeated greatly, the tools written by the systems need a large amount of time, problems are easy to occur, when the data protocol of the shared platform has new contents, the systems also need to update the tools completely, a large amount of development time and development cost are caused, and the tools are not easy to use and have poor expandability.
In summary, in the existing data protocol conversion mode, when each system requests a shared platform, a large amount of development work is required to convert the data protocol of the system into the shared platform data protocol because the data protocols between different systems are not uniform, which consumes manpower and material resources, and is prone to errors. Moreover, when the data protocol of the shared platform has new contents, each system also needs to update its own tool, resulting in a large amount of development time and development cost, and the tool is not easy to use and has poor expandability.
The invention can intelligently convert the data protocol of the system into the data protocol of the sharing platform in a self-defined annotation mode, so that developers do not need to manually convert the system protocol into the data protocol of the sharing platform, manual intervention is not needed, the working difficulty is simplified, and the development time is shortened. Meanwhile, the invention is written by using an easy-to-expand mode, and when a new protocol needs to be converted, the original code does not need to be modified, and only the expansion is needed on the current basis.
The following describes a data protocol conversion method provided in an embodiment of the present application in detail, with reference to fig. 2. As shown in fig. 2, the method includes:
s201, determining data generated by a first system according to a target data protocol format, wherein the target data protocol format is generated by annotating a field of an original data protocol format of the first system;
in the embodiment of the present application, the shared platform is referred to as a second system, a system for accessing the shared platform is referred to as a first system, a data protocol format of the first system (for convenience of distinguishing, the data protocol format of the first system is referred to as an original data protocol format) is annotated, and the data protocol format after the annotation in the first system is referred to as a target data protocol format.
The data protocol conversion method provided by the embodiment of the application can be applied to any first system for accessing the sharing platform, the original data protocol format in the first system can be regarded as the original data protocol format of the first system, and the target data protocol format of the first system is generated in response to annotation operation of a user on the field of the original data protocol format of the first system. That is, the original data protocol format of the first system may be considered the target data protocol format after the annotation is completed.
The data protocol conversion method provided by the embodiment of the application can provide a configuration information table for a user at a first system side, wherein the configuration information table comprises at least one piece of configuration information, and the configuration information indicates fields and notes; different fields indicated by different configuration information are different.
The user at the first system side can perform annotation operation on fields in the original data protocol format of the first system based on all the configuration information in the configuration information table to obtain the target data protocol format of the first system. Specifically, the first system responds to an operation that a user marks a comment indicated by the configuration information to a field indicated by the configuration information in the original protocol data format in the first system, and generates a target data protocol format of the first system.
For example, the configuration information table includes 3 pieces of configuration information, where the 3 pieces of configuration information are configuration information 1 (configuration information 1 indicates field 1 and annotation 1), configuration information 2 (configuration information 2 indicates field 2 and annotation 2), and configuration information 3 (configuration information 3 indicates field 3 and annotation 1), respectively, and then the target data protocol format of the first system is obtained in response to an operation of a user on annotation 1 labeled by field 1 in the original protocol format of the first system, annotation 2 labeled by field 2 in the original protocol format of the first system, and annotation 1 labeled by field 3 in the original protocol format of the first system. That is, the target data protocol format of the first system is the original data protocol format in which the field 1 is annotated with the annotation 1, the field 2 is annotated with the annotation 2, and the field 3 is standardized with the annotation 3 in the first system.
In the embodiments of the present application, the same annotation may be considered to belong to the same annotation type, and different annotations may be considered to belong to different annotation types. That is, each annotation may be considered to be an annotation type.
For example, the configuration information table includes 5 pieces of configuration information, and the configuration information includes configuration information 1 (configuration information 1 indicates field 1 and annotation 1), configuration information 2 (configuration information 2 indicates field 2 and annotation 2), configuration information 3 (configuration information 3 indicates field 3 and annotation 1), configuration information 4 (configuration information 4 indicates field 4 and annotation 2), and configuration information 5 (configuration information 5 indicates field 5 and annotation 3), so that annotation 1 can be considered as one annotation type, annotation 2 is considered as one annotation type, and annotation 3 is considered as one annotation type.
In the embodiment of the application, the comment type of the comment of the field is related to the field attribute of the field. Because each annotation may be considered to be an annotation type, and the annotations for a field are related to the field property of the field, the annotations provided by the embodiment of the present application may include the following:
the @ EqualsCondition annotation, equates to an equality condition in the shared platform data structure; i.e., the @ EqualsCondition annotation relates to a field whose attribute characterization is equal to a condition for annotating a field whose attribute is equal to a condition attribute.
The @ InCondition annotation, which is equivalent to the inclusion condition in the shared platform data structure; that is, the @ InCondition annotation is related to fields whose attribute representation contains conditions, and is used to annotate fields whose attributes contain condition attributes.
The @ LikeCondition annotation, which is equivalent to a fuzzy condition in the shared platform data structure; that is, the @ LikeCondition annotation is associated with a field whose attribute characterizes the fuzzy condition, and is used to annotate a field whose attribute is a fuzzy condition attribute.
The @ QueryCondition annotation, which is equivalent to the query condition in the shared platform data structure; that is, the @ QueryCondition annotation is associated with a field for which an attribute characterizes a query condition, for annotating a field for which an attribute is a query condition.
The @ RangCondition annotation, which is equivalent to the common range condition in the shared platform data structure; that is, the @ RangCondition annotation relates to a field whose attribute characterizes a normal scope condition, for annotating a field whose attribute is a normal scope condition.
The @ RangteCondition annotation, which is equivalent to the time range condition in the shared platform data structure; that is, the @ RangTimeCondition annotation relates to the field for which the attribute characterizes the time range condition, and is used to annotate the field for which the attribute characterizes the time range condition.
The @ UnUsContonditon annotation, which equates to an unused field condition in the shared platform data structure; that is, the @ UnUuseContinditon annotation relates to a field in which a property characterizes a non-use field condition, and is used to annotate a field in which the property is a non-use field condition.
The above is only the preferred content of the annotation provided by the embodiment of the present application, and the inventor can set the specific content of the annotation according to his own needs, which is not limited herein.
S202, obtaining a target field carrying annotation in data;
in the embodiment of the application, the original data protocol format of the first system is annotated in advance, so that the original data protocol format of the first system is changed into the target data protocol format, and thus, the subsequent first system generates data according to the target data protocol format when generating the data, and the generated data has a field carrying annotation. For ease of distinction, the field in the data that carries the annotation is referred to as the target field.
Under the condition that the field of the target data protocol format of the first system is marked with the annotation, if data is generated according to the field marked with the annotation, the field in the data also carries the marked annotation.
S203, determining a preset target data format corresponding to the annotation carried by the target field, wherein the target data format represents the data format requirement of the second system on the target field;
in the embodiment of the application, a corresponding relation between an annotation type and policy information is preset, after it is determined that data generated by a first system according to a target data protocol format includes a target field carrying annotation, the annotation type of the annotation carried by the target field can be determined, the corresponding relation between the preset annotation type and the policy information is inquired, the policy information corresponding to the annotation type of the annotation carried by the target field is obtained, and for convenience of distinguishing, the acquired policy information corresponding to the annotation type of the annotation carried by the target field can be called as target policy information.
The preset policy information provided in the embodiments of the present application will be described in detail below. The embodiment of the present application provides several kinds of policy information as follows:
abstract field annotation strategy, wherein the strategy extracts the common method of all strategies, processes each specific annotated field by using a template mode, and converts the data protocol of each first system into the data protocol of a shared platform;
analyzing the strategy of the @ EqualsFieldAnnnotiationStrength annotation, and converting the field marked with the annotation in the data protocol of each system into a corresponding equality condition in a shared platform data structure;
InFieldAnnounotationStrategy, analyzing the strategy of the @ InCondition annotation, and converting the field marked with the annotation in the data protocol in each system into a corresponding inclusion condition in a data structure of a shared platform;
the LikeFieldAnnountationStrategy analyzes the strategy of @ LikeCondition annotation, and converts the field marked with the annotation in the data protocol in each system into a corresponding fuzzy condition in a data structure of a shared platform;
and resolving the strategy of the @ RangFieldInnotationStrategy, and converting the field marked with the annotation in the data protocol in each system into a corresponding common range condition in the data structure of the shared platform.
Analyzing the strategy of the @ RangteFineMinnotationStrength annotation, and converting the field marked with the annotation in the data protocol of each system into a corresponding time range condition in the data structure of the shared platform;
abstract QueryConditionTypeStrategy, analyze @ QueryCondition annotation, and convert the data protocols of each system to the data protocol of the shared platform.
The above are only some preferred contents of the policy information provided by the embodiment of the present application, and the inventor may set the specific contents of the annotation information according to his own needs, which is not limited herein.
In the embodiment of the application, before generating data and sending the data to a second system (a sharing platform), a first system may determine a target field carrying annotations in the data, determine target policy information corresponding to an annotation type to which the annotations carried by the target field belong, further analyze the target policy information to obtain a data format indicated by the target policy information, determine the data format indicated by the target policy information as a target data format corresponding to the annotations carried by the target field, and characterize the data format requirement of the second system on the target field.
S204, converting the data format of the data information of the target field in the data into a target data format to generate target data;
the number of the object fields carrying annotations in the data can be one or more, the object data format corresponding to the annotations carried by each object field in the data is respectively obtained, and the data format of the data information of the object fields in the data is converted into the object data format corresponding to the annotations carried by the object fields, so that the object data is obtained.
For example, the data is composed of 5 fields, which are field 1, field 2, field 3, field 4 and field 5, the target fields of the annotations carried in the 5 fields are field 1 and field 3, respectively, the obtained target data format corresponding to the annotations carried in the field 1 is data format 1, and the target data format corresponding to the annotations carried in the field 3 is data format 2, so that the data format of the data information in the field 1 in the data is converted into the data format 1, and the data format of the data information in the field 3 is converted into the data format 2, so as to obtain the target data. That is, data in which the data format of the data information of the field 1 is converted into the data format 1 and the data format of the data information of the field 3 is converted into the data format 2 may be regarded as target data.
S205, sending the target data to a second system, wherein the second system is a shared platform, and the first system is different from the second system.
In the embodiment of the application, before generating data and sending the data to a second system (a sharing platform), a first system may determine a target field carrying annotations in the data, determine target policy information corresponding to an annotation type to which the annotations carried by the target field belong, further obtain a data format indicated by the target policy information, determine the data format indicated by the target policy information as a target data format corresponding to the annotations carried by the target field, convert the data format of the data information of the target field in the data into the target data format corresponding to the annotations carried by the target field, obtain target data, and further send the target data to the second system.
According to the data protocol conversion method, the original data protocol format of the first system is converted into the target data protocol format, the data can be converted into the target data meeting the data format requirement of the second system before being sent to the second system after the first system generates the data, and then the target data is sent to the second system instead of sending the data to the second system, so that the second system can identify the target data sent by the first system, and the purpose that the first system is accessed into the second system is achieved.
The data protocol conversion method provided by the embodiment of the application can be applied to a target data protocol conversion tool, the target data protocol conversion tool is suitable for each first system, and the purpose that the first system accesses to the sharing platform can be achieved without independently developing the respective data protocol conversion tool by each first system.
The data protocol conversion method provided by the embodiment of the application has the following processes:
1. defining a data protocol format of a first system;
2. introducing a target data protocol conversion tool provided by the embodiment of the application into a first system;
3. adding the custom note in the embodiment of the application into the field on the specific pair in the defined data protocol format of the first system;
4. calling a data protocol conversion method provided by the embodiment of the application;
5. the target data protocol conversion tool begins to analyze the custom annotation in the data generated by the first system;
6. judging annotation types on specific fields in the data, and calling corresponding strategy information to convert the field data structure in the data into a corresponding data structure in the shared platform to obtain a data protocol of returning target data to the shared platform;
7. returning the target data to the first system;
8. the first system sends the target data to the second system.
According to the method and the device, aiming at the problem that each first system needs to develop a conversion tool, the data protocol of the first system is intelligently converted into the data protocol of the sharing platform by compiling the user-defined annotation, so that developers do not need to manually convert the data protocol of the first system into the data protocol of the sharing platform, the work difficulty is simplified, and the development time is shortened. Meanwhile, the method is written in an easily-extensible mode, and when a new protocol needs to be converted, the original code does not need to be modified, and only the extension is needed on the current basis.
Fig. 3 is a schematic structural diagram of a data protocol conversion apparatus according to an embodiment of the present application.
As shown in fig. 3, the apparatus includes:
a data determining unit 31, configured to determine data generated by the first system according to a target data protocol format, where the target data protocol format is generated by annotating a field of an original data protocol format of the first system;
a target field obtaining unit 32, configured to obtain a target field carrying an annotation in the data;
the target data format determining unit 33 is configured to determine a preset target data format corresponding to the annotation carried in the target field, where the target data format represents a data format requirement of the second system on the target field;
a data format conversion unit 34, configured to convert the data format of the data information of the target field in the data into a target data format to generate target data;
and a data sending unit 35, configured to send the target data to a second system, where the second system is a shared platform, and the first system is different from the second system.
The data protocol conversion apparatus provided in the embodiment of the present application further includes a target data protocol format generating unit, where the target data protocol format generating unit includes:
the device comprises a configuration information acquisition unit, a configuration information display unit and a configuration information display unit, wherein the configuration information acquisition unit is used for acquiring at least one piece of preset configuration information, the configuration information indicates fields and notes, and different configuration information indicates different fields;
and the target data protocol format generating subunit is used for responding to the operation that the user marks the annotation indicated by the configuration information to the field indicated by the configuration information in the original data protocol format in the first system, and generating the target data protocol format of the first system.
In this embodiment of the present application, preferably, the target data format determining unit includes:
the first determining unit is used for determining the annotation type of the annotation carried by the target field;
the search unit is used for searching the preset corresponding relation between the annotation type and the strategy information and acquiring the target strategy information corresponding to the annotation type to which the annotation carried by the target field belongs;
and the second determining unit is used for determining the data format indicated by the target policy information as the target data format corresponding to the annotation carried by the target field.
In this embodiment of the application, preferably, the second determining unit is specifically configured to parse the target policy information, and determine a data format indicated by the obtained target policy information as a target data format corresponding to the annotation carried by the target field.
In this embodiment of the present application, preferably, the number of the target fields carrying annotations in the data is one or more, and the data format conversion unit includes:
the third determining unit is used for determining data information of a target field in the data;
and the conversion subunit is used for converting the data format of the data information of the target field in the data into a target data format corresponding to the annotation carried by the target field to obtain the target data.
In the embodiment of the present application, preferably, the annotation type to which the annotation carried by the target field belongs is related to the field attribute of the target field.
In the embodiment of the present application, it is preferable that different field attributes correspond to different annotation types, and a field attribute is an attribute that characterizes a condition, an attribute that characterizes a fuzzy condition, an attribute that characterizes a query condition, an attribute that characterizes a normal-range condition, an attribute that characterizes a time-range condition, or an attribute that characterizes no field condition is used.
Fig. 4 is a block diagram of a hardware structure of an electronic device used in a data protocol conversion method according to an embodiment of the present application. In this embodiment, the electronic device may be a host.
The electronic device may include, as shown in fig. 4: a processor 401, a memory 402, a communication interface 403, an input unit 404, and a display 405 and a communication bus 406.
The memory 402 is used for storing one or more programs, which may include program codes including computer operation instructions, and in the embodiment of the present invention, the memory stores at least the programs for implementing the following functions:
determining data generated by a first system according to a target data protocol format, wherein the target data protocol format is generated by annotating a field of an original data protocol format of the first system;
acquiring a target field carrying annotation in data;
determining a preset target data format corresponding to the annotation carried by the target field, wherein the target data format represents the data format requirement of the second system on the target field;
converting the data format of the data information of the target field in the data into a target data format to generate target data;
and sending the target data to a second system, wherein the second system is a shared platform, and the first system is different from the second system.
That is, the program stored in the memory is used to implement the data protocol conversion method provided by the above-described embodiment.
Alternatively, the detailed function and the extended function of the program may be described with reference to the following.
The processing module 401, the memory 402, the communication interface 403, the input unit 404, and the display 405 all communicate with each other through the communication bus 406.
In the embodiment of the present invention, the processor 401 may be a Central Processing Unit (CPU), an application-specific integrated circuit (ASIC), a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices.
The processor may call and execute programs stored in memory 402.
The communication interface 403 may be an interface of a communication module, such as an interface of a GSM module.
The present invention may further include an input unit 404, which may include a touch sensing unit sensing a touch event on the touch display panel, a keyboard, and the like.
The display 405 includes a display panel, such as a touch display panel or the like. In one possible case, the Display panel may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like.
Of course, the electronic device structure shown in fig. 4 does not constitute a limitation to the electronic device in the embodiment of the present invention, and in practical applications, the terminal may include more or less components than those shown in fig. 4, or some components may be combined.
Further, an embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored, and the computer-executable instructions are used for executing the data protocol conversion method.
Alternatively, the detailed functionality and extended functionality of the computer-executable instructions may be as described above.
The application provides a data protocol conversion method, a data protocol conversion device, electronic equipment and a storage medium, wherein a field of an original data protocol format of a first system is annotated by using a data format requirement of a shared platform for the field, so that each first system obtains a target data protocol format corresponding to the first system; based on the data format, each first system can automatically convert the data into target data meeting the data format requirement of the sharing platform and send the target data to the sharing platform when sending the data to the sharing platform based on the respective target data protocol format. Therefore, each first system does not need to independently construct a data protocol conversion tool, the working difficulty is simplified, and the development time is reduced; moreover, when a new protocol needs to be converted, the original code of the data protocol conversion method provided by the application does not need to be modified, and only the expansion is needed on the current basis, so that the usability and the expandability of the data protocol conversion method are improved.
The above detailed description is provided for a data protocol conversion method, apparatus, electronic device and storage medium, and specific examples are applied herein to explain the principles and embodiments of the present invention, and the descriptions of the above embodiments are only used to help understanding the method and its core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include or include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (8)

1. A method for data protocol conversion, comprising:
determining data generated by a first system according to a target data protocol format, wherein the target data protocol format is generated by annotating a field of an original data protocol format of the first system;
acquiring a target field carrying annotation in the data;
determining a preset target data format corresponding to the annotation carried by the target field, wherein the target data format represents the data format requirement of a second system on the target field;
converting the data format of the data information of the target field in the data into the target data format to generate target data;
sending the target data to a second system, wherein the second system is a shared platform, and the first system is different from the second system;
the target data protocol format generation method comprises the following steps:
acquiring at least one piece of preset configuration information, wherein the configuration information indicates fields and notes, and different configuration information indicates different fields;
responding to an operation that a user marks a comment indicated by the configuration information to a field indicated by the configuration information in an original data protocol format in the first system, and generating a target data protocol format of the first system;
the determining a preset target data format corresponding to the annotation carried by the target field includes:
determining an annotation type to which the annotation carried by the target field belongs;
searching a preset corresponding relation between the annotation type and the strategy information, and acquiring target strategy information corresponding to the annotation type to which the annotation carried by the target field belongs;
and determining the data format indicated by the target strategy information as a target data format corresponding to the annotation carried by the target field.
2. The method according to claim 1, wherein the determining the data format indicated by the target policy information as the target data format corresponding to the annotation carried by the target field includes:
and analyzing the target strategy information, and determining the data format indicated by the acquired target strategy information as a target data format corresponding to the annotation carried by the target field.
3. The method according to claim 1, wherein the number of target fields carrying annotations in the data is one or more, and the converting the data format of the data information of the target fields in the data into the target data format to generate the target data comprises:
determining data information of the target field in the data;
and converting the data format of the data information of the target field in the data into a target data format corresponding to the annotation carried by the target field to obtain target data.
4. The method of claim 1, wherein the annotation type to which the annotation carried by the target field belongs is related to a field attribute of the target field.
5. The method of claim 4, wherein different field attributes correspond to different annotation types, and wherein the field attributes are attributes that characterize conditions equal to, attributes that characterize conditions including, attributes that characterize fuzzy conditions, attributes that characterize query conditions, attributes that characterize normal range conditions, attributes that characterize time range conditions, or attributes that characterize conditions in which no field is used.
6. A data protocol conversion device, comprising:
the data determining unit is used for determining data generated by a first system according to a target data protocol format, wherein the target data protocol format is generated by annotating a field of an original data protocol format of the first system;
a target field obtaining unit, configured to obtain a target field carrying an annotation in the data;
the target data format determining unit is used for determining a preset target data format corresponding to the annotation carried by the target field, and the target data format represents the data format requirement of a second system on the target field;
the data format conversion unit is used for converting the data format of the data information of the target field in the data into the target data format to generate target data;
a data sending unit, configured to send the target data to the second system, where the second system is a shared platform, and the first system is different from the second system;
the data determining unit is specifically configured to:
acquiring at least one piece of preset configuration information, wherein the configuration information indicates fields and notes, and different configuration information indicates different fields;
responding to an operation that a user marks a comment indicated by the configuration information to a field indicated by the configuration information in an original data protocol format in the first system, and generating a target data protocol format of the first system;
the target data format determining unit is specifically configured to:
determining the annotation type of the annotation carried by the target field;
searching a preset corresponding relation between the annotation type and the strategy information, and acquiring target strategy information corresponding to the annotation type to which the annotation carried by the target field belongs;
and determining the data format indicated by the target strategy information as a target data format corresponding to the annotation carried by the target field.
7. An electronic device, comprising: the system comprises a processor and a memory, wherein the processor and the memory are connected through a communication bus; the processor is used for calling and executing the program stored in the memory; the memory for storing a program for implementing the data protocol conversion method according to any one of claims 1 to 5.
8. A computer-readable storage medium having computer-executable instructions stored thereon for performing the data protocol conversion method of any one of claims 1-5.
CN202010811812.XA 2020-08-13 2020-08-13 Data protocol conversion method and device, electronic equipment and storage medium Active CN111970267B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010811812.XA CN111970267B (en) 2020-08-13 2020-08-13 Data protocol conversion method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010811812.XA CN111970267B (en) 2020-08-13 2020-08-13 Data protocol conversion method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111970267A CN111970267A (en) 2020-11-20
CN111970267B true CN111970267B (en) 2022-08-30

Family

ID=73365483

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010811812.XA Active CN111970267B (en) 2020-08-13 2020-08-13 Data protocol conversion method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111970267B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112532712B (en) * 2020-11-24 2023-03-28 青岛海尔科技有限公司 Protocol transmission method and device, storage medium, and electronic device
CN113422765B (en) * 2021-06-18 2023-04-07 杭州深渡科技有限公司 Data transmission method and device of Internet of things equipment and Internet of things equipment
CN113742407B (en) * 2021-08-31 2024-04-30 浙江惠瀜网络科技有限公司 Data conversion method and device
CN113890891A (en) * 2021-10-11 2022-01-04 国网电子商务有限公司 Data sharing interaction method and device of energy cloud network
CN114095584A (en) * 2021-11-29 2022-02-25 重庆忽米网络科技有限公司 Model conversion and construction method of industrial equipment data and readable storage medium
CN114222009B (en) * 2021-12-15 2024-05-24 北京工业大学 Industrial communication multi-protocol conversion system
CN113918770B (en) * 2021-12-16 2022-03-25 上海冰鉴信息科技有限公司 Method and device for converting character string and time field
CN114885039B (en) * 2022-05-30 2023-06-23 中国联合网络通信集团有限公司 Data transmission method, device and storage medium
CN115314566A (en) * 2022-07-26 2022-11-08 北京金山云网络技术有限公司 Data transmission method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106302442A (en) * 2016-08-12 2017-01-04 广州慧睿思通信息科技有限公司 A kind of network communication packet analytic method based on Java language
CN108600389A (en) * 2018-05-10 2018-09-28 山东浪潮通软信息科技有限公司 A kind of data transmission method and device based on common interface platform
CN109547474A (en) * 2018-12-21 2019-03-29 深圳市创梦天地科技有限公司 A kind of data transmission method and device
CN110781230A (en) * 2019-09-12 2020-02-11 腾讯大地通途(北京)科技有限公司 Data access method, device and equipment

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7149206B2 (en) * 2001-02-08 2006-12-12 Electronic Data Systems Corporation System and method for managing wireless vehicular communications
JP6805422B2 (en) * 2016-03-08 2020-12-23 株式会社電通 Equipment, programs and information processing methods

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106302442A (en) * 2016-08-12 2017-01-04 广州慧睿思通信息科技有限公司 A kind of network communication packet analytic method based on Java language
CN108600389A (en) * 2018-05-10 2018-09-28 山东浪潮通软信息科技有限公司 A kind of data transmission method and device based on common interface platform
CN109547474A (en) * 2018-12-21 2019-03-29 深圳市创梦天地科技有限公司 A kind of data transmission method and device
CN110781230A (en) * 2019-09-12 2020-02-11 腾讯大地通途(北京)科技有限公司 Data access method, device and equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
对几类重要网络安全协议形式模型的分析;季庆光等;《计算机学报》;20050712(第07期);全文 *

Also Published As

Publication number Publication date
CN111970267A (en) 2020-11-20

Similar Documents

Publication Publication Date Title
CN111970267B (en) Data protocol conversion method and device, electronic equipment and storage medium
US20180329690A1 (en) Converting visual diagrams into code
CN1307553C (en) Apparatus and method for syntactic analysis expanding mark language file
CN109933571B (en) Database design document generation method, device and computer readable storage medium
US9811605B2 (en) Methods, apparatuses and computer program products for automated learning of data models
US8078914B2 (en) Open error-handling system
CN109634835B (en) Memory leak analysis method and related device
CN104679500B (en) Method and device for realizing automatic generation of entity class
CN106648569B (en) Target serialization realization method and device
CN114741070A (en) Code generation method and device, electronic equipment and storage medium
CN111638873A (en) Program code generation method and device, computer equipment and storage medium
US11650875B2 (en) Abnormal inode dynamic repair method and system, and related component
CN110716738A (en) Data processing method and device, cloud platform, electronic equipment and storage medium
CN110968296B (en) Data acquisition method, device, equipment and readable storage medium
CN116560683A (en) Software updating method, device, equipment and storage medium
CN114185791A (en) Method, device and equipment for testing data mapping file and storage medium
CN111078213A (en) Code generation method and code generation device
CN111488144B (en) Data processing method and device
CN110442636B (en) Data reading and writing method and device and data reading and writing equipment
CN112181411A (en) Menu generation method, menu generation device and diagnosis equipment
CN115291887A (en) Code generation method, device, equipment and storage medium
CN115357319A (en) User interface rendering method and device
CN114461193A (en) Method, device, equipment and storage medium for generating communication protocol code
CN114546410A (en) Code optimization method based on design mode and related equipment
CN110471708B (en) Method and device for acquiring configuration items based on reusable components

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: 100032 room 8018, 8 / F, building 7, Guangyi street, Xicheng District, Beijing

Patentee after: State Grid Digital Technology Holdings Co.,Ltd.

Patentee after: State Grid E-Commerce Technology Co.,Ltd.

Address before: 311 guanganmennei street, Xicheng District, Beijing 100053

Patentee before: STATE GRID ELECTRONIC COMMERCE Co.,Ltd.

Patentee before: State Grid E-Commerce Technology Co.,Ltd.