File processing method, computer device and readable storage medium

文档序号:1937221 发布日期:2021-12-07 浏览:20次 中文

阅读说明:本技术 文件处理方法、计算机装置及可读存储介质 (File processing method, computer device and readable storage medium ) 是由 王柏忠 于 2020-06-03 设计创作,主要内容包括:本发明提供一种文件处理方法,包括:实时监控第一暂存文件夹是否有存储新文件,并于监控到所述第一暂存文件夹存储了新文件时,利用预设的消息系统发布关于该新文件的消息;根据关于所述新文件的消息将所述新文件从所述第一暂存文件夹移动到第二暂存文件夹;及基于对所述新文件的处理结果将所述新文件从所述第二暂存文件夹移动到与所述新文件的处理结果所对应的目标文件夹中。本发明还提供实现所述文件处理方法的计算机装置和可读存储介质。本发明方便后期对问题文件的查找与处理。(The invention provides a file processing method, which comprises the following steps: monitoring whether a first temporary storage folder stores new files in real time, and issuing a message about the new files by using a preset message system when the first temporary storage folder is monitored to store the new files; moving the new file from the first staging folder to a second staging folder in accordance with a message regarding the new file; and moving the new file from the second temporary storage folder to a target folder corresponding to the processing result of the new file based on the processing result of the new file. The invention also provides a computer device and a readable storage medium for realizing the file processing method. The invention is convenient for searching and processing the problem file in the later period.)

1. A method of processing a document, the method comprising:

the method comprises the steps of establishing a first temporary storage folder, a second temporary storage folder and a plurality of target folders in advance, wherein the first temporary storage folder is used for storing files to be processed; the second temporary storage folder is used for storing the files being processed; the target folders are used for storing files corresponding to different processing results respectively;

monitoring whether the first temporary storage folder stores new files in real time, and issuing a message about the new files by using a preset message system when the first temporary storage folder is monitored to store the new files;

moving the new file from the first staging folder to the second staging folder in accordance with the message regarding the new file; and

and processing the new file according to a preset processing mode, and moving the new file from the second temporary storage folder to the target folder corresponding to the processing result of the new file based on the processing result of the new file.

2. The file processing method according to claim 1, wherein the processing the new file in a preset processing manner, and moving the new file from the second staging folder to the target folder corresponding to the processing result of the new file based on the processing result of the new file comprises:

judging whether the file format of the new file is a processable file format;

when the file format of the new file is not a processable file format, moving the new file from the second temporary storage folder to a first target folder in the plurality of target folders;

when the file format of the new file is a processable file format and the new file is successfully processed according to the preset processing mode, moving the new file from the second temporary storage folder to a second target folder in the plurality of target folders; and

and when the file format of the new file is a processable file format and the new file is failed to be processed according to the preset processing mode, moving the new file from the second temporary storage folder to a third target folder in the plurality of target folders.

3. The document processing method according to claim 2, characterized in that the method further comprises:

and when the new file is moved from the second temporary folder to any one of the target folders, sending a notification of the completion of the processing of the new file to the preset message system.

4. The document processing method according to claim 3, characterized in that the method further comprises:

and when the preset message system receives the notification of the completion of the processing of the new file, deleting the message of the new file from the message queue of the preset message system.

5. The file processing method of claim 4, wherein the predetermined message system is a Kafka distributed message publish and subscribe system.

6. The file processing method according to claim 5, wherein the message about the new file includes a location of the new file in the first staging folder, a file name of the new file.

7. The document processing method according to claim 6, further comprising:

when the new file is closed and needs to be opened again during the processing of the new file according to the preset processing mode: acquiring a message related to the new file from the preset message system, and acquiring the new file from the first temporary storage folder according to the position of the new file in the first temporary storage folder, wherein the position of the new file is included in the message related to the new file; and when the new file is not acquired from the first temporary storage folder, acquiring the new file from the second temporary storage folder.

8. The document processing method according to claim 7, further comprising:

when the new file is not acquired from the second temporary storage folder, determining that the new file is processed; and

when it is determined that the new file has been processed, sending the completion processing notification about the new file to the preset message system.

9. A computer-readable storage medium storing at least one instruction which, when executed by a processor, implements a file processing method according to any one of claims 1 to 8.

10. A computer arrangement comprising a memory and at least one processor, the memory having stored therein a plurality of modules, which when executed by the at least one processor implement the file processing method of any one of claims 1 to 8.

Technical Field

The present invention relates to the field of computer technologies, and in particular, to a file processing method, a computer device, and a readable storage medium.

Background

In general, in the process of processing various types of files, such as an ETL (Extract-Transform-Load) file of large data, an error or an inability to process often occurs. In the past, in the process of file recovery processing, which files are processed or processed again after the log record analysis. The process of searching for the files with problems according to the log records after the events is too tedious, and time and labor are consumed.

Disclosure of Invention

In view of the above, it is desirable to provide a file processing method, a computer device and a readable storage medium, which can distinguish the file placement positions according to the processing result of the file, and facilitate the search and processing of the problem file in the later period.

The file processing method comprises the following steps: the method comprises the steps of establishing a first temporary storage folder, a second temporary storage folder and a plurality of target folders in advance, wherein the first temporary storage folder is used for storing files to be processed; the second temporary storage folder is used for storing the files being processed; the target folders are used for storing files corresponding to different processing results respectively;

monitoring whether the first temporary storage folder stores new files in real time, and issuing a message about the new files by using a preset message system when the first temporary storage folder is monitored to store the new files;

moving the new file from the first staging folder to the second staging folder in accordance with the message regarding the new file; and

and processing the new file according to a preset processing mode, and moving the new file from the second temporary storage folder to the target folder corresponding to the processing result of the new file based on the processing result of the new file.

Preferably, the processing the new file according to a preset processing manner, and moving the new file from the second temporary storage folder to the target folder corresponding to the processing result of the new file based on the processing result of the new file includes:

judging whether the file format of the new file is a processable file format;

when the file format of the new file is not a processable file format, moving the new file from the second temporary storage folder to a first target folder in the plurality of target folders;

when the file format of the new file is a processable file format and the new file is successfully processed according to the preset processing mode, moving the new file from the second temporary storage folder to a second target folder in the plurality of target folders; and

and when the file format of the new file is a processable file format and the new file is failed to be processed according to the preset processing mode, moving the new file from the second temporary storage folder to a third target folder in the plurality of target folders.

Preferably, the method further comprises:

and when the new file is moved from the second temporary folder to any one of the target folders, sending a notification of the completion of the processing of the new file to the preset message system.

Preferably, the method further comprises:

and when the preset message system receives the notification of the completion of the processing of the new file, deleting the message of the new file from the message queue of the preset message system.

Preferably, the preset message system is a Kafka distributed message publishing and subscribing system.

Preferably, the message about the new file includes a location of the new file in the first staging folder, a file name of the new file.

Preferably, the method further comprises:

when the new file is closed and needs to be opened again during the processing of the new file according to the preset processing mode: acquiring a message related to the new file from the preset message system, and acquiring the new file from the first temporary storage folder according to the position of the new file in the first temporary storage folder, wherein the position of the new file is included in the message related to the new file; and when the new file is not acquired from the first temporary storage folder, acquiring the new file from the second temporary storage folder.

Preferably, the method further comprises:

when the new file is not acquired from the second temporary storage folder, determining that the new file is processed; and

when it is determined that the new file has been processed, sending the completion processing notification about the new file to the preset message system.

The computer-readable storage medium stores at least one instruction that, when executed by a processor, implements the file processing method.

The computer apparatus includes a memory and at least one processor, the memory having stored therein a plurality of modules that, when executed by the at least one processor, implement the file processing method.

Compared with the prior art, the file processing method, the computer device and the readable storage medium have the advantages that the file placing positions are distinguished according to the processing results of the files, and the problem files are conveniently searched and processed in the later period.

Drawings

FIG. 1 is a block diagram of a computer device according to a preferred embodiment of the present invention.

FIG. 2 is a functional block diagram of a document processing system according to a preferred embodiment of the present invention.

FIG. 3 is a flowchart of a document processing method according to a preferred embodiment of the invention.

Schematic after treatment.

Description of the main elements

Computer device 3
Processor with a memory having a plurality of memory cells 32
Memory device 31
Document processing system 30
Preset module 301
Monitoring module 302
Execution module 303

The following detailed description will further illustrate the invention in conjunction with the above-described figures.

Detailed Description

In order that the above objects, features and advantages of the present invention can be more clearly understood, a detailed description of the present invention will be given below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and features of the embodiments may be combined with each other without conflict.

In the following description, numerous specific details are set forth to provide a thorough understanding of the present invention, and the described embodiments are merely a subset of the embodiments of the present invention, rather than a complete embodiment. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used in the description of the invention herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.

Fig. 1 is a diagram illustrating an architecture of a computer device according to a preferred embodiment of the present invention.

In this embodiment, the computer device 3 comprises a memory 31, at least one processor 32, and at least one communication bus 33 electrically connected to each other.

It will be appreciated by those skilled in the art that the configuration of the computer apparatus 3 shown in fig. 1 does not constitute a limitation of the embodiments of the present invention, and that the computer apparatus 3 may also comprise more or less hardware or software than that shown in fig. 1, or a different arrangement of components.

It should be noted that the computer device 3 is only an example, and other electronic products that are currently available or may come into existence in the future, such as electronic products that can be adapted to the present invention, should also be included in the scope of the present invention, and are included herein by reference.

In some embodiments, the memory 31 may be used to store program codes of computer programs and various data. For example, the memory 31 may be used to store the file processing system 30 installed in the computer device 3 and realize high-speed and automatic access to programs or data during the operation of the computer device 3. The Memory 31 may be a non-volatile computer-readable storage medium including a Read-Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), a One-time Programmable Read-Only Memory (OTPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a Compact-Read-Only Memory (CD-ROM) or other optical disk storage, a magnetic disk storage, a tape storage, or any other non-volatile computer-readable storage medium capable of carrying or storing data.

In some embodiments, the at least one processor 32 may be comprised of an integrated circuit. For example, the integrated circuit may be formed by a single packaged integrated circuit, or may be formed by a plurality of integrated circuits packaged with the same function or different functions, and include one or more Central Processing Units (CPUs), microprocessors, digital Processing chips, graphics processors, and combinations of various control chips. The at least one processor 32 is a Control Unit (Control Unit) of the computer apparatus 3, and is connected to various components of the whole computer apparatus 3 by various interfaces and lines, and executes various functions of the computer apparatus 3 and processes data, for example, a function of processing a file, by executing a program or a module or an instruction stored in the memory 31 and calling data stored in the memory 31 (see the description of fig. 3 later).

In some embodiments, the at least one communication bus 33 is arranged to enable connectivity communication between the memory 31 and the at least one processor 32, as well as other elements.

In this embodiment, the file processing system 30 may include one or more modules, and the one or more modules are stored in the memory 31 and executed by at least one or more processors (in this embodiment, the processor 32) to implement the function of processing the file (see the description of fig. 3 later for details).

In the present embodiment, referring to fig. 2, the document processing system 30 may be divided into a plurality of functional modules according to the functions performed by the document processing system. The plurality of functional modules include a presetting module 301, a monitoring module 302 and an executing module 303. The module referred to herein is a series of computer readable instruction segments capable of being executed by at least one processor, such as processor 32, and performing a fixed function, and is stored in a memory, such as memory 31 of computer device 3. In the present embodiment, the functions of the modules will be described in detail later with reference to fig. 3.

In this embodiment, the integrated unit implemented in the form of a software functional module may be stored in a nonvolatile readable storage medium. The software functional modules include one or more computer readable instructions, and the computer device 3 or the processor (processor) implements the parts of the method of the embodiments of the present invention, such as the method of processing files shown in fig. 3, by executing the one or more computer readable instructions.

In a further embodiment, in conjunction with fig. 2, the at least one processor 32 may execute operating devices of the computer device 3 as well as installed various types of application programs (e.g., the file processing system 30), program code, and the like.

The memory 31 has program code of a computer program stored therein, and the at least one processor 32 can call the program code stored in the memory 31 to perform related functions. For example, the modules of the document processing system 30 in fig. 3 are program codes stored in the memory 31 and executed by the at least one processor 32, so as to implement the functions of the modules for the purpose of processing documents (see the description of fig. 3 below for details).

In one embodiment of the invention, the memory 31 stores one or more computer readable instructions that are executed by the at least one processor 32 for the purpose of processing files. In particular, the at least one processor 32 may implement the above-mentioned computer-readable instructions as described in detail below with reference to fig. 3.

FIG. 3 is a flowchart of a document processing method according to a preferred embodiment of the invention.

In the present embodiment, the file processing method may be applied to one or more computer devices 3, and for one or more computer devices 3 that need to perform file processing, the functions for file processing provided by the method of the present invention may be directly integrated on the one or more computer devices 3, or may be run on the one or more computer devices 3 in the form of a Software Development Kit (SDK).

As shown in fig. 3, the document processing method specifically includes the following steps, and the order of the steps in the flowchart may be changed and some steps may be omitted according to different requirements.

Step S1, the presetting module 301 pre-establishes a first temporary storage folder, a second temporary storage folder, and a plurality of target folders, wherein the first temporary storage folder is used for storing files to be processed; the second temporary storage folder is used for storing the files being processed; the target folders are used for storing files corresponding to different processing results respectively.

In this embodiment, the plurality of target folders includes a first target folder, a second target folder, and a third target folder.

The first target folder is used for storing files with file formats which are not supported, namely files which cannot be opened.

The second target folder is used for storing the successfully processed files, for example, the files processed in a preset processing mode.

The third target folder is used for storing files which fail to be processed, such as files with errors in the processing process.

Step S2, the monitoring module 302 monitors whether the first temporary storage folder stores a new file in real time, and issues a message about the new file by using a preset message system when it is monitored that the first temporary storage folder stores the new file.

In this embodiment, the new file may be defined as a file newly stored in the first temporary storage folder.

Specifically, the monitoring module 302 may identify whether a new file is stored in the first temporary folder by monitoring parameters such as a file name, a modification date of a file type file, and/or a file size.

In one embodiment, the predetermined message system is a Kafka distributed message publishing and subscribing system.

In one embodiment, the message regarding the new file includes a location of the new file in the first staging folder, a file name of the new file, and the like.

Specifically, the monitoring module 302 controls the preset message system to add the message related to the new file to a message queue of the preset message system.

In step S3, the executing module 303 receives the message about the new file, and moves the new file from the first temporary folder to the second temporary folder according to the message about the new file.

Specifically, the execution module 303 moves the new file from the first staging folder to the second staging folder according to the location of the new file in the first staging folder included in the message regarding the new file.

In this embodiment, "move" described above and below refers to a change in position. If the new file is moved from the first staging folder to the second staging folder, the location of the new file is changed from the first staging folder to the second staging folder.

Step S4, the executing module 303 processes the new file according to a preset processing manner, and moves the new file from the second temporary storage folder to the target folder corresponding to the processing result of the new file based on the processing result of the new file.

In one embodiment, the predetermined processing manner includes, but is not limited to, copying data in the new file, deleting duplicate data from the new file, and the like.

In one embodiment, the processing the new file according to the preset processing manner, and moving the new file from the second temporary folder to the target folder corresponding to the processing result of the new file based on the processing result of the new file comprises (a1) - (a 4):

(a1) and judging whether the file format of the new file is a processable/supportable file format.

In this embodiment, it is determined whether the file format of the new file is a processable/supportable file format, that is, whether the new file can be opened by the executing module 303.

Specifically, the executing module 303 may determine whether the file format of the new file is one of preset formats (e.g., doc format,. xls format, tif format); if the file format of the new file is one of the preset formats, the executing module 303 determines that the file format of the new file is a processable/supportable file format; if the file format of the new file is not any of the preset formats, the executing module 303 determines that the file format of the new file is not a processable/supportable file format.

(a2) When the file format of the new file is not a processable/supportable file format, moving the new file from the second staging folder to a first target folder of the plurality of target folders. That is, the first target folder may be used to store a file whose file format is not processable/supportable, in other words, the storage result corresponding to the first target folder is "the file whose file format is not processable/supportable.

(a3) And when the file format of the new file is a processable file format and the new file is successfully processed according to the preset processing mode (for example, when the new file is successfully copied to the required data), moving the new file from the second temporary storage folder to the second target folder in the plurality of target folders.

(a4) And when the file format of the new file is a processable file format and the new file is processed in a failure mode according to the preset processing mode (for example, when an error occurs in the processing process and the new file cannot be processed successfully), moving the new file from the second temporary storage folder to the third target folder in the plurality of target folders.

It should be noted that, in this embodiment, when the new file is moved from the second temporary storage folder to any one of the target folders, the new file is no longer stored in the second temporary storage file.

In an embodiment, after the executing module 303 moves the new file from the second temporary folder to any one of the target folders, the executing module 303 further sends a completion processing notification about the new file to the preset message system to notify the preset message system that the new file has been processed.

In one embodiment, when the preset message system receives the notification of the completion processing of the new file, the message related to the new file is deleted from the message queue of the preset message system.

In an embodiment, when the executing module 303 processes the new file according to the preset processing manner, when the new file is closed and needs to be opened again: the executing module 303 retrieves the message about the new file from the preset message system, and acquires the new file from the first temporary storage folder according to the position of the new file in the first temporary storage folder included in the message about the new file; when the execution module 303 does not obtain the new file from the first temporary storage folder, the execution module 303 obtains the new file from the second temporary storage folder.

In one embodiment, when the execution module 303 does not obtain the new file from the second temporary folder, the execution module 303 determines that the new file has been processed. When it is determined that the new file has been processed, the execution module 303 sends the completion processing notification about the new file to the preset message system. And deleting the message related to the new file from the message queue of the preset message system when the preset message system receives the notification of the completion processing related to the new file.

In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.

The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.

In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.

It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is obvious that the word "comprising" does not exclude other elements or that the singular does not exclude the plural. A plurality of units or means recited in the apparatus claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.

Finally, it should be noted that the above embodiments are only used for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the above preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions can be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

12页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:跨应用图片展示方法、装置、存储介质及终端

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!