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

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

Info

Publication number
CN116702720A
CN116702720A CN202310759920.0A CN202310759920A CN116702720A CN 116702720 A CN116702720 A CN 116702720A CN 202310759920 A CN202310759920 A CN 202310759920A CN 116702720 A CN116702720 A CN 116702720A
Authority
CN
China
Prior art keywords
tree data
node
table file
file
comparison result
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310759920.0A
Other languages
Chinese (zh)
Inventor
段丁瑞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202310759920.0A priority Critical patent/CN116702720A/en
Publication of CN116702720A publication Critical patent/CN116702720A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/177Editing, e.g. inserting or deleting of tables; using ruled lines
    • G06F40/18Editing, e.g. inserting or deleting of tables; using ruled lines of spreadsheets
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a file processing method, a file processing device, electronic equipment and a storage medium, and relates to the technical field of data processing. According to the method, the conversion of the form files to be processed is realized based on the preset structure information of the form types of the files, tree data of the form files to be processed are generated, tree comparison is conducted based on the tree data of the form files to be processed, accuracy of corresponding relations of all sub-units among different form files is guaranteed, accuracy of comparison results of different form files to be processed is guaranteed, fusion and conflict judgment of the local form files and the far-end form files can be conducted based on the comparison results, fusion content between the local form files and the far-end form files is determined, automatic fusion processing between the local form files and the far-end form files is achieved, and accuracy of file fusion is improved.

Description

File processing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a method and apparatus for processing a file, an electronic device, and a storage medium.
Background
In the development of online games, developers often use Excel files to configure game content, and submit the Excel files to version control tools such as SVN and GIT for processing. Since in the version control tool, excel files are treated as binary files. Therefore, when multiple persons modify and submit the same Excel file (such as branch merging), the case of Excel file modification conflict often occurs, so that the accuracy of the generated file of the latest version cannot be ensured. Therefore, there is a need to solve the problem of file modification conflicts by means of file comparison and fusion.
In the prior art, the comparison method of the Excel files is commonly adopted and is realized based on the longest public subsequence algorithm, the comparison process is to calculate the similarity of the rows and the columns in the two Excel files to be compared according to the longest public subsequence algorithm, find out the corresponding relation of the rows and the columns in the two Excel files, thereby obtaining the new addition and deletion of the rows and the modification of the cells, and complete the fusion process of the Excel files on the basis.
However, the comparison mode of the method is one-sided, and the accuracy of the comparison result is poor, so that fusion is performed based on the comparison result, and the accuracy of the generated fusion result is poor.
Disclosure of Invention
The application aims to provide a file processing method, a file processing device, electronic equipment and a storage medium, so as to improve the accuracy of table file comparison and fusion.
In order to achieve the above purpose, the technical scheme adopted by the embodiment of the application is as follows:
in a first aspect, an embodiment of the present application provides a file processing method, including: converting each form file to be processed according to preset structure information of the form type file to generate tree data of each form file to be processed, wherein the preset structure information comprises: hierarchical relationships of subunits; the same identification information is arranged between the corresponding sub-units in different form files to be processed; the table file to be processed includes: original table files, local table files and remote table files;
comparing the tree data of each to-be-processed form file to obtain a comparison result of each node in the tree data of each to-be-processed form file, wherein the comparison result represents the relative modification content among different to-be-processed form files;
determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file;
Updating the fusion state of the nodes in the tree data of the local table file according to the comparison result of the nodes in the tree data of the remote table file, and updating the local table file according to the fusion state of the nodes in the tree data updated by the local table file and the node type.
In a second aspect, an embodiment of the present application further provides a file processing apparatus, including: the device comprises a generation module, a comparison module, a determination module and an updating module;
the generating module is configured to convert each form file to be processed according to preset structure information of the form type file, and generate tree data of each form file to be processed, where the preset structure information includes: hierarchical relationships of subunits; the same identification information is arranged between the corresponding sub-units in different form files to be processed; the table file to be processed includes: original table files, local table files and remote table files;
the comparison module is used for comparing the tree data of each form file to be processed to obtain a comparison result of each node in the tree data of each form file to be processed, and the comparison result represents the relative modification content among different form files to be processed;
The determining module is used for determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file;
the updating module is used for updating the fusion state of the nodes in the tree data of the local table file according to the comparison result of the nodes in the tree data of the remote table file, and updating the local table file according to the fusion state of the nodes in the tree data updated by the local table file and the node type.
In a third aspect, an embodiment of the present application provides an electronic device, including: a processor, a storage medium, and a bus, the storage medium storing machine-readable instructions executable by the processor, the processor and the storage medium communicating over the bus when the electronic device is operating, the processor executing the machine-readable instructions to implement a file processing method as provided in the first aspect.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs a file processing method as provided in the first aspect.
The beneficial effects of the application are as follows:
the application provides a file processing method, a device, electronic equipment and a storage medium, which are used for realizing the conversion of a to-be-processed form file based on preset structure information of the form type file, generating tree data of the to-be-processed form file, thereby carrying out tree comparison based on the tree data of the to-be-processed form file, ensuring the accuracy of the corresponding relation of all sub-units among different form files, further ensuring the accuracy of the comparison result of different to-be-processed form files, and carrying out fusion and conflict judgment of the local form file and the far-end form file based on the comparison result to determine the fusion content between the local form file and the far-end form file, so as to realize the automatic fusion processing between the local form file and the far-end form file and improve the accuracy of file fusion.
In addition, the comparison result and the fusion state are displayed according to the preset display style through the provided windows platform graphical interface, so that a user can conveniently and clearly check the comparison result and the fusion result and perform conflict processing, the workload of manually processing the conflict of the Excel file is reduced, and the accuracy of the conflict processing of the Excel file and the processing efficiency of the Excel file in the branch development process are improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart illustrating a method for processing a file according to an embodiment of the present application;
FIG. 2 is a second flowchart of a file processing method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of tree data of a table file according to an embodiment of the present application;
FIG. 4 is a flowchart illustrating a method for processing a file according to an embodiment of the present application;
FIG. 5 is a flowchart illustrating a method for processing a file according to an embodiment of the present application;
FIG. 6 is a flowchart of a file processing method according to an embodiment of the present application;
FIG. 7 is a flowchart illustrating a method for processing a file according to an embodiment of the present application;
FIG. 8 is a flowchart of a file processing method according to an embodiment of the present application;
FIG. 9 is a flowchart eighth of a method for processing a file according to an embodiment of the present application;
Fig. 10 is a flowchart illustrating a file processing method according to an embodiment of the present application;
FIG. 11 is a flowchart illustrating a method for processing a file according to an embodiment of the present application;
FIG. 12 is a schematic diagram of a document processing apparatus according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for the purpose of illustration and description only and are not intended to limit the scope of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in this disclosure, illustrates operations implemented according to some embodiments of the present application. It should be understood that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to or removed from the flow diagrams by those skilled in the art under the direction of the present disclosure.
In addition, the described embodiments are only some, but not all, embodiments of the application. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present application.
It should be noted that the term "comprising" will be used in embodiments of the application to indicate the presence of the features stated hereafter, but not to exclude the addition of other features.
In the development of online games, developers often use Excel files to configure game content, and incorporate the Excel files into version control tools such as SVN (version control system of open source), GIT (distributed version control system of open source), and the like. Since in these versioning tools Excel files are treated as binary files. Therefore, when multiple persons modify and commit the same Excel file (e.g., branch merge), there is often a case where the Excel file conflicts. These conflicts typically require the submitter to compare via an Excel file comparison tool and manually modify the Excel file and resubmit. To increase the efficiency and accuracy of this conflict handling process, an efficient, accurate Excel file comparison and fusion system is generally required.
In a common Excel file comparison and fusion system, the common Excel file comparison method is generally based on the longest common subsequence (Longest Common Subsequence) algorithm. The comparison process calculates the similarity of the rows and the columns of the two-dimensional tables to be compared according to the longest public subsequence algorithm, and finds out the corresponding relation of the rows and the columns in the two Excel tables, so that the new addition and deletion of the rows and the columns and the modification of the cells are obtained, and the fusion process of the Excel files is completed on the basis.
Current Excel file comparison and fusion systems typically suffer from three problems:
1. cannot guarantee the accuracy of the comparison and fusion results
As mentioned above, the comparison method of the Excel file commonly used at present is based on the longest public subsequence, and the method calculates the corresponding relation between the Excel row and the Excel column based on the similarity, and according to the specific use situation and the data, errors or situations that cannot be handled (such as modification of the similar row and the similar column, or addition and deletion of the whole row and the whole column) may exist, so that an accurate comparison result of the Excel file cannot be always obtained, and the accuracy and stability of the fusion of the Excel file are further affected.
2. Partial code frames have imperfect support for Excel file reading and writing
At present, common codes such as python, java, C # and the like have various code libraries for supporting reading and writing of Excel files, but due to the fact that the version of Excel software (namely, office software) is more (such as office2016, office365, office2019 and the like) and the content of the Excel files is diversified (including numbers, texts, hyperlinks, formats, endorsements, formulas, screening, data verification and the like), the support of part of the code libraries for reading and writing of the Excel files is imperfect or lacks maintenance, and partial content loss (such as endorsement and format loss) can be caused when the Excel files of specific versions are opened and generated, and the consistency of the files generated by fusion and the original files in all aspects cannot be ensured.
3. Cross-platform support for Excel file comparison and fusion is not implemented
The existing Excel file comparison and fusion system is usually completed in a windows platform, and comparison and fusion of Excel files under cross-platform are not achieved. Under the high-strength branch development flow, the efficiency of the development flow can be greatly improved by automatically executing the fusion branch through the server, namely, requirements are provided for Excel file comparison and cross-platform support of a fusion system.
Based on the problems of the accuracy, excel file support and cross-platform of the existing Excel file comparison and fusion system, the application provides the cross-platform Excel file comparison and fusion system based on the structural information, and the Excel file comparison and fusion is converted into tree data to be processed, so that the comparison and fusion of the multi-version Excel files under multiple platforms are realized, and the accuracy and the efficiency of the Excel file fusion are improved.
FIG. 1 is a flowchart illustrating a method for processing a file according to an embodiment of the present application; the subject of execution of the method may be a computer device, as shown in fig. 1, the method may include:
s101, converting each form file to be processed according to preset structure information of the form type file to generate tree data of each form file to be processed, wherein the preset structure information comprises: hierarchical relationships of subunits; the same identification information is arranged between the corresponding sub-units in different form files to be processed; the table file to be processed includes: original table file, local table file and remote table file.
A form type file is typically composed of a structure of rows, columns, and cells composed of rows and columns, such as a common Excel file. The structure information of the form type file is generally fixed, and is generally composed of sub-units such as worksheets, rows, columns, cells and the like, and the hierarchical relationship among the sub-units is also preset, that is, the preset structure information here may include each sub-unit constituting the form type file and the hierarchical relationship among the sub-units, and the form type file may be subjected to format conversion according to the preset structure information. In this embodiment, the table file may be converted into tree data for processing.
In some embodiments, for different table files, to facilitate comparison between files, to ensure correspondence of the comparison, the same identification information may be assigned to corresponding sub-units in different table files. For example: the working table 1 in the table file 1 and the working table 1 in the table file 2 have the same identification information, and the row 1 under the working table 1 in the table file 1 and the row 1 under the working table 1 in the table file 2 have the same identification information, namely, the corresponding working tables, rows and columns in different table files have the same ID and each ID has uniqueness, so that the indexing of the corresponding sub-units in different table files is facilitated.
Optionally, the table files to be processed related to the scheme may include an original table file, a local table file and a remote table file. Where the original table file may refer to a base table file (or an old version of a table file, a base file), the local table file may refer to a locally modified file (or a local branched table file, a local file), and the remote table file may refer to a remotely stored latest version of a table file (or a remote branched table file, a remote file). The common ancestor version of the local table file and the remote table file is the original table file.
The remote form file may also be understood as a current latest form file, which exists as a public file, when there are multiple users modifying the same original form file, because different users may have a sequence during modification, each user submits the modified form file to the remote end for storage after local modification, in principle, the modification of the later user should be based on the latest form file submitted by the previous user modification, that is, the modification of the later user should be based on the remote form file, but because there may be an asynchronous problem in data, the remote form file cannot be obtained timely, so when each user modifies locally, the local form file is usually generated based on the original form file, and then the local form file and the remote form file are fused, so as to obtain the latest form file submitted after local modification, thereby ensuring the accuracy and integrity of file modification.
Exemplary: both a and b modify the original form file, a modifies locally and submits it to the remote end, and b modifies the original form file based on the fact that a submits the storage and the latest version form file of the remote end (remote form file) in local modification, but there may be data asynchronization, b does not acquire the remote form file, and b modifies the original form file based on the original form file.
S102, comparing the tree data of the form files to be processed to obtain comparison results of all nodes in the tree data of the form files to be processed, wherein the comparison results represent relative modification contents among different form files to be processed.
It should be noted that, the comparison process of files generally occurs when a user views a local file modification or views a difference between two versions (or branches) of a certain file, and mainly involves two files: an original table file and a local table file.
The fusion process often occurs in the process of submitting local modification or branching fusion by a user, and mainly involves three files: original table file, local table file and remote table file. And the fusion process needs to make fusion judgment based on the comparison result generated in the comparison process.
When the method is applied to a file comparison scene, the above-mentioned form text to be processed may include: original table file, local table file.
When the method is applied to a file fusion scene, the to-be-processed form text may include: original table file, local table file and remote table file.
Optionally, tree comparison can be performed based on tree data of the form file to be processed obtained after the form file to be processed is converted, wherein each subunit in the form of tree nodes is correspondingly displayed in the form of tree nodes in the tree data, and comparison of the form files is performed on each subunit in the form files, so that comparison results of each node in the tree data of each form file to be processed can be generated. Each table file to be processed corresponds to tree data, each tree data can correspond to a data table, the data table is used for recording attribute information of nodes in the tree data, and a comparison result of the nodes can be one of the attribute information of the nodes.
The comparison results may characterize the relative modification between different table files to be processed, such as: if the two table files to be compared are a and b, respectively, then when the comparison result of the node 1 (assumed to be row 1) in the tree data of the table file a is new, it may be expressed that: table file a is newly added with row 1 relative to table file b.
S103, determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file.
When the table fusion is performed, the modification in the local table file and the modification in the remote table file need to be fused, and then the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file can be obtained respectively. And the fusion conflict judgment of the two table files is carried out according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file, and the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file are respectively generated according to the judgment result.
In some embodiments, the fusion state may indicate whether the nodes can be fused, when the fusion state is fusible, the fusible nodes can be fused, and when the fusion state is conflicted, it is indicated that different modification modes are presented for the same node, and the confliction needs to be resolved.
S104, updating the fusion state of the nodes in the tree data of the local table file according to the comparison result of the nodes in the tree data of the remote table file, and updating the local table file according to the fusion state of the nodes in the tree data updated by the local table file and the node type.
In some embodiments, based on the comparison result, the fusion state of the nodes in the tree data of the local table file can be updated based on the comparison result of each node in the tree data of the remote table file, so as to obtain a more accurate fusion state of the nodes in the tree data of the local table file.
Optionally, the local table file may be modified and updated based on the fusion state of the nodes in the tree data updated by the local table file and the node type, so as to generate a local modified target table file, and after the local modified target table file is submitted, the current remote table file may be updated, so as to obtain a new remote table file.
In summary, according to the file processing method provided by the embodiment, the conversion of the to-be-processed form file is realized based on the preset structure information of the form type file, and the tree data of the to-be-processed form file is generated, so that the tree comparison is performed based on the tree data of the to-be-processed form file, the accuracy of the corresponding relation of each subunit between different form files is ensured, the accuracy of the comparison result of different to-be-processed form files is ensured, and the fusion and conflict judgment of the local form file and the far-end form file can be performed based on the comparison result, so that the fusion content between the local form file and the far-end form file is determined, and the automatic fusion processing between the local form file and the far-end form file is realized, and the file fusion accuracy is improved.
FIG. 2 is a second flowchart of a file processing method according to an embodiment of the present application; alternatively, in a conventional form type file, the subunits may each include: file table, row, column, cell; the present embodiment is described in terms of a table file containing four types of subunits, namely a file table, rows, columns, and cells.
Optionally, in step S101, converting each form file to be processed according to preset structure information of the form type file to generate tree data of each form file to be processed may include:
S201, screening the sub-units to be processed in each table file to be processed according to the hierarchical relation of each sub-unit in the table type file, the pre-configured sub-unit screening condition and the identification generation mode, and distributing identification information for each screened sub-unit.
In some embodiments, since the number of sub-units contained in the table file is large, it is also possible to contain multiple sub-units for one type, e.g., multiple rows, multiple columns, multiple worksheets, etc. While the comparison for the table file may often be performed only on a portion of the subunits in the table file, no complete comparison is required.
Based on this, in this embodiment, according to preset subunit screening conditions and identifier generation modes, according to the hierarchical relationship of subunits in the preset structural information, the subunits to be processed in each to-be-processed table file are screened, and identifier information is allocated to each screened subunit.
The identification of the sub-unit to be selected may be indicated in the sub-unit screening conditions, and the sub-unit screening conditions may include: worksheet screening conditions, row screening conditions, column screening conditions, and cell screening conditions.
Regarding the generation of subunit identifiers, for a worksheet, the title of the worksheet or the serial number of the worksheet may be employed as its identification information; for a row, a first cell of a certain two columns can be used as row identification information or a row number can be used as row identification information; for a column, the first n cells of a certain row may be used as column identification information or a column number may be used as column identification information; for a cell, the identification information of the row and the identification information of the column may be spliced as the identification information of the cell.
S202, constructing tree data of a table file to be processed from top to bottom according to the hierarchical relation of the screened subunits, wherein the number of layers contained in the tree data is consistent with the number of types of the subunits, and the types of nodes contained in each layer are determined according to the hierarchical relation of each subunit.
Optionally, a more obvious hierarchical relationship exists among file tables, rows, columns and cells in the file of the table type: for example: the table file contains a plurality of worksheets, each worksheet containing a plurality of rows and columns, each row and column containing a plurality of cells that are not empty.
The process of generating tree data from a table file may be as follows:
1) And reading the table file to be processed, and initializing a root node, namely a file node.
2) Traversing all the worksheets in the to-be-processed table file, generating worksheet nodes by the worksheet screening conditions and the identification generation rules of the worksheets, and sequentially placing the worksheets in the child node list of the root node.
3) And traversing the rows and the columns of all the worksheets to be processed respectively, generating row nodes or column nodes for the rows or the columns to be processed according to the screening conditions and the identification generation rules of the rows and the columns, and sequentially putting the row nodes or the column nodes into a child node list of the worksheet nodes.
4) Traversing all non-empty cells in each worksheet, generating cell nodes by using cell screening conditions and identification generating rules, finding out nodes generated by corresponding rows and columns of the cells, and respectively placing the cell nodes into child node lists of the row nodes and the column nodes.
Through the algorithm flow, the table file to be processed can be converted into four-layer tree data which takes the file node as a root node, and takes file nodes, worksheet nodes, row and column nodes and cell nodes as all layers from top to bottom.
Fig. 3 is a schematic diagram of tree data of a table file according to an embodiment of the present application.
As shown in fig. 3, taking an Excel file as an example of a table file to be processed, a schematic diagram of converting the Excel file into tree data is shown, and the layers from top to bottom are as follows: excel files, worksheets, rows or columns, cells.
As illustrated in fig. 3, the inclusion relationship of the sub-cells between the layers is represented, the Excel file includes a working table 1, a working table 2, and the like, the working table 1 includes a row 1, a row 2, a column 1, a column 2, and the like, the cell 1 is configured by the row 1 and the column 1, the cell 2 is configured by the row 1 and the column 2, the cell 3 is configured by the row 2 and the column 1, the cell 4 is configured by the row 2 and the column 2.
FIG. 4 is a flowchart illustrating a method for processing a file according to an embodiment of the present application; optionally, in step S102, comparing the tree data of each to-be-processed table file to obtain a comparison result of each node in the tree data of each to-be-processed table file may include:
s401, comparing the tree data of the local table file with corresponding nodes in the tree data of the original table file to generate a comparison result of each node in the tree data of the local table file, wherein the comparison result comprises: new addition, deletion, modification and no operation.
In some embodiments, since the local table file and the remote table file are both obtained after modification based on the original table file, the local table file may be compared with the original table file to obtain a comparison result of the local table file; and comparing the remote form file with the original form file to obtain a comparison result of the remote form file.
Then, the tree data of the local table file may be compared with the corresponding nodes in the tree data of the original table file, so as to generate a comparison result of each node in the tree data of the local table file. The comparison performed by the corresponding node may refer to that two corresponding nodes (two nodes having the same identification information) in the two tree data are compared respectively. For example: the node 1 in the tree data of the local table file is compared with the node 1 in the tree data of the original table file, the node 2 in the tree data of the local table file is compared with the node 2 in the tree data of the original table file, and the like.
S402, comparing the tree data of the remote form file with corresponding nodes in the tree data of the original form file to generate a comparison result of each node in the tree data of the remote form file.
Similarly, the tree data of the remote form file is compared with the corresponding nodes in the tree data of the original form file, so that a comparison result of each node in the tree data of the remote form file is generated.
FIG. 5 is a flowchart illustrating a method for processing a file according to an embodiment of the present application; optionally, in step S401, comparing the tree data of the local table file with the corresponding nodes in the tree data of the original table file, to generate a comparison result of each node in the tree data of the local table file may include:
s501, if the corresponding node to be compared is empty in the tree data of the local table file and is not empty in the tree data of the original table file, determining that the comparison result of the corresponding node in the tree data of the original table file is deletion.
In some embodiments, the tree data of the local table file and the tree data of the original table file may be converted into the node dictionary form, so that the comparison of all the corresponding nodes is implemented by traversing all the keys in the node dictionary for node indexing.
The node dictionary may refer to tree data represented in the form of a value by the node itself with the node's identification as a key. For example: assuming that the identifier of the row 1 in the tree data is a as a key, when the key is used for indexing, the row 1 can be queried by querying the key a, so that the row 1 is compared.
The conversion of the tree data into the node dictionary is only for facilitating indexing to the corresponding node, and the above processing may not be performed in practical application.
In the first case, if the corresponding node to be compared is empty in the tree data of the local table file, but not in the tree data of the original table file, that is, the corresponding node is deleted in the local table file, but in the deleted state, the tree data of the local table file does not include the corresponding node, and the record of the node comparison result cannot be performed, in which case, the comparison result of the corresponding node may be recorded as deleted in the tree data of the original table file.
S502, if the corresponding node to be compared is not empty in the tree data of the local table file and is empty in the tree data of the original table file, determining that the comparison result of the corresponding node in the tree data of the local table file is new.
In the second case, if the corresponding node to be compared is not null in the tree data of the local table file, but null in the tree data of the original table file, that is, the corresponding node is actually added in the local table file, and since the corresponding node exists in the tree data of the local table file, the comparison result of the corresponding node can be recorded in the tree data of the local table file as a new addition.
S503, if the corresponding node to be compared is not null in the tree data of the local table file and the tree data of the original table file, recursively searching the cell nodes in the sub-nodes of the corresponding node, and determining comparison results of the corresponding node in the tree data of the local table file and the tree data of the original table file respectively according to the values of the cell nodes.
And in the third case, if the corresponding node to be compared is not null in the tree data of the local table file and the tree data of the original table file and the corresponding node is a cell node, determining the comparison result of the corresponding node according to the value of the cell node in the local table file and the value of the cell node in the original table file respectively.
If the corresponding node is not a cell node, the comparison result of the corresponding node is determined by the sub-node comparison result of the corresponding node, and the cell node corresponding to the corresponding node can be sequentially found downwards in a recursive comparison mode, and the comparison result of the corresponding node is determined according to the comparison mode of the cell node.
S504, determining the comparison result of each node in the tree data of the local table file according to the comparison result of each node in the tree data of the original table file and the comparison result of each node in the tree data of the local table file.
Optionally, since some types of comparison results of the local table file with respect to the original table file are recorded in the node comparison results of the tree data of the original table file, the comparison results of the nodes in the tree data of the original table file and the comparison results of the nodes in the tree data of the local table file may be integrated to obtain the comparison results of the nodes in the tree data of the local table file.
Optionally, in step S503, determining, according to the values of the cell nodes, comparison results of the corresponding nodes in the tree data of the local table file and in the tree data of the original table file, respectively, may include: if the values of the cell nodes are inconsistent in the tree data of the local table file and the tree data of the original table file, determining that the comparison results of the corresponding nodes in the tree data of the local table file and the tree data of the original table file are modified.
In the third case, when the corresponding node is a cell node, for comparison of the cell node, when the values of the cell node are inconsistent in the tree data of the local table file and in the tree data of the original table file, that is, the same cell in the local table file and the original table file has different data, it may be determined that the comparison result of the corresponding node in the tree data of the local table file and in the tree data of the original table file is modified. If the values of the cell nodes are consistent in the tree data of the local table file and the tree data of the original table file, the comparison results of the corresponding nodes in the tree data of the local table file and the tree data of the original table file can be determined to be unmodified.
When the tree data of the local table file and the comparison results of all corresponding nodes in the tree data of the original table file are not modified, the comparison results of the two table files are obtained as no operation; otherwise, the comparison result is modified.
FIG. 6 is a flowchart of a file processing method according to an embodiment of the present application; optionally, in step S504, determining the comparison result of each node in the tree data of the local table file according to the comparison result of each node in the tree data of the original table file and the comparison result of each node in the tree data of the local table file may include:
s601, obtaining the candidate nodes which are newly added and modified as the comparison result of the nodes in the tree data of the local table file and the candidate nodes which are deleted and modified as the comparison result of the nodes in the tree data of the original table file.
Optionally, the comparison results of all nodes in the tree data of the local table file can be traversed, and nodes with newly added and modified comparison results are obtained as candidate nodes; and traversing the comparison results of all nodes in the tree data of the original table file, and acquiring the nodes with all the comparison results deleted and modified as candidate nodes.
S602, according to the comparison result of each candidate node, generating the comparison result of each node in the tree data of the local table file.
Then, the comparison result of each node in the tree data of the local table file can be generated from the comparison result of each candidate node obtained as described above.
Table 1 below shows the comparison results of each node in the tree data of the generated table file:
TABLE 1
The last four rows (worksheet 3, table 3-row 2, table 3-column 5, table 3-cell (2, 5)) are comparison results of modified and deleted nodes in the tree data of the original table file, and are used as part of the comparison results of the nodes in the tree data of the local table file.
Optionally, the generating manner of the comparison result of the nodes in the tree data of the remote table file may be performed by referring to the above steps, which is not described herein again.
FIG. 7 is a flowchart illustrating a method for processing a file according to an embodiment of the present application; optionally, in step S103, determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file may include:
S701, the comparison result of the corresponding node in the tree data of the local table file and the tree data of the remote table file is a newly added node, the child node of the corresponding node and the comparison result of the child node are complemented in the tree data, the comparison result of the corresponding node is updated from the newly added node to the modified node, and the comparison result of each node updated in the tree data of the local table file and the comparison result of each node updated in the tree data of the remote table file are respectively obtained.
Through the embodiment, the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data of the remote table file can be obtained respectively. And then updating the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data of the remote table file according to the comparison result of the corresponding node. So as to ensure that the comparison result of each node based on the fusion state is accurate when the fusion state is determined, thereby improving the accuracy of the fusion result.
Optionally, the tree data of the local table file and the corresponding nodes (under the same ID) in the tree data of the remote table file are compared in a recursive manner (the comparison mode can refer to the three cases of steps S501-S503 for comparison) of the subtrees, the comparison results of all the nodes (the sub-nodes of the corresponding nodes) in the two subtrees are complemented, and the comparison results of the sub-tree root nodes (the corresponding nodes) are modified.
Table 2 is a schematic representation of the comparison result of each node updated in the tree data of the local table file:
TABLE 2
Node Comparison result
Worksheet 2 Modification of
TABLE 2 Row 5 Modification of
TABLE 2 column 6 Modification of
Table 2-Unit cell (5, 6) Modification of
Worksheet 3 Modification of
TABLE 3 Row 1 Modification of
TABLE 3 column 5 Modification of
Table 3-Unit cell (1, 5) Modification of
Worksheet 5 Deletion of
TABLE 5 Row 1 Deletion of
TABLE 5 column 6 Deletion of
Table 5-Unit cell (1, 6) Deletion of
Table 3 is a schematic representation of the comparison result of each node updated in the tree data of the remote table file:
TABLE 3 Table 3
/>
S702, obtaining a union set of each node updated in the tree data of the local table file and each node updated in the tree data of the remote table file, and obtaining a node set.
Optionally, the nodes updated in the tree data of the local table file and the nodes updated in the tree data of the remote table file can be combined to obtain a node set. In some embodiments, the obtained node set may be represented in a queue, that is, a queue of all nodes is generated, so that when the nodes are traversed to perform conflict determination, the nodes currently required to be traversed may be sequentially fetched from the head of the queue in turn, repetition of node traversal may be avoided, and the node set may be represented in a sequence form at present.
S703, traversing each node in the node set in turn, and generating a fusion state of each node updated in the tree data of the local table file and a fusion state of each node updated in the tree data of the remote table file according to a comparison result of the node traversed currently in the tree data of the local table file and a comparison result in the tree data of the remote table file respectively, wherein the fusion state comprises: no operation, fusion, conflict, new addition, deletion and modification.
Optionally, by sequentially traversing each node in the node set, generating a fusion state of each node updated in the tree data of the local table file and a fusion state of each node updated in the tree data of the remote table file according to a comparison result of the currently traversed node in the tree data of the local table file and a comparison result in the tree data of the remote table file respectively.
The specific fusion state generation mode is as follows:
FIG. 8 is a flowchart of a file processing method according to an embodiment of the present application; optionally, in step S703, generating the fusion state of each node updated in the tree data of the local table file and the fusion state of each node updated in the tree data of the remote table file according to the comparison result of the node traversed currently in the tree data of the local table file and the comparison result in the tree data of the remote table file, respectively, may include:
S801, if the currently traversed node is empty or only one of the currently traversed node is empty in the tree data of the local table file and the tree data of the remote table file, determining that the fusion states of the currently traversed node in the tree data of the local table file and the tree data of the remote table file are all fusible.
If the currently traversed node is empty in the tree data of the local table file and only one of the tree data of the remote table file is empty, that is, only one of the local table file and the remote table file modifies the node or neither of the two is modified, then the fusion states of the currently traversed node in the tree data of the local table file and the tree data of the remote table file can be considered to be fusion.
This can also be understood as the nodes currently traversed perform different modification operations in the local table file and the remote table file.
S802, if the currently traversed node is not null in the tree data of the local table file and the tree data of the far-end table file, judging whether the comparison results of the currently traversed node in the tree data of the local table file and the tree data of the far-end table file are the same or not.
If the currently traversed node is not null in the tree data of the local table file and the tree data of the remote table file, whether the comparison result of the currently traversed node in the tree data of the local table file and the tree data of the remote table file is the same can be further judged.
S803, if the comparison results are the same, judging whether the comparison results of the nodes traversed currently are all modified and the node values are different.
If the comparison results of the currently traversed nodes in the tree data of the local table file and the tree data of the remote table file are the same, whether the comparison results are all modified and whether the node values are different can be further judged.
S804, if the comparison results are all modified and the node values are different, determining that the fusion states of the currently traversed nodes in the tree data of the local table file and the tree data of the remote table file are all conflicts.
When the comparison results are all modified and the node values are different, the node traversed at present can be considered to be subjected to the same modification in the local table file and the remote table file, the modified contents are different, and the fusion states of the node traversed at present in the tree data of the local table file and the tree data of the remote table file are considered to be conflicts.
Optionally, in step S802, after determining whether the comparison result of the currently traversed node in the tree data of the local table file and the tree data of the remote table file is the same, the method further includes: if the comparison results are different, determining that the fusion states of the currently traversed nodes in the tree data of the local table file and the tree data of the remote table file are all conflicts.
If the comparison results of the currently traversed node in the tree data of the local table file and the tree data of the remote table file are different, the currently traversed node is considered to be modified differently in the local table file and the remote table file, and conflicts exist, so that the fusion states of the currently traversed node in the tree data of the local table file and the tree data of the remote table file are determined to be conflicts.
FIG. 9 is a flowchart eighth of a method for processing a file according to an embodiment of the present application; optionally, in step S104, updating the fusion state of the nodes in the tree data of the local table file according to the comparison result of the nodes in the tree data of the remote table file may include:
S901, if the comparison result of the target node in the tree data of the far-end table file is newly increased, a subtree taking the target node as a root node is newly increased in the tree data of the local table file, and the fusion state of the target node and all nodes of the subtree is updated to be newly increased; the target node indicates that the fusion state is a fusible node.
Based on the above determination of the fusion state, in this embodiment, the fusion state of the nodes in the tree data of the local table file may be updated by writing the node data with the fusion state being fusible in the tree data of the remote table file into the tree data of the local table file. Three situations can be distinguished:
first kind: and if the comparison result of the nodes in the tree data of the remote table file is new, a subtree taking the node as a root node is newly added at a corresponding position in the tree data of the local table file, and the fusion state of all the nodes of the subtree is set to be newly added. If the node is a worksheet, row or column node, the original location attribute of the same type of node is updated. The original position attribute is used for representing the original position of the node in the table file. For example: row identification, column identification, etc. The update of the original position attribute is to ensure that the identification of each column of the original rows in the table is not affected when the rows and columns are newly inserted or deleted.
Exemplary: for example, if the remote table file is inserted with the line 2, a new line 2 is inserted between the line 1 and the line 2 of the local table file, the identification of the original line 2 is changed to the old line 2, and the insertion is changed to the new line 2, so that in the subsequent modification, the modification to the line 2 can be accurately performed by finding the old line 2, and not performing the modification in the new line 2.
S902, if the comparison result of the target node in the tree data of the remote table file is modification and the target node is a cell node, modifying the value of the target node in the tree data of the local table file to be consistent with the value of the target node in the tree data of the remote table file, and updating the fusion state of the target node in the tree data of the local table file to be modified.
Second kind: the comparison result of the nodes in the tree data of the remote table file is modified: if the node is a cell node, modifying the value of the corresponding node in the tree data of the local table file to be the same as that in the tree data of the remote table file, and setting the fusion state of the node as to be modified; if not, the cell node is not processed.
S903, if the comparison result of the target node in the tree data of the remote table file is deletion, updating the fusion state of all nodes under the subtree of the target node in the tree data of the local table file to be deleted.
Third kind: and if the comparison result state of the nodes in the tree data of the remote table file is deletion, setting the fusion state of all the nodes under the subtree of the corresponding node in the tree data of the local table file to be deleted. If the node is a worksheet, row or column node, the original location attribute of the same type of node is updated.
The following table 4 shows a schematic diagram of the fusion state of nodes in tree data of a remote table file:
TABLE 4 Table 4
Through the above processing, the fusion state of the nodes in the tree data after the update of the local table file is as follows in table 5:
TABLE 5
Node Comparison result Fusion state
Worksheet 2 Modification of /
TABLE 2 Row 5 Modification of /
TABLE 2 column 6 Modification of Conflict with each other
Table 2-Unit cell (5, 6) Modification of Conflict with each other
Worksheet 3 Modification of /
TABLE 3 Row 1 Modification of /
TABLE 3 column 5 Modification of /
Table 3-Unit cell (1, 5) Modification of Conflict with each other
Worksheet 5 Deletion of /
TABLE 5 Row 1 Deletion of /
TABLE 5 column 6 Deletion of /
Table 5-Unit cell (1, 6) Deletion of /
TABLE 1 Row 1 New addition of To be newly added
Table 1-Unit cell (1, 2) New addition of To be newly added
Table 3-Unit cell (1, 6) Deletion of To be deleted
Table 3-Unit cell (1, 7) New addition of To be newly added
Fig. 10 is a flowchart illustrating a file processing method according to an embodiment of the present application; optionally, in step S104, updating the local table file according to the fusion state and the node type of the nodes in the tree data updated by the local table file may include:
S1001, ordering all nodes in the tree data after the local table file is updated according to the fusion state of the nodes in the tree data after the local table file is updated and the node types.
The above processing procedure has obtained the fusion state of the nodes in the tree data updated by the local table file, and in this embodiment, the local modified target file can be generated by generating the Excel file by the tree data.
In contrast to the process of converting an Excel file into tree data, the process of updating a local table file to generate a local modified target file is a process of converting the Excel tree data into a new Excel file, and the flow comprises the following steps:
1) And reading the local table file, and generating Excel file memory data newData which is completely the same as the local table file data.
2) And traversing all nodes in the tree data updated by the local table file with breadth first, and sequencing the nodes according to the fusion state (priority order to be deleted, added and modified) and the node types (priority order of worksheets, rows, columns and cells) of the nodes to generate a sequencing result.
S1002, traversing each node in turn according to the sequencing result, and updating the local table file according to the fusion state of the node traversed currently and the node type.
3) And traversing each node in turn according to the sequencing result, and updating the local table file according to the node type and the fusion state.
Optionally, in step S1002, updating the local table file according to the fusion state and the node type of the currently traversed node includes:
if the currently traversed node is a worksheet, a row or a column and the fusion state is deletion, deleting a subunit at a position corresponding to the node in the local table file.
a) The node type of the node traversed currently is worksheet, row or column, and the fusion state is deletion: and deleting the corresponding worksheet, row or column in newData according to the original position attribute of the node, and simultaneously clearing the format, data verification, screening and the like of the corresponding position.
If the currently traversed node is a worksheet, a row or a column and the fusion state is newly increased, the worksheet, the row or the column which is newly increased at the corresponding position of the node in the local table file is obtained;
b) The node type of the node traversed currently is worksheets, rows or columns, and the fusion state is newly added: and according to the original position attribute of the node, newly adding an empty worksheet, row or column in newData, and copying the format, data verification, screening and the like of the corresponding position in the remoteFile to write in newData.
If the node traversed currently is a cell and the fusion state is newly added or modified, determining the position of the node in the local table file according to the row node and the column node corresponding to the node, and writing the value of the cell in the remote table file into the position.
c) The node type of the node traversed currently is a cell, and the fusion state is newly added or modified: and acquiring the original positions of the corresponding rows and columns according to the two father nodes (row nodes and column nodes) corresponding to the node, and reading the values, formats, comments and the like of the corresponding cells in the remote table file and writing the values, formats, comments and the like into the positions.
Alternatively, after all node traversals are completed, the newData may generate the locally modified target file according to the subunit hierarchical relationship of the Excel file.
FIG. 11 is a flowchart illustrating a method for processing a file according to an embodiment of the present application; optionally, in step S103, after determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file, the method further includes:
s1101, according to node types, fusion states and comparison results of the nodes, and preset display patterns of the fusion states and display patterns of the comparison results, respectively converting tree data of the local table file and tree data of the remote table file into target forms for display, wherein the target forms comprise: in the form of a two-dimensional table.
In some embodiments, a graphical interface based on a windows platform is also implemented to implement result presentation of the comparison results and the fusion state.
The windows graphical interface converts comparison and fusion results of the Excel files into comparison and display of a plurality of groups of two-dimensional tables, and a user can switch through a drop-down option.
Alternatively, the display style of the fusion state and the display style of the comparison result may be preset, where the display style may include: the display colors and the display symbols can be used for representing different comparison results and different fusion results by adopting different colors and symbols, so that the comparison results and the fusion results can be displayed in a two-dimensional form according to a set style, and a user can clearly check the comparison results and the fusion state conveniently.
For example: new addition-corresponding yellow; delete-corresponds to orange; modification-corresponding purple; conflict-corresponding pink; the new addition is indicated by an addition sign; deletion is indicated by minus signs; the collision is represented by a sigh, etc. The display style can be adjusted in a self-adaptive mode at present, and different comparison results and fusion states can be effectively distinguished.
S1102, in response to a conflict processing operation input to the form with the conflict fusion state, changing the form information of the form with the conflict fusion state.
Optionally, on the basis of result display, a user can select a worksheet, skip to view and search through keys and shortcut keys, and meanwhile, file structure information and a result display style can be set and stored.
The modification operation for the file is done by the right-key option, and mainly includes three categories, data using the far-end table file, data using the local table file, and append to the end of the file (which can only be used in case of a row conflict):
(1) Data using remote form files: and using node data in the tree data of the remote form file to cover the node data in the tree data of the local form file, and modifying the fusion state into to-be-modified or to-be-deleted.
(2) Data using local table files: and modifying the fusion state of the corresponding nodes in the tree data of the local table file into no operation.
(3) Append to the end of file: and newly adding subtrees of corresponding rows at the end position in the tree data of the local table file, and modifying the fusion state to be newly added. After the user clicks on save or conflict resolution, these modification operations will be written in turn into the tree data of the local table file.
In some embodiments, when processing conflicts, a conflict handling operation may be based on a user entering for a target form in the presented fusion state results, where the conflict handling operation may be a right click, selecting whether to employ data in the local form file or data in the remote form file as the target value for the target form in the presented drop-down options.
Of course, for non-conflicting processing, similar to that described above, non-conflicting processing may also be performed by triggering the presentation of a drop-down option at the form location to be processed, selecting the desired data from the drop-down option.
For example: the local table file originally deletes one row, the remote table file is not modified, and no conflict exists after the local table file and the remote table file are fused, but after the local table file is checked by a user, the deletion operation of the row in the local table file is considered to belong to the wrong deletion, and the row needs to be restored, the drop-down menu can be triggered and displayed through the right key at the position to be restored, and the remote table file data is selected to be used, so that the content of the wrongly deleted row is newly added to the corresponding position.
In addition, in order to facilitate the automatic operation and cross-platform support of the scheme, a cross-platform user notification flow is realized to finish reminding of the automatic fusion result. When the non-windows platform runs, the scheme skips the step of displaying the result, and the judgment is directly carried out according to the conflict judgment and the automatic fusion result. If no node with the fusion state being the conflict exists in the conflict judging results of the local table file and the remote table file, a new Excel file is directly generated according to the automatic fusion result and is automatically submitted, and the fusion process is completed. Otherwise, the fusion process is stopped, the file is rolled back, all node information with the fusion state being the conflict is exported to be text, the corresponding user is traced back through the modification log of the file in the svn/git, the conflict information is sent to the user through the internal software of the company and the like, and the user is reminded of manual processing.
In summary, according to the file processing method provided in the embodiment, the conversion of the to-be-processed form file is realized based on the preset structure information of the form type file, and the tree data of the to-be-processed form file is generated, so that the tree comparison is performed based on the tree data of the to-be-processed form file, the accuracy of the corresponding relationship of each subunit between different form files is ensured, the accuracy of the comparison result of different to-be-processed form files is ensured, and the fusion and conflict judgment of the local form file and the remote form file can be performed based on the comparison result, so as to determine the fusion content between the local form file and the remote form file, thereby realizing the automatic fusion processing between the local form file and the remote form file, and improving the accuracy of file fusion.
In addition, the comparison result and the fusion state are displayed according to the preset display style through the provided windows platform graphical interface, so that a user can conveniently and clearly check the comparison result and the fusion result and perform conflict processing, the workload of manually processing the conflict of the Excel file is reduced, and the accuracy of the conflict processing of the Excel file and the processing efficiency of the Excel file in the branch development process are improved.
The following describes a device, equipment, storage medium, etc. for executing the file processing method provided by the present application, and specific implementation processes and technical effects thereof are referred to above, and are not described in detail below.
Fig. 12 is a schematic diagram of a file processing device according to an embodiment of the present application, where functions implemented by the file processing device correspond to steps executed by the above method. The apparatus may be understood as the above-mentioned computer device, as shown in fig. 12, and may include: a generating module 120, a comparing module 121, a determining module 122, and an updating module 123;
the generating module 120 is configured to convert each form file to be processed according to preset structure information of the form type file, and generate tree data of each form file to be processed, where the preset structure information includes: hierarchical relationships of subunits; the same identification information is arranged between the corresponding sub-units in different form files to be processed; the table file to be processed includes: original table files, local table files and remote table files;
the comparison module 121 is configured to compare tree data of each to-be-processed table file to obtain a comparison result of each node in the tree data of each to-be-processed table file, where the comparison result represents relative modification content between different to-be-processed table files;
The determining module 122 is configured to determine a fusion state of each node in the tree data of the local table file and a fusion state of each node in the tree data of the remote table file according to a comparison result of each node in the tree data of the local table file and a comparison result of each node in the tree data corresponding to the remote table file;
the updating module 123 is configured to update the fusion state of the nodes in the tree data of the local table file according to the comparison result of each node in the tree data of the remote table file, and update the local table file according to the fusion state of the nodes in the tree data updated by the local table file and the node type.
Optionally, the subunit comprises: file table, row, column, cell; the generating module 120 is specifically configured to screen the sub-units to be processed in each form file to be processed according to the hierarchical relationship of each sub-unit in the form type file, the pre-configured sub-unit screening condition and the identifier generating mode, and allocate identifier information to each screened sub-unit;
according to the hierarchical relationship of each screened subunit, constructing tree data of the table file to be processed from top to bottom, wherein the number of layers contained in the tree data is consistent with the number of types of subunits, and the types of nodes contained in each layer are determined according to the hierarchical relationship of each subunit.
Optionally, the comparing module 121 is specifically configured to compare the tree data of the local table file with corresponding nodes in the tree data of the original table file, and generate a comparison result of each node in the tree data of the local table file, where the comparison result includes: new addition, deletion, modification and no operation;
comparing the tree data of the remote form file with the corresponding nodes in the tree data of the original form file to generate a comparison result of each node in the tree data of the remote form file.
Optionally, the comparing module 121 is specifically configured to determine that the comparison result of the corresponding node in the tree data of the original table file is deletion if the corresponding node to be compared is empty in the tree data of the local table file and is not empty in the tree data of the original table file;
if the corresponding node to be compared is not empty in the tree data of the local table file and is empty in the tree data of the original table file, determining that the comparison result of the corresponding node in the tree data of the local table file is newly increased;
if the corresponding node to be compared is not null in the tree data of the local table file and the tree data of the original table file, recursively searching the cell nodes in the child nodes of the corresponding node, and determining comparison results of the corresponding node in the tree data of the local table file and the tree data of the original table file respectively according to the values of the cell nodes;
And determining the comparison result of each node in the tree data of the local table file according to the comparison result of each node in the tree data of the original table file and the comparison result of each node in the tree data of the local table file.
Optionally, the comparing module 121 is specifically configured to determine that the comparison result of the corresponding node in the tree data of the local table file and the tree data of the original table file is modified if the values of the cell nodes are inconsistent in the tree data of the local table file and the tree data of the original table file.
Optionally, the comparing module 121 is specifically configured to obtain that the comparison result of the nodes in the tree data of the local table file is a candidate node that is newly added and modified, and that the comparison result of the nodes in the tree data of the original table file is a candidate node that is deleted and modified;
and generating the comparison result of each node in the tree data of the local table file according to the comparison result of each candidate node.
Optionally, the determining module 122 is specifically configured to supplement the tree data of the local table file with the tree data of the remote table file by using the newly added node as the comparison result of the corresponding node, and supplement the tree data with the child node of the corresponding node and the comparison result of the child node, and update the comparison result of the corresponding node from the newly added node to the modified node, so as to obtain the comparison result of each node updated in the tree data of the local table file and the comparison result of each node updated in the tree data of the remote table file respectively;
Obtaining a union set of each node updated in the tree data of the local table file and each node updated in the tree data of the remote table file to obtain a node set;
traversing each node in the node set in turn, and generating a fusion state of each node updated in the tree data of the local table file and a fusion state of each node updated in the tree data of the remote table file according to a comparison result of the node traversed currently in the tree data of the local table file and a comparison result in the tree data of the remote table file respectively, wherein the fusion state comprises: no operation, fusion, conflict, new addition, deletion and modification.
Optionally, the determining module 122 is specifically configured to determine that the fusion states of the currently traversed node in the tree data of the local table file and the tree data of the remote table file are all fusible if the currently traversed node is null or only one of the currently traversed node is null in the tree data of the local table file and the tree data of the remote table file;
if the currently traversed node is not null in the tree data of the local table file and the tree data of the far-end table file, judging whether the comparison results of the currently traversed node in the tree data of the local table file and the tree data of the far-end table file are the same or not;
If the comparison results are the same, judging whether the comparison results of the nodes traversed currently are all modified or not and the node values are different;
if the comparison results are all modified and the node values are different, determining that the fusion states of the currently traversed nodes in the tree data of the local table file and the tree data of the remote table file are all conflicts.
Optionally, the determining module 122 is specifically configured to determine that the fusion states of the currently traversed node in the tree data of the local table file and the tree data of the remote table file are all conflicts if the comparison results are different.
Optionally, the updating module 123 is specifically configured to, if the comparison result of the target node in the tree data of the remote table file is new, newly add a subtree with the target node as a root node in the tree data of the local table file, and update the fusion state of the target node and all nodes of the subtree to be newly added; the target node indicates that the fusion state is a fusible node;
if the comparison result of the target node in the tree data of the remote table file is modification and the target node is a cell node, modifying the value of the target node in the tree data of the local table file to be consistent with the value of the target node in the tree data of the remote table file, and updating the fusion state of the target node in the tree data of the local table file to be modified;
If the comparison result of the target nodes in the tree data of the remote table file is deletion, updating the fusion state of all the nodes under the subtree of the target nodes in the tree data of the local table file to be deleted.
Optionally, the updating module 123 is specifically configured to sort each node in the tree data updated by the local table file according to the fusion state of the node in the tree data updated by the local table file and the node type;
and traversing each node in turn according to the sequencing result, and updating the local table file according to the fusion state and the node type of the node traversed currently.
Optionally, the updating module 123 is specifically configured to delete a subunit of the local table file at a position corresponding to the node if the node traversed currently is a worksheet, a row or a column and the fusion state is delete;
if the currently traversed node is a worksheet, a row or a column and the fusion state is newly increased, the worksheet, the row or the column which is newly increased at the corresponding position of the node in the local table file is obtained;
if the node traversed currently is a cell and the fusion state is newly added or modified, determining the position of the node in the local table file according to the row node and the column node corresponding to the node, and writing the value of the cell in the remote table file into the position.
Optionally, the apparatus further comprises: the display module and the conflict processing module;
the display module is used for respectively converting the tree data of the local table file and the tree data of the remote table file into target forms for display according to the node type, the fusion state and the comparison result of the nodes, and the preset display style of the fusion state and the preset display style of the comparison result, wherein the target forms comprise: a two-dimensional tabular form;
and the conflict processing module is used for responding to the conflict processing operation input for the table with the conflict fusion state and changing the table information of the table with the conflict fusion state.
The foregoing apparatus is used for executing the method provided in the foregoing embodiment, and its implementation principle and technical effects are similar, and are not described herein again.
The above modules may be one or more integrated circuits configured to implement the above methods, for example: one or more application specific integrated circuits (Application Specific Integrated Circuit, abbreviated as ASIC), or one or more microprocessors (digital singnal processor, abbreviated as DSP), or one or more field programmable gate arrays (Field Programmable Gate Array, abbreviated as FPGA), or the like. For another example, when a module above is implemented in the form of a processing element scheduler code, the processing element may be a general-purpose processor, such as a central processing unit (Central Processing Unit, CPU) or other processor that may invoke the program code. For another example, the modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
The modules may be connected or communicate with each other via wired or wireless connections. The wired connection may include a metal cable, optical cable, hybrid cable, or the like, or any combination thereof. The wireless connection may include a connection through a LAN, WAN, bluetooth, zigBee, or NFC, or any combination thereof. Two or more modules may be combined into a single module, and any one module may be divided into two or more units. It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the method embodiments, and are not repeated in the present disclosure.
Fig. 13 is a schematic structural diagram of an electronic device according to an embodiment of the present application, including: a processor 801, a storage medium 802, and a bus 803, the storage medium 802 storing machine-readable instructions executable by the processor 801, the processor 801 and the storage medium 802 communicating over the bus 803 when the electronic device runs a file processing method as in the embodiment, the processor 801 executing the machine-readable instructions to perform the steps of:
in one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: converting each form file to be processed according to preset structure information of the form type file to generate tree data of each form file to be processed, wherein the preset structure information comprises: hierarchical relationships of subunits; the same identification information is arranged between the corresponding sub-units in different form files to be processed; the table file to be processed includes: original table files, local table files and remote table files; comparing the tree data of the form files to be processed to obtain comparison results of all nodes in the tree data of the form files to be processed, wherein the comparison results represent relative modification contents among different form files to be processed; determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file; updating the fusion state of the nodes in the tree data of the local table file according to the comparison result of the nodes in the tree data of the remote table file, and updating the local table file according to the fusion state of the nodes in the tree data updated by the local table file and the node type.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: screening the sub-units to be processed in each form file to be processed according to the hierarchical relation of each sub-unit in the form type file, the pre-configured sub-unit screening conditions and the identification generation mode, and distributing identification information for each screened sub-unit; according to the hierarchical relationship of each screened subunit, constructing tree data of the table file to be processed from top to bottom, wherein the number of layers contained in the tree data is consistent with the number of types of subunits, and the types of nodes contained in each layer are determined according to the hierarchical relationship of each subunit.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: comparing the tree data of the local table file with corresponding nodes in the tree data of the original table file to generate a comparison result of each node in the tree data of the local table file, wherein the comparison result comprises: new addition, deletion, modification and no operation; comparing the tree data of the remote form file with the corresponding nodes in the tree data of the original form file to generate a comparison result of each node in the tree data of the remote form file.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: if the corresponding node to be compared is empty in the tree data of the local table file and is not empty in the tree data of the original table file, determining that the comparison result of the corresponding node in the tree data of the original table file is deletion; if the corresponding node to be compared is not empty in the tree data of the local table file and is empty in the tree data of the original table file, determining that the comparison result of the corresponding node in the tree data of the local table file is newly increased; if the corresponding node to be compared is not null in the tree data of the local table file and the tree data of the original table file, recursively searching the cell nodes in the child nodes of the corresponding node, and determining comparison results of the corresponding node in the tree data of the local table file and the tree data of the original table file respectively according to the values of the cell nodes; and determining the comparison result of each node in the tree data of the local table file according to the comparison result of each node in the tree data of the original table file and the comparison result of each node in the tree data of the local table file.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: if the values of the cell nodes are inconsistent in the tree data of the local table file and the tree data of the original table file, determining that the comparison results of the corresponding nodes in the tree data of the local table file and the tree data of the original table file are modified.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: obtaining the comparison result of the nodes in the tree data of the local table file as newly added and modified candidate nodes and the comparison result of the nodes in the tree data of the original table file as deleted and modified candidate nodes; and generating the comparison result of each node in the tree data of the local table file according to the comparison result of each candidate node.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: the method comprises the steps that the comparison result of corresponding nodes in tree data of a local table file and tree data of a remote table file is a newly added node, the sub-nodes of the corresponding nodes and the comparison result of the sub-nodes are complemented in the tree data, the comparison result of the corresponding nodes is updated from the newly added to the modified, and the comparison result of each node updated in the tree data of the local table file and the comparison result of each node updated in the tree data of the remote table file are respectively obtained; obtaining a union set of each node updated in the tree data of the local table file and each node updated in the tree data of the remote table file to obtain a node set; traversing each node in the node set in turn, and generating a fusion state of each node updated in the tree data of the local table file and a fusion state of each node updated in the tree data of the remote table file according to a comparison result of the node traversed currently in the tree data of the local table file and a comparison result in the tree data of the remote table file respectively, wherein the fusion state comprises: no operation, fusion, conflict, new addition, deletion and modification.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: if the currently traversed node is empty or only one of the currently traversed node is empty in the tree data of the local table file and the tree data of the far-end table file, determining that the fusion states of the currently traversed node in the tree data of the local table file and the tree data of the far-end table file are all fusible; if the currently traversed node is not null in the tree data of the local table file and the tree data of the far-end table file, judging whether the comparison results of the currently traversed node in the tree data of the local table file and the tree data of the far-end table file are the same or not; if the comparison results are the same, judging whether the comparison results of the nodes traversed currently are all modified or not and the node values are different; if the comparison results are all modified and the node values are different, determining that the fusion states of the currently traversed nodes in the tree data of the local table file and the tree data of the remote table file are all conflicts.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: if the comparison results are different, determining that the fusion states of the currently traversed nodes in the tree data of the local table file and the tree data of the remote table file are all conflicts.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: if the comparison result of the target node in the tree data of the far-end table file is new, a subtree taking the target node as a root node is newly added in the tree data of the local table file, and the fusion state of the target node and all nodes of the subtree is updated to be newly added; the target node indicates that the fusion state is a fusible node; if the comparison result of the target node in the tree data of the remote table file is modification and the target node is a cell node, modifying the value of the target node in the tree data of the local table file to be consistent with the value of the target node in the tree data of the remote table file, and updating the fusion state of the target node in the tree data of the local table file to be modified; if the comparison result of the target nodes in the tree data of the remote table file is deletion, updating the fusion state of all the nodes under the subtree of the target nodes in the tree data of the local table file to be deleted.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: ordering all nodes in the tree data after the local table file updating according to the fusion state and the node type of the nodes in the tree data after the local table file updating; and traversing each node in turn according to the sequencing result, and updating the local table file according to the fusion state and the node type of the node traversed currently.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: if the node traversed currently is a worksheet, a row or a column and the fusion state is deletion, deleting a subunit at a position corresponding to the node in the local table file; if the currently traversed node is a worksheet, a row or a column and the fusion state is newly increased, the worksheet, the row or the column which is newly increased at the corresponding position of the node in the local table file is obtained; and determining the position of the node in the local table file according to the row node and the column node corresponding to the node, and writing the value of the cell in the remote table file into the position.
In one possible embodiment, the processor 801, when executing the file processing method, is specifically configured to: according to the node type, the fusion state and the comparison result of the nodes, and the preset display style of the fusion state and the preset display style of the comparison result, respectively converting the tree data of the local table file and the tree data of the remote table file into target forms for display, wherein the target forms comprise: a two-dimensional tabular form; in response to a conflict handling operation entered for a form whose fusion state is a conflict, form information for the form whose fusion state is a conflict is altered.
In which a storage medium 802 stores program code that, when executed by the processor 801, causes the processor 801 to perform various steps in a file processing method according to various exemplary embodiments of the present application described in the section of the "exemplary method" described above in this specification.
The processor 801 may be a general purpose processor such as a Central Processing Unit (CPU), digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or may implement or perform the methods, steps, and logic blocks disclosed in embodiments of the application. The general purpose processor may be a microprocessor or any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in the processor for execution.
The storage medium 802 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. The Memory may include at least one type of storage medium, which may include, for example, flash Memory, hard disk, multimedia card, card Memory, random access Memory (Random Access Memory, RAM), static random access Memory (Static Random Access Memory, SRAM), programmable Read-Only Memory (Programmable Read Only Memory, PROM), read-Only Memory (ROM), charged erasable programmable Read-Only Memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), magnetic Memory, magnetic disk, optical disk, and the like. The memory is any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to such. The storage medium 802 of the present application may also be circuitry or any other device capable of implementing a storage function for storing program instructions and/or data.
Optionally, an embodiment of the present application further provides a computer readable storage medium having stored thereon a computer program, which when executed by a processor, performs the steps of:
in one possible embodiment, the processor, when executing the file processing method, is specifically configured to: converting each form file to be processed according to preset structure information of the form type file to generate tree data of each form file to be processed, wherein the preset structure information comprises: hierarchical relationships of subunits; the same identification information is arranged between the corresponding sub-units in different form files to be processed; the table file to be processed includes: original table files, local table files and remote table files; comparing the tree data of the form files to be processed to obtain comparison results of all nodes in the tree data of the form files to be processed, wherein the comparison results represent relative modification contents among different form files to be processed; determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file; updating the fusion state of the nodes in the tree data of the local table file according to the comparison result of the nodes in the tree data of the remote table file, and updating the local table file according to the fusion state of the nodes in the tree data updated by the local table file and the node type.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: screening the sub-units to be processed in each form file to be processed according to the hierarchical relation of each sub-unit in the form type file, the pre-configured sub-unit screening conditions and the identification generation mode, and distributing identification information for each screened sub-unit; according to the hierarchical relationship of each screened subunit, constructing tree data of the table file to be processed from top to bottom, wherein the number of layers contained in the tree data is consistent with the number of types of subunits, and the types of nodes contained in each layer are determined according to the hierarchical relationship of each subunit.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: comparing the tree data of the local table file with corresponding nodes in the tree data of the original table file to generate a comparison result of each node in the tree data of the local table file, wherein the comparison result comprises: new addition, deletion, modification and no operation; comparing the tree data of the remote form file with the corresponding nodes in the tree data of the original form file to generate a comparison result of each node in the tree data of the remote form file.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: if the corresponding node to be compared is empty in the tree data of the local table file and is not empty in the tree data of the original table file, determining that the comparison result of the corresponding node in the tree data of the original table file is deletion; if the corresponding node to be compared is not empty in the tree data of the local table file and is empty in the tree data of the original table file, determining that the comparison result of the corresponding node in the tree data of the local table file is newly increased; if the corresponding node to be compared is not null in the tree data of the local table file and the tree data of the original table file, recursively searching the cell nodes in the child nodes of the corresponding node, and determining comparison results of the corresponding node in the tree data of the local table file and the tree data of the original table file respectively according to the values of the cell nodes; and determining the comparison result of each node in the tree data of the local table file according to the comparison result of each node in the tree data of the original table file and the comparison result of each node in the tree data of the local table file.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: if the values of the cell nodes are inconsistent in the tree data of the local table file and the tree data of the original table file, determining that the comparison results of the corresponding nodes in the tree data of the local table file and the tree data of the original table file are modified.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: obtaining the comparison result of the nodes in the tree data of the local table file as newly added and modified candidate nodes and the comparison result of the nodes in the tree data of the original table file as deleted and modified candidate nodes; and generating the comparison result of each node in the tree data of the local table file according to the comparison result of each candidate node.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: the method comprises the steps that the comparison result of corresponding nodes in tree data of a local table file and tree data of a remote table file is a newly added node, the sub-nodes of the corresponding nodes and the comparison result of the sub-nodes are complemented in the tree data, the comparison result of the corresponding nodes is updated from the newly added to the modified, and the comparison result of each node updated in the tree data of the local table file and the comparison result of each node updated in the tree data of the remote table file are respectively obtained; obtaining a union set of each node updated in the tree data of the local table file and each node updated in the tree data of the remote table file to obtain a node set; traversing each node in the node set in turn, and generating a fusion state of each node updated in the tree data of the local table file and a fusion state of each node updated in the tree data of the remote table file according to a comparison result of the node traversed currently in the tree data of the local table file and a comparison result in the tree data of the remote table file respectively, wherein the fusion state comprises: no operation, fusion, conflict, new addition, deletion and modification.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: if the currently traversed node is empty or only one of the currently traversed node is empty in the tree data of the local table file and the tree data of the far-end table file, determining that the fusion states of the currently traversed node in the tree data of the local table file and the tree data of the far-end table file are all fusible; if the currently traversed node is not null in the tree data of the local table file and the tree data of the far-end table file, judging whether the comparison results of the currently traversed node in the tree data of the local table file and the tree data of the far-end table file are the same or not; if the comparison results are the same, judging whether the comparison results of the nodes traversed currently are all modified or not and the node values are different; if the comparison results are all modified and the node values are different, determining that the fusion states of the currently traversed nodes in the tree data of the local table file and the tree data of the remote table file are all conflicts.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: if the comparison results are different, determining that the fusion states of the currently traversed nodes in the tree data of the local table file and the tree data of the remote table file are all conflicts.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: if the comparison result of the target node in the tree data of the far-end table file is new, a subtree taking the target node as a root node is newly added in the tree data of the local table file, and the fusion state of the target node and all nodes of the subtree is updated to be newly added; the target node indicates that the fusion state is a fusible node; if the comparison result of the target node in the tree data of the remote table file is modification and the target node is a cell node, modifying the value of the target node in the tree data of the local table file to be consistent with the value of the target node in the tree data of the remote table file, and updating the fusion state of the target node in the tree data of the local table file to be modified; if the comparison result of the target nodes in the tree data of the remote table file is deletion, updating the fusion state of all the nodes under the subtree of the target nodes in the tree data of the local table file to be deleted.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: ordering all nodes in the tree data after the local table file updating according to the fusion state and the node type of the nodes in the tree data after the local table file updating; and traversing each node in turn according to the sequencing result, and updating the local table file according to the fusion state and the node type of the node traversed currently.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: if the node traversed currently is a worksheet, a row or a column and the fusion state is deletion, deleting a subunit at a position corresponding to the node in the local table file; if the currently traversed node is a worksheet, a row or a column and the fusion state is newly increased, the worksheet, the row or the column which is newly increased at the corresponding position of the node in the local table file is obtained; and determining the position of the node in the local table file according to the row node and the column node corresponding to the node, and writing the value of the cell in the remote table file into the position.
In one possible embodiment, the processor, when executing the file processing method, is specifically configured to: according to the node type, the fusion state and the comparison result of the nodes, and the preset display style of the fusion state and the preset display style of the comparison result, respectively converting the tree data of the local table file and the tree data of the remote table file into target forms for display, wherein the target forms comprise: a two-dimensional tabular form; in response to a conflict handling operation entered for a form whose fusion state is a conflict, form information for the form whose fusion state is a conflict is altered.
In an embodiment of the present application, the computer program may further execute other machine readable instructions when executed by a processor to perform the method as described in other embodiments, and the specific implementation of the method steps and principles are referred to in the description of the embodiments and are not described in detail herein.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in hardware plus software functional units.
The integrated units implemented in the form of software functional units described above may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (english: processor) to perform some of the steps of the methods according to the embodiments of the application. And the aforementioned storage medium includes: u disk, mobile hard disk, read-Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic disk or optical disk, etc.

Claims (16)

1. A document processing method, comprising:
converting each form file to be processed according to preset structure information of the form type file to generate tree data of each form file to be processed, wherein the preset structure information comprises: hierarchical relationships of subunits; the same identification information is arranged between the corresponding sub-units in different form files to be processed; the table file to be processed includes: original table files, local table files and remote table files;
Comparing the tree data of each to-be-processed form file to obtain a comparison result of each node in the tree data of each to-be-processed form file, wherein the comparison result represents the relative modification content among different to-be-processed form files;
determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file;
updating the fusion state of the nodes in the tree data of the local table file according to the comparison result of the nodes in the tree data of the remote table file, and updating the local table file according to the fusion state of the nodes in the tree data updated by the local table file and the node type.
2. The method of claim 1, wherein the subunit comprises: file table, row, column, cell; converting each form file to be processed according to the preset structure information of the form type file to generate tree data of each form file to be processed, wherein the tree data comprises the following steps:
Screening the sub-units to be processed in each form file to be processed according to the hierarchical relation of each sub-unit in the form type file, the pre-configured sub-unit screening conditions and the identification generation mode, and distributing identification information for each screened sub-unit;
and constructing tree data of the table file to be processed from top to bottom according to the hierarchical relation of the screened subunits, wherein the number of layers contained in the tree data is consistent with the number of types of the subunits, and the types of nodes contained in each layer are determined according to the hierarchical relation of the subunits.
3. The method according to claim 1, wherein comparing the tree data of each form file to be processed to obtain the comparison result of each node in the tree data of each form file to be processed, comprises:
comparing the tree data of the local table file with corresponding nodes in the tree data of the original table file to generate a comparison result of each node in the tree data of the local table file, wherein the comparison result comprises: new addition, deletion, modification and no operation;
comparing the tree data of the remote table file with corresponding nodes in the tree data of the original table file, and generating a comparison result of each node in the tree data of the remote table file.
4. A method according to claim 3, wherein comparing the tree data of the local table file with the corresponding nodes in the tree data of the original table file to generate the comparison result of each node in the tree data of the local table file comprises:
if the corresponding node to be compared is empty in the tree data of the local table file and is not empty in the tree data of the original table file, determining that the comparison result of the corresponding node in the tree data of the original table file is deletion;
if the corresponding node to be compared is not empty in the tree data of the local table file and is empty in the tree data of the original table file, determining that the comparison result of the corresponding node in the tree data of the local table file is newly increased;
if the corresponding node to be compared is not null in the tree data of the local table file and the tree data of the original table file, recursively searching for the cell node in the child node of the corresponding node, and determining comparison results of the corresponding node in the tree data of the local table file and the tree data of the original table file respectively according to the value of the cell node;
And determining the comparison result of each node in the tree data of the local table file according to the comparison result of each node in the tree data of the original table file and the comparison result of each node in the tree data of the local table file.
5. The method of claim 4, wherein determining the comparison result of the corresponding node in the tree data of the local table file and in the tree data of the original table file, respectively, according to the values of the cell nodes, comprises:
if the values of the cell nodes are inconsistent in the tree data of the local table file and the tree data of the original table file, determining that the comparison results of the corresponding nodes in the tree data of the local table file and the tree data of the original table file are modified.
6. The method of claim 4, wherein determining the comparison result of each node in the tree data of the local table file based on the comparison result of each node in the tree data of the original table file and the comparison result of each node in the tree data of the local table file comprises:
Obtaining the candidate nodes which are newly added and modified as the comparison result of the nodes in the tree data of the local table file and the candidate nodes which are deleted and modified as the comparison result of the nodes in the tree data of the original table file;
and generating a comparison result of each node in the tree data of the local table file according to the comparison result of each candidate node.
7. The method according to claim 1, wherein determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file comprises:
the comparison result of the corresponding nodes in the tree data of the local table file and the tree data of the remote table file is a newly added node, the sub-nodes of the corresponding nodes and the comparison result of the sub-nodes are complemented in the tree data, the comparison result of the corresponding nodes is updated from the newly added node to the modified node, and the comparison result of each node updated in the tree data of the local table file and the comparison result of each node updated in the tree data of the remote table file are respectively obtained;
Obtaining a union set of each node updated in the tree data of the local table file and each node updated in the tree data of the remote table file to obtain a node set;
traversing each node in the node set in turn, and generating a fusion state of each node updated in the tree data of the local table file and a fusion state of each node updated in the tree data of the remote table file according to a comparison result of the node traversed currently in the tree data of the local table file and a comparison result of the node traversed currently in the tree data of the remote table file, wherein the fusion state comprises: no operation, fusion, conflict, new addition, deletion and modification.
8. The method according to claim 7, wherein the generating the fusion state of each node updated in the tree data of the local table file and the fusion state of each node updated in the tree data of the remote table file according to the comparison result of the node currently traversed in the tree data of the local table file and the comparison result in the tree data of the remote table file, respectively, includes:
If the currently traversed node is empty or only one of the currently traversed node is empty in the tree data of the local table file and the tree data of the remote table file, determining that the fusion states of the currently traversed node in the tree data of the local table file and the tree data of the remote table file are all fusion-capable;
if the currently traversed node is not null in the tree data of the local table file and the tree data of the remote table file, judging whether the comparison results of the currently traversed node in the tree data of the local table file and the tree data of the remote table file are the same or not;
if the comparison results are the same, judging whether the comparison results of the nodes traversed currently are all modified or not and the node values are different;
if the comparison results are all modified and the node values are different, determining that the fusion states of the currently traversed node in the tree data of the local table file and the tree data of the remote table file are all conflicts.
9. The method of claim 8, wherein determining whether the comparison result of the currently traversed node in the tree data of the local table file and in the tree data of the remote table file is the same further comprises:
If the comparison results are different, determining that the fusion states of the currently traversed nodes in the tree data of the local table file and the tree data of the remote table file are all conflicts.
10. The method according to any one of claims 7-9, wherein updating the fusion state of the nodes in the tree data of the local table file according to the comparison result of the nodes in the tree data of the remote table file includes:
if the comparison result of the target node in the tree data of the remote table file is new, a subtree taking the target node as a root node is newly added in the tree data of the local table file, and the fusion state of the target node and all nodes of the subtree is updated to be newly added; the target node indicates that the fusion state is a fusible node;
if the comparison result of the target node in the tree data of the remote table file is modification and the target node is a cell node, modifying the value of the target node in the tree data of the local table file to be consistent with the value of the target node in the tree data of the remote table file, and updating the fusion state of the target node in the tree data of the local table file to be modified;
If the comparison result of the target node in the tree data of the remote table file is deletion, updating the fusion state of all nodes under the subtree of the target node in the tree data of the local table file to be deleted.
11. The method according to claim 1, wherein updating the local table file according to the fusion state and the node type of the nodes in the tree data updated by the local table file comprises:
ordering all nodes in the tree data updated by the local table file according to the fusion state and the node type of the nodes in the tree data updated by the local table file;
and traversing each node in turn according to the sequencing result, and updating the local table file according to the fusion state and the node type of the node traversed currently.
12. The method of claim 11, wherein updating the local table file according to the fusion state of the currently traversed node and the node type comprises:
if the currently traversed node is a worksheet, a row or a column and the fusion state is deletion, deleting a subunit at a position corresponding to the node in the local table file;
If the currently traversed node is a worksheet, a row or a column and the fusion state is newly increased, the newly increased worksheet, row or column is in the corresponding position of the node in the local table file;
if the node traversed currently is a cell and the fusion state is newly added or modified, determining the position of the node in the local table file according to the row node and the column node corresponding to the node, and writing the value of the cell in the remote table file into the position.
13. The method of claim 1, wherein after determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file, further comprises:
according to the node type, the fusion state and the comparison result of the nodes, and the preset display style of the fusion state and the preset display style of the comparison result, respectively converting the tree data of the local table file and the tree data of the remote table file into target forms for display, wherein the target forms comprise: a two-dimensional tabular form;
in response to a conflict handling operation entered for a form whose fusion state is a conflict, form information for the form whose fusion state is a conflict is altered.
14. A document processing apparatus, comprising: the device comprises a generation module, a comparison module, a determination module and an updating module;
the generating module is configured to convert each form file to be processed according to preset structure information of the form type file, and generate tree data of each form file to be processed, where the preset structure information includes: hierarchical relationships of subunits; the same identification information is arranged between the corresponding sub-units in different form files to be processed; the table file to be processed includes: original table files, local table files and remote table files;
the comparison module is used for comparing the tree data of each form file to be processed to obtain a comparison result of each node in the tree data of each form file to be processed, and the comparison result represents the relative modification content among different form files to be processed;
the determining module is used for determining the fusion state of each node in the tree data of the local table file and the fusion state of each node in the tree data of the remote table file according to the comparison result of each node in the tree data of the local table file and the comparison result of each node in the tree data corresponding to the remote table file;
The updating module is used for updating the fusion state of the nodes in the tree data of the local table file according to the comparison result of the nodes in the tree data of the remote table file, and updating the local table file according to the fusion state of the nodes in the tree data updated by the local table file and the node type.
15. An electronic device, comprising: a processor, a storage medium and a bus, the storage medium storing program instructions executable by the processor, the processor and the storage medium communicating via the bus when the electronic device is running, the processor executing the program instructions to implement the file processing method of any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when executed by a processor, implements the file processing method according to any of claims 1 to 13.
CN202310759920.0A 2023-06-26 2023-06-26 File processing method and device, electronic equipment and storage medium Pending CN116702720A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310759920.0A CN116702720A (en) 2023-06-26 2023-06-26 File processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310759920.0A CN116702720A (en) 2023-06-26 2023-06-26 File processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116702720A true CN116702720A (en) 2023-09-05

Family

ID=87825525

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310759920.0A Pending CN116702720A (en) 2023-06-26 2023-06-26 File processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116702720A (en)

Similar Documents

Publication Publication Date Title
US7673235B2 (en) Method and apparatus for utilizing an object model to manage document parts for use in an electronic document
US5553216A (en) Structured database system together with structure definition frame storing document body data
US9075787B2 (en) Defining a reusable spreadsheet-function by extracting the function from a complex calculation in a spreadsheet document
CN110738027B (en) Computer-implemented method, apparatus, and storage medium for generating spreadsheet formulas
CN110442585B (en) Data updating method, data updating device, computer equipment and storage medium
CN109614329B (en) Software test case aided design method based on interface control file
JP2005107597A (en) Device and method for searching for similar sentence and program
CN107784055A (en) Transaction methods and device based on non-relational database
CN113553458A (en) Data export method and device in graph database
CN111124938B (en) Method for generating componentized test case
JP2013228964A (en) Information management device and information searching method
CN109376248B (en) Knowledge base construction and partial sequence structure chart generation method based on incremental learning
JP7073756B2 (en) Merge method, merge device, and merge program
CN113609433B (en) Method and device for determining arithmetic layout, electronic equipment and storage medium
CN116702720A (en) File processing method and device, electronic equipment and storage medium
CN116028062A (en) Target code generation method, NPU instruction display method and device
JP6251860B2 (en) Information management apparatus and file management method
WO2016190444A1 (en) Information management device, and file management method
CN114201961A (en) Comment prediction method, device, equipment and readable storage medium
CN114296726A (en) Code generation method and device, computer equipment and storage medium
KR20220099745A (en) A spatial decomposition-based tree indexing and query processing methods and apparatus for geospatial blockchain data retrieval
JP5504212B2 (en) Test case automatic generation system, test case automatic generation method, and test case automatic generation program
JP6647954B2 (en) Design document input / output device, design document input / output system, and design document input / output method
WO2018038065A1 (en) Information management device and file management method
CN116226066B (en) Low code platform code synchronization method and device, electronic equipment and storage medium

Legal Events

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