Method and device for generating volume based on case elements
By using the variable string replacement method based on word templates in electronic file management, the problem of flexible configuration and online editing is solved, the functions of flexible configuration and user online editing are realized, and the flexibility and user experience of the system are improved.
Patent Information
- Application Number
- CN202410675908.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-08-30
AI Technical Summary
The existing technology does not support flexible configuration and online editing in electronic file archiving management, resulting in the need to frequently modify the source code in response to personalized needs, and the generated image files cannot be edited online in real time.
Using a word template-based method, by configuring static and dynamic parts, using variable strings to occupy places in the template, text replacement is performed from the database query value based on case information, and text replacement is implemented through the replace method of the document Range object to support online users edit.
It realizes flexible configuration and online editing functions, reduces the need for code modification, and improves the system's flexibility and user experience.
Smart Images

Figure CN118569233A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer automation, and in particular to a method and device for generating volumes based on case elements. Background Art
[0002] In the process of electronic file filing management, the styles of the cover, directory, preparation table, and bottom of the file filed by each court are different. The differences are mainly reflected in the data requirements, fonts, font sizes, page margins, background colors, font colors, etc. on the template. Although the traditional implementation method based on the JAVA AWT component library can also achieve the above effects, it is not flexible enough. In the face of increasing personalized needs, it is necessary to frequently modify the source code in large quantities, and the generated image files cannot be edited online in real time. Summary of the invention
[0003] The present invention discloses a method and device for generating volumes based on case elements, which are used to solve the problem that the prior art does not support flexible configuration and online editing.
[0004] A method for generating a volume based on case elements comprises the following steps:
[0005] S1: Configure a word template. The content in the word template includes a static part and a dynamic part. The static part is the content that does not change with different cases, including one or more of the cover, directory, preparation table, font, font size, page margin, and background color. The dynamic part is the content that changes with different cases, including the date, court name, etc. The dynamic part is in the form of a variable string, occupying a place in the word template;
[0006] S2: Receive the case information provided by the user, use the corresponding word template, traverse the variable string in the word template, query the value corresponding to each variable string from the database according to the case information and complete the text replacement, obtain the volume in word format, and convert the volume in word format into the required format according to the needs; if the user requests to modify the content, return the volume in word format to the user, and after the user completes the modification, convert the volume in word format into the required format again.
[0007] Furthermore, the variable string includes a variable identifier and a verification mechanism.
[0008] Furthermore, the format rule of the variable string is TDH[variable name length][variable name], where "TDH" is the variable identifier, "[variable name]" is the name of the variable string, and "[variable name length]" represents the length of "[variable name]"; a string is a variable string if it conforms to the format rule of the variable string, otherwise it is an ordinary string.
[0009] Furthermore, the specific method of performing text replacement on the variable string is through the replace method of the document Range object.
[0010] The present invention also provides a device for generating a volume based on case elements, comprising the following modules:
[0011] Configuration module: used to configure the word template. The content in the word template includes static part and dynamic part. The static part is the content that will not change with different cases, including one or more of the cover, directory, preparation table, font, font size, page margin, background color, etc. The dynamic part is the content that will change with different cases, including date, court name, etc. The dynamic part takes up a place in the word template in the form of variable string.
[0012] Generation module: used to receive case information provided by the user, use the corresponding word template, traverse the variable string in the word template, query the value corresponding to each variable string from the database according to the case information and complete the text replacement, obtain the volume in word format, and convert the volume in word format into the required format as required; if the user requests to modify the content, the volume in word format will be returned to the user, and after the user completes the modification, the volume in word format will be converted into the required format again.
[0013] Furthermore, the variable string includes a variable identifier and a verification mechanism.
[0014] Furthermore, the format rule of the variable string is TDH[variable name length][variable name], where "TDH" is the variable identifier, "[variable name]" is the name of the variable string, and "[variable name length]" represents the length of "[variable name]"; a string is a variable string if it conforms to the format rule of the variable string, otherwise it is an ordinary string.
[0015] Furthermore, the specific method of performing text replacement on the variable string is through the replace method of the document Range object.
[0016] Beneficial effect: After using the present invention, in the face of increasing personalized needs, it is only necessary to make the corresponding word template without a large amount of code modification, so the configuration is very flexible and convenient. At the same time, if the user needs to modify the content, the word template to be converted can be directly submitted to the user, so that the user can realize online editing. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 This is a schematic diagram of the word template in the present invention;
[0018] Figure 2 A schematic diagram of the volume generation process in the present invention; DETAILED DESCRIPTION
[0019] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0020] like Figure 1-2 As shown, a method for generating a volume based on case elements includes the following steps:
[0021] S1: Configure a word template. The content in the word template includes a static part and a dynamic part. The static part is the content that does not change with different cases, including one or more of the cover, directory, preparation table, font, font size, page margin, and background color. The dynamic part is the content that changes with different cases, including the date, court name, etc. The dynamic part is in the form of a variable string, occupying a place in the word template;
[0022] Specifically, the variable string includes a variable identifier and a validation mechanism; in this embodiment, the format rule of the variable string is TDH[variable name length][variable name], where "TDH" is the variable identifier, "[variable name]" is the name of the variable string, and "[variable name length]" represents the length of "[variable name]". If a string conforms to the format rule of the variable string, it is a variable string, otherwise it is an ordinary string. For example, TDH03SPZ, which starts with TDH, and the number 03 following it is exactly the number of the following string "SPZ", so TDH03SPZ is a variable string; if it is TDH04SPZ, it will not be understood as a variable string, but as an ordinary string in a word template;
[0023] S2: Receive case information provided by the user, use the corresponding word template, traverse the variable string in the word template, query the value corresponding to each variable string from the database according to the case information and complete the text replacement, obtain the volume in word format, and convert the volume in word format into the required format as required. In this embodiment, it is converted into pdf format or image format; if the user requests to modify the content, the volume in word format is returned to the user. After the user completes the modification, the volume in word format is converted into the required format again.
[0024] Specifically, the method of querying the value corresponding to each variable string from the database is to use an SQL statement to query; for example, there are variable strings "TDH04FYMC" and "TDH03SJY" in the word template, and the following information is saved in the corresponding case in the database: [{"TDH04FYMC":"A certain city intermediate personnel court"},{"TDH03SJY":"Zhang San"}], then replace "TDH04FYMC" and "TDH03SJY" in the word template with "A certain city intermediate personnel court" and "Zhang San" respectively.
[0025] Specifically, the specific method for performing text replacement on a variable string is to use the replace method of the document Range object. The Range object represents a continuous area in a document, which is defined by a starting character position and an ending character position.
[0026] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for generating volumes based on case elements, characterized in that The following steps are involved: S1: Configure a word template. The content in the word template includes a static part and a dynamic part. The static part is the content that does not change with different cases, and the dynamic part is the content that changes with different cases. The dynamic part is in the form of a variable string and occupies a place in the word template. S2: Receive the case information provided by the user, use the corresponding word template, traverse the variable string in the word template, query the value corresponding to each variable string from the database according to the case information and complete the text replacement, obtain the volume in word format, and convert the volume in word format into the required format according to the needs; if the user requests to modify the content, return the volume in word format to the user, and after the user completes the modification, convert the volume in word format into the required format again.
2. A method for generating volumes based on case elements according to claim 1, characterized in that: The variable string includes the variable identifier and the validation mechanism.
3. The method for generating volumes based on case elements according to claim 1, characterized in that: The format rule of variable string is TDH[variable name length][variable name], where "TDH" is the variable identifier, "[variable name]" is the name of the variable string, and "[variable name length]" indicates the length of "[variable name]". If a string conforms to the format rule of variable string, it is a variable string, otherwise it is a common string.
4. The method for generating volumes based on case elements according to claim 1, characterized in that: The specific method to perform text replacement on a variable string is through the replace method of the document Range object.
5. A device for generating volumes based on case elements, characterized in that Includes the following modules: Configuration module: used to configure the word template. The content in the word template includes static part and dynamic part. The static part is the content that will not change with different cases, and the dynamic part is the content that will change with different cases. The dynamic part takes place in the word template in the form of variable string. Generation module: used to receive case information provided by the user, use the corresponding word template, traverse the variable string in the word template, query the value corresponding to each variable string from the database according to the case information and complete the text replacement, obtain the volume in word format, and convert the volume in word format into the required format as required; if the user requests to modify the content, the volume in word format will be returned to the user, and after the user completes the modification, the volume in word format will be converted into the required format again.
6. The device for generating volumes based on case elements according to claim 5, characterized in that: The variable string includes the variable identifier and the validation mechanism.
7. The device for generating volumes based on case elements according to claim 5, characterized in that: The format rule of variable string is TDH[variable name length][variable name], where "TDH" is the variable identifier, "[variable name]" is the name of the variable string, and "[variable name length]" indicates the length of "[variable name]". If a string conforms to the format rule of variable string, it is a variable string, otherwise it is a common string.
8. The device for generating volumes based on case elements according to claim 5, characterized in that: The specific method to perform text replacement on a variable string is through the replace method of the document Range object.
