System and method for realizing timed task change operation
By introducing a matching and update mechanism for task configuration tables and triggers in the timing task system, the problem of restarting the project by modifying the timing task configuration is solved, and the timing is changed and maintained without affecting the project's operation, which improves timing Maintainability of tasks.
Patent Information
- Application Number
- CN202411238824.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-12-31
AI Technical Summary
During the project update and iteration process, modification of the timed task configuration requires restarting the project, resulting in failure to update in time, or restarting the project has adverse effects on the project operation.
A system is designed to implement timing task change operations, including timing task viewing module, management module and permission module. Through matching updates of task configuration tables and triggers, the timing task change operations are allowed without affecting the operation of the project. .
It realizes changing and maintaining timing tasks without affecting the normal operation of the project, improving the maintainability of timing tasks.
Smart Images

Figure CN119225849A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a system and method for implementing a scheduled task change operation. Background Art
[0002] When the project is small and there are few scheduled tasks, the scheduled tasks are placed in the business code and the scheduled task configuration is placed in the project configuration file. This method is simple, efficient and has a short development cycle. However, as the project is updated and iterated, more and more scheduled tasks are used. The disadvantages of this method of placing scheduled tasks in the business code and placing the scheduled task configuration in the project configuration file become more and more obvious. When the scheduled task configuration needs to be modified, the project needs to be restarted. However, since the operation of the project cannot be interrupted at any time, the scheduled tasks cannot be updated in time, or the project cannot be restarted at any time, which will have an adverse impact on the normal operation of the project. Summary of the invention
[0003] In order to solve the above technical problems, the present invention is proposed. The embodiments of the present invention provide a system and method for implementing a scheduled task change operation, which can change a scheduled task without affecting the normal operation of a project.
[0004] According to one aspect of the present invention, there is provided a system for implementing a scheduled task change operation, comprising: a scheduled task viewing module, the scheduled task viewing module being configured to view scheduled tasks in a task configuration table; wherein the task configuration table comprises fields for storing creation triggers and management of scheduled tasks; a scheduled task management module, the scheduled task management module being communicatively connected to the scheduled task viewing module, the scheduled task management module being configured to update the task configuration table according to a matching result between a trigger and a scheduled task in the task configuration table; and a permission module, the permission module being communicatively connected to the scheduled task viewing module, the permission module being configured to classify data and set corresponding management permissions for different types of data.
[0005] In one embodiment, the system for implementing the scheduled task change operation also includes: a task operation log module, which is communicatively connected to the scheduled task viewing module and the scheduled task management module, and the task operation log module is configured to record the operation status of the scheduled task; wherein the operation status includes the scheduled task identification code, the start time of the operation, the end time of the operation, the consumed time, whether the operation is successful, the functional description of the task and the error log; an operation report display module, which is communicatively connected to the task operation log module, and the operation report display module is configured to count the operation status of the scheduled task and generate a graph to display the number of successful operations, the number of failed operations and the success rate.
[0006] In one embodiment, the scheduled task viewing module includes: a scheduled task information query unit, which is configured to perform data screening based on query conditions to return the user's scheduled tasks; wherein the query conditions include a scheduled task identification code and a scheduled task name; the permission module includes: a scheduled task permission query unit, which is configured to verify the user's permissions before performing data screening based on the query conditions; wherein, when the user's permissions are verified to be an administrator, query permissions for all scheduled tasks are provided, and when the user's permissions are verified to be a non-administrator, query permissions for the user's own scheduled tasks are provided.
[0007] In one embodiment, the scheduled task management module includes: a scheduled task verification unit, which is configured to verify whether the identification code of the scheduled task is repeated and whether the time expression complies with the rules; a scheduled task editing unit, which is communicated with the scheduled task verification unit, and the scheduled task editing unit is configured to update the scheduled task in the task configuration table according to the time expression of the trigger when the trigger and the scheduled task in the task configuration table match successfully and the time expression of the trigger is different from the time expression of the scheduled task in the task configuration table; a scheduled task identification code verification unit, which is configured to query the task configuration table according to the input scheduled task identification code. If the scheduled task identification code exists in the task configuration table, the scheduled task identification code verification fails.
[0008] In one embodiment, the permission module also includes: a scheduled task editing permission unit, and the scheduled task change permission unit is configured to verify the user's permissions before updating the scheduled task verified by the scheduled task verification unit; wherein, when the verified user's permissions are for administrators, editing permissions for all scheduled tasks are provided, and when the verified user's permissions are for non-administrators, editing permissions for the user's own scheduled tasks are provided.
[0009] In one embodiment, the scheduled task management module also includes: a scheduled task deletion unit, which is configured to delete the data in the task configuration table according to the scheduled task identification code of the scheduled task; a scheduled task closing unit, which is configured to close the scheduled task to stop running the scheduled task; wherein, after closing the scheduled task by the scheduled task closing unit, the scheduled task can be opened again, and after deleting the scheduled task by the scheduled task deletion unit, it cannot be restored.
[0010] According to another aspect of the present invention, a method for implementing a scheduled task change operation is provided, which is applied to a system for implementing a scheduled task change operation as described in any of the above-mentioned embodiments, and the method for implementing a scheduled task change operation includes: obtaining a registered trigger, and scanning a task configuration table through the scheduled task viewing module to obtain a scheduled task in the task configuration table; wherein the registered trigger represents the actual execution content of the scheduled task; through the scheduled task management module, comparing a trigger key of the trigger and a scheduled task in the task configuration table; wherein the trigger key represents a condition that causes the trigger to be activated; when the scheduled task represented by the registered trigger already exists in the task configuration table, and the time expression of the registered trigger is different from the time expression in the task configuration table, the time expression of the registered trigger is updated to the task configuration table through the scheduled task management module.
[0011] In one embodiment, the method for implementing a scheduled task change operation also includes: if the scheduled task in the task configuration table does not match a corresponding trigger, loading the found path to create a trigger, and waiting for the condition of the time expression to be met to automatically execute the corresponding code segment; if the registered trigger does not exist in the task configuration table, deleting the registered trigger.
[0012] In one embodiment, when the scheduled task represented by the registered trigger already exists in the task configuration table, and the time expression of the registered trigger is different from the time expression in the task configuration table, the time expression of the registered trigger is updated to the task configuration table through the scheduled task management module, including: when the scheduled task represented by the registered trigger already exists in the task configuration table, and the time expression of the registered trigger is different from the time expression in the task configuration table, checking whether the time expression of the trigger meets the preset format requirements; when the time expression of the trigger meets the preset format requirements, updating the time expression of the registered trigger to the task configuration table through the scheduled task management module.
[0013] In one embodiment, the method for implementing a scheduled task change operation also includes: in response to a batch update instruction, obtaining a task identification code of the scheduled task to be updated and a scheduled task identification code in a task configuration table; verifying whether the task identification code of the scheduled task to be updated is repeated with the scheduled task identification code in the task configuration table; when the task identification codes of the scheduled tasks to be updated are not repeated with the scheduled task identification codes in the task configuration table, verifying whether the time expression of the scheduled task to be updated meets a preset format requirement; when the time expression of the scheduled task to be updated meets the preset format requirement, updating the task configuration table based on the scheduled task to be updated.
[0014] The system and method for implementing scheduled task change operations provided by the present invention can facilitate viewing of scheduled tasks in a task configuration table, and update the task configuration table according to the matching results between triggers and scheduled tasks in the task configuration table. By changing scheduled tasks based on triggers, scheduled tasks can be changed without affecting project operation, thereby improving the maintainability of scheduled tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The above and other purposes, features and advantages of the present invention will become more apparent by describing the embodiments of the present invention in more detail in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings, the same reference numerals generally represent the same components or steps.
[0016] Figure 1 It is a structural diagram of a system for implementing a scheduled task change operation provided by an exemplary embodiment of the present invention.
[0017] Figure 2 It is a flowchart of a method for implementing a scheduled task change operation provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0018] Below, the exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described here.
[0019] In some implementations, the basis for the present invention to implement the scheduled task CRUD operation is to configure the task configuration table and triggers. A trigger is a special object or stored procedure in a database management system. It is associated with the task configuration table and is used to automatically trigger a series of operations or logic when a specific event (such as insert, update, delete, etc.) on the task configuration table occurs. A trigger is a special type of stored procedure, and its execution is not called by a program or started manually, but is triggered by an event in a database. When the conditions defined by the trigger are met, the trigger will automatically execute the corresponding action without manual intervention. The trigger is usually associated with the task configuration table. When the data in the task configuration table changes, the trigger will perform operations according to predefined rules. The execution of the trigger is triggered by an event in the database (such as INSERT, UPDATE, DELETE, etc.). The trigger can check whether the insert, update or delete operation complies with the defined rules and constraints. By creating a trigger, the business logic can be automatically executed when the data changes, thereby improving the efficiency of data processing. Therefore, the actual execution content of the scheduled task is placed in the trigger, which can take effect without restarting the project, and will not affect the normal operation of the project. The task configuration table is used to store fields for creating triggers and managing scheduled tasks. In order to facilitate the maintenance of scheduled tasks, the table structure of scheduled tasks requires the classification to be as accurate as possible, the fields to be as comprehensive as possible, and the structure to be as concise as possible. The task configuration table structure requires the scheduled task code (identification code), the class path of the code segment, and the switch. The class path is the path used by the Java Runtime Environment (JRE) to find and load class files (.class) and resource files (such as .properties, .xml, etc.).
[0020] The CRUD operations of scheduled tasks are the basic and core operations in database operations, representing four operations: Create, Retrieve, Update, and Delete. Create means adding new data items to the database. This usually involves inserting one or more rows of data into a table. For example, in a task configuration table, you may need to create a new scheduled task, which involves inserting a record containing the scheduled task into the task configuration table. Retrieve: Retrieve data from the database. This can be retrieving all data in the table or retrieving data that meets specific conditions. For example, you may need to query the name and identification code of the scheduled task. Update: Modify existing data items in the database. This usually involves modifying one or more rows of data in the task configuration table. For example, if the time expression of the scheduled task changes, you may need to update the corresponding record in the task configuration table to reflect this change. Delete: Remove data items from the database. This involves deleting one or more rows of data from the table. For example, if a user decides to delete a scheduled task, he may need to delete the record of the scheduled task from the task configuration table. Therefore, the CRUD operations of scheduled tasks represent the changes of scheduled tasks.
[0021] There is a close relationship between scheduled tasks and triggers. Triggers play an important role in CRUD (create, read, update, delete) scheduled tasks. Scheduled tasks refer to tasks that are automatically executed at a scheduled time. These tasks can be simple script execution, data backup, system maintenance, etc. Triggers define the conditions or time rules for when to trigger (i.e., execute) scheduled tasks. It is the core component of scheduled task execution and determines when the task is executed. Scheduled tasks rely on triggers to determine the execution time point. Once the conditions set by the trigger (such as a specific time, event trigger, etc.) are met, the scheduled task will be automatically executed. Therefore, in CRUD scheduled tasks, the role of triggers is mainly reflected in the following aspects: (1) Triggers can accurately set the execution time of scheduled tasks, including specific time points, dates, time intervals, etc. This ensures that tasks can be accurately executed according to the scheduled time plan; (2) In addition to time control, some triggers can also trigger scheduled tasks based on the occurrence of specific events. For example, when a table in the database is updated, a related scheduled task can be triggered to perform data synchronization or backup operations; (3) Triggers provide flexible configuration options, allowing users to customize the execution frequency and execution time of tasks according to actual needs. This enables scheduled tasks to adapt to different application scenarios and requirements; (4) In CRUD operations, triggers can be used to ensure data consistency and integrity. For example, when updating or deleting data, triggers can automatically perform some additional operations (such as logging, updating data in related tables, etc.) to ensure data consistency and traceability; (5) Triggers make the execution of scheduled tasks highly automated. Once a trigger is set and activated, the user does not need to manually intervene in the execution of the task, thus saving time and labor costs.
[0022] In some implementations, in order to facilitate management and classification, a field belonging to the machine is added because there are multiple machines, and rbss has multiple projects, so grouping is added to ensure that scheduled tasks of different projects belong to one group.
[0023] In some implementations, a scheduled task running result record table may also be set in the database, and the scheduled task running result record table is used to record the execution result of each trigger, according to the time and trigger code.
[0024] Based on the above needs to implement CRUD operations on scheduled tasks, it is necessary to plan the front-end system module. Therefore, Figure 1 FIG. 1 is a schematic diagram of a system for implementing a scheduled task change operation provided by an exemplary embodiment of the present invention. Figure 1As shown, the system for implementing the scheduled task change operation includes: a scheduled task viewing module 11, the scheduled task viewing module is configured to view the scheduled tasks in the task configuration table; wherein the task configuration table includes fields for storing the creation of triggers and the management of scheduled tasks; a scheduled task management module 12, the scheduled task management module is communicated with the scheduled task viewing module, and the scheduled task management module is configured to update the task configuration table according to the matching results of the trigger and the scheduled task in the task configuration table; and a permission module 13, the permission module is communicated with the scheduled task viewing module, and the permission module is configured to classify the data and set corresponding management permissions for different types of data.
[0025] In some embodiments, the scheduled task viewing module has the functions of querying and querying scheduled tasks by conditions, the scheduled task management module includes the functions of adding, editing, and deleting scheduled tasks, and the permission module classifies data permissions according to users. The scheduled task viewing module is embodied in a Web page and is generated as a scheduled task viewing page. The scheduled task viewing page can see all scheduled tasks under the user, and the edit button behind the data row can also be clicked to enter the modification page of the scheduled task. If it is an administrator, all scheduled tasks can be seen. Jumping to the modification page of the scheduled task is the implementation of the scheduled task management module in the Web page. The scheduled task management page is mainly for the modification of scheduled tasks, which will be filled with original data. At the same time, the page will perform format verification on the time expression (for example, cron expression, which is a powerful time expression used to specify the time for periodic execution of tasks in Unix / Linux systems and many Unix-based systems (such as cron job schedulers). Cron expressions consist of six or seven fields, each field represents a part of the schedule, and the fields are separated by spaces). Click the Save button to call the back-end interface to save the modified data to the task configuration table. The permission module is used to implement permission classification and classify data according to users. For example, the administrator can see all data (original data and processed data), and other users can see the original data and processed data they imported.
[0026] In addition, in some implementations, in order to facilitate users to view data intuitively, a task running log module and a running report display module can be set. The page implemented based on the task running log module can show the running status of each scheduled task in detail, including the scheduled task code, whether it is successful and the running time. At the same time, a secondary page can be configured. The secondary page mainly includes: the start time of the run, the end time, the consumed time, whether the run is successful, the description of the task function, the error log, etc. The running report display module will summarize and count the running status of the scheduled task, and then form a bar chart in parallel to show the number of successful runs, the number of failures and the success rate, so as to facilitate users to manage scheduled tasks.
[0027] The task running log module configures the running log query interface, which is used to query the running log of the scheduled task. The interface returns detailed information about each task running, such as start time, end time, running time, running results, error log, etc. If you are an administrator, you have the query permission for all task running logs. If you are not an administrator, you can only see the query permission for your own task running log. In addition, you can also configure the data statistics summary interface, which is used to provide data provision functions for statistics and chart generation for the page. It will calculate the required data and pass it to the page, such as the number of successful task runs, the number of failed tasks, the time of task running, etc. Based on security considerations, this interface will also perform permission verification. If you are an administrator, you have the statistical permission for all data. If you are not an administrator, you can only see the data permission for your own task statistics. For example, the running report display module can call the data statistics summary interface to obtain data for generating a bar chart.
[0028] In one embodiment, the scheduled task viewing module may include: a scheduled task information query unit, which is configured to perform data screening based on query conditions to return the user's scheduled tasks; wherein the query conditions include a scheduled task identification code and a scheduled task name; correspondingly, the permission module includes: a scheduled task permission query unit, which is configured to verify the user's permissions before performing data screening based on the query conditions; wherein, when the user's permissions are verified to be an administrator, query permissions for all scheduled tasks are provided, and when the user's permissions are verified to be a non-administrator, query permissions for the user's own scheduled tasks are provided.
[0029] The function of querying scheduled task information unit can be implemented based on the backend configuration interface, such as setting the interface for querying scheduled task information. The interface filters data according to the query conditions, and provides fuzzy query based on the scheduled task code and the scheduled task name. When querying, this interface will first determine whether the user is an administrator based on the query scheduled task permission unit. If the user is an administrator, he has the permission to query all data. If the user is not an administrator, he can only query the scheduled tasks he created. The query scheduled task information unit is mainly used for the page display of scheduled tasks and the echo of data when modifying.
[0030] In one embodiment, the scheduled task management module may include: a scheduled task verification unit, which is configured to verify whether the identification code of the scheduled task is repeated and whether the time expression complies with the rules; an editing scheduled task unit, which is communicated with the scheduled task verification unit, and the editing scheduled task unit is configured to update the scheduled task in the task configuration table according to the time expression of the trigger when the trigger and the scheduled task in the task configuration table match successfully and the time expression of the trigger is different from the time expression of the scheduled task in the task configuration table; a scheduled task identification code verification unit, which is configured to query the task configuration table according to the input scheduled task identification code. If the scheduled task identification code exists in the task configuration table, the scheduled task identification code verification fails.
[0031] The scheduled task verification unit is used to verify whether the code of the scheduled task is repeated, whether the cron expression complies with the rules, etc. After the verification is passed, the scheduled task editing unit will be used to update the data in the table according to the scheduled task code. At the same time, the scheduled task editing unit can also perform batch updates based on the interface for editing scheduled tasks. During batch updates, the scheduled task code in the database will be verified first, and then the multiple data submitted this time will be checked for the same task code. It will also verify whether the cron expression complies with the specifications. After the verification is passed, the update operation will be performed. This function is mainly used to modify cron expressions in batches. In addition, based on security considerations, permission verification will also be performed. For example, the permission module can also include: a scheduled task editing permission unit, and a scheduled task change permission unit is configured to verify the user's permission before updating the scheduled task verified by the scheduled task verification unit; wherein, when the permission of the verified user is an administrator, the editing permission of all scheduled tasks is provided, and when the permission of the verified user is a non-administrator, the editing permission of the user's own scheduled task is provided, that is, if the administrator is an administrator, the user has the permission to change all data, and if the administrator is not an administrator, the user can only modify the scheduled tasks added by himself. The scheduled task identification code verification unit is configured with a scheduled task code verification interface. The scheduled task code verification interface is used to verify the uniqueness of the code when the scheduled task code is entered on the page. The entered scheduled task code will be used to check the task configuration table. If data can be found, the code entered by the user on the page cannot be used and needs to be changed. If data cannot be found in the task configuration table, the code entered by the user can be used.
[0032] In one embodiment, the scheduled task management module also includes: a scheduled task deletion unit, which is configured to delete the data in the task configuration table according to the scheduled task identification code of the scheduled task; a scheduled task closing unit, which is configured to close the scheduled task to stop running the scheduled task; wherein, after closing the scheduled task by the scheduled task closing unit, the scheduled task can be opened again, and after deleting the scheduled task by the scheduled task deletion unit, it cannot be restored.
[0033] According to the scheduled task identification code of the scheduled task, the data in the task configuration table is deleted. The database or data table stores multiple scheduled task data. Each scheduled task has a unique identification code, called the scheduled task identification code (scheduled task code). If you need to remove (that is, delete) a scheduled task from this table, use the scheduled task code as a key or instruction to directly find the scheduled task corresponding to the scheduled task code from the database or data table, and then delete the corresponding scheduled task data. Therefore, based on the scheduled task identification code, the data in the task configuration table can be deleted quickly and accurately to find and delete the corresponding scheduled task, thereby efficiently completing the deletion operation.
[0034] The scheduled task deletion unit is configured with an interface for implementing scheduled task deletion. If the user no longer needs this scheduled task, click the delete button on the page to call the scheduled task deletion interface, and the data in the task table will be deleted according to the task code. The next time the scheduled task scans the task configuration table, the task will be deleted in the trigger, and the code segment will no longer run. It should be noted that this operation is irreversible, so it is not necessary to delete it. For example, use the scheduled task closing function on the page. After closing the scheduled task, the code segment will no longer run. It can be opened again when needed without any impact. In addition, based on security considerations, the scheduled task deletion interface can also perform permission verification. If you are an administrator, you have all change permissions. If you are not an administrator, you can only modify the tasks you added.
[0035] Based on the front-end module configured above, the back-end interfaces that can be configured include: an interface for querying scheduled tasks, an interface for adding scheduled tasks, an interface for editing scheduled tasks, an interface for deleting scheduled tasks, an execution log interface, and an interface for data required for statistics.
[0036] Based on the front-end module and back-end interface configured above, a page tool for automatically implementing scheduled task CRUD operations can be provided. A new input box is added to the page, and the scheduled task code, scheduled task name, belonging machine, scheduled task class, switch, group and description need to be entered. The modification page includes: scheduled task code, scheduled task name, belonging machine, scheduled task class, switch, group and description. It supports dynamic modification of task status, start / stop task, and can view execution logs through the Web page. Therefore, through a scheduled task, the task configuration table of the database is scanned regularly to obtain the scheduled tasks and corresponding code segment classes configured in the table to execute the business. The configuration related to the scheduled task can be updated through the web page. The queue of the scheduled task will be updated at the next scan. Or if there is already a business code, there is no need to write a set of scheduled task execution code separately. The code class path can be directly configured in the table, and the code segment will be found and executed through the class path, which is convenient for maintenance and management. Even if you don’t know SQL or operate the database, you can quickly and easily maintain the scheduled task, which greatly improves the maintainability of the scheduled task, the decoupling of the scheduled task and the logic code, the flexibility of the scheduled task switch and the utilization rate of the code.
[0037] Figure 2 is a flow chart of a method for implementing a scheduled task change operation provided by an exemplary embodiment of the present invention. Based on the front-end module and the back-end interface configured as above, the following can be implemented: Figure 2 The method of steps 100 to 300 shown in the figure first obtains a registered trigger, and scans the task configuration table through a scheduled task viewing module to obtain a scheduled task in the task configuration table (step 100); wherein the registered trigger represents the actual execution content of the scheduled task, and then the trigger key of the trigger is compared with the scheduled task in the task configuration table through the scheduled task management module (step 200); wherein the trigger key represents the condition that causes the trigger to be activated; finally, when the scheduled task represented by the registered trigger already exists in the task configuration table, and the time expression of the registered trigger is different from the time expression in the task configuration table, the time expression of the registered trigger is updated to the task configuration table through the scheduled task management module (step 300).
[0038] In some embodiments, the specific implementation of step 100-step 300 can be: first write a scheduled task, cyclically scan the scheduled task configuration table, and obtain data to create, delete, and update triggers. By regularly scanning the task configuration table, the system can automatically discover newly added, modified, or deleted task configurations, and automatically schedule and execute corresponding tasks according to the configuration information, which reduces the need for manual intervention and improves the accuracy and efficiency of task execution. There is a corresponding relationship between the task configuration table and the registrar. If the actual execution content is placed in the project file, when the scheduled task is modified, the project needs to be restarted to take effect. Therefore, placing the configuration in the task configuration table and the actual execution content of the task in the program (trigger) will not affect the project operation, and the scheduled task can be modified directly when the project is running. Use the scheduler.getTriggerKeys method of QuartzScheduler (open source job scheduling library) to obtain all registered triggers, and compare the trigger key of the trigger with the scheduled task found in the task configuration table. If the trigger has been registered (that is, the scheduled task is already in the list), then determine whether the cron expression of the registered trigger is the same as the cron expression in the table. If they are different, update them. If they are the same, do nothing.
[0039] In a database system, a trigger is a piece of code that is automatically executed in response to events such as INSERT, UPDATE, and DELETE on a database table. These triggers need to be registered or defined in the database so that they can be automatically executed when a specified event occurs. Task configuration tables are usually used to store and manage configuration information for scheduled tasks, such as task name, execution time, execution cycle, execution method, etc. This information is used by schedulers (such as Quartz, Spring Task, etc.) to schedule and execute scheduled tasks. Registered triggers mainly come from the database system and are used to automatically execute specific logic at the database level. Task configuration tables come from the configuration of the application or system and are used to schedule and manage scheduled tasks at the application level.
[0040] A trigger key usually refers to an event or condition that causes a trigger to be automatically activated or executed, which can be operations such as INSERT, UPDATE, DELETE on a database table, or other specific events supported by the database system. For example, when a new row is inserted into a task configuration table, a trigger can be defined to automatically perform some actions, such as updating data in another task configuration table or performing some validation. When an existing row in a task configuration table is updated, a trigger can be defined to check the updated content, perform some additional logic, or prevent certain updates. When a row is deleted from a task configuration table, a trigger can be activated to perform actions such as recording a deletion log, updating data in related task configuration tables, and so on.
[0041] In one embodiment, the method for implementing a scheduled task change operation may also include: if the scheduled task in the task configuration table does not match a corresponding trigger, loading the found path to create a trigger, and waiting for the condition of the time expression to be met to automatically execute the corresponding code segment; if the registered trigger does not exist in the task configuration table, deleting the registered trigger.
[0042] If the scheduled task does not match the corresponding trigger, you can load the found class path to create a trigger and wait for the cron expression to be satisfied to automatically execute the corresponding code segment. The trigger creates a scheduled task by scanning all scheduled tasks enabled in the configuration table, using scheduler.getTriggerKeys in the open source Quartz Scheduler to obtain all triggers to determine whether a new trigger needs to be registered. If the registered trigger does not match the corresponding scheduled task in the task configuration table, call deleteJob to delete the registered trigger.
[0043] In one embodiment, the method for implementing a scheduled task change operation may further include: in response to a batch update instruction, obtaining the task identification code of the scheduled task to be updated and the scheduled task identification code in the task configuration table; verifying whether the task identification code of the scheduled task to be updated is repeated with the scheduled task identification code in the task configuration table; when the task identification codes of the scheduled tasks to be updated are not repeated with the scheduled task identification codes in the task configuration table, verifying whether the time expression of the scheduled task to be updated meets the preset format requirement; when the time expression of the scheduled task to be updated meets the preset format requirement, updating the task configuration table based on the scheduled task to be updated.
[0044] Scheduled tasks in the task configuration table can be updated in batches. Based on the task identification code, it can be quickly determined whether there is duplicate data. If there is duplicate data in the scheduled task to be updated, or if there is duplicate data between the scheduled task to be updated and the scheduled task already in the task configuration table, the duplicate data will be modified and resubmitted. If there is no duplicate data, check whether the cron expression meets the specifications (preset format requirements). Only data that meets the specifications can be updated, and data that does not meet the specifications needs to be modified and resubmitted.
[0045] An embodiment of the present invention provides a device for implementing a scheduled task change operation. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. From a hardware perspective, in addition to a CPU, memory, network interface, and non-volatile memory, the device in the embodiment where the device is located can generally include other hardware, such as a forwarding chip responsible for processing messages, etc. Taking software implementation as an example, as a device in a logical sense, it is formed by the CPU of the device where it is located reading the corresponding computer program instructions in the non-volatile memory into the memory for execution.
[0046] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and the computer program is used to execute the method for implementing a scheduled task change operation according to any of the above embodiments.
[0047] In addition, an embodiment of the present invention may also be a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are executed by a processor, the processor executes the steps of the method for implementing a scheduled task change operation according to various embodiments of the present invention described above in this specification.
[0048] In addition to the above methods and devices, an embodiment of the present invention may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps in the method for implementing a scheduled task change operation described in any of the above embodiments of this specification.
[0049] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: a processor; a memory for storing instructions executable by the processor; and the processor, configured to execute the method for implementing a scheduled task change operation according to any of the above embodiments.
[0050] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A system for implementing scheduled task change operations, characterized in that: include: A scheduled task viewing module, wherein the scheduled task viewing module is configured to view scheduled tasks in a task configuration table; wherein the task configuration table includes fields for storing creation triggers and managing scheduled tasks; A scheduled task management module, the scheduled task management module is in communication with the scheduled task viewing module, and the scheduled task management module is configured to update the task configuration table according to the matching result between the trigger and the scheduled task in the task configuration table; A permission module, the permission module is in communication with the scheduled task viewing module, and the permission module is configured to classify the data and set corresponding management permissions for different types of data.
2. The system for implementing scheduled task change operation according to claim 1, characterized in that: The system for implementing the scheduled task change operation also includes: A task running log module, the task running log module is in communication with the scheduled task viewing module and the scheduled task management module, and the task running log module is configured to record the running status of the scheduled task; wherein the running status includes the scheduled task identification code, the time when the running starts, the time when the running ends, the consumed time, whether the running is successful, the function description of the task and the error log; An operation report display module is communicatively connected with the task operation log module, and is configured to count the operation status of the scheduled tasks and generate a graph to display the number of successful operations, the number of failed operations and the success rate.
3. The system for implementing scheduled task change operation according to claim 1, characterized in that: The scheduled task viewing module includes: A scheduled task information query unit, wherein the scheduled task information query unit is configured to perform data screening based on a query condition to return the user's scheduled tasks; wherein the query condition includes a scheduled task identification code and a scheduled task name; The permission modules include: A query scheduled task permission unit, wherein the query scheduled task permission unit is configured to verify the user's permissions before filtering data based on the query conditions; wherein, when the verified user's permissions are for an administrator, query permissions for all scheduled tasks are provided, and when the verified user's permissions are for a non-administrator, query permissions for the user's own scheduled tasks are provided.
4. The system for implementing scheduled task change operation according to claim 1, characterized in that: The scheduled task management module includes: A timed task verification unit, configured to verify whether the identification code of the timed task is repeated and whether the time expression complies with the rules; A scheduled task editing unit, wherein the scheduled task editing unit is in communication with the scheduled task verification unit, and the scheduled task editing unit is configured to update the scheduled task in the task configuration table according to the time expression of the trigger when the trigger and the scheduled task in the task configuration table match successfully and the time expression of the trigger is different from the time expression of the scheduled task in the task configuration table; The scheduled task identification code verification unit is configured to query the task configuration table according to the input scheduled task identification code. If the scheduled task identification code exists in the task configuration table, the scheduled task identification code verification fails.
5. The system for implementing scheduled task change operation according to claim 4, characterized in that: The permissions module also includes: The scheduled task editing permission unit, the scheduled task change permission unit is configured to verify the user's permissions before updating the scheduled task verified by the scheduled task verification unit; wherein, when the verified user's permissions are for administrators, the editing permissions for all scheduled tasks are provided, and when the verified user's permissions are for non-administrators, the editing permissions for the user's own scheduled tasks are provided.
6. The system for implementing scheduled task change operation according to claim 1, characterized in that: The scheduled task management module also includes: A scheduled task deletion unit, wherein the scheduled task deletion unit is configured to delete data in the task configuration table according to a scheduled task identification code of the scheduled task; A scheduled task closing unit, wherein the scheduled task closing unit is configured to close the scheduled task to stop running the scheduled task; After the scheduled task is closed by the scheduled task closing unit, the scheduled task can be opened again, and after the scheduled task is deleted by the scheduled task deleting unit, it cannot be restored.
7. A method for implementing a scheduled task change operation, applied to the system for implementing a scheduled task change operation as described in any one of claims 1 to 6, characterized in that: The method for implementing the scheduled task change operation includes: Obtain a registered trigger, and scan the task configuration table through the scheduled task viewing module to obtain the scheduled task in the task configuration table; wherein the registered trigger represents the actual execution content of the scheduled task; By means of the scheduled task management module, the trigger key of the trigger is compared with the scheduled tasks in the task configuration table; wherein the trigger key indicates the condition causing the trigger to be activated; When the scheduled task represented by the registered trigger already exists in the task configuration table, and the time expression of the registered trigger is different from the time expression in the task configuration table, the time expression of the registered trigger is updated to the task configuration table through the scheduled task management module.
8. The method for implementing a scheduled task change operation according to claim 7, characterized in that: The method for implementing the scheduled task change operation also includes: If the scheduled task in the task configuration table does not match the corresponding trigger, the found path is loaded to create a trigger, and the corresponding code segment is automatically executed when the time expression is met; If the registered trigger does not exist in the task configuration table, the registered trigger is deleted.
9. The method for implementing a scheduled task change operation according to claim 7, characterized in that: When the scheduled task represented by the registered trigger already exists in the task configuration table, and the time expression of the registered trigger is different from the time expression in the task configuration table, updating the time expression of the registered trigger to the task configuration table through the scheduled task management module includes: When the scheduled task represented by the registered trigger already exists in the task configuration table, and the time expression of the registered trigger is different from the time expression in the task configuration table, verify whether the time expression of the trigger meets the preset format requirements; When the time expression of the trigger meets the preset format requirement, the time expression of the registered trigger is updated to the task configuration table through the scheduled task management module.
10. The method for implementing a scheduled task change operation according to claim 7, characterized in that: The method for implementing the scheduled task change operation also includes: In response to the batch update instruction, obtaining the task identification code of the scheduled task to be updated and the scheduled task identification code in the task configuration table; Check whether the task identification code of the scheduled task to be updated is the same as the scheduled task identification code in the task configuration table; When the task identification codes of the scheduled tasks to be updated are not repeated with the scheduled task identification codes in the task configuration table, verify whether the time expression of the scheduled tasks to be updated meets the preset format requirements; When the time expression of the scheduled task to be updated meets the preset format requirement, the task configuration table is updated based on the scheduled task to be updated.
