CN113806312A - File processing method and device, electronic equipment and storage medium - Google Patents

File processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113806312A
CN113806312A CN202111141662.7A CN202111141662A CN113806312A CN 113806312 A CN113806312 A CN 113806312A CN 202111141662 A CN202111141662 A CN 202111141662A CN 113806312 A CN113806312 A CN 113806312A
Authority
CN
China
Prior art keywords
file
processed
processing
service
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111141662.7A
Other languages
Chinese (zh)
Inventor
李建胜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Tuoxian Technology Co Ltd
Original Assignee
Beijing Jingdong Tuoxian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Tuoxian Technology Co Ltd filed Critical Beijing Jingdong Tuoxian Technology Co Ltd
Priority to CN202111141662.7A priority Critical patent/CN113806312A/en
Publication of CN113806312A publication Critical patent/CN113806312A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/14Details of searching files based on file metadata
    • G06F16/148File search processing

Abstract

The invention discloses a file processing method, a file processing device, electronic equipment and a storage medium, and relates to the technical field of computers. One embodiment of the method comprises: acquiring a downloaded file, triggering a write-in transaction to write file information into a file download record table, and marking a service state corresponding to the downloaded file in the file download record table as pending; inquiring the file to be processed with the service state as the file to be processed, triggering a service processing transaction to execute service processing on the file to be processed, and updating the service state of the file to be processed into the processing; and inquiring the service state of the file to be uploaded in the process, triggering an uploading transaction to generate and upload a result file, and updating the service state of the file to be uploaded into the process success. The method and the device can solve the problems that after the processing of the file is interrupted, the processing progress of each data in the file needs to be judged in sequence, the file can be processed continuously, the operation is complex, and the file processing efficiency is reduced.

Description

File processing method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a file processing method and apparatus, an electronic device, and a storage medium.
Background
In the service processing, in order to reduce the number of data transmission between systems, data transmission may be performed by way of file transmission, and each file may include multiple pieces of data. In the prior art, after receiving a file, a system needs to perform corresponding service processing on data in the file, store a processing result, and return a result file to an opposite end. However, after the system interrupts processing the file due to a failure or the like, if the system needs to continue processing the file, the processing progress of each data in the file needs to be sequentially judged according to the file processing procedure, and then the file can be continuously processed.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for processing a file, an electronic device, and a storage medium, which can solve the problem that after the processing of the file is interrupted, the processing progress of each data in the file needs to be sequentially determined to continue processing the file, so that not only the operation is complex, but also the file processing efficiency is reduced.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a method of file processing.
The file processing method of the embodiment of the invention comprises the following steps: acquiring a downloaded file, triggering a write-in transaction to acquire file information of the downloaded file, writing the file information into a file download record table, and marking a service state corresponding to the downloaded file in the file download record table as pending; inquiring the file to be processed with the service state in the file downloading record table, triggering a service processing transaction to execute service processing on the file to be processed, and updating the service state of the file to be processed into processing; and inquiring the service state of the file downloading record table as the processed file to be uploaded, triggering an uploading transaction to obtain a service processing result corresponding to the file to be uploaded, further generating and uploading a result file, and updating the service state of the file to be uploaded into a processing success state.
In an embodiment, before querying the pending file whose service status is pending in the file download record table, the method further includes:
and writing each row of data in the downloaded file into a file row record list, and marking the service state corresponding to each row of data as pending in the file row record list.
In another embodiment, the triggering a service processing transaction to execute service processing on a file to be processed and update a service state of the file to be processed into a processing state includes:
inquiring whether the file row record list comprises to-be-processed row data which belong to the to-be-processed file and have a service state to be processed;
if not, updating the service state corresponding to the file to be processed in the file downloading record table to be processed; and if so, reading the data of the to-be-processed row in the file row record list, triggering a service processing transaction for each data of the to-be-processed row to execute corresponding service processing, and updating a service state corresponding to the data of the to-be-processed row based on a service processing result.
In another embodiment, the executing the service processing and updating the service state corresponding to the data to be processed based on the service processing result includes:
calling a preset verification model, and performing data verification on the to-be-processed line data to obtain a verification result;
if the verification result is qualified, performing service processing on the to-be-processed row data to obtain a service processing result, and updating the service state corresponding to the to-be-processed row data to be successful when the processing result is successful; and if the verification result is unqualified, determining that the service processing result of the to-be-processed line data is failed, and updating the service state corresponding to the to-be-processed line data into failure.
In yet another embodiment, the file information includes a service type;
triggering a service processing transaction for each row of data to be processed, comprising:
and inquiring the service type of the file to be processed from the file downloading record table to trigger a service processing transaction corresponding to the service type for each line of data to be processed.
In another embodiment, writing each line of data in the downloaded file into a file line record list includes:
acquiring the quantity of the line data in the downloaded file, calculating the splitting batch of the line data based on the single writing quantity, further splitting the line data to obtain a splitting result, and writing the line data into a file line record list based on the splitting result.
In yet another embodiment, the triggering a write transaction includes:
calculating a check mark of the downloaded file based on the downloaded file including data to judge whether the file download record table includes the check mark;
if yes, ignoring the downloaded file; if not, triggering a corresponding write-in transaction for the downloaded file.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an apparatus for file processing.
The file processing device of the embodiment of the invention comprises: the writing unit is used for acquiring the downloaded file, triggering a writing transaction to acquire file information of the downloaded file, writing the file information into a file downloading record table, and marking the service state corresponding to the downloaded file in the file downloading record table as pending; the processing unit is used for inquiring the file to be processed with the service state to be processed in the file downloading record table, triggering a service processing transaction so as to execute service processing on the file to be processed, and updating the service state of the file to be processed into the processing; and the uploading unit is used for inquiring the service state of the file to be uploaded in the processing in the file downloading record table, triggering an uploading transaction to obtain a service processing result corresponding to the file to be uploaded, further generating and uploading a result file, and updating the service state of the file to be uploaded into a processing success state.
In one embodiment, the writing unit is further configured to:
and writing each row of data in the downloaded file into a file row record list, and marking the service state corresponding to each row of data as pending in the file row record list.
In another embodiment, the processing unit is specifically configured to:
inquiring whether the file row record list comprises to-be-processed row data which belong to the to-be-processed file and have a service state to be processed;
if not, updating the service state corresponding to the file to be processed in the file downloading record table to be processed; and if so, reading the data of the to-be-processed row in the file row record list, triggering a service processing transaction for each data of the to-be-processed row to execute corresponding service processing, and updating a service state corresponding to the data of the to-be-processed row based on a service processing result.
In another embodiment, the processing unit is specifically configured to:
calling a preset verification model, and performing data verification on the to-be-processed line data to obtain a verification result;
if the verification result is qualified, performing service processing on the to-be-processed row data to obtain a service processing result, and updating the service state corresponding to the to-be-processed row data to be successful when the processing result is successful; and if the verification result is unqualified, determining that the service processing result of the to-be-processed line data is failed, and updating the service state corresponding to the to-be-processed line data into failure.
In yet another embodiment, the file information includes a service type;
the processing unit is specifically configured to:
and inquiring the service type of the file to be processed from the file downloading record table to trigger a service processing transaction corresponding to the service type for each line of data to be processed.
In another embodiment, the writing unit is specifically configured to:
acquiring the quantity of the line data in the downloaded file, calculating the splitting batch of the line data based on the single writing quantity, further splitting the line data to obtain a splitting result, and writing the line data into a file line record list based on the splitting result.
In another embodiment, the writing unit is specifically configured to:
calculating a check mark of the downloaded file based on the downloaded file including data to judge whether the file download record table includes the check mark;
if yes, ignoring the downloaded file; if not, triggering a corresponding write-in transaction for the downloaded file.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided an electronic apparatus.
An electronic device of an embodiment of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the file processing method provided by the embodiment of the invention.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention stores thereon a computer program, which, when executed by a processor, implements a method of file processing provided by an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: in the embodiment of the invention, for the downloaded file, a write-in transaction can be triggered, file information of the downloaded file is written into a file download record table, and a corresponding service state is marked to be processed so as to wait for the flow of service processing; for the file to be processed with the service state to be processed in the file downloading record table, triggering the service processing transaction to execute the corresponding service processing, and updating the service state to be processed to wait for the process of uploading the result; for the file to be uploaded in the file downloading record table with the service state being processing, the process of uploading the service result corresponding to the execution of the uploading transaction can be triggered. In the embodiment of the invention, the processing process of the file is properly split, each split part is processed in a transaction triggering mode, and the execution of each transaction is independent, so that when the file is processed, even if the file processing is interrupted, the processing progress of the file can be directly determined based on the execution condition of the corresponding transaction, and the unprocessed file is continuously processed based on the triggering of the transaction again without sequentially judging the processing progress of each data in the file, therefore, the operation is simple, and the file processing efficiency can be improved.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of one principal flow of a method of document processing according to an embodiment of the present invention;
FIG. 2 is a diagram of a file download record table according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a file row record list according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a file upload schedule according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a main flow of a method of file writing according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a main flow of a method of file transaction processing according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a main flow of a method for uploading a result file according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of the main elements of an apparatus for document processing according to an embodiment of the present invention;
FIG. 9 is a diagram of yet another exemplary system architecture to which embodiments of the present invention may be applied;
FIG. 10 is a schematic block diagram of a computer system suitable for use in implementing embodiments of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict.
The embodiment of the invention provides a file processing system which can be used for carrying out data transmission based on files and processing the files, for example, taking data transmission between the file processing system and a certain bank system and handling point business as an example. The bank system can transmit the user data added with the points to the business processing system through ftp, and after the business processing of adding the points is completed by the file processing system, the result file is uploaded to the ftp and returned to the bank system.
Specifically, the file processing system splits the processing flow of the file into three parts, which are respectively file writing, service processing and result uploading, and sets corresponding transactions for each part, namely writing transactions, service processing transactions and uploading transactions, and can complete the processing of the file by executing the corresponding transactions.
An embodiment of the present invention provides a method for processing a file, where the method may be performed by a file processing system, as shown in fig. 1, and the method includes:
s101: acquiring a downloaded file, triggering a write-in transaction to acquire file information of the downloaded file, writing the file information into a file download record table, and marking a service state corresponding to the downloaded file in the file download record table as pending.
Among them, the systems usually pre-agree on the file storage location, such as the file storage server, which may be ftp specifically. The system sending the file may store the file to an agreed storage location, from which the file processing system may download the file. After the file is downloaded, a temporary file, i.e. a downloaded file, may be generated, and the file processing system may obtain the downloaded file and then trigger a write transaction for it. The write-in transaction is used for executing a process of writing a file into a file downloading record table, the write-in transaction can acquire an identifier of a downloaded file when triggered, and further can acquire file information of the downloaded file based on the identifier, then write the file information into the file downloading record table for storage, and simultaneously mark the service state of the file to be downloaded as to-be-processed, the to-be-processed indicates that the file can execute the next processing, and the write-in transaction can execute transaction submission after execution. The transaction submission success indicates that the file to be downloaded is successfully written, the transaction submission failure indicates that the file to be downloaded is unsuccessfully written, and at this time, the transaction can be rolled back, namely, the write transaction is executed on the downloaded file again.
The file information of the file may be included in the file download record table, for example, the file name, the download batch identifier, the download time, the service status, and the like may be included. Specifically, as shown in fig. 2, a schematic diagram of a file download record table is shown.
In the embodiment of the present invention, in order to avoid performing repeated writing operations on the same file, the file download record table may further store a check identifier of each file, where the check identifier may be calculated based on data included in the file. Before triggering a write transaction for the downloaded file in this step, the check identifier of the downloaded file may be calculated based on the data included in the downloaded file, so as to determine whether the file download record table includes the check identifier of the downloaded file. If yes, the file information of the downloaded file is written into the file downloading record table, and the downloaded file can be ignored; if not, the file information of the downloaded file is not yet written in the file downloading record table, and then a corresponding writing transaction can be triggered for the downloaded file.
It should be noted that the file downloading record table may further store the service type of the file, so as to perform service processing on the file subsequently. In the embodiment of the invention, on one hand, the service type can be stored through the service type field, and the file usually comprises the service type corresponding to the file, so that the file is only required to be stored in the corresponding field in the file downloading record table; on the other hand, the service type may be represented by a file name, and at this time, the file download record table only needs to store the file name, for example, if the service type is a calculation score, the file name may be jifen _123, and if the service type is registration, the file name may be zhuce _ 123.
In the embodiment of the present invention, each file generally includes a plurality of pieces of data, the data may be stored in a data table, and each row of data in the data table may be regarded as a row of data. During file processing, corresponding business processing needs to be performed on each line of data. In order to facilitate service processing, in the embodiment of the present invention, a file row record list may be further set, where the file row record list is used to store data information of each row of data in a downloaded file, so that after the write-in transaction is triggered in this step, the step of writing each row of data in the downloaded file into the file row record list for storage and marking a service state corresponding to each row of data in the file row record list as a pending state may also be performed. The file line record list may include a file name or a file identifier of a file to which the line data belongs, a line identifier of the line data, a service state of the line data, and the like, where the service state of the line data is to be processed and indicates that it can execute a service process. Fig. 3 is a schematic diagram of a file row record list.
When a file includes a large amount of line data, the line data is usually written into the file line record list in batches. Specifically, in the embodiment of the present invention, the number of line data written in each time, that is, the number of single writing operations, may be preset, the number of line data included in the downloaded file is then obtained, a split batch of line data in the downloaded file may be calculated based on the number of single writing operations, the line data is split to obtain a split result, and finally, the line data is written in the file line record list based on the split result and is stored. For example, if the number of line data is 1 ten thousand and the number of single writes is 1000, the line data may be split into 10 batches to be written into the file line record list.
S102: and inquiring the file to be processed in the file downloading record table, wherein the service state of the file to be processed is the file to be processed, triggering a service processing transaction to execute service processing on the file to be processed, and updating the service state of the file to be processed into the processing.
When the downloaded file is written into the file download record table, the service state is marked as pending to indicate that the service processing needs to be executed, so that the service state in the file download record table can be inquired as the pending file, that is, the pending file, to execute the service processing. After the file to be processed is inquired, a business processing transaction can be triggered, after the business processing transaction is triggered, corresponding business processing can be executed, a processing result is obtained, the business state of the file to be processed is updated to be in processing, and the fact that subsequent processing flows can be executed is shown.
In the embodiment of the present invention, since the file includes a plurality of line data, each line data is required to perform service processing, and the service state can be updated only after the processing result is obtained, the execution process of triggering the service processing transaction in this step may specifically be: inquiring whether the file row record list comprises to-be-processed row data which belong to the to-be-processed file and have a service state to be processed; if not, updating the service state corresponding to the file to be processed in the file downloading record table to be processed; and if so, reading the data of the to-be-processed data in the file row record list, triggering a business processing transaction for each data of the to-be-processed data to execute corresponding business processing, and updating the business state corresponding to the data of the to-be-processed data based on a business processing result.
After the file to be processed is inquired, whether the file to be processed includes the row data with the service state to be processed or not can be inquired from the file row record detail table, that is, whether the file row record detail table includes the row data with the service state to be processed and belonging to the file to be processed or not can be inquired. If not, the line data in the file to be processed is all processed by the service, that is, the file to be processed is already processed, at this time, the service state corresponding to the file to be processed in the file downloading record table can be updated to be in the process, which indicates that the file to be processed can execute the subsequent result uploading process; if yes, indicating that row data in the file to be processed is not processed by the service, reading the row data to be processed in the file row record detail table, and triggering a corresponding service processing transaction for each row data to be processed, namely triggering an independent service processing transaction for each row data to execute corresponding service processing, and further updating a service state corresponding to the row data to be processed based on a service processing result.
Since the service types corresponding to the files are different, the service processing transactions for processing the line data in the files are also the same, so in the embodiment of the present invention, when the service processing transactions are triggered for the line data, the service type needs to be determined first, and specifically, the following can be implemented: and inquiring the service type of the file to be processed from the file downloading record table to trigger the service processing transaction corresponding to the service type for each line of data to be processed. After the business processing transaction is triggered, the data information of the corresponding row of data can be acquired, and then business processing can be executed, so that a processing result is obtained. When the business processing of the row data to be processed is successful, after the processing result is stored, the business state of the row data to be processed in the file row record list can be updated to be successful, and the transaction is submitted; when the service processing of the data to be processed is unsuccessful, the data to be processed needs to be re-processed, namely, the transaction is rolled back, and at the moment, the service state of the data to be processed in the file line record list does not need to be updated.
It should be noted that, when the data in each line in the file is subjected to the service processing, data verification is also required to be performed, so as to avoid unsuccessful service processing caused by unqualified data. Specifically, the following may be implemented: calling a preset verification model, and performing data verification on the data to be processed to obtain a verification result; if the verification result is qualified, performing service processing on the data to be processed to obtain a service processing result, and updating the service state corresponding to the data to be processed to be successful when the processing result is successful; and if the verification result is unqualified, determining that the service processing result of the to-be-processed line data is failed, and updating the service state corresponding to the to-be-processed line data into failure. If the check result is unqualified, the service processing is not required to be executed, the service processing result of the to-be-processed line data can be directly determined to be failure, and then the corresponding service state can be updated to be failure. If the verification result is qualified, performing service processing on the data to be processed to obtain a service processing result, and updating the service state corresponding to the data to be processed to be successful when the processing result is successful; and when the processing result is unsuccessful, the service state corresponding to the to-be-processed line data is not updated, and the service processing transaction can be triggered for the to-be-processed line data again.
It should be noted that after each row of data is processed, the processing result is stored, and if the processing result is a failure, the reason for the failure may also be stored, so that the peer system performs analysis based on the processing result.
S103: and inquiring the service state of the file to be uploaded in the processing in the file downloading record table, triggering an uploading transaction to obtain a service processing result corresponding to the file to be uploaded, further generating and uploading a result file, and updating the service state of the file to be uploaded into a processing success state.
After the file to be processed completes the service processing, the service state is marked as in-process to indicate that the result uploading needs to be executed, so that the service state in the file downloading record table can be inquired as the file in processing in the step, namely the file to be uploaded, so as to execute the result uploading. After the file to be uploaded is inquired, an uploading transaction can be triggered, after the uploading transaction is triggered, a service processing result corresponding to the file to be uploaded can be obtained, a result file is further generated and uploaded, and the service state of the file to be uploaded is updated to be successful in processing.
In the embodiment of the invention, the file uploading list can be set, and after the result file is uploaded, the uploading information of the file to be uploaded can be written into the file uploading list so as to facilitate the recording and storage of the file uploading result. Fig. 4 is a schematic diagram of a file upload list.
It should be noted that, in the embodiment of the present invention, the result file may be set according to requirements, for example, a first line in the result file may be a description related to a company, a second line may be an attribute name of file docking, a third line may be a processing result of each line of data, a last line may be a final line, and fields are separated by separators. The document processing system may generate a desired result file based on the results of the processing of the line data in the document.
In the embodiment of the invention, the processing process of the file is properly split, each split part is processed in a transaction triggering mode, and the execution of each transaction is independent, so that when the file is processed, even if the file processing is interrupted, the processing progress of the file can be directly determined based on the execution condition of the corresponding transaction, and the unprocessed file is continuously processed based on the triggering of the transaction again without sequentially judging the processing progress of each data in the file, therefore, the operation is simple, and the file processing efficiency can be improved.
The following describes the method for writing a file in step S101 according to an embodiment of the present invention with reference to the embodiment shown in fig. 1. As shown in fig. 5, the method includes:
s501: and acquiring the downloaded file.
In the embodiment of the invention, the file downloading task can be executed by downloading the jobs.
S502: based on the data included in the downloaded file, a check mark of the downloaded file is calculated.
In the embodiment of the present invention, the check mark may be determined as the check mark based on hash algorithm calculation, that is, based on the hash value corresponding to the data included in the downloaded file.
S503: judging whether the file downloading record table comprises a check mark or not, and if so, ignoring the downloaded file; if not, go to step S504.
S504: a write transaction is triggered.
Because the file is generated as a temporary file when being downloaded, the downloaded file can be stored to a database and other positions after the corresponding write-in transaction is triggered.
S505: and acquiring file information of the downloaded file, writing the file information into a file downloading record table, and marking the service state corresponding to the downloaded file in the file downloading record table as pending.
S506: and writing each row of data in the downloaded file into a file row record detail table, and marking the service state corresponding to each row of data as pending in the file row record detail table.
S507: judging whether the writing is successful, if so, submitting the transaction; if not, the transaction is rolled back.
If the steps S505 and S506 are successfully executed, that is, the writing is successfully performed, the file download record table and the file row record list after the steps S505 and S506 are executed may be stored, and the transaction is committed. If steps S505 and S506 are not performed successfully, i.e. indicating a write failure, the write transaction of the downloaded file may be rolled back, i.e. step S501 is performed.
In the embodiment of the invention, a uniform high-availability solution is formed by processing the file based on the transaction, the business processing flow is divided into three transactions by a splitting mode, the file can be processed by a mode of three timing task rounds, and the file writing, the business processing and the result uploading are independent and do not influence each other; when the file is too large, the problem that the performance of the system is reduced because the whole large business of the service is executed immediately after the file is analyzed can be solved; when the system is restarted or other uncontrollable factors cause the processing failure of a certain file, the next transaction triggers execution to compensate.
The following describes, in conjunction with the embodiment shown in fig. 1, a method for processing a file service in step S102 according to an embodiment of the present invention. As shown in fig. 6, the method includes:
s601: and inquiring the file to be processed with the service state to be the file to be processed in the file downloading record table.
The embodiment of the invention can be executed through the preset service processing jobb.
S602: inquiring whether the file row record list comprises data of the to-be-processed data which belong to the to-be-processed file and have a service state of the to-be-processed data, and if not, updating the service state corresponding to the to-be-processed file in the file download record list into processing; if yes, go to step S603.
S603: and reading the data of the row to be processed in the file row record list, and triggering a corresponding business processing transaction for each data of the row to be processed.
S604: and calling a preset verification model for each row of data to be processed, and performing data verification on the row of data to be processed to obtain a verification result.
The data check may include two parts, which are a basic data check and a service data check. The basic data check may include checking whether a data type of a certain field is a preset number type. The service data check may include checking that the user id in the user id field is correct.
The result of the data check includes pass and fail.
S605: judging whether the check result is qualified or not, if not, determining that the service processing result of the to-be-processed line data is failed, and updating the service state of the to-be-processed line data in the file line record list into failure; if yes, go to step S606.
S606: executing service processing on the data to be processed, judging whether the service processing is successful, if so, updating the service state of the data to be processed in the file row record list to be successful; if not, the transaction is rolled back.
After the business processing is successful, the processing result of the data to be processed can be stored, and the business state of the data to be processed in the file row record list is updated to be successful; and after the service processing is unsuccessful, rolling back the service processing transaction of the data to be processed.
After the pending row data processing is complete, the transaction may be committed. The processing interfaces can be respectively abstracted out for the verification of the data to be processed and the corresponding business processing so as to call different business modules for realization.
In the embodiment of the invention, a uniform high-availability solution is formed by processing the file based on the transaction, the business processing flow is divided into three transactions by a splitting mode, the file can be processed by a mode of three timing task rounds, and the file writing, the business processing and the result uploading are independent and do not influence each other; when the file is too large, the problem that the performance of the system is reduced because the whole large business of the service is executed immediately after the file is analyzed can be solved; the business processing of each line of data in the file can independently execute business operation through corresponding affairs, and the business operation is independent minor affairs and does not influence each other. When the system is restarted or other uncontrollable factors cause the processing failure of a certain file, the next transaction triggers execution to compensate.
The following describes, with reference to the embodiment shown in fig. 1, a method for uploading a result file in step S103 according to an embodiment of the present invention. As shown in fig. 7, the method includes:
s701: and inquiring the service state in the file downloading record table as the file to be uploaded in the process.
The embodiment of the invention can be executed through the preset upload job.
S702: and triggering an uploading transaction, acquiring a service processing result corresponding to the file to be uploaded, and generating a result file.
And in order to ensure that all the row data included in the file to be uploaded are processed, before the uploading transaction is triggered, whether the row data with the service state to be processed exists in the row data included in the file to be uploaded can be inquired through the file downloading record table. If yes, indicating that data of the file to be uploaded is not processed, and not triggering an uploading transaction; if not, the data processing of the file to be uploaded is completed, and uploading is triggered.
S703: judging whether a result file of the file to be uploaded is uploaded, if so, updating the service state of the file to be uploaded to be successfully processed; if not, go to step S704.
In the step, whether the result file of the file to be uploaded is uploaded can be judged by inquiring whether the result file of the file to be uploaded exists in the server.
S704: and uploading the result file to a corresponding server, and updating the service state of the file to be uploaded to be successfully processed.
The corresponding server may be a server agreed between file docking systems.
In the embodiment of the invention, the file processing is formed into a uniform high-availability solution based on transactions. The business processing flow is disassembled into three transactions in a split mode, the file can be processed in a mode of three timing task trainings, and the file writing, the business processing and the result uploading are independent and do not affect each other; when the file is too large, the problem that the performance of the system is reduced because the whole large business of the service is executed immediately after the file is analyzed can be solved; when the system is restarted or other uncontrollable factors cause the processing failure of a certain file, the next transaction triggers execution to compensate.
In order to solve the problems in the prior art, an embodiment of the present invention provides a file processing apparatus 800, as shown in fig. 8, where the apparatus 800 includes:
a writing unit 801, configured to acquire a downloaded file, trigger a writing transaction to acquire file information of the downloaded file, write the file information into a file download record table, and mark a service state corresponding to the downloaded file in the file download record table as pending;
the processing unit 802 is configured to query the file download record table that the service status is a to-be-processed file to be processed, trigger a service processing transaction, execute service processing on the to-be-processed file, and update the service status of the to-be-processed file into processing;
the uploading unit 803 is configured to query the service status in the file download record table as a processed file to be uploaded, trigger an uploading transaction to obtain a service processing result corresponding to the file to be uploaded, further generate and upload a result file, and update the service status of the file to be uploaded to a processing success status.
It should be understood that the manner of implementing the embodiment of the present invention is the same as the manner of implementing the embodiment shown in fig. 1, and the description thereof is omitted.
In an implementation manner of the embodiment of the present invention, the writing unit 801 is further configured to:
and writing each row of data in the downloaded file into a file row record list, and marking the service state corresponding to each row of data as pending in the file row record list.
In another implementation manner of the embodiment of the present invention, the processing unit 802 is specifically configured to:
inquiring whether the file row record list comprises to-be-processed row data which belong to the to-be-processed file and have a service state to be processed;
if not, updating the service state corresponding to the file to be processed in the file downloading record table to be processed; and if so, reading the data of the to-be-processed row in the file row record list, triggering a service processing transaction for each data of the to-be-processed row to execute corresponding service processing, and updating a service state corresponding to the data of the to-be-processed row based on a service processing result.
In another implementation manner of the embodiment of the present invention, the processing unit 802 is specifically configured to:
calling a preset verification model, and performing data verification on the to-be-processed line data to obtain a verification result;
if the verification result is qualified, performing service processing on the to-be-processed row data to obtain a service processing result, and updating the service state corresponding to the to-be-processed row data to be successful when the processing result is successful; and if the verification result is unqualified, determining that the service processing result of the to-be-processed line data is failed, and updating the service state corresponding to the to-be-processed line data into failure.
In another implementation manner of the embodiment of the present invention, the file information includes a service type;
the processing unit 802 is specifically configured to:
and inquiring the service type of the file to be processed from the file downloading record table to trigger a service processing transaction corresponding to the service type for each line of data to be processed.
In another implementation manner of the embodiment of the present invention, the writing unit 801 is specifically configured to:
acquiring the quantity of the line data in the downloaded file, calculating the splitting batch of the line data based on the single writing quantity, further splitting the line data to obtain a splitting result, and writing the line data into a file line record list based on the splitting result.
In another implementation manner of the embodiment of the present invention, the writing unit 801 is specifically configured to:
calculating a check mark of the downloaded file based on the downloaded file including data to judge whether the file download record table includes the check mark;
if yes, ignoring the downloaded file; if not, triggering a corresponding write-in transaction for the downloaded file.
It should be understood that the embodiment of the present invention is implemented in the same manner as the embodiment shown in fig. 1, 5, 6 or 7, and is not repeated herein.
In the embodiment of the invention, the processing process of the file is properly split, each split part is processed in a transaction triggering mode, and the execution of each transaction is independent, so that when the file is processed, even if the file processing is interrupted, the processing progress of the file can be directly determined based on the execution condition of the corresponding transaction, and the unprocessed file is continuously processed based on the triggering of the transaction again without sequentially judging the processing progress of each data in the file, therefore, the operation is simple, and the file processing efficiency can be improved.
According to an embodiment of the present invention, an electronic device and a readable storage medium are also provided.
The electronic device of the embodiment of the invention comprises: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the processor, and the instructions are executed by the at least one processor to cause the at least one processor to execute the method for processing files provided by the embodiment of the invention.
Fig. 9 shows an exemplary system architecture 900 of a file processing method or device to which embodiments of the invention may be applied.
As shown in fig. 9, the system architecture 900 may include end devices 901, 902, 903, a network 904, and a server 905. Network 904 is the medium used to provide communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 901, 902, 903 to interact with a server 905 over a network 904 to receive or send messages and the like. Various client applications may be installed on the terminal devices 901, 902, 903.
The terminal devices 901, 902, 903 may be, but are not limited to, smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 905 may be a server that provides various services, and may analyze and process data such as a received file processing request, and feed back a processing result (e.g., a result file — just an example) to the terminal device.
It should be noted that the method for processing a file provided by the embodiment of the present invention is generally executed by the server 905, and accordingly, a device for processing a file is generally disposed in the server 905.
It should be understood that the number of terminal devices, networks, and servers in fig. 9 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 10, a block diagram of a computer system 1000 suitable for implementing embodiments of the present invention is shown. The computer system illustrated in FIG. 10 is only one example and should not impose any limitations on the scope of use or functionality of embodiments of the invention.
As shown in fig. 10, the computer system 1000 includes a Central Processing Unit (CPU)1001 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)1002 or a program loaded from a storage section 1008 into a Random Access Memory (RAM) 1003. In the RAM 1003, various programs and data necessary for the operation of the system 1000 are also stored. The CPU 1001, ROM 1002, and RAM 1003 are connected to each other via a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
The following components are connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output section 1007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 1008 including a hard disk and the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1010 as necessary, so that a computer program read out therefrom is mounted into the storage section 1008 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication part 1009 and/or installed from the removable medium 1011. The computer program executes the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 1001.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a unit, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present invention may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a write unit, a processing unit, and an upload unit. Where the names of these units do not in some cases constitute a limitation of the unit itself, for example, a write unit may also be described as a "unit of the function of the write unit".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to perform the method of file processing provided by the present invention.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A file processing method, comprising:
acquiring a downloaded file, triggering a write-in transaction to acquire file information of the downloaded file, writing the file information into a file download record table, and marking a service state corresponding to the downloaded file in the file download record table as pending;
inquiring the file to be processed with the service state in the file downloading record table, triggering a service processing transaction to execute service processing on the file to be processed, and updating the service state of the file to be processed into processing;
and inquiring the service state of the file downloading record table as the processed file to be uploaded, triggering an uploading transaction to obtain a service processing result corresponding to the file to be uploaded, further generating and uploading a result file, and updating the service state of the file to be uploaded into a processing success state.
2. The method according to claim 1, wherein before querying the pending file with the service status pending in the file download record table, the method further comprises:
and writing each row of data in the downloaded file into a file row record list, and marking the service state corresponding to each row of data as pending in the file row record list.
3. The method of claim 2, wherein the triggering a transaction to perform a transaction on the file to be processed and updating the transaction status of the file to be processed to be in process comprises:
inquiring whether the file row record list comprises to-be-processed row data which belong to the to-be-processed file and have a service state to be processed;
if not, updating the service state corresponding to the file to be processed in the file downloading record table to be processed; and if so, reading the data of the to-be-processed row in the file row record list, triggering a service processing transaction for each data of the to-be-processed row to execute corresponding service processing, and updating a service state corresponding to the data of the to-be-processed row based on a service processing result.
4. The method according to claim 3, wherein the performing the service processing and updating the service state corresponding to the data to be processed based on the service processing result comprises:
calling a preset verification model, and performing data verification on the to-be-processed line data to obtain a verification result;
if the verification result is qualified, performing service processing on the to-be-processed row data to obtain a service processing result, and updating the service state corresponding to the to-be-processed row data to be successful when the processing result is successful; and if the verification result is unqualified, determining that the service processing result of the to-be-processed line data is failed, and updating the service state corresponding to the to-be-processed line data into failure.
5. The method of claim 3, wherein the file information comprises a service type;
triggering a service processing transaction for each row of data to be processed, comprising:
and inquiring the service type of the file to be processed from the file downloading record table to trigger a service processing transaction corresponding to the service type for each line of data to be processed.
6. The method of claim 2, wherein writing each line of data in the downloaded file to a file line record list comprises:
acquiring the quantity of the line data in the downloaded file, calculating the splitting batch of the line data based on the single writing quantity, further splitting the line data to obtain a splitting result, and writing the line data into a file line record list based on the splitting result.
7. The method of claim 1, wherein triggering the write transaction comprises:
calculating a check mark of the downloaded file based on the downloaded file including data to judge whether the file download record table includes the check mark;
if yes, ignoring the downloaded file; if not, triggering a corresponding write-in transaction for the downloaded file.
8. A document processing apparatus, characterized by comprising:
the writing unit is used for acquiring the downloaded file, triggering a writing transaction to acquire file information of the downloaded file, writing the file information into a file downloading record table, and marking the service state corresponding to the downloaded file in the file downloading record table as pending;
the processing unit is used for inquiring the file to be processed with the service state to be processed in the file downloading record table, triggering a service processing transaction so as to execute service processing on the file to be processed, and updating the service state of the file to be processed into the processing;
and the uploading unit is used for inquiring the service state of the file to be uploaded in the processing in the file downloading record table, triggering an uploading transaction to obtain a service processing result corresponding to the file to be uploaded, further generating and uploading a result file, and updating the service state of the file to be uploaded into a processing success state.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202111141662.7A 2021-09-28 2021-09-28 File processing method and device, electronic equipment and storage medium Pending CN113806312A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111141662.7A CN113806312A (en) 2021-09-28 2021-09-28 File processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111141662.7A CN113806312A (en) 2021-09-28 2021-09-28 File processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113806312A true CN113806312A (en) 2021-12-17

Family

ID=78896934

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111141662.7A Pending CN113806312A (en) 2021-09-28 2021-09-28 File processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113806312A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117667319A (en) * 2024-02-02 2024-03-08 建信金融科技有限责任公司 Transaction processing method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117667319A (en) * 2024-02-02 2024-03-08 建信金融科技有限责任公司 Transaction processing method and device
CN117667319B (en) * 2024-02-02 2024-05-03 建信金融科技有限责任公司 Transaction processing method and device

Similar Documents

Publication Publication Date Title
US10678597B2 (en) Event-driven blockchain workflow processing
US20220253458A1 (en) Method and device for synchronizing node data
CN109508326B (en) Method, device and system for processing data
CN110688828A (en) File processing method and device, file processing system and computer equipment
CN108933695B (en) Method and apparatus for processing information
CN110795479A (en) Method and device for distributed ETL scheduling based on data
CN107220375B (en) Data reading and writing method and server
CN110737655B (en) Method and device for reporting data
CN113806312A (en) File processing method and device, electronic equipment and storage medium
CN111159211A (en) Order information generation method, device and system, computer equipment and storage medium
CN110389976B (en) Multi-interface data scheduling method and device
CN110781134A (en) Data processing method and device, computer storage medium and electronic equipment
CN110764911A (en) Resource scheduling method, device and control system based on order
CN114428815A (en) Data storage method and device, electronic equipment and computer readable medium
CN113312900A (en) Data verification method and device
CN111210349A (en) Virtual asset transfer hosting method and device, electronic equipment and storage medium
CN112184027A (en) Task progress updating method and device and storage medium
CN110765148A (en) Service data processing method and device
CN110688295A (en) Data testing method and device
CN115981828B (en) Service message processing method and device
CN112950138B (en) Collaborative development state management method, device and server
CN111932374A (en) Data updating method and device and electronic equipment
CN112905605A (en) Contract standing book data structure and contract standing book data operation method and device
CN114356884A (en) Data migration method and device
CN114896084A (en) Event processing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination