WO2021027592A1 - 文件处理方法、装置、设备及计算机可读存储介质 - Google Patents

文件处理方法、装置、设备及计算机可读存储介质 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
English (en)
French (fr)
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
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2021027592A1 publication Critical patent/WO2021027592A1/zh

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

一种文件处理方法、装置、设备及计算机可读存储介质。该文件处理方法包括:确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息(S10);根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象(S20);根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象(S30);根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件(S40)。

Description

文件处理方法、装置、设备及计算机可读存储介质
本申请要求于2019年08月14日提交中国专利局、申请号为201910761804.6、发明名称为“文件处理方法、装置、设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及金融科技(Fintech)技术领域,尤其涉及一种文件处理方法、装置、设备及计算机可读存储介质。
背景技术
随着计算机技术的发展,越来越多的技术(大数据、分布式、区块链Blockchain、人工智能等)应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,但由于金融行业的安全性、实时性要求,也对技术提出了更高的要求。
随着金融领域业务的不断发展,各种业务交易量不断增大,各种交易文件不断增多,若全部通过人工处理,会出现处理效率低、差错率高的问题。因此,对于一些常见类型的文件,会编写对应的代码,以实现对文件的自动化处理。通过上述方式自动处理文件时,会存在以下问题:1)代码复用度较低,每次有新的文件处理均需开发一套新的代码对文件进行处理;2)一旦文件中的某些格式有变化,如文件顺序、分隔符,需重新修改代码;3)若文件中增加了新业务,必须重新修改代码,增加对应的处理逻辑。因此,现有技术中为实现文件的自动化处理,需要大量的代码开发,开发工作量较大,且开发效率较低。
技术解决方案
本申请的主要目的在于提供一种文件处理方法、装置、设备及计算机可读存储介质,旨在通过配置的方式实现文件的自动化处理,以减少开发人员的工作量、提高开发效率。
为实现上述目的,本申请提供一种文件处理方法,所述文件处理方法包括:
确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;
根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;
根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;
根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。
在一实施例中,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:
根据所述行首标识将所述待处理文件拆分成多条数据;
根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;
获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;
根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
在一实施例中,所述根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象的步骤之前,还包括:
检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;
确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;
确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量后,检测所述配置信息中的严格模式为严格还是非严格;
确定所述配置信息中的严格模式为严格后,生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;
确定所述配置信息中的严格模式非严格后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
在一实施例中,所述配置信息还包括第二数组元素与第二目标转换属性之间的映射关系,所述根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件的步骤包括:
提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;
按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。
在一实施例中,所述配置信息还包括文件限定大小,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤之前,还包括:
获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;
确定所述文件大小已超过所述文件限定大小后,根据所述文件限定大小对所述待处理文件进行拆分;
所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:
根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。
在一实施例中,所述根据所述文件名称从预设配置表中获取对应的配置信息的步骤包括:
根据所述文件名称确定所述待处理文件的文件类型;
根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。
在一实施例中,所述文件处理方法还包括:
在接收到配置表修改请求时,基于所述配置表修改请求显示对应的配置信息修改界面;
接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。
此外,为实现上述目的,本申请还提供一种文件处理装置,所述文件处理装置包括:
信息获取模块,设置为确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;
第一转换模块,设置为根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;
处理模块,设置为根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;
第二转换模块,设置为根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。
此外,为实现上述目的,本申请还提供一种文件处理设备,所述文件处理设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的文件处理程序,所述文件处理程序被所述处理器执行时实现如上所述的文件处理方法的步骤。
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有文件处理程序,所述文件处理程序被处理器执行时实现如上所述的文件处理方法的步骤。
本申请提供一种文件处理方法、装置、设备及计算机可读存储介质,接收到文件处理请求时,先根据该文件处理请求获取待处理文件及其文件名称,并根据文件名称从预设配置表中获取对应的配置信息;然后,根据配置信息和第一预设规则对待处理文件进行转换处理,得到待处理Java对象,进而根据配置信息中的处理类名,调用对应的执行器对待处理Java对象进行处理,得到处理结果Java对象;最后,根据配置信息和第二预设规则对处理结果Java对象进行转换处理,得到处理结果文件。通过上述方式,本申请通过配置的方式实现文件的自动化处理,相比于现有技术中通过写代码的方式对文件进行自动化处理,本申请在新增处理文件或文件更改时,无需开发人员新增或修改大量的代码,从而可减少开发人员的工作量、提高开发效率。
附图说明
图1为本申请实施例方案涉及的硬件运行环境的设备结构示意图;
图2为本申请文件处理方法第一实施例的流程示意图;
图3为本申请文件处理装置第一实施例的功能模块示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
本申请的实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
参照图1,图1为本申请实施例方案涉及的硬件运行环境的设备结构示意图。
本申请实施例文件处理设备可以是智能手机,也可以是PC(Personal Computer,个人计算机)、平板电脑、便携计算机等终端设备。
如图1所示,该文件处理设备可以包括:处理器1001,例如CPU,通信总线1002,用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如Wi-Fi接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。
本领域技术人员可以理解,图1中示出的文件处理设备结构并不构成对文件处理设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
如图1所示,作为一种计算机存储介质的存储器1005中可以包括操作***、网络通信模块、用户接口模块以及文件处理程序。
在图1所示的终端中,网络接口1004主要用于连接后台服务器,与后台服务器进行数据通信;用户接口1003主要用于连接客户端,与客户端进行数据通信;而处理器1001可以用于调用存储器1005中存储的文件处理程序,并执行以下操作:
确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;
根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;
根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;
根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。
进一步地,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:
根据所述行首标识将所述待处理文件拆分成多条数据;
根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;
获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;
根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
进一步地,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:
检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;
确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;
确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量,检测所述配置信息中的严格模式为严格还是非严格;
确定所述配置信息中的严格模式为严格后,生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;
确定所述配置信息中的严格模式为非严格后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
进一步地,所述配置信息还包括第二数组元素与第二目标转换属性之间的映射关系,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:
提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;
按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。
进一步地,所述配置信息还包括文件限定大小,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:
获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;
确定所述文件大小已超过所述文件限定大小后,根据所述文件限定大小对所述待处理文件进行拆分;
所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:
根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。
进一步地,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:
根据所述文件名称确定所述待处理文件的文件类型;
根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。
进一步地,处理器1001可以调用存储器1005中存储的文件处理程序,还执行以下操作:
接收到配置表修改请求,基于所述配置表修改请求显示对应的配置信息修改界面;
接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。
基于上述硬件结构,提出本申请文件处理方法的各实施例。
本申请提供一种文件处理方法。
参照图2,图2为本申请文件处理方法第一实施例的流程示意图。
在本实施例中,该文件处理方法包括:
步骤S10,确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;
本实施例的文件处理方法是由文件处理设备实现的,该设备以服务器为例进行说明。在本实施例中,服务器接收到文件处理请求时,先根据该文件处理请求获取待处理文件及其文件名称,并根据文件名称从预设配置表中获取对应的配置信息。
其中,步骤“根据所述文件名称从预设配置表中获取对应的配置信息”包括:
步骤a1,根据所述文件名称确定所述待处理文件的文件类型;
步骤a2,根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。
在获取到待处理文件的文件名称之后,可以先根据文件名称确定待处理文件的文件类型,然后根据文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与该目标配置名称对应的配置信息。其中,该预设配置表中可以包括但不限于配置名称、行首标识、分隔符、目标转换Java类名、第一数组元素与第一目标转换属性之间的映射关系(即读文件要转换的Java类的属性及其与第一数组元素之间的映射关系)、第二数组元素与第二目标转换属性之间的映射关系(即写文件要转换的Java类的属性及其与第二数组元素之间的映射关系)、处理类名、严格模式、文件限定大小和事务处理大小等字段。对应的,每一条配置信息包括上述各字段对应的配置信息,需要说明的是,由于不同行首标识所对应的配置信息有所不同,因此一个目标配置名称可以对应多条配置信息。例如,对于文件类型是Batch Performance Test(批量性能测试)的待处理文件,预设配置表中会包含4条不同的配置信息,各条配置信息中的行首标识分别为H、X、Y、Z,用于后续在识别到待处理文件每一行开头的字符后,采用与该字符(即行首标识)对应的配置信息将各行数据自动反序列化为一个Java对象。
当然,可以理解,在具体实施例中,还可以直接建立文件名称与配置名称之间的映射关系,从而根据文件名称、文件名称与配置名称之间的映射关系直接确定得到目标配置名称,进而从预设配置表中获取与该目标配置名称对应的配置信息。
步骤S20,根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;
在获取到待处理文件和配置信息之后,根据配置信息和第一预设规则对待处理文件进行转换处理,得到待处理Java对象。需要说明的是,一行数据对应一个Java对象,待处理文件包括多条(行)数据时,对应的待处理Java对象也有多个。
其中,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,步骤S20包括:
步骤b1,根据所述行首标识将所述待处理文件拆分成多条数据;
对象的反序列化(把字节序列恢复为对象的过程)的具体过程如下:先根据行首标识将待处理文件拆分成多条数据,例如,对于下列文件:
H|123|333
B|22|tt
B|22|tt
B|22|tt
B|22|tt
F|333|tt
可根据行首标识拆分得到6条数据。
步骤b2,根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;
然后,根据分隔符将多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素。例如,对于H|123|333这一条数据,可得到第一数组元素分别为123、333。
步骤b3,获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;
然后,获取第一目标转换属性的类型,并调用与第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素。例如,第一目标转换属性包括age(年龄)和date(日期)时,可分别调用字符串转整数类的格式转化器和字符串转日期类的格式转换器,以进行格式转换。
步骤b4,根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
然后,根据目标转换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对象。
步骤S30,根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;
在得到待处理Java对象之后,根据配置信息中的处理类名,调用对应的执行器对待处理Java对象进行处理,得到处理结果Java对象。其中,执行器用于执行业务逻辑,例如,得到的Java对象为Fund Transfer(资金转移)对象,可根据处理类名确定对应的执行器是Fund Transfer Server.doTransfer,那么会自动调用这个执行器去处理这个Fund Transfer对象来完成转账业务,进而得到处理结果,该处理结果也为Java对象,记作处理结果Java对象。
步骤S40,根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。
在经处理得到处理结果Java对象之后,根据配置信息和第二预设规则对处理结果Java对象进行转换处理,得到处理结果文件。即,需将处理结果Java对象转换成对应的字符串,以便于回写结果文件。此过程涉及对象的序列化,即把对象转换为字节序列。
其中,所述配置信息还包括第二数组元素与第二目标转换属性之间的映射关系,步骤S40包括:
步骤c1,提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;
具体的,提取处理处理结果Java对象中各第二目标转换属性所对应的属性信息,然后调用与该第二目标转换属性的类型对应的第二格式转换器,对属性信息进行格式转换,得到第二数组元素。其中,第二格式转换器即为对象类转字符串类型的格式转换器,如整数类转字符串的格式转化器、日期类转字符串的格式转换器。
步骤c2,按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。
然后,按预设格式对第二数组元素、行首标识、分隔符进行拼接,得到处理结果文件。其中,预设格式可以是预先设定的,可以类似于待处理文件的格式,例如,得到第二数组元素为222、234,若配置信息中的行首标识为B,分隔符为|,即可拼接得到B|222|234,在分别对各处理结果Java对象进行转换后,可得到多组第二数组元素,然后对各第二数组元素分别进行拼接,进而根据各拼接结果生成得到处理结果文件。
本申请实施例提供一种文件处理方法,接收到文件处理请求时,先根据该文件处理请求获取待处理文件及其文件名称,并根据文件名称从预设配置表中获取对应的配置信息;然后,根据配置信息和第一预设规则对待处理文件进行转换处理,得到待处理Java对象,进而根据配置信息中的处理类名,调用对应的执行器对待处理Java对象进行处理,得到处理结果Java对象;最后,根据配置信息和第二预设规则对处理结果Java对象进行转换处理,得到处理结果文件。通过上述方式,本申请实施例中通过配置的方式实现文件的自动化处理,相比于现有技术中通过写代码的方式对文件进行自动化处理,本申请实施例在新增处理文件或文件更改时,无需开发人员新增或修改大量的代码,从而可减少开发人员的工作量、提高开发效率。
进一步地,基于上述第一实施例,提出本申请文件处理方法的第二实施例。
基于上述第一实施例,在上述步骤b4之前,该文件处理方法还包括:
步骤A,检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;
在本实施例中,为保证根据待处理文件读取得到的第一数组元素可进行后续处理,在配置信息中还可以设置严格模式,进而根据严格模式、第一数组元素的数量及第一目标转换属性的数量,来确定是否可进一步进行后续的处理(即下一步骤S20)。其中,严格模式包括严格和非严格两种。具体的,在读取得到第一数组元素之后,检测读取得到的第一数组元素的数量是否等于第一目标转换属性的数量。
确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量,执行步骤b4:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;
确定读取得到的第一数组元素的数量等于第一目标转换属性的数量后,说明第一数据元素的数量足够,此时,可根据目标转换Java类名和第一数组元素与第一目标转换属性之间的映射关系,将格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象,进而执行后续的处理过程,具体的执行过程可参照上述第一实施例,此处不作赘述。
确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量后,执行步骤B:检测所述配置信息中的严格模式为严格还是非严格;
确定读取得到的第一数组元素的数量不等于第一目标转换属性的数量后,需进一步检测配置信息中的严格模式为严格还是非严格,以结合严格模式确定是否可执行下一步处理。
确定所述配置信息中的严格模式为严格,执行步骤C:生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;
确定配置信息中的严格模式为严格,无法执行下一步处理,此时,生成对应的异常提醒信息,并返回至与该文件处理请求对应的用户端。
确定所述配置信息中的严格模式为非严格,执行步骤b4:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
确定配置信息中的严格模式为非严格,说明即使数量不相等,也可以继续执行下一步骤,即根据目标转换Java类名和第一数组元素与第一目标转换属性之间的映射关系,将格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象,进而执行后续的处理过程。需要说明的是,当读取得到的第一数组元素的数量不等于第一目标转换属性的数量,且严格模式为非严格模式时,需根据第一数组元素的数量和第一目标转换属性的数量进行映射。例如,若第一目标转换属性的数量为4个时,若第一数组元素的数量为5个,则只需映射前4个元素,若第一数组元素的数量为2个,则只需将这2个元素映射至对应你的第一目标转换属性中即可。
进一步地,基于上述第一实施例,提出本申请文件处理方法的第三实施例。
基于上述第一实施例,所述配置信息还包括文件限定大小,在上述步骤S20之前,该文件处理方法还包括:
步骤D,获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;
在本实施例中,配置信息还可以包括文件限定大小,该文件限定大小为一次限定处理的数据条数。在获取到待处理文件之后,可先获取该待处理文件的文件大小,其中,该文件大小是指待处理文件中所包括的数据总条数,具体的,可根据行首标识进行确定,文件每行具有一个行首标识,行首标识的个数即为数据总条数;当然也可以直接识别待处理文件的总行数,总行数即为数据总条数。然后,检测待处理文件的文件大小是否超过文件限定大小。
确定所述文件大小已超过所述文件限定大小,执行步骤E:根据所述文件限定大小对所述待处理文件进行拆分;
此时,步骤S20包括:
根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。
确定待处理文件的文件大小已超过文件限定大小,为避免因服务器压力过大、导致服务器的处理性能受限,可根据文件限定大小对待处理文件进行拆分,进而根据配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。进而执行后续步骤,具体的执行过程可参照上述第一实施例,此处不作赘述。
确定所述文件大小未超过所述文件限定大小,执行步骤S20:根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。
确定待处理文件的文件大小未超过文件限定大小,无需对待处理文件进行拆分,直接处理即可,具体的,根据配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象,进而执行后续步骤,具体的执行过程可参照上述第一实施例,此处不作赘述。
通过上述方式,通过配置文件限定大小,在处理文件时,检测待处理文件的文件大小是否超过该文件限定大小,当超过时,则对待处理文件进行拆分处理,可避免服务器因压力过大而导致服务器的处理性能受限。
进一步地,配置信息还可以包括事务提交大小,其中,事务提交大小是指处理时单次所限定的数据大小,对应的,在步骤S30之前,还可以检测所述待处理Java对象的大小是否超过所述事务提交大小,进而根据所述事务提交大小来控制单次处理的待处理Java对象的数据量。通过上述方式,也可以根据实际需要控制单次处理数量,避免服务器压力过大。
对应的,也可以采用上述类似的方式,限定单次转换的处理结果Java对象的数据量,以进一步避免因服务器压力过大、导致服务器的处理性能受限的情况发生。
进一步地,基于上述各实施例,提出本申请文件处理方法的第三实施例。
在本实施例中,所述文件处理方法还包括:
步骤F,接收到配置表修改请求,基于所述配置表修改请求显示对应的配置信息修改界面;
步骤G,接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。
在本实施例中,当有新的文件需自动处理、或原文件中发生了格式变化、或原文件中增加了新业务时,此时,工作人员只需新增配置信息、或修改原配置信息即可,无需开发一整套新的代码,也无需对原代码做大幅度的修改。具体的,当工作人员需要修改配置表时,可通过用户端(如手机、PC等)的对应软件或App(Application,应用程序)点击配置表修改选项,即可触发配置表修改请求,此时,服务器在接收到配置表修改请求时,基于该配置表修改请求显示对应的配置信息修改界面,工作人员可通过该配置信息修改界面输入修改信息,在输入完成后可触发配置表修改指令,此时,服务器在接收到用户基于该配置信息修改界面触发的配置表修改指令时,根据该配置表修改指令更新预设配置表。例如,对于部分配置信息的修改,可直接修改调整预设配置表中的相关配置信息,如分隔符、处理类名、映射关系、文件限定大小等。对于新增配置信息,只需在预设配置表中新增一行,添加对应的配置名称、目标转换Java类名、行首标识、分隔符、映射关系、处理类名等信息,再增加相关配置即可完成。
通过上述方式,可便于工作人员对预设配置表中的配置信息进行更新,同时,基于配置的方式实现文件的自动化处理,无需开发人员新增或修改大量的代码,可减少开发人员的工作量,提高开发效率。
本申请还提供一种文件处理装置。
参照图3,图3为本申请文件处理装置第一实施例的功能模块示意图。
如图3所示,所述文件处理装置包括:
信息获取模块10,设置为接收文件处理请求,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;
第一转换模块20,设置为根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;
处理模块30,设置为根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;
第二转换模块40,设置为根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。
进一步地,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,所述第一转换模块20包括:
文件拆分单元,设置为根据所述行首标识将所述待处理文件拆分成多条数据;
元素读取单元,设置为根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;
第一转换单元,设置为获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;
元素映射单元,设置为根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
进一步地,所述第一转换模块20还包括:
第一检测单元,设置为检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;
所述元素映射单元,还设置为所述第一检测确定单元确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量后,根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;
第二检测单元,设置为所述第一检测确定单元确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量,检测所述配置信息中的严格模式为严格还是非严格;
异常提醒单元,设置为所述第二检测单元确定所述配置信息中的严格模式为严格后,生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;
所述元素映射单元,还设置为所述第二检测单元确定所述配置信息中的严格模式为非严格后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
进一步地,所述第二转换模块40包括:
第二转换单元,设置为提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;
拼接单元,设置为按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。
进一步地,所述配置信息还包括文件限定大小,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤之前,所述文件处理装置还包括:
大小检测模块,设置为获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;
文件拆分模块,设置为所述大小检测模块确定所述文件大小已超过所述文件限定大小后,根据所述文件限定大小对所述待处理文件进行拆分;
所述第一转换模块,还设置为根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。
进一步地,所述信息获取模块10包括:
类型确定单元,设置为根据所述文件名称确定所述待处理文件的文件类型;
信息获取单元,设置为根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。
进一步地,所述文件处理装置还包括:
显示模块,设置为在接收到配置表修改请求后,基于所述配置表修改请求显示对应的配置信息修改界面;
更新模块,设置为接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。
其中,上述文件处理装置中各个模块的功能实现与上述文件处理方法实施例中各步骤相对应,其功能和实现过程在此处不再一一赘述。
本申请还提供一种计算机可读存储介质,该计算机可读存储介质上存储有文件处理程序,所述文件处理程序被处理器执行时实现如以上任一项实施例所述的文件处理方法的步骤。
本申请计算机可读存储介质的具体实施例与上述文件处理方法各实施例基本相同,在此不作赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者***不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者***所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者***中还存在另外的相同要素。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (10)

  1. 一种文件处理方法,其中,所述文件处理方法包括:
    确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;
    根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;
    根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;
    根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。
  2. 如权利要求1所述的文件处理方法,其中,所述配置信息包括目标转换Java类名、行首标识、分隔符、第一数组元素与第一目标转换属性之间的映射关系,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:
    根据所述行首标识将所述待处理文件拆分成多条数据;
    根据所述分隔符将所述多条数据拆分成数组,并遍历拆分得到的数组,读取第一数组元素;
    获取第一目标转换属性的类型,并调用与所述第一目标转换属性的类型对应的第一格式转换器,对读取得到的第一数组元素进行格式转换,得到格式转换后的第一数组元素;
    根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
  3. 如权利要求2所述的文件处理方法,其中,所述根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象的步骤之前,还包括:
    检测读取得到的第一数组元素的数量是否等于所述第一目标转换属性的数量;
    确定读取得到的第一数组元素的数量等于所述第一目标转换属性的数量后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象;
    确定读取得到的第一数组元素的数量不等于所述第一目标转换属性的数量后,检测所述配置信息中的严格模式为严格还是非严格;
    确定所述配置信息中的严格模式为严格后,生成对应的异常提醒信息,并返回至与所述文件处理请求对应的用户端;
    确定所述配置信息中的严格模式非严格后,执行步骤:根据所述目标转换Java类名和所述第一数组元素与第一目标转换属性之间的映射关系,将所述格式转换后的第一数组元素分别映射至对应的第一目标转换属性中,得到待处理Java对象。
  4. 如权利要求2所述的文件处理方法,其中,所述配置信息还包括第二数组元素与第二目标转换属性之间的映射关系,所述根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件的步骤包括:
    提取所述处理结果Java对象中各第二目标转换属性所对应的属性信息,并调用与所述第二目标转换属性的类型对应的第二格式转换器,对所述属性信息进行格式转换,得到第二数组元素;
    按预设格式对所述第二数组元素、所述行首标识、所述分隔符进行拼接,得到处理结果文件。
  5. 如权利要求1所述的文件处理方法,其中,所述配置信息还包括文件限定大小,所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤之前,还包括:
    获取所述待处理文件的文件大小,并检测所述文件大小是否超过所述文件限定大小;
    确定所述文件大小已超过所述文件限定大小后,根据所述文件限定大小对所述待处理文件进行拆分;
    所述根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象的步骤包括:
    根据所述配置信息和第一预设规则依次对各拆分后的待处理文件进行转换处理,得到待处理Java对象。
  6. 如权利要求1所述的文件处理方法,其中,所述根据所述文件名称从预设配置表中获取对应的配置信息的步骤包括:
    根据所述文件名称确定所述待处理文件的文件类型;
    根据所述文件类型和预设的文件类型与配置名称之间的映射关系,确定目标配置名称,并从预设配置表中获取与所述目标配置名称对应的配置信息。
  7. 如权利要求1至6中任一项所述的文件处理方法,其中,所述文件处理方法还包括:
    接收到配置表修改请求,基于所述配置表修改请求显示对应的配置信息修改界面;
    接收用户基于所述配置信息修改界面触发的配置表修改指令,并根据所述配置表修改指令更新所述预设配置表。
  8. 一种文件处理装置,其中,所述文件处理装置包括:
    信息获取模块,设置为确定接收到文件处理请求后,根据所述文件处理请求获取待处理文件及其文件名称,并根据所述文件名称从预设配置表中获取对应的配置信息;
    第一转换模块,设置为根据所述配置信息和第一预设规则对所述待处理文件进行转换处理,得到待处理Java对象;
    处理模块,设置为根据所述配置信息中的处理类名,调用对应的执行器对所述待处理Java对象进行处理,得到处理结果Java对象;
    第二转换模块,设置为根据所述配置信息和第二预设规则对所述处理结果Java对象进行转换处理,得到处理结果文件。
  9. 一种文件处理设备,其中,所述文件处理设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的文件处理程序,所述文件处理程序被所述处理器执行时实现如权利要求1至7中任一项所述的文件处理方法。
  10. 一种计算机可读存储介质,其中,所述计算机可读存储介质上存储有文件处理程序,所述文件处理程序被处理器执行时实现如权利要求1至7中任一项所述的文件处理方法。
PCT/CN2020/106058 2019-08-14 2020-07-31 文件处理方法、装置、设备及计算机可读存储介质 WO2021027592A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910761804.6A CN110457260A (zh) 2019-08-14 2019-08-14 文件处理方法、装置、设备及计算机可读存储介质
CN201910761804.6 2019-08-14

Publications (1)

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

Family

ID=68487422

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/106058 WO2021027592A1 (zh) 2019-08-14 2020-07-31 文件处理方法、装置、设备及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN110457260A (zh)
WO (1) WO2021027592A1 (zh)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110457260A (zh) * 2019-08-14 2019-11-15 深圳前海微众银行股份有限公司 文件处理方法、装置、设备及计算机可读存储介质
CN112953988B (zh) * 2019-12-10 2023-03-24 浙江宇视科技有限公司 一种基于ftp的数据对接方法及装置
CN111309498B (zh) * 2020-02-13 2023-09-15 山东汇贸电子口岸有限公司 请求处理方法、装置及计算机可读介质
CN111949614B (zh) * 2020-08-12 2024-04-02 中国工商银行股份有限公司 银行***文件转换方法及装置
CN112230983B (zh) * 2020-10-15 2021-08-03 上海嗨普智能信息科技股份有限公司 信息处理方法、电子设备和介质
CN112925749A (zh) * 2021-02-20 2021-06-08 北京同邦卓益科技有限公司 一种数据处理方法、装置、电子设备及存储介质
CN113076129B (zh) * 2021-03-23 2023-11-28 成都安恒信息技术有限公司 一种复杂配置依赖关系自动检查处理方法

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105117378A (zh) * 2015-08-05 2015-12-02 联动优势电子商务有限公司 一种json文件转换为excel文件的方法及装置
CN106886390A (zh) * 2015-12-15 2017-06-23 大唐软件技术股份有限公司 一种Java对象生成和转换方法和Java对象生成和转换装置
CN107784049A (zh) * 2016-12-05 2018-03-09 上海壹账通金融科技有限公司 多格式文件解析的方法和装置
WO2018178641A1 (en) * 2017-03-28 2018-10-04 Gb Gas Holdings Limited Data replication system
CN108804140A (zh) * 2018-06-15 2018-11-13 中国建设银行股份有限公司 一种批量指令解析方法、装置及设备
CN109889588A (zh) * 2019-02-13 2019-06-14 中国银行股份有限公司 文件获取方法、装置、计算机设备和存储介质
CN110457260A (zh) * 2019-08-14 2019-11-15 深圳前海微众银行股份有限公司 文件处理方法、装置、设备及计算机可读存储介质

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101699397B (zh) * 2009-10-09 2015-09-16 上海宝信软件股份有限公司 实现Java与XML数据绑定的方法

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105117378A (zh) * 2015-08-05 2015-12-02 联动优势电子商务有限公司 一种json文件转换为excel文件的方法及装置
CN106886390A (zh) * 2015-12-15 2017-06-23 大唐软件技术股份有限公司 一种Java对象生成和转换方法和Java对象生成和转换装置
CN107784049A (zh) * 2016-12-05 2018-03-09 上海壹账通金融科技有限公司 多格式文件解析的方法和装置
WO2018178641A1 (en) * 2017-03-28 2018-10-04 Gb Gas Holdings Limited Data replication system
CN108804140A (zh) * 2018-06-15 2018-11-13 中国建设银行股份有限公司 一种批量指令解析方法、装置及设备
CN109889588A (zh) * 2019-02-13 2019-06-14 中国银行股份有限公司 文件获取方法、装置、计算机设备和存储介质
CN110457260A (zh) * 2019-08-14 2019-11-15 深圳前海微众银行股份有限公司 文件处理方法、装置、设备及计算机可读存储介质

Also Published As

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

Similar Documents

Publication Publication Date Title
WO2021027592A1 (zh) 文件处理方法、装置、设备及计算机可读存储介质
CN109582301B (zh) 基于任务调度***的业务处理方法、装置、设备及介质
CN111274045B (zh) 一种多平台对接方法、装置、计算机设备及可读存储介质
US20100211539A1 (en) System and method for building a data warehouse
US6408303B1 (en) System and method for automated building of a trading partner profile
WO2020024419A1 (zh) 业务场景的测试方法、电子装置及可读存储介质
WO2020134989A1 (zh) Excel数据的导入方法、装置、计算机设备和存储介质
US8862937B2 (en) Method and system for migrating data from multiple sources
CN111290806A (zh) 应用程序接口的调用方法、装置、计算机设备及存储介质
TW201439792A (zh) 資料庫訪問系統及方法
WO2022068316A1 (zh) 数据对账方法、装置、设备及存储介质
CN111241180A (zh) 一种信息处理的方法、装置、设备及存储介质
CN106990974B (zh) 一种app应用更新方法、装置及电子设备
US11449461B2 (en) Metadata-driven distributed dynamic reader and writer
CN117556008A (zh) 基于大语言模型的交互方法、介质、装置和计算设备
CN116414689A (zh) 一种基于反射机制的接口参数校验方法及***
CN116644122A (zh) 数据事务处理方法、装置、计算机设备及存储介质
CN115934537A (zh) 接口测试工具生成方法、装置、设备、介质及产品
CN112732547A (zh) 业务测试方法、装置、存储介质及电子设备
CN109740027B (zh) 数据交换方法、装置、服务器和存储介质
CN107705089B (zh) 业务处理方法、装置及设备
CN112230983B (zh) 信息处理方法、电子设备和介质
CN111400058A (zh) 调用消息的方法、装置、计算机设备及存储介质
CN113077241B (zh) 审批处理方法、装置、设备及存储介质
CN109376023B (zh) 用于生成调用信息、发布返回码组的方法和设备

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