Request processing method and apparatus, electronic device, storage medium, and computer program product
By establishing a pre-set task information set in the backend, periodically updating and managing the task information, and sending requests to the frontend periodically, the problem of the frontend being unable to obtain the results of device operation execution in a timely manner is solved, improving interaction efficiency and saving backend resources.
Patent Information
- Application Number
- CN202410288897.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-13
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2044-03-13
AI Technical Summary
The front-end cannot directly obtain the results of device operation execution, or the waiting time for obtaining the results is too long, resulting in low work efficiency in the interaction between the front-end and the back-end.
By establishing a pre-set task information set in the backend, periodically updating and managing the task information, the frontend periodically sends query or creation requests, and the backend executes processing tasks based on the task information set, simplifying the query process and reducing thread usage.
It improves the efficiency of the interaction between the front-end and back-end, simplifies the query process, and saves back-end computing resources.
Smart Images

Figure CN118803061B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of Internet of Things, and in particular to a request processing method and device, electronic equipment, storage medium and computer program product. BACKGROUND
[0002] An Internet of Things system generally includes a front end, a back end and devices. The front end includes various forms such as browser pages, mobile application programs (APPs), WeChat mini-programs, etc. The back end is deployed on a server and generally provides Hypertext Transfer Protocol (HTTP) protocol interfaces for the front end to access. The devices establish connections with the back end through Internet of Things protocols to implement functions such as data reporting and instruction execution. User operations on the devices initiated from the front end generally include parameter configuration, restart, upgrade, etc. However, in related technologies, the front end cannot directly obtain operation execution results of the devices, or it takes a long time to obtain the operation execution results, or the back end determines the operation execution results in a complex manner, resulting in a complex process for the front end to obtain the operation execution results. This makes the interaction process between the front end and the back end inefficient. SUMMARY
[0003] The request processing method, device, electronic equipment, storage medium and computer program product provided by the embodiments of the present application can improve the work efficiency in the interaction process between the front end and the back end.
[0004] The technical solution of the present application is implemented as follows:
[0005] The embodiments of the present application provide a request processing method, which includes the following steps:
[0006] receiving a first request sent by a front end; wherein the first request includes a query request periodically sent by the front end based on predetermined conditions, or a creation request; the creation request is used to create task information in a preset task information set; the preset task information set is determined based on periodic updates to each created task information;
[0007] performing a corresponding processing task in the preset task information set based on the first request.
[0008] In the above solution, when the first request includes the query request, before receiving the first request sent by the front end, the method further includes the following steps:
[0009] receiving a previous query request sent by the front end;
[0010] querying the preset task information set in response to the previous query request to obtain first task information of a corresponding device;
[0011] If the first task information indicates that no task response result has been obtained for the corresponding device, then a task incomplete result is sent to the front end; wherein, the predetermined condition includes the task incomplete result.
[0012] In the above scheme, receiving the first request sent by the front end includes:
[0013] The system receives query requests periodically sent by the front end after obtaining the result of the task not being completed.
[0014] In the above scheme, the step of executing the corresponding processing task in the preset task information set based on the first request includes:
[0015] Based on the device information and task content information included in the query request, the corresponding second task information is searched in the preset task information set;
[0016] Based on the status information of the second task information, the query result is sent to the front end; wherein, the status information is used to characterize the task progress of the second task information.
[0017] In the above scheme, when the first request includes the creation request, the step of executing the corresponding processing task based on the first request in the preset task information set includes:
[0018] The task information is created in response to the creation request in the preset task information set; wherein, the task information includes: task content information, device information, task identifier information, time information, and status information indicating creation.
[0019] In the above scheme, after the task information is created in response to the creation request in the preset task information set, the method further includes:
[0020] Periodically traverse each of the task information in the preset task information set to determine the predetermined task information including predetermined status information; wherein, the predetermined status information is used to characterize the task response result of not obtaining the corresponding device;
[0021] The scheduled task information is updated based on the scheduled status information.
[0022] In the above scheme, updating the predetermined task information based on the predetermined status information includes one of the following:
[0023] If the predetermined status information is created, then operation data is sent to the corresponding device based on the task content information and the device information in the predetermined task information, and the predetermined status information is modified to indicate startup;
[0024] If the predetermined state information represents starting, a timeout detection result of the predetermined task information is determined based on time information in the predetermined task information, and the predetermined state information is modified based on the timeout detection result.
[0025] In the above scheme, the method further comprises:
[0026] receiving the task response result of the device in response to the operation data feedback;
[0027] modifying the predetermined state information of the corresponding predetermined task information based on the task response result.
[0028] Embodiments of the present application also provide a request processing method, applied to a front end, comprising:
[0029] sending a first request to a back end; wherein the first request comprises a query request or a creation request sent periodically based on a predetermined condition; the creation request is used to create task information in a preset task information set in the back end; the preset task information set is determined by the back end based on periodicity for updating each created task information.
[0030] In the above scheme, when the first request comprises the query request, before the first request is sent to the back end, the method further comprises:
[0031] sending a previous query request to the back end in response to a received user operation instruction;
[0032] receiving a task incomplete result fed back by the back end in response to the previous query request; wherein the task incomplete result is fed back by first task information queried by the back end based on the previous query request, and the first task information represents that a task response result of a corresponding device has not been obtained; the predetermined condition comprises the task incomplete result.
[0033] In the above scheme, the first request sent to the back end comprises:
[0034] sending the query request to the back end periodically based on the task incomplete result.
[0035] Embodiments of the present application also provide a request processing device, applied to a back end, comprising:
[0036] a receiving unit, configured to receive a first request sent by a front end; wherein the first request comprises a query request or a creation request sent periodically by the front end based on a predetermined condition; the creation request is used to create task information in a preset task information set; the preset task information set is determined based on periodicity for updating each created task information;
[0037] The processing unit is configured to perform a corresponding processing task in the preset task information set based on the first request.
[0038] The application further provides a request processing device applied to a front end and comprising:
[0039] The sending unit is configured to send a first request to a back end; the first request comprises a query request or a creation request sent periodically based on a predetermined condition; the creation request is used to create a task information in a preset task information set of the back end; and the preset task information set is determined by the back end based on periodicity for updating each created task information.
[0040] The application further provides an electronic device comprising a first memory and a first processor; the first memory stores a computer program capable of running on the first processor; and the first processor implements the steps in the method on the back end side when executing the computer program.
[0041] The application further provides a computer readable storage medium having a computer program stored thereon; the computer program is executed by a first processor to implement the steps in the method on the back end side.
[0042] The application further provides a computer program product comprising a computer program; the computer program is executed by a first processor to implement the steps in the method on the back end side.
[0043] The application further provides an electronic device comprising a second memory and a second processor; the second memory stores a computer program capable of running on the second processor; and the second processor implements the steps in the method on the front end side when executing the computer program.
[0044] The application further provides a computer readable storage medium having a computer program stored thereon; the computer program is executed by a second processor to implement the steps in the method on the front end side.
[0045] The application further provides a computer program product comprising a computer program; the computer program is executed by a second processor to implement the steps in the method on the front end side.
[0046] In this embodiment, a first request sent by the front end is received. The first request includes a query request or a creation request periodically sent by the front end based on predetermined conditions. The creation request is used to create task information in a preset task information set. The preset task information set is determined by periodically updating each created task information set. Based on the first request, a corresponding processing task is executed within the preset task information set. Since the query request is periodically sent by the front end based on predetermined conditions, the user on the front end does not need to perform multiple query operations, simplifying the query process and allowing the front end to obtain the corresponding query results more quickly. Furthermore, the back end can manage each created task information set by periodically updating the preset task information set. This centralized, periodic management scheme reduces the need for numerous threads when managing multiple task information sets, simplifies the management logic of multiple task information sets, saves backend computing resources, and allows for a faster response to frontend requests, thereby improving the efficiency of the interaction between the front end and the backend. Attached Figure Description
[0047] Figure 1 An optional flowchart illustrating the request processing method provided in an embodiment of this application;
[0048] Figure 2 An optional effect diagram of the request processing method provided in the embodiments of this application;
[0049] Figure 3 An optional structural diagram of the request processing apparatus provided in the embodiments of this application;
[0050] Figure 4 An optional flowchart illustrating the request processing method provided in an embodiment of this application;
[0051] Figure 5 An optional flowchart illustrating the request processing method provided in an embodiment of this application;
[0052] Figure 6 An optional flowchart illustrating the request processing method provided in an embodiment of this application;
[0053] Figure 7 An optional flowchart illustrating the request processing method provided in an embodiment of this application;
[0054] Figure 8 An optional flowchart illustrating the request processing method provided in an embodiment of this application;
[0055] Figure 9 An optional flowchart illustrating the request processing method provided in an embodiment of this application;
[0056] Figure 10An optional effect diagram of the request processing method provided by the embodiment of the present application is shown in the following figure;
[0057] Figure 11 An interaction diagram of the request processing method provided by the embodiment of the present application is shown in the following figure;
[0058] Figure 12 A structure diagram of the request processing apparatus provided by the embodiment of the present application is shown in the following figure Figure 1 ;
[0059] Figure 13 A hardware entity diagram of the electronic device provided by the embodiment of the present application is shown in the following figure Figure 1 ;
[0060] Figure 14 A structure diagram of the request processing apparatus provided by the embodiment of the present application is shown in the following figure Figure 2 ;
[0061] Figure 15 A hardware entity diagram of the electronic device provided by the embodiment of the present application is shown in the following figure Figure 2 . DETAILED DESCRIPTION
[0062] In order to make the purpose, technical scheme and advantages of the present application more clear, the technical scheme of the present application is further described in detail below in combination with the drawings and embodiments, and the described embodiments should not be regarded as limiting the present application, and all other embodiments obtained by the person skilled in the art without making creative labor belong to the protection scope of the present application.
[0063] In the following description, "some embodiments" are described, which describe a subset of all possible embodiments, but it can be understood that "some embodiments" can be the same subset or different subset of all possible embodiments, and can be combined with each other without conflict.
[0064] If the similar description of "first / second" appears in the application file, the following description is added, in the following description, the term "first\second\third" only distinguishes similar objects, and does not represent the specific order of the objects, and it can be understood that "first\second\third" can be interchanged with the specific order or sequence as allowed, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0065] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.
[0066] In the related art, a user initiates an operation on a device from a front end, which usually includes parameter configuration, restart, upgrade, etc. Due to the interactive protocol mechanism or the device operation characteristics, it takes a long time, and it takes more than 1 minute or even longer to get the operation execution result. The current technical solution usually includes the following three kinds:
[0067] 1. The front end adopts a synchronous task execution mode, that is, after the user initiates a device operation through the front end, the front end stays in a result waiting interface and does not allow the user to perform other operations until the device responds to the result or judges the timeout to prompt the user to the result. The first solution does not allow the user to perform other operations during task execution, and the user experience is poor when the task execution time is long (such as more than 1 minute).
[0068] 2. The front end still adopts a synchronous task execution mode, but the front end does not wait for the device to respond, but waits for the back end to respond that the task has been successfully received and issued to the device to prompt the user, and the actual execution result of the device needs to be judged by the user through the device information (such as version number, parameter value). The second solution is that the user receives a response that the back end receives an instruction, which is not the device execution result, and is suitable for some operation scenarios (such as upgrade can be checked by subsequent version number to see if it is successful).
[0069] 3. The front end adopts an asynchronous task execution mode, that is, after the user initiates a device operation through the front end, the back end creates a task information and responds to the front end, the front end prompts the user that the task has been created, and the back end creates a thread for each task to execute and maintain the task execution result. At this time, the front end can perform other operations without waiting for the task to complete, and can also view the execution status of all tasks. Our solution also maintains the corresponding execution status for each task information. In the third solution, the asynchronous task processing logic of the back end is relatively universal and is suitable for various types of tasks such as data processing and data backup. However, when the solution is applied to the asynchronous task processing of the Internet of Things device interaction, the system occupies many resources and has high complexity. Although the operation of the user viewing all task execution states can realize the function of querying the asynchronous task result, the operation is not intuitive and convenient.
[0070] The embodiment of the present application provides a request processing method, please refer to Figure 1 , an optional flow diagram of the request processing method provided by the embodiment of the present application will be described in combination with Figure 1 steps shown.
[0071] S101, receiving a first request sent by a front end; wherein the first request includes a query request periodically sent by the front end based on a predetermined condition, or a creation request; the creation request is used to create a task information in a preset task information set; the preset task information set is determined based on the periodicity of updating each created task information.
[0072] In the embodiments of the present application, the backend receives the creation request sent by the front end, and the creation request is used to create task information in a preset task information set. The preset task information set is determined based on periodic updating of each created task information. The backend can also receive the query request sent by the front end periodically based on a predetermined condition.
[0073] The predetermined condition can be a task incomplete result sent by the backend to the front end. After the front end sends the previous query request to the backend based on the user operation instruction, the backend finds the task information representing the task response result of the corresponding device that has not been obtained based on the query request, and at this time, the backend sends the task incomplete result to the front end.
[0074] The front end includes various forms such as a browser page, a mobile phone APP, and a WeChat mini program. The backend is deployed on a server and generally provides an HTTP protocol interface for the front end to access. The device establishes a connection with the backend through an Internet of Things protocol to realize functions such as data reporting and execution instruction. The task information is used for the backend to perform corresponding operations on the device.
[0075] In the embodiments of the present application, the backend periodically traverses each task information in the preset task information set, and performs state updating and / or operation updating on the task information based on the state information in each task information. The state information is used to represent the task progress of the task information.
[0076] For example, as shown in Figure 2 The user can input the device identity document number (Identity document, ID), device name, device grouping, and device area in the front-end interface. After the front end clicks the operation button (such as upgrade) on the interface, the front end initiates a creation request to the backend, and the backend creates task information in response to the creation request and stores the task information in the preset task information set. The front end can also initiate a query request to the backend by clicking the operation button (such as query) on the interface.
[0077] S102, based on the first request, performing a corresponding processing task in the preset task information set.
[0078] In the embodiments of the present application, the backend queries the task information of the corresponding device in the preset task information set based on the query request, and feeds back the query result to the front end based on the task information. The backend creates a corresponding task information in the preset task information set based on the creation request.
[0079] For example, as shown in Figure 3 The Internet of Things system generally includes a front end 10, a backend 20, and a device 30. In this scheme, the backend 20 includes a task information storage module 23, a task monitoring module 24, a task execution module 22, and a device data module 21:
[0080] 1. The task information storage module 23 stores each piece of task information, including at least task number, task content, device to which it belongs, creation time, end time, and task status, which includes at least creation, start, success, failure, and timeout.
[0081] 2. The front end initiates a task creation and status query request to the task monitoring module 24, and the task monitoring module receives the front-end request and reads and writes the task information storage module.
[0082] 3. The task execution module 22 runs periodically and performs corresponding operations according to the task status, including sending data to the device to initiate device operation and determining whether the task is timed out and unresponsive.
[0083] 4. The device data module 21 waits to receive the operation response reported by the device and updates the task status of the task information storage module according to the response result.
[0084] In the embodiment of the application, a first request sent by a front end is received; wherein the first request includes a query request or a creation request sent by the front end based on a predetermined condition periodically; the creation request is used to create task information in a preset task information set; the preset task information set is determined based on periodic updating of each created task information; and a corresponding processing task is performed in the preset task information set based on the first request. In this way, since the query request is sent by the front end based on the predetermined condition periodically, the user on the front end side does not need to perform a query operation multiple times, the query process is simplified, the front end can obtain the corresponding query result more quickly, in addition, the back end can manage each created task information through periodic updating of the preset task information set, this information set management scheme makes it unnecessary to occupy many threads to manage multiple task information, simplifies the management logic of multiple task information, saves the computing resources of the back end, and when facing the request of the front end, the back end can respond quickly, thereby improving the work efficiency in the interaction process between the front end and the back end.
[0085] Please refer to Figure 4 , an optional flowchart of the request processing method provided in the embodiment of the application, Figure 1 S101-S102 shown in the figure can also be implemented through S201-S206, which will be described in combination with the steps.
[0086] S201, receiving a previous query request sent by the front end.
[0087] In the embodiment of the application, the front end obtains device information input by a user, forms a previous query request based on the obtained device information, and sends the previous query request to the back end, and the back end receives the previous query request sent by the front end.
[0088] S202, in response to the previous query request, querying in the preset task information set to obtain first task information of the corresponding device.
[0089] In the embodiment of the application, the backend responds to the previous query request and queries the first task information of the corresponding device in the preset task information set based on the device information in the previous query request.
[0090] Each task information includes task content information, device information, task identification information, time information, and state information representing task progress.
[0091] S203, if the first task information represents that the task response result of the corresponding device has not been obtained, the task incomplete result is sent to the front end; wherein the predetermined condition includes the task incomplete result.
[0092] In the embodiment of the application, if the state information in the first task information is creation or start, it is determined that the first task information represents that the task response result of the corresponding device has not been obtained, and the backend sends the task incomplete result to the front end.
[0093] For example, the front end initiates a query request to the task monitoring module to query the latest task of a certain device. If the task is in the "creation" or "start" state, the backend sends the task incomplete result to the front end, the front end displays the effect of being executed (such as a dynamic effect icon representing loading) based on the task incomplete result, and automatically starts a timer (such as 5 seconds later) to initiate the next query request; if the task is in the "success", "failure" or "timeout" state, the user is prompted with the result and time of the last operation.
[0094] S204, receiving the query request sent periodically by the front end after obtaining the task incomplete result.
[0095] In the embodiment of the application, after receiving the task incomplete result, the front end can send a query request to the backend after a predetermined time. The device information included in the query request can be consistent with the device information included in the previous query request.
[0096] For example, the front end can send a query request to the backend after 5 seconds. In some other embodiments, the front end can also send a query request to the backend after other time lengths.
[0097] S205, based on the device information and task content information included in the query request, searching for corresponding second task information in the preset task information set.
[0098] In the embodiment of the present application, the backend queries the corresponding second task information in the preset task information set based on the device information and the task content information included in the query request. The second task information matches the device information in the query request.
[0099] S206, based on the state information of the second task information, sends a query result to the front end.
[0100] In the embodiment of the present application, the second task information includes state information representing the progress of the task information. The backend sends a query result to the front end based on the state information of the second task information. If the state information represents the "creation" and "start" states, the backend sends the front end a task incomplete result (query result). The front end interface button displays an effect of being executed (such as a dynamic effect icon representing loading), and automatically starts a timer (such as 5 seconds later) to initiate the next query request. If the state information represents the "success", "failure" and "timeout" states, the backend sends the front end the result and time of the last operation of the second task information.
[0101] In the embodiment of the present application, the previous query request sent by the front end is received. In response to the previous query request, the first task information of the corresponding device is queried in the preset task information set. If the first task information represents that the task response result of the corresponding device has not been obtained, a task incomplete result is sent to the front end; wherein the predetermined condition includes the task incomplete result. The query request sent periodically by the front end after receiving the task incomplete result is received. Based on the device information and the task content information included in the query request, the corresponding second task information is searched in the preset task information set. Based on the state information of the second task information, the query result is sent to the front end. In this way, when the backend receives the previous query request and finds the task information that does not include the task response result of the corresponding device, the front end is fed back the task incomplete result. Then the front end can send the query request periodically based on the task incomplete result. This automatic query method of the front end based on the task incomplete result does not require the user on the front end side to perform the query operation multiple times, simplifies the query process, and can make the front end obtain the corresponding query result more quickly, thereby improving the work efficiency of the interaction process between the front end and the backend.
[0102] Please refer to Figure 5 , an optional flowchart of the request processing method provided by the embodiment of the present application is shown in Figure 1 S102 shown in the embodiment of the present application can also be implemented by S301, which will be described in combination with the steps.
[0103] S301 creates the task information in the preset task information set in response to the creation request; wherein the task information includes: task content information, device information, task identification information, time information and state information representing creation.
[0104] In the embodiment of the present application, the creation request includes task content information, device information to which the task belongs, and task identification information. The backend creates state information representing the creation in response to the creation request, and combines the task content information, the device information to which the task belongs, the task identification information, time information, and the state information to obtain task information. The time information can be time information of receiving the creation request.
[0105] In the embodiment of the present application, the task information is created in the preset task information set in response to the creation request. The task information includes task content information, device information to which the task belongs, task identification information, time information, and state information representing the creation. After the backend receives the creation request sent by the front end, the task information including the task content information, the device information to which the task belongs, the task identification information, the time information, and the state information representing the creation is created in the preset task information set. Then, the corresponding query or start operation can be completed based on each sub-information included in the task information, which facilitates the processing process of the task information, and further improves the management efficiency of the backend for the task information.
[0106] Please refer to Figure 6 An optional flowchart of a request processing method provided in the embodiment of the present application is shown in Figure 5 S301, and can further include S401-S402. The steps will be described in combination.
[0107] S401, periodically traversing each task information in the preset task information set to determine a predetermined task information including predetermined state information. The predetermined state information is used to represent that a task response result of a corresponding device has not been obtained.
[0108] In the embodiment of the present application, the state information of the task information included in the preset task information set can represent task creation, task start, task success, task failure, and task timeout. The backend periodically traverses each task information to determine predetermined task information whose state information represents creation and start.
[0109] For example, the backend periodically (for example, 5 seconds) runs to obtain tasks in the "creation" and "start" states from the preset task information set. For the task in the "creation" state, operation data is sent to the device according to the task information, and the task state is modified to "start". For the task in the "start" state, it is judged whether the task execution is timed out according to the task information. If it is timed out, the task state is modified to "timeout".
[0110] S402, updating the predetermined task information based on the predetermined state information.
[0111] In the embodiments of the present application, if the predetermined state information represents creation, the backend sends operation data to the corresponding device based on the task content information and the device information in the predetermined task information, and modifies the predetermined state information to represent start; if the predetermined state information represents start, the backend determines a timeout detection result of the predetermined task information based on the time information in the predetermined task information, and modifies the predetermined state information based on the timeout detection result.
[0112] In the embodiments of the present application, the backend can determine the execution duration of the task based on the time information in the predetermined task information, compare the execution duration with a predetermined duration threshold, determine a timeout detection result, and modify the corresponding predetermined state information to represent timeout if the execution duration is greater than the predetermined duration threshold, or keep the corresponding predetermined state information as start if the execution duration is not greater than the predetermined duration threshold.
[0113] In the embodiments of the present application, each task information in the preset task information set is periodically traversed to determine the predetermined task information including the predetermined state information, the predetermined state information is used to represent that the task response result of the corresponding device has not been obtained, and the predetermined task information is updated based on the predetermined state information. This scheme of centralized and periodic management of task information makes it unnecessary to occupy many threads for managing multiple task information, simplifies the management logic of multiple task information, saves the computing resources of the backend, and enables the backend to quickly respond to the request from the front end, thereby improving the work efficiency in the interaction process between the front end and the backend.
[0114] Please refer to Figure 7 An optional flowchart of the request processing method provided in the embodiments of the present application will be described in combination with the steps.
[0115] S501, receiving the task response result fed back by the device in response to the operation data.
[0116] In the embodiments of the present application, the backend receives the task response result fed back by the device in response to the operation data.
[0117] The task response result can represent task execution "success" or "failure".
[0118] S502, modifying the predetermined state information of the corresponding predetermined task information based on the task response result.
[0119] In the embodiments of the present application, if the task response result represents task execution "success", the predetermined state information of the corresponding predetermined task information is modified to represent "success"; if the task response result represents task execution "failure", the predetermined state information of the corresponding predetermined task information is modified to represent "failure".
[0120] In the embodiments of the present application, the receiving device responds to the task response result of the operation data feedback. The predetermined state information of the corresponding predetermined task information is modified based on the task response result. In this way, after the device responds to the operation data and completes the corresponding operation, the task response result is fed back to the backend, so that the backend can update the state of the task information in the preset task information set based on the task response result in a timely manner, and the front end can quickly and timely query the accurate task progress state when querying the corresponding task information.
[0121] Please refer to Figure 8 An optional flowchart of the request processing method provided by the embodiments of the present application is shown, which will be described in combination with the steps.
[0122] S601, a first request is sent to the backend; wherein the first request includes a query request sent periodically based on a predetermined condition, or a creation request; the creation request is used to create task information in a preset task information set of the backend; and the preset task information set is determined by the backend based on periodic updates to each created task information.
[0123] In the embodiments of the present application, the front end sends a first request to the backend. The first request includes a query request sent periodically based on a predetermined condition, or a creation request; the creation request is used to create task information in a preset task information set of the backend; and the preset task information set is determined by the backend based on periodic updates to each created task information.
[0124] In the embodiments of the present application, a first request is sent to the backend; wherein the first request includes a query request sent periodically based on a predetermined condition, or a creation request; the creation request is used to create task information in a preset task information set of the backend; and the preset task information set is determined by the backend based on periodic updates to each created task information. In this way, since the query request is sent periodically by the front end based on the predetermined condition, the user on the front end side does not need to perform a query operation multiple times, the query process is simplified, the front end can obtain the corresponding query result more quickly, in addition, the backend can manage each created task information through periodic updates to the preset task information set. This scheme of centralized and periodic management of the information set makes it unnecessary to occupy many threads for managing multiple task information, simplifies the management logic of multiple task information, saves the computing resources of the backend, and can quickly respond to the request from the front end, thereby improving the work efficiency in the interaction process between the front end and the backend.
[0125] Please refer to Figure 9 An optional flowchart of the request processing method provided by the embodiments of the present application is shown, Figure 8 S601 shown can also be implemented through S701 to S703, which will be described in combination with the steps.
[0126] S701, in response to the received user operation instruction, sending a previous query request to the backend.
[0127] In the embodiment of the application, the front end sends a previous query request to the backend in response to the received user operation instruction, carrying device information and task content information.
[0128] S702, receiving the task incomplete result fed back by the backend in response to the previous query request.
[0129] In the embodiment of the application, after the backend receives the previous query request, the corresponding first task information is found. If the state information of the first task information is "created" or "started", it is determined that the first task information represents that the task response result of the corresponding device has not been obtained, and the backend sends the task incomplete result to the front end. The predetermined condition includes the task incomplete result.
[0130] S703, periodically sending the query request to the backend based on the task incomplete result.
[0131] In the embodiment of the application, the front end sends the query request to the backend after a predetermined period of time based on the task incomplete result.
[0132] Wherein, after the backend receives the query request, the corresponding task information can be queried based on the device information in the query request. If the task information is in the "success", "failure" or "timeout" state, the user is prompted about the result and time of the last operation. For example, Figure 10 , the backend sends the front end the device name: new device, device ID: CWMP, device group: wanhj corresponding task information, the result and time of the last operation: "last upgrade timeout, 2023-10-15 12:00:30".
[0133] In the embodiment of the application, in response to the received user operation instruction, a previous query request is sent to the backend. The task incomplete result fed back by the backend in response to the previous query request is received. The query request is periodically sent to the backend based on the task incomplete result. In this way, when the backend receives the previous query request and finds the task information that does not include the corresponding device task response result, the front end is fed back the task incomplete result, and then the front end can periodically send the query request based on the task incomplete result. This automatic query method based on the task incomplete result of the front end does not require the user on the front end side to perform multiple query operations, simplifies the query process, and can more quickly obtain the corresponding query result, thereby improving the work efficiency of the interaction process between the front end and the backend.
[0134] Please refer to Figure 11The interaction schematic diagram of the request processing method provided in the embodiments of the present application will be described in combination with the steps.
[0135] S801, the backend receives a first request sent by the front end; wherein the first request comprises a query request or a creation request sent periodically by the front end based on a predetermined condition; the creation request is used to create task information in a preset task information set; the preset task information set is determined based on periodicity for updating each created task information.
[0136] In the embodiments of the present application, the real-time step of S801 can refer to S101, which will not be described here.
[0137] S802, the backend performs a corresponding processing task in the preset task information set based on the first request.
[0138] In the embodiments of the present application, the real-time step of S802 can refer to S102, which will not be described here.
[0139] Please refer to Figure 12 The structure schematic diagram of the request processing apparatus provided in the embodiments of the present application is shown in Figure 1 .
[0140] The embodiments of the present application also provide a request processing apparatus 600 applied to a backend, comprising a receiving unit 601 and a processing unit 602.
[0141] The receiving unit 601 is used to receive a first request sent by the front end; wherein the first request comprises a query request or a creation request sent periodically by the front end based on a predetermined condition; the creation request is used to create task information in a preset task information set; the preset task information set is determined based on periodicity for updating each created task information.
[0142] The processing unit 602 is used to perform a corresponding processing task in the preset task information set based on the first request.
[0143] In the embodiments of the present application, the receiving unit 601 in the request processing apparatus 600 is used to receive a previous query request sent by the front end; a first task information of a corresponding device is obtained by querying in the preset task information set in response to the previous query request; if the first task information represents that a task response result corresponding to the device has not been obtained, a task incomplete result is sent to the front end; wherein the predetermined condition comprises the task incomplete result.
[0144] In the embodiments of the present application, the receiving unit 601 in the request processing apparatus 600 is used to receive the query request sent periodically by the front end after obtaining the task incomplete result.
[0145] The processing unit 602 in the request processing apparatus 600 is configured to search for corresponding second task information in the preset task information set based on the device information and the task content information included in the query request.
[0146] The processing unit 602 in the request processing apparatus 600 is configured to send a query result to the front end based on the state information of the second task information, wherein the state information is used to represent the task progress of the second task information.
[0147] The processing unit 602 in the request processing apparatus 600 is configured to create the task information in the preset task information set in response to the creation request, wherein the task information includes task content information, device information, task identification information, time information, and state information representing creation.
[0148] The processing unit 602 in the request processing apparatus 600 is configured to periodically traverse each task information in the preset task information set, and determine a predetermined task information including predetermined state information, wherein the predetermined state information is used to represent that a task response result of a corresponding device has not been obtained.
[0149] The processing unit 602 in the request processing apparatus 600 is configured to update the predetermined task information based on the predetermined state information.
[0150] The processing unit 602 in the request processing apparatus 600 is configured to, if the predetermined state information represents creation, send operation data to a corresponding device based on the task content information and the device information in the predetermined task information, and modify the predetermined state information to represent start-up.
[0151] If the predetermined state information represents start-up, the processing unit 602 in the request processing apparatus 600 is configured to determine a timeout detection result of the predetermined task information based on the time information in the predetermined task information, and modify the predetermined state information based on the timeout detection result.
[0152] The processing unit 602 in the request processing apparatus 600 is configured to receive the task response result fed back by the device in response to the operation data, and modify the predetermined state information of the corresponding predetermined task information based on the task response result.
[0153] It should be noted that, in the embodiments of the present application, if the request processing method described above is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, and includes a number of instructions for causing a request processing device (which can be a personal computer or the like) to execute all or part of the methods described in the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (Read Only Memory, ROM), a magnetic disk or an optical disk, and various media that can store program codes. Thus, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0154] Correspondingly, the embodiments of the present application provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps in the method on the back-end side.
[0155] Correspondingly, the embodiments of the present application also provide a computer program product, which includes a computer program, and the computer program is executable by the first processor 701 of the electronic device 700 to complete the steps in the method on the back-end side.
[0156] Correspondingly, the embodiments of the present application provide an electronic device 700, which includes a first memory 702 and a first processor 701, and the first memory 702 stores a computer program executable on the first processor 701, and the first processor 701 implements the steps in the method when executing the program.
[0157] It should be noted that: the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects to the method embodiments. For technical details not disclosed in the storage medium and device embodiments of the present application, please refer to the description of the method embodiments of the present application for understanding.
[0158] It should be noted that, Figure 13 A hardware entity of an electronic device provided in the embodiments of the present application Figure 1 As Figure 13 shown, the hardware entity of the electronic device 700 includes a first processor 701 and a first memory 702, wherein;
[0159] The first processor 701 usually controls the overall operation of the electronic device 700.
[0160] The first memory 702 is configured to store instructions and applications executable by the first processor 701, and can also cache data (for example, image data, audio data, voice communication data, and video communication data) to be processed by the first processor 701 and modules in the electronic device 700 and data that has been processed, and can be implemented by a FLASH or a Random Access Memory (RAM).
[0161] Please refer to Figure 14 The structure of the request processing apparatus provided in the embodiments of the present application is shown in FIG. 8. Figure 2 .
[0162] The embodiments of the present application also provide a request processing apparatus 800 applied to a front end, comprising a sending unit 801.
[0163] The sending unit 801 is configured to send a first request to a back end; wherein the first request comprises a query request sent periodically based on a predetermined condition, or a creation request; the creation request is used to create a task information in a preset task information set in the back end; the preset task information set is determined by the back end based on periodicity for updating each created task information.
[0164] In the embodiments of the present application, the sending unit 801 in the request processing apparatus 800 is configured to send a previous query request to the back end in response to a received user operation instruction; and receive a task incomplete result fed back by the back end in response to the previous query request; wherein the task incomplete result is fed back by first task information queried by the back end based on the previous query request, and the first task information represents a task response result of a corresponding device that has not been obtained; and the predetermined condition comprises the task incomplete result.
[0165] In the embodiments of the present application, the sending unit 801 in the request processing apparatus 800 is configured to send the query request to the back end periodically based on the task incomplete result.
[0166] Correspondingly, the embodiments of the present application provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the steps in the front end side method.
[0167] Correspondingly, the embodiments of the present application also provide a computer program product, which comprises a computer program, and the computer program is executable by the second processor 901 of the electronic device 900 to complete the steps in the front end side method.
[0168] Correspondingly, this application provides an electronic device 900, including a second memory 902 and a second processor 901. The second memory 902 stores a computer program that can run on the second processor 901. When the second processor 901 executes the program, it implements the steps in the above method.
[0169] It should be noted that the descriptions of the storage medium and device embodiments above are similar to the descriptions of the method embodiments above, and have similar beneficial effects. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0170] It should be noted that, Figure 15 A hardware entity illustration of an electronic device provided in the embodiments of this application. Figure 2 ,like Figure 15 As shown, the hardware entity of the electronic device 900 includes: a second processor 901 and a second memory 902, wherein;
[0171] The second processor 901 typically controls the overall operation of the electronic device 900.
[0172] The second memory 902 is configured to store instructions and applications executable by the second processor 901, and can also cache data to be processed or already processed by the second processor 901 and various modules in the electronic device 900 (e.g., image data, audio data, voice communication data, and video communication data), which can be implemented by flash memory or random access memory (RAM).
[0173] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0174] It should be noted that, in the present document, the terms "comprising", "containing", or any other similar term are intended to encompass non-exclusive inclusion, such that processes, methods, articles, or apparatuses that comprise a list of elements are not limited to those elements, but can also include other elements not expressly listed, or also include elements inherent in such processes, methods, articles, or apparatuses. Without further limitation, an element defined by the phrase "comprising a" does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0175] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and actual implementation can have another division manner, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed components can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0176] The units described above as separate components can or can not be physically separate, and the components shown as units can or can not be physical units; they can be located in one place or distributed on multiple network units; and part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0177] In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be realized in the form of hardware or in the form of hardware plus software functional unit.
[0178] Those of ordinary skill in the art can understand that all or part of the steps of the above method embodiments can be completed by program instruction related hardware, and the foregoing program can be stored in a computer readable storage medium, and the program executes the steps of the above method embodiments when executed; and the foregoing storage medium includes: mobile storage device, read only memory (Read Only Memory, ROM), magnetic disc or optical disc, and various storage program codes.
[0179] Alternatively, the above-mentioned integrated units of the present application, if realized in the form of software function modules and sold or used as independent products, can also be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the embodiments of the present application. The aforementioned storage medium includes: mobile storage devices, ROM, magnetic disks or optical disks, and various media that can store program codes.
[0180] The above is only an embodiment of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A request processing method, characterized in that, Applied to the backend, including: Receive the previous query request sent by the front end; In response to the previous query request, a query is performed in the preset task information set to obtain the first task information of the corresponding device; If the first task information indicates that no task response result has been obtained for the corresponding device, then a task incomplete result is sent to the front end; wherein, the predetermined condition includes the task incomplete result; The system receives a first request from the front end; wherein the first request includes a query request and a creation request periodically sent by the front end based on predetermined conditions; the creation request is used to create task information in a preset task information set; the preset task information set is determined based on periodic updates to each created task information set; the task information is used by the back end to perform corresponding operations on the device; the device establishes a connection with the back end through an Internet of Things (IoT) protocol. Based on the first request, the corresponding processing task is executed in the preset task information set.
2. The request processing method according to claim 1, characterized in that, The step of executing the corresponding processing task in the preset task information set based on the first request includes: Based on the device information and task content information included in the query request, the corresponding second task information is searched in the preset task information set; Based on the status information of the second task information, the query result is sent to the front end; wherein, the status information is used to characterize the task progress of the second task information.
3. The request processing method according to claim 1, characterized in that, When the first request includes the creation request, the step of executing the corresponding processing task based on the first request in the preset task information set includes: The task information is created in response to the creation request in the preset task information set; wherein, the task information includes: task content information, device information, task identifier information, time information, and status information indicating creation.
4. The request processing method according to claim 3, characterized in that, After creating the task information in response to the creation request in the preset task information set, the method further includes: Periodically traverse each of the task information in the preset task information set to determine the predetermined task information including predetermined status information; wherein, the predetermined status information is used to characterize the task response result of not obtaining the corresponding device; The scheduled task information is updated based on the scheduled status information.
5. The request processing method according to claim 4, characterized in that, Updating the predetermined task information based on the predetermined status information includes one of the following: If the predetermined status information is created, then operation data is sent to the corresponding device based on the task content information and the device information in the predetermined task information, and the predetermined status information is modified to indicate startup; If the predetermined status information indicates that the task has been started, then the timeout detection result of the predetermined task information is determined based on the time information in the predetermined task information, and the predetermined status information is modified based on the timeout detection result.
6. The request processing method according to claim 5, characterized in that, The method further includes: Receive the task response result from the device in response to the operation data; Modify the predetermined status information of the corresponding predetermined task information based on the task response result.
7. A request processing method, characterized in that, Applied to front-end, including: Send the previous query request to the backend; Receive a task incomplete result; wherein, the task incomplete result is that the backend responds to the previous query request by querying a preset task information set to obtain the first task information of the corresponding device; if the first task information indicates that no task response result for the corresponding device has been obtained, then the task incomplete result is sent to the frontend; wherein, the predetermined condition includes the task incomplete result; A first request is sent to the backend; wherein the first request includes a query request and a creation request sent periodically based on predetermined conditions; the creation request is used to create task information in a preset task information set in the backend; the preset task information set is determined by the backend based on periodic updates to each created task information; the task information is used by the backend to perform corresponding operations on the device; the device establishes a connection with the backend through an Internet of Things protocol.
8. The request processing method according to claim 7, characterized in that, When the first request includes the query request, before sending the first request to the backend, the method further includes: In response to the received user operation command, send the previous query request to the backend; The system receives a response from the backend to the previous query request, indicating that the task was not completed. The task not completed result is a response from the backend based on the first task information queried by the backend in the previous query request, where the first task information indicates that no task response result was obtained from the corresponding device. The predetermined condition includes the task not completed result.
9. The request processing method according to claim 7, characterized in that, Sending the first request to the backend includes: Based on the incomplete result of the task, the query request is periodically sent to the backend.
10. A request processing apparatus, characterized in that, Applied to the backend, including: The receiving unit is used to receive the previous query request sent by the front end. The processing unit is used to respond to the previous query request by querying the preset task information set to obtain the first task information of the corresponding device; If the first task information indicates that no task response result has been obtained for the corresponding device, then a task incomplete result is sent to the front end; wherein, the predetermined condition includes the task incomplete result; A receiving unit is used to receive a first request sent by the front end; wherein the first request includes a query request and a creation request sent periodically by the front end based on predetermined conditions; the creation request is used to create task information in a preset task information set; the preset task information set is determined based on periodic updates to each created task information; the task information is used by the back end to perform corresponding operations on the device; the device establishes a connection with the back end through an Internet of Things protocol; The processing unit is configured to execute the corresponding processing task in the preset task information set based on the first request.
11. A request processing apparatus, characterized in that, Applied to front-end, including: A sending unit is used to send a previous query request to the backend; receive a task incomplete result; wherein, the task incomplete result is that the backend responds to the previous query request by querying a preset task information set to obtain the first task information of the corresponding device; if the first task information indicates that no task response result for the corresponding device has been obtained, then the task incomplete result is sent to the frontend; wherein, the predetermined condition includes the task incomplete result. A sending unit is used to send a first request to the backend; wherein the first request includes a query request and a creation request sent periodically based on predetermined conditions; the creation request is used to create task information in a preset task information set of the backend; the preset task information set is determined by the backend based on periodic updates to each created task information; the task information is used by the backend to perform corresponding operations on the device; the device establishes a connection with the backend through an Internet of Things protocol.
12. An electronic device, characterized in that, The method includes a memory and a processor, the memory storing a computer program executable on the processor, the processor executing the computer program to implement the steps of the method according to any one of claims 1 to 6, or to implement the steps of the method according to any one of claims 7 to 9.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6, or the steps of the method according to any one of claims 7 to 9.
14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6, or the steps of the method according to any one of claims 7 to 9.
Citation Information
Patent Citations
Data processing method, device, system, equipment, medium and program product
CN117609344A
Internet of Things terminal equipment access method and system based on Netty
CN117615033A