Disclosure of Invention
To overcome the foregoing technical problems, embodiments of the present invention provide a file processing method and apparatus.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, a file processing method provided in an embodiment of the present invention includes: downloading a file to be processed from an FTP server which performs file interaction with a third party; carrying out format conversion on the file to be processed to obtain a target processing file; executing corresponding operation according to the file type of the target processing file to obtain a processing result file; and uploading the processing result file to the FTP server.
With reference to the first aspect, an embodiment of the present invention provides a first possible implementation manner of the first aspect, where uploading the processing result file to the FTP server includes: converting the format of the processing result file into a file format corresponding to the FTP server; and uploading the processing result file subjected to format conversion to the FTP server.
With reference to the first aspect, an embodiment of the present invention provides a second possible implementation manner of the first aspect, where the executing a corresponding operation according to a file type of the target processing file to obtain a processing result file includes: acquiring identification information of the target processing file; determining the file type of the target processing file according to the identification information; and executing the operation matched with the file type to obtain a processing result file.
With reference to the first aspect, an embodiment of the present invention provides a third possible implementation manner of the first aspect, where uploading the processing result file to the FTP server includes: determining whether the processing result file needs to be uploaded or not according to the file type; and if so, uploading the processing result file to the FTP server.
With reference to the first aspect, an embodiment of the present invention provides a fourth possible implementation manner of the first aspect, where downloading a file to be processed from an FTP server that performs file interaction with a third party includes: acquiring an IP address of the FTP server for performing file interaction with the third party; and accessing the FTP server according to the IP address, and downloading a file to be processed from the FTP server.
In a second aspect, an embodiment of the present invention provides a file processing apparatus, including: the download unit is used for downloading the file to be processed from the FTP server which performs file interaction with a third party; the format conversion unit is used for carrying out format conversion on the file to be processed to obtain a target processing file; the processing unit is used for executing corresponding operation according to the file type of the target processing file to obtain a processing result file; and the uploading unit is used for uploading the processing result file to the FTP server.
With reference to the second aspect, an embodiment of the present invention provides a first possible implementation manner of the second aspect, where the uploading unit is further configured to: converting the format of the processing result file into a file format corresponding to the FTP server; and uploading the processing result file subjected to format conversion to the FTP server.
With reference to the second aspect, an embodiment of the present invention provides a second possible implementation manner of the second aspect, where the processing unit is further configured to: acquiring identification information of the target processing file; determining the file type of the target processing file according to the identification information; and executing the operation matched with the file type to obtain a processing result file.
With reference to the second aspect, an embodiment of the present invention provides a third possible implementation manner of the second aspect, where the uploading unit is further configured to: determining whether the processing result file needs to be uploaded or not according to the file type; and if so, uploading the processing result file to the FTP server.
With reference to the second aspect, an embodiment of the present invention provides a fourth possible implementation manner of the second aspect, where the downloading unit is further configured to: acquiring an IP address of the FTP server for performing file interaction with the third party; and accessing the FTP server according to the IP address, and downloading a file to be processed from the FTP server.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
according to the file processing method and device provided by the embodiment of the invention, the file to be processed is downloaded from the FTP server which performs file interaction with a third party; carrying out format conversion on the file to be processed to obtain a target processing file; executing corresponding operation according to the file type of the target processing file to obtain a processing result file; and uploading the processing result file to the FTP server. Therefore, the recognition rate can be effectively improved, and the processing speed is further increased. And the third party can quickly identify the file content through the file format set by the third party, so that the identification time of the third party on the file content is effectively reduced, and the probability of false identification is reduced.
In order to make the aforementioned and other objects, features and advantages of the present invention comprehensible, preferred embodiments accompanied with figures are described in detail below.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. 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. Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. 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.
First embodiment
Please refer to fig. 1, which is a flowchart illustrating a file processing method according to a first embodiment of the present invention. The specific process shown in FIG. 1 will be described in detail below.
And step S101, downloading the file to be processed from the FTP server which performs file interaction with the third party.
The File to be processed is a File which is uploaded to an FTP (File Transfer Protocol) server in advance by a third party.
The third party may be a plurality of parties.
Optionally, the file to be processed may be a file provided by a third party and used for entrusting and deducting fees of each province of high-speed traffic in the transportation industry, and may also be a file for other purposes, such as a file for performing reconciliation processing, or a file for performing information aggregation, and the like, which is not limited specifically herein.
As an embodiment, step S101 includes: acquiring an IP (Internet Protocol) address of the FTP server for performing file interaction with the third party; and accessing the FTP server according to the IP address, and downloading a file to be processed from the FTP server.
Alternatively, the IP address may be pre-stored in a local database, stored on a server, or input by the user in real time (for example, the IP address input by the user in a web page through an input device such as a keyboard).
As another embodiment, the execution is initiated based on the crontab timing service, the IP address of the FTP server performing file interaction with the third party is obtained, the FTP server is accessed according to the IP address, and the file to be processed is downloaded from the FTP server. And downloading the files to be processed from the FTP server through a unified FTP server management inlet.
And step S102, carrying out format conversion on the file to be processed to obtain a target processing file.
In this embodiment, the initial format of the file to be processed is a file format configured by a third party, that is, a file format set by the third party according to the requirement of the third party.
Optionally, the file format is a format of file content. For example, in a third party's pending document, the different fields are distinguished by '/' or by spaces.
As an embodiment, step S102 includes: and carrying out format conversion on the file to be processed according to a local preset file format to obtain a target processing file.
The file format of the third-party file to be processed is converted into the local format, so that the target processing file can be rapidly processed conveniently, and the processing accuracy is improved. For example, when there are files to be processed provided by a plurality of different third parties, the files to be processed may be caused due to different providers (i.e., the third parties). Therefore, the file to be processed is processed on the basis of the local file format by converting the format into the local file format, so that the files to be processed provided by different providers can be effectively and quickly processed.
For example, if the document to be processed provided by the third party a has many characters with different meanings, and the document to be processed provided by the third party B also has some non-universal characters, the document to be processed provided by the third party a and the third party B is converted into a universal document format by format conversion, so that the recognition rate can be effectively improved, and the processing speed can be further increased.
In an optional embodiment, after step S102, the method further includes: and pushing the target processing file to a queue to be processed.
By using the queue to carry out multi-process asynchronous operation, the processing efficiency can be effectively improved. And asynchronous calling is carried out by using the queue, and each step of operation is decoupled, so that the subsequent transverse expansion can be carried out more conveniently, and more third parties are added.
Step S103, executing corresponding operation according to the file type of the target processing file to obtain a processing result file.
In the embodiment, operations for different file types are configured in advance, for example, a fee deduction operation is performed on the vehicle traffic flow file after downloading; or the account checking file executes the account checking program after being downloaded.
As an embodiment, step S103 includes: determining the file type of the target processing file according to the identification information; and executing the operation matched with the file type to obtain a processing result file.
Alternatively, the identification information may be a file name.
Of course, in actual use, the identification information may also be generated by other means. For example, the file name is processed by a hash algorithm to obtain the identification information.
For example, after the XX1 province and the XX2 province respectively provide the files to be processed for the high-speed passage entrusted fee deduction processing, the files to be processed provided by each third party are continuously acquired from the queue (namely, the files to be processed in XX1 province and XX2 province are sequentially acquired in the form of the queue), so that the file contents are read, entrusted fee deduction operation is carried out, a processing result file is obtained, and the processing result file is stored locally.
And step S104, uploading the processing result file to the FTP server.
As an embodiment, step S104 includes: converting the format of the processing result file into a file format corresponding to the FTP server, for example, converting the format into a file format required by a third party; and uploading the processing result file subjected to format conversion to the FTP server.
For example, assuming that the file format required by the third party is a, the format of the processing result file is converted into a.
As another embodiment, step S104 includes: uploading the processing result file to a processing result database in the FTP server; checking the processing result file to obtain a second processing result file; converting the format of the second processing result file into a file format corresponding to the FTP server; and uploading the second processing result file subjected to format conversion to the FTP server.
Optionally, performing a verification process on the processing result file to obtain a second processing result file, including: and processing the processing result file according to a settlement protocol to obtain a second processing result file, and storing the second processing result file to the local.
Optionally, the settlement agreement is pre-set by a third party.
Continuing with the above example, after the fee deduction operation, the processing result file is processed according to the settlement agreement, such as fee deduction result processing in the settlement period, blacklist data generated by fee deduction failure, and the like. And storing the obtained second processing result file to the local. Converting the second processing result file into a file format corresponding to the FTP server through format conversion; and uploading the second processing result file subjected to format conversion to the FTP server. Therefore, the third party can rapidly identify the file content through the file format set by the third party, and the identification time of the third party on the file content is effectively reduced, and the probability of false identification is reduced. For example, the second processing result file is uploaded directly to the FTP server, but it is likely that the third party does not know at all what each field in the second processing result file expresses, but only what statistics it needs to be in the file at the time of its initiation.
In this embodiment, by using the file processing method provided by this embodiment, when a third-party object is newly added, the subsequent workload and the possibility of error are greatly reduced.
According to the file processing method provided by the embodiment of the invention, the file to be processed is downloaded from the FTP server which performs file interaction with a third party; carrying out format conversion on the file to be processed to obtain a target processing file; executing corresponding operation according to the file type of the target processing file to obtain a processing result file; and uploading the processing result file to the FTP server. Therefore, the recognition rate can be effectively improved, and the processing speed is further increased. And the third party can quickly identify the file content through the file format set by the third party, so that the identification time of the third party on the file content is effectively reduced, and the probability of false identification is reduced.
Second embodiment
Fig. 2 shows a one-to-one correspondence document processing apparatus that employs the document processing method shown in the first embodiment, corresponding to the document processing method in the first embodiment. As shown in fig. 2, the file processing apparatus 400 includes a downloading unit 410, a format converting unit 420, a processing unit 430, and an uploading unit 440. The implementation functions of the image acquisition module 410, the file processing module 420, the correction module 430, the posture adjustment module 440, and the execution module 450 correspond to the corresponding steps in the first embodiment one to one, and for avoiding redundancy, detailed descriptions are not needed in this embodiment.
And the downloading unit 410 is used for downloading the file to be processed from the FTP server performing file interaction with the third party.
Optionally, the downloading unit 410 is further configured to: acquiring an IP address of the FTP server for performing file interaction with the third party; and accessing the FTP server according to the IP address, and downloading a file to be processed from the FTP server.
And the format conversion unit 420 is configured to perform format conversion on the file to be processed to obtain a target processing file.
The processing unit 430 is configured to execute a corresponding operation according to the file type of the target processing file, so as to obtain a processing result file.
Optionally, the processing unit 430 is further configured to: acquiring identification information of the target processing file; determining the file type of the target processing file according to the identification information; and executing the operation matched with the file type to obtain a processing result file.
An uploading unit 440, configured to upload the processing result file to the FTP server.
Optionally, the uploading unit 440 is further configured to: converting the format of the processing result file into a file format corresponding to the FTP server; and uploading the processing result file subjected to format conversion to the FTP server.
Optionally, the uploading unit 440 is further configured to: determining whether the processing result file needs to be uploaded or not according to the file type; and if so, uploading the processing result file to the FTP server.
In this embodiment, through the unified and standardized processing flow and the modularized architecture of the file processing method provided by the present application, a new partner (third party) can access the file processing apparatus 400 provided by the present application in a plug-in manner. And are highly decoupled through individual modules/units so that each unit function can be maintained separately.
Third embodiment
As shown in fig. 3, is a schematic diagram of an electronic device 300. The electronic device 300 includes a memory 302, a processor 304, and a computer program 303 stored in the memory 302 and capable of running on the processor 304, wherein the computer program 303 implements the file processing method in the first embodiment when executed by the processor 304, and is not described herein again to avoid repetition. Alternatively, the computer program 303 is implemented by the processor 304 to implement the functions of the modules/units in the file processing apparatus according to the second embodiment, and is not described herein again to avoid repetition.
Illustratively, the computer program 303 may be partitioned into one or more modules/units, which are stored in the memory 302 and executed by the processor 304 to implement the present invention. One or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 303 in the electronic device 300. For example, the computer program 303 may be divided into the image capturing module 410, the file processing module 420, the correcting module 430, the posture adjusting module 440 and the executing module 450 in the second embodiment, and specific functions of each unit are as described in the first embodiment or the second embodiment, which are not described herein again.
The electronic device 300 may be a desktop computer, a notebook, a palmtop, or a smart phone.
The Memory 302 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like. The memory 302 is used for storing a program, and the processor 304 executes the program after receiving an execution instruction, and the method defined by the flow disclosed in any of the foregoing embodiments of the present invention may be applied to the processor 304, or implemented by the processor 304.
The processor 304 may be an integrated circuit chip having signal processing capabilities. The Processor 304 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It is understood that the configuration shown in fig. 3 is only a schematic configuration of the electronic device 300, and the electronic device 300 may further include more or less components than those shown in fig. 3. The components shown in fig. 3 may be implemented in hardware, software, or a combination thereof.
Fourth embodiment
An embodiment of the present invention further provides a storage medium, where the storage medium stores instructions, and when the instructions run on a computer, when the computer program is executed by a processor, the file processing method in the first embodiment is implemented, and details are not repeated here to avoid repetition. Alternatively, the computer program is executed by a processor to implement the functions of the modules/units in the file processing apparatus according to the second embodiment, and details are not repeated here to avoid repetition.
From the above description of the embodiments, it is clear to those skilled in the art that the present invention can be implemented by hardware, or by software plus a necessary general hardware platform, and based on such understanding, the technical solution of the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute the method of the various implementation scenarios of the present invention.
In summary, according to the file processing method and device provided by the present invention, the file to be processed is downloaded from the FTP server performing file interaction with the third party; carrying out format conversion on the file to be processed to obtain a target processing file; executing corresponding operation according to the file type of the target processing file to obtain a processing result file; and uploading the processing result file to the FTP server. Therefore, the recognition rate can be effectively improved, and the processing speed is further increased. And the third party can quickly identify the file content through the file format set by the third party, so that the identification time of the third party on the file content is effectively reduced, and the probability of false identification is reduced.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.