WO2021027592A1 - File processing method, apparatus, device and computer readable storage medium - Google Patents

File processing method, apparatus, device and computer readable storage medium Download PDF

Info

Publication number
WO2021027592A1
WO2021027592A1 PCT/CN2020/106058 CN2020106058W WO2021027592A1 WO 2021027592 A1 WO2021027592 A1 WO 2021027592A1 CN 2020106058 W CN2020106058 W CN 2020106058W WO 2021027592 A1 WO2021027592 A1 WO 2021027592A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
processed
configuration information
processing
conversion
Prior art date
Application number
PCT/CN2020/106058
Other languages
French (fr)
Chinese (zh)
Inventor
夏勇
李凌
Original Assignee
深圳前海微众银行股份有限公司
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
Priority claimed from CN201910761804.6A external-priority patent/CN110457260B/en
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2021027592A1 publication Critical patent/WO2021027592A1/en

Links

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/11File system administration, e.g. details of archiving or snapshots
    • 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/11File system administration, e.g. details of archiving or snapshots
    • G06F16/116Details of conversion of file system types or formats
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Definitions

  • This application relates to the field of financial technology (Fintech) technology, and in particular to a file processing method, device, equipment, and computer-readable storage medium.
  • Financial technology Fetech
  • the main purpose of this application is to provide a file processing method, device, equipment, and computer-readable storage medium, aiming to realize automatic file processing through configuration, so as to reduce the workload of developers and improve development efficiency.
  • the present application provides a file processing method, the file processing method includes:
  • the configuration information includes the target conversion Java class name, line beginning identifier, separator, the mapping relationship between the first array element and the first target conversion attribute, and the configuration information is based on the configuration information and the first target conversion attribute.
  • the step of converting the file to be processed by a preset rule to obtain a Java object to be processed includes:
  • the first array elements after the format conversion are respectively mapped to the corresponding first target conversion attributes to obtain The pending Java object.
  • the first array elements after the format conversion are respectively mapped to corresponding ones according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute In the first target conversion attribute, before the step of obtaining the to-be-processed Java object, it also includes:
  • the configuration information further includes a mapping relationship between a second array element and a second target conversion attribute
  • the processing result Java object is converted according to the configuration information and a second preset rule Processing to obtain the processing result file includes:
  • the second array element, the line header identifier, and the separator are spliced in a preset format to obtain a processing result file.
  • the configuration information further includes a file limit size
  • the method before the step of converting the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed, the method further includes :
  • the step of converting the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed includes:
  • the split files to be processed are sequentially converted to obtain the Java objects to be processed.
  • the step of obtaining corresponding configuration information from a preset configuration table according to the file name includes:
  • the target configuration name is determined, and the configuration information corresponding to the target configuration name is obtained from the preset configuration table.
  • the file processing method further includes:
  • the present application also provides a file processing device, the file processing device includes:
  • the information obtaining module is configured to obtain the file to be processed and its file name according to the file processing request after confirming that the file processing request is received, and obtain corresponding configuration information from the preset configuration table according to the file name;
  • the first conversion module is configured to perform conversion processing on the file to be processed according to the configuration information and the first preset rule to obtain a Java object to be processed;
  • the processing module is configured to call the corresponding executor to process the to-be-processed Java object according to the processing class name in the configuration information to obtain the processing result Java object;
  • the second conversion module is configured to perform conversion processing on the processing result Java object according to the configuration information and a second preset rule to obtain a processing result file.
  • the present application also provides a file processing device, the file processing device includes: a memory, a processor, and a file processing program stored in the memory and running on the processor, so When the file processing program is executed by the processor, the steps of the file processing method described above are implemented.
  • the present application also provides a computer-readable storage medium having a file processing program stored on the computer-readable storage medium, and the file processing program is executed by a processor to realize the file processing as described above. Method steps.
  • This application provides a file processing method, device, equipment, and computer-readable storage medium.
  • the file to be processed and its file name are first obtained according to the file processing request, and the file name is obtained from a preset configuration table
  • the corresponding configuration information is obtained in the configuration information; then, the file to be processed is converted according to the configuration information and the first preset rule to obtain the Java object to be processed, and then the corresponding executor is called according to the processing class name in the configuration information.
  • the processing is performed to obtain the processing result Java object; finally, the processing result Java object is converted according to the configuration information and the second preset rule to obtain the processing result file.
  • FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the application;
  • FIG. 2 is a schematic flowchart of the first embodiment of the application file processing method
  • FIG. 3 is a schematic diagram of functional modules of the first embodiment of the file processing apparatus of this application.
  • FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the application.
  • the document processing device in the embodiment of this application can be a smart phone or a PC (Personal Computer, personal computer), tablet computer, portable computer and other terminal equipment.
  • the file processing device may include a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005.
  • the communication bus 1002 is used to implement connection and communication between these components.
  • the user interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
  • the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a Wi-Fi interface).
  • the memory 1005 can be a high-speed RAM memory or a stable memory (non-volatile memory), such as disk storage.
  • the memory 1005 may also be a storage device independent of the foregoing processor 1001.
  • FIG. 1 does not constitute a limitation on the file processing device, and may include more or less components than shown in the figure, or a combination of certain components, or different components Layout.
  • the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a file processing program.
  • the network interface 1004 is mainly used to connect to a back-end server and communicate with the back-end server;
  • the user interface 1003 is mainly used to connect to a client and communicate with the client;
  • the processor 1001 can be used to Call the file processing program stored in the memory 1005 and perform the following operations:
  • the configuration information includes the target conversion Java class name, line beginning identifier, separator, the mapping relationship between the first array element and the first target conversion attribute, and the processor 1001 can call the file processing program stored in the memory 1005 , Also do the following:
  • the first array elements after the format conversion are respectively mapped to the corresponding first target conversion attributes to obtain The pending Java object.
  • processor 1001 may call a file processing program stored in the memory 1005, and also perform the following operations:
  • the execution step according to the target conversion Java class name and the mapping relationship between the first array elements and the first target conversion attributes , Map the first array elements after the format conversion to the corresponding first target conversion attributes respectively to obtain the to-be-processed Java object;
  • configuration information further includes the mapping relationship between the second array element and the second target conversion attribute
  • the processor 1001 may call the file processing program stored in the memory 1005, and further perform the following operations:
  • the second array element, the line header identifier, and the separator are spliced in a preset format to obtain a processing result file.
  • the configuration information also includes a limited file size
  • the processor 1001 may call a file processing program stored in the memory 1005, and also perform the following operations:
  • the step of converting the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed includes:
  • the split files to be processed are sequentially converted to obtain the Java objects to be processed.
  • processor 1001 may call a file processing program stored in the memory 1005, and also perform the following operations:
  • the target configuration name is determined, and the configuration information corresponding to the target configuration name is obtained from the preset configuration table.
  • processor 1001 may call a file processing program stored in the memory 1005, and also perform the following operations:
  • This application provides a file processing method.
  • FIG. 2 is a schematic flowchart of a first embodiment of a file processing method of this application.
  • the file processing method includes:
  • Step S10 after determining that the file processing request is received, obtain the file to be processed and its file name according to the file processing request, and obtain corresponding configuration information from a preset configuration table according to the file name;
  • the file processing method in this embodiment is implemented by a file processing device, and the device is described by taking a server as an example.
  • the server when the server receives the file processing request, it first obtains the file to be processed and its file name according to the file processing request, and obtains corresponding configuration information from the preset configuration table according to the file name.
  • the step of "obtaining corresponding configuration information from the preset configuration table according to the file name" includes:
  • Step a1 Determine the file type of the file to be processed according to the file name
  • Step a2 Determine the target configuration name according to the file type and the mapping relationship between the preset file type and the configuration name, and obtain configuration information corresponding to the target configuration name from the preset configuration table.
  • the file type of the file to be processed can be determined first according to the file name, and then the target configuration name is determined according to the file type and the mapping relationship between the preset file type and the configuration name, and The configuration information corresponding to the target configuration name is obtained from the preset configuration table.
  • the preset configuration table may include, but is not limited to, the configuration name, line header identifier, separator, target conversion Java class name, the mapping relationship between the first array element and the first target conversion attribute (that is, the The properties of the Java class and its mapping relationship with the first array element), the mapping relationship between the second array element and the second target conversion property (that is, the property of the Java class to be converted in the write file and its relationship with the second The mapping relationship between array elements), processing class name, strict mode, file limit size and transaction processing size and other fields.
  • each piece of configuration information includes the configuration information corresponding to the above-mentioned fields.
  • one target configuration name can correspond to multiple pieces of configuration information.
  • the file type is Batch Performance Test (batch performance test) files to be processed.
  • the preset configuration table will contain 4 different configuration information.
  • the line headers in each configuration information are H, X, Y, and Z respectively, which are used for subsequent identification
  • the configuration information corresponding to the character is used to automatically deserialize each line of data into a Java object.
  • mapping relationship between the file name and the configuration name can also be directly established, so as to directly determine the target configuration name according to the mapping relationship between the file name, the file name and the configuration name, and then from The configuration information corresponding to the target configuration name is obtained from the preset configuration table.
  • Step S20 Perform conversion processing on the file to be processed according to the configuration information and the first preset rule to obtain a Java object to be processed;
  • the file to be processed is converted according to the configuration information and the first preset rule to obtain the Java object to be processed. It should be noted that a row of data corresponds to one Java object, and when the file to be processed includes multiple (rows) of data, there are also multiple corresponding Java objects to be processed.
  • the configuration information includes the target conversion Java class name, line header identifier, separator, the mapping relationship between the first array element and the first target conversion attribute, and step S20 includes:
  • Step b1 Split the file to be processed into multiple pieces of data according to the line header identifier
  • the specific process of object deserialization (the process of restoring the byte sequence to the object) is as follows: First, the file to be processed is split into multiple pieces of data according to the line header identification, for example, for the following files:
  • 6 pieces of data can be obtained by splitting according to the line header identification.
  • Step b2 split the multiple pieces of data into an array according to the separator, and traverse the split array, and read the first array element;
  • the first array elements can be obtained as 123 and 333 respectively.
  • Step b3 Obtain the type of the first target conversion attribute, and call the first format converter corresponding to the type of the first target conversion attribute to perform format conversion on the read first array element to obtain the converted format First array element;
  • the type of the first target conversion attribute is obtained, and the first format converter corresponding to the type of the first target conversion attribute is called to perform format conversion on the read first array element to obtain the first array after the format conversion element.
  • the first target conversion attribute includes age (age) and date (date)
  • a string-to-integer format converter and a string-to-date format converter can be called respectively to perform format conversion.
  • Step b4 according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, map the first array element after format conversion to the corresponding first target conversion attribute, respectively , Get the Java object to be processed.
  • the first array elements after format conversion are respectively mapped to the corresponding first target conversion attributes to obtain the Java object to be processed .
  • the corresponding target standard is changed to the Java class File Coop Open Confirm Detl class. After splitting into an array, read the first array elements 123 and 333.
  • the Coop Open Confirm Detl object is the Java object to be processed.
  • Step S30 According to the processing class name in the configuration information, call the corresponding executor to process the to-be-processed Java object to obtain the processing result Java object;
  • the executor After obtaining the Java object to be processed, according to the processing class name in the configuration information, call the corresponding executor to process the Java object to be processed to obtain the processing result Java object.
  • the executor is used to execute business logic.
  • the obtained Java object is a Fund Transfer object
  • the corresponding executor can be determined according to the processing class name as Fund Transfer Server.doTransfer, then the executor will be automatically called to process the Fund Transfer object to complete the transfer business, and then get the processing result.
  • the processing result is also a Java object, which is recorded as the processing result Java object.
  • Step S40 Perform conversion processing on the processing result Java object according to the configuration information and the second preset rule to obtain a processing result file.
  • the processing result Java object is converted according to the configuration information and the second preset rule to obtain the processing result file. That is, the processing result Java object needs to be converted into a corresponding character string in order to write back the result file.
  • This process involves the serialization of the object, that is, converting the object into a sequence of bytes.
  • the configuration information further includes the mapping relationship between the second array element and the second target conversion attribute
  • step S40 includes:
  • Step c1 Extract the attribute information corresponding to each second target conversion attribute in the processing result Java object, and call a second format converter corresponding to the type of the second target conversion attribute to format the attribute information Convert to get the second array element;
  • the second format converter is a format converter that converts an object type to a string type, such as a format converter that converts an integer type to a string, and a date type to a string format converter.
  • Step c2 splicing the second array element, the line header identifier, and the separator according to a preset format to obtain a processing result file.
  • the second array element, line beginning identifier, and separator are spliced according to the preset format to obtain the processing result file.
  • the preset format can be preset and can be similar to the format of the file to be processed. For example, if the second array element is 222 and 234, if the line header identifier in the configuration information is B and the separator is
  • the embodiment of the application provides a file processing method.
  • a file processing request When a file processing request is received, the file to be processed and its file name are first obtained according to the file processing request, and corresponding configuration information is obtained from a preset configuration table according to the file name; , Convert the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed, and then call the corresponding executor to process the Java object to be processed according to the processing class name in the configuration information to obtain the processing result Java object ; Finally, the processing result Java object is converted according to the configuration information and the second preset rule to obtain the processing result file.
  • the automatic processing of files is realized through configuration. Compared with the automatic processing of files by writing codes in the prior art, the embodiments of the present application will process newly added files or file changes. , No need for developers to add or modify a large amount of code, which can reduce the workload of developers and improve development efficiency.
  • the file processing method further includes:
  • Step A detecting whether the number of read first array elements is equal to the number of first target conversion attributes
  • the strict mode in order to ensure that the first array element read from the file to be processed can be subjected to subsequent processing, the strict mode can also be set in the configuration information, and then according to the strict mode, the number of first array elements and the first target The number of conversion attributes is used to determine whether further subsequent processing can be performed (ie, the next step S20).
  • strict mode includes strict and non-strict. Specifically, after the first array element is read, it is detected whether the number of the read first array element is equal to the number of the first target conversion attribute.
  • step b4 is performed: according to the target conversion Java class name and the mapping between the first array elements and the first target conversion attributes Relationship, mapping the first array elements after the format conversion to the corresponding first target conversion attributes to obtain the Java object to be processed;
  • the Java class name and the first array element and the first target conversion attribute can be converted according to the target
  • the mapping relationship between the first array elements after format conversion are respectively mapped to the corresponding first target conversion attributes to obtain the Java object to be processed, and then execute the subsequent processing process.
  • I won’t repeat them here.
  • step B After determining that the number of elements in the first array obtained is not equal to the number of the first target conversion attributes, perform step B: detecting whether the strict mode in the configuration information is strict or non-strict;
  • step C is executed: corresponding abnormal reminder information is generated, and returned to the client corresponding to the file processing request;
  • step b4 is executed: according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, the format converted The first array elements are respectively mapped to the corresponding first target conversion attributes to obtain the to-be-processed Java object.
  • the number of the first target conversion attribute is 4, if the number of the first array element is 5, only the first 4 elements need to be mapped, and if the number of the first array element is 2, then only the These two elements can be mapped to the conversion attribute corresponding to your first target.
  • the configuration information further includes a file limit size.
  • the file processing method further includes:
  • Step D Obtain the file size of the file to be processed, and detect whether the file size exceeds the file limit size
  • the configuration information may also include a limited file size, where the limited file size is the number of pieces of data that can be processed at one time.
  • the file size of the file to be processed can be obtained first, where the file size refers to the total number of data included in the file to be processed. Specifically, it can be determined according to the line header identification. Each line has a line header identifier, the number of line header identifiers is the total number of data; of course, the total number of lines of the file to be processed can also be directly identified, and the total number of lines is the total number of data. Then, it is detected whether the file size of the file to be processed exceeds the file limit size.
  • step E splitting the file to be processed according to the limited file size
  • step S20 includes:
  • the split files to be processed are sequentially converted to obtain the Java objects to be processed.
  • the file to be processed can be split according to the file limit size, and then based on the configuration information and the first preset
  • the rules sequentially convert the files to be processed after splitting to obtain the Java objects to be processed. Further, the subsequent steps are executed, and the specific execution process can refer to the above-mentioned first embodiment, which will not be repeated here.
  • step S20 is executed: according to the configuration information and the first preset rule, the split files to be processed are sequentially converted to obtain the Java object to be processed.
  • the files to be processed after splitting are converted in turn After processing, the Java object to be processed is obtained, and then the subsequent steps are executed.
  • the specific execution process please refer to the above-mentioned first embodiment, which will not be repeated here.
  • the size of the configuration file is limited.
  • it is detected whether the file size of the file to be processed exceeds the limited size of the file.
  • the file to be processed is split and processed, which can avoid the server from being overstressed.
  • the processing performance of the server is limited.
  • the configuration information may also include the transaction commit size, where the transaction commit size refers to the data size limited by a single time during processing.
  • the transaction commit size refers to the data size limited by a single time during processing.
  • the transaction commit size further controls the data volume of the Java object to be processed in a single processing according to the transaction commit size.
  • the above-mentioned similar method can also be used to limit the data volume of the Java object of the processing result of a single conversion, so as to further avoid the situation that the server's processing performance is limited due to excessive server pressure.
  • the file processing method further includes:
  • Step F receiving a configuration table modification request, and displaying a corresponding configuration information modification interface based on the configuration table modification request;
  • Step G Receive a configuration table modification instruction triggered by the user based on the configuration information modification interface, and update the preset configuration table according to the configuration table modification instruction.
  • the staff when there is a new file that needs to be processed automatically, or the format of the original file is changed, or a new service is added to the original file, at this time, the staff only needs to add configuration information or modify the original configuration The information is enough, no need to develop a whole set of new code, and no need to make substantial changes to the original code.
  • the staff when the staff needs to modify the configuration table, they can click on the configuration table modification option through the corresponding software or App (Application) of the user terminal (such as mobile phone, PC, etc.) to trigger the configuration table modification request.
  • the server receives the configuration table modification request, it displays the corresponding configuration information modification interface based on the configuration table modification request.
  • the staff can input the modification information through the configuration information modification interface, and the configuration table modification instruction can be triggered after the input is completed.
  • the server updates the preset configuration table according to the configuration table modification instruction. For example, for the modification of part of the configuration information, you can directly modify and adjust the relevant configuration information in the preset configuration table, such as separators, processing class names, mapping relationships, file limit sizes, etc.
  • For new configuration information just add a new line in the preset configuration table, add the corresponding configuration name, target conversion Java class name, line beginning identification, separator, mapping relationship, processing class name and other information, and then add related configuration It's done.
  • the application also provides a file processing device.
  • FIG. 3 is a schematic diagram of the functional modules of the first embodiment of the file processing apparatus of this application.
  • the file processing device includes:
  • the information obtaining module 10 is configured to receive a file processing request, obtain a file to be processed and its file name according to the file processing request, and obtain corresponding configuration information from a preset configuration table according to the file name;
  • the first conversion module 20 is configured to perform conversion processing on the file to be processed according to the configuration information and a first preset rule to obtain a Java object to be processed;
  • the processing module 30 is configured to call the corresponding executor to process the to-be-processed Java object according to the processing class name in the configuration information to obtain the processing result Java object;
  • the second conversion module 40 is configured to perform conversion processing on the processing result Java object according to the configuration information and a second preset rule to obtain a processing result file.
  • the configuration information includes the target conversion Java class name, line beginning identifier, separator, the mapping relationship between the first array element and the first target conversion attribute, and the first conversion module 20 includes:
  • a file splitting unit configured to split the file to be processed into multiple pieces of data according to the line header identifier
  • An element reading unit configured to split the multiple pieces of data into an array according to the separator, traverse the split array, and read the first array element
  • the first conversion unit is configured to obtain the type of the first target conversion attribute, and call the first format converter corresponding to the type of the first target conversion attribute, and perform format conversion on the read first array element to obtain The first array element after format conversion;
  • the element mapping unit is configured to map the first array elements after the format conversion to the corresponding first array elements respectively according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute In the target conversion property, the Java object to be processed is obtained.
  • the first conversion module 20 further includes:
  • the first detection unit is configured to detect whether the number of the read first array elements is equal to the number of the first target conversion attributes
  • the element mapping unit is further configured to: after the first detection and determination unit determines that the number of read first array elements is equal to the number of the first target conversion attribute, convert the Java class name and the first target conversion attribute according to the target A mapping relationship between array elements and first target conversion attributes, mapping the first array elements after the format conversion to the corresponding first target conversion attributes to obtain the Java object to be processed;
  • the second detection unit is configured so that the first detection and determination unit determines that the number of read first array elements is not equal to the number of the first target conversion attribute, and detects whether the strict mode in the configuration information is strict or non strict;
  • An abnormality reminder unit configured to generate corresponding abnormality reminder information after the second detection unit determines that the strict mode in the configuration information is strict, and return to the client corresponding to the file processing request;
  • the element mapping unit is further configured to: after the second detection unit determines that the strict mode in the configuration information is non-strict, execute the step of: converting the Java class name and the first array element and the first target according to the target
  • the mapping relationship between the conversion attributes is to map the first array elements after the format conversion to the corresponding first target conversion attributes to obtain the Java object to be processed.
  • the second conversion module 40 includes:
  • the second conversion unit is configured to extract attribute information corresponding to each second target conversion attribute in the processing result Java object, and call a second format converter corresponding to the type of the second target conversion attribute, to The attribute information is formatted to obtain the second array element;
  • the splicing unit is configured to splice the second array element, the line header identifier, and the separator in a preset format to obtain a processing result file.
  • the configuration information further includes a file limit size
  • the file processing device before the step of converting the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed, the file processing device also includes:
  • a size detection module configured to obtain the file size of the file to be processed, and detect whether the file size exceeds the file limit size
  • a file splitting module configured to split the file to be processed according to the limited file size after the size detection module determines that the file size has exceeded the limited file size
  • the first conversion module is further configured to sequentially perform conversion processing on the split files to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed.
  • the information acquisition module 10 includes:
  • the type determining unit is configured to determine the file type of the file to be processed according to the file name
  • the information obtaining unit is configured to determine the target configuration name according to the file type and the mapping relationship between the preset file type and the configuration name, and obtain configuration information corresponding to the target configuration name from the preset configuration table.
  • the file processing device further includes:
  • the display module is configured to display the corresponding configuration information modification interface based on the configuration table modification request after receiving the configuration table modification request;
  • the update module is configured to receive a configuration table modification instruction triggered by a user based on the configuration information modification interface, and update the preset configuration table according to the configuration table modification instruction.
  • each module in the above-mentioned file processing apparatus corresponds to each step in the above-mentioned file processing method embodiment, and the functions and realization processes thereof will not be repeated here.
  • the present application also provides a computer-readable storage medium having a file processing program stored on the computer-readable storage medium, and when the file processing program is executed by a processor, the file processing method as described in any of the above embodiments is implemented step.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Devices For Executing Special Programs (AREA)
  • Stored Programmes (AREA)

Abstract

A file processing method, an apparatus, a device and a computer readable storage medium. The file processing method comprises: after determining that a file processing request is received, acquiring a file to be processed and the filename thereof according to the file processing request, and acquiring corresponding configuration information from a preset configuration table according to the filename (S10); converting the file to be processed according to the configuration information and a first preset rule to obtain a Java object to be processed (S20); according to a processing class name in the configuration information, calling a corresponding executor to process the Java object to be processed so as to obtain a processing result Java object (S30); and converting the processing result Java object according to the configuration information and a second preset rule to obtain a processing result file (S40).

Description

文件处理方法、装置、设备及计算机可读存储介质File processing method, device, equipment and computer readable storage medium
本申请要求于2019年08月14日提交中国专利局、申请号为201910761804.6、发明名称为“文件处理方法、装置、设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 201910761804.6, and the invention title is "File processing methods, devices, equipment and computer-readable storage media" on August 14, 2019. The reference is incorporated in the application.
技术领域Technical field
本申请涉及金融科技(Fintech)技术领域,尤其涉及一种文件处理方法、装置、设备及计算机可读存储介质。This application relates to the field of financial technology (Fintech) technology, and in particular to a file processing method, device, equipment, and computer-readable storage medium.
背景技术Background technique
随着计算机技术的发展,越来越多的技术(大数据、分布式、区块链Blockchain、人工智能等)应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,但由于金融行业的安全性、实时性要求,也对技术提出了更高的要求。With the development of computer technology, more and more technologies (big data, distributed, blockchain, artificial intelligence, etc.) are applied in the financial field. The traditional financial industry is gradually transforming to Fintech. However, due to financial The industry's security and real-time requirements also place higher requirements on technology.
随着金融领域业务的不断发展,各种业务交易量不断增大,各种交易文件不断增多,若全部通过人工处理,会出现处理效率低、差错率高的问题。因此,对于一些常见类型的文件,会编写对应的代码,以实现对文件的自动化处理。通过上述方式自动处理文件时,会存在以下问题:1)代码复用度较低,每次有新的文件处理均需开发一套新的代码对文件进行处理;2)一旦文件中的某些格式有变化,如文件顺序、分隔符,需重新修改代码;3)若文件中增加了新业务,必须重新修改代码,增加对应的处理逻辑。因此,现有技术中为实现文件的自动化处理,需要大量的代码开发,开发工作量较大,且开发效率较低。With the continuous development of financial business, the volume of various business transactions continues to increase, and various transaction documents continue to increase. If all transaction documents are processed manually, problems of low processing efficiency and high error rates will occur. Therefore, for some common types of files, the corresponding code will be written to realize the automatic processing of the files. When automatically processing files through the above methods, there will be the following problems: 1) The code reuse is low, and a new set of code must be developed to process the file every time a new file is processed; 2) Once some files are processed There are changes in format, such as file order and separator, the code needs to be revised; 3) If new services are added to the file, the code must be revised again and the corresponding processing logic is added. Therefore, in the prior art, in order to realize automatic file processing, a large amount of code development is required, the development workload is relatively large, and the development efficiency is low.
技术解决方案Technical solutions
本申请的主要目的在于提供一种文件处理方法、装置、设备及计算机可读存储介质,旨在通过配置的方式实现文件的自动化处理,以减少开发人员的工作量、提高开发效率。The main purpose of this application is to provide a file processing method, device, equipment, and computer-readable storage medium, aiming to realize automatic file processing through configuration, so as to reduce the workload of developers and improve development efficiency.
为实现上述目的,本申请提供一种文件处理方法,所述文件处理方法包括:In order to achieve the above objective, the present application provides a file processing method, the file processing method includes:
确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;After determining that the file processing request is received, obtain the file to be processed and its file name according to the file processing request, and obtain corresponding configuration information from the preset configuration table according to the file name;
根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;Performing conversion processing on the file to be processed according to the configuration information and the first preset rule to obtain a Java object to be processed;
根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;According to the processing class name in the configuration information, call the corresponding executor to process the to-be-processed Java object to obtain the processing result Java object;
根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。Transform the processing result Java object according to the configuration information and the second preset rule to obtain a processing result file.
在一实施例中,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:In an embodiment, the configuration information includes the target conversion Java class name, line beginning identifier, separator, the mapping relationship between the first array element and the first target conversion attribute, and the configuration information is based on the configuration information and the first target conversion attribute. The step of converting the file to be processed by a preset rule to obtain a Java object to be processed includes:
根据所述行首标识将所述待处理文件拆分成多条数据;Split the file to be processed into multiple pieces of data according to the line header identifier;
根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;Split the multiple pieces of data into arrays according to the separator, traverse the split arrays, and read the first array element;
获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;Acquire the type of the first target conversion attribute, and call the first format converter corresponding to the type of the first target conversion attribute to perform format conversion on the read first array element to obtain the first array after format conversion element;
根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。According to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, the first array elements after the format conversion are respectively mapped to the corresponding first target conversion attributes to obtain The pending Java object.
在一实施例中,所述根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象的步骤之前,还包括:In an embodiment, the first array elements after the format conversion are respectively mapped to corresponding ones according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute In the first target conversion attribute, before the step of obtaining the to-be-processed Java object, it also includes:
检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;Detecting whether the number of read first array elements is equal to the number of first target conversion attributes;
确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;After determining that the number of read first array elements is equal to the number of the first target conversion attributes, perform the step of: converting the Java class name according to the target and the mapping between the first array elements and the first target conversion attributes Relationship, mapping the first array elements after the format conversion to the corresponding first target conversion attributes to obtain the Java object to be processed;
确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量后,检测所述配置信息中的严格模式为严格还是非严格;After determining that the number of read first array elements is not equal to the number of the first target conversion attributes, detecting whether the strict mode in the configuration information is strict or non-strict;
确定所述配置信息中的严格模式为严格后,生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;After determining that the strict mode in the configuration information is strict, generate corresponding exception reminding information and return it to the client corresponding to the file processing request;
确定所述配置信息中的严格模式非严格后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。After determining that the strict mode in the configuration information is not strict, perform the step of: according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, the second format converted An array element is respectively mapped to the corresponding first target conversion attribute to obtain the Java object to be processed.
在一实施例中,所述配置信息还包括第二数组元素与第二目标转换属性之间的映射关系,所述根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件的步骤包括:In an embodiment, the configuration information further includes a mapping relationship between a second array element and a second target conversion attribute, and the processing result Java object is converted according to the configuration information and a second preset rule Processing to obtain the processing result file includes:
提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;Extract the attribute information corresponding to each second target conversion attribute in the processing result Java object, and call the second format converter corresponding to the type of the second target conversion attribute to perform format conversion on the attribute information to obtain Second array element;
按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。The second array element, the line header identifier, and the separator are spliced in a preset format to obtain a processing result file.
在一实施例中,所述配置信息还包括文件限定大小,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤之前,还包括:In an embodiment, the configuration information further includes a file limit size, and before the step of converting the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed, the method further includes :
获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;Acquiring the file size of the file to be processed, and detecting whether the file size exceeds the file limit size;
确定所述文件大小已超过所述文件限定大小后,根据所述文件限定大小对所述待处理文件进行拆分;After determining that the file size has exceeded the file limit size, split the file to be processed according to the file limit size;
所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:The step of converting the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed includes:
根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。According to the configuration information and the first preset rule, the split files to be processed are sequentially converted to obtain the Java objects to be processed.
在一实施例中,所述根据所述文件名称从预设配置表中获取对应的配置信息的步骤包括:In an embodiment, the step of obtaining corresponding configuration information from a preset configuration table according to the file name includes:
根据所述文件名称确定所述待处理文件的文件类型;Determining the file type of the file to be processed according to the file name;
根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。According to the file type and the mapping relationship between the preset file type and the configuration name, the target configuration name is determined, and the configuration information corresponding to the target configuration name is obtained from the preset configuration table.
在一实施例中,所述文件处理方法还包括:In an embodiment, the file processing method further includes:
在接收到配置表修改请求时,基于所述配置表修改请求显示对应的配置信息修改界面;When receiving a configuration table modification request, display a corresponding configuration information modification interface based on the configuration table modification request;
接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。Receive a configuration table modification instruction triggered by a user based on the configuration information modification interface, and update the preset configuration table according to the configuration table modification instruction.
此外,为实现上述目的,本申请还提供一种文件处理装置,所述文件处理装置包括:In addition, in order to achieve the above objective, the present application also provides a file processing device, the file processing device includes:
信息获取模块,设置为确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;The information obtaining module is configured to obtain the file to be processed and its file name according to the file processing request after confirming that the file processing request is received, and obtain corresponding configuration information from the preset configuration table according to the file name;
第一转换模块,设置为根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;The first conversion module is configured to perform conversion processing on the file to be processed according to the configuration information and the first preset rule to obtain a Java object to be processed;
处理模块,设置为根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;The processing module is configured to call the corresponding executor to process the to-be-processed Java object according to the processing class name in the configuration information to obtain the processing result Java object;
第二转换模块,设置为根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。The second conversion module is configured to perform conversion processing on the processing result Java object according to the configuration information and a second preset rule to obtain a processing result file.
此外,为实现上述目的,本申请还提供一种文件处理设备,所述文件处理设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的文件处理程序,所述文件处理程序被所述处理器执行时实现如上所述的文件处理方法的步骤。In addition, in order to achieve the above object, the present application also provides a file processing device, the file processing device includes: a memory, a processor, and a file processing program stored in the memory and running on the processor, so When the file processing program is executed by the processor, the steps of the file processing method described above are implemented.
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有文件处理程序,所述文件处理程序被处理器执行时实现如上所述的文件处理方法的步骤。In addition, in order to achieve the above object, the present application also provides a computer-readable storage medium having a file processing program stored on the computer-readable storage medium, and the file processing program is executed by a processor to realize the file processing as described above. Method steps.
本申请提供一种文件处理方法、装置、设备及计算机可读存储介质,接收到文件处理请求时,先根据该文件处理请求获取待处理文件及其文件名称,并根据文件名称从预设配置表中获取对应的配置信息;然后,根据配置信息和第一预设规则对待处理文件进行转换处理,得到待处理Java对象,进而根据配置信息中的处理类名,调用对应的执行器对待处理Java对象进行处理,得到处理结果Java对象;最后,根据配置信息和第二预设规则对处理结果Java对象进行转换处理,得到处理结果文件。通过上述方式,本申请通过配置的方式实现文件的自动化处理,相比于现有技术中通过写代码的方式对文件进行自动化处理,本申请在新增处理文件或文件更改时,无需开发人员新增或修改大量的代码,从而可减少开发人员的工作量、提高开发效率。This application provides a file processing method, device, equipment, and computer-readable storage medium. When a file processing request is received, the file to be processed and its file name are first obtained according to the file processing request, and the file name is obtained from a preset configuration table The corresponding configuration information is obtained in the configuration information; then, the file to be processed is converted according to the configuration information and the first preset rule to obtain the Java object to be processed, and then the corresponding executor is called according to the processing class name in the configuration information. The processing is performed to obtain the processing result Java object; finally, the processing result Java object is converted according to the configuration information and the second preset rule to obtain the processing result file. Through the above method, this application realizes the automatic processing of files through configuration. Compared with the automatic processing of files by writing code in the prior art, this application does not require new developers to process new files or file changes. Adding or modifying a large amount of code can reduce the workload of developers and improve development efficiency.
附图说明Description of the drawings
图1为本申请实施例方案涉及的硬件运行环境的设备结构示意图;FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the application;
图2为本申请文件处理方法第一实施例的流程示意图;FIG. 2 is a schematic flowchart of the first embodiment of the application file processing method;
图3为本申请文件处理装置第一实施例的功能模块示意图。FIG. 3 is a schematic diagram of functional modules of the first embodiment of the file processing apparatus of this application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics, and advantages of the purpose of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
本申请的实施方式Implementation of this application
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It should be understood that the specific embodiments described here are only used to explain the application, and are not used to limit the application.
参照图1,图1为本申请实施例方案涉及的硬件运行环境的设备结构示意图。Referring to FIG. 1, FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the application.
本申请实施例文件处理设备可以是智能手机,也可以是PC(Personal Computer,个人计算机)、平板电脑、便携计算机等终端设备。The document processing device in the embodiment of this application can be a smart phone or a PC (Personal Computer, personal computer), tablet computer, portable computer and other terminal equipment.
如图1所示,该文件处理设备可以包括:处理器1001,例如CPU,通信总线1002,用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如Wi-Fi接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 1, the file processing device may include a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to implement connection and communication between these components. The user interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a Wi-Fi interface). The memory 1005 can be a high-speed RAM memory or a stable memory (non-volatile memory), such as disk storage. Optionally, the memory 1005 may also be a storage device independent of the foregoing processor 1001.
本领域技术人员可以理解,图1中示出的文件处理设备结构并不构成对文件处理设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art can understand that the structure of the file processing device shown in FIG. 1 does not constitute a limitation on the file processing device, and may include more or less components than shown in the figure, or a combination of certain components, or different components Layout.
如图1所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及文件处理程序。As shown in FIG. 1, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a file processing program.
在图1所示的终端中,网络接口1004主要用于连接后台服务器,与后台服务器进行数据通信;用户接口1003主要用于连接客户端,与客户端进行数据通信;而处理器1001可以用于调用存储器1005中存储的文件处理程序,并执行以下操作:In the terminal shown in FIG. 1, the network interface 1004 is mainly used to connect to a back-end server and communicate with the back-end server; the user interface 1003 is mainly used to connect to a client and communicate with the client; and the processor 1001 can be used to Call the file processing program stored in the memory 1005 and perform the following operations:
确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;After determining that the file processing request is received, obtain the file to be processed and its file name according to the file processing request, and obtain corresponding configuration information from the preset configuration table according to the file name;
根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;Performing conversion processing on the file to be processed according to the configuration information and the first preset rule to obtain a Java object to be processed;
根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;According to the processing class name in the configuration information, call the corresponding executor to process the to-be-processed Java object to obtain the processing result Java object;
根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。Transform the processing result Java object according to the configuration information and the second preset rule to obtain a processing result file.
进一步地,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:Further, the configuration information includes the target conversion Java class name, line beginning identifier, separator, the mapping relationship between the first array element and the first target conversion attribute, and the processor 1001 can call the file processing program stored in the memory 1005 , Also do the following:
根据所述行首标识将所述待处理文件拆分成多条数据;Split the file to be processed into multiple pieces of data according to the line header identifier;
根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;Split the multiple pieces of data into arrays according to the separator, traverse the split arrays, and read the first array element;
获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;Acquire the type of the first target conversion attribute, and call the first format converter corresponding to the type of the first target conversion attribute to perform format conversion on the read first array element to obtain the first array after format conversion element;
根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。According to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, the first array elements after the format conversion are respectively mapped to the corresponding first target conversion attributes to obtain The pending Java object.
进一步地,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:Further, the processor 1001 may call a file processing program stored in the memory 1005, and also perform the following operations:
检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;Detecting whether the number of read first array elements is equal to the number of first target conversion attributes;
确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;It is determined that the number of the first array elements obtained by reading is equal to the number of the first target conversion attributes, and the execution step: according to the target conversion Java class name and the mapping relationship between the first array elements and the first target conversion attributes , Map the first array elements after the format conversion to the corresponding first target conversion attributes respectively to obtain the to-be-processed Java object;
确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量,检测所述配置信息中的严格模式为严格还是非严格;Determining that the number of read first array elements is not equal to the number of first target conversion attributes, and detecting whether the strict mode in the configuration information is strict or non-strict;
确定所述配置信息中的严格模式为严格后,生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;After determining that the strict mode in the configuration information is strict, generate corresponding exception reminding information and return it to the client corresponding to the file processing request;
确定所述配置信息中的严格模式为非严格后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。After determining that the strict mode in the configuration information is non-strict, perform the step: according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, the format converted The first array elements are respectively mapped to the corresponding first target conversion attributes to obtain the to-be-processed Java object.
进一步地,所述配置信息还包括第二数组元素与第二目标转换属性之间的映射关系,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:Further, the configuration information further includes the mapping relationship between the second array element and the second target conversion attribute, and the processor 1001 may call the file processing program stored in the memory 1005, and further perform the following operations:
提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;Extract the attribute information corresponding to each second target conversion attribute in the processing result Java object, and call the second format converter corresponding to the type of the second target conversion attribute to perform format conversion on the attribute information to obtain Second array element;
按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。The second array element, the line header identifier, and the separator are spliced in a preset format to obtain a processing result file.
进一步地,所述配置信息还包括文件限定大小,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:Further, the configuration information also includes a limited file size, and the processor 1001 may call a file processing program stored in the memory 1005, and also perform the following operations:
获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;Acquiring the file size of the file to be processed, and detecting whether the file size exceeds the file limit size;
确定所述文件大小已超过所述文件限定大小后,根据所述文件限定大小对所述待处理文件进行拆分;After determining that the file size has exceeded the file limit size, split the file to be processed according to the file limit size;
所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:The step of converting the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed includes:
根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。According to the configuration information and the first preset rule, the split files to be processed are sequentially converted to obtain the Java objects to be processed.
进一步地,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:Further, the processor 1001 may call a file processing program stored in the memory 1005, and also perform the following operations:
根据所述文件名称确定所述待处理文件的文件类型;Determining the file type of the file to be processed according to the file name;
根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。According to the file type and the mapping relationship between the preset file type and the configuration name, the target configuration name is determined, and the configuration information corresponding to the target configuration name is obtained from the preset configuration table.
进一步地,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:Further, the processor 1001 may call a file processing program stored in the memory 1005, and also perform the following operations:
接收到配置表修改请求,基于所述配置表修改请求显示对应的配置信息修改界面;After receiving the configuration table modification request, display the corresponding configuration information modification interface based on the configuration table modification request;
接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。Receive a configuration table modification instruction triggered by a user based on the configuration information modification interface, and update the preset configuration table according to the configuration table modification instruction.
基于上述硬件结构,提出本申请文件处理方法的各实施例。Based on the above hardware structure, various embodiments of the file processing method of the present application are proposed.
本申请提供一种文件处理方法。This application provides a file processing method.
参照图2,图2为本申请文件处理方法第一实施例的流程示意图。Referring to FIG. 2, FIG. 2 is a schematic flowchart of a first embodiment of a file processing method of this application.
在本实施例中,该文件处理方法包括:In this embodiment, the file processing method includes:
步骤S10,确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;Step S10, after determining that the file processing request is received, obtain the file to be processed and its file name according to the file processing request, and obtain corresponding configuration information from a preset configuration table according to the file name;
本实施例的文件处理方法是由文件处理设备实现的,该设备以服务器为例进行说明。在本实施例中,服务器接收到文件处理请求时,先根据该文件处理请求获取待处理文件及其文件名称,并根据文件名称从预设配置表中获取对应的配置信息。The file processing method in this embodiment is implemented by a file processing device, and the device is described by taking a server as an example. In this embodiment, when the server receives the file processing request, it first obtains the file to be processed and its file name according to the file processing request, and obtains corresponding configuration information from the preset configuration table according to the file name.
其中,步骤“根据所述文件名称从预设配置表中获取对应的配置信息”包括:Wherein, the step of "obtaining corresponding configuration information from the preset configuration table according to the file name" includes:
步骤a1,根据所述文件名称确定所述待处理文件的文件类型;Step a1: Determine the file type of the file to be processed according to the file name;
步骤a2,根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。Step a2: Determine the target configuration name according to the file type and the mapping relationship between the preset file type and the configuration name, and obtain configuration information corresponding to the target configuration name from the preset configuration table.
在获取到待处理文件的文件名称之后,可以先根据文件名称确定待处理文件的文件类型,然后根据文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与该目标配置名称对应的配置信息。其中,该预设配置表中可以包括但不限于配置名称、行首标识、分隔符、目标转换Java类名、第一数组元素与第一目标转换属性之间的映射关系(即读文件要转换的Java类的属性及其与第一数组元素之间的映射关系)、第二数组元素与第二目标转换属性之间的映射关系(即写文件要转换的Java类的属性及其与第二数组元素之间的映射关系)、处理类名、严格模式、文件限定大小和事务处理大小等字段。对应的,每一条配置信息包括上述各字段对应的配置信息,需要说明的是,由于不同行首标识所对应的配置信息有所不同,因此一个目标配置名称可以对应多条配置信息。例如,对于文件类型是Batch Performance Test(批量性能测试)的待处理文件,预设配置表中会包含4条不同的配置信息,各条配置信息中的行首标识分别为H、X、Y、Z,用于后续在识别到待处理文件每一行开头的字符后,采用与该字符(即行首标识)对应的配置信息将各行数据自动反序列化为一个Java对象。After obtaining the file name of the file to be processed, the file type of the file to be processed can be determined first according to the file name, and then the target configuration name is determined according to the file type and the mapping relationship between the preset file type and the configuration name, and The configuration information corresponding to the target configuration name is obtained from the preset configuration table. Among them, the preset configuration table may include, but is not limited to, the configuration name, line header identifier, separator, target conversion Java class name, the mapping relationship between the first array element and the first target conversion attribute (that is, the The properties of the Java class and its mapping relationship with the first array element), the mapping relationship between the second array element and the second target conversion property (that is, the property of the Java class to be converted in the write file and its relationship with the second The mapping relationship between array elements), processing class name, strict mode, file limit size and transaction processing size and other fields. Correspondingly, each piece of configuration information includes the configuration information corresponding to the above-mentioned fields. It should be noted that because the configuration information corresponding to different line header identifiers is different, one target configuration name can correspond to multiple pieces of configuration information. For example, for the file type is Batch Performance Test (batch performance test) files to be processed. The preset configuration table will contain 4 different configuration information. The line headers in each configuration information are H, X, Y, and Z respectively, which are used for subsequent identification After reaching the character at the beginning of each line of the file to be processed, the configuration information corresponding to the character (that is, the line beginning identifier) is used to automatically deserialize each line of data into a Java object.
当然,可以理解,在具体实施例中,还可以直接建立文件名称与配置名称之间的映射关系,从而根据文件名称、文件名称与配置名称之间的映射关系直接确定得到目标配置名称,进而从预设配置表中获取与该目标配置名称对应的配置信息。Of course, it can be understood that in a specific embodiment, the mapping relationship between the file name and the configuration name can also be directly established, so as to directly determine the target configuration name according to the mapping relationship between the file name, the file name and the configuration name, and then from The configuration information corresponding to the target configuration name is obtained from the preset configuration table.
步骤S20,根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;Step S20: Perform conversion processing on the file to be processed according to the configuration information and the first preset rule to obtain a Java object to be processed;
在获取到待处理文件和配置信息之后,根据配置信息和第一预设规则对待处理文件进行转换处理,得到待处理Java对象。需要说明的是,一行数据对应一个Java对象,待处理文件包括多条(行)数据时,对应的待处理Java对象也有多个。After the file to be processed and the configuration information are acquired, the file to be processed is converted according to the configuration information and the first preset rule to obtain the Java object to be processed. It should be noted that a row of data corresponds to one Java object, and when the file to be processed includes multiple (rows) of data, there are also multiple corresponding Java objects to be processed.
其中,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,步骤S20包括:Wherein, the configuration information includes the target conversion Java class name, line header identifier, separator, the mapping relationship between the first array element and the first target conversion attribute, and step S20 includes:
步骤b1,根据所述行首标识将所述待处理文件拆分成多条数据;Step b1: Split the file to be processed into multiple pieces of data according to the line header identifier;
对象的反序列化(把字节序列恢复为对象的过程)的具体过程如下:先根据行首标识将待处理文件拆分成多条数据,例如,对于下列文件:The specific process of object deserialization (the process of restoring the byte sequence to the object) is as follows: First, the file to be processed is split into multiple pieces of data according to the line header identification, for example, for the following files:
H|123|333H|123|333
B|22|ttB|22|tt
B|22|ttB|22|tt
B|22|ttB|22|tt
B|22|ttB|22|tt
F|333|ttF|333|tt
可根据行首标识拆分得到6条数据。6 pieces of data can be obtained by splitting according to the line header identification.
步骤b2,根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;Step b2, split the multiple pieces of data into an array according to the separator, and traverse the split array, and read the first array element;
然后,根据分隔符将多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素。例如,对于H|123|333这一条数据,可得到第一数组元素分别为123、333。Then, split multiple pieces of data into arrays according to the separator, and traverse the split array to read the first array element. For example, for the piece of data H|123|333, the first array elements can be obtained as 123 and 333 respectively.
步骤b3,获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;Step b3: Obtain the type of the first target conversion attribute, and call the first format converter corresponding to the type of the first target conversion attribute to perform format conversion on the read first array element to obtain the converted format First array element;
然后,获取第一目标转换属性的类型,并调用与第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素。例如,第一目标转换属性包括age(年龄)和date(日期)时,可分别调用字符串转整数类的格式转化器和字符串转日期类的格式转换器,以进行格式转换。Then, the type of the first target conversion attribute is obtained, and the first format converter corresponding to the type of the first target conversion attribute is called to perform format conversion on the read first array element to obtain the first array after the format conversion element. For example, when the first target conversion attribute includes age (age) and date (date), a string-to-integer format converter and a string-to-date format converter can be called respectively to perform format conversion.
步骤b4,根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。Step b4, according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, map the first array element after format conversion to the corresponding first target conversion attribute, respectively , Get the Java object to be processed.
然后,根据目标转换Java类名和第一数组元素与第一目标转换属性之间的映射关系,将格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。例如,上述例中,对于H|123|333这一条数据,如以H开头的行首标识,对应的目标准换Java类为File Coop Open Confirm Detl类。在拆分后成数组后,读取得到第一数组元素123、333,若第一目标转换属性包括field1、field2,在格式转换后,将第一数组元素映射至第一目标转换属性中,即123->filed1,333->filed2,转换结束后,可得到一个设置好数据的File Coop Open Confirm Detl对象,即待处理Java对象。Then, according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, the first array elements after format conversion are respectively mapped to the corresponding first target conversion attributes to obtain the Java object to be processed . For example, in the above example, for the H|123|333 piece of data, such as the line header identifier starting with H, the corresponding target standard is changed to the Java class File Coop Open Confirm Detl class. After splitting into an array, read the first array elements 123 and 333. If the first target conversion attribute includes field1 and field2, after format conversion, map the first array element to the first target conversion attribute, that is 123->filed1, 333->filed2, after the conversion, you can get a File with the data set The Coop Open Confirm Detl object is the Java object to be processed.
步骤S30,根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;Step S30: According to the processing class name in the configuration information, call the corresponding executor to process the to-be-processed Java object to obtain the processing result Java object;
在得到待处理Java对象之后,根据配置信息中的处理类名,调用对应的执行器对待处理Java对象进行处理,得到处理结果Java对象。其中,执行器用于执行业务逻辑,例如,得到的Java对象为Fund Transfer(资金转移)对象,可根据处理类名确定对应的执行器是Fund Transfer Server.doTransfer,那么会自动调用这个执行器去处理这个Fund Transfer对象来完成转账业务,进而得到处理结果,该处理结果也为Java对象,记作处理结果Java对象。After obtaining the Java object to be processed, according to the processing class name in the configuration information, call the corresponding executor to process the Java object to be processed to obtain the processing result Java object. Among them, the executor is used to execute business logic. For example, the obtained Java object is a Fund Transfer object, and the corresponding executor can be determined according to the processing class name as Fund Transfer Server.doTransfer, then the executor will be automatically called to process the Fund Transfer object to complete the transfer business, and then get the processing result. The processing result is also a Java object, which is recorded as the processing result Java object.
步骤S40,根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。Step S40: Perform conversion processing on the processing result Java object according to the configuration information and the second preset rule to obtain a processing result file.
在经处理得到处理结果Java对象之后,根据配置信息和第二预设规则对处理结果Java对象进行转换处理,得到处理结果文件。即,需将处理结果Java对象转换成对应的字符串,以便于回写结果文件。此过程涉及对象的序列化,即把对象转换为字节序列。After the processing result Java object is obtained through processing, the processing result Java object is converted according to the configuration information and the second preset rule to obtain the processing result file. That is, the processing result Java object needs to be converted into a corresponding character string in order to write back the result file. This process involves the serialization of the object, that is, converting the object into a sequence of bytes.
其中,所述配置信息还包括第二数组元素与第二目标转换属性之间的映射关系,步骤S40包括:Wherein, the configuration information further includes the mapping relationship between the second array element and the second target conversion attribute, and step S40 includes:
步骤c1,提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;Step c1: Extract the attribute information corresponding to each second target conversion attribute in the processing result Java object, and call a second format converter corresponding to the type of the second target conversion attribute to format the attribute information Convert to get the second array element;
具体的,提取处理处理结果Java对象中各第二目标转换属性所对应的属性信息,然后调用与该第二目标转换属性的类型对应的第二格式转换器,对属性信息进行格式转换,得到第二数组元素。其中,第二格式转换器即为对象类转字符串类型的格式转换器,如整数类转字符串的格式转化器、日期类转字符串的格式转换器。Specifically, the attribute information corresponding to each second target conversion attribute in the processing result Java object is extracted, and then the second format converter corresponding to the type of the second target conversion attribute is called to perform format conversion on the attribute information to obtain the first Two array elements. Among them, the second format converter is a format converter that converts an object type to a string type, such as a format converter that converts an integer type to a string, and a date type to a string format converter.
步骤c2,按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。Step c2, splicing the second array element, the line header identifier, and the separator according to a preset format to obtain a processing result file.
然后,按预设格式对第二数组元素、行首标识、分隔符进行拼接,得到处理结果文件。其中,预设格式可以是预先设定的,可以类似于待处理文件的格式,例如,得到第二数组元素为222、234,若配置信息中的行首标识为B,分隔符为|,即可拼接得到B|222|234,在分别对各处理结果Java对象进行转换后,可得到多组第二数组元素,然后对各第二数组元素分别进行拼接,进而根据各拼接结果生成得到处理结果文件。Then, the second array element, line beginning identifier, and separator are spliced according to the preset format to obtain the processing result file. Among them, the preset format can be preset and can be similar to the format of the file to be processed. For example, if the second array element is 222 and 234, if the line header identifier in the configuration information is B and the separator is |, that is Can be spliced to get B|222|234. After each processing result Java object is converted, multiple sets of second array elements can be obtained, and then each second array element can be spliced separately, and then the processing results are generated according to the splicing results file.
本申请实施例提供一种文件处理方法,接收到文件处理请求时,先根据该文件处理请求获取待处理文件及其文件名称,并根据文件名称从预设配置表中获取对应的配置信息;然后,根据配置信息和第一预设规则对待处理文件进行转换处理,得到待处理Java对象,进而根据配置信息中的处理类名,调用对应的执行器对待处理Java对象进行处理,得到处理结果Java对象;最后,根据配置信息和第二预设规则对处理结果Java对象进行转换处理,得到处理结果文件。通过上述方式,本申请实施例中通过配置的方式实现文件的自动化处理,相比于现有技术中通过写代码的方式对文件进行自动化处理,本申请实施例在新增处理文件或文件更改时,无需开发人员新增或修改大量的代码,从而可减少开发人员的工作量、提高开发效率。The embodiment of the application provides a file processing method. When a file processing request is received, the file to be processed and its file name are first obtained according to the file processing request, and corresponding configuration information is obtained from a preset configuration table according to the file name; , Convert the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed, and then call the corresponding executor to process the Java object to be processed according to the processing class name in the configuration information to obtain the processing result Java object ; Finally, the processing result Java object is converted according to the configuration information and the second preset rule to obtain the processing result file. In the above manner, in the embodiment of the present application, the automatic processing of files is realized through configuration. Compared with the automatic processing of files by writing codes in the prior art, the embodiments of the present application will process newly added files or file changes. , No need for developers to add or modify a large amount of code, which can reduce the workload of developers and improve development efficiency.
进一步地,基于上述第一实施例,提出本申请文件处理方法的第二实施例。Further, based on the above-mentioned first embodiment, a second embodiment of the file processing method of this application is proposed.
基于上述第一实施例,在上述步骤b4之前,该文件处理方法还包括:Based on the foregoing first embodiment, before the foregoing step b4, the file processing method further includes:
步骤A,检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;Step A, detecting whether the number of read first array elements is equal to the number of first target conversion attributes;
在本实施例中,为保证根据待处理文件读取得到的第一数组元素可进行后续处理,在配置信息中还可以设置严格模式,进而根据严格模式、第一数组元素的数量及第一目标转换属性的数量,来确定是否可进一步进行后续的处理(即下一步骤S20)。其中,严格模式包括严格和非严格两种。具体的,在读取得到第一数组元素之后,检测读取得到的第一数组元素的数量是否等于第一目标转换属性的数量。In this embodiment, in order to ensure that the first array element read from the file to be processed can be subjected to subsequent processing, the strict mode can also be set in the configuration information, and then according to the strict mode, the number of first array elements and the first target The number of conversion attributes is used to determine whether further subsequent processing can be performed (ie, the next step S20). Among them, strict mode includes strict and non-strict. Specifically, after the first array element is read, it is detected whether the number of the read first array element is equal to the number of the first target conversion attribute.
确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量,执行步骤b4:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;It is determined that the number of read first array elements is equal to the number of the first target conversion attributes, and step b4 is performed: according to the target conversion Java class name and the mapping between the first array elements and the first target conversion attributes Relationship, mapping the first array elements after the format conversion to the corresponding first target conversion attributes to obtain the Java object to be processed;
确定读取得到的第一数组元素的数量等于第一目标转换属性的数量后,说明第一数据元素的数量足够,此时,可根据目标转换Java类名和第一数组元素与第一目标转换属性之间的映射关系,将格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象,进而执行后续的处理过程,具体的执行过程可参照上述第一实施例,此处不作赘述。After confirming that the number of first array elements read is equal to the number of first target conversion attributes, it indicates that the number of first data elements is sufficient. At this time, the Java class name and the first array element and the first target conversion attribute can be converted according to the target The mapping relationship between the first array elements after format conversion are respectively mapped to the corresponding first target conversion attributes to obtain the Java object to be processed, and then execute the subsequent processing process. For the specific execution process, refer to the first implementation above For example, I won’t repeat them here.
确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量后,执行步骤B:检测所述配置信息中的严格模式为严格还是非严格;After determining that the number of elements in the first array obtained is not equal to the number of the first target conversion attributes, perform step B: detecting whether the strict mode in the configuration information is strict or non-strict;
确定读取得到的第一数组元素的数量不等于第一目标转换属性的数量后,需进一步检测配置信息中的严格模式为严格还是非严格,以结合严格模式确定是否可执行下一步处理。After determining that the number of read first array elements is not equal to the number of first target conversion attributes, it is necessary to further check whether the strict mode in the configuration information is strict or non-strict, and combined with the strict mode to determine whether the next processing can be performed.
确定所述配置信息中的严格模式为严格,执行步骤C:生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;It is determined that the strict mode in the configuration information is strict, and step C is executed: corresponding abnormal reminder information is generated, and returned to the client corresponding to the file processing request;
确定配置信息中的严格模式为严格,无法执行下一步处理,此时,生成对应的异常提醒信息,并返回至与该文件处理请求对应的用户端。It is determined that the strict mode in the configuration information is strict, and the next processing cannot be performed. At this time, the corresponding abnormal reminder information is generated and returned to the client corresponding to the file processing request.
确定所述配置信息中的严格模式为非严格,执行步骤b4:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。It is determined that the strict mode in the configuration information is non-strict, and step b4 is executed: according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, the format converted The first array elements are respectively mapped to the corresponding first target conversion attributes to obtain the to-be-processed Java object.
确定配置信息中的严格模式为非严格,说明即使数量不相等,也可以继续执行下一步骤,即根据目标转换Java类名和第一数组元素与第一目标转换属性之间的映射关系,将格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象,进而执行后续的处理过程。需要说明的是,当读取得到的第一数组元素的数量不等于第一目标转换属性的数量,且严格模式为非严格模式时,需根据第一数组元素的数量和第一目标转换属性的数量进行映射。例如,若第一目标转换属性的数量为4个时,若第一数组元素的数量为5个,则只需映射前4个元素,若第一数组元素的数量为2个,则只需将这2个元素映射至对应你的第一目标转换属性中即可。Confirm that the strict mode in the configuration information is non-strict, which means that even if the numbers are not equal, you can continue to the next step, which is to change the format according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute The converted first array elements are respectively mapped to the corresponding first target conversion attributes to obtain the to-be-processed Java object, and then perform subsequent processing. It should be noted that when the number of read first array elements is not equal to the number of first target conversion attributes, and the strict mode is non-strict mode, it needs to be based on the number of first array elements and the first target conversion attribute. The quantity is mapped. For example, if the number of the first target conversion attribute is 4, if the number of the first array element is 5, only the first 4 elements need to be mapped, and if the number of the first array element is 2, then only the These two elements can be mapped to the conversion attribute corresponding to your first target.
进一步地,基于上述第一实施例,提出本申请文件处理方法的第三实施例。Further, based on the above-mentioned first embodiment, a third embodiment of the file processing method of this application is proposed.
基于上述第一实施例,所述配置信息还包括文件限定大小,在上述步骤S20之前,该文件处理方法还包括:Based on the foregoing first embodiment, the configuration information further includes a file limit size. Before the foregoing step S20, the file processing method further includes:
步骤D,获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;Step D: Obtain the file size of the file to be processed, and detect whether the file size exceeds the file limit size;
在本实施例中,配置信息还可以包括文件限定大小,该文件限定大小为一次限定处理的数据条数。在获取到待处理文件之后,可先获取该待处理文件的文件大小,其中,该文件大小是指待处理文件中所包括的数据总条数,具体的,可根据行首标识进行确定,文件每行具有一个行首标识,行首标识的个数即为数据总条数;当然也可以直接识别待处理文件的总行数,总行数即为数据总条数。然后,检测待处理文件的文件大小是否超过文件限定大小。In this embodiment, the configuration information may also include a limited file size, where the limited file size is the number of pieces of data that can be processed at one time. After obtaining the file to be processed, the file size of the file to be processed can be obtained first, where the file size refers to the total number of data included in the file to be processed. Specifically, it can be determined according to the line header identification. Each line has a line header identifier, the number of line header identifiers is the total number of data; of course, the total number of lines of the file to be processed can also be directly identified, and the total number of lines is the total number of data. Then, it is detected whether the file size of the file to be processed exceeds the file limit size.
确定所述文件大小已超过所述文件限定大小,执行步骤E:根据所述文件限定大小对所述待处理文件进行拆分;It is determined that the file size has exceeded the limited file size, and step E is performed: splitting the file to be processed according to the limited file size;
此时,步骤S20包括:At this time, step S20 includes:
根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。According to the configuration information and the first preset rule, the split files to be processed are sequentially converted to obtain the Java objects to be processed.
确定待处理文件的文件大小已超过文件限定大小,为避免因服务器压力过大、导致服务器的处理性能受限,可根据文件限定大小对待处理文件进行拆分,进而根据配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。进而执行后续步骤,具体的执行过程可参照上述第一实施例,此处不作赘述。Determine that the file size of the file to be processed has exceeded the file limit. In order to avoid the server's processing performance being limited due to excessive server pressure, the file to be processed can be split according to the file limit size, and then based on the configuration information and the first preset The rules sequentially convert the files to be processed after splitting to obtain the Java objects to be processed. Further, the subsequent steps are executed, and the specific execution process can refer to the above-mentioned first embodiment, which will not be repeated here.
确定所述文件大小未超过所述文件限定大小,执行步骤S20:根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。It is determined that the file size does not exceed the limited file size, and step S20 is executed: according to the configuration information and the first preset rule, the split files to be processed are sequentially converted to obtain the Java object to be processed.
确定待处理文件的文件大小未超过文件限定大小,无需对待处理文件进行拆分,直接处理即可,具体的,根据配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象,进而执行后续步骤,具体的执行过程可参照上述第一实施例,此处不作赘述。Make sure that the file size of the file to be processed does not exceed the file limit. You do not need to split the file to be processed, just process it directly. Specifically, according to the configuration information and the first preset rule, the files to be processed after splitting are converted in turn After processing, the Java object to be processed is obtained, and then the subsequent steps are executed. For the specific execution process, please refer to the above-mentioned first embodiment, which will not be repeated here.
通过上述方式,通过配置文件限定大小,在处理文件时,检测待处理文件的文件大小是否超过该文件限定大小,当超过时,则对待处理文件进行拆分处理,可避免服务器因压力过大而导致服务器的处理性能受限。Through the above method, the size of the configuration file is limited. When processing the file, it is detected whether the file size of the file to be processed exceeds the limited size of the file. When it exceeds, the file to be processed is split and processed, which can avoid the server from being overstressed. The processing performance of the server is limited.
进一步地,配置信息还可以包括事务提交大小,其中,事务提交大小是指处理时单次所限定的数据大小,对应的,在步骤S30之前,还可以检测所述待处理Java对象的大小是否超过所述事务提交大小,进而根据所述事务提交大小来控制单次处理的待处理Java对象的数据量。通过上述方式,也可以根据实际需要控制单次处理数量,避免服务器压力过大。Further, the configuration information may also include the transaction commit size, where the transaction commit size refers to the data size limited by a single time during processing. Correspondingly, before step S30, it can also be detected whether the size of the Java object to be processed exceeds The transaction commit size further controls the data volume of the Java object to be processed in a single processing according to the transaction commit size. Through the above method, the number of single processing can also be controlled according to actual needs to avoid excessive server pressure.
对应的,也可以采用上述类似的方式,限定单次转换的处理结果Java对象的数据量,以进一步避免因服务器压力过大、导致服务器的处理性能受限的情况发生。Correspondingly, the above-mentioned similar method can also be used to limit the data volume of the Java object of the processing result of a single conversion, so as to further avoid the situation that the server's processing performance is limited due to excessive server pressure.
进一步地,基于上述各实施例,提出本申请文件处理方法的第三实施例。Further, based on the foregoing embodiments, a third embodiment of the file processing method of this application is proposed.
在本实施例中,所述文件处理方法还包括:In this embodiment, the file processing method further includes:
步骤F,接收到配置表修改请求,基于所述配置表修改请求显示对应的配置信息修改界面;Step F, receiving a configuration table modification request, and displaying a corresponding configuration information modification interface based on the configuration table modification request;
步骤G,接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。Step G: Receive a configuration table modification instruction triggered by the user based on the configuration information modification interface, and update the preset configuration table according to the configuration table modification instruction.
在本实施例中,当有新的文件需自动处理、或原文件中发生了格式变化、或原文件中增加了新业务时,此时,工作人员只需新增配置信息、或修改原配置信息即可,无需开发一整套新的代码,也无需对原代码做大幅度的修改。具体的,当工作人员需要修改配置表时,可通过用户端(如手机、PC等)的对应软件或App(Application,应用程序)点击配置表修改选项,即可触发配置表修改请求,此时,服务器在接收到配置表修改请求时,基于该配置表修改请求显示对应的配置信息修改界面,工作人员可通过该配置信息修改界面输入修改信息,在输入完成后可触发配置表修改指令,此时,服务器在接收到用户基于该配置信息修改界面触发的配置表修改指令时,根据该配置表修改指令更新预设配置表。例如,对于部分配置信息的修改,可直接修改调整预设配置表中的相关配置信息,如分隔符、处理类名、映射关系、文件限定大小等。对于新增配置信息,只需在预设配置表中新增一行,添加对应的配置名称、目标转换Java类名、行首标识、分隔符、映射关系、处理类名等信息,再增加相关配置即可完成。In this embodiment, when there is a new file that needs to be processed automatically, or the format of the original file is changed, or a new service is added to the original file, at this time, the staff only needs to add configuration information or modify the original configuration The information is enough, no need to develop a whole set of new code, and no need to make substantial changes to the original code. Specifically, when the staff needs to modify the configuration table, they can click on the configuration table modification option through the corresponding software or App (Application) of the user terminal (such as mobile phone, PC, etc.) to trigger the configuration table modification request. When the server receives the configuration table modification request, it displays the corresponding configuration information modification interface based on the configuration table modification request. The staff can input the modification information through the configuration information modification interface, and the configuration table modification instruction can be triggered after the input is completed. When receiving the configuration table modification instruction triggered by the user based on the configuration information modification interface, the server updates the preset configuration table according to the configuration table modification instruction. For example, for the modification of part of the configuration information, you can directly modify and adjust the relevant configuration information in the preset configuration table, such as separators, processing class names, mapping relationships, file limit sizes, etc. For new configuration information, just add a new line in the preset configuration table, add the corresponding configuration name, target conversion Java class name, line beginning identification, separator, mapping relationship, processing class name and other information, and then add related configuration It's done.
通过上述方式,可便于工作人员对预设配置表中的配置信息进行更新,同时,基于配置的方式实现文件的自动化处理,无需开发人员新增或修改大量的代码,可减少开发人员的工作量,提高开发效率。Through the above method, it is convenient for the staff to update the configuration information in the preset configuration table. At the same time, the automatic processing of the file is realized based on the configuration method, without the developer adding or modifying a large amount of code, which can reduce the developer's workload , Improve development efficiency.
本申请还提供一种文件处理装置。The application also provides a file processing device.
参照图3,图3为本申请文件处理装置第一实施例的功能模块示意图。Referring to FIG. 3, FIG. 3 is a schematic diagram of the functional modules of the first embodiment of the file processing apparatus of this application.
如图3所示,所述文件处理装置包括:As shown in Fig. 3, the file processing device includes:
信息获取模块10,设置为接收文件处理请求,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;The information obtaining module 10 is configured to receive a file processing request, obtain a file to be processed and its file name according to the file processing request, and obtain corresponding configuration information from a preset configuration table according to the file name;
第一转换模块20,设置为根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;The first conversion module 20 is configured to perform conversion processing on the file to be processed according to the configuration information and a first preset rule to obtain a Java object to be processed;
处理模块30,设置为根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;The processing module 30 is configured to call the corresponding executor to process the to-be-processed Java object according to the processing class name in the configuration information to obtain the processing result Java object;
第二转换模块40,设置为根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。The second conversion module 40 is configured to perform conversion processing on the processing result Java object according to the configuration information and a second preset rule to obtain a processing result file.
进一步地,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,所述第一转换模块20包括:Further, the configuration information includes the target conversion Java class name, line beginning identifier, separator, the mapping relationship between the first array element and the first target conversion attribute, and the first conversion module 20 includes:
文件拆分单元,设置为根据所述行首标识将所述待处理文件拆分成多条数据;A file splitting unit, configured to split the file to be processed into multiple pieces of data according to the line header identifier;
元素读取单元,设置为根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;An element reading unit, configured to split the multiple pieces of data into an array according to the separator, traverse the split array, and read the first array element;
第一转换单元,设置为获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;The first conversion unit is configured to obtain the type of the first target conversion attribute, and call the first format converter corresponding to the type of the first target conversion attribute, and perform format conversion on the read first array element to obtain The first array element after format conversion;
元素映射单元,设置为根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。The element mapping unit is configured to map the first array elements after the format conversion to the corresponding first array elements respectively according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute In the target conversion property, the Java object to be processed is obtained.
进一步地,所述第一转换模块20还包括:Further, the first conversion module 20 further includes:
第一检测单元,设置为检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;The first detection unit is configured to detect whether the number of the read first array elements is equal to the number of the first target conversion attributes;
所述元素映射单元,还设置为所述第一检测确定单元确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量后,根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;The element mapping unit is further configured to: after the first detection and determination unit determines that the number of read first array elements is equal to the number of the first target conversion attribute, convert the Java class name and the first target conversion attribute according to the target A mapping relationship between array elements and first target conversion attributes, mapping the first array elements after the format conversion to the corresponding first target conversion attributes to obtain the Java object to be processed;
第二检测单元,设置为所述第一检测确定单元确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量,检测所述配置信息中的严格模式为严格还是非严格;The second detection unit is configured so that the first detection and determination unit determines that the number of read first array elements is not equal to the number of the first target conversion attribute, and detects whether the strict mode in the configuration information is strict or non strict;
异常提醒单元,设置为所述第二检测单元确定所述配置信息中的严格模式为严格后,生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;An abnormality reminder unit, configured to generate corresponding abnormality reminder information after the second detection unit determines that the strict mode in the configuration information is strict, and return to the client corresponding to the file processing request;
所述元素映射单元,还设置为所述第二检测单元确定所述配置信息中的严格模式为非严格后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。The element mapping unit is further configured to: after the second detection unit determines that the strict mode in the configuration information is non-strict, execute the step of: converting the Java class name and the first array element and the first target according to the target The mapping relationship between the conversion attributes is to map the first array elements after the format conversion to the corresponding first target conversion attributes to obtain the Java object to be processed.
进一步地,所述第二转换模块40包括:Further, the second conversion module 40 includes:
第二转换单元,设置为提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;The second conversion unit is configured to extract attribute information corresponding to each second target conversion attribute in the processing result Java object, and call a second format converter corresponding to the type of the second target conversion attribute, to The attribute information is formatted to obtain the second array element;
拼接单元,设置为按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。The splicing unit is configured to splice the second array element, the line header identifier, and the separator in a preset format to obtain a processing result file.
进一步地,所述配置信息还包括文件限定大小,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤之前,所述文件处理装置还包括:Further, the configuration information further includes a file limit size, and before the step of converting the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed, the file processing device Also includes:
大小检测模块,设置为获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;A size detection module, configured to obtain the file size of the file to be processed, and detect whether the file size exceeds the file limit size;
文件拆分模块,设置为所述大小检测模块确定所述文件大小已超过所述文件限定大小后,根据所述文件限定大小对所述待处理文件进行拆分;A file splitting module configured to split the file to be processed according to the limited file size after the size detection module determines that the file size has exceeded the limited file size;
所述第一转换模块,还设置为根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。The first conversion module is further configured to sequentially perform conversion processing on the split files to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed.
进一步地,所述信息获取模块10包括:Further, the information acquisition module 10 includes:
类型确定单元,设置为根据所述文件名称确定所述待处理文件的文件类型;The type determining unit is configured to determine the file type of the file to be processed according to the file name;
信息获取单元,设置为根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。The information obtaining unit is configured to determine the target configuration name according to the file type and the mapping relationship between the preset file type and the configuration name, and obtain configuration information corresponding to the target configuration name from the preset configuration table.
进一步地,所述文件处理装置还包括:Further, the file processing device further includes:
显示模块,设置为在接收到配置表修改请求后,基于所述配置表修改请求显示对应的配置信息修改界面;The display module is configured to display the corresponding configuration information modification interface based on the configuration table modification request after receiving the configuration table modification request;
更新模块,设置为接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。The update module is configured to receive a configuration table modification instruction triggered by a user based on the configuration information modification interface, and update the preset configuration table according to the configuration table modification instruction.
其中,上述文件处理装置中各个模块的功能实现与上述文件处理方法实施例中各步骤相对应,其功能和实现过程在此处不再一一赘述。Among them, the function realization of each module in the above-mentioned file processing apparatus corresponds to each step in the above-mentioned file processing method embodiment, and the functions and realization processes thereof will not be repeated here.
本申请还提供一种计算机可读存储介质,该计算机可读存储介质上存储有文件处理程序,所述文件处理程序被处理器执行时实现如以上任一项实施例所述的文件处理方法的步骤。The present application also provides a computer-readable storage medium having a file processing program stored on the computer-readable storage medium, and when the file processing program is executed by a processor, the file processing method as described in any of the above embodiments is implemented step.
本申请计算机可读存储介质的具体实施例与上述文件处理方法各实施例基本相同,在此不作赘述。The specific embodiments of the computer-readable storage medium of this application are basically the same as the embodiments of the above-mentioned file processing method, and will not be repeated here.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。It should be noted that in this article, the terms "include", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements not only includes those elements, It also includes other elements not explicitly listed, or elements inherent to the process, method, article, or system. If there are no more restrictions, the element defined by the sentence "including a..." does not exclude the existence of other identical elements in the process, method, article or system that includes the element.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the foregoing embodiments of the present application are only for description, and do not represent the advantages and disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the method of the above embodiments can be implemented by means of software plus the necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is better.的实施方式。 Based on this understanding, the technical solution of this application essentially or the part that contributes to the existing technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM/RAM) as described above. , Magnetic disk, optical disk), including several instructions to make a terminal device (can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the method described in each embodiment of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above are only preferred embodiments of this application, and do not limit the scope of this application. Any equivalent structure or equivalent process transformation made using the content of the description and drawings of this application, or directly or indirectly used in other related technical fields , The same reason is included in the scope of patent protection of this application.

Claims (10)

  1. 一种文件处理方法,其中,所述文件处理方法包括:A file processing method, wherein the file processing method includes:
    确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;After determining that the file processing request is received, obtain the file to be processed and its file name according to the file processing request, and obtain corresponding configuration information from the preset configuration table according to the file name;
    根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;Performing conversion processing on the file to be processed according to the configuration information and the first preset rule to obtain a Java object to be processed;
    根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;According to the processing class name in the configuration information, call the corresponding executor to process the to-be-processed Java object to obtain the processing result Java object;
    根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。Transform the processing result Java object according to the configuration information and the second preset rule to obtain a processing result file.
  2. 如权利要求1所述的文件处理方法,其中,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:The file processing method according to claim 1, wherein the configuration information includes a target conversion Java class name, a line header identifier, a separator, a mapping relationship between the first array element and the first target conversion attribute, and the The step of converting the file to be processed by the configuration information and the first preset rule to obtain the Java object to be processed includes:
    根据所述行首标识将所述待处理文件拆分成多条数据;Split the file to be processed into multiple pieces of data according to the line header identifier;
    根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;Split the multiple pieces of data into arrays according to the separator, traverse the split arrays, and read the first array element;
    获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;Acquire the type of the first target conversion attribute, and call the first format converter corresponding to the type of the first target conversion attribute to perform format conversion on the read first array element to obtain the first array after format conversion element;
    根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。According to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, the first array elements after the format conversion are respectively mapped to the corresponding first target conversion attributes to obtain The pending Java object.
  3. 如权利要求2所述的文件处理方法,其中,所述根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象的步骤之前,还包括:The file processing method according to claim 2, wherein the first format converted according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute The array elements are respectively mapped to the corresponding first target conversion attributes, and before the step of obtaining the to-be-processed Java object, it also includes:
    检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;Detecting whether the number of read first array elements is equal to the number of first target conversion attributes;
    确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;After determining that the number of read first array elements is equal to the number of the first target conversion attributes, perform the step of: converting the Java class name according to the target and the mapping between the first array elements and the first target conversion attributes Relationship, mapping the first array elements after the format conversion to the corresponding first target conversion attributes to obtain the Java object to be processed;
    确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量后,检测所述配置信息中的严格模式为严格还是非严格;After determining that the number of read first array elements is not equal to the number of the first target conversion attributes, detecting whether the strict mode in the configuration information is strict or non-strict;
    确定所述配置信息中的严格模式为严格后,生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;After determining that the strict mode in the configuration information is strict, generate corresponding exception reminding information and return it to the client corresponding to the file processing request;
    确定所述配置信息中的严格模式非严格后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。After determining that the strict mode in the configuration information is not strict, perform the step of: according to the target conversion Java class name and the mapping relationship between the first array element and the first target conversion attribute, the second format converted An array element is respectively mapped to the corresponding first target conversion attribute to obtain the Java object to be processed.
  4. 如权利要求2所述的文件处理方法,其中,所述配置信息还包括第二数组元素与第二目标转换属性之间的映射关系,所述根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件的步骤包括:The file processing method according to claim 2, wherein the configuration information further includes a mapping relationship between a second array element and a second target conversion attribute, and the configuration information and the second preset rule The processing result Java object is converted to obtain the processing result file. The steps include:
    提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;Extract the attribute information corresponding to each second target conversion attribute in the processing result Java object, and call the second format converter corresponding to the type of the second target conversion attribute to perform format conversion on the attribute information to obtain Second array element;
    按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。The second array element, the line header identifier, and the separator are spliced in a preset format to obtain a processing result file.
  5. 如权利要求1所述的文件处理方法,其中,所述配置信息还包括文件限定大小,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤之前,还包括:5. The file processing method according to claim 1, wherein the configuration information further includes a limited file size, and the file to be processed is converted according to the configuration information and a first preset rule to obtain Java to be processed Before the steps of the object, it also includes:
    获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;Acquiring the file size of the file to be processed, and detecting whether the file size exceeds the file limit size;
    确定所述文件大小已超过所述文件限定大小后,根据所述文件限定大小对所述待处理文件进行拆分;After determining that the file size has exceeded the file limit size, split the file to be processed according to the file limit size;
    所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:The step of converting the file to be processed according to the configuration information and the first preset rule to obtain the Java object to be processed includes:
    根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。According to the configuration information and the first preset rule, the split files to be processed are sequentially converted to obtain the Java objects to be processed.
  6. 如权利要求1所述的文件处理方法,其中,所述根据所述文件名称从预设配置表中获取对应的配置信息的步骤包括:5. The file processing method according to claim 1, wherein the step of obtaining corresponding configuration information from a preset configuration table according to the file name comprises:
    根据所述文件名称确定所述待处理文件的文件类型;Determining the file type of the file to be processed according to the file name;
    根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。According to the file type and the mapping relationship between the preset file type and the configuration name, the target configuration name is determined, and the configuration information corresponding to the target configuration name is obtained from the preset configuration table.
  7. 如权利要求1至6中任一项所述的文件处理方法,其中,所述文件处理方法还包括:8. The file processing method according to any one of claims 1 to 6, wherein the file processing method further comprises:
    接收到配置表修改请求,基于所述配置表修改请求显示对应的配置信息修改界面;After receiving the configuration table modification request, display the corresponding configuration information modification interface based on the configuration table modification request;
    接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。Receive a configuration table modification instruction triggered by a user based on the configuration information modification interface, and update the preset configuration table according to the configuration table modification instruction.
  8. 一种文件处理装置,其中,所述文件处理装置包括:A file processing device, wherein the file processing device includes:
    信息获取模块,设置为确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;The information obtaining module is configured to obtain the file to be processed and its file name according to the file processing request after confirming that the file processing request is received, and obtain corresponding configuration information from the preset configuration table according to the file name;
    第一转换模块,设置为根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;The first conversion module is configured to perform conversion processing on the file to be processed according to the configuration information and the first preset rule to obtain a Java object to be processed;
    处理模块,设置为根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;The processing module is configured to call the corresponding executor to process the to-be-processed Java object according to the processing class name in the configuration information to obtain the processing result Java object;
    第二转换模块,设置为根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。The second conversion module is configured to perform conversion processing on the processing result Java object according to the configuration information and a second preset rule to obtain a processing result file.
  9. 一种文件处理设备,其中,所述文件处理设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的文件处理程序,所述文件处理程序被所述处理器执行时实现如权利要求1至7中任一项所述的文件处理方法。A file processing device, wherein the file processing device includes: a memory, a processor, and a file processing program stored on the memory and running on the processor, and the file processing program is executed by the processor When executed, the file processing method according to any one of claims 1 to 7 is realized.
  10. 一种计算机可读存储介质,其中,所述计算机可读存储介质上存储有文件处理程序,所述文件处理程序被处理器执行时实现如权利要求1至7中任一项所述的文件处理方法。A computer-readable storage medium, wherein a file processing program is stored on the computer-readable storage medium, and when the file processing program is executed by a processor, the file processing according to any one of claims 1 to 7 is realized method.
PCT/CN2020/106058 2019-08-14 2020-07-31 File processing method, apparatus, device and computer readable storage medium WO2021027592A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910761804.6 2019-08-14
CN201910761804.6A CN110457260B (en) 2019-08-14 File processing method, device, equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
WO2021027592A1 true WO2021027592A1 (en) 2021-02-18

Family

ID=68487422

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/106058 WO2021027592A1 (en) 2019-08-14 2020-07-31 File processing method, apparatus, device and computer readable storage medium

Country Status (1)

Country Link
WO (1) WO2021027592A1 (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105117378A (en) * 2015-08-05 2015-12-02 联动优势电子商务有限公司 Method and apparatus for converting JSON file into EXCEL file
CN106886390A (en) * 2015-12-15 2017-06-23 大唐软件技术股份有限公司 A kind of Java object generation and conversion method and Java object generation and conversion equipment
CN107784049A (en) * 2016-12-05 2018-03-09 上海壹账通金融科技有限公司 The method and apparatus of multi-format document parsing
WO2018178641A1 (en) * 2017-03-28 2018-10-04 Gb Gas Holdings Limited Data replication system
CN108804140A (en) * 2018-06-15 2018-11-13 中国建设银行股份有限公司 A kind of batch instruction analytic method, device and equipment
CN109889588A (en) * 2019-02-13 2019-06-14 中国银行股份有限公司 File acquisition method, device, computer equipment and storage medium
CN110457260A (en) * 2019-08-14 2019-11-15 深圳前海微众银行股份有限公司 Document handling method, device, equipment and computer readable storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105117378A (en) * 2015-08-05 2015-12-02 联动优势电子商务有限公司 Method and apparatus for converting JSON file into EXCEL file
CN106886390A (en) * 2015-12-15 2017-06-23 大唐软件技术股份有限公司 A kind of Java object generation and conversion method and Java object generation and conversion equipment
CN107784049A (en) * 2016-12-05 2018-03-09 上海壹账通金融科技有限公司 The method and apparatus of multi-format document parsing
WO2018178641A1 (en) * 2017-03-28 2018-10-04 Gb Gas Holdings Limited Data replication system
CN108804140A (en) * 2018-06-15 2018-11-13 中国建设银行股份有限公司 A kind of batch instruction analytic method, device and equipment
CN109889588A (en) * 2019-02-13 2019-06-14 中国银行股份有限公司 File acquisition method, device, computer equipment and storage medium
CN110457260A (en) * 2019-08-14 2019-11-15 深圳前海微众银行股份有限公司 Document handling method, device, equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN110457260A (en) 2019-11-15

Similar Documents

Publication Publication Date Title
CN111274045B (en) Multi-platform docking method and device, computer equipment and readable storage medium
US20100211539A1 (en) System and method for building a data warehouse
US6408303B1 (en) System and method for automated building of a trading partner profile
CN111290806B (en) Calling method and device of application program interface, computer equipment and storage medium
WO2020024419A1 (en) Testing method for service scenario, electronic device and readable storage medium
WO2020134989A1 (en) Excel data import method and apparatus, and computer device and storage medium
US8862937B2 (en) Method and system for migrating data from multiple sources
CN110647316B (en) Method and device for generating universal business object, computer equipment and storage medium
WO2022068316A1 (en) Data reconciliation method and apparatus, device, and storage medium
CN106990974B (en) APP updating method and device and electronic equipment
US20240028608A1 (en) Schema validation with support for ordering
US11449461B2 (en) Metadata-driven distributed dynamic reader and writer
WO2021027592A1 (en) File processing method, apparatus, device and computer readable storage medium
CN116414689A (en) Interface parameter verification method and system based on reflection mechanism
CN116644122A (en) Data transaction processing method, device, computer equipment and storage medium
CN111241180A (en) Information processing method, device, equipment and storage medium
CN115934537A (en) Interface test tool generation method, device, equipment, medium and product
CN112732547A (en) Service testing method and device, storage medium and electronic equipment
CN110457260B (en) File processing method, device, equipment and computer readable storage medium
CN107705089B (en) Service processing method, device and equipment
CN112230983B (en) Information processing method, electronic device, and medium
CN111400058A (en) Method and device for calling message, computer equipment and storage medium
CN110674119A (en) Data processing method, system and computer readable storage medium
CN109376023B (en) Method and equipment for generating calling information and issuing return code group
US11768819B2 (en) Data unblocking in application platforms

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20851753

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20851753

Country of ref document: EP

Kind code of ref document: A1