Document generation method and device, equipment and storage medium thereof
By pre-generating documents with different numbers and adding buffer pools for timed generation tasks, the problem of strong dependence on the database during document generation is solved, and high availability and performance improvement of document generation is achieved.
Patent Information
- Application Number
- CN202411500935.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-10-24
AI Technical Summary
The existing technology relies heavily on databases during document generation, which can easily lead to database crashes and affect high availability and performance.
By starting the timing generation task, the document distinction number pre-generates regularly, and the pre-generated number is added to the buffer pool. When receiving a document generation request, the earliest generated number is obtained from the buffer pool and the target document is generated in combination with the preset document template.
Reduce dependence on the database, avoid the problem of high concurrent access to the database, reduce the risk of database crashes, extend the database service life, and improve the high availability and performance of document generation.
Smart Images

Figure CN119538893A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of R&D and design technology, and is applied to text document generation scenarios, and in particular to a document generation method, device, equipment and storage medium thereof. Background Art
[0002] For the Internet insurance product underwriting platform, high availability and high performance of the platform are crucial. Generating policy numbers is a necessary step in the underwriting process. If an exception occurs during the underwriting process and the policy number is not generated, the entire underwriting process will fail.
[0003] Traditional document generation, such as insurance policy generation, relies heavily on the database for the policy number, or document number generation process. Every time a document generation request is received, the database is called in real time to generate a document number. When an exception occurs in the database, the document number generation fails, which leads to document generation failure, seriously affecting business development and failing to achieve high availability. At the same time, the average daily order volume of the Internet document generation platform is large, and each document generation request calls the database in real time, which is also a challenge to the database performance requirements and can easily cause database crashes. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a document generation method, apparatus, device and storage medium thereof to solve the problem that the existing document generation is strongly dependent on the database and easily causes the database to crash.
[0005] In order to solve the above technical problems, the present application embodiment provides a document generation method, which adopts the following technical solutions:
[0006] A document generation method comprises the following steps:
[0007] Start the preset timed generation task;
[0008] According to the scheduled generation task and the preset generation strategy, the document distinguishing number is pre-generated regularly;
[0009] Serialize and sort the pre-generated document difference numbers according to the generation time to obtain serialized document difference numbers;
[0010] Adding the serialized document difference numbers to a preset document number buffer pool;
[0011] Obtaining a document generation request, wherein the document generation request includes non-templated information that needs to be written into the generated document;
[0012] Obtaining the earliest generated document distinction number from the document number buffer pool according to the sequence position and obtaining the target document template from a preset document generation template library;
[0013] Parsing the document generation request to obtain the non-templated information;
[0014] The non-templated information is written into the corresponding reserved position in the target document template to generate a target expected document, and the earliest generated document difference number is set as the number information of the target expected document.
[0015] Furthermore, the generation strategy specifies the generation format corresponding to the variable field in the document distinguishing number, and the step of pre-generating the document distinguishing number regularly according to the scheduled generation task and the preset generation strategy specifically includes:
[0016] Step 301, obtaining in real time the execution time point of the scheduled generation task when the generation task is executed this time;
[0017] Step 302, inputting the execution time point into the generation format as a generation parameter of a target variable field;
[0018] Step 303, obtaining the target variable field generated by the generation format;
[0019] Step 304: splice the preset fixed field and the target variable field according to a preset splicing method to obtain a spliced field as the document distinguishing number.
[0020] Further, the generation format includes a function formula for performing decimal conversion on the time information. After executing the step of inputting the execution time point as a generation parameter of the target variable field into the generation format, the method further includes:
[0021] Execute the function formula for converting the time information into decimal;
[0022] Obtaining a decimal value corresponding to the execution time point;
[0023] The decimal value is used as the target variable field.
[0024] Furthermore, the generation strategy also specifies all disabled strings that cannot be used by the variable fields in the document distinguishing number. After executing the step of obtaining the target variable field generated by the generation format, the method further includes:
[0025] By comparing and identifying, determining whether the target variable field is a disabled character string;
[0026] If the target variable field is a disabled character string, re-execute steps 301 to 303 to obtain the latest variable field generated by the generation format, and update the latest variable field to the target variable field;
[0027] If the target variable field is not a disabled character string, step 304 is executed.
[0028] Furthermore, before executing the steps of obtaining the earliest generated document difference number from the document number buffer pool according to the sequence position and obtaining the target document template from the preset document generation template library, the method includes:
[0029] Performing a parsing format check on the document generation request to determine whether the document generation request conforms to a preset parsing format;
[0030] If the document generation request does not conform to the preset parsing format, a prompt message indicating a request error is sent to the target request end;
[0031] If the document generation request conforms to the preset parsing format, the document generation request is forwarded to the target parsing end.
[0032] Furthermore, before executing the steps of obtaining the earliest generated document difference number from the document number buffer pool according to the sequence position and obtaining the target document template from the preset document generation template library, the method further includes:
[0033] By using a preset monitoring and statistics component, it is counted whether the number of document difference numbers cached in the document number buffer pool does not exceed a preset number requirement;
[0034] If the number of document difference numbers cached in the document number buffer pool does not exceed the preset minimum number requirement, triggering the start of the scheduled generation task;
[0035] If the number of document difference numbers cached in the document number buffer pool exceeds a preset maximum number requirement, the scheduled generation task is triggered to stop.
[0036] Furthermore, the method further comprises:
[0037] Identify the current time point of the system;
[0038] Based on historical request data, determine whether the current time point of the system is the peak period for document generation;
[0039] If the current time point of the system is the peak period of document generation, a task cloning method is used to generate N scheduled generation tasks, and all scheduled generation tasks are started based on a multi-threaded synchronous execution method, where N is a positive integer greater than 1.
[0040] In order to solve the above technical problems, the embodiment of the present application also provides a document generation device, which adopts the following technical solution:
[0041] A document generating device, comprising:
[0042] A scheduled generation task startup module is used to start a preset scheduled generation task;
[0043] A document distinguishing number pre-generation module, used for pre-generating document distinguishing numbers at regular intervals according to the scheduled generation task and a preset generation strategy;
[0044] A serialization module is used to serialize and sort the pre-generated document difference numbers according to the generation time to obtain the serialized document difference numbers;
[0045] A buffer pool adding module is used to add the serialized document difference number to a preset document number buffer pool;
[0046] A document generation request acquisition module, used to acquire a document generation request, wherein the document generation request includes non-templated information that needs to be written into the generated document;
[0047] A document generation component acquisition module, used to acquire the earliest generated document distinction number from the document number buffer pool according to the sequence position and to acquire the target document template from a preset document generation template library;
[0048] A document generation request parsing module, used for parsing the document generation request to obtain the non-templated information;
[0049] The target expected document generation module is used to write the non-templated information into the corresponding reserved position in the target document template to generate the target expected document, and set the earliest generated document difference number as the number information of the target expected document.
[0050] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0051] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the document generation method described above when executing the computer-readable instructions.
[0052] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0053] A computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the document generation method as described above.
[0054] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0055] The document generation method described in the embodiment of the present application starts a scheduled generation task; pre-generates a document difference number at a scheduled time; adds the document to a preset document number buffer pool; obtains a document generation request; obtains the earliest generated document difference number from the document number buffer pool and obtains a target document template from a preset document generation template library; parses the document generation request to obtain non-templated information; writes the non-templated information to the corresponding reserved position in the target document template, generates the target expected document, and sets the earliest generated document difference number as the number information of the target expected document. By pre-generating document difference numbers through scheduled generation tasks, when a document generation request is obtained, the document difference number is directly obtained from the document number buffer pool and assigned to the generated document. Compared with directly accessing the database to instantly generate document difference numbers, this avoids the problem of high concurrent access to the database during batch generation, is less likely to cause database crashes, and extends the service life of the database. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0057] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;
[0058] Figure 2 is a flow chart of an embodiment of a document generation method according to the present application;
[0059] Figure 3 yes Figure 2 A flowchart of a specific embodiment of step 202 is shown;
[0060] Figure 4 is a structural schematic diagram of an embodiment of a document generation device according to the present application;
[0061] Figure 5 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0062] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0063] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0064] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0065] like Figure 1 As shown, the system architecture 100 may include a terminal device 101, a network 102 and a server 103. The terminal device 101 may be a laptop 1011, a tablet computer 1012 or a mobile phone 1013. The network 102 is used to provide a medium for a communication link between the terminal device 101 and the server 103. The network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0066] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0067] The terminal device 101 can be any electronic device with a display screen and supporting web browsing. In addition to a laptop computer 1011, a tablet computer 1012 or a mobile phone 1013, the terminal device 101 can also be an e-book reader, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 (Moving Picture Experts Group Audio Layer IV), a laptop computer, a desktop computer, etc.
[0068] The server 103 may be a server that provides various services, such as a background server that provides support for a web page displayed on the terminal device 101 .
[0069] It should be noted that the document generation method provided in the embodiment of the present application is generally executed by a terminal device, and accordingly, the document generation device is generally arranged in the terminal device.
[0070] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0071] Continue to refer Figure 2 , shows a flow chart of an embodiment of a document generation method according to the present application. The document generation method comprises the following steps:
[0072] Step 201, start the preset timed generation task;
[0073] Specifically, the timed generation task, for example: in the underwriting platform, the task of regularly generating policy numbers; another example: when generating documents in batches, different documents are numbered differently corresponding to different documents.
[0074] Step 202, pre-generating document distinguishing numbers on a regular basis according to the scheduled generation task and the preset generation strategy;
[0075] Specifically, the preset generation strategy includes a predetermined generation format, base conversion format, sensitive word screening, field splicing method, output format, etc. Through the preset generation strategy, the document distinguishing number is pre-generated regularly to ensure that the final generated document distinguishing number has a unified format, that is, the generation controllability is achieved, and it is also convenient for subsequent management and identification.
[0076] Step 203, serializing and arranging the pre-generated document difference numbers according to the generation time to obtain serialized document difference numbers;
[0077] The pre-generated document difference numbers are serialized and sorted according to the generation time to obtain the serialized document difference numbers, thereby realizing the orderly sorting of the disordered document difference numbers, so as to facilitate the subsequent orderly acquisition of the document difference numbers.
[0078] Step 204, adding the serialized document difference numbers to a preset document number buffer pool;
[0079] Step 205, obtaining a document generation request, wherein the document generation request includes non-templated information that needs to be written into the generated document;
[0080] Step 206, obtaining the earliest generated document distinction number from the document number buffer pool according to the sequence position and obtaining the target document template from a preset document generation template library;
[0081] By adding the serialized document difference numbers into a preset document number buffer pool, when a document generation request is obtained, the earliest generated document difference number is obtained from the document number buffer pool according to the sequence position, thereby getting rid of the strong dependence on the database, and document generation will not be interrupted even if the database is unavailable.
[0082] Step 207, parsing the document generation request to obtain the non-templated information;
[0083] Step 208: write the non-templated information into the corresponding reserved position in the target document template to generate a target expected document, and set the earliest generated document difference number as the number information of the target expected document.
[0084] In this embodiment, by starting a scheduled generation task; pre-generating a document difference number at a scheduled time; adding it to a preset document number buffer pool; obtaining a document generation request; obtaining the earliest generated document difference number from the document number buffer pool and obtaining a target document template from a preset document generation template library; parsing the document generation request to obtain non-templated information; writing the non-templated information to the corresponding reserved position in the target document template, generating a target expected document, and setting the earliest generated document difference number as the number information of the target expected document. By pre-generating a document difference number through a scheduled generation task, when a document generation request is obtained, the document difference number is directly obtained from the document number buffer pool and assigned to the generated document. Compared with directly accessing the database to instantly generate a document difference number, this avoids the problem of high concurrent access to the database during batch generation, is less likely to cause database crashes, and extends the service life of the database.
[0085] In this embodiment, the generation strategy specifies the generation format corresponding to the variable fields in the document distinguishing number.
[0086] Continue to refer Figure 3 , in some optional implementations, Figure 3 yes Figure 2 The flowchart of a specific embodiment of step 202 shown includes the following steps:
[0087] Step 301, obtaining in real time the execution time point of the scheduled generation task when the generation task is executed this time;
[0088] Step 302, inputting the execution time point into the generation format as a generation parameter of a target variable field;
[0089] Step 303, obtaining the target variable field generated by the generation format;
[0090] Step 304: splice the preset fixed field and the target variable field according to a preset splicing method to obtain a spliced field as the document distinguishing number.
[0091] By inputting the execution time point as a generation parameter of the target variable field into the generation format, the non-repetitiveness of the document distinction number finally generated is ensured, that is, the uniqueness of the document distinction number finally generated is ensured.
[0092] In this embodiment, the generation format includes a function formula for decimal conversion of time information. After executing the step of inputting the execution time point as the generation parameter of the target variable field into the generation format, the method also includes: executing the function formula for decimal conversion of time information; obtaining the decimal value corresponding to the execution time point; and using the decimal value as the target variable field.
[0093] In this embodiment, the generation strategy also specifies all disabled strings that cannot be used in the variable fields in the document distinction number. After executing the step of obtaining the target variable field generated by the generation format, the method further includes: determining whether the target variable field is a disabled string by comparison and identification; if the target variable field is a disabled string, re-executing steps 301 to 303 to obtain the latest variable field generated by the generation format, and updating the latest variable field to the target variable field; if the target variable field is not a disabled string, executing step 304.
[0094] Specifically, for example, when generating an insurance policy number or a document number with higher security, the simpler document number field is excluded. Here, all disabled strings that cannot be used by the variable fields in the document distinguishing number can be freely set by the generating request end. This ensures that the generated document number meets specific requirements.
[0095] In this embodiment, before executing the steps of obtaining the earliest generated document distinction number from the document number buffer pool according to the sequence position and obtaining the target document template from the preset document generation template library, the method includes: performing a parsing format check on the document generation request to determine whether the document generation request conforms to the preset parsing format; if the document generation request does not conform to the preset parsing format, sending a prompt message indicating a request error to the target request end; if the document generation request conforms to the preset parsing format, forwarding the document generation request to the target parsing end.
[0096] In fact, the request format of the document generation request is checked. If the check passes, the subsequent steps are continued. If not, an error prompt is given.
[0097] In this embodiment, before executing the steps of obtaining the earliest generated document distinction number from the document number buffer pool according to the sequence position and obtaining the target document template from the preset document generation template library, the method also includes: using a preset monitoring and statistical component to count whether the number of document distinction numbers cached in the document number buffer pool does not exceed the preset number requirement; if the number of document distinction numbers cached in the document number buffer pool does not exceed the preset minimum number requirement, triggering the start of the scheduled generation task; if the number of document distinction numbers cached in the document number buffer pool exceeds the preset maximum number requirement, triggering the stop of the scheduled generation task.
[0098] In fact, this part monitors the quantity of document difference numbers cached in the document number buffer pool, which avoids too much data in the buffer pool and too little data in the buffer pool, and uses the buffer pool rationally.
[0099] In this embodiment, the document generation method also includes: identifying the current time point of the system; determining whether the current time point of the system is a peak period for document generation based on historical request data; if the current time point of the system is a peak period for document generation, using task cloning to generate N scheduled generation tasks, and starting all scheduled generation tasks based on a multi-threaded synchronous execution method, where N is a positive integer greater than 1.
[0100] Specifically, based on historical request data, determine whether the current time point of the system is the peak period of document generation, so that during the peak period of document generation, use task cloning to generate N scheduled generation tasks, and start all scheduled generation tasks based on multi-threaded synchronous execution, ensuring that the document differentiation numbering requirements are met during the peak period of document generation.
[0101] In this embodiment, after executing the step of setting the earliest generated document distinction number as the numbering information of the target expected document, the method further includes: writing the earliest generated document distinction number into the reserved position corresponding to the document distinction number in the target expected document.
[0102] This application starts a scheduled generation task; pre-generates document difference numbers on a scheduled basis; adds the document to a preset document number buffer pool; obtains a document generation request; obtains the earliest generated document difference number from the document number buffer pool and obtains a target document template from a preset document generation template library; parses the document generation request to obtain non-templated information; writes the non-templated information to the corresponding reserved position in the target document template, generates the target expected document, and sets the earliest generated document difference number to the number information of the target expected document. By pre-generating document difference numbers through scheduled generation tasks, when a document generation request is obtained, the document difference number is directly obtained from the document number buffer pool and assigned to the generated document. Compared with directly accessing the database to instantly generate document difference numbers, this avoids the problem of high concurrent access to the database during batch generation, is less likely to cause database crashes, and extends the service life of the database.
[0103] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0104] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0105] In the embodiment of the present application, by starting a scheduled generation task; pre-generating document difference numbers on a scheduled basis; adding them to a preset document number buffer pool; obtaining a document generation request; obtaining the earliest generated document difference number from the document number buffer pool and obtaining a target document template from a preset document generation template library; parsing the document generation request to obtain non-templated information; writing the non-templated information to the corresponding reserved position in the target document template, generating the target expected document, and setting the earliest generated document difference number as the number information of the target expected document. By pre-generating document difference numbers through scheduled generation tasks, when a document generation request is obtained, the document difference number is directly obtained from the document number buffer pool and assigned to the generated document. Compared with directly accessing the database to instantly generate document difference numbers, this avoids the problem of high concurrent access to the database during batch generation, is less likely to cause database crashes, and extends the service life of the database.
[0106] Further references Figure 4 , as a response to the above Figure 2 In order to realize the method shown in the figure, the present application provides an embodiment of a document generation device, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0107] like Figure 4 As shown, the document generation device 400 described in this embodiment includes: a timed generation task starting module 401, a document distinguishing number pre-generation module 402, a serialization and sorting module 403, a buffer pool adding module 404, a document generation request acquisition module 405, a document generation component acquisition module 406, a document generation request parsing module 407 and a target expected document generation module 408. Among them:
[0108] The scheduled generation task starting module 401 is used to start the preset scheduled generation task;
[0109] The document distinguishing number pre-generation module 402 is used to pre-generate the document distinguishing number regularly according to the scheduled generation task and the preset generation strategy;
[0110] A serialization module 403 is used to serialize and sort the pre-generated document difference numbers according to the generation time to obtain serialized document difference numbers;
[0111] The adding buffer pool module 404 is used to add the serialized document difference number to a preset document number buffer pool;
[0112] The document generation request acquisition module 405 is used to acquire a document generation request, wherein the document generation request includes non-templated information that needs to be written into the generated document;
[0113] The document generation component acquisition module 406 is used to acquire the earliest generated document distinction number from the document number buffer pool according to the sequence position and acquire the target document template from the preset document generation template library;
[0114] A document generation request parsing module 407, used to parse the document generation request to obtain the non-templated information;
[0115] The target expected document generation module 408 is used to write the non-templated information into the corresponding reserved position in the target document template to generate the target expected document, and set the earliest generated document difference number as the number information of the target expected document.
[0116] This application starts a scheduled generation task; pre-generates document difference numbers on a scheduled basis; adds the document to a preset document number buffer pool; obtains a document generation request; obtains the earliest generated document difference number from the document number buffer pool and obtains a target document template from a preset document generation template library; parses the document generation request to obtain non-templated information; writes the non-templated information to the corresponding reserved position in the target document template, generates the target expected document, and sets the earliest generated document difference number to the number information of the target expected document. By pre-generating document difference numbers through scheduled generation tasks, when a document generation request is obtained, the document difference number is directly obtained from the document number buffer pool and assigned to the generated document. Compared with directly accessing the database to instantly generate document difference numbers, this avoids the problem of high concurrent access to the database during batch generation, is less likely to cause database crashes, and extends the service life of the database.
[0117] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0118] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0119] To solve the above technical problems, the present application also provides a computer device. Figure 5 , Figure 5 This is a basic structural block diagram of the computer device in this embodiment.
[0120] The computer device 5 includes a memory 5a, a processor 5b, and a network interface 5c which are interconnected through a system bus. It should be noted that: Figure 5 Only a computer device 5 having a component memory 5a, a processor 5b, and a network interface 5c is shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a digital processor (DSP), an embedded device, etc.
[0121] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0122] The memory 5a includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 5a can be an internal storage unit of the computer device 5, such as a hard disk or memory of the computer device 5. In other embodiments, the memory 5a can also be an external storage device of the computer device 5, such as a plug-in hard disk equipped on the computer device 5, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 5a can also include both the internal storage unit of the computer device 5 and its external storage device. In this embodiment, the memory 5a is generally used to store the operating system and various application software installed on the computer device 5, such as a computer-readable instruction of a document generation method, etc. In addition, the memory 5a can also be used to temporarily store various types of data that have been output or are to be output.
[0123] The processor 5b may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 5b is generally used to control the overall operation of the computer device 5. In this embodiment, the processor 5b is used to run the computer-readable instructions stored in the memory 5a or process data, such as running the computer-readable instructions of the document generation method.
[0124] The network interface 5c may include a wireless network interface or a wired network interface. The network interface 5c is generally used to establish a communication connection between the computer device 5 and other electronic devices.
[0125] The computer device proposed in this embodiment belongs to the field of research and development design technology and is applied to text document generation scenarios. This application starts a scheduled generation task; pre-generates document difference numbers on a scheduled basis; adds them to a preset document number buffer pool; obtains a document generation request; obtains the earliest generated document difference number from the document number buffer pool and obtains the target document template from a preset document generation template library; parses the document generation request to obtain non-templated information; writes the non-templated information to the corresponding reserved position in the target document template, generates the target expected document, and sets the earliest generated document difference number as the number information of the target expected document. By pre-generating document difference numbers through scheduled generation tasks, when a document generation request is obtained, the document difference number is directly obtained from the document number buffer pool and assigned to the generated document. Compared with directly accessing the database to instantly generate document difference numbers, this avoids the problem of high concurrent access to the database during batch generation, is less likely to cause database crashes, and extends the service life of the database.
[0126] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by a processor to enable the processor to perform the steps of the document generation method as described above.
[0127] The computer-readable storage medium proposed in this embodiment belongs to the field of research and development design technology and is applied to text document generation scenarios. This application starts a scheduled generation task; pre-generates document difference numbers on a scheduled basis; adds them to a preset document number buffer pool; obtains a document generation request; obtains the earliest generated document difference number from the document number buffer pool and obtains the target document template from a preset document generation template library; parses the document generation request to obtain non-templated information; writes the non-templated information to the corresponding reserved position in the target document template, generates the target expected document, and sets the earliest generated document difference number to the number information of the target expected document. By pre-generating document difference numbers through scheduled generation tasks, when a document generation request is obtained, the document difference number is directly obtained from the document number buffer pool and assigned to the generated document. Compared with directly accessing the database to instantly generate document difference numbers, this avoids the problem of high concurrent access to the database during batch generation, is less likely to cause database crashes, and extends the service life of the database.
[0128] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0129] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A document generation method, characterized in that: The steps include: Start the preset timed generation task; According to the scheduled generation task and the preset generation strategy, the document distinguishing number is pre-generated regularly; Serialize and sort the pre-generated document difference numbers according to the generation time to obtain serialized document difference numbers; Adding the serialized document difference numbers to a preset document number buffer pool; Obtaining a document generation request, wherein the document generation request includes non-templated information that needs to be written into the generated document; Obtaining the earliest generated document distinction number from the document number buffer pool according to the sequence position and obtaining the target document template from a preset document generation template library; Parsing the document generation request to obtain the non-templated information; The non-templated information is written into the corresponding reserved position in the target document template to generate a target expected document, and the earliest generated document difference number is set as the number information of the target expected document.
2. The document generation method according to claim 1, characterized in that: The generation strategy specifies the generation format corresponding to the variable field in the document difference number. The step of pre-generating the document difference number regularly according to the scheduled generation task and the preset generation strategy specifically includes: Step 301, obtaining in real time the execution time point of the scheduled generation task when the generation task is executed this time; Step 302, inputting the execution time point into the generation format as a generation parameter of a target variable field; Step 303, obtaining the target variable field generated by the generation format; Step 304: splice the preset fixed field and the target variable field according to a preset splicing method to obtain a spliced field as the document distinguishing number.
3. The document generation method according to claim 2, characterized in that: The generation format includes a function formula for performing decimal conversion on the time information. After executing the step of inputting the execution time point as a generation parameter of the target variable field into the generation format, the method further includes: Execute the function formula for converting the time information into decimal; Obtaining a decimal value corresponding to the execution time point; The decimal value is used as the target variable field.
4. The document generation method according to claim 2, characterized in that: The generation strategy also specifies all disabled strings that cannot be used by the variable fields in the document distinguishing number. After executing the step of obtaining the target variable field generated by the generation format, the method further includes: By comparing and identifying, determining whether the target variable field is a disabled character string; If the target variable field is a disabled character string, re-execute steps 301 to 303 to obtain the latest variable field generated by the generation format, and update the latest variable field to the target variable field; If the target variable field is not a disabled character string, step 304 is executed.
5. The document generation method according to claim 1, characterized in that: Before executing the steps of obtaining the earliest generated document distinction number from the document number buffer pool according to the sequence position and obtaining the target document template from a preset document generation template library, the method includes: Performing a parsing format check on the document generation request to determine whether the document generation request conforms to a preset parsing format; If the document generation request does not conform to the preset parsing format, a prompt message indicating a request error is sent to the target request end; If the document generation request conforms to the preset parsing format, the document generation request is forwarded to the target parsing end.
6. The document generation method according to claim 1 or 5, characterized in that: Before executing the steps of obtaining the earliest generated document difference number from the document number buffer pool according to the sequence position and obtaining the target document template from the preset document generation template library, the method further includes: By using a preset monitoring and statistics component, it is counted whether the number of document difference numbers cached in the document number buffer pool does not exceed a preset number requirement; If the number of document difference numbers cached in the document number buffer pool does not exceed the preset minimum number requirement, triggering the start of the scheduled generation task; If the number of document difference numbers cached in the document number buffer pool exceeds a preset maximum number requirement, the scheduled generation task is triggered to stop.
7. The document generation method according to claim 1, characterized in that: The method further comprises: Identify the current time point of the system; Based on historical request data, determine whether the current time point of the system is the peak period for document generation; If the current time point of the system is the peak period of document generation, a task cloning method is used to generate N scheduled generation tasks, and all scheduled generation tasks are started based on a multi-threaded synchronous execution method, where N is a positive integer greater than 1.
8. A document generation device, characterized in that: include: A scheduled generation task startup module is used to start a preset scheduled generation task; A document distinguishing number pre-generation module, used for pre-generating document distinguishing numbers at regular intervals according to the scheduled generation task and a preset generation strategy; A serialization module is used to serialize and sort the pre-generated document difference numbers according to the generation time to obtain the serialized document difference numbers; A buffer pool adding module is used to add the serialized document difference number to a preset document number buffer pool; A document generation request acquisition module, used to acquire a document generation request, wherein the document generation request includes non-templated information that needs to be written into the generated document; A document generation component acquisition module, used to acquire the earliest generated document distinction number from the document number buffer pool according to the sequence position and to acquire the target document template from a preset document generation template library; A document generation request parsing module, used for parsing the document generation request to obtain the non-templated information; The target expected document generation module is used to write the non-templated information into the corresponding reserved position in the target document template to generate the target expected document, and set the earliest generated document difference number as the number information of the target expected document.
9. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the document generation method according to any one of claims 1 to 7 when executing the computer-readable instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the document generation method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Management system and method on file number and code
CN102117277A
Automatic serial number generator
CN103729426A
ID management method and apparatus
CN108874946A
Method for customizing data format and data conversion system
CN110825751A
Document processing method and device and electronic equipment
CN112417834A