A cost accounting real-time display method, device and medium
Patent Information
- Application Number
- CN202410118037.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-26
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2044-01-26
AI Technical Summary
[0004]传统的成本核算系统通过提前归集好核算所需业务数据进行核算,在核算过程中只能粗略显示当前执行的步骤,难以具体显示核算的数据,也难以直观展示核算处理过程信息
[0038] Based on the WebSocket communication protocol, a connection is established between the browser and the server during cost accounting. This allows the server to proactively push data to the browser, which then displays the processing progress and content returned by the server in real time. This achieves real-time display of progress and data during cost accounting, addressing the need for visualized cost accounting progress among enterprise users and improving the intuitiveness and ease of use of cost accounting. Furthermore, based on the WebSocket protocol, it offers good real-time performance, saves bandwidth resources, has low system overhead, and can automatically estimate the completion time based on factors such as the amount of accounting data, updating the estimated remaining time in real time.
Smart Images

Figure CN118094033B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, specifically to a method, device, and medium for real-time display of cost accounting. Background Technology
[0002] In an Enterprise Resource Planning (ERP) system, cost accounting is required to meet the corresponding enterprise needs.
[0003] Due to the complexity of the cost accounting process and the large volume of business data, the entire cost accounting process often takes several minutes or even hours. Enterprise users usually focus on the real-time accounting progress and data content.
[0004] Traditional cost accounting systems perform calculations by pre-collecting the necessary business data. During the calculation process, they can only roughly display the currently executed steps, making it difficult to display specific calculation data or intuitively show the calculation process information. Summary of the Invention
[0005] To address the aforementioned issues, this application proposes a method for real-time display of cost accounting, comprising:
[0006] The server pre-registers a WebSocket service endpoint and receives cost calculation requests sent by users through their browsers;
[0007] Receive and parse the request parameters sent by the browser, set the corresponding request context information, and start the cost accounting process;
[0008] For the cost accounting process, a cost accounting status is set, the required accounting steps and the cost data included in the accounting steps are obtained, and the accounting completion time is estimated based on the cost data to obtain the estimated completion time.
[0009] The calculation progress information is returned to the browser so that the browser can parse and display the calculation progress information based on the structure of the request context information. The calculation progress information includes: cost calculation status, current calculation step, current step progress, and estimated completion time.
[0010] Based on the producer-consumer model, an event listener is added to each accounting node corresponding to the accounting step, and real-time progress information is generated based on the consumed content of the event listener.
[0011] The real-time progress information is sent to the browser so that the browser can parse the real-time progress information and update and display the calculation progress information.
[0012] In one example, receiving a cost calculation request sent by a user through a browser includes:
[0013] Start listening for cost calculation requests initiated by the browser;
[0014] The system determines that a user has initiated a cost calculation request based on the WebSocket protocol through a browser, establishes a connection between the browser and the server, and displays a dialog box in the browser to show the calculation progress information.
[0015] In one example, the request parameters sent by the browser are received and parsed, specifically including:
[0016] Receive and parse the request parameters sent by the browser to determine whether the request parameters are abnormal;
[0017] If no exceptions are found, continue setting the corresponding request context information;
[0018] If an exception is found, a formatted exception message will be returned based on the request parameters.
[0019] In one example, before setting the cost accounting status for the cost accounting process, the method further includes:
[0020] The cost accounting process is locked to prevent other users from executing the cost accounting process simultaneously within the same time period.
[0021] In one example, based on the producer-consumer pattern, event listeners are added to each accounting node corresponding to the accounting step, and real-time progress information is generated based on the consumed content of the event listeners, specifically including:
[0022] The accounting nodes included in the accounting steps are identified, and an event listener is added before each accounting node is calculated based on the producer-consumer pattern.
[0023] The event listener processes and consumes the processing information corresponding to the accounting node. If the processing information belongs to the accounting progress information, then formatted real-time progress information is generated based on the processing information.
[0024] In one example, after processing and consuming the processing information corresponding to the accounting node through the event listener, the method further includes:
[0025] Record the processing time of the processing information by the accounting node;
[0026] Based on the processing time of all consumed accounting nodes and the preset weights corresponding to the accounting nodes, the estimated completion time of the remaining accounting nodes is obtained through weighted calculation.
[0027] The estimated completion time is sent to the browser so that the browser updates the accounting progress information.
[0028] In one example, real-time progress information is generated based on the consumed content of the event listener, specifically including:
[0029] Once it is confirmed that all accounting nodes have been consumed, real-time progress information is generated to update the cost accounting status and add the accounting completion time in the real-time progress information.
[0030] In one example, the method further includes:
[0031] Based on the event listener, if an anomaly is detected in the cost accounting process, the corresponding anomaly information is obtained, formatted, and sent to the browser for display.
[0032] On the other hand, this application also proposes a real-time cost accounting display device, including:
[0033] At least one processor; and,
[0034] A memory communicatively connected to the at least one processor; wherein,
[0035] The memory stores instructions that can be executed by the at least one processor, which enables the at least one processor to perform a real-time cost accounting display method as described in any of the above examples.
[0036] On the other hand, this application also proposes a non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured as: the real-time display method for cost accounting described in any of the above examples.
[0037] The real-time cost accounting display method proposed in this application can bring the following beneficial effects:
[0038] Based on the WebSocket communication protocol, a connection is established between the browser and the server during cost accounting. This allows the server to proactively push data to the browser, which then displays the processing progress and content returned by the server in real time. This achieves real-time display of progress and data during cost accounting, addressing the need for visualized cost accounting progress among enterprise users and improving the intuitiveness and ease of use of cost accounting. Furthermore, based on the WebSocket protocol, it offers good real-time performance, saves bandwidth resources, has low system overhead, and can automatically estimate the completion time based on factors such as the amount of accounting data, updating the estimated remaining time in real time. Attached Figure Description
[0039] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0040] Figure 1 This is a flowchart illustrating the real-time display method for cost accounting in this embodiment of the application.
[0041] Figure 2 This is a schematic diagram illustrating real-time display of cost accounting in one scenario of this application embodiment;
[0042] Figure 3 This is a schematic diagram of the real-time cost accounting display device in the embodiments of this application. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0044] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0045] In traditional cost accounting, the following scheme is typically used to demonstrate the cost accounting process:
[0046] 1. Use a single HTTP request. Until the cost calculation is completed, the browser will continuously display "Calculating" or other prompts, and then display the calculation results after the calculation is completed.
[0047] 2. Use a polling method to continuously request the server for the latest data at preset time intervals, and display the current calculation progress data obtained from each request in the browser.
[0048] Among these issues, using a single HTTP request makes it difficult to display accounting process information. The browser page remains in an intermediate state for a long time, and users can only receive one type of content feedback while waiting for a long time, resulting in a poor user experience. In addition, it is impossible to know whether there are any abnormalities in the cost accounting during the request, which may lead to problems such as no response or excessively long response time.
[0049] Using polling, the browser needs to constantly send requests to the server. However, HTTP requests can contain lengthy headers, with only a small portion containing truly valid data, easily wasting bandwidth and other resources. Furthermore, this polling method may have data gaps of a few seconds, making it difficult to obtain calculation progress in a timely manner, resulting in poor real-time display of the calculation process. To execute queries and return calculation progress, the server needs to store the calculation progress in a database or cache, potentially causing data redundancy and increasing server storage overhead.
[0050] Based on this, such as Figure 1 As shown in the embodiments of this application, a method for real-time display of cost accounting is provided, including:
[0051] S101: The server pre-registers a websocket service endpoint and receives cost calculation requests sent by users through their browsers.
[0052] WebSocket is a protocol for full-duplex communication over a single TCP connection. A WebSocket server endpoint refers to a server that is built and registered based on the WebSocket protocol, enabling it to communicate using the WebSocket protocol.
[0053] like Figure 2 As shown, after registering the WebSocket service endpoint, the server starts listening for cost calculation requests initiated by the browser and waits for WebSocket connection requests.
[0054] When a user has a cost accounting need, they log in to the ERP system through a browser and initiate a cost accounting request. The cost accounting request is implemented based on the WebSocket protocol. At this time, the browser creates a WebSocket request to the server, and the server establishes a WebSocket connection based on the request.
[0055] The browser displays a corresponding dialog box in the ERP system, which is used to show accounting progress information. The dialog box can be displayed in the form of a pop-up window.
[0056] S102: Receive and parse the request parameters sent by the browser, set the corresponding request context information, and start the cost accounting process.
[0057] The browser sends request parameters to the server, which include user information, current user operation parameters, etc., via an established WebSocket connection. User information may include user ID, user permissions, etc., and current user operation parameters may include the target of the cost accounting to be performed and the scope of the cost accounting.
[0058] like Figure 2As shown, after receiving the request parameters, the server parses them to determine if there are any anomalies. If no anomalies are found and the parameters are normal, the server continues to set the corresponding request context information (Session information) and begins the cost calculation process.
[0059] If there is an error in the request parameters, a formatted error message will be returned based on the request parameters. After receiving the error message, the browser can prompt the user so that the user can troubleshoot the error according to the prompt. Alternatively, after receiving the error, the browser can try to resend the request parameters.
[0060] S103: For the cost accounting process, set the cost accounting status, obtain the required accounting steps and the cost data included in the accounting steps, and estimate the accounting completion time based on the cost data to obtain the estimated completion time.
[0061] Since the cost accounting process has just started, the cost accounting status can be set to running. Different accounting targets may have different corresponding accounting steps. Cost data may include material, labor, and output data. The accounting steps and cost data can be pre-stored on the ERP system's server. When a user submits a cost accounting request, the server retrieves the corresponding accounting steps and cost data based on the cost accounting target ID. Here, the accounting steps and cost data can all be referred to as accounting data.
[0062] The estimated completion time can be based on cost data. For example, the estimated completion time can be obtained based on the amount and complexity of the cost data (e.g., the data complexity can be determined based on the data type and data source). The more data there is and the higher the data complexity, the longer the estimated completion time will be.
[0063] In addition, such as Figure 2 As shown, before obtaining the cost accounting data, the cost accounting process can be locked to prevent other users from executing the cost accounting process simultaneously within the same time period. Locking means that the cost data used in this cost accounting process cannot be accessed by other accounting processes or modified by other programs or business logic.
[0064] S104: Return the accounting progress information to the browser so that the browser can parse and display the accounting progress information based on the structure of the request context information. The accounting progress information includes: cost accounting status, current accounting step, current step progress, and estimated completion time.
[0065] like Figure 2 As shown, after the server starts the calculation process, it returns the context information of the calculation start to the browser, which then parses the information and displays it to the user.
[0066] At this point, the browser continues the cost accounting process and obtains the corresponding accounting progress information. The accounting progress information includes: cost accounting status, current accounting step, current step progress, and estimated completion time. Among them, the cost accounting status is in progress and will not be modified until the current cost accounting process is completed. The current accounting step and current step progress can be determined based on the accounting step currently being processed. The estimated completion time can be displayed as the initially determined estimated completion time at the beginning. After each accounting step is completed, the estimated completion time can be re-estimated based on the processing time.
[0067] After receiving the accounting progress information, the browser parses the information and displays it in a dialog box.
[0068] S105: Based on the producer-consumer model, add event listeners to each accounting node corresponding to the accounting step, and generate real-time progress information based on the consumed content of the event listeners.
[0069] During cost accounting, the server identifies the accounting nodes within each accounting step. Each accounting step can be considered a single accounting node, or each action within a given step can be considered a single accounting node. Based on the producer-consumer pattern, an event listener is added before each accounting node's calculation. The producer-consumer pattern is a concurrent programming pattern used to solve the coordination problem between producers and consumers in a multi-threaded environment. An event listener is a programming mechanism used to listen for specific events and execute corresponding actions when the events occur. Event listeners can respond to system events; adding event listeners before the accounting node's calculation allows it to monitor the completion status of each accounting node.
[0070] At this point, the event listener processes and consumes the processing information corresponding to the accounting node. If the processing information is accounting progress information (e.g., cost accounting status, current accounting step, current step progress), or other information pre-configured in the user operation parameters that needs to be displayed in the browser (e.g., information related to the target to be calculated, server status information, etc.), then formatted real-time progress information is generated based on the processing information (or, as shown in the example below). Figure 2 As shown, this is called the progress information, so that it can be packaged as real-time progress information (also called progress information) and sent to the browser as the content to be sent.
[0071] S106: Send the real-time progress information to the browser so that the browser can parse the real-time progress information and update and display the accounting progress information.
[0072] After receiving the real-time progress information, the browser parses it. Since the progress information has already been displayed in the dialog box, if changes are detected in the real-time progress information, the displayed information reflecting these changes will be updated accordingly.
[0073] Furthermore, each time the processing information corresponding to a computation node is processed and consumed through the event listener, it is considered that the computation node has completed its processing. At this time, the processing time of the computation node for processing information is recorded. A corresponding weight is pre-assigned to each computation node. This weight can be obtained based on the average processing time of each computation node in the historical records. The longer the average processing time, the higher its corresponding weight.
[0074] At this point, based on the processing time of all consumed processing nodes and the preset weights corresponding to the processing nodes, the estimated completion time for the remaining processing nodes is obtained through weighted calculation. For example, if the estimated completion time based on the data volume and complexity is A, and the total weight of the processed processing nodes is 0.4 after normalization, then the weight of the remaining processing nodes is 0.6, and the estimated completion time for the remaining processing nodes is 0.6*A.
[0075] The estimated completion time is sent to the browser so that the browser can update the calculation progress information. This can be done along with real-time progress information, or asynchronously after the calculation is complete, as the calculation may take some additional time.
[0076] Based on the WebSocket communication protocol, a connection is established between the browser and the server during cost accounting. This allows the server to proactively push data to the browser, which then displays the processing progress and content returned by the server in real time. This achieves real-time display of progress and data during cost accounting, addressing the need for visualized cost accounting progress among enterprise users and improving the intuitiveness and ease of use of cost accounting. Furthermore, based on the WebSocket protocol, it offers good real-time performance, saves bandwidth resources, has low system overhead, and can automatically estimate the completion time based on factors such as the amount of accounting data, updating the estimated remaining time in real time.
[0077] In one embodiment, such as Figure 2 As shown, once all accounting nodes have been consumed, the accounting is considered complete, and real-time progress information is generated. This real-time progress information updates the cost accounting status to "completed," and adds the accounting completion time. This completion time is the actual time recorded during this cost accounting process.
[0078] At this time, the real-time progress information (such as...) Figure 2 As shown, since the calculation has been completed, the corresponding context information (which can also be called the calculation completion time) is sent to the browser. After the browser parses the information, it displays an interface indicating that the calculation has been completed in the dialog box and disconnects the WebSocket connection with the server. At this point, the user can continue to view the data of the calculation process and then choose to close the dialog box after viewing it.
[0079] In addition, the cost accounting process can be monitored based on event listeners. If an exception occurs in the cost accounting process, the corresponding exception information can be obtained, formatted, and sent to the browser for display.
[0080] like Figure 3 As shown, this application also proposes a real-time cost accounting display device, comprising:
[0081] At least one processor; and,
[0082] A memory communicatively connected to the at least one processor; wherein,
[0083] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform a real-time cost accounting display method as described in any of the above embodiments.
[0084] This application also proposes a non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured as the real-time cost accounting display method described in any of the above embodiments.
[0085] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and medium embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the description of the method embodiments.
[0086] The devices and media provided in this application are one-to-one with the methods. Therefore, the devices and media also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0087] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0088] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0089] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0090] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0091] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0092] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0093] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0094] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0095] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for real-time display of cost accounting, characterized in that, include: The server pre-registers a WebSocket service endpoint and receives cost calculation requests sent by users through their browsers; Receive and parse the request parameters sent by the browser, set the corresponding request context information, and start the cost accounting process; For the cost accounting process, a cost accounting status is set, the required accounting steps and the cost data included in the accounting steps are obtained, and the accounting completion time is estimated based on the cost data to obtain the estimated completion time. The calculation progress information is returned to the browser so that the browser can parse and display the calculation progress information based on the structure of the request context information. The calculation progress information includes: cost calculation status, current calculation step, current step progress, and estimated completion time. Based on the producer-consumer model, an event listener is added to each accounting node corresponding to the accounting step, and real-time progress information is generated based on the consumed content of the event listener. The real-time progress information is sent to the browser so that the browser can parse the real-time progress information and update and display the accounting progress information. Based on the producer-consumer model, an event listener is added to each accounting node corresponding to the accounting step, and real-time progress information is generated based on the consumed content of the event listener, specifically including: The accounting nodes included in the accounting steps are identified, and an event listener is added before each accounting node is calculated based on the producer-consumer pattern. The event listener processes and consumes the processing information corresponding to the accounting node. If the processing information belongs to the accounting progress information, then formatted real-time progress information is generated based on the processing information. After processing and consuming the processing information corresponding to the accounting node through the event listener, the method further includes: Record the processing time of the processing information by the accounting node; Based on the processing time of all consumed accounting nodes and the preset weights corresponding to the accounting nodes, the estimated completion time of the remaining accounting nodes is obtained through weighted calculation. The estimated completion time is sent to the browser so that the browser updates the accounting progress information.
2. The method according to claim 1, characterized in that, Receive cost calculation requests sent by users through their browsers, specifically including: Start listening for cost calculation requests initiated by the browser; The system determines that a user has initiated a cost calculation request based on the WebSocket protocol through a browser, establishes a connection between the browser and the server, and displays a dialog box in the browser to show the calculation progress information.
3. The method according to claim 1, characterized in that, Receiving and parsing the request parameters sent by the browser, specifically including: Receive and parse the request parameters sent by the browser to determine whether the request parameters are abnormal; If no exceptions are found, continue setting the corresponding request context information; If an exception is found, a formatted exception message will be returned based on the request parameters.
4. The method according to claim 1, characterized in that, Before setting the cost accounting status for the aforementioned cost accounting process, the method further includes: The cost accounting process is locked to prevent other users from executing the cost accounting process simultaneously within the same time period.
5. The method according to claim 1, characterized in that, Based on the consumed content of the event listener, real-time progress information is generated, specifically including: Once it is confirmed that all accounting nodes have been consumed, real-time progress information is generated to update the cost accounting status and add the accounting completion time in the real-time progress information.
6. The method according to claim 1, characterized in that, The method further includes: Based on the event listener, if an anomaly is detected in the cost accounting process, the corresponding anomaly information is obtained, formatted, and sent to the browser for display.
7. A real-time cost accounting display device, characterized in that, include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform, for example, the real-time cost accounting display method as described in any one of claims 1 to 6.
8. A non-volatile computer storage medium storing computer-executable instructions, characterized in that, The computer-executable instructions are set to: the real-time cost accounting display method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Asynchronous task inquiry method and device
CN107798108A
Websocket-based task progress interaction method and system
CN114327898A