File processing method, device and equipment
By importing and parsing digital report templates, rendering and editing report files, the redundant information and parsing errors in front-end interactions are solved, and the unified and simplified processing of report files is achieved.
Patent Information
- Application Number
- CN202411683830.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-11
AI Technical Summary
In the heavy-load railway transportation industry, the front and back end interactions carry a large amount of redundant information and occupy broadband traffic, resulting in the front and back ends needing to write unnecessary parsing logic on the algorithm, which is prone to errors in data acquisition and analysis.
By importing a digital report template to the target application according to the preset import specifications, performing file parsing to obtain the target format file and entry item parameter file, rendering the digital report template with the target format file, inserting the entry item editing component, and entering the entry data through the component to form a report file.
It realizes a unified report file, simplifies program logic, avoids data parsing errors, and improves the efficiency and accuracy of data processing.
Smart Images

Figure CN119598993A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer information processing, and in particular to a method, device and equipment for processing a file. Background Art
[0002] In the heavy-load railway transportation industry, in order to ensure the normal operation of various equipment and facilities including the power supply system, it is necessary to implement real-time monitoring and testing of all power supply equipment along the line around the clock. Accurate and complete test reports can quickly locate equipment failures, troubleshoot the causes of equipment problems, and ensure that the equipment can operate stably.
[0003] With the development trend of industry informatization, multimeter measurement report forms are gradually becoming digitalized, but the data reporting method is still mainly based on a single report form. With various report form formats, the management of the report form has increased a lot of workload, and the front-end and back-end interactions usually use the source file format. The interaction carries a lot of redundant information, occupies bandwidth traffic, and also requires the front-end and back-end to write redundant parsing logic in the algorithm, which is prone to errors in the parsing of collected data. Summary of the invention
[0004] The purpose of the present invention is to at least provide a file processing method, device and equipment, which can at least solve the problem that the front-end and back-end interactions carry a large amount of redundant information, occupy broadband traffic, and require the front-end and back-end to write redundant parsing logic in the algorithm, which is prone to errors in the parsing of collected data. At least it can achieve the effect of unifying report files, simplifying program logic, and avoiding data parsing errors.
[0005] To solve the above technical problem, at least one embodiment of the present application provides a file processing method, including:
[0006] Importing a digital report form template into a target application according to a preset import specification; the digital report form template includes a plurality of blank entries;
[0007] Parsing the digital report template to obtain a target format file for rendering and an item parameter file for standardizing item editing components;
[0008] Rendering the digital report form template using the target format file to obtain a digital report form instance;
[0009] Calling the item parameter file to insert the item editing component into the digital report form instance to generate an editable report form file;
[0010] The item data is input into the report editable file through the item editing component to form a report file.
[0011] At least one embodiment of the present application further provides a file processing device, including:
[0012] An import module, used to import a digital report template into a target application according to a preset import specification; the digital report template includes a plurality of blank entries;
[0013] A parsing module, used for parsing the digital report template to obtain a target format file for rendering and an item parameter file for standardizing an item editing component;
[0014] A rendering module, used to render the digital report form template using the target format file to obtain a digital report form instance;
[0015] An inserting module, used for calling the item parameter file to insert the item editing component into the digital report form instance to generate an editable report form file;
[0016] A forming module is used to input the entry data into the report editable file through the entry item editing component to form a report file.
[0017] At least one embodiment of the present application also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned file processing method.
[0018] At least one embodiment of the present application further provides a computer-readable storage medium storing a computer program, wherein the computer program implements the above-mentioned file processing method when executed by a processor.
[0019] The embodiment of the present application provides a method for processing a file, which imports a digital report form template into a target application according to a preset import specification; the digital report form template contains a plurality of blank entries; the digital report form template is parsed to obtain a target format file for rendering and an entry item parameter file for standardizing an entry item editing component; the digital report form template is rendered using the target format file to obtain a digital report form instance; the entry item parameter file is called to insert an entry item editing component into the digital report form instance to generate an editable report form file; entry data is input into the editable report form file through the entry item editing component to form a report form file. The report form test parameters can be extracted separately, and the form differentiation work is moved forward to the template data processing, thereby unifying the report form file, simplifying the program logic, and avoiding data parsing errors.
[0020] In some optional embodiments, the file parsing of the digital report template to obtain a target format file for rendering and an item parameter file for standardizing the item editing component includes:
[0021] Using a document processing tool to perform character string conversion processing on the digital report form template to obtain a word character string file;
[0022] Extracting JSON parameters from the word string file, and replacing the JSON parameters with placeholders, to obtain an entry item parameter file for standardizing an entry item editing component;
[0023] The word character string file is subjected to character string conversion processing to obtain an HTML format file for rendering.
[0024] Among them, the digital report form template is parsed to obtain the target format file and the item parameter file used to standardize the item editing components. There is no need to perform differential processing on the report form, and the file can be rendered directly through the target format file. The processing process is simple and efficient.
[0025] In some optional embodiments, calling the item parameter file to insert an item editing component into the digital report form instance to generate an editable report form file includes:
[0026] Using the item parameter file to judge the type of the item in the digital report form instance to obtain a judgment result;
[0027] According to the judgment result, the item editing component corresponding to the item in the digital report form instance is inserted into the digital report form instance to generate an editable report form file.
[0028] Among them, HTML format files are used to render digital report templates within the target application. There is no need to switch applications, and file rendering can be achieved simply and quickly, thereby improving the user experience.
[0029] In some optional embodiments, the process of determining the entry data includes:
[0030] Collecting parameter data corresponding to the entry items in the editable file of the report form;
[0031] Filling the parameter data corresponding to the entry item into the editable report form file to obtain a preformed report form file;
[0032] The parameter data corresponding to the entry items in the preformed report file are supplemented and corrected to determine the entry data.
[0033] Among them, the parameter data is matched with the items in the report file, and supplemented and corrected to obtain correct and complete entry data, which is convenient for directly matching the data to the report template to form a report file. This can avoid the intermediate template and HTML format conversion process, and can also retain the original style of the original to the greatest extent.
[0034] In some optional embodiments, the file processing method further includes:
[0035] The entry parameter file is used to determine the source type of the parameter data; the source types include: automatic collection and manual entry.
[0036] The parameter data is obtained by automatic collection and manual entry. In the event that the automatically collected parameter data is missed or wrongly collected, the parameter data is supplemented and corrected, thereby ensuring the correctness and completeness of the parameter data.
[0037] In some optional embodiments, the supplementing and correcting the parameter data corresponding to the item in the preformed report file to determine the item data includes:
[0038] Traversing the parameter data corresponding to the items in the preformed report file;
[0039] The erroneous parameter data is corrected and the missing parameter data is supplemented to obtain entry data.
[0040] Among them, correcting the erroneous parameter data and supplementing the missing parameter data can ensure the correctness and completeness of the parameter data, thereby obtaining a correct and standardized report file.
[0041] In some optional embodiments, the step of inputting the entry data into the editable report file through the entry item editing component to form the report file includes:
[0042] Read the word string file from the database;
[0043] Performing regular expression parsing processing on the word string file, replacing the placeholders in the word string file with the entry data, and obtaining a word string report file;
[0044] The word character string report file is saved as a word file to obtain the report file.
[0045] The final report file is based on the initially imported digital report template. The item data is filled in and rendered in the digital report template. It does not involve the conversion process between intermediate templates and HTML formats, thus retaining the original style of the file to the greatest extent. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] One or more embodiments are exemplarily described by the pictures in the corresponding drawings, and these exemplary descriptions do not constitute limitations on the embodiments.
[0047] Figure 1 It is a flowchart of a method for processing a file provided in an embodiment of the present application;
[0048] Figure 2 is a schematic diagram of a digital report template provided in an embodiment of the present application;
[0049] Figure 3 is a schematic diagram of an example of a digital report provided by an embodiment of the present application;
[0050] Figure 4 is a schematic diagram of a report file provided in an embodiment of the present application;
[0051] Figure 5 This is another flowchart of a file processing method provided by an embodiment of the present application;
[0052] Figure 6 It is a schematic diagram of a process of rendering a digital report template using a target format file provided in an embodiment of the present application;
[0053] Figure 7 It is a module schematic diagram of a file processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0054] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the present application, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can also be implemented. The division of the following embodiments is for the convenience of description, and the specific implementation of the present application should not be construed as any limitation, and the various embodiments can be combined and referenced with each other under the premise of no contradiction.
[0055] The following problems still exist in the prior art: there are many types of measurement reports, which are not uniformly processed and are mostly paper versions, which requires a large amount of data entry work; the original measurement report forms are mostly unstructured files that interact between the front and back ends. After the front end pulls the files, the built-in program algorithm cannot process them and needs to call other software in the system. Switching between multiple programs results in a poor user experience; generally, the front end will directly operate the original report form when collecting data, which poses the risk of modifying the report form by mistake, resulting in inconsistency between the final generated report form and the expected download.
[0056] In order to solve the technical problem that the front-end and back-end interactions carry a large amount of redundant information, occupy broadband traffic, and require the front-end and back-end to write redundant parsing logic in the algorithm, which is prone to errors in the parsing of collected data, the present invention proposes a file processing method. The implementation details of a file processing method of this embodiment are specifically described below. The following content is only the implementation details provided for the convenience of understanding and is not necessary for the implementation of this solution.
[0057] Embodiment 1:
[0058] The file processing method of this embodiment can be applied to electronic devices with communication, computing and data storage capabilities. The specific process can be as follows: Figure 1 As shown, including:
[0059] Step 101, importing a digital report form template into a target application according to a preset import specification; the digital report form template includes a plurality of blank entries;
[0060] Step 102, parsing the digital report template to obtain a target format file for rendering and an item parameter file for standardizing the item editing component;
[0061] Step 103, using the target format file to render the digital report form template to obtain a digital report form instance;
[0062] Step 104, calling the item parameter file to insert the item editing component into the digital report form instance, and generating an editable report form file;
[0063] Step 105: Input the entry data into the report editable file through the entry item editing component to form a report file.
[0064] In this embodiment, the digital report form template is imported into the target application according to the preset import specification; the digital report form template contains multiple blank entries, the digital report form template is parsed to obtain the target format file for rendering and the entry item parameter file for standardizing the entry item editing component, the digital report form template is rendered using the target format file to obtain the digital report form instance, the entry item parameter file is called to insert the entry item editing component into the digital report form instance, an editable report form file is generated, and entry data is input into the editable report form file through the entry item editing component to form a report form file. The report form test parameters can be extracted separately, and the form differentiation work is moved forward to the template data processing, thereby unifying the report form file, simplifying the program logic, and avoiding data parsing errors.
[0065] Embodiment 2:
[0066] The file processing method of this embodiment can be applied to electronic devices with communication, computing and data storage capabilities. This embodiment specifically describes the implementation details of steps 101 to 105 described in Example 1. The following content is only the implementation details provided for ease of understanding and is not necessary for implementing this solution.
[0067] In step 101, a digital report template is imported into a target application according to a preset import specification; the digital report template includes a plurality of blank entries. Figure 2 shown.
[0068] The target application may be a document editing application, which may specifically include: Word (word processing software). The entry items may at least include: test location, temperature, humidity, test date, nameplate, model, rated current, operating voltage, factory date, manufacturer, operating number, installation location, loop resistance, conclusion, and remarks.
[0069] Specifically, in some examples, the preset import specification may include:
[0070] Items that need to be tested and pre-filled are enclosed by the "[]" identifier, which contains the test items and item-related attributes;
[0071] Fill in the placeholders and attribute JSON (JavaScript Object Notation, a lightweight data exchange format) in “[]”, for example: “[{attr_code:“test_addr”,type:”select”,select_value:“substation, power supply station”}]”;
[0072] Among them, attr_code is the placeholder for each item in the report; select is the drop-down selection type, which can be used with select_value to complete the drop-down component rendering; input is manual input, which is rendered as an input component; date is the date type, which can be automatically read from the system during data collection; collect is the automatic collection type, and the data of the automatic collection type can be automatically obtained from the collection terminal;
[0073] The JSON data in the placeholder "[]" supports flexible expansion.
[0074] Among them, by importing the digital report form template into the target application according to the preset import specification, the report form file can be converted into a digital report form template for unified processing, thereby reducing the probability of errors in generating the report form.
[0075] The step 102 is to parse the digital report template to obtain a target format file for rendering and an item parameter file for standardizing the item editing component.
[0076] Specifically, in some embodiments, step 102 may include:
[0077] Step 1021, using a document processing tool to perform character string conversion processing on the digital report form template to obtain a word character string file;
[0078] Step 1022, extracting JSON parameters from the word string file, and replacing the JSON parameters with placeholders, to obtain an entry item parameter file for standardizing the entry item editing component;
[0079] Step 1023, performing string conversion processing on the word string file to obtain an HTML format file for rendering.
[0080] In the specific implementation, the specific steps of parsing the digital report template include:
[0081] Step 1, initialize wordJSON, wordStr, wordStr;
[0082] Among them, wordJSON is used to store parameters extracted from the Word template string; wordStr contains the converted Word template string, which is used as the initial template input; wordStr is used to cache wordStr for replacement operation in subsequent processing;
[0083] Step 2, extract the parameter module that conforms to the JSON format from wordStr through the regular expression / (?=\[\{).*? (?<=\}\]) / g, and perform the following operations on each matching content:
[0084] Step 21, convert the matched string into JSON parameter and store it in codeJSON;
[0085] Step 22, using the attr_code field of the JOSN parameter as the key, and storing the JOSN parameter itself in wordJOSN;
[0086] Step 23, replace the corresponding JSON parameter in _wordStr with the placeholder [{${codeJSON.attr_code}}].
[0087] Step 3, pass the processed _wordStr to the handleStrToHTML function to convert it into the HTML format string htmlStr;
[0088] Step 4, save the converted HTML string and the JSON object containing the JSON parameters to the target file path respectively, and complete the output of the HTML format file and the entry parameter file.
[0089] Among them, the digital report form template is parsed to obtain the target format file and the item parameter file used to standardize the item editing components. There is no need to perform differential processing on the report form, and the file can be rendered directly through the target format file. The processing process is simple and efficient.
[0090] In step 103, the digital report form template is rendered using the target format file to obtain a digital report form instance. Figure 3 shown.
[0091] In specific implementation, the step 103 may include:
[0092] Step 1031, parsing the digital report form template into an AST (Abstract Syntax Tree) structure, the AST structure is used to describe the elements such as labels, attributes, time, binding, etc. in the digital report form template, so that the structure and semantics of the digital report form template are represented in a tree structure;
[0093] Step 1032, identifying HTML tags, instructions, binding attributes and time processing functions in the digital report template, and constructing a hierarchical relationship of AST nodes;
[0094] Step 1033, optimizing the initially generated AST structure, removing unnecessary nodes and merging static nodes; this can reduce redundant calculations in subsequent rendering processes;
[0095] Step 1034, marking the static content nodes during the processing so that the parts that do not need to be updated are skipped during the rendering and updating process;
[0096] Step 1035, when executing the rendering function, a corresponding virtual DOM (Document Object Model) structure is generated. The virtual DOM is used to describe the intermediate state of the interface; this makes it easier to compare the new and old states to reduce actual DOM operations;
[0097] The virtual DOM structure only retains the minimum update set, which ensures that only the changed DOM nodes are modified when data is updated, thus improving rendering efficiency.
[0098] Step 1036, rendering to the interface according to the generated virtual DOM, and generating a digital report instance.
[0099] Among them, rendering the digital report form can improve the visual quality of the digital report form instance, enhance the realism of the digital report form, highlight the details and texture, and thus effectively display the information of the items in the digital report form instance.
[0100] Step 104, calling the item parameter file to insert the item editing component into the digital report form instance, and generating an editable report form file.
[0101] Specifically, in some embodiments, step 104 may include:
[0102] Step 1041, using the item parameter file to determine the type of the item in the digital report form instance, and obtaining a determination result;
[0103] Step 1042, based on the judgment result, insert the item editing component corresponding to the item in the digital report form instance into the digital report form instance to generate an editable report form file.
[0104] The entry item editing component may include: an input box and a drop-down selection box.
[0105] In a specific implementation, the specific process of inserting the item editing component corresponding to the item in the digital report form instance into the digital report form instance may include:
[0106] Initialize _htmlStr to the input HTML string, which is used to store the processed HTML content;
[0107] Use the regular expression / \[\{\s*([^\s^\}]+)\s*\}\] / g to match the fragment containing the placeholder in htmlStr. For each matching result i, extract the key value i[1] in the placeholder for subsequent processing;
[0108] Generates the corresponding HTML form space code string nodeStr based on the matching placeholder type;
[0109] If the placeholder type is select, the optional value is obtained from targetItem.select_value to generate a <el-select>Elements and corresponding <el-option>The HTML code of the element, the el-select component is used to render a drop-down selection box;
[0110] If the placeholder type is input or date, a <el-input>The HTML code of the element. The el-input component is used for text input box or date picker.
[0111] For unmatched placeholders, an empty string is generated, keeping the original content without replacement;
[0112] Each matched placeholder string i[0] is replaced with the generated dynamic form control code nodeStr, thereby forming a final HTML string containing dynamic HTML form elements, namely htmlStr.
[0113] Specifically, when data is entered, the type parameters related to the item editing component can be determined based on the item parameter file.
[0114] Among them, HTML format files are used to render digital report templates within the target application. There is no need to switch applications, and file rendering can be achieved simply and quickly, thereby improving the user experience.
[0115] Step 105, input the item data into the report editable file through the item editing component to form a report file. Figure 4 shown.
[0116] Specifically, in some embodiments, the process of determining the entry data in step 105 may include:
[0117] Step 105A, collecting parameter data corresponding to the items in the editable file of the report;
[0118] Among them, the entry parameter file can be used to determine the source type of parameter data; the source types include: automatic collection and manual entry.
[0119] Step 105B, fill in the parameter data corresponding to the entry item into the editable report form file to obtain a preformed report form file;
[0120] Step 105C, supplement and correct the parameter data corresponding to the entry items in the pre-formed report form file to determine the entry data.
[0121] Furthermore, in some embodiments, step 1053 may include:
[0122] Step 105C1, traversing the parameter data corresponding to the items in the pre-formed report file;
[0123] Step 105C2, correct the erroneous parameter data and supplement the missing parameter data to obtain entry data.
[0124] The system will automatically determine whether the data entry is manual or automatic based on whether "type" is "collect". After the parameter data collection is completed, click the Submit button to upload the collected data corresponding to the entry item. After receiving the reported data, the background system will parse it and regenerate the entry parameter file with the entry data.
[0125] It should be noted that the parameters in the entry parameter file can be reviewed, and the erroneous or missing parameters can be corrected and supplemented to form complete entry data.
[0126] It is worth noting that a "value" field can be added to the item parameter file to store the data reported after collection or review. For details, please refer to the following example:
[0127] Before storing data: {°attr_code:°"hldz#1”,°type:°"collect”°}
[0128] After storing the data, it will be: {°attr_code:"hldz#1",°type:°"collect",°°value:°"5"°}
[0129] Specifically, in some embodiments, step 105 may include:
[0130] Step 1051, read the word string file from the database;
[0131] Step 1052, performing regular expression parsing processing on the word string file, replacing the placeholders in the word string file with the entry data, and obtaining a word string report file;
[0132] Step 1053, save the word string report file as a word file to obtain the report file.
[0133] In specific implementation, the backend can generate a report file based on the algorithm combined with the digital report template and item data. The specific process includes:
[0134] Read word string file from database;
[0135] Regular expression is used to parse out the attr_code placeholder and replace the entry parameter into the word string file to obtain the string report file;
[0136] The replaced string report file is saved as a word file, and the style of the word file, that is, the report file, is consistent with the digital report template.
[0137] The final report file is based on the initially imported digital report template. The item data is filled in and rendered in the digital report template. It does not involve the conversion process between intermediate templates and HTML formats, thus retaining the original style of the file to the greatest extent.
[0138] Embodiment three:
[0139] The file processing method of this embodiment can be applied to electronic devices with communication, computing and data storage capabilities. Figure 5 The implementation details of the file processing method are explained in detail. The following content is only provided for the convenience of understanding the implementation details and is not necessary for the implementation of this solution.
[0140] In some embodiments, Figure 5 As shown, the specific implementation process of the file processing method may include:
[0141] After the digital report form template is imported into the front-end interface, the digital report form template is uploaded to the back-end, and the digital report form template is parsed by the back-end algorithm to generate an HTML format file and an item parameter file;
[0142] Pull the HTML file to the front-end interface, render the digital report template, and obtain the digital report instance;
[0143] Calling the item parameter file, parsing the parameter data in the item parameter file, and inserting the item editing components such as input box and drop-down box into the digital report form instance;
[0144] Enter parameter data, upload parameter data, and merge parameter data and item parameter files;
[0145] Rendering of report editable files in combination with item parameter files with parameter data;
[0146] Review and revise parameter data in the editable file of the report to form item data;
[0147] Upload the item data to the backend, and the backend will fill the item data back into the corresponding position in the digital report form template according to the algorithm to generate a report form file;
[0148] Operators can download the complete report file through the front-end interface.
[0149] In this embodiment, through the file processing method, a specific algorithm is used to convert the report file into a template for unified processing, thereby reducing the labor cost caused by data maintenance; the front-end and back-end interaction adopts the HTML (Hypertext Markup Language) mode to render the report file, that is, all operations are performed inside the APP (application) without switching, thereby improving the user experience; and the HTML mode is only used during the front-end and back-end interaction. After the data collection is completed, the data is backfilled into the original report template through a specific algorithm to ensure that the original format of the report is not changed.
[0150] Embodiment 4:
[0151] The file processing method of this embodiment can be applied to electronic devices with communication, computing and data storage capabilities. Figure 6 The implementation details of rendering the digital report template using the target format file are specifically explained. The following content is only provided for the convenience of understanding the implementation details and is not necessary for implementing this solution.
[0152] In some embodiments, Figure 6 As shown, the specific implementation process of rendering the digital report template using the target format file may include:
[0153] Import digital report form templates;
[0154] Parse the digital report template to obtain HTML format file and item parameter file;
[0155] The digital report form template is rendered using an HTML format file to obtain a digital report form instance;
[0156] Using the item parameter file, determine the text type of the item, and insert the input component into the digital report form instance;
[0157] Using the item parameter file, determine the drop-down selection type of the item, and insert the selection component into the digital report form instance;
[0158] Using the entry item parameter file, determine the date type / auto-fill type of the entry item and insert the date component into the digital report form instance;
[0159] Insert data entry type parameters into the digital report form instance, which can be manually entered / automatically entered, and combined to form an editable report form file;
[0160] The report editable file can be parsed by an abstract syntax tree algorithm to obtain a parsing result;
[0161] The parsing result is transformed and combined with the filled code to generate HRML code represented by JOSN parameters;
[0162] And generate virtual nodes, which are then rendered to the application interface to form a visual report file.
[0163] In this embodiment, it is only necessary to import the digital report form template according to the rules to automatically parse the corresponding parameters and parameter types, and generate the HTML format file required for front-end rendering. There is no need to perform differentiated processing on the report form, which is simple and efficient. This front-end and back-end interactive method using HTML can adapt to PC (terminal (personal computer), APP (Application) and other front-ends without the need to separately develop SDK (software development kit, Software Development Kit) files to interact with webview (components used to embed web page content in mobile applications or desktop applications), and unidirectional insertion of input box components. The report form file does not need to run across platforms. The report form file finally generated by the file processing method is based on the initially imported file, and the acquired measurement values are filled in and rendered in the initial template. It does not involve the process of converting between the intermediate template and the HTML format, that is, the original style of the file is retained to the greatest extent.
[0164] In the above embodiment, through the file processing method, a specific algorithm is used to convert the report file into a template for unified processing, thereby reducing the labor cost caused by data maintenance; the front-end and back-end interaction uses HTML (Hypertext Markup Language) mode to render the report file, that is, all operations are performed within the APP (application) without switching, thereby improving the user experience; and the HTML mode is only used during the front-end and back-end interaction. After the data collection is completed, the data is backfilled into the original report template through a specific algorithm to ensure that the original format of the report is not changed.
[0165] This application only needs to import the digital report form template according to the rules to automatically parse the corresponding parameters and parameter types, and generate the HTML format file required for front-end rendering. There is no need to differentiate the report form, which is simple and efficient. This front-end and back-end interactive method using HTML can adapt to PC (terminal (personal computer), APP (Application) and other front-ends without the need to separately develop SDK (software development kit, Software Development Kit) files to interact with webview (components used to embed web page content in mobile applications or desktop applications), and unidirectional insertion of input box components. The report form file does not need to run across platforms. The report form file finally generated by the file processing method is based on the initially imported file, and the acquired measurement values are filled in and rendered in the initial template. It does not involve the process of converting between the intermediate template and HTML format, that is, the original style of the file is retained to the greatest extent.
[0166] Embodiment five:
[0167] Another embodiment of the present application relates to a file processing device 700. The implementation details of the file processing device 700 of this embodiment are specifically described below. The following content is only for the convenience of understanding the implementation details provided, and is not necessary for implementing this solution. The schematic diagram of the file processing device 700 of this embodiment can be as follows Figure 7 As shown, it includes: an import module 701, a parsing module 702, a rendering module 703, an inserting module 704 and a forming module 705.
[0168] The import module 701 is used to import the digital report template into the target application according to the preset import specification; the digital report template includes a plurality of blank entries;
[0169] The parsing module 702 is used to parse the digital report template to obtain a target format file for rendering and an item parameter file for standardizing the item editing component;
[0170] A rendering module 703 is used to render the digital report form template using the target format file to obtain a digital report form instance;
[0171] Insertion module 704, used to call the item parameter file to insert the item editing component into the digital report form instance to generate an editable report form file;
[0172] The forming module 705 is used to input the entry data into the report editable file through the entry item editing component to form a report file.
[0173] In some optional embodiments, the digital report template is parsed to obtain a target format file for rendering and an item parameter file for standardizing the item editing component, including:
[0174] Use document processing tools to convert the digital report form template into a character string to obtain a word character string file;
[0175] Extract JSON parameters from the word string file, and replace the JSON parameters with placeholders to obtain an entry item parameter file for standardizing the entry item editing component;
[0176] Perform string conversion on the word string file to obtain an HTML format file for rendering.
[0177] In some optional embodiments, calling the item parameter file to insert the item editing component into the digital report form instance to generate an editable report form file includes:
[0178] The item parameter file is used to judge the type of the item in the digital report form instance to obtain a judgment result;
[0179] According to the judgment result, the item editing component corresponding to the item in the digital report form instance is inserted into the digital report form instance to generate an editable report form file.
[0180] In some optional embodiments, the process of determining the entry data includes:
[0181] Collect parameter data corresponding to the items in the editable file of the report form;
[0182] Fill in the parameter data corresponding to the entry item into the editable report form file to obtain a preformed report form file;
[0183] Supplement and correct the parameter data corresponding to the entry items in the pre-formed report file to determine the entry data.
[0184] In some optional embodiments, the file processing device 700 may further include:
[0185] The judgment module 706 uses the item parameter file to judge the source type of the parameter data; the source types include: automatic collection and manual entry.
[0186] In some optional embodiments, supplementing and correcting the parameter data corresponding to the item in the pre-formed report file to determine the item data includes:
[0187] Traverse the parameter data corresponding to the items in the pre-formed report file;
[0188] The erroneous parameter data is corrected and the missing parameter data is supplemented to obtain the entry data.
[0189] In some optional embodiments, the item data is input into the report editable file through the item editing component to form a report file, including:
[0190] Read word string file from database;
[0191] Perform regular expression parsing on the word string file, replace the placeholders in the word string file with the entry data, and obtain the word string report file;
[0192] Save the word string report file as a word file to obtain the report file.
[0193] In this embodiment, the file processing device can be used to extract the report form test parameters separately, and the form differentiation work can be moved forward to the template data processing, thereby unifying the report form files, simplifying the program logic, and avoiding data parsing errors.
[0194] It should be noted that the file processing device is a file processing device corresponding to the above-mentioned file processing method. All implementation methods in the embodiment of the above-mentioned file processing method are applicable to the embodiment of the file processing device and can achieve the same effect.
[0195] It is worth mentioning that all modules involved in this embodiment are logic modules. In practical applications, a logic unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of this application, this embodiment does not introduce units that are not closely related to solving the technical problems proposed by this application, but this does not mean that there are no other units in this embodiment.
[0196] Embodiment six:
[0197] Another embodiment of the present application relates to an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the file processing method in the above-mentioned embodiments.
[0198] Among them, the memory and the processor are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor.
[0199] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory can be used to store data used by the processor when performing operations.
[0200] Embodiment seven:
[0201] Another embodiment of the present application relates to a computer-readable storage medium storing a computer program, which implements the above method embodiment when executed by a processor.
[0202] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as: ROM), random access memory (Random Access Memory, referred to as: RAM), disk or optical disk and other media that can store program codes.
[0203] Those skilled in the art will appreciate that the above embodiments are specific embodiments for implementing the present application, and in actual applications, various changes may be made thereto in form and detail without departing from the spirit and scope of the present application.
Claims
1. A method for processing a file, characterized in that: include: Import the digital report template into the target application according to the preset import specification; The digital report template includes a plurality of blank entries; Parsing the digital report template to obtain a target format file for rendering and an item parameter file for standardizing item editing components; Rendering the digital report form template using the target format file to obtain a digital report form instance; Calling the item parameter file to insert the item editing component into the digital report form instance to generate an editable report form file; The item data is input into the report editable file through the item editing component to form a report file.
2. The method for processing a file according to claim 1, characterized in that: The file parsing of the digital report template to obtain a target format file for rendering and an item parameter file for standardizing the item editing component includes: Using a document processing tool to perform character string conversion processing on the digital report form template to obtain a word character string file; Extracting JSON parameters from the word string file, and replacing the JSON parameters with placeholders, to obtain an entry item parameter file for standardizing an entry item editing component; The word character string file is subjected to character string conversion processing to obtain an HTML format file for rendering.
3. The method for processing a file according to claim 2, characterized in that: The calling of the item parameter file to insert the item editing component into the digital report form instance to generate an editable report form file includes: Using the item parameter file to judge the type of the item in the digital report form instance to obtain a judgment result; According to the judgment result, the item editing component corresponding to the item in the digital report form instance is inserted into the digital report form instance to generate an editable report form file.
4. The method for processing a file according to claim 1, characterized in that: The process of determining the entry data includes: Collecting parameter data corresponding to the entry items in the editable file of the report form; Filling the parameter data corresponding to the entry item into the editable report form file to obtain a preformed report form file; The parameter data corresponding to the entry items in the preformed report file are supplemented and corrected to determine the entry data.
5. The method for processing a file according to claim 4, characterized in that: Also includes: Using the entry parameter file to determine the source type of the parameter data; The source types include: automatic collection and manual entry.
6. The method for processing a file according to claim 4, characterized in that: The step of supplementing and correcting the parameter data corresponding to the item in the preformed report file to determine the item data includes: Traversing the parameter data corresponding to the items in the preformed report file; The erroneous parameter data is corrected and the missing parameter data is supplemented to obtain entry data.
7. The method for processing a file according to claim 2, characterized in that: The step of inputting the entry data into the editable report file through the entry item editing component to form a report file includes: Read the word string file from the database; Performing regular expression parsing processing on the word string file, replacing the placeholders in the word string file with the entry data, and obtaining a word string report file; The word character string report file is saved as a word file to obtain the report file.
8. A file processing device, characterized in that: include: An import module, used for importing the digital report template into the target application according to a preset import specification; The digital report template includes a plurality of blank entries; A parsing module, used for parsing the digital report template to obtain a target format file for rendering and an item parameter file for standardizing an item editing component; A rendering module, used to render the digital report form template using the target format file to obtain a digital report form instance; An inserting module, used for calling the item parameter file to insert the item editing component into the digital report form instance to generate an editable report form file; A forming module is used to input the entry data into the report editable file through the entry item editing component to form a report file.
9. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the file processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the file processing method according to any one of claims 1 to 7 is implemented.