Disclosure of Invention
In view of this, in order to solve the above-mentioned technical problem of how to build a new system by using an old system, the embodiments of the present invention provide a power application-oriented building system, a method, an apparatus, a server, and a storage medium.
In a first aspect, an embodiment of the present invention provides a power application-oriented building system, including a server, and each client connected to the server in a communication manner, where metadata information and interface information are stored in the server, and the server includes a metadata definition module, and the client is provided with a service data access module;
the unified relation 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;
the business data access module is used for the client to access the RESTful interface.
Optionally, the metadata definition module uses a unified relational data model to describe system roles, organizations, and/or operational rules when modeling metadata.
Optionally, the data entity of the metadata model includes a system role, an organization mechanism, and a business rule, wherein the system role is used for limiting fields that can be accessed by a user, the organization mechanism is used for the visibility of records in the generalized table to the user, and the business rule defines all business constraints of a specific system.
Optionally, the system roles include at least a system administrator, a business administrator, an audit administrator, a business auditor, a business operator, and/or a business configurator.
In a second aspect, an embodiment of the present invention provides a method for constructing an electric power application, including:
based on a client request of a power application-oriented building system, loading all metadata and interface definitions, and generating a RESTful interface;
determining the authority of a current user based on current user information acquired after the current user logs in;
and processing and feeding back data based on the permission and the data access instruction triggered by the current user.
In one possible embodiment, the method further comprises:
classifying metadata in a preset state, and optimizing the metadata in a preset type.
In a third aspect, an embodiment of the present invention provides a power application-oriented building apparatus, including:
the data loading module is used for loading all metadata and interface definitions based on a client request of a power application-oriented construction system and generating 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 the data based on the permission and the data access instruction triggered by the current user.
In a fourth aspect, an embodiment of the present invention provides a server, including: the power application-oriented building method of the second aspect includes a processor and a memory, where the processor is configured to execute a power application-oriented building program stored in the memory to implement the power application-oriented building method of 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 executable by one or more processors to implement the power application oriented construction method in the second aspect.
The power application-oriented construction system provided by the embodiment of the invention comprises a server and various clients which are 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 clients are provided with a service data access module; the unified relation 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; the business data access module is used for the client to access the RESTful interface. 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 in terms of the form of calling the service interface provided to the outside in the power application.
The power application-oriented construction method provided by the embodiment of the invention comprises the steps of loading all metadata and interface definitions based on a client request of a power application-oriented construction system to generate a RESTful interface; determining the authority of a current user based on current user information acquired after the current user logs in; and processing and feeding back data based on the permission 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 metadata in all databases can be rapidly processed and fed back to the front end.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
For the purpose of facilitating an understanding of the embodiments of the present invention, reference will now be made to the following description of specific embodiments, taken in conjunction with the accompanying drawings, which are not intended to limit the embodiments of the invention.
Fig. 1 is a structural diagram of a construction system for electric power application according to an embodiment of the present invention, as shown in fig. 1, specifically:
the power application-oriented construction system provided by the embodiment of the invention comprises a server and each client which is 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 is provided with a service data access module.
The following are respectively described:
1. metadata information
The metadata information describes data entities and relations of the service field; all data entities and their relations are described by using a unified relational data model, the metadata information is stored in a relational database, the data of all operations are regarded as tables, the tables can refer to the data in the relational database, and can refer to file systems, APIs and shell commands, and the metadata information defines the information of field names, types, association relations (main external key relations) and the like in the accessed data sources, as shown in fig. 2.
Constructing a unified relational data model, and firstly multiplexing 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 and recording in a database; secondly, modeling the business relationship, and establishing a required business relationship table; according to the information of the database table, the meta information of all databases is automatically inserted into the meta information table, specifically, the existing databases support the inquiry of the meta information of the tables and the fields, so that the main external key information of the data can be directly inquired, the fields, the types of the fields, the attributes of the fields and the like in the tables can be directly inquired in the databases, the inquiry result is inserted into the meta information table, and for the non-database table, the part of the data needs to be manually inserted; then, configuring a role-field permission table according to the power information security requirements and the service requirements; and finally, configuring an operation definition table according to the power information security requirement and the service requirement.
Further, the power application-oriented construction system further comprises a metadata model, wherein a data entity of the metadata model comprises a system role, an organization mechanism and/or an operation rule, the system role is used for limiting fields which can be accessed by a user, the organization mechanism is used for limiting the visibility of the constructed system to the user, and the business rule defines all business constraints of a specific system and ensures 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 operations executable by each system role and accessible data are strictly defined in the authority table for each role in advance, that is, the system roles determine fields of a metadata base accessible to the user.
The organization is an organization to which the user belongs and a hierarchy thereof, corresponds to an organization tree in reality, and determines the visibility of the system to the current user, for example, the organization of the user A is an A power company, the system role of the user A can be a system administrator, and the user A can access all data of the A power company; optionally, the organization of the B user is a sub-company B of the a power company, so that the B user can access the data of the level below the sub-company B, and the system generated by the constructor automatically increases the filtering condition according to the organization during operation, so that only the data accessible by the operation is returned or only allowed.
2. Interface information
The interface information is used for accessing metadata, and the interface comprises a new service data instance, a deleted service data instance, a modified service data instance and/or a query obtained service data instance, wherein the service data entity can be from a database, an API (application program interface), a shell command and a file system. In the invention, the operation of simply adding, deleting, modifying and inquiring the business data instance adopts a unified relation data model to automatically generate an interface, and the complex operation of calculating the business data instance or the interface related to heterogeneous data sources and the like is performed through the flow of pseudo code definition processing, namely, workflow, each statement in the workflow accesses a specific data source through the unified relation data model to perform data operation, and a constructor analyzes the transformation and the transmission of pseudo code processing data to complete the whole workflow.
It should be noted that, the general access method for service data includes, but is not limited to, the above enumeration, and in a specific application system, the implementation manner of the interface information may be specifically implemented, for example, when a new data manipulation and an information access manner need to be added, a new class may be added in the unified relational data model, so that the information is related, and thus, the expandability of the data access manner is ensured.
3. Metadata definition module
The metadata definition module provides a path for defining metadata and restful interface information according to requirements for a developer to use, and the operation rule specifically comprises a format and semantics for defining input and output; defining an internal flow, namely a simple operation or a multi-operation combined flow; the specific implementation information indicates the access mode of the data source to be operated and even the code method is clear; operational data source information such as databases, local system commands, third party interface call addresses, etc.; data of 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 rules may also include special business rules, and the rules are mainly complements of other operation rules, such as organization structures, system roles, interface definitions, and the like, and may be implemented in a black-and-white list manner.
4. Service data access module
The business data access module is used for customizing the business data access interface by a user.
The power application-oriented construction system provided by the embodiment of the invention comprises a server and various clients which are 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 clients are provided with a service data access module; the unified relation 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; the business data access module is used for the client to access the RESTful interface. 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 in terms of the form of calling the service interface provided to the outside in the power application.
Fig. 3 is a workflow diagram of a construction system for electric power application according to an embodiment of the present invention, as shown in fig. 3, specifically including:
after the user starts up at the generalized server, inputting user information, wherein the user information comprises information such as user system roles, organization and the like, the system firstly loads system metadata according to the user information, and analyzes and optimizes the metadata into two parts of irrelevant calling paths and relevant calling paths, wherein the information of each interface and source information in the database are stored in the database, the information is shared by all interfaces, and the information is loaded when the system starts up, namely, the information irrelevant to the calling paths; the interface internally records a database operation, and the field returned by the internal table is related to the specific interface, namely the information related to the calling path. When the system is started, only an irrelevant part of the optimized calling path is analyzed, wherein the analysis and optimization mode can be cache, and the two-dimensional table structure in the database is optimized into other structures, such as a TableB table, and analysis is not needed when each calling is performed; in the system operation, 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 request task list of the access object of the database each time. And when the subsequent similar call occurs, the cache information is directly read, repeated analysis is avoided, and the response speed is improved.
The universality of the generalized server is embodied on the automatic realization of common statistical operations even for adding, deleting and checking based on system metadata. The business requirements of all application systems in the power industry can be mostly converted or directly realized into the operation analysis, the reconstruction and the expression of the operation analysis, the optimization and the reconstruction are realized as a specific application system.
Under the unified relational data model, each data source comprising local system call, third party system interface and the like is placed under the unified relational data model, and the required relational data operation is compatible on engineering realization, so that automatic association calculation is extended to the outside of a relational database, as shown in fig. 3, as long as data fields required by a certain operation are indicated in an operation definition table, even if the fields are scattered in different data sources, the system automatically completes all association calculation for the operation, for example, through a metadata table of the unified relational model, the automatic association calculation can be completed as long as the relationship of corresponding fields of two tables is found, the data of the two tables are combined into a return result according to the main external key association relationship, and the outside looks like accessing one table. Optionally, in the running process of the system, the reusable association calculation result can be cached, so as to realize lazy optimization.
Further, any system meeting information security requirements is subject to data access constraints for the user. In order to realize the generalization of the server, on the basis of automatic data association, the system further realizes the automatic generation of role constraint conditions and mechanism constraint conditions. As shown in fig. 3, constraints for one operation include: user-defined conditions for data access by a user; and checking the legality of the role for performing certain operation according to the role constraint condition and the role authority table. This is an analysis of call path correlation that can check and cache results when the first such call occurs; the mechanism constraint condition can be determined by the membership of an organization to which an operator belongs and an organization to which a data record to be operated belongs in the power industry, so that an algorithm for rapidly judging the membership of the organization to which the operator belongs is needed on the basis of an 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. Within the power industry, the operation behavior of an application system is almost focused on data access, and therefore, the complexity of the business process is not reflected in the complexity of the flow chart, but the mapping relationship of the input and output fields of each operation. In this case, the programming language is the best expression, and according to the principle that the expression is irrelevant to specific code implementation, a simple pseudo code expression is designed as a business process definition, and the system automatically analyzes the pseudo code to realize the automation of the process of delivering documents, information or tasks according to predefined rules and sequences.
Fig. 4 is a flow chart of a construction method for electric power application according to an embodiment of the present invention, as shown in fig. 4, where the method specifically includes:
s41, loading all metadata and interface definitions based on a client request of a power application-oriented building system, and generating a RESTful interface.
S42, classifying metadata in a preset state, and optimizing the metadata in a preset type.
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 permission and the data access instruction triggered by the current user.
Hereinafter, S41 to S44 will be collectively described:
after a user starts a server side of a power application-oriented construction system, inputting user information, wherein the user information comprises information such as user system roles, organization and the like, the system receives the user information and loads all metadata and interface definitions according to the user information, a RESTful interface is generated, all loaded metadata are divided into two types of irrelevant calling paths and relevant calling paths according to loading paths of the metadata, information of all interfaces and source information in a database are stored in the database, the information is shared by all interfaces, and the information is loaded when the system starts, namely, the information irrelevant to the calling paths; the interface internally records a database operation, and the field returned by the internal table is related to the specific interface, namely the information related to the calling path. After metadata is loaded by the system, only data of an irrelevant type of an optimized calling path is analyzed, wherein the analysis and optimization mode can be cache, and a two-dimensional table structure in a database is optimized into other structures, such as a TableB table, and analysis is not needed when each calling is performed; in the system operation, 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 request task list of the access object of the database each time. And when the subsequent similar call occurs, the cache information is directly read, repeated analysis is avoided, and the response speed is improved.
Further, the access right of the current user to the metadata can be determined according to information such as a system role, an organization mechanism and/or an operation rule in the user information, wherein the system role is used for limiting fields which can be accessed by the user, the organization mechanism is used for limiting the visibility of the constructed system to the user, the operation rule is used for limiting the operation of the system to the metadata according to the system role and the organization mechanism, and when the user does not have the access right of certain data, prompt information can be displayed to prompt the user to have no access right or to perform operations such as adding, deleting, modifying and the like on the data.
For example, when the current organization of the a user is an a power company, and the system role of the a user may be a system administrator, the a user may access all data of the a power company; optionally, the organization of the B user is a sub-company B of the a power company, so that the B user can access the data of the level below the sub-company B, and the system generated by the constructor automatically increases the filtering condition according to the organization during operation, so as to ensure that only the data which can be accessed by the operation is returned or only allowed
For another example, when the current a user is a common employee of a certain company, the authority of the a user can be that only the information such as the working data of the a user can be checked; if the A user is a financial staff of a certain company, the A user can check or perform operations such as adding, deleting, modifying performance information of staff in the company; if the A user is a high-level manager of a certain company, the user can view, add, modify and delete the work data of all staff 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 senior manager of a company, the data access instruction input by the user a is to view the working data of a group of employees, and the system queries the database according to the data access instruction to export and display all the working data of the employees of the corresponding group.
The power application-oriented construction method provided by the embodiment of the invention comprises the steps of loading all metadata and interface definitions based on a client request of a power application-oriented construction system to generate a RESTful interface; classifying metadata in a preset state, and optimizing the metadata in a preset type; determining the authority of a current user based on current user information acquired after the current user logs in; and processing and feeding back data based on the permission 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 metadata in all databases can be rapidly processed and fed back to the front end.
Fig. 5 is a schematic structural diagram of a construction device for electric 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 building system, and generate a RESTful interface;
a determining module 502, configured to determine authority of a current user based on current user information acquired after the current user logs in;
and the processing module 503 is configured to process and feed back data based on the permission and the data access instruction triggered by the current user.
In one possible implementation manner, the processing module 503 is specifically configured to classify metadata in a preset state, and perform optimization processing on metadata in a preset type.
The power application-oriented construction device provided in this embodiment may be the power application-oriented construction device shown in fig. 5, and may perform all steps of the power application-oriented construction method shown in fig. 4, so as to achieve the technical effects of the power application-oriented construction method shown in fig. 4, and the description thereof will be omitted herein for brevity.
Fig. 6 is a schematic structural diagram of a server according to an embodiment of the present invention, and a 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 connected communications between these components. The bus system 605 includes a power bus, a control bus, and a status signal bus in addition to a data bus. But for clarity of illustration 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, a trackball, a touch pad, or a touch screen, etc.).
It is to 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 nonvolatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable EPROM (EEPROM), or a flash Memory. The volatile memory may be random access memory (Random Access Memory, RAM) which acts as an external cache. By way of example, and not limitation, many forms of RAM are available, such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (Double Data Rate SDRAM), enhanced SDRAM (ESDRAM), synchronous DRAM (SLDRAM), and Direct 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 implementations, the memory 602 stores the following elements, executable units or data structures, or a subset thereof, or an extended 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, for implementing various basic services and processing hardware-based tasks. The application 6022 includes various application programs such as a Media Player (Media Player), a Browser (Browser), and the like for realizing various application services. The program for implementing the method of the embodiment of the present invention may be included in the application 6022.
In the embodiment of the present invention, the processor 601 is configured to execute the method steps provided by the method embodiments by calling a program or an instruction stored in the memory 602, specifically, a program or an instruction stored in the application 6022, for example, including:
based on a client request of a power application-oriented building system, loading all metadata and interface definitions, and generating a RESTful interface; determining the authority of a current user based on current user information acquired after the current user logs in; and processing and feeding back data based on the permission and the data access instruction triggered by the current user.
In one possible implementation manner, after the loading of all metadata and interface definitions and the generation of the RESTful interface, the metadata in the preset state is classified, and the metadata in the preset type is optimized.
The method disclosed in the above embodiment of the present invention may be applied to the processor 601 or implemented by the processor 601. The processor 601 may be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in the processor 601 or instructions in the form of software. The processor 601 may be a general purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The disclosed methods, steps, and logic blocks 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 embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software elements in a decoding processor. The software elements may be located in a random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory 602, and the processor 601 reads information in the memory 602 and performs the steps of the above method in combination with its hardware.
It is to be understood that the embodiments described herein may be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For a hardware implementation, the processing units may be implemented within one or more application specific integrated circuits (Application Specific Integrated Circuits, ASIC), digital signal processors (Digital Signal Processing, DSP), digital signal processing devices (dspev, DSPD), programmable logic devices (Programmable Logic Device, PLD), field programmable gate arrays (Field-Programmable Gate Array, FPGA), general purpose processors, controllers, micro-controllers, microprocessors, other electronic units designed 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 that perform 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 a server as shown in fig. 6, and may perform all steps of the power application-oriented construction method shown in fig. 4, so as to achieve the technical effects of the power application-oriented construction method shown in fig. 4, and the description thereof will be specifically referred to in fig. 4, and is omitted herein for brevity.
The embodiment of the invention also provides a storage medium (computer readable storage medium). The storage medium here stores one or more programs. Wherein the storage medium may comprise volatile memory, such as random access memory; the memory may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid state disk; the memory may also comprise a combination of the above types of memories.
When one or more programs are stored in the storage medium, the one or more programs can be executed by one or more processors to implement the automatic printing method performed on the server side.
The processor is configured to execute a power application-oriented building program stored in the memory, so as to implement the following steps of a power application-oriented building method executed on a server side:
based on a client request of a power application-oriented building system, loading all metadata and interface definitions, and generating a RESTful interface; determining the authority of a current user based on current user information acquired after the current user logs in; and processing and feeding back data based on the permission and the data access instruction triggered by the current user.
In one possible implementation manner, after the loading of all metadata and interface definitions and the generation of the RESTful interface, the metadata in the preset state is classified, and the metadata in the preset type is optimized.
Those of skill would further appreciate that the various illustrative elements 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 elements and steps are described above generally in terms of function in order to clearly illustrate the 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 solution. 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, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed 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 foregoing description of the embodiments has been provided for the purpose of illustrating the general principles of the invention, and is not meant to limit the scope of the invention, but to limit the invention to the particular embodiments, and any modifications, equivalents, improvements, etc. that fall within the spirit and principles of the invention are intended to be included within the scope of the invention.