Alarm task execution method and system, computer equipment and storage medium
By introducing technologies such as identifier resolution, priority dynamic management, task disassembly and dependency scheduling, asynchronous execution and real-time result feedback in the police task processing system, the problems of inflexible priority, slow processing speed, repeated calculations and poor user experience in police task processing are solved, and efficient task processing and excellent user experience are achieved.
Patent Information
- Application Number
- CN202510294004.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-13
- Publication Date
- 2025-06-10
AI Technical Summary
In the process of police task processing, the prior art has problems such as inflexible task priority determination, slow processing speed, repeated calculations and poor user experience.
By analyzing the alarm task request, generating a unique identifier, querying the cache database to reuse the execution results, dynamically adjusting the task queue based on the priority attributes, disassemblying the task into a subtask, and building a task dependency graph for scheduling, and feedback the subtask execution results in real time.
It realizes flexible adjustment of task priorities, improves processing efficiency, avoids repeated calculations, significantly improves user experience, and improves response and execution efficiency to complex police tasks.
Smart Images

Figure CN120124975A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and particularly to a method, system, computer device, and storage medium for executing police task. Background Art
[0002] With the continuous upgrading of social governance requirements, the public security system has gradually introduced artificial intelligence technology to improve the processing efficiency and response ability of police tasks. Among them, as an important branch of artificial intelligence, the large language model has begun to be widely used in the analysis, processing, and decision-making support of police tasks due to its excellent performance in natural language understanding and generation.
[0003] However, in the actual application process, the task execution scheme of the large language model often follows the traditional task management mode. For example, fixed rules are used to queue and process tasks. Although these traditional methods have certain applicability in dealing with simple tasks, their efficiency and response speed are insufficient when facing tasks with high suddenness, urgency, and complexity in police tasks. The main problems are as follows: (1) The task priority determination mechanism is not flexible: The existing system usually queues tasks using fixed rules (for example, first come, first served). This static task priority mechanism cannot dynamically adjust the task order according to the urgency, impact range, and importance of the tasks, resulting in the inability to give priority to urgent tasks and affecting the overall response efficiency of the system. (2) The task processing speed is slow: The traditional sequential processing mode requires tasks to be executed one by one in the order of submission. When the task volume is large, the processing speed drops significantly, making it difficult to meet the requirements in high-concurrency scenarios. Especially in the process of police task processing, the disposal time may be delayed due to task accumulation. (3) Task duplicate processing: There is no effective task caching mechanism in the existing system, resulting in duplicate tasks being unable to directly reuse historical processing results but having to execute the same calculations again. This duplicate processing not only wastes a large amount of computing resources but also reduces the overall efficiency of the system. (4) Poor user experience: In the traditional system, the execution results of tasks are usually uniformly fed back to users after all subtasks are completed. For complex and time-consuming tasks, this mode causes users to wait for a long time to obtain the results, seriously affecting the user experience, especially in the police handling scenarios that require quick response.
[0004] Therefore, how to dynamically adjust task priorities, improve task processing efficiency, avoid duplicate processing, and optimize the user experience has become an important problem that needs to be solved urgently. Summary of the Invention
[0005] In view of this, the embodiments of this application provide a method, system, computer device, and storage medium for executing police tasks, which can effectively solve the problems in the prior art such as inflexible task priority determination, slow processing speed, duplicate calculations, and poor user experience.
[0006] In a first aspect, an embodiment of the present application provides a method for executing a police situation task, including:
[0007] When a police situation task request is received, parse the police situation task request to generate a police situation task identifier;
[0008] Query the cache database based on the police situation task identifier to obtain the execution result of the police situation task;
[0009] When the execution result does not meet the preset conditions, insert the police situation task into the task queue based on the priority attribute of the police situation task;
[0010] Obtain the police situation task with the highest priority from the task queue, and disassemble the police situation task into one or more police situation subtasks;
[0011] If there are dependencies between the police situation subtasks, construct a task dependency graph according to the dependencies, and schedule and execute each police situation subtask based on the task dependency graph;
[0012] During the execution process of each police situation subtask, return the execution result of each police situation subtask to the task request end in real time.
[0013] In some embodiments, the parsing the police situation task request to generate a police situation task identifier includes:
[0014] Extract the task content, task type, and task identification information in the police situation task;
[0015] Generate the police situation task identifier based on the task content, the task type, and the task identification information; wherein, the police situation task identifier is used to uniquely identify the police situation task.
[0016] In some embodiments, the when the execution result does not meet the preset conditions, insert the police situation task into the task queue based on the priority attribute of the police situation task includes:
[0017] When there is no valid execution result matching the police situation task identifier in the cache database, obtain the priority attribute of the police situation task, and the type of the priority attribute includes at least one of the urgency level, the influence range, and the resource requirement; wherein, each priority attribute is assigned a corresponding weight;
[0018] Calculate a priority score based on the score of the obtained priority attribute and the corresponding weight;
[0019] Insert the police situation task into the task queue, and dynamically adjust the task queue according to the priority score.
[0020] In some embodiments, obtaining the police situation task with the highest priority from the task queue and disassembling the police situation task into one or more police situation subtasks includes:
[0021] Extracting the police situation task with the highest score of the priority from the dynamically adjusted task queue;
[0022] Analyzing the extracted police situation task to identify the execution logic and dependencies of the police situation task;
[0023] Based on the execution logic and the dependencies, disassembling the police situation task into one or more of the police situation subtasks; assigning a unique sub-identifier to the police situation subtasks, and the unique sub-identifier is used to track the execution results of each subtask.
[0024] In some embodiments, after disassembling the police situation task into one or more of the police situation subtasks based on the execution logic and the dependencies, it further includes:
[0025] When the attribute relationship between the police situation subtasks is an independent subtask, asynchronously scheduling and executing the independent subtasks concurrently;
[0026] When the attribute relationship between the police situation subtasks is a dependent subtask, scheduling and executing the dependent subtasks according to the dependencies.
[0027] In some embodiments, if there are dependencies between the police situation subtasks, then constructing a task dependency graph based on the dependencies and scheduling and executing each of the police situation subtasks based on the task dependency graph includes:
[0028] Generating the task dependency graph according to the dependencies, and the task dependency graph is a directed acyclic graph;
[0029] Based on the task dependency graph, planning the execution order of the police situation subtasks, and identifying the police situation subtasks as police situation subtasks that can be executed in parallel or police situation subtasks that need to be executed in sequence;
[0030] For the police situation subtasks that can be executed in parallel, performing concurrent scheduling through the asynchronous method;
[0031] For the police situation subtasks that need to be executed in sequence, scheduling and executing them in sequence in combination with the asynchronous method until all the police situation subtasks are completed.
[0032] In some embodiments, during the execution process of each of the police situation subtasks, returning the execution results of each of the police situation subtasks to the task requester in real time includes:
[0033] During the execution of the police situation sub-task, capture and generate partial execution results corresponding to the police situation sub-task in real time;
[0034] Send the partial execution results to the task request end in batches through streaming transmission;
[0035] When all the police situation sub-tasks are completely executed, summarize the execution results of all the police situation sub-tasks to generate the complete execution result of the police situation task.
[0036] In a second aspect, an embodiment of the present application provides a police situation task execution system, including:
[0037] A task identifier generation module, configured to parse the police situation task request to generate a police situation task identifier when receiving a police situation task request;
[0038] An execution result acquisition module, configured to query the cache database based on the police situation task identifier to obtain the execution result of the police situation task;
[0039] A queue adjustment module, configured to insert the police situation task into the task queue based on the priority attribute of the police situation task when the execution result does not meet the preset conditions;
[0040] A task disassembling module, configured to obtain the police situation task with the highest priority from the task queue and disassemble the police situation task into one or more police situation sub-tasks;
[0041] A scheduling and execution module, configured to construct a task dependency graph according to the dependency relationship if there is a dependency relationship between the police situation sub-tasks, and schedule and execute each police situation sub-task based on the task dependency graph;
[0042] An execution result generation module, configured to return the execution results of the police situation sub-tasks to the task request end in real time during the execution of each police situation sub-task.
[0043] In a third aspect, an embodiment of the present application provides a computer device, the computer device includes a processor and a memory, the memory stores a computer program, and the processor is configured to execute the computer program to implement the police situation task execution method in the first aspect above.
[0044] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, when the computer program is executed on a processor, implementing the police situation task execution method in the first aspect above.
[0045] The embodiments of the present application have the following beneficial effects:
[0046] The method for executing police situation tasks in this application generates a unique identifier by parsing the police situation task request and queries the cache database, which can quickly reuse the execution results of completed tasks, reduce duplicate calculations, and significantly improve the resource utilization efficiency. When the execution result does not meet the preset conditions, the task queue is dynamically adjusted based on the priority attribute of the task to ensure that urgent and important tasks are scheduled first, improving the response ability to sudden police situations. Through task decomposition and dependency relationship management, a task dependency graph is constructed to achieve efficient scheduling of subtasks, supporting flexible combinations of concurrent processing and sequential execution, avoiding task blocking and optimizing the execution process. At the same time, during the execution of subtasks, the execution result is gradually generated and fed back to the task request end in real time, greatly shortening the waiting time perceived by users and improving the real-time performance and interactive experience of the task. The method for executing police situation tasks in this application realizes the efficient processing of police situation tasks and the comprehensive optimization of user experience through the organic combination of technologies such as identifier parsing, dynamic priority management, task decomposition and dependency relationship scheduling, asynchronous execution, and real-time result feedback, providing a reliable guarantee for the intelligent processing of complex police situation tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] To more clearly illustrate the technical solutions of the embodiments of this application, the following will briefly introduce the drawings required in the embodiments. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0048] Figure 1(a) shows an application scenario diagram of a method for executing police situation tasks according to an embodiment of this application;
[0049] Figure 1(b) shows another application scenario diagram of a method for executing police situation tasks according to an embodiment of this application;
[0050] Figure 2 shows a hierarchical structure diagram of a method for executing police situation tasks according to an embodiment of this application;
[0051] Figure 3 shows a flowchart of a method for executing police situation tasks according to an embodiment of this application;
[0052] Figure 4 shows a structural diagram of a system for executing police situation tasks according to an embodiment of this application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0053] The following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the drawings in the embodiments of this application. Obviously, the described embodiments are only some embodiments of this application, not all embodiments.
[0054] The components of the embodiments of the present application that are generally described and illustrated in the accompanying drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application claimed, but merely represents selected embodiments of the present application. All other embodiments obtained by those skilled in the art based on the embodiments of the present application without creative efforts fall within the scope of protection of the present application.
[0055] Hereinafter, the terms "including", "having" and their cognates that may be used in various embodiments of the present application are only intended to indicate specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be construed as precluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or the possibility of adding one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items. In addition, the terms "first", "second", "third", etc. are only used for descriptive distinction and cannot be construed as indicating or implying relative importance.
[0056] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art to which the various embodiments of the present application belong. The terms (such as those defined in a commonly used dictionary) will be construed to have the same meaning as the contextual meaning in the relevant technical field and will not be construed to have an idealized meaning or an overly formal meaning unless clearly defined in the various embodiments of the present application.
[0057] The following will describe in detail some embodiments of the present application with reference to the accompanying drawings. Without conflict, the following embodiments and the features in the embodiments may be combined with each other.
[0058] Considering the problems in the prior art such as inflexible task priority determination, slow processing speed, repeated calculations, and poor user experience, therefore, an emergency task execution method is proposed. By introducing a priority dynamic adjustment mechanism, task decomposition and dependency relationship management, asynchronous processing technology, streaming result feedback, and cache reuse strategy, the intelligent management and efficient execution of emergency tasks are realized. The method of the present application can dynamically adjust the priority according to the urgency, influence range, etc. of the emergency task to ensure the priority scheduling of high-priority tasks; through task decomposition and dependency relationship management, it supports the parallel execution and sequential scheduling of tasks, effectively optimizing the execution efficiency; through the method of streaming transmission, the execution results of subtasks are fed back in real time, significantly improving the user interaction experience; in addition, through the cache reuse mechanism, repeated calculations are avoided and resource waste is reduced. The method of the present application comprehensively improves the response ability, execution efficiency, and user satisfaction for complex emergency tasks, providing efficient and stable technical support for intelligent emergency management.
[0059] A method for executing an alarm task provided by an embodiment of the present application can be applied in the following application environments. The method for executing an alarm task of the present application is applied in a computer system as shown in Figure 1(a). The system includes a client and a server. The client is a medium for users to interact with the large model server. Users input alarm task requests through the client and obtain results. The client device can be a smart phone, a laptop computer, a desktop computer, or other terminal devices supporting Internet connection. Specifically, as shown in Figure 1(b), in the client, the priority score of a task can be manually input by the user or automatically calculated through a front-end algorithm, and the task is submitted to the server side through the front end for processing. The server, as the background support, can be an independent physical server or a large model server, a cluster, a distributed system, a cache database, etc. composed of multiple physical servers. The main functions of the server include task management, cache query and reuse, task decomposition and scheduling, and completing task execution through asynchronous processing. After the task is executed, it is returned to the front end for the user to view.
[0060] The method for executing an alarm task of the present application is implemented based on a three-layer architecture system, as Figure 2 shown, which are the front-end layer, the business logic layer, and the background service layer respectively. The three-layer architecture supports the efficient reception, allocation, execution, and result feedback of tasks through division of labor and cooperation. The front-end layer is the layer where users directly interact. It includes two main modules: the request processing module and the event stream return module. The request processing module is responsible for receiving and parsing various requests initiated by users, while the event stream return module is responsible for real-time feedback of the processed information to users in the form of a stream; the business logic layer consists of a task management module and an asynchronous task execution module, and is responsible for planning and supervising the execution process of various tasks to ensure efficient task allocation and orderly operation; the background service layer is the basis for supporting upper-layer applications, mainly including two parts: the large language model processing module and the cache file database. The large language model processing module provides intelligent language services and support, and the cache file database improves the read and write performance and stability of the system.
[0061] Figure 3 A flowchart of a method for executing an alarm task according to an embodiment of the present application is shown. Exemplarily, the method includes the following steps:
[0062] Step S100, when an alarm task request is received, parse the alarm task request to generate an alarm task identifier.
[0063] Exemplarily, when a warning task request is received from the front end, the warning task request is automatically parsed and a unique warning task identifier is generated. The warning task identifier is used as the unique identifier of the task for scheduling, executing, and tracking the status of subsequent tasks. By generating task identifiers, efficient management of warning tasks and precise control of task life cycles are achieved to avoid confusion between tasks.
[0064] In an optional embodiment, in step S100, parsing the alarm task request to generate an alarm task identifier includes:
[0065] When receiving the alarm task request input from the front end, the core key information of the task is extracted from the alarm task request, including task content, task type and task identification information. Among them, the task content refers to the specific alarm event described in the task request, such as fire alarm, traffic accident, etc.; the task type refers to the category to which the task belongs, such as emergency task, general task, etc.; the task identification information refers to the unique tag data in the task request, such as the task ID or the UUID generated by the system.
[0066] After extracting the above information, the task content, task type and task identification information can be processed according to the preset rules. For example, the preset rules may include: extracting keywords from the task content and converting them into specific hash values; using classification coding for task types, such as "emergency task" is coded as "E1" and "general task" is coded as "G2"; directly embedding the task identification information into the alarm task identifier to ensure the uniqueness of the identifier. The identifier can be represented by a string, a numeric value or other encoding form, such as "E1-20230101-T001".
[0067] The method of the embodiment of the present application generates a warning task identifier which is used to uniquely identify the warning task within the system, ensuring that the corresponding task can be quickly located during subsequent task query, cache processing, priority sorting and scheduling.
[0068] Step S200, query the cache database based on the alarm task identifier to obtain the execution result of the alarm task.
[0069] Exemplarily, the cache database is queried based on the alarm task identifier as the query key to obtain the execution result of the alarm task. Through the query operation of the cache database, it can be determined whether the task has been processed before and whether there is an execution result of the task. The cache database is an efficient storage mechanism for storing intermediate results of tasks or processed task results to reduce repeated calculations and improve query speed.
[0070] When the execution result matching the police situation task identifier is found in the cache database, it is necessary to further determine whether the data in the execution result is valid. (1) Timeliness: Whether the data has not expired. (2) Data integrity: Whether the data is complete and undamaged. (3) Parameter consistency: Whether the parameters of the current request are consistent with the task parameters when generating the execution result. Only when all verification conditions are passed is the execution result considered valid.
[0071] If the execution result meets the above conditions, the execution result can be directly reused without re-executing the task process, and the execution result is directly returned to the requester.
[0072] It should be noted that when storing, the validity period of the execution result can also be set, and expired data can be periodically cleared through a cache cleaning policy (for example, the LRU policy). Specifically, when the cache is full, based on the access records of all data, the data with the lowest future access probability will be eliminated to avoid excessive storage space occupied by the cache and ensure the efficiency and consistency of the cache.
[0073] The method of the embodiment of the present application can quickly determine whether a task has been processed by querying the cache database based on the police situation task identifier. This mechanism significantly reduces the repeated calculation of tasks and improves the overall processing efficiency. At the same time, through the validity period management and dynamic update of the execution result, the accuracy and real-time nature of the execution result can be guaranteed, further enhancing the task processing ability and user experience.
[0074] Step S300, when the execution result does not meet the preset conditions, insert the police situation task into the task queue based on the priority attribute of the police situation task.
[0075] When the execution result matching the police situation task identifier is not found in the cache database, the task is inserted into the task queue according to the priority attribute of the police situation task. The task queue is used to store and manage all police situation tasks that need to be processed, and is dynamically adjusted according to the priority to ensure that tasks with higher priorities can be scheduled and executed first, thereby achieving reasonable resource allocation and efficient task processing.
[0076] In an optional embodiment, in step S300, when the execution result does not meet the preset conditions, inserting the police situation task into the task queue based on the priority attribute of the police situation task includes:
[0077] When the execution result is invalid or the cache is not hit, the task needs to be inserted into the task queue. First, extract the priority attributes related to the alarm task. The priority attributes are used to measure the importance and urgency of the task, including but not limited to the following: Urgency: Represents the time sensitivity of the task. For example, how soon the task needs to be completed. Scope of influence: Represents the degree of impact of the task on the system or users. For example, the geographical scope involved or the number of people affected. Resource requirements: Represents the amount of resources required to complete the task. For example, computing resources or network bandwidth.
[0078] Assign corresponding weights to the priority attributes of each alarm task, and calculate the comprehensive priority score of the task based on these weights: Assign a score to each attribute according to the urgency, scope of influence, and resource requirements of the task. For example, the score of "urgency" is the time limit for the task to be completed, and the shorter the time, the higher the score. Set weights for each priority attribute according to the importance of the attribute. For example, the weight of urgency is 50%, and the weights of the scope of influence and resource requirements are 30% and 20% respectively. The comprehensive priority score is calculated by the following formula:
[0079]
[0080] where P is the priority score, W i is the score of the i-th attribute, S i is the weight of the i-th attribute, and n is the number of priority attributes.
[0081] Insert the alarm task into the task queue according to the priority score. The task queue is a data structure used to dynamically manage the priorities of tasks. The priority queue is implemented using a max heap (Max Heap), and the specific method is as follows:
[0082] Insert the new task at the end of the heap, and adjust its position upward by comparing the priority score with the parent node until a suitable position is found to ensure that the properties of the heap are maintained. When it is necessary to obtain the task with the highest priority score, get the task from the root node of the heap (i.e., the task with the highest priority), and replace the root node with the last element of the heap. Then, through the downward adjustment operation, ensure that the heap satisfies the properties of the max heap again. If the priority attributes of a certain task change due to external conditions (such as increased urgency), recalculate the priority score of the task and adjust the position of the task in the max heap according to the score, so as to update the order of the queue in real time.
[0083] After insertion, the task queue is dynamically adjusted according to the priority score, ensuring that tasks with higher priority scores are located at the front of the queue and are thus scheduled and executed first. When there are multiple tasks in the task queue, the task with the highest priority score is always quickly obtained in an efficient manner, and the task is scheduled and executed. In addition, to ensure the real-time performance and efficiency of the task queue, the queue dynamically responds to changes in the task priority score, and the order of tasks is updated in real time through the adjustment mechanism of the max heap, ensuring the fairness and efficiency of task scheduling.
[0084] The method of the embodiment of the present application dynamically adjusts the task queue according to the priority attributes of the police situation tasks, ensuring that high-priority tasks are preferentially scheduled and executed. The calculation method of the priority score is flexible and can adjust the weight distribution according to actual needs, so as to adapt to the management of police situation tasks in different scenarios. The dynamic adjustment mechanism of the task queue improves the utilization efficiency of resources, effectively shortens the response time of emergency tasks, and improves the overall efficiency of task processing.
[0085] Step S400: Obtain the police situation task with the highest priority from the task queue, and disassemble the police situation task into one or more police situation subtasks.
[0086] Obtain the police situation task with the highest priority score from the dynamically adjusted task queue, and disassemble the task into one or more police situation subtasks. The disassembly process of the police situation task is based on the execution logic and dependency relationship of the task. Each disassembled police situation subtask can be executed independently or scheduled and executed according to the dependency order, that is, independent subtasks or dependent subtasks. Through this method, complex tasks can be managed more efficiently, and independent tracking and processing of each subtask are supported.
[0087] In an optional embodiment, in step S400, obtaining the police situation task with the highest priority from the task queue and disassembling the police situation task into one or more police situation subtasks includes:
[0088] In the task queue, all police situation tasks to be executed are dynamically sorted according to the priority score. That is, the task queue dynamically sorts tasks according to the priority score, ensuring that the task with the highest score is located at the front of the queue. After extracting the task at the front of the queue from the task queue, analyze the specific content of the task, and based on the execution logic and dependency relationship, disassemble the police situation task into one or more police situation subtasks, and identify the attribute relationships between the police situation subtasks, such as:
[0089] Independent subtasks: Subtasks that are independent of each other and have no dependency relationship can be directly used as independent police situation subtasks for execution. For example, a separate inspection task for a certain area.
[0090] Dependent subtasks: There are dependencies between subtasks. When scheduling tasks, tasks with dependencies need to be executed step by step in the order of dependencies. For example, subsequent analysis tasks that need to be started after the alarm information is confirmed.
[0091] After the decomposition is completed, a globally unique sub-identifier (UUID) is assigned to each subtask to track the execution status and results of the subtask and ensure the global uniqueness of the identifier.
[0092] It should be noted that after the decomposition is completed, according to the attributes of the subtasks, the subtasks are scheduled and executed: for example, subtasks without dependencies can use the asyncio asynchronous framework to create a coroutine for each subtask and start the parallel execution of these subtasks. Since there are no dependencies between tasks, all subtasks can be started simultaneously without considering the order of tasks. Subtasks with dependencies are scheduled and executed sequentially in the order defined in the task dependency graph to ensure the correctness of the task flow.
[0093] The method of the embodiment of the present application can schedule and execute more flexibly after decomposing the task into multiple subtasks, making full use of system resources. The task decomposition process is based on the execution logic and dependencies to ensure reasonable and controllable task division. At the same time, fine-grained tracking of the execution process of subtasks is achieved through unique sub-identifiers. The method of this embodiment is applicable to processing task scenarios with multiple stages and complex dependencies, which helps to improve task processing efficiency and optimize the use of system resources.
[0094] Step S500, if there are dependencies between the alarm subtasks, then according to the dependencies, construct a task dependency graph, and schedule and execute the alarm subtasks based on the task dependency graph.
[0095] The task dependency graph is used to represent the dependency order between subtasks to ensure that the execution process of tasks is logical, and at the same time, the execution efficiency can be optimized through parallel and sequential methods. The task dependency graph provides a clear task execution path for scheduling, thus realizing efficient task management and resource allocation.
[0096] In an optional embodiment, in step S500, if there are dependencies between the alarm subtasks, then according to the dependencies, construct a task dependency graph, and schedule and execute the alarm subtasks based on the task dependency graph, including:
[0097] Analyze the dependency relationships of police situation subtasks to identify the sequence and interdependencies between subtasks. For example, the dependency relationships of subtasks may come from the logical constraints of the task content (e.g., certain tasks must start after other tasks are completed) or the dependencies of data input (e.g., a subtask requires the output of a previous task as input). Dependency relationships are usually represented in the form of "Task A → Task B", indicating that Task B depends on the completion of Task A to execute.
[0098] Generate a task dependency graph based on the dependency relationships. Here, the vertices of the task dependency graph represent a police situation subtask. The edges of the task dependency graph represent the dependency relationships between subtasks. For example, an edge from Task A to Task B indicates that Task B must be executed after Task A is completed. To ensure the correct dependency relationships of tasks, the task dependency graph is acyclic (DAG, Directed Acyclic Graph). The system will check the acyclicity when generating the dependency graph. If there is a cyclic dependency, an error will be prompted and the task scheduling will stop.
[0099] After generating the task dependency graph, plan the execution order of tasks based on the in-degree of tasks. The specific execution is as follows:
[0100] Let the task set be T = {T1, T2…Tn}, and the dependency relationship set be D = {(Ti, Tj)|Ti->Tj};
[0101] The initial in-degree of each task is (in_degree), which is calculated from the dependency relationships:
[0102] in-degree(Ti) = {Tj∣(Tj,Ti)∈D}
[0103] Among them, Ti represents a node, and Tj represents another node in the graph; (Ti, Tj)∈D means that in the edge set D of the graph, there is an edge pointing from node Tj to node Ti; in_degree(Ti): represents the in-degree of node Ti, that is, how many nodes Tj have an edge pointing to Ti.
[0104] Tasks that can be executed in parallel: Identify tasks that can be executed in parallel by checking the in-degree of tasks (i.e., the number of previous tasks). Tasks with an in-degree of 0 indicate no dependencies and can be executed immediately. These tasks are added to the ready_tasks set:
[0105] ready-tasks = {Ti∣in-degree(Ti) = 0}
[0106] Among them, ready_tasks: represents the set of tasks ready to be executed; Ti represents a task node in the graph; in_degree(Ti) = 0 means that the in-degree of task Ti is 0, that is, no other tasks depend on it. In other words, task Ti has no prerequisites and can start execution immediately.
[0107] Tasks to be executed in sequence: According to the paths in the dependency graph, plan the task groups that must be executed in sequence. For example, task B must be executed after task A is completed.
[0108] For tasks with an in-degree of 0 and no dependencies, the large language model schedules them concurrently through an asynchronous mechanism (e.g., based on asyncio), and multiple tasks are started and executed simultaneously.
[0109] For task groups that need to be executed in sequence, combined with the asynchronous mechanism, start tasks one by one according to the paths in the dependency graph. For example, when task A is completed, the system immediately starts task B, and starts task C after task B is completed, until all tasks in this task group are completed.
[0110] After each subtask is completed, update the task dependency graph to reduce the in-degree value of subsequent tasks.
[0111] The update rule is as follows: when task Ti is completed, the in-degree of all tasks Tj that depend on Ti is reduced by 1:
[0112] in-degree(Tj) = in-degree(Tj) - 1
[0113] Among them, in_degree(Tj): represents the in-degree of task node Tj, that is, the number of other tasks pointing to this task. When a certain task Ti is completed, its influence may reduce the in-degree of other tasks Tj. At this time, the in-degree of node Tj is reduced by 1, indicating that one dependency of Tj has been satisfied and it can continue to be executed.
[0114] If the in-degree of a certain task becomes 0, then this task can be marked as executable and immediately scheduled, and added to the ready_tasks set to ensure that it can be immediately scheduled and executed.
[0115] For example, when there are multiple task sets (e.g., G_1, G_2... G_k), each set can be represented as an independent task dependency graph. Schedule each task set separately and achieve concurrent execution asynchronously:
[0116] Results = asyncio(Schedule(G_1), Schedule(G_2),..., Schedule(G_k))
[0117] Among them, Results represents the final result, which is the output of all parallel scheduling tasks; asyncio: represents the asynchronous execution of scheduling tasks; Schedule(G_1), Schedule(G_2),..., Schedule(G_k): represents scheduling multiple tasks.
[0118] In this formula, all tasks G_1, G_2... G_k are executed in parallel. These tasks are scheduled through asyncio asynchronous operations, and the results are returned after all tasks are completed. This method can effectively support the independent scheduling of multiple task sets and improve the task processing efficiency.
[0119] The method of the embodiment of this application, a method for dispatching and executing alarm sub-tasks based on a task dependency graph, can efficiently handle complex task scenarios. The task dependency graph ensures the correct execution order of tasks, and at the same time improves the overall task processing efficiency through an asynchronous concurrent scheduling mechanism. For tasks that can be executed in parallel, it can make full use of computing resources to achieve fast response of tasks; for tasks with complex dependencies, it can ensure the integrity and accuracy of tasks through sequential scheduling.
[0120] Step S600, during the execution of each alarm sub-task, return part of the execution results of each alarm sub-task to the task request end in real time.
[0121] Exemplarily, during the execution of the alarm sub-task, partially execute results of the sub-task are dynamically generated and returned to the task request end in real time to timely feedback the execution progress of the task. When all alarm sub-tasks are executed, summarize the execution results of all sub-tasks, generate a complete execution result of the alarm task, and store the complete execution result in the cache database to support subsequent task query and reuse.
[0122] In an optional embodiment, in step S600, during the execution of each alarm sub-task, returning part of the execution results of each alarm sub-task to the task request end in real time includes:
[0123] During the execution of each alarm sub-task, capture part of the execution results of the sub-task in real time. For example: for a monitoring task, the sub-tasks can be alarm information in different monitoring areas. Whenever a certain area is completed, immediately capture the alarm result of that area and generate the corresponding partial execution result. According to the progress of the sub-task, extract the key data (such as, processing status, partial result data) generated during the execution process as the partial execution result.
[0124] Adopt the streaming transmission method of the large language model to return part of the execution results to the task request side in batches in real time. The streaming transmission of the large language model enables part of the execution results to be transmitted to the user in real time before the subtasks are completed, thereby reducing the waiting time perceived by the user and improving the immediacy of task processing. Part of the execution results can be sent in batches according to the completion progress of the subtasks. For example, whenever a subtask is completed, the execution result of the task is immediately packaged and transmitted to the task request side. After receiving part of the execution results, the task request side can display the progress information of the subtasks in real time, facilitating the user to understand the processing status of the task.
[0125] It should be noted that when all the alarm subtasks are completed, the execution results of all the subtasks are summarized to generate the complete execution result of the alarm task. The result data is extracted from all the completed subtasks, and according to the logical relationship at the time of task decomposition, the results of each subtask are integrated. For example, for tasks processed by region, the alarm information of all regions is integrated to form a global alarm report. The complete result is usually stored in the form of structured data, including the execution status and result data of all subtasks. That is, the generated complete execution result is stored in the cache database for subsequent task queries. The cache database supports fast access and can effectively improve the response efficiency of the system. It should be noted that when the execution result of the same alarm task changes, the result in the cache is updated in a timely manner to ensure data consistency and effectiveness.
[0126] The method of the embodiment of the present application generates and feedbacks part of the execution results of the subtasks in real time, significantly improving the user's perception experience of the task processing progress. At the same time, the application of the streaming transmission of the large language model reduces the occupation of system resources by the accumulation of subtask results, making data transmission more efficient. The finally generated complete execution result is stored in the cache database, which is not only convenient for subsequent task queries and reuse, but also provides support for the system to achieve efficient management of task results.
[0127] Figure 4 A schematic structural diagram of the alarm task execution system according to the embodiment of the present application is shown. Exemplarily, the system includes:
[0128] A task identifier generation module 41, configured to parse the alarm task request to generate an alarm task identifier when receiving an alarm task request;
[0129] An execution result acquisition module 42, configured to query the cache database based on the alarm task identifier to obtain the execution result of the alarm task;
[0130] A queue adjustment module 43, configured to insert the alarm task into the task queue based on the priority attribute of the alarm task when the execution result does not meet the preset conditions;
[0131] The task decomposition module 44 is configured to obtain the alarm task with the highest priority from the task queue and decompose the alarm task into one or more alarm subtasks;
[0132] The scheduling and execution module 45 is configured to, if there is a dependency relationship between the alarm subtasks, construct a task dependency graph according to the dependency relationship and schedule and execute each alarm subtask based on the task dependency graph;
[0133] The execution result generation module 46 is configured to, during the execution process of each alarm subtask, return the execution result of each alarm subtask to the task request end in real time.
[0134] It can be understood that the system in this embodiment corresponds to the method in the above embodiment, and the optional items in the above embodiment are also applicable to this embodiment, so they will not be described repeatedly here.
[0135] The present application further provides a computer device. Exemplarily, the computer device includes a processor and a memory. The memory stores a computer program, and the processor runs the computer program to enable the storage device to execute the above method or the functions of each module in the above system.
[0136] Among them, the processor may be an integrated circuit chip with signal processing capabilities. The processor may be a general-purpose processor, including at least one of a central processing unit (CPU), a graphics processing unit (GPU), a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc., which can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.
[0137] The memory can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electric Erasable Programmable Read-Only Memory (EEPROM), etc. Among them, the memory is used to store computer programs, and after receiving the execution instruction, the processor can execute the computer program accordingly.
[0138] This application also provides a computer-readable storage medium for storing the computer program used in the above storage device. For example, the computer-readable storage medium may include, but is not limited to: various media that can store program codes such as USB flash drives, mobile hard disks, Read-Only Memory (ROM), Random Access Memory (RAM), magnetic disks, or optical discs.
[0139] In several embodiments provided by this application, it should be understood that the disclosed systems and methods can also be implemented in other ways. The system embodiments described above are merely illustrative. For example, the flowcharts and structure diagrams in the drawings show the possible architectures, functions, and operations of the systems, methods, and computer program products according to multiple embodiments of this application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the blocks can occur in a different order from that marked in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the structure diagram and / or flowchart, as well as the combination of blocks in the structure diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0140] In addition, in each embodiment of this application, each functional module or unit can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.
[0141] When the above-mentioned function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a storage device (which may be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application.
[0142] As described above, the above are only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of changes or substitutions, which should all be covered by the protection scope of the present application.
Claims
1. A method for executing a warning task, characterized in that: The method comprises: When receiving a warning task request, parsing the warning task request to generate a warning task identifier; Querying a cache database based on the alarm task identifier to obtain the execution result of the alarm task; When the execution result does not meet the preset condition, inserting the alarm task into the task queue based on the priority attribute of the alarm task; Obtain the highest priority alarm task from the task queue, and decompose the alarm task into one or more alarm subtasks; If there is a dependency relationship between the alarm subtasks, a task dependency graph is constructed according to the dependency relationship, and the alarm subtasks are scheduled and executed based on the task dependency graph; During the execution of each of the alarm subtasks, the execution results of each of the alarm subtasks are returned to the task request end in real time.
2. The method for executing a warning task according to claim 1, characterized in that: The step of parsing the alarm task request to generate an alarm task identifier includes: Extracting task content, task type and task identification information from the alarm task; The alarm task identifier is generated based on the task content, the task type and the task identification information; wherein the alarm task identifier is used to uniquely identify the alarm task.
3. The method for executing a warning task according to claim 1, characterized in that: When the execution result does not meet the preset condition, inserting the alarm task into the task queue based on the priority attribute of the alarm task includes: When the execution result matching the alarm task identifier does not exist in the cache database, obtaining the priority attribute of the alarm task, the type of the priority attribute includes at least one of urgency, impact scope and resource requirement; wherein each priority attribute is assigned a corresponding weight; Calculating a priority score based on the obtained scores of the priority attributes and corresponding weights; The alarm task is inserted into the task queue, and the task queue is dynamically adjusted according to the priority score.
4. The method for executing a warning task according to claim 1, characterized in that: The obtaining of the highest priority alarm task from the task queue and decomposing the alarm task into one or more alarm subtasks includes: Extracting the highest-scoring alarm task of the priority level from the dynamically adjusted task queue; Analyze the extracted alarm tasks to identify the execution logic and dependency relationships of the alarm tasks; Based on the execution logic and the dependency relationship, the alarm task is decomposed into one or more alarm subtasks; a unique sub-identifier is assigned to the alarm subtask, and the unique sub-identifier is used to track the execution result of each subtask.
5. The method for executing a warning task according to claim 4, characterized in that: After the alarm task is decomposed into one or more alarm subtasks based on the execution logic and the dependency relationship, the method further includes: When the attribute relationship between the alarm subtasks is that of independent subtasks, the independent subtasks are concurrently scheduled and executed in an asynchronous manner; When the attribute relationship between the alarm subtasks is a dependent subtask, the dependent subtasks are scheduled and executed according to the dependent relationship.
6. The method for executing a warning task according to claim 5, characterized in that: If there is a dependency relationship between the alarm subtasks, the dependency relationship constructs a task dependency graph, and schedules and executes the alarm subtasks based on the task dependency graph, including: Generate the task dependency graph according to the dependency relationship, wherein the task dependency graph is a directed acyclic graph; Planning the execution order of the alarm subtasks based on the task dependency graph, and identifying the alarm subtasks as the alarm subtasks that can be executed in parallel or the alarm subtasks that need to be executed in sequence; For the alarm subtasks that can be executed in parallel, concurrent scheduling is performed in the asynchronous manner; The alarm subtasks that need to be executed in sequence are scheduled and executed in sequence in combination with the asynchronous method until all the alarm subtasks are completed.
7. The method for executing a warning task according to claim 1, characterized in that: During the execution of each of the alarm subtasks, the execution result of each of the alarm subtasks is returned to the task requesting end in real time, including: During the execution of the alarm situation subtask, a partial execution result corresponding to the alarm situation subtask is captured and generated in real time; Sending the partial execution results to the task requesting end in batches by streaming; When all the alarm situation subtasks are executed, the execution results of all the alarm situation subtasks are summarized to generate a complete execution result of the alarm situation task.
8. A police situation task execution system, characterized in that: The system comprises: A task identifier generating module, for parsing the alarm task request to generate an alarm task identifier when receiving the alarm task request; An execution result acquisition module, used to query the cache database based on the alarm task identifier to obtain the execution result of the alarm task; A queue adjustment module, used for inserting the alarm task into a task queue based on the priority attribute of the alarm task when the execution result does not meet the preset condition; A task decomposition module is used to obtain the highest priority alarm task from the task queue and decompose the alarm task into one or more alarm subtasks; A scheduling and execution module, for constructing a task dependency graph according to the dependency relationships if there are dependencies between the alarm subtasks, and scheduling and executing the alarm subtasks based on the task dependency graph; The execution result generation module is used to return the execution result of each of the alarm subtasks to the task request end in real time during the execution of each of the alarm subtasks.
9. A computer device, characterized in that: The computer device includes a processor and a memory, the memory stores a computer program, and the processor is used to execute the computer program to implement the alarm task execution method described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed on a processor, implements the alarm task execution method according to any one of claims 1-7.
Citation Information
Cited By
Multi-model cooperative processing method and system
CN120560865A
A multi-model cooperative processing method and system
CN120560865B
Multi-task scheduling method, system and equipment based on resource queue management and medium
CN121029354A
LLM-based dynamic planning and reflecting task execution method, device and system
CN121455644A