Asynchronous file downloading method, device and equipment
By extracting and encapsulating data query components, we build a file storage center system and process data downloads asynchronously, solving the low development efficiency and performance problems of traditional download functions and achieving efficient asynchronous file downloads.
Patent Information
- Application Number
- CN202410913873.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2024-10-08
AI Technical Summary
The traditional web project file download function requires repeated coding, which results in low development efficiency. The synchronization method results in long waiting times, affects system performance, and may cause the service to crash or become unresponsive.
Extract the data query component and data export component, encapsulate it into a data download module, abstract it into a data query interface, build a file storage center system, process data download asynchronously, and reduce the occupation of main business resources.
It reduces the coupling between download business and main business, improves download independence and resource utilization, avoids service crashes, and improves system performance.
Smart Images

Figure CN118748674A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device and equipment for asynchronously downloading files. Background Art
[0002] The traditional web project file download function requires an export button for each query on each page, resulting in repeated code coding and low development efficiency. In addition, the synchronous mode results in a long waiting time, which affects the current operator's subsequent operations on other pages of the system. In addition, the program is executed on the service, occupying the current service's resources, such as CPU and memory, which may cause important services to freeze or become unresponsive due to exporting files. Summary of the invention
[0003] The present invention provides a method, device and equipment for asynchronous file downloading, which can reduce the coupling between the downloading service and the main service and reduce the occupation of the main program resources by the data downloading task.
[0004] In one aspect, the present invention provides a method for asynchronously downloading a file, the method comprising:
[0005] Extract the data query component and data export component from the preset project file;
[0006] Encapsulating the data query component and the data export component to form a data download module;
[0007] Abstracting the data query component into a data query interface, and compiling attribute information of the data query interface;
[0008] According to the attribute information of the data download module and the data query interface, a file storage center system is constructed and stored in a network attached storage disk;
[0009] In response to a data download request from an external service platform, determine a business query interface;
[0010] The service query interface is called to query the target service data corresponding to the data download request in the network attached storage disk, and store the data in a local folder.
[0011] Optionally, constructing a file storage center system according to the attribute information of the data download module and the data query interface includes:
[0012] Build preset template engines corresponding to multiple preset file formats;
[0013] Determine preset attribute information of a preset data download module and a preset data query interface corresponding to each preset template engine according to the attribute information of the data download module and the data query interface;
[0014] A file storage center system is constructed according to the preset data download module corresponding to each preset template engine and the preset attribute information of the preset data query interface.
[0015] Optionally, calling the service query interface to query the network attached storage disk for target service data corresponding to the data download request includes:
[0016] Determining a target template engine corresponding to the target business data according to a target data format corresponding to the target business data;
[0017] The service query interface is called to query the target template engine in the network attached storage disk, and the target service data corresponding to the data download request is queried in the target template engine.
[0018] Optionally, the method further includes:
[0019] Obtaining the real-time task export status and real-time export progress of the target business data;
[0020] Storing the real-time task export status and real-time export progress of the target business data in a cache database;
[0021] In response to the task query instruction of the target object, the current task export status and the current export progress corresponding to the current time are queried in the cache database.
[0022] Optionally, in response to the task query instruction of the target object, querying the cache database for the current task export status and current export progress corresponding to the current time includes:
[0023] Obtaining an object permission database; the object permission database stores data access permission information corresponding to each preset object;
[0024] In response to a task query instruction of a target object, querying the object permission database for a result of data access permission corresponding to the target object;
[0025] If the data access permission result indicates that the target object has access permission, query the cache database for the current task export status and the current export progress corresponding to the current time.
[0026] Optionally, determining the service query interface in response to a data download request from an external service platform includes:
[0027] In response to a data download request from an external service platform, obtaining a service enumeration value in the data download request;
[0028] A data query interface matching the business enumeration value is queried to obtain a business query interface.
[0029] Optionally, in response to a data download request from an external service platform, obtaining a service enumeration value in the data download request includes:
[0030] Get the file export task and display the download progress of the target file in the download center;
[0031] When the download progress meets the preset condition, generating a data download request to the external service platform in response to the file download control;
[0032] The calling of the service query interface to query the target service data corresponding to the data download request in the network attached storage disk includes:
[0033] Calling the business query interface, and determining target paging parameters based on the paging query function;
[0034] According to the target paging parameter, the network attached storage disk is queried for target service data corresponding to the data download request.
[0035] Another aspect provides a device for asynchronously downloading files, the device comprising:
[0036] A component extraction module, used to extract data query components and data export components in a preset project file;
[0037] An encapsulation module, used to encapsulate the data query component and the data export component to form a data download module;
[0038] An attribute determination module, used to abstract the data query component into a data query interface and write attribute information of the data query interface;
[0039] A storage module, used to construct a file storage center system and store the file in a network-attached storage disk according to the attribute information of the data download module and the data query interface;
[0040] An interface determination module, used to determine a business query interface in response to a data download request from an external service platform;
[0041] The file storage module is used to call the service query interface, query the target service data corresponding to the data download request in the network attached storage disk, and store it in a local folder.
[0042] Optionally, the storage module includes:
[0043] A preset template building unit, used to build preset template engines corresponding to multiple preset file formats;
[0044] An attribute determination unit, used to determine preset attribute information of a preset data download module and a preset data query interface corresponding to each preset template engine according to the attribute information of the data download module and the data query interface;
[0045] The system construction unit is used to construct a file storage center system according to the preset data download module corresponding to each preset template engine and the preset attribute information of the preset data query interface.
[0046] Optionally, the file storage module includes:
[0047] A target engine determining unit, configured to determine a target template engine corresponding to the target business data according to a target data format corresponding to the target business data;
[0048] The data query unit is used to call the service query interface, query the target template engine in the network attached storage disk, and query the target service data corresponding to the data download request in the target template engine.
[0049] Optionally, the device further comprises:
[0050] A real-time data acquisition module is used to acquire the real-time task export status and real-time export progress of the target business data;
[0051] A cache module, used to store the real-time task export status and real-time export progress of the target business data in a cache database;
[0052] The current data query module is used to query the current task export status and current export progress corresponding to the current time in the cache database in response to the task query instruction of the target object.
[0053] Optionally, the current data query module is also used to obtain an object permission database; the object permission database stores data access permission information corresponding to each preset object; in response to a task query instruction of the target object, the object permission database is queried for the data access permission result corresponding to the target object; if the data access permission result indicates that the target object has access permission, the cache database is queried for the current task export status and current export progress corresponding to the current time.
[0054] Optionally, the interface determination module includes:
[0055] A service value acquisition unit, configured to respond to a data download request from an external service platform and acquire a service enumeration value in the data download request;
[0056] The interface query unit is used to query the data query interface matching the business enumeration value to obtain the business query interface.
[0057] Optionally, the business value acquisition unit is further used to acquire a file export task and display the download progress of the target file in the download center; when the download progress meets a preset condition, in response to the file download control, a data download request of the external service platform is generated;
[0058] The data query unit is further used to call the business query interface, determine the target paging parameters based on the paging query function, and query the target business data corresponding to the data download request in the network attached storage disk according to the target paging parameters.
[0059] On the other hand, an electronic device is provided, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or the at least one program is loaded and executed by the processor to implement the above-mentioned asynchronous file downloading method.
[0060] On the other hand, a computer storage medium is provided, wherein the computer storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by a processor to implement the above-mentioned asynchronous file downloading method.
[0061] On the other hand, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes to implement the above-mentioned file asynchronous download method.
[0062] The method, device and equipment for asynchronous file downloading provided by the present invention have the following technical effects:
[0063] The present invention extracts the data query component and the data export component in the preset project file; encapsulates the data query component and the data export component to form a data download module; abstracts the data query component into a data query interface, and writes the attribute information of the data query interface; constructs a file storage center system and stores it in a network-attached storage disk according to the attribute information of the data download module and the data query interface; determines the business query interface in response to the data download request of the external service platform; calls the business query interface, queries the target business data corresponding to the data download request in the network-attached storage disk, and stores it in a local folder. The present invention constructs a file asynchronous download center, encapsulates the export file logic into a separate project architecture service, separates the code level from the main business service, reduces coupling, and improves its independence; at the architecture level, the export logic is abstracted, and the specific business logic is implemented by the interface and written by itself, which increases flexibility and greatly releases the resources of important services. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the technical solutions and advantages of the embodiments of this specification or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0065] Figure 1 It is a schematic diagram of a file asynchronous downloading system provided by an embodiment of this specification;
[0066] Figure 2 It is a flowchart of a method for asynchronous file downloading provided by an embodiment of this specification;
[0067] Figure 3 It is a flowchart of a method for constructing a file storage center system according to the attribute information of the data download module and the data query interface provided in an embodiment of this specification;
[0068] Figure 4 It is a flowchart of a method for determining a business query interface in response to a data download request from an external service platform provided in an embodiment of this specification;
[0069] Figure 5 It is a flowchart of a method for calling the service query interface and querying the target service data corresponding to the data download request in the network attached storage disk provided by an embodiment of this specification;
[0070] Figure 6It is a flowchart of a method for querying the current task export status and the current export progress corresponding to the current time in the cache database provided by an embodiment of this specification;
[0071] Figure 7 It is a flowchart of a method for querying the current task export status and the current export progress corresponding to the current time in the cache database in response to a task query instruction of a target object provided by an embodiment of this specification;
[0072] Figure 8 It is a structural diagram of a file asynchronous downloading device provided in an embodiment of this specification;
[0073] Fig. 9 It is a structural diagram of a server provided in an embodiment of this specification. DETAILED DESCRIPTION
[0074] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0075] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0076] See also Figure 1 , Figure 1 is a schematic diagram of a file asynchronous download system provided by an embodiment of this specification, such as Figure 1 As shown, the file asynchronous downloading system may include at least a server 01 and a client 02 .
[0077] Specifically, in the embodiments of this specification, the server 01 may include an independently operated server, or a distributed server, or a server cluster composed of multiple servers, and may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Server 01 may include a network communication unit, a processor, a memory, and the like. Specifically, the server 01 can be used to perform deduplication processing of text.
[0078] Specifically, in the embodiments of this specification, the client 02 may include physical devices such as smart phones, desktop computers, tablet computers, laptop computers, digital assistants, smart wearable devices, smart speakers, vehicle terminals, smart TVs, etc., and may also include software running in physical devices, such as web pages provided by some service providers to users, or applications provided by these service providers to users. Specifically, the client 02 may be used to query the similarity between feedback texts online.
[0079] The following describes a method for asynchronously downloading files according to the present invention. Figure 2 It is a flowchart of a method for asynchronous file downloading provided in an embodiment of this specification. This specification provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the steps among many orders, and does not represent the only order of execution. When the actual system or server product is executed, it can be executed in sequence or in parallel (for example, in a parallel processor or multi-threaded processing environment) according to the method shown in the embodiment or the drawings. Specifically, Figure 2 As shown, the method may include:
[0080] S201: Extracting a data query component and a data export component from a preset project file.
[0081] In the embodiment of the present specification, the data query component and the data export component may be determined according to the data query function and the data export function in the preset project file.
[0082] S203: Encapsulate the data query component and the data export component to form a data download module.
[0083] In the embodiment of this specification, the data query and export functions are extracted separately from the project, encapsulated into modules, and a data download module is constructed.
[0084] S205: Abstracting the data query component into a data query interface, and compiling attribute information of the data query interface.
[0085] In the embodiments of this specification, data query can be abstracted into an interface, and a specific service implements the interface and writes its details, that is, obtains the attribute information of the data query interface.
[0086] S207: Construct a file storage center system according to the attribute information of the data download module and the data query interface and store the file in a network attached storage disk.
[0087] In the embodiments of this specification, the network attached storage disk is a NAS disk. NAS (Network Attached Storage) is a device connected to the network and has a data storage function, also known as "network storage".
[0088] Among them, technology selection and architecture design: adopt microservice architecture, use Spring Boot as the basic framework, and integrate MyBatis or JPA for data persistence operations. Use Docker container deployment to ensure the portability and scalability of services. The file export service can be configured and managed through Spring Cloud Config to achieve centralized and dynamic refresh of configuration. SpringCloudConfig provides centralized external configuration support for microservices in the microservice architecture, and the configuration server provides a centralized external configuration for all environments of different microservice applications.
[0089] In the embodiments of this specification, Figure 3 As shown, the file storage center system is constructed according to the attribute information of the data download module and the data query interface, including:
[0090] S2071: Constructing preset template engines corresponding to multiple preset file formats;
[0091] S2073: Determine preset attribute information of a preset data download module and a preset data query interface corresponding to each preset template engine according to the attribute information of the data download module and the data query interface;
[0092] S2075: Construct a file storage center system according to the preset data download module corresponding to each preset template engine and the preset attribute information of the preset data query interface.
[0093] In the embodiments of this specification, multiple preset file formats may include but are not limited to PDF, Excel, and CSV; in addition to the basic export function, a template engine (such as FreeMarker or Thymeleaf) is added to support custom style output in multiple file formats (PDF, Excel, CSV, etc.) to enhance the user experience. An asynchronous task queue (such as RabbitMQ or Kafka) is implemented to asynchronously process the export task to avoid blocking the main thread.
[0094] S209: In response to the data download request from the external service platform, determine a business query interface.
[0095] In the embodiments of this specification, Figure 4 As shown, the step of determining the business query interface in response to a data download request from an external service platform includes:
[0096] S2091: Responding to a data download request from an external service platform, obtaining a service enumeration value in the data download request;
[0097] S2093: Query the data query interface that matches the business enumeration value to obtain the business query interface.
[0098] In the embodiment of the present specification, the step of responding to a data download request from an external service platform and obtaining a service enumeration value in the data download request includes:
[0099] Get the file export task and display the download progress of the target file in the download center;
[0100] When the download progress meets a preset condition, a data download request to an external service platform is generated in response to the file download control.
[0101] In the embodiments of this specification, when the external system needs to download data, it calls the external interface provided by the asynchronous file export system through the feign method. It only needs to pass the business enumeration value written in the export system, and it will automatically find the specific business logic query interface. And through the configured paging data, it will automatically divide it into detailed pages according to the maximum amount, and write the query data page by page into the file and put it into the nas disk.
[0102] Feign client optimization: Feign client configuration supports retry mechanism and timeout processing to improve the robustness of external calls. Hystrix or Resilience4j is used to implement fuse and degradation strategies to prevent service avalanche effects. If the download progress meets the preset conditions, the download progress can reach 100%.
[0103] S2011: calling the service query interface, querying the target service data corresponding to the data download request in the network attached storage disk, and storing the target service data in a local folder.
[0104] In the embodiment of this specification, the current business system needs to be mounted on the file disk Nas, and then when the user operator clicks to download, a download task will be generated in the file download center. This task will dynamically update the download progress percentage. When it reaches 100%, a download button will be displayed. The user clicks the download button, which will be forwarded through Nginx. There is a download connection file trigger, which will directly jump to the download task of the browser and gradually download to the local file. The user can find the file in the local file and open it for access.
[0105] In the embodiments of this specification, Figure 5 As shown, calling the service query interface to query the target service data corresponding to the data download request in the network attached storage disk includes:
[0106] S20111: determining a target template engine corresponding to the target business data according to a target data format corresponding to the target business data;
[0107] S20113: Call the business query interface, query the target template engine in the network attached storage disk, and query the target business data corresponding to the data download request in the target template engine.
[0108] In the embodiment of the present specification, the calling of the service query interface to query the target service data corresponding to the data download request in the network attached storage disk includes:
[0109] Calling the business query interface, and determining target paging parameters based on the paging query function;
[0110] According to the target paging parameter, the network attached storage disk is queried for target service data corresponding to the data download request.
[0111] In the embodiments of this specification, the paging query function of Spring Data is used in combination with the custom PageHelper class to automatically calculate the paging parameters and split the query tasks according to the configured maximum data volume. Dynamic file merging technology is implemented to gradually write the paging query results into the same file to reduce file fragmentation. Intelligent scheduling and load balancing: For high-concurrency scenarios, Netflix Zuul or Spring Cloud Gateway is used as the API gateway to implement intelligent routing and load balancing of requests to ensure high availability of services.
[0112] In the embodiments of this specification, Figure 6 As shown, the method also includes:
[0113] S601: Obtaining the real-time task export status and real-time export progress of the target business data;
[0114] S603: Storing the real-time task export status and real-time export progress of the target business data in a cache database;
[0115] S605: In response to the task query instruction of the target object, query the cache database for the current task export status and current export progress corresponding to the current time.
[0116] In the embodiments of this specification, Redis or a database can be used to record the export task status and progress, and a RESTful API is provided to allow real-time query of the task status. Actuator is introduced to monitor the health status of the system, and Prometheus and Grafana are integrated to visually monitor the export service performance and resource usage.
[0117] In the embodiments of this specification, Figure 7 As shown, in response to the task query instruction of the target object, querying the current task export status and current export progress corresponding to the current time in the cache database includes:
[0118] S6051: Acquire an object authority database; the object authority database stores data access authority information corresponding to each preset object;
[0119] S6053: In response to the task query instruction of the target object, query the object permission database for a data access permission result corresponding to the target object;
[0120] S6055: If the data access permission result indicates that the target object has access permission, query the cache database for the current task export status and current export progress corresponding to the current time.
[0121] In the embodiment of the present specification, if the data access permission result indicates that the target object does not have access permission, querying the cache database for the current task export status and the current export progress corresponding to the current time is not performed.
[0122] In the embodiments of this specification, OAuth2 or JWT is implemented to authenticate API access to ensure data security. Different download permissions can be assigned according to user roles, supporting fine-grained access control, thereby improving the security of data export.
[0123] In an exemplary embodiment, a method for asynchronously downloading a file is provided, comprising:
[0124] Step 1: Build a separate file export service, including export functions, query file export progress, and file generation style;
[0125] Build a download-center system and hang the system on a NAS disk to store files. Extract the data query and export functions in the project separately, encapsulate them into modules, and abstract the data query into an interface. The specific business implements this interface and writes its details. When the external service calls the download function, it directly passes the enumeration value to trigger the specific business query interface and export the specific business data file to the NAS disk.
[0126] Technology selection and architecture design: Adopt microservice architecture, use Spring Boot as the basic framework, and integrate MyBatis or JPA for data persistence operations. Use Docker container deployment to ensure the portability and scalability of services. File export services can be configured and managed through Spring Cloud Config to achieve centralized and dynamic configuration refresh.
[0127] Enhanced file export service: In addition to basic export functions, add template engines (such as FreeMarker or Thymeleaf) to support custom style output in multiple file formats (PDF, Excel, CSV, etc.) to enhance user experience. Implement asynchronous task queues (such as RabbitMQ or Kafka) to process export tasks asynchronously to avoid blocking the main thread.
[0128] Query and progress tracking: Use Redis or database to record the export task status and progress, and provide RESTful API to allow real-time query of task status. Introduce Actuator to monitor the health status of the system, and integrate Prometheus and Grafana to visually monitor the performance and resource usage of export services.
[0129] Security and permission control: Implement OAuth2 or JWT to authenticate API access to ensure data security. Assign different download permissions based on user roles to support fine-grained access control.
[0130] Step 2: Provide a unified download interface for external systems;
[0131] When an external system needs to download data, it calls the external interface provided by the asynchronous file export system through the feign method. It only needs to pass the business enumeration value written in the export system, and it will automatically find the specific business logic query interface. And through the configured paging data, it will automatically divide it into detailed pages according to the maximum amount, and write the query data page by page into the file and put it into the nas disk.
[0132] Feign client optimization: Feign client configuration supports retry mechanism and timeout processing to improve the robustness of external calls. Hystrix or Resilience4j is used to implement circuit breaking and degradation strategies to prevent service avalanche effects.
[0133] Pagination query and automatic slicing: Use the pagination query function of Spring Data, combined with the custom PageHelper class to automatically calculate the pagination parameters, and split the query task according to the configured maximum data volume. Implement dynamic file merging technology to gradually write the pagination query results into the same file to reduce file fragmentation.
[0134] Intelligent scheduling and load balancing: For high-concurrency scenarios, use Netflix Zuul or Spring Cloud Gateway as the API gateway to implement intelligent routing and load balancing of requests to ensure high availability of services.
[0135] Step 3: Provide a query list of the file download center;
[0136] The current business system needs to be mounted on the file disk Nas. Then, when the user operator clicks to download, a download task will be generated in the file download center. This task will dynamically update the download progress percentage. When it reaches 100%, a download button will be displayed. When the user clicks the download button, it will be forwarded through Nginx. There is a download connection file trigger, which will directly jump to the download task of the browser and gradually download to the local file. The user can find the file in the local file and open it for access.
[0137] Real-time progress feedback: The front end uses WebSocket to push the download progress to the user interface in real time, providing a smoother interactive experience. The progress bar design uses CSS3 animation to enhance the visual effect.
[0138] File preview function: For files in specific formats (such as PDF, pictures), an online preview function is provided, so that the content can be viewed without downloading. This function is implemented using technologies such as PDF.js or ImageMagick.
[0139] Download acceleration and flow control: Increase download speed by configuring Nginx cache strategy and large file block transmission. Use flow limiting components (such as Sentinel or Guava RateLimiter) to prevent download peaks from impacting the system.
[0140] Logging and auditing: Implement a detailed logging mechanism, including operation logs, exception logs, and performance logs. Use ELK Stack (Elasticsearch, Logstash, Kibana) for log collection, analysis, and visualization to facilitate troubleshooting and compliance auditing.
[0141] In the embodiments of the present specification, the file asynchronous download center encapsulates the file export logic into a separate project architecture service, separates the code level from the main business service, reduces coupling and improves its independence, and abstracts the export logic at the architecture level, and writes the specific business logic by implementing the interface. At the same time, parameters such as the number of data items involved in the export, the number of files that can be downloaded at the same time, and the export file address are made configurable to increase flexibility. This greatly releases the resources of important services, decouples them from the main program, does not occupy the main program resources, and will not have any impact on the main program.
[0142] It can be seen from the technical solution provided by the above embodiments of this specification that the embodiments of this specification extract the data query component and the data export component in the preset project file; encapsulate the data query component and the data export component to form a data download module; abstract the data query component into a data query interface, and write the attribute information of the data query interface; according to the attribute information of the data download module and the data query interface, build a file storage center system and store it in a network-attached storage disk; respond to the data download request of the external service platform, determine the business query interface; call the business query interface, query the target business data corresponding to the data download request in the network-attached storage disk, and store it in a local folder. The present invention constructs a file asynchronous download center, encapsulates the export file logic into a separate project architecture service, separates the code level from the main business service, reduces coupling, and improves its independence; at the architecture level, abstracts the export logic, and the specific business logic is implemented by the interface and written by itself, which increases flexibility and greatly releases the resources of important services.
[0143] The embodiment of this specification also provides a file asynchronous download device, such as Figure 8 As shown, the device comprises:
[0144] Component extraction module 810, used to extract data query components and data export components in a preset project file;
[0145] The encapsulation module 820 is used to encapsulate the data query component and the data export component to form a data download module;
[0146] The attribute determination module 830 is used to abstract the data query component into a data query interface and write attribute information of the data query interface;
[0147] The storage module 840 is used to construct a file storage center system and store the file in a network-attached storage disk according to the attribute information of the data download module and the data query interface;
[0148] The interface determination module 850 is used to determine the business query interface in response to the data download request of the external service platform;
[0149] The file storage module 860 is used to call the business query interface, query the target business data corresponding to the data download request in the network attached storage disk, and store it in a local folder.
[0150] Optionally, the storage module includes:
[0151] A preset template building unit, used to build preset template engines corresponding to multiple preset file formats;
[0152] An attribute determination unit, used to determine preset attribute information of a preset data download module and a preset data query interface corresponding to each preset template engine according to the attribute information of the data download module and the data query interface;
[0153] The system construction unit is used to construct a file storage center system according to the preset data download module corresponding to each preset template engine and the preset attribute information of the preset data query interface.
[0154] Optionally, the file storage module includes:
[0155] A target engine determining unit, configured to determine a target template engine corresponding to the target business data according to a target data format corresponding to the target business data;
[0156] The data query unit is used to call the service query interface, query the target template engine in the network attached storage disk, and query the target service data corresponding to the data download request in the target template engine.
[0157] Optionally, the device further comprises:
[0158] A real-time data acquisition module is used to acquire the real-time task export status and real-time export progress of the target business data;
[0159] A cache module, used to store the real-time task export status and real-time export progress of the target business data in a cache database;
[0160] The current data query module is used to query the current task export status and current export progress corresponding to the current time in the cache database in response to the task query instruction of the target object.
[0161] Optionally, the current data query module is also used to obtain an object permission database; the object permission database stores data access permission information corresponding to each preset object; in response to a task query instruction of the target object, the object permission database is queried for the data access permission result corresponding to the target object; if the data access permission result indicates that the target object has access permission, the cache database is queried for the current task export status and current export progress corresponding to the current time.
[0162] Optionally, the interface determination module includes:
[0163] A service value acquisition unit, configured to respond to a data download request from an external service platform and acquire a service enumeration value in the data download request;
[0164] The interface query unit is used to query the data query interface matching the business enumeration value to obtain the business query interface.
[0165] Optionally, the business value acquisition unit is further used to acquire a file export task and display the download progress of the target file in the download center; when the download progress meets a preset condition, in response to the file download control, a data download request of the external service platform is generated;
[0166] The data query unit is further used to call the business query interface, determine the target paging parameters based on the paging query function, and query the target business data corresponding to the data download request in the network attached storage disk according to the target paging parameters.
[0167] The device and method embodiments in the described device embodiments are based on the same inventive concept.
[0168] An embodiment of the present specification provides an electronic device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the file asynchronous download method provided in the above method embodiment.
[0169] An embodiment of the present invention also provides a computer storage medium, which can be set in a terminal to store at least one instruction or at least one program related to a file asynchronous download method in a method embodiment. The at least one instruction or at least one program is loaded and executed by the processor to implement the file asynchronous download method provided by the above method embodiment.
[0170] The embodiment of the present invention also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes to implement the file asynchronous download method provided by the above method embodiment.
[0171] Optionally, in the embodiments of this specification, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
[0172] The memory described in the embodiments of this specification can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, application programs required for functions, etc.; the data storage area may store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.
[0173] The asynchronous file download method embodiment provided in the embodiments of this specification can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Taking running on a server as an example, Fig. 9 1 is a hardware structure block diagram of a server of a file asynchronous download method provided in an embodiment of this specification. Fig. 9As shown, the server 900 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 910 (the central processing unit 910 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 930 for storing data, and one or more storage media 920 (such as one or more mass storage devices) for storing application programs 923 or data 922. Among them, the memory 930 and the storage medium 920 can be short-term storage or permanent storage. The program stored in the storage medium 920 may include one or more modules, each of which may include a series of instruction operations on the server. Furthermore, the central processing unit 910 can be configured to communicate with the storage medium 920 and execute a series of instruction operations in the storage medium 920 on the server 900. The server 900 may also include one or more power supplies 960, one or more wired or wireless network interfaces 950, one or more input and output interfaces 940, and / or one or more operating systems 921, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0174] The input / output interface 940 may be used to receive or send data via a network. The specific example of the network may include a wireless network provided by a communication provider of the server 900. In one example, the input / output interface 940 includes a network adapter (Network Interface Controller, NIC), which may be connected to other network devices via a base station so as to communicate with the Internet. In one example, the input / output interface 940 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0175] It can be understood by those skilled in the art that Fig. 9 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig. 9 More or fewer components as shown, or with Fig. 9 Different configurations are shown.
[0176] It can be seen from the embodiments of the asynchronous file download method, device, electronic device or storage medium provided by the present invention that the present invention extracts the data query component and the data export component in the preset project file; encapsulates the data query component and the data export component to form a data download module; abstracts the data query component into a data query interface, and writes the attribute information of the data query interface; constructs a file storage center system and stores it in a network-attached storage disk according to the attribute information of the data download module and the data query interface; determines the business query interface in response to the data download request of the external service platform; calls the business query interface, queries the target business data corresponding to the data download request in the network-attached storage disk, and stores it in a local folder. The present invention constructs a file asynchronous download center, encapsulates the export file logic into a separate project architecture service, separates the code level from the main business service, reduces coupling, and improves its independence; at the architecture level, abstracts the export logic, and the specific business logic is implemented by the interface and written by itself, which increases flexibility and greatly releases the resources of important services.
[0177] It should be noted that the above sequence of the embodiments of this specification is for description only and does not represent the advantages and disadvantages of the embodiments. The above describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0178] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0179] A person skilled in the art will appreciate that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0180] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for asynchronous file downloading, characterized in that: The method comprises: Extract the data query component and data export component from the preset project file; Encapsulating the data query component and the data export component to form a data download module; Abstracting the data query component into a data query interface, and compiling attribute information of the data query interface; According to the attribute information of the data download module and the data query interface, a file storage center system is constructed and stored in a network attached storage disk; In response to a data download request from an external service platform, determine a business query interface; The service query interface is called to query the target service data corresponding to the data download request in the network attached storage disk, and store the data in a local folder.
2. The method according to claim 1, characterized in that The file storage center system is constructed according to the attribute information of the data download module and the data query interface, including: Build preset template engines corresponding to multiple preset file formats; Determine preset attribute information of a preset data download module and a preset data query interface corresponding to each preset template engine according to the attribute information of the data download module and the data query interface; A file storage center system is constructed according to the preset data download module corresponding to each preset template engine and the preset attribute information of the preset data query interface.
3. The method according to claim 2, characterized in that The calling of the service query interface to query the target service data corresponding to the data download request in the network attached storage disk includes: Determining a target template engine corresponding to the target business data according to a target data format corresponding to the target business data; The service query interface is called to query the target template engine in the network attached storage disk, and the target service data corresponding to the data download request is queried in the target template engine.
4. The method according to claim 1, characterized in that: The method further comprises: Obtaining the real-time task export status and real-time export progress of the target business data; Storing the real-time task export status and real-time export progress of the target business data in a cache database; In response to the task query instruction of the target object, the current task export status and the current export progress corresponding to the current time are queried in the cache database.
5. The method according to claim 4, characterized in that In response to the task query instruction of the target object, querying the cache database for the current task export status and current export progress corresponding to the current time includes: Obtaining an object permission database; the object permission database stores data access permission information corresponding to each preset object; In response to a task query instruction of a target object, querying the object permission database for a result of data access permission corresponding to the target object; If the data access permission result indicates that the target object has access permission, query the cache database for the current task export status and the current export progress corresponding to the current time.
6. The method according to claim 1, characterized in that The step of determining the service query interface in response to the data download request from the external service platform includes: In response to a data download request from an external service platform, obtaining a service enumeration value in the data download request; A data query interface matching the business enumeration value is queried to obtain a business query interface.
7. The method according to claim 6, characterized in that The step of responding to a data download request from an external service platform and obtaining a service enumeration value in the data download request includes: Get the file export task and display the download progress of the target file in the download center; When the download progress meets the preset condition, generating a data download request to the external service platform in response to the file download control; The calling of the service query interface to query the target service data corresponding to the data download request in the network attached storage disk includes: Calling the business query interface, and determining target paging parameters based on the paging query function; According to the target paging parameter, the network attached storage disk is queried for target service data corresponding to the data download request.
8. A file asynchronous downloading device, characterized in that: The device comprises: A component extraction module, used to extract data query components and data export components in a preset project file; An encapsulation module, used to encapsulate the data query component and the data export component to form a data download module; An attribute determination module, used to abstract the data query component into a data query interface and write attribute information of the data query interface; A storage module, used to construct a file storage center system and store the file in a network-attached storage disk according to the attribute information of the data download module and the data query interface; An interface determination module, used to determine a business query interface in response to a data download request from an external service platform; The file storage module is used to call the service query interface, query the target service data corresponding to the data download request in the network attached storage disk, and store it in a local folder.
9. An electronic device, characterized in that: The device comprises: a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the file asynchronous downloading method as described in any one of claims 1-7.
10. A computer storage medium, characterized in that: The computer storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the file asynchronous downloading method according to any one of claims 1-7.
