Disclosure of Invention
In view of the above, in order to solve the technical problem of how to construct a new system by using an old system, embodiments of the present invention provide a construction system, a method, an apparatus, a server and a storage medium for power application.
In a first aspect, an embodiment of the present invention provides a construction system for power applications, including a server and clients communicatively connected to the server, where metadata information and interface information are stored in the server, the server includes a metadata definition module, and the clients are provided with a service data access module;
the unified relational data model establishes a graph model based on the metadata information and accesses all data sources;
the interface information is used for generating a RESTful interface;
the metadata definition module is used for defining metadata to be customized according to requirements;
and the business data access module is used for accessing the RESTful interface by the client.
Optionally, the metadata definition module describes system roles, organizations and/or operation rules using a unified relational data model when modeling the metadata.
Optionally, the data entities of the metadata model include system roles for limiting fields accessible to the user, organizational structures for visibility of records in the generalized table to the user, and business rules defining all business constraints of a particular system.
Optionally, the system role at least includes a system administrator, a service administrator, an audit administrator, a service auditor, a service operator and/or a service configurator.
In a second aspect, an embodiment of the present invention provides a construction method for power application, including:
loading all metadata and interface definitions based on a client request of a construction system facing the power application, and generating a RESTful interface;
determining the authority of the current user based on the current user information acquired after the current user logs in;
and processing and feeding back data based on the authority and the data access instruction triggered by the current user.
In one possible embodiment, the method further comprises:
and classifying the metadata in the preset state, and optimizing the metadata in the preset type.
In a third aspect, an embodiment of the present invention provides a construction apparatus for power application, including:
the data loading module is used for loading all metadata and interface definitions based on a client request of a construction system facing the power application to generate a RESTful interface;
the determining module is used for determining the authority of the current user based on the current user information acquired after the current user logs in;
and the processing module is used for processing and feeding back data based on the authority and the data access instruction triggered by the current user.
In a fourth aspect, an embodiment of the present invention provides a server, including: a processor and a memory, the processor being configured to execute the power application-oriented construction program stored in the memory to implement the power application-oriented construction method in the second aspect.
In a fifth aspect, an embodiment of the present invention provides a storage medium, including: the storage medium stores one or more programs, which are executable by one or more processors to implement the power application oriented construction method in the second aspect described above.
The construction system for the power application comprises a server and each client end in communication connection with the server, wherein metadata information and interface information are stored in the server and comprise a metadata definition module, and the client end is provided with a service data access module; the unified relational data model establishes a graph model based on the metadata information and accesses all data sources; the interface information is used for generating a RESTful interface; the metadata definition module is used for defining metadata to be customized according to requirements; and the business data access module is used for accessing the RESTful interface by the client. Therefore, the purpose of automatically constructing the system can be achieved by utilizing the construction system facing the power application, the workload of developing a new system is reduced, the safety of power information is ensured, and the flexibility is improved aiming at the form of externally providing service interface calling in the power application.
The construction method for the power application comprises the steps of loading all metadata and interface definitions based on a client request of a construction system for the power application, and generating a RESTful interface; determining the authority of the current user based on the current user information acquired after the current user logs in; and processing and feeding back data based on the authority and the data access instruction triggered by the current user. By the method, the power application software system can be simply and quickly constructed, and the metadata in all the databases can be quickly processed and fed back to the front end.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, 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 some, but not all, embodiments of the present invention. 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.
For the convenience of understanding of the embodiments of the present invention, the following description will be further explained with reference to specific embodiments, which are not to be construed as limiting the embodiments of the present invention.
Fig. 1 is a construction diagram of a construction system for power application according to an embodiment of the present invention, as shown in fig. 1, specifically:
the construction system for the power application comprises a server and each client end in communication connection with the server, wherein metadata information and interface information are stored in the server, the server comprises a metadata definition module, and the client end is provided with a service data access module.
The following are introduced separately:
one, metadata information
The metadata information describes data entities and relationships thereof in the business field; all data entities and relationships thereof are described by using a unified relational data model, the metadata information is stored in a relational database, all the operated data is regarded as a table, the table can refer to data in the relational database and can also refer to a file system, an API (application programming interface) and a shell command, and the metadata information defines information such as field names, types, association relationships (main foreign key relationships) and the like in a table in an accessed data source, as shown in FIG. 2.
Constructing a unified relational data model, and firstly multiplexing and recording a role table, an organization table, a user table, an operation log table, a role field authority table, a data field table and the like in a database; secondly, performing business relation modeling and establishing a required business relation table; according to the database table information, automatically inserting all database meta-information into a meta-information table, specifically, the existing database supports the query of the meta-information of tables and fields, not only can directly find the main foreign key information of the data, but also can find which fields, types of the fields, attributes of the fields and the like in the table, the user directly queries in the database, inserts the query result into the meta-information table, and for a non-database table, the part of data needs to be manually inserted; then, configuring a role-field authority table according to the power information security requirement and the service requirement; and finally, configuring an operation definition table according to the power information safety requirement and the service requirement.
Further, the construction system facing the power application further comprises a metadata model, and a data entity of the metadata model comprises a system role, an organization mechanism and/or an operation rule, wherein the system role is used for limiting fields accessible by a user, the organization mechanism is used for limiting visibility of the constructed system to the user, and the operation rule defines all operation constraints of a specific system to ensure consistency and integrity of data.
Optionally, in the power industry, the system roles at least include a system administrator, a service administrator, an audit administrator, a service auditor, a service operator and/or a service configurator, and the operations executable by the system roles and the accessible data are strictly specified in the authority table for each role in advance, that is, the system roles determine fields of the metadata base accessible by the user.
The organization is the organization to which the user belongs and the hierarchy thereof, and corresponds to the organization tree in reality, the organization determines the visibility of the system to the current user, for example, the organization of the user A is the power company A, the system role of the user A can be the system administrator, and the user A can access all data of the power company A; optionally, the organization of the B user is a subsidiary B of the a power company, the B user may access data at a level below the subsidiary B, and the system generated by the builder may automatically add a filter condition according to the organization during operation, so as to ensure that only data accessible by operations is returned or allowed.
Second, interface information
The interface information is used for accessing the metadata, the interface comprises a service data instance which is newly added, deleted, modified and/or inquired, and the service data entity can be from a database or from an API (application program interface), a shell command and a file system. In the invention, a unified relational data model is adopted to automatically generate an interface for simple operations of adding, deleting, modifying and inquiring the business data instance, a pseudo code definition processing flow, namely a workflow, is adopted for complex operations of calculating the business data instance or the interface related to a heterogeneous data source and the like, each statement in the workflow accesses a specific data source through the unified relational data model to carry out data operation, and a constructor analyzes the transformation and transmission of pseudo code processing data to complete the whole workflow.
It should be noted that, the general service data access method includes, but is not limited to, the above enumeration, and in a specific application system, the implementation of the interface information may be specifically implemented, for example, when a new data manipulation and information access mode needs to be added, a new class may be added to the unified relational data model to relate the information, so that the extensibility of the data access mode is ensured.
Third, metadata definition module
The metadata definition module provides a way for defining metadata and restful interface information according to requirements for developers to use, and the operation rules specifically comprise input and output format and semantics; defining an internal flow, namely a flow of simple operation or multi-operation combination; the specific implementation information indicates the access mode of the data source to be operated and even specifies the code method; information of operated data sources, such as a database, a local system command, a third-party interface calling address and the like; data for specific operations, such as which database, which table, which field, or which interface returns a field; whether exposed as an external interface.
It should be noted that the operation rule may also include a special business rule, and the rule is mainly a supplement to other operation rules, such as an organization structure, a system role, an interface definition, and the like, and may be implemented in a black-and-white list manner.
Fourth, service data access module
And the service data access module is used for customizing a service data access interface by a user.
The construction system for the power application comprises a server and each client end in communication connection with the server, wherein metadata information and interface information are stored in the server and comprise a metadata definition module, and the client end is provided with a service data access module; the unified relational data model establishes a graph model based on the metadata information and accesses all data sources; the interface information is used for generating a RESTful interface; the metadata definition module is used for defining metadata to be customized according to requirements; and the business data access module is used for accessing the RESTful interface by the client. Therefore, the purpose of automatically constructing the system can be achieved by utilizing the construction system facing the power application, the workload of developing a new system is reduced, the safety of power information is ensured, and the flexibility is improved aiming at the form of externally providing service interface calling in the power application.
Fig. 3 is a work flow diagram of a construction system for power application according to an embodiment of the present invention, as shown in fig. 3, specifically including:
the method comprises the steps that a user inputs user information after a universal server is started, the user information comprises information of system roles, organizational structures and the like of the user, the system loads system metadata firstly according to the user information, analysis and optimization of the metadata are divided into two parts, namely calling path independence and calling path relevance, information of each interface and source information of a table in a database are stored in the database, the information is shared by all interfaces, the information is loaded when the system is started, and the information is calling path independence; the internal table returns the information related to the specific interface, namely the calling path. When the system is started, only the irrelevant part of the optimized call path is analyzed, wherein the analysis and optimization mode can be cache, the two-dimensional table structure in the database is optimized into other structures, such as a tableB table, and the analysis is not required to be carried out every time the call is carried out; in the operation of the system, when each call occurs, the reusable information on the call path and in the call process is cached, and the reusable information is the same as the field name or SQL statement returned by the access object of the database each time the access object requests the task table. When subsequent similar calling occurs, the cache information is directly read, repeated analysis is avoided, and the response speed is improved.
The generalization of the generalization service end is realized by the automation of increasing, deleting, modifying and even commonly used statistic operation based on the system metadata. The service requirements of each application system in the power industry can be mostly converted or directly realized to be reconstructed after the operation analysis optimization and expressed as a specific application system.
Under the unified relational data model, all data sources including local system calls, third-party system interfaces and the like are placed under the unified relational data model, required relational data operations are compatible in engineering implementation, and therefore automatic association calculation is extended to the outside of a relational database. Optionally, in the system operation process, the reusable association calculation result may be cached, so as to implement "lazy optimization".
Further, any system that meets information security requirements is subject to restrictions on user data access. In order to realize the generalization of the server, the system further realizes the automatic generation of role constraint conditions and mechanism constraint conditions on the basis of automatic data association. As shown in fig. 3, constraints of an operation include: user-defined conditions for data access by a user; and the role constraint condition is used for verifying the legality of the role for carrying out certain operation according to the role authority table. This is a call path-related analysis that can check and cache results when a first such call occurs; the mechanism constraint condition can be determined by the membership between the organization mechanism to which the operator belongs and the organization mechanism to which the data record to be operated belongs in the power industry, so an algorithm for rapidly judging the membership between the organization mechanism and the organization mechanism needs to be realized on the basis of organizing a organization tree.
It should be noted that the business process definition formulated according to the business rules is an important part of the system metadata. In the power industry, the operation behaviors of application systems are almost concentrated on data access, so the complexity of the business process is not reflected in the complexity of a flow chart, but the mapping relation of input and output fields of each operation is included. In this case, the program language is the best expression, and according to the principle that the expression is irrelevant to the specific code implementation, a simple pseudo code expression is designed to be used as a business process definition, and the system can automatically analyze the pseudo code to realize the automation of the process of transmitting documents, information or tasks according to predefined rules and sequences.
Fig. 4 is a schematic flowchart of a construction method for power application according to an embodiment of the present invention, and as shown in fig. 4, the method specifically includes:
s41, loading all metadata and interface definitions based on the client request of the power application-oriented construction system, and generating a RESTful interface.
And S42, classifying the metadata in the preset state, and optimizing the metadata in the preset type.
And S43, determining the authority of the current user based on the current user information acquired after the current user logs in.
And S44, processing and feeding back data based on the authority and the data access instruction triggered by the current user.
Hereinafter, the following descriptions collectively describe S41 to S44:
the method comprises the steps that a user inputs user information after a server side of a construction system facing the electric power application is started, the user information comprises information of system roles, organizational structures and the like of the user, the system receives the user information, loads all metadata and interface definitions according to the user information, generates RESTful interfaces, and divides all the loaded metadata into two types, namely calling path-independent types and calling path-related types according to loading paths of the metadata, wherein information of each interface and source information of tables in the database are stored in the database, the information is shared by all the interfaces, and the information is loaded when the system is started, and the information is information which is calling path-independent; the internal table returns the information related to the specific interface, namely the calling path. After the system loads metadata, only analyzing and optimizing data of a type irrelevant to a call path, wherein the analyzing and optimizing mode can be caching, and a two-dimensional table structure in a database is optimized into other structures, such as a tableB table, and the analysis is not required to be carried out every time the call is carried out; in the operation of the system, when each call occurs, the reusable information on the call path and in the call process is cached, and the reusable information is the same as the field name or SQL statement returned by the access object of the database each time the access object requests the task table. When subsequent similar calling occurs, the cache information is directly read, repeated analysis is avoided, and the response speed is improved.
Furthermore, the access right of the current user to the metadata can be determined according to information such as a system role, an organization and/or an operation rule in the user information, wherein the system role is used for limiting fields accessible by the user, the organization is used for limiting visibility of the constructed system to the user, the operation rule is used for limiting operation of the system to the metadata according to the system role and the organization, and when the user does not have access right to some data, prompt information can be displayed to prompt the user to have no access right or perform operations such as adding, deleting and modifying on the data.
For example, if the current organization of the user a is the power company a, and the system role of the user a may be the system administrator, the user a may access all data of the power company a; optionally, the organization of the B user is a subsidiary B of the a power company, the B user may access data at a level below the subsidiary B, and the system generated by the builder may automatically add a filter condition according to the organization during operation, so as to ensure that only data accessible by returning or only allowing operations is returned
For another example, if the user a is a common employee of a certain company, the authority of the user a may be that only the user a can view information such as his own work data; if the user A is a financial staff of a certain company, the user A can check or perform operations such as adding, deleting and modifying performance information of partial staff in the company; if the user A is a high-level manager of a certain company, the user can view, add, modify and delete the work data of all employees in the company.
Further, all metadata are processed and fed back based on the authority of the user and the data access instruction triggered by the current user.
For example, the user a is a high-level manager of a certain company, the data access instruction input by the user a is to check the work data of a certain group of employees, and the system queries the database according to the data access instruction, and exports and displays all the work data of the corresponding group of employees.
The construction method for the power application comprises the steps of loading all metadata and interface definitions based on a client request of a construction system for the power application, and generating a RESTful interface; classifying metadata in a preset state, and optimizing the metadata in a preset type; determining the authority of the current user based on the current user information acquired after the current user logs in; and processing and feeding back data based on the authority and the data access instruction triggered by the current user. By the method, the power application software system can be simply and quickly constructed, and the metadata in all the databases can be quickly processed and fed back to the front end.
Fig. 5 is a schematic structural diagram of a construction apparatus for power application according to an embodiment of the present invention, including:
the data loading module 501 is configured to load all metadata and interface definitions based on a client request of a power application-oriented construction system, and generate a RESTful interface;
a determining module 502, configured to determine an authority of a current user based on current user information obtained after the current user logs in;
and the processing module 503 is configured to process and feed back data based on the authority and the data access instruction triggered by the current user.
In a possible implementation manner, the processing module 503 is specifically configured to classify metadata in a preset state, and perform optimization processing on the preset type of metadata.
The electric power application-oriented construction apparatus provided in this embodiment may be the electric power application-oriented construction apparatus shown in fig. 5, and may perform all the steps of the electric power application-oriented construction method shown in fig. 4, so as to achieve the technical effect of the electric power application-oriented construction method shown in fig. 4, and please refer to the description related to fig. 4 for brevity, which is not described herein again.
Fig. 6 is a schematic structural diagram of a server according to an embodiment of the present invention, where the server 600 shown in fig. 6 includes: at least one processor 601, memory 602, at least one network interface 604, and other user interfaces 603. The various components in server 600 are coupled together by a bus system 605. It is understood that the bus system 605 is used to enable communications among the components. The bus system 605 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are labeled as bus system 605 in fig. 6.
The user interface 603 may include, among other things, a display, a keyboard, or a pointing device (e.g., a mouse, trackball, touch pad, or touch screen, among others.
It will be appreciated that the memory 602 in embodiments of the invention may be either volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. The non-volatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable PROM (EEPROM), or a flash Memory. Volatile Memory can be Random Access Memory (RAM), which acts as external cache Memory. By way of illustration and not limitation, many forms of RAM are available, such as Static random access memory (Static RAM, SRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic random access memory (Synchronous DRAM, SDRAM), Double Data Rate Synchronous Dynamic random access memory (ddr Data Rate SDRAM, ddr SDRAM), Enhanced Synchronous SDRAM (ESDRAM), Synchlink DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 602 described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
In some embodiments, memory 602 stores the following elements, executable units or data structures, or a subset thereof, or an expanded set thereof: an operating system 6021 and application programs 6022.
The operating system 6021 includes various system programs, such as a framework layer, a core library layer, a driver layer, and the like, and is used for implementing various basic services and processing hardware-based tasks. The application program 6022 includes various application programs such as a Media Player (Media Player), a Browser (Browser), and the like, and is used to implement various application services. A program implementing the method of an embodiment of the invention can be included in the application program 6022.
In the embodiment of the present invention, by calling a program or an instruction stored in the memory 602, specifically, a program or an instruction stored in the application program 6022, the processor 601 is configured to execute the method steps provided by the method embodiments, for example, including:
loading all metadata and interface definitions based on a client request of a construction system facing the power application, and generating a RESTful interface; determining the authority of the current user based on the current user information acquired after the current user logs in; and processing and feeding back data based on the authority and the data access instruction triggered by the current user.
In a possible embodiment, after all metadata and interface definitions are loaded and a RESTful interface is generated, metadata in a preset state is classified, and metadata in a preset type is optimized.
The method disclosed by the above-mentioned embodiment of the present invention can be applied to the processor 601, or implemented by the processor 601. The processor 601 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 601. The Processor 601 may be a general-purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, or discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software elements in the decoding processor. The software elements may be located in ram, flash, rom, prom, or eprom, registers, among other storage media that are well known in the art. The storage medium is located in the memory 602, and the processor 601 reads the information in the memory 602 and completes the steps of the method in combination with the hardware thereof.
It is to be understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or any combination thereof. For a hardware implementation, the Processing units may be implemented within one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), general purpose processors, controllers, micro-controllers, microprocessors, other electronic units configured to perform the functions described herein, or a combination thereof.
For a software implementation, the techniques described herein may be implemented by means of units performing the functions described herein. The software codes may be stored in a memory and executed by a processor. The memory may be implemented within the processor or external to the processor.
The server provided in this embodiment may be the server shown in fig. 6, and may execute all the steps of the construction method for power application shown in fig. 4, so as to achieve the technical effect of the construction method for power application shown in fig. 4.
The embodiment of the invention also provides a storage medium (computer readable storage medium). The storage medium herein stores one or more programs. Among others, the storage medium may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, a hard disk, or a solid state disk; the memory may also comprise a combination of memories of the kind described above.
When one or more programs in the storage medium are executable by one or more processors, the automatic printing method executed on the server side is realized.
The processor is used for executing the electric power application-oriented construction program stored in the memory to realize the following steps of the electric power application-oriented construction method executed on the server side:
loading all metadata and interface definitions based on a client request of a construction system facing the power application, and generating a RESTful interface; determining the authority of the current user based on the current user information acquired after the current user logs in; and processing and feeding back data based on the authority and the data access instruction triggered by the current user.
In a possible embodiment, after all metadata and interface definitions are loaded and a RESTful interface is generated, metadata in a preset state is classified, and metadata in a preset type is optimized.
Those of skill would further appreciate that the various illustrative components and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied in hardware, a software module executed by a processor, or a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.