Data processing method and device, storage medium and electronic equipment
By combining a pre-defined aggregation interface with a target query engine, the problem of needing to customize multiple API interfaces on the server side is solved, enabling flexible data processing and efficient data transmission, and reducing development costs.
Patent Information
- Application Number
- CN202111404674.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-24
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2041-11-24
AI Technical Summary
In existing technologies, the server needs to customize multiple API interfaces to respond to the data requirements of different clients, resulting in a large workload and high cost in development.
The system receives data processing requests from multiple clients through a pre-defined aggregation interface, parses service methods and parameters, calls the corresponding service methods, and returns the processing results. It also uses data schema files and method executors to bind to the target query engine, enabling a unified interface to call different service methods.
It reduces development costs, increases interface flexibility, improves data transmission efficiency, avoids data redundancy, and is suitable for scenarios such as traffic signal control.
Smart Images

Figure CN114117190B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, and in particular, to a data processing method, a data processing apparatus, a computer readable storage medium and an electronic device. BACKGROUND
[0002] With the development of technology, the Internet application technology develops rapidly, and people can carry out various interactive activities through the Internet application. Taking the client as an example, the user can obtain corresponding service data through the application program interface customized by the server.
[0003] In order to meet the differentiated needs of different clients, the server needs to customize different application program interfaces (hereinafter referred to as API interfaces) according to the service types of application services to respond to the demand data of different clients. Among them, for different application services, the customized API interfaces may be similar, at this time, it is still necessary to repeatedly develop multiple API interfaces, which leads to a large amount of development work, and further increases the development cost.
[0004] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present disclosure, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0005] The purpose of the present disclosure is to provide a data processing method, a data processing apparatus, a computer readable storage medium and an electronic device, and to at least partially overcome the problem of high development cost when the server responds to the demand data of different clients due to related technology.
[0006] According to a first aspect of the present disclosure, a data processing method is provided, comprising:
[0007] receiving a plurality of data processing requests sent by a plurality of clients through a preset aggregation interface, wherein the data processing request carries a service method and a service method parameter;
[0008] parsing each data processing request, and calling a corresponding service method according to the parsed service method and service method parameter to obtain a data processing result;
[0009] returning the data processing result to the client.
[0010] In an exemplary embodiment of the present disclosure, the method further comprises:
[0011] configuring a data mode file, wherein the data mode file includes a service method, a service method parameter and a return parameter corresponding to the service method parameter;
[0012] A method executor is created, which is used to call data processing logic corresponding to different service methods, and the method executor is configured with the same service methods as in the data mode file;
[0013] The service methods in the data mode file are bound to the service methods in the method executor to obtain a target query engine.
[0014] In an exemplary embodiment of the present disclosure, at least one service method is configured in the data mode file, and the method further comprises:
[0015] The preset aggregation interface is created according to the service method configured in the data mode file, so as to receive data processing requests sent by multiple clients through the preset aggregation interface.
[0016] In an exemplary embodiment of the present disclosure, the data processing request includes a query condition and a query variable, the query condition carries the service method and the service method parameter, and the query variable carries the field value of the service method parameter.
[0017] In an exemplary embodiment of the present disclosure, after receiving the data processing requests sent by multiple clients through the preset aggregation interface, the method further comprises:
[0018] The query condition and the query variable in each data processing request are extracted, and a request data structure object is constructed from the query condition and the query variable.
[0019] In an exemplary embodiment of the present disclosure, the data processing request is parsed, and a corresponding service method is called according to the parsed service method and service method parameter to obtain a data processing result, comprising:
[0020] The query condition and the query variable are extracted from the request data structure object, and a query parameter for inputting the target query engine is generated according to the query condition and the query variable;
[0021] The query condition in the query parameter is parsed through the target query engine, and the parsed service method and service method parameter are routed to the corresponding method executor;
[0022] The data processing logic of the service method is called through the method executor, and the data processing result is obtained according to the field value of the service method parameter in the query variable.
[0023] In an exemplary embodiment of the present disclosure, the data processing result is returned to the client, comprising:
[0024] returning the data processing result to the target query engine to verify the data processing result;
[0025] when the data processing result is verified, returning the data processing result to the client in a preset data format.
[0026] when the data processing result is not verified, returning the data processing result directly to the client.
[0027] According to a second aspect of the present disclosure, a data processing apparatus is provided, comprising:
[0028] a request receiving module configured to receive data processing requests sent by a plurality of clients through a preset aggregation interface, wherein the data processing requests carry service methods and service method parameters;
[0029] a request processing module configured to parse each data processing request, and call a corresponding service method according to the parsed service method identifier and service method parameter to obtain a data processing result;
[0030] a request response module configured to return the data processing result to the client.
[0031] According to a third aspect of the present disclosure, a computer readable storage medium is provided, which stores a computer program, and the computer program is executed by a processor to implement the method of any one of the above.
[0032] According to a fourth aspect of the present disclosure, an electronic device is provided, comprising a processor and a memory for storing executable instructions of the processor, wherein the processor is configured to execute the method of any one of the above by executing the executable instructions.
[0033] The exemplary embodiments of the present disclosure can have the following partial or all beneficial effects:
[0034] In the data processing method provided by the example embodiment of the present disclosure, a plurality of data processing requests sent by a plurality of clients are received through a preset aggregation interface, the data processing requests carrying service methods and service method parameters; each data processing request is parsed, and a corresponding service method is called according to the parsed service method and service method parameter, so as to obtain a data processing result; and the data processing result is returned to the client. On the one hand, different service methods can be called through a unified interface according to the request fields sent by the plurality of clients, and without defining a plurality of interfaces for different request fields, the specified data requested by the client can be returned, which not only reduces the development cost, but also increases the flexibility of the interface; on the other hand, the data required by the client can be returned according to the request field specified by the client, without returning other invalid data, which improves the data transmission efficiency and avoids data redundancy in the data transmission process.
[0035] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0036] The accompanying drawings, which are incorporated into and form part of the specification, illustrate an embodiment consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0037] Figure 1 A schematic diagram of an example system architecture of a data processing method and device to which the embodiments of the present disclosure can be applied is shown;
[0038] Figure 2 A flowchart of a data processing method according to an embodiment of the present disclosure is schematically shown;
[0039] Figure 3 A flowchart of constructing a target query engine according to an embodiment of the present disclosure is schematically shown;
[0040] Figure 4 A flowchart of processing a data processing request according to an embodiment of the present disclosure is schematically shown;
[0041] Figure 5 A flowchart of a data processing method according to a specific embodiment of the present disclosure is schematically shown;
[0042] Figure 6 A flowchart of calling different application services through a unified interface according to an embodiment of the present disclosure is schematically shown;
[0043] Figure 7 a block diagram of a data processing apparatus according to one embodiment of the present disclosure is shown schematically;
[0044] Figure 8 a structural schematic diagram of a computer system of an electronic device suitable for implementing embodiments of the present disclosure is shown schematically. DETAILED DESCRIPTION
[0045] Example implementations will now be described more fully with reference to the accompanying drawings. Example implementations can be implemented in any
[0046] In addition, the accompanying drawings are included to provide a further understanding of the present disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the present disclosure and serve to explain the principles of the present disclosure. Features, elements, and / or properties that are
[0047] Figure 1 a schematic diagram of a system architecture of an exemplary application environment of a data processing method and apparatus to which embodiments of the present disclosure can be applied is shown.
[0048] As Figure 1As shown, the system architecture 100 can include one or more of terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc. The terminal devices 101, 102, 103 can be various electronic devices, including but not limited to desktop computers, portable computers, smart phones and tablets, etc., for providing a user interface for displaying data processing results. For example, a client (such as a browser) is installed on the terminal device, and the user views the data processing results through the browser client. It should be understood that Figure 1 The number of terminal devices, networks and servers in the above is only illustrative. According to the implementation needs, there can be any number of terminal devices, networks and servers. For example, the server 105 can be one server, or a server cluster composed of multiple servers, or a cloud computing platform or a virtualization center. Specifically, the server 105 can be used to perform: receiving data processing requests sent by multiple clients through a preset aggregation interface, the data processing requests carrying service methods and service method parameters; parsing each data processing request, and calling a corresponding service method according to the parsed service method and service method parameters to obtain a data processing result; returning the data processing result to the client.
[0049] The technical solutions of the embodiments of the present disclosure are described in detail as follows:
[0050] In the example implementation of the present disclosure, the scenario of traffic area coordinated control can be taken as an example for illustration. For example, the timing optimization and coordinated control of traffic signal lights in a certain area can be performed, that is, the traffic signal control data of the area is optimized. The traffic signal control data can include sub-area timing data, intersection parameter data and intersection phase record, the sub-area timing data includes sub-area name, road name, public cycle, coordination direction, start timing time and end timing time, etc., the intersection parameter data includes intersection name, period table number, period matching, scheme cycle, positive direction coordinated phase, road section distance, reverse speed, intersection phase difference, etc., and the intersection phase record includes intersection phase name and time, etc. For example, when the timing optimization and coordinated control of traffic signal lights are performed, the sub-area timing interval, intersection parameter, intersection phase and phase release prohibition record can be configured, and the manual timing is used to achieve the control of signal light switching.
[0051] The traffic signal control optimization data needs to have real-time and low latency. In actual application, a business system can use a same set of API interfaces and split the same set of API interfaces into multiple API interfaces for maintenance in order to call the corresponding API interface for each field required to be returned by the client (PC, mobile terminal, etc.) in order to be compatible with multiple clients. Meanwhile, for different application services, the customized API interfaces can be similar. For example, for the delete sub-area service and the delete intersection data service in traffic signal control, the interface input parameters and behaviors of both are similar. At this time, two API interfaces still need to be repeatedly developed, resulting in a large development workload and increasing development costs. It can be understood that the data processing method provided by the present disclosure can be applied but is not limited to the scene of traffic area coordination control. The method can be applied to any scene of calling application services through an aggregation interface, and the present disclosure does not make specific limitations thereto.
[0052] Based on one or more of the above problems, the present example embodiment provides a data processing method. Referring to Figure 2 The data processing method can include steps S210 to S230 as shown in the figure:
[0053] Step S210. Receive data processing requests sent by multiple clients through a preset aggregation interface, wherein the data processing requests carry service methods and service method parameters;
[0054] Step S220. Analyze each data processing request, and call the corresponding service method according to the service method and service method parameter obtained by analysis to obtain a data processing result;
[0055] Step S230. Return the data processing result to the client.
[0056] In the data processing method provided by the example embodiment of the present disclosure, multiple clients send data processing requests through a preset aggregation interface, wherein the data processing requests carry service methods and service method parameters; each data processing request is analyzed, and the corresponding service method is called according to the service method and service method parameter obtained by analysis to obtain a data processing result; and the data processing result is returned to the client. On the one hand, different service methods can be called through a unified interface according to the request fields sent by multiple clients, and multiple interfaces do not need to be defined for different request fields to return the specified data requested by the client, which not only reduces the development cost but also increases the flexibility of the interface; on the other hand, the data required by the client can be returned according to the request field specified by the client, without returning other invalid data, which improves the data transmission efficiency and avoids data redundancy in the data transmission process.
[0057] The above steps of the present example embodiment will be described in more detail below.
[0058] In step S210, the data processing request sent by the plurality of clients is received through the preset aggregation interface, and the data processing request carries a service method and a service method parameter.
[0059] In the example embodiment of the present disclosure, when implementing coordinated control of the traffic area, the server can provide query services and maintenance services, etc. For example, the client can request the server to return the intersection parameter data of a certain intersection through the query service, so as to optimize the timing of the traffic signal of the intersection. The client can also request the server to delete a certain sub-area through the maintenance service such as the change service, so as to perform coordinated management of the traffic area. Correspondingly, the data processing request sent by the client can be a request for obtaining specified data, or a request for deleting specified data, or a request for other types of services, which are not limited in the present disclosure.
[0060] When different clients call the query service to interact with data, the calling result is usually returned according to the fixed size of the content. For example, when the client needs to return the intersection parameter data, the server will return all the intersection parameter fields, including the intersection name, the period table number, the period matching, the scheme period, the positive direction coordination phase, the road segment distance, the reverse speed, and the intersection phase difference, while the client does not need to return the intersection phase difference field.
[0061] In the example embodiment of the present disclosure, when the plurality of clients request different application services, the data processing request sent by the plurality of clients can be received through the preset aggregation interface. The preset aggregation interface can be a GraphQL API interface. GraphQL can integrate a plurality of application services into an API to form a unified API interface, that is, only one API interface needs to be developed to request the required data. Correspondingly, the traffic signal control data can be queried through the GraphQL language. GraphQL is a query language for data interface, which is a runtime that uses custom data types to perform queries. A GraphQL service is created by defining data types and corresponding data fields. Each field on each type provides a corresponding parsing function (i.e., data query logic). Therefore, after the client sends a query request to the API interface, the data type returned by the API interface is determined, and only the required data needs to be received, and the complete data set does not need to be received.
[0062] Reference Figure 3 As shown, a GraphQL service can be created according to steps 310 to 330, that is, a GraphQL query engine is constructed.
[0063] Step S310. A data schema file is configured, which includes service methods, service method parameters, and return parameters corresponding to the service method parameters.
[0064] Specifically, a data schema file, i.e., a schema file, can be pre-configured. The schema file is a description of data in GraphQL, and the schema file can include two types, namely a query type (query) and a mutation type (mutation). The query can be used to query data, and the mutation can be used to create or update data. In addition, the default scalar types of GraphQL can include: Int (signed 32-bit integer), Float (signed double-precision floating-point value), String (UTF-8 character sequence), Boolean (Boolean value, true or false), and id (unique identifier).
[0065] In the schema file, service methods, service method parameters, and return parameters corresponding to the service method parameters can be customized. If the return parameter is a custom parameter, the fields and types contained in the return parameter also need to be defined. For example, a custom schema file can be as follows:
[0066]
[0067]
[0068] The service method defined in the schema file includes a query service method and two change service methods. The query service method is getSubArea, which is used to obtain sub-area data. The parameter of the service method is the id of the sub-area to be queried, which can be the id of the sub-area to be queried recorded in the database table, and the data type is Int. The return parameter type corresponding to the service method parameter is SubAreaRespVO, and the fields and types encapsulated in the return parameter are id (sub-area id, type Int), subregionName (sub-area name, type String), subregionCode (sub-area code, type String), cycle (public cycle, type Int), direction (coordination direction, type Int), startTime (start timing time, type String), and endTime (end timing time, type String), corresponding to the specified fields of the client. The two change service methods are deleteSubArea and deleteCrossparam, which are used to delete sub-areas and delete intersection parameters, respectively. The service method parameter of deleteSubArea is the id of the sub-area to be deleted, and the data type is Int. The return parameter type corresponding to the service method parameter is Int, and the returned field is still the id of the sub-area to be deleted. The service method parameter of deleteCrossparam is the id of the intersection parameter to be deleted, and the data type is Int. The return parameter type corresponding to the service method parameter is Int, and the returned field is still the id of the intersection parameter to be deleted. It should be noted that the schema file can be customized according to the actual needs of the user, and the schema file can define all the services required by the user, all service parameters, and all fields of the return object of the service. The present disclosure does not make specific limitations thereto.
[0069] Step S320. Create a method executor for calling different service methods corresponding to data processing logic, and the method executor is configured with the same service methods as in the data schema file.
[0070] After the schema file is defined, a query or mutation in the schema file needs to be implemented. Specifically, a method executor, i.e., a resolver class, can be created. Each field of each type in the schema file can be supported by a resolver function, that is, the resolver function is an implementation of a GraphQL entry and can be used to call data processing logic corresponding to different service methods. When a field is executed, the corresponding resolver function can be called and data processing logic can be executed to generate a field value. Therefore, the resolver function of each field of each type in the schema file can be defined so that the resolver class is configured with the same service methods as in the schema file.
[0071] Step S330. Binding the service methods in the data schema file with the service methods in the method executor to obtain a target query engine.
[0072] In the example embodiment, the target query engine can be a GraphQL query engine. Specifically, to perform a query on the schema file, a GraphQL query engine needs to be constructed first, and a parameter is carried to call the execute() method. After the query, an ExecutionResult object can be returned, which can include the result data of the query or an error information set when an error occurs. For example, a configuration binder provider can be created to bind the service methods in the schema file and the corresponding resolver functions to obtain a GraphQL query engine.
[0073] In addition, at least one service method can be configured in the data schema file, and a preset aggregation interface can be created according to the service method configured in the data schema file to receive data processing requests sent by multiple clients through the preset aggregation interface. For example, if the schema file is configured with three service methods, getSubArea, delSubArea, and deleteCrossparam, a GraphQL API interface can be created according to the three service methods, that is, the three service methods can be integrated into the API to form a unified API interface, and the data processing logic programmed by the GraphQL query engine can be implemented in the API interface. The GraphQL API interface can reduce the redundancy of the application layer interface, make the interface maintainable, and reduce the development workload, thereby reducing the development cost.
[0074] In this example, the client can accurately obtain the specified traffic signal control data by customizing the schema file. Moreover, the custom schema file has good flexibility, and can control the server to expose the corresponding interface service according to the data processing request sent by the client. In addition, by binding the content in the schema file and the resolver function, the corresponding application service can be called when the data processing request is received.
[0075] In an example embodiment, the data processing request sent by the client can include a query condition and a query variable. The query condition can carry a service method and a service method parameter, and the query variable can carry a field value of the service method parameter. For example, the data processing request can be a json string, which can include a query condition query field and a query variable variables field. For example, the json string can be as follows:
[0076]
[0077] The query field in the json string is a schema statement for deleting a sub-area. Wherein, deleteSubArea represents a change service method, i.e. a delete sub-area service method. $id:Int represents a change service method parameter, i.e. the id of the sub-area to be deleted. id:$id represents a parameter placeholder, corresponding to the field value of id in the variables field. The variables field corresponds to the field value of the change service method parameter in the query field, and {"id":1} represents deleting a sub-area with id 1. After the server receives the request, the delete sub-area service can be called, and the specified data {"id":1} is returned after the service is executed.
[0078] In this example, the client can specify the called service method, service method parameter, and field value of the service method parameter (i.e. specified return field), and different services can be called through the schema statement, which can not only meet the needs of the client to obtain data, but also reduce data redundancy caused by compatibility with multiple clients. Moreover, compared with returning all data, the data transmission packet byte number is smaller when returning specified data, thereby improving the data transmission efficiency.
[0079] In step S220, each data processing request is parsed, and the corresponding service method is called according to the parsed service method and service method parameter to obtain the data processing result.
[0080] After receiving the data processing requests sent by the plurality of clients, the query conditions and query variables in each data processing request can be extracted, and a request data structure object can be constructed according to the query conditions and query variables. The request data structure object can be a GraphQLRequest, so as to map a json string into a built-in field type of GraphQL by using the GraphQLRequest. For example, the values of the query field and the variables field in each json string can be extracted, and a GraphQLRequest can be constructed according to the values of the query field and the variables field.
[0081] Reference Figure 4 According to steps 410 to 430, the received data processing request can be processed.
[0082] Step S410. The query conditions and query variables are extracted from the request data structure object, and a query parameter for inputting the target query engine is generated according to the query conditions and query variables.
[0083] Specifically, the values of the query field and the variables field in the GraphQLRequest can be extracted, and a query parameter for inputting the GraphQL query engine can be generated according to the extracted values of the query field and the variables field. The type of the query parameter can be ExecutionInput. For example, the generated query parameter can be as follows:
[0084]
[0085] Step S420. The query conditions in the query parameter are parsed by the target query engine, and the service method and the service method parameter obtained by parsing are routed to the corresponding method executor.
[0086] After obtaining the query parameter required by the GraphQL query engine, the query conditions in the query parameter, that is, the query field, can be parsed by the GraphQL query engine, the service method and the service method parameter in the query field are obtained, and then the corresponding resolver function can be matched according to the service method and the service method parameter.
[0087] Step S430. The data processing logic of the service method is called by the method executor, and the data processing result is obtained according to the field value of the service method parameter in the query variable.
[0088] The resolver function can call the data processing logic corresponding to the service method in the query field, and after executing the data processing logic, the fields that need to be returned can be filtered according to the values of the variables field to obtain the final data processing result, that is, the fields specified by the client. Finally, the fields specified by the client can be packaged into an ExecutionResult object and returned to the GraphQL query engine.
[0089] In this example embodiment, after receiving the schema statement sent by the client, the service method and the service method parameters in the schema statement are parsed, and the obtained service method and the service method parameters are routed to the corresponding service processing program to obtain the fields specified by the client. When receiving multiple schema statements sent by clients through a unified interface, different application services can be called according to the differences in the schema statements, and the specified data requested by the client can be returned without defining multiple interfaces, which reduces the development cost and improves the transmission efficiency of data. Moreover, for a unified interface, it is also convenient for testers to maintain.
[0090] For example, as shown in FIG. 5, after receiving the data processing request of the client, the corresponding service method can be called according to steps S501 to S506. Figure 5
[0091] Step S501. The first client sends an HTTP (Hyper Text Transfer Protocol) request. For example, a PC sends an HTTP request, and the content of the HTTP request is a schema statement for deleting a sub-area, which is as follows:
[0092]
[0093] Step S502. The second client sends an HTTP request. For example, a mobile terminal sends an HTTP request, and the content of the HTTP request is a schema statement for deleting an intersection parameter, which is as follows:
[0094]
[0095] Step S503. The API aggregation interface receives the HTTP request. For example, two clients can request the same API aggregation interface, so that the same API aggregation interface can complete the deletion of different resources, thereby achieving the effect of aggregation.
[0096] Step S504. The resolver parses the schema statement to obtain the method called in the HTTP request. After the API aggregation interface receives the schema statement for deleting different resources, the resolver parses the schema statement to obtain the service method in the schema statement, so as to route to the corresponding data processing logic (i.e., resource program) according to the parsed deletion method, that is, steps S505 and S506 are executed.
[0097] Step S505. The delete sub-area service is called. When the service method in the schema statement is parsed as the delete sub-area service method, the delete sub-area service is called, and the corresponding sub-area is deleted according to the field value of the service method parameter in the schema statement, such as deleting the sub-area with id 1 in the database table.
[0098] Step S506. The delete intersection parameter service is called. When the service method in the schema statement is parsed as the delete intersection parameter service method, the delete intersection parameter service is called, and the corresponding intersection parameter is deleted according to the field value of the service method parameter in the schema statement, such as deleting the intersection parameter with id 1 in the database table.
[0099] In this example, the APIs with similar behaviors (deleting sub-areas and deleting intersection parameters) in traffic signal control are aggregated into a unified API interface exposed to the outside, which can reduce the redundancy of application layer interfaces and reduce the development workload. Moreover, by specifying the return data of the request by the client, the redundant data generated during data transmission can be effectively reduced, and the efficiency of data transmission is improved.
[0100] In step S230, the data processing result is returned to the client.
[0101] After calling multiple application services to obtain multiple data processing results, the data processing results can be returned to the target query engine for verification. When the data processing result passes the verification, the data processing result can be returned to the client in a preset data format. When the data processing result does not pass the verification, the data processing result can be directly returned to the client.
[0102] For example, after receiving the ExecutionResult object, the GraphQL query engine can verify the ExecutionResult object. For example, it can be determined whether the ExecutionResult object contains error information. Specifically, when the GraphQL query engine calls the application service, if there is an error result, the error result is returned to the server. The server determines whether the error result of the GraphQL query engine is empty. If not, an error has occurred. When the ExecutionResult object contains error information, the error information can be directly returned to the client for error reporting. When the ExecutionResult object does not contain error information, the client-specified field can be obtained from the ExecutionResult object, and the client-specified field can be encapsulated into a ResponseVO object and returned to the client.
[0103] In an example embodiment, referring to FIG. 1, Figure 6 The data processing method provided by the present disclosure can include steps S601 to S608.
[0104] Step S601. The client constructs a json string. After the server creates a schema file, the client can construct a json string containing a query field and a variables field to initiate a request to the server.
[0105] Step S602. The client sends a request.
[0106] Step S603. The server parses the request. After receiving the json string, the server extracts the query field and the variables field in the json string to construct a GraphqlRequest, and then extracts the query field and the variables field in the GraphqlRequest to construct the input parameters required by the GraphQL query engine.
[0107] Step S604. The query engine determines the requested server according to the parsing result. The GraphQL query engine parses the query field in the input parameters, and routes to the corresponding method executor resolver according to the parsing result.
[0108] Step S605. Call the corresponding service method and return the data processing result. The resolver calls the service method to execute the corresponding data processing logic, and selectively returns the data according to the field specified by the client in the request.
[0109] Step S606. Determine whether there is error information. After returning the data to the GraphQL query engine, it can be determined whether there is error information in the data. If there is error information, step S607 is executed, otherwise step S608 is executed.
[0110] Step S607. Return error information.
[0111] Step S608. Return specified data.
[0112] In the data processing method provided in the example embodiments of the present disclosure, a plurality of data processing requests sent by a plurality of clients are received through a preset aggregation interface, the data processing requests carrying service methods and service method parameters; each data processing request is parsed, and a corresponding service method is called according to the parsed service method and service method parameter to obtain a data processing result; and the data processing result is returned to the client. On the one hand, different service methods can be called through a unified interface according to the request fields sent by a plurality of clients, and without defining a plurality of interfaces for different request fields, the specified data requested by the client can be returned, which not only reduces the development cost, but also increases the flexibility of the interface; on the other hand, the data required by the client can be returned according to the request field specified by the client, without returning other invalid data, which improves the data transmission efficiency and avoids data redundancy in the data transmission process.
[0113] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired result. In addition or alternatively, some steps can be omitted, a plurality of steps can be combined into one step, and / or one step can be divided into a plurality of steps, etc.
[0114] Further, in the example embodiments, a data processing apparatus is also provided. As shown in the accompanying drawings, the data processing apparatus 700 can include a request receiving module 710, a request processing module 720, and a request response module 730, wherein: Figure 7
[0115] The request receiving module 710 is configured to receive a plurality of data processing requests sent by a plurality of clients through a preset aggregation interface, the data processing requests carrying service methods and service method parameters;
[0116] The request processing module 720 is configured to parse each data processing request, and call a corresponding service method according to the parsed service method and service method parameter to obtain a data processing result;
[0117] The request response module 730 is configured to return the data processing result to the client.
[0118] In an optional implementation, the data processing apparatus 700 further comprises:
[0119] a file configuration module configured to configure a data mode file, wherein the data mode file comprises a service method, a service method parameter, and a return parameter corresponding to the service method parameter;
[0120] an executor creation module configured to create a method executor, wherein the method executor is configured to invoke data processing logic corresponding to different service methods, and the method executor is configured with the same service method as in the data mode file;
[0121] a method binding module configured to bind the service method in the data mode file with the service method in the method executor, to obtain a target query engine.
[0122] In an optional implementation, the data mode file is configured with at least one service method, and the data processing apparatus 700 further comprises:
[0123] an interface creation module configured to create a preset aggregation interface according to the service method configured in the data mode file, so as to receive data processing requests sent by a plurality of clients through the preset aggregation interface.
[0124] In an optional implementation, the data processing request comprises a query condition and a query variable, wherein the query condition carries the service method and the service method parameter, and the query variable carries a field value of the service method parameter.
[0125] In an optional implementation, the data processing apparatus 700 further comprises:
[0126] a structure object construction module configured to extract the query condition and the query variable in each data processing request, and to construct a request data structure object from the query condition and the query variable.
[0127] In an optional implementation, the request processing module 720 comprises:
[0128] a query parameter generation unit configured to extract the query condition and the query variable from the request data structure object, and to generate a query parameter for inputting the target query engine according to the query condition and the query variable;
[0129] an executor determination unit configured to parse the query condition in the query parameter through the target query engine, and to route to a corresponding method executor according to the parsed service method and service method parameter;
[0130] The data generation unit is configured to invoke the data processing logic of the service method by the method executor, and obtain the data processing result according to the field value of the service method parameter in the query variable.
[0131] In an optional embodiment, the request response module 730 includes:
[0132] The data verification unit is configured to return the data processing result to the target query engine for verification of the data processing result.
[0133] The first data return unit is configured to return the data processing result to the client in a preset data format when the data processing result passes the verification.
[0134] The second data return unit is configured to directly return the data processing result to the client when the data processing result fails to pass the verification.
[0135] The specific details of the modules in the above data processing apparatus have been described in the corresponding data processing method, and thus will not be described here.
[0136] The modules in the above apparatus can be general processors, including central processing units, network processing units, etc. The modules can also be digital signal processors, application specific integrated circuits, field programmable gate arrays, or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The modules can also be implemented in the form of software, firmware, etc. The processors in the above apparatus can be independent processors or integrated together.
[0137] Exemplary embodiments of the present disclosure also provide a computer readable storage medium having stored thereon a program product capable of implementing the above method of the present disclosure. In some possible embodiments, various aspects of the present disclosure can also be implemented in the form of a program product, which includes program codes for causing an electronic device to perform the steps described in the above “Exemplary Method” section according to various exemplary embodiments of the present disclosure when the program product is run on the electronic device. The program product can take the form of a portable compact disc read-only memory (CD-ROM) and include program codes, and can be run on an electronic device, such as a personal computer. However, the program product of the present disclosure is not limited to this, and in this document, the readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus or device.
[0138] A program product can take any combination of one or more computer-readable media. The computer-readable media can be a computer-readable storage medium or a computer-readable signal medium. The computer-readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the above. More specific examples (a non-exhaustive list) of the computer-readable storage medium include an electrical connection having one or more wires, a portable disc, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0139] The computer-readable signal medium can include a computer-readable storage medium that is propagated as a carrier wave in a baseband or propagated as part of a carrier wave of a propagated signal in a baseband. The propagated signal can take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium that is not a computer-readable storage medium and that can communicate, propagate, or transport programming for use by or in connection with an instruction execution system, apparatus, or device.
[0140] The program code embodied on the computer-readable media can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical, RF, and the like, or any suitable combination of the above.
[0141] Program code used to carry out operations of the present disclosure can be written in any combination of one or more programming languages, including an object-oriented programming language such as Java, C++, or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, such as through the Internet using an Internet Service Provider. The present disclosure is not limited to a particular programming language or programming techniques and the program code can be implemented using any programming language.
[0142] An exemplary embodiment of the present disclosure also provides an electronic device capable of implementing the above-described method. The electronic device 800 according to this exemplary embodiment of the present disclosure will be described below with reference to FIG. 8. Figure 8 The electronic device 800 is merely an example and should not impose any limitation on the functions and use range of the embodiments of the present disclosure. Figure 8 The electronic device 800 is merely an example and should not impose any limitation on the functions and use range of the embodiments of the present disclosure.
[0143] As shown in Figure 8 The electronic device 800 can be in the form of a general computing device. Components of the electronic device 800 can include, but are not limited to, at least one processing unit 810, at least one memory unit 820, a bus 830 that connects different system components, including the memory unit 820 and the processing unit 810, and a display unit 840.
[0144] The memory unit 820 stores program codes that can be executed by the processing unit 810, such that the processing unit 810 performs steps according to various exemplary embodiments of the present disclosure described in the "Exemplary Methods" section of the present specification. For example, the processing unit 810 can perform any one or more method steps in the methods of Figures 2 to 6
[0145] The memory unit 820 can include a readable medium in the form of volatile memory units, such as a random access memory (RAM) 821 and / or a cache memory unit 822, and can further include a read-only memory (ROM) 823.
[0146] The memory unit 820 can further include program / utility 824 having a set of the program modules 825, such as an operating system, one or more application programs, other program modules, and program data, and can include implementation of a network environment, each of these examples, or some combination thereof.
[0147] The bus 830 can be representative of one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration bus, a processing bus, or a local bus using any of a variety of bus architectures.
[0148] The electronic device 800 can also communicate with one or more external devices 900 such as a keyboard or pointing device, a Bluetooth device, or a device for enabling
[0149] Those skilled in the art will readily understand that the example embodiments described herein can be implemented by software and / or by hardware components. As such, the technical solutions according to the embodiments of the present disclosure can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (e.g., a CD-ROM, a USB flash drive, a mobile hard disk, or the like) or on a network, and includes a number of instructions for causing a computing device (e.g., a personal computer, a server, a terminal device, or a network device) to perform the methods according to the example embodiments of the present disclosure.
[0150] In addition, the above-described flowcharts are merely schematic illustrations of the processes included in the methods according to the example embodiments of the present disclosure, and are not intended to be limiting. It will be readily understood that the processes shown in the above-described flowcharts do not indicate or limit the time sequence of the processes. In addition, it will be readily understood that the processes can be executed synchronously or asynchronously, for example, in multiple modules.
[0151] It should be noted that, although several modules or units of the device for action execution are mentioned in the foregoing detailed description, such a division is not mandatory. Indeed, according to the embodiments of the present disclosure, the features and functionalities of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functionalities of one module or unit described above can be further divided into several modules or units.
[0152] It should be understood that the present disclosure is not limited to the precise structures described above and illustrated in the drawings and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A data processing method, characterized in that, This method is used to optimize traffic signal control data, which includes at least one of intersection parameter data, sub-zone timing data, and intersection phase records; the data processing method includes: Configure the data schema file and create a method executor; the service methods in the data schema file include a query service method and a change service method, wherein the query service method is used to obtain sub-area data; and the change service method is used to delete sub-areas and delete intersection parameters. Bind the service methods in the data pattern file to the service methods in the method executor to obtain the target query engine, and create a preset aggregation interface according to the service methods configured in the data pattern file of the target query engine; The system receives data processing requests from multiple clients through a preset aggregation interface. The data processing requests carry service methods and service method parameters. Each data processing request is parsed by the target query engine, and the corresponding service method is called according to the parsed service method and service method parameters to obtain the data processing result; The data processing results are returned to the client to optimize traffic signal timing based on the data processing results, and / or delete sub-zones, and / or delete intersection parameters.
2. The data processing method according to claim 1, characterized in that, The data pattern file includes service methods, service method parameters, and return parameters corresponding to the service method parameters; the method executor is used to call the data processing logic corresponding to different service methods, and the method executor is configured with the same service methods as those in the data pattern file.
3. The data processing method according to claim 1, characterized in that, The data processing request includes query conditions and query variables. The query conditions carry the service method and service method parameters, and the query variables carry the field values of the service method parameters.
4. The data processing method according to claim 3, characterized in that, After receiving data processing requests from multiple clients, the method further includes: Extract the query conditions and query variables from each data processing request, and construct a request data structure object from the query conditions and query variables.
5. The data processing method according to claim 4, characterized in that, The process of parsing each data processing request through a preset aggregation interface and calling the corresponding service method based on the parsed service method and service method parameters to obtain the data processing result includes: Extract query conditions and query variables from the request data structure object, and generate query parameters for inputting into the target query engine based on the query conditions and query variables; The target query engine parses the query conditions in the query parameters and routes them to the corresponding method executor based on the parsed service method and service method parameters. The data processing logic of the service method is invoked by the method executor, and the data processing result is obtained based on the field values of the service method parameters in the query variables.
6. The data processing method according to claim 5, characterized in that, Returning the data processing result to the client includes: The data processing result is returned to the target query engine for verification. When the data processing result passes verification, the data processing result is returned to the client according to a preset data format; If the data processing result fails verification, the data processing result will be returned directly to the client.
7. A data processing apparatus, characterized in that, For optimizing traffic signal control data, the traffic signal control data includes at least one of sub-zone timing data, intersection parameter data, and intersection phase records; the data processing device includes: The file configuration module is used to configure the data pattern file and create the method executor; the service methods in the data pattern file include a query service method and a change service method, wherein the query service method is used to obtain sub-area data; and the change service method is used to delete sub-areas and delete intersection parameters. The method binding module is used to bind the service methods in the data pattern file with the service methods in the method executor to obtain the target query engine, and to create a preset aggregation interface according to the service methods configured in the data pattern file of the target query engine. The request receiving module is used to receive data processing requests sent by multiple clients through a preset aggregation interface. The data processing requests carry service methods and service method parameters. The request processing module is used to parse each data processing request through the target query engine, and call the corresponding service method according to the parsed service method identifier and service method parameters to obtain the data processing result; The request-response module is used to return the data processing results to the client so as to optimize the timing of traffic lights and / or delete sub-zones and / or delete intersection parameters based on the data processing results.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-6.
9. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to execute the method of any one of claims 1-6 by executing the executable instructions.
Citation Information
Patent Citations
GraphQL based micro service configuration design method and device and storage equipment
CN109587212A
Data service method and device and readable storage medium
CN112256772A