A contract number generation method and system based on contract text

By obtaining key fields from the contract text and combining them with random numbers to generate contract numbers, and comparing them against the database for duplicates, the problems of duplication and inefficiency in contract number management are solved, achieving automated and unique contract number generation.

CN119378501BActive Publication Date: 2026-06-30NO 15 INST OF CHINA ELECTRONICS TECH GRP

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NO 15 INST OF CHINA ELECTRONICS TECH GRP
Filing Date
2024-10-29
Publication Date
2026-06-30

Smart Images

  • Figure CN119378501B_ABST
    Figure CN119378501B_ABST
Patent Text Reader

Abstract

This application belongs to the field of computer technology. A method for generating contract numbers based on contract text is disclosed. The method includes: obtaining a request for generating contract text; obtaining key fields of the contract text according to the request; obtaining a first random number corresponding to the contract text according to the contract text; combining the key fields and the first random number to obtain a first contract number of the contract text; comparing the first contract number with numbers pre-stored in a database to obtain a comparison result; if the comparison result is a duplicate, regenerating a second random number based on the contract text, combining the second random number with the key fields to obtain a second contract number, and storing it in the database; if the comparison result is a non-duplicate, storing the first contract number in the database. This method solves the problem of duplicate contract number generation IDs and improves the efficiency of contract number generation and management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of computer technology, and in particular relates to a method and system for generating contract numbers based on contract text. Background Technology

[0002] In the past, contract number management often relied on contract numbering specialists who needed to pre-assign and record contract numbers, either offline in paper form or online in electronic form. However, this manual management method has significant limitations, especially in collaborative environments, where it struggles to support the automatic generation of various types of incremental contract numbers online. As businesses grow and expand, the number and types of contracts increase, and traditional management methods can no longer meet the high efficiency and accuracy requirements of large enterprises in contract numbering management.

[0003] Therefore, enterprises urgently need a new method for generating and managing contract numbers. This method should be able to automate the processing of large numbers of contracts, support multi-user collaboration, and flexibly respond to different types of contract numbering requirements in order to improve overall work efficiency and reduce human error. Summary of the Invention

[0004] Therefore, it is necessary to provide a method and system for generating contract numbers based on contract text to address the aforementioned technical problems.

[0005] Firstly, this application provides a method for generating contract numbers based on contract text, the method comprising:

[0006] Obtain the request used to generate the contract text;

[0007] Based on the request, obtain the key fields of the contract text;

[0008] Based on the contract text, obtain the first random number corresponding to the contract text;

[0009] The key field and the first random number are combined to obtain the first contract number of the contract text;

[0010] The first contract number is compared with the numbers pre-stored in the database to obtain the comparison result;

[0011] If the comparison result is a duplicate, a second random number is regenerated based on the contract text, and the second random number is combined with the key field to obtain a second contract number, which is then stored in the database.

[0012] If the comparison result is non-duplicate, the first contract number is stored in the database.

[0013] In some feasible methods, the step of obtaining the key fields of the contract text according to the request includes:

[0014] Feature extraction is performed on the contract text to obtain keyword features;

[0015] Based on the keyword features, key fields are obtained, wherein the key fields include at least the department, contract type, and contract signing time.

[0016] In some feasible methods, the step of obtaining the first random number corresponding to the contract text based on the contract text includes:

[0017] Obtain the current time point corresponding to the request;

[0018] Compare the current time point with the historical time point of the last successful generation of a serial number;

[0019] If the current time is less than the historical time when the sequence number was successfully generated, a clock rollback is triggered.

[0020] If the clock rollback is less than the preset time and the number of serial numbers generated at the historical time point has not reached the maximum value, then the current time point is set as the historical time point, and the serial number is extended based on the previous successful generation of the serial number to obtain the first random number with the next serial number;

[0021] If the clock rollback is less than a preset time and the number of serial numbers generated at the historical time point has reached the maximum value, an exception is thrown. The thrown exception includes at least one of the following: executing exception handling code, program termination, and user notification.

[0022] In some implementable methods, the step of forming a clock rollback if the current timestamp is less than the historical timestamp of the last time the sequence number was generated includes:

[0023] If the clock rollback is greater than or equal to a preset time, and no serial number is generated within the clock rollback time period, then the serial number is extended based on the previous successful generation of the serial number to obtain the first random number with the next serial number;

[0024] If the clock rollback is greater than or equal to a preset time, and a sequence number is generated within the clock rollback time period, then an exception is thrown.

[0025] In some feasible implementations, the step of combining the key field and the first random number to obtain the first contract number of the contract text includes:

[0026] The number of tags is determined according to a pre-set combination order;

[0027] Match the tag with the key field to obtain the key field containing the tag;

[0028] The key field with the label and the first random number are combined to obtain the first contract number of the contract text.

[0029] In some feasible methods, the step of regenerating a second random number based on the contract text if the comparison result is a duplicate, combining the second random number with the key field to obtain a second contract number, and storing it in the database includes:

[0030] Retrieve from the database any pre-stored numbers that are duplicates of the first contract number;

[0031] Based on the pre-stored number, traverse several numbers following the pre-stored number to obtain the first temporary comparison number group;

[0032] The second contract number is compared with the first temporary comparison number group to obtain the temporary comparison result;

[0033] If the comparison result is non-duplicate, the second contract number is stored in the database;

[0034] If the comparison result is a duplicate, a third random number is regenerated based on the contract text, and the third random number is combined with the key field to obtain a third contract number. The third contract number is then compared with a second temporary comparison number group, where the second temporary comparison number group represents the number that is the same as the second contract number, and is formed by combining several subsequent numbers.

[0035] Secondly, this application provides a contract numbering system based on contract text, applied to the aforementioned contract numbering method based on contract text, the system comprising:

[0036] The receiving module is used to receive requests for generating contract text;

[0037] The generation module is used to obtain the key fields of the contract text based on the request;

[0038] The generation module is also used to obtain a first random number corresponding to the contract text based on the contract text;

[0039] The combination module is used to combine the key field and the first random number to obtain the first contract number of the contract text;

[0040] The judgment module is used to compare the first contract number with the number pre-stored in the database to obtain the comparison result;

[0041] If the comparison result is a duplicate, a second random number is regenerated based on the contract text, and the second random number is combined with the key field to obtain a second contract number, which is then stored in the database.

[0042] If the comparison result is non-duplicate, the first contract number is stored in the database.

[0043] Thirdly, this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the aforementioned method.

[0044] Fourthly, this application provides a computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the aforementioned method.

[0045] Fifthly, this application provides a computer program that, when executed by a processor, implements the steps of the aforementioned method.

[0046] Beneficial Effects: This application provides a method for generating contract numbers based on contract text. The method involves obtaining a request to generate contract text; obtaining key fields of the contract text based on the request; obtaining a first random number corresponding to the contract text based on the contract text; combining the key fields and the first random number to obtain a first contract number of the contract text; comparing the first contract number with pre-stored numbers in a database to obtain a comparison result; if the comparison result is a duplicate, regenerating a second random number based on the contract text and combining the second random number with the key fields to obtain a second contract number, which is then stored in the database; if the comparison result is a non-duplicate, storing the first contract number in the database. This method solves the problem of duplicate contract number generation IDs and improves the efficiency of contract number generation and management. Attached Figure Description

[0047] To more clearly illustrate the technical solutions in the embodiments of this application or the conventional technology, the drawings used in the description of the embodiments or the conventional technology will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0048] Figure 1 This is a flowchart of a contract number generation method based on contract text in one embodiment. Detailed Implementation

[0049] To facilitate understanding of this application, a more complete description will be provided below with reference to the accompanying drawings, which illustrate embodiments of the present application. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that the disclosure of this application will be thorough and complete.

[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the specification of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The term "and / or" as used herein includes any and all couplings of one or more of the associated listed items.

[0051] It is understood that the terms “first,” “second,” etc., used in this application may be used herein to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish one element from another.

[0052] The following explanations of some terms used in this application are provided to aid in understanding the application:

[0053] Snowflake is an algorithm developed by Twitter for generating unique IDs in distributed systems.

[0054] Currently, the mainstream approach to generating auto-incrementing contract numbers is based on the Snowflake algorithm. This algorithm consists of a 64-bit long value, comprising 1 sign bit, 41 bits for storing millisecond-level timestamps, 10 bits for storing machine code, and 12 bits for storing sequence numbers. This method is ordered and does not rely on middleware, but it is strongly dependent on the timestamp. If the server's time is too fast and needs to be recalibrated, clock rollback can cause ID duplication issues.

[0055] like Figure 1 As shown, in a first aspect, this application provides a method for generating contract numbers based on contract text, the method comprising:

[0056] S100, Obtain a request for generating contract text.

[0057] Specifically, the request for contract text can be initiated by a department, with employees of that department making the application. This way, when extracting key fields from the contract text in subsequent steps, the department of the company can be reflected in the contract text, which is helpful for the company's subsequent management of the contract text.

[0058] In this way, employees in the department can request contract texts through the corresponding system.

[0059] S200, Based on the request, obtain the key fields of the contract text.

[0060] Specifically, obtaining the key fields of the contract text may include the following steps:

[0061] S201, extract features from the contract text to obtain keyword features.

[0062] S202, Based on the keyword features, obtain the key fields.

[0063] The key fields include at least the department, contract type, and contract signing time.

[0064] Specifically, when drafting a contract, the contract text should at least include the department, contract type, and contract signing date.

[0065] Thus, upon receiving a request, feature recognition of the content in the contract text includes the following steps:

[0066] Extract the first, second, and third regions from the contract text. The first region represents the department, the second the contract type, and the third the contract signing date. In other words, across multiple contract texts, the positions of these three keywords (department, contract type, and contract signing date) can be fixed. For example, the department might be in the upper left corner, the contract type in the upper left or upper right corner, and the contract signing date in the lower right corner. This division of regions based on the aforementioned keyword positions creates the first, second, and third regions.

[0067] Feature extraction is performed on the first, second, and third regions to obtain keyword features. Conventional feature extraction methods (e.g., Bag of Words, TF-IDF, Word2Vec, etc.) are used for these regions. After feature extraction, feature recognition is performed to obtain the keyword features. In other words, for a contract text, only the specified first, second, and third regions need to be recognized, eliminating the need to recognize the entire contract text. This saves time on feature extraction and improves accuracy, avoiding inaccurate feature extraction and incorrect keyword features due to similar departments, contract types, and dates appearing in other parts of the contract text. For example, the contract text can be a framework contract. This fixes the positions of the corresponding first, second, and third regions in the contract text, facilitating targeted feature extraction from these regions.

[0068] It should be noted that, as mentioned above, upon receiving a request, feature identification of the contract text can be performed using the above method for framework contracts. For non-framework contracts, the following method can be used:

[0069] The process involves extracting the first, second, and third regions from the contract text. If at least some of these regions fail to extract key fields, feature recognition is performed on the entire contract text to obtain the key fields. In other words, it first determines whether the contract text is a framework contract. If it is, feature recognition is directly performed on the first, second, and third regions. If the contract text is determined not to be a framework contract, then full-text feature extraction is performed to obtain keyword features. This method avoids the waste of resources associated with directly extracting features from the entire contract text.

[0070] S300, based on the contract text, obtain the first random number corresponding to the contract text.

[0071] Specifically, obtaining the first random number corresponding to the contract text may include the following steps:

[0072] S301, Obtain the current time point corresponding to the request.

[0073] It should be noted that when the system receives a request to generate a contract number, it first obtains the current time. This time is usually a timestamp, representing the number of milliseconds since the start time.

[0074] S302, compare the current time point with the historical time point of the last successful generation of the serial number.

[0075] It should be noted that the system will compare the current time with the stored historical time of the last successfully generated serial number. The historical time is the timestamp corresponding to the last successfully generated serial number.

[0076] S303, if the current time is less than the historical time when the sequence number was successfully generated, then a clock rollback is triggered:

[0077] If the clock rollback is less than the preset time and the number of serial numbers generated at the historical time point has not reached the maximum value, then the current time point is set as the historical time point, and the serial number is extended based on the previous successful generation of the serial number to obtain the first random number with the next serial number;

[0078] If the clock rollback is less than a preset time and the number of serial numbers generated at the historical time point has reached the maximum value, an exception is thrown. The thrown exception includes at least one of the following: executing exception handling code, program termination, and user notification.

[0079] It should be noted that if the current time is earlier than a historical time, this indicates that a clock rollback has occurred. Next, we will determine the appropriate action for each scenario:

[0080] Case 1: The clock rollback is less than the preset time and the serial number has not reached the maximum value.

[0081] If the clock rollback time is less than a system-preset threshold (e.g., 2 seconds), and the number of serial numbers generated at this historical time point has not reached the maximum value (e.g., 4095), then the system sets the current time point as the historical time point and generates a new first random number (i.e., the new serial number) by extending the serial number based on the previously successfully generated serial number.

[0082] Case 2: The clock rollback is less than the preset time, but the serial number has reached the maximum value.

[0083] If the clock rollback time is less than a preset threshold, but the number of serial numbers generated at this historical point in time has already reached the maximum value, the system cannot continue generating serial numbers without generating duplicate serial numbers. In this case, the system will throw an exception.

[0084] For actions that throw an exception, at least one of the following is required: execution of exception handling code, program termination, or user notification. Exception handling code may include logging errors, releasing resources, etc. Program termination may involve safely shutting down or restarting the service. User notification may include sending an alert to the system administrator or displaying an error message to the user.

[0085] For example, assume that the system's preset clock rollback threshold is 2 seconds and the maximum value of the serial number is 4095.

[0086] 1. Normal situation:

[0087] The last time a serial number was successfully generated was at time 1641014400000, and the serial number was 4094.

[0088] The system has received a new request. The current time is 1641014400100.

[0089] Because the current time point is greater than the historical time point, the system normally generates a new serial number 4095.

[0090] 2. Clock rollback and serial number not reached maximum value:

[0091] The last time a serial number was successfully generated was at time 1641014400000, and the serial number was 4094.

[0092] The system has received a new request, and the current time point has been reverted to 1641014399900.

[0093] Because the clock rollback is less than 2 seconds and the serial number has not reached its maximum value, the system sets the current time point to 1641014400000 and the serial number to 4095.

[0094] 3. Clock rollback and serial number has reached maximum value:

[0095] The last time a serial number was successfully generated was at 1641014400000, and the serial number was 4095.

[0096] The system has received a new request, and the current time point has been reverted to 1641014399900.

[0097] Because the clock rollback is less than 2 seconds, but the serial number has reached its maximum value, the system throws an exception, executes exception handling code, which may include logging errors and notifying the system administrator or user. In this way, the system can effectively handle clock rollback while ensuring the uniqueness and continuity of the serial number.

[0098] In addition, the step of forming a clock rollback if the current timestamp is less than the historical timestamp of the last time the sequence number was generated also includes:

[0099] If the clock rollback is greater than or equal to a preset time, and no serial number is generated within the clock rollback time period, then the serial number is extended based on the previous successful generation of the serial number to obtain the first random number with the next serial number;

[0100] If the clock rollback is greater than or equal to a preset time, and a sequence number is generated within the clock rollback time period, then an exception is thrown.

[0101] It should be noted that clock rollback occurs when the system detects that the current timestamp is less than the historical timestamp of the last successful sequence number generation. This includes the following two scenarios:

[0102] Case 1: The clock rollback is greater than or equal to the preset time, but no serial number is generated within the time period.

[0103] If the clock rollback period is greater than or equal to a system-preset threshold (e.g., 2 seconds), and no sequence number is generated within this period, the system can safely generate a new first random number (i.e., the new sequence number) by extending the sequence number based on the previously successfully generated sequence number. In this case, it is assumed that no other instance generated a sequence number during the rollback period, so continuing to number will not cause duplication.

[0104] Case 2: The clock rollback is greater than or equal to the preset time and a serial number has been generated within the time period.

[0105] If the clock rollback period is greater than or equal to a preset threshold, and a sequence number has already been generated within this period, the system cannot determine whether continuing to generate sequence numbers will lead to duplication. In this case, the system throws an exception to avoid potential data consistency issues. The handling of such exceptions is as described above and will not be repeated here.

[0106] For example, assume that the system's preset clock rollback threshold is 2 seconds and the maximum value of the serial number is 4095.

[0107] 1. Clock rollback is greater than or equal to the preset time but no serial number is generated:

[0108] The last time a serial number was successfully generated was at time 1641014400000, and the serial number was 4094.

[0109] The system time was rolled back to 1641014399000, a clock rollback of 1000 milliseconds (1 second) occurred, and no other operations generated a sequence number during this 1 second.

[0110] Because the clock rollback is less than the preset 2-second threshold, and no serial number is generated during this period, the system will extend the serial number from 4094 to 4095.

[0111] 2. Clock rollback is greater than or equal to the preset time and a serial number has been generated:

[0112] The last time a serial number was successfully generated was at time 1641014400000, and the serial number was 4094.

[0113] The system time was rolled back to 1641014398000, and a clock rollback of 2000 milliseconds (2 seconds) occurred. During these two seconds, the system generated serial number 4095.

[0114] Because the clock rollback is equal to the preset 2-second threshold, and a serial number has already been generated during this period, the system cannot determine whether it is safe to continue generating serial numbers, and therefore throws an exception.

[0115] By employing the above strategies, the system can effectively handle the problem of duplicate serial numbers caused by clock rollback while ensuring data consistency.

[0116] S400, combine the key field and the first random number to obtain the first contract number of the contract text.

[0117] Specifically, obtaining the first contract number of the contract text may include the following steps:

[0118] S401, determine the number of tags according to the pre-set combination order.

[0119] Specifically, before generating contract numbers, the system needs a predefined template that specifies which key fields should be included in the contract number and their order. For example, the template might be "Department Number - Contract Type - Contract Signing Date - Random Number". Each key field in the template corresponds to a tag, and the system needs to determine the number of tags and their order based on the template. The number and order of tags are determined according to business requirements and contract numbering specifications.

[0120] S402, Match the tag with the key field to obtain the key field with the tag.

[0121] Specifically, the system extracts key fields from the contract text, which have been identified in previous steps and include at least the department, contract type, and contract signing time.

[0122] The system then matches these key fields with the tags in the template. For example, if the order in the template is "Department Number-Contract Type-Contract Signing Date", the system will put the extracted fields into the template in that order.

[0123] The purpose of this step is to convert unstructured key field information into a structured format so that it can be further processed.

[0124] S403, combine the key field with the label and the first random number to obtain the first contract number of the contract text.

[0125] Specifically, once the key fields are tokenized, the system combines them with a first random number to generate the final contract number.

[0126] The first random number was generated in the previous steps, which ensures the uniqueness of the contract number.

[0127] The system concatenates the key fields and the first random number according to a predefined template order to form a complete contract number. For example, if the key field is "Sales Department-Lease Contract-2024-01-01" and the first random number is "123456789", then the contract number might be "Sales Department-Lease Contract-2024-01-01-123456789".

[0128] Exemplary

[0129] Department: Sales Department;

[0130] Contract type: Lease contract;

[0131] Contract signing date: 2024-01-01;

[0132] The first random number is: 123456789;

[0133] If the template for the contract number is: "Department Number - Contract Type - Contract Signing Date - Random Number", then the contract number is: Sales Department - Lease Contract - 2024-01-01-123456789.

[0134] This contract number combines key field information with a random number, containing both basic contract information and ensuring the uniqueness of the number.

[0135] Through the above steps, the system can automatically generate structured and unique contract numbers, simplifying the contract management process and reducing the possibility of human error.

[0136] It should be noted that a predefined template was constructed, which determines the combination order of key fields. This can be understood as the template having a certain number of blanks; filling in the blanks with the corresponding key fields generates the contract number. Furthermore, each blank represents a label. This allows for adjustments to the pre-defined combination order later on; simply adjust the label's position. After the label is adjusted, the key field it represents will also be adjusted, improving the ease of adjusting the combination order. In particular, if additional contract number content is needed after the pre-defined combination order has been formed, simply add blanks to the template and add corresponding labels to these blanks. This method is especially suitable for situations where a large number of contract numbers have already been generated and adjustments to their content are required, improving processing efficiency and operational convenience.

[0137] S500, compare the first contract number with the number pre-stored in the database to obtain the comparison result.

[0138] Specifically, the comparison method can be to use SQL query commands in the database for query comparison.

[0139] S600, if the comparison result is a duplicate, then a second random number is regenerated based on the contract text, and the second random number is combined with the key field to obtain a second contract number, which is then stored in the database;

[0140] If the comparison result is non-duplicate, the first contract number is stored in the database.

[0141] Specifically, step S600 may include the following steps:

[0142] S501, retrieve a pre-stored number in the database that is the same as the first contract number.

[0143] S502, based on the pre-stored number, traverse several numbers following the pre-stored number to obtain the first temporary comparison number group.

[0144] S503, compare the second contract number with the first temporary comparison number group to obtain a temporary comparison result;

[0145] If the comparison result is non-duplicate, the second contract number is stored in the database;

[0146] If the comparison result is a duplicate, a third random number is regenerated based on the contract text, and the third random number is combined with the key field to obtain a third contract number. The third contract number is then compared with a second temporary comparison number group, where the second temporary comparison number group represents the number that is the same as the second contract number, and is formed by combining several subsequent numbers.

[0147] Specifically, this step involves comparing the newly generated second contract number with the first temporary comparison number group. If the comparison result is non-duplicate, it means that the second contract number is unique and can be stored in the database. If the comparison result is duplicate, it means that other users have already generated new contract numbers during the generation of the second contract number, so the third contract number needs to be regenerated.

[0148] It's important to note that after generating a new contract number, the system needs to check if the same number already exists in the database. That is, the system performs a query to search the database for records that exactly match the newly generated first contract number. If a duplicate number is found, a new contract number needs to be constructed, i.e., the second contract number. However, this construction might require manual intervention or automatic generation. During the second contract number generation process, other users might also be requesting contract text and successfully generating contract numbers. This could result in several contract numbers being generated after the pre-stored numbers (from other users' successful contract text requests). In this case, the pre-stored numbers and these subsequent contract numbers are combined into a temporary comparison group. Next, the second contract number is generated according to the contract number generation method. Then, only the second contract number needs to be compared with the temporary comparison group; a global database comparison is unnecessary, saving resources. The purpose of this method is to handle number conflicts that may occur due to concurrent operations.

[0149] In addition, if the comparison results are repeated, a second temporary comparison number group is reconstructed according to the aforementioned method for comparison. If the results are repeated, a temporary comparison number group needs to be reconstructed again until the generated contract numbers are not repeated. The generated unique numbers are then stored in the database.

[0150] It should be noted that since the existing numbers in the database are unique, when comparing the generated contract number with the number in the database, if there is a duplicate, it will most likely be a duplicate of the last number in the database. In the case of a duplicate, when regenerating the contract number, the sequence number will be generated in a sequential manner. That is to say, the temporary comparison number group only considers the number after the duplicate number, and does not need to consider the number before it. If no other numbers are generated after the number in the temporary comparison number group, then there will be only one number in this temporary comparison number group that is a duplicate of the newly generated contract number.

[0151] Exemplary

[0152] Assume the contract number format is: "Department Number-Contract Type-Contract Signing Date-Random Number", and the system's preset check range is the next 10 numbers.

[0153] 1. Initial situation:

[0154] User A generated a contract number: "Sales Department - Lease Contract - 2024-01-01-123456".

[0155] The system executes step S501, finds that this number is unique, and stores it in the database.

[0156] 2. Concurrency:

[0157] User B generated the same contract number almost simultaneously: "Sales Department - Lease Contract - 2024-01-01-123456".

[0158] The system executes step S501 and finds that this number already exists, so it proceeds to step S502.

[0159] The system checked the 10 serial numbers following "Sales Department-Lease Contract-2024-01-01-123456" and found that they had all been occupied by other users.

[0160] User B's system enters step S503, generates a new random number, such as "789012", and generates a second contract number: "Sales Department - Lease Contract - 2024-01-01-789012".

[0161] The system compares this second contract number with the first temporary comparison number group, confirms its uniqueness, and then stores it in the database.

[0162] 3. Duplicate second contract number:

[0163] If, in step S503, the second contract number is found to be duplicated after comparison with the first temporary comparison number group, it indicates that another user has already occupied this number during the generation of the second contract number.

[0164] The system will then generate a third random number, such as "345678", and generate a third contract number: "Sales Department - Lease Contract - 2024-01-01-345678".

[0165] The system compares this third contract number with the second temporary comparison number group (i.e., several numbers following the second contract number), confirms its uniqueness, and then stores it in the database.

[0166] The above method uses temporary comparison number groups for number caching, avoiding database performance degradation caused by frequent database queries.

[0167] Example

[0168] For example, if a company has System Department 1 and System Department 2, their corresponding system names would be 0001 and 0002 respectively; if there are personnel contracts and procurement contracts, their corresponding system names would be RSHT and CGHT respectively. Now, there is a personnel contract with a signing date of January 1, 2024. In this embodiment, after receiving a request to generate contract text, the key fields of the contract are obtained, including the department, contract type, and contract signing date, and a random number is generated for the contract file. The random number generation uses an optimized Snowflake algorithm. This optimization mainly includes:

[0169] If the clock rollback is less than 2 seconds, the current time will be set to the time of the last ID generation; if it exceeds 2 seconds, an exception will be thrown. If the ID generated at the last time point is less than 4095, but exceeds 4095, an exception will be thrown, and ID generation can continue even with a clock rollback. If a clock rollback occurs, say for 5 seconds, and no ID needs to be generated within those 5 seconds, the clock rollback has no impact. This solves the problem of duplicate serial numbers caused by the Snowflake algorithm triggering a clock rollback when generating contract serial numbers. The optimized algorithm is implemented in Java, and the core code is as follows:

[0170]

[0171]

[0172] For example, if the sequence code obtained by the above algorithm is "49422236…8882773", then the contract number corresponding to the personnel contract signed by System One on January 1, 2024 can be represented as "0001+RSHT+20240101+49422236…8882773".

[0173] Determine if a completely identical contract number exists in the database. If so, generate a new random number for that contract and recombine it to form a new contract number; otherwise, successfully save the contract number and its corresponding contract information to the database.

[0174] In some embodiments, if a contract number fails to be generated successfully the first time using this method, the contract number is generated a second time using this method, until it is determined that there are no duplicate contract numbers in the database, at which point the contract number can be truly persisted in the database.

[0175] In some embodiments, the contract number is formatted as "Department Number + Contract Type + Contract Signing Date + Random Number," where the department number is 4 digits, the contract type is an abbreviation of the first character of a Chinese character (capitalized), the contract date is 4 digits, and the random number is 64 digits long. The department number, contract type, contract signing date, and random number can be freely combined in any order. It should be understood that the format of the contract number is not limited to the one described above; the order of "Department Number + Contract Type + Contract Signing Date + Random Number" can be arbitrary.

[0176] In summary, this application presents a contract number generation method based on contract text. It receives a request to generate contract text, obtains key fields of the contract, generates random numbers for the contract file, and assembles a contract number based on the obtained key fields and the generated random numbers. The method then checks if an identical contract number exists in the database. If so, it regenerates a random number for that contract, thus recombining the two to form a new contract number. Otherwise, it successfully saves the contract number and its corresponding contract information to the database. This solves the problem of duplicate contract number generation IDs and improves the efficiency of contract number generation and management.

[0177] Secondly, this application provides a contract numbering system based on contract text, applied to the aforementioned contract numbering method based on contract text, the system comprising:

[0178] The receiving module is used to receive requests for generating contract text;

[0179] The generation module is used to obtain the key fields of the contract text based on the request;

[0180] The generation module is also used to obtain a first random number corresponding to the contract text based on the contract text;

[0181] The combination module is used to combine the key field and the first random number to obtain the first contract number of the contract text;

[0182] The judgment module is used to compare the first contract number with the number pre-stored in the database to obtain the comparison result;

[0183] If the comparison result is a duplicate, a second random number is regenerated based on the contract text, and the second random number is combined with the key field to obtain a second contract number, which is then stored in the database.

[0184] If the comparison result is non-duplicate, the first contract number is stored in the database.

[0185] Thirdly, this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the aforementioned method.

[0186] Fourthly, this application provides a computer storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the aforementioned method.

[0187] Fifthly, this application provides a computer program that, when executed by a processor, implements the steps of the aforementioned method.

[0188] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0189] The various embodiments in this disclosure are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0190] The scope of protection of this disclosure is not limited to the embodiments described above. Obviously, those skilled in the art can make various modifications and variations to this disclosure without departing from its scope and spirit. If such modifications and variations fall within the scope of the claims of this disclosure and their equivalents, then the intent of this disclosure also includes such modifications and variations.

Claims

1. A method for generating contract numbers based on contract text, characterized in that the method... include: Obtain the request used to generate the contract text; Based on the request, obtain the key fields of the contract text; Based on the contract text, obtain the first random number corresponding to the contract text; The key field and the first random number are combined to obtain the first contract number of the contract text; The first contract number is compared with the numbers pre-stored in the database to obtain the comparison result; If the comparison result is a duplicate, a second random number is regenerated based on the contract text, and the second random number is combined with the key field to obtain a second contract number, which is then stored in the database. If the comparison result is non-duplicate, then the first contract number is stored in the database; wherein, The step of obtaining the key fields of the contract text according to the request includes: Feature extraction is performed on the contract text to obtain keyword features; Based on the keyword features, key fields are obtained, wherein the key fields include at least the department, contract type, and contract signing time; Upon receiving a request, feature recognition of the content in the contract text includes: Retrieve the first, second, and third regions from the contract text. The first region represents the region where the department is located, the second region represents the region where the contract type is located, and the third region represents the region where the contract was signed. Feature extraction is performed on the first, second, and third regions to obtain keyword features; The first, second, and third regions of the contract text are retrieved. If at least some of the key fields are not extracted from the first, second, and third regions, feature recognition is performed on the entire contract text to obtain the key fields; among them, The step of combining the key field and the first random number to obtain the first contract number of the contract text includes: The number of tags is determined according to a pre-set combination order; Match the tag with the key field to obtain the key field containing the tag; The key field with the label and the first random number are combined to obtain the first contract number of the contract text; Build a predefined template and determine the order in which key fields are combined; The template has a label space; fill the key fields into the label space to form the contract number. To adjust or add to the order of key fields, adjust or add label positions to create a new order of key fields. The step of regenerating a second random number based on the contract text if the comparison result is a duplicate, combining the second random number with the key field to obtain a second contract number, and storing it in the database includes: Retrieve from the database any pre-stored numbers that are duplicates of the first contract number; Based on the pre-stored number, traverse several numbers following the pre-stored number to obtain the first temporary comparison number group; The second contract number is compared with the first temporary comparison number group to obtain the temporary comparison result; If the comparison result is non-duplicate, the second contract number is stored in the database; If the comparison result is a duplicate, a third random number is regenerated based on the contract text, and the third random number is combined with the key field to obtain a third contract number. The third contract number is then compared with the second temporary comparison number group, wherein the second temporary comparison number group represents a combination of several numbers following the number that is duplicated with the second contract number.

2. The contract number generation method based on contract text according to claim 1, characterized in that, The step of obtaining the first random number corresponding to the contract text based on the contract text includes: Obtain the current time point corresponding to the request; Compare the current time point with the historical time point of the last successful generation of a serial number; If the current time is less than the historical time when the sequence number was successfully generated, a clock rollback is triggered. If the clock rollback is less than the preset time and the number of serial numbers generated at the historical time point has not reached the maximum value, then the current time point is set as the historical time point, and the serial number is extended based on the previous successful generation of the serial number to obtain the first random number with the next serial number; If the clock rollback is less than a preset time and the number of serial numbers generated at the historical time point has reached the maximum value, an exception is thrown. The thrown exception includes at least one of the following: executing exception handling code, program termination, and user notification.

3. The contract number generation method based on contract text according to claim 2, characterized in that, The step of triggering a clock rollback if the current time is less than the historical time when the sequence number was last generated includes: If the clock rollback is greater than or equal to a preset time, and no serial number is generated within the clock rollback time period, then the serial number is extended based on the previous successful generation of the serial number to obtain the first random number with the next serial number; If the clock rollback is greater than or equal to a preset time, and a sequence number is generated within the clock rollback time period, then an exception is thrown.

4. A contract numbering system based on contract text, characterized in that, The system, applicable to the contract number generation method based on contract text according to any one of claims 1-3, comprises: The receiving module is used to receive requests for generating contract text; The generation module is used to obtain the key fields of the contract text based on the request; The generation module is also used to obtain a first random number corresponding to the contract text based on the contract text; The combination module is used to combine the key field and the first random number to obtain the first contract number of the contract text; The judgment module is used to compare the first contract number with the number pre-stored in the database to obtain the comparison result; If the comparison result is a duplicate, a second random number is regenerated based on the contract text, and the second random number is combined with the key field to obtain a second contract number, which is then stored in the database. If the comparison result is non-duplicate, the first contract number is stored in the database.

5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.

6. A computer storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.

7. A computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.