Contract number generation method and system based on contract text

By generating a contract number based on contract text, extract key fields and generate random numbers, combine the contract number, and use comparison to ensure the uniqueness of the contract, solve the problem of low contract number management efficiency in traditional methods, realize efficiency, achieve efficiency, efficient, and efficient and efficient, and achieve efficiency, efficient, and efficient, and efficient, and efficient and efficient, Accurate contract number generation and management.

CN119378501AActive Publication Date: 2025-01-28NO 15 INST OF CHINA ELECTRONICS TECH GRP

Patent Information

Application Number
CN202411521337.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-01-28
Estimated Expiration
2044-10-29

AI Technical Summary

Technical Problem

Traditional contract number management methods are difficult to support the automatic generation of multiple types of incremental contract numbers online, especially in a multi-person collaboration environment, which leads to inefficiency and high error rates, which cannot meet the needs of large enterprises for high efficiency and high accuracy.

Method used

Provide a contract number generation method based on contract text, to obtain the request of the contract text, extract key fields, generate random numbers, and form a contract number to combine key fields and random numbers to ensure uniqueness.

Benefits of technology

The automation contract number generation and management have been realized, supporting multi -user cooperation, improving work efficiency, reducing human errors, and flexible response to different types of contract numbers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119378501A_ABST
    Figure CN119378501A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of computers. The invention discloses a contract number generation method based on a contract text. The method comprises the following steps: acquiring a request for generating the contract text; obtaining a key field 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 field and the first random number to obtain a first contract number of the contract text; comparing the first contract number with a number pre-stored in a database to obtain a comparison result; if the comparison result is repeated, regenerating a second random number according to the contract text, combining the second random number with the key field to obtain a second contract number, and storing the second contract number in the database; and if the comparison result is non-repetition, storing the first contract number in a database. Through the method, the problem that the contract number generation ID is repeated is solved, and the contract number generation and management efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and in particular, relates to a method and system for generating a contract number based on a contract text. Background Art

[0002] In previous practice, the management of contract numbers often relied on contract number management specialists, who needed to allocate and record contract numbers in advance, either in paper form offline or in electronic form online. However, this manual management method has obvious limitations, especially in a multi-person collaborative environment, where it is difficult to support the automatic generation of multiple types of incremental contract numbers online. With the growth of enterprise scale and the expansion of business, the number and types of contracts are increasing, and traditional management methods can no longer meet the needs of large enterprises for high efficiency and accuracy in contract number management.

[0003] Therefore, enterprises urgently need a new method for generating and managing contract numbers, which should be able to automatically process a large number of contracts, support multi-user collaboration, and be able to flexibly respond to different types of contract number requirements to improve overall work efficiency and reduce human errors. Summary of the invention

[0004] Based on this, it is necessary to provide a method and system for generating a contract number based on the contract text to address the above technical issues.

[0005] In a first aspect, the present application provides a method for generating a contract number based on a contract text, the method comprising:

[0006] Get a request for generating a contract text;

[0007] According to the request, obtain key fields of the contract text;

[0008] According to the contract text, obtaining a first random number corresponding to the contract text;

[0009] Combining the key field and the first random number to obtain a first contract number of the contract text;

[0010] Compare the first contract number with the number pre-stored in the database to obtain a comparison result;

[0011] If the comparison result is a duplicate, regenerate a second random number according to the contract text, combine the second random number with the key field to obtain a second contract number, and store it in the database;

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

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

[0014] Extracting features from the contract text to obtain keyword features;

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

[0016] In some practicable manners, the step of obtaining a first random number corresponding to the contract text according to the contract text includes:

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

[0018] Compare the current time point with the historical time point when the sequence number was last successfully generated;

[0019] If the current time point is less than the historical time point when the sequence number was successfully generated last time, a clock is rolled back:

[0020] If the clock is dialed back less than the preset time, and the number of sequence numbers generated at the historical time point has not reached the maximum value, the current time point is set as the historical time point, and the sequence number is postponed based on the last successful generation of the sequence number to obtain the first random number with the next sequence number;

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

[0022] In some practicable manners, if the current timestamp is less than the historical timestamp of the last generated sequence number, the step of dialing back the clock includes:

[0023] If the clock dial-back time is greater than or equal to the preset time, and no sequence number is generated during the clock dial-back time period, the sequence number is postponed based on the last successful generation of the sequence number to obtain the first random number with the next sequence number;

[0024] If the clock is dialed back for a period greater than or equal to a preset time, and a sequence number is generated within the time period of the clock being dialed back, an exception is thrown.

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

[0026] Determine the number of labels according to the pre-set combination order;

[0027] Matching the tag with the key field to obtain the key field with the tag;

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

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

[0030] Obtaining a pre-stored number in the database that is repeated with the first contract number;

[0031] According to the pre-stored number, traverse a number of numbers after the pre-stored number to obtain a first temporary comparison number group;

[0032] Compare the second contract number with the first temporary comparison number group to obtain a 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 duplication, 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, and the third contract number is compared with the second temporary comparison number group, wherein the second temporary comparison number group represents a number that is repeated with the second contract number, and is formed by a combination of several subsequent numbers.

[0035] In a second aspect, the present application provides a system for generating a contract number based on a contract text, which is applied to the aforementioned method for generating a contract number based on a contract text, and the system comprises:

[0036] A receiving module, used for obtaining a request for generating a contract text;

[0037] A generating module, used for obtaining key fields of the contract text according to the request;

[0038] The generating module is further used to obtain a first random number corresponding to the contract text according to the contract text;

[0039] A combining module, used for combining the key field and the first random number to obtain a first contract number of the contract text;

[0040] A judgment module, used for comparing the first contract number with the number pre-stored in the database to obtain a comparison result;

[0041] If the comparison result is a duplicate, regenerate a second random number according to the contract text, combine the second random number with the key field to obtain a second contract number, and store it in the database;

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

[0043] In a third aspect, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the aforementioned method when executing the computer program.

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

[0045] In a fifth aspect, the present application provides a computer program, which implements the steps of the aforementioned method when executed by a processor.

[0046] Beneficial effect: This application provides a method for generating a contract number based on a contract text, which includes obtaining a request for generating a contract text; obtaining a key field 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 field and the first random number to obtain a first contract number of the contract text; comparing the first contract number with a number pre-stored in a database to obtain a comparison result; if the comparison result is a duplicate, regenerating a second random number according to the contract text, combining the second random number with the key field to obtain a second contract number, and storing it in the database; if the comparison result is non-duplicate, storing the first contract number in the database. The above method solves the problem of duplicate IDs in contract number generation, and improves the efficiency of contract number generation and management. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the conventional technology, the drawings required for use in the embodiments or the conventional technology descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0048] Figure 1 The present invention is a flowchart of a method for generating a contract number based on a contract text in one embodiment. DETAILED DESCRIPTION

[0049] In order to facilitate understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. Embodiments of the present application are provided in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.

[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used herein includes any and all couplings of one or more related listed items.

[0051] It can be understood that the terms "first", "second", etc. used in the present application can be used in this article to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from another element.

[0052] Some terms involved in this application are explained below to facilitate understanding of this application:

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

[0054] At present, the mainstream method of generating self-incrementing contract numbers is based on the snowflake algorithm. This algorithm consists of a 64-bit long type value consisting of 1 sign bit, 41 bits to store millisecond timestamps, 10 bits to store machine codes, and 12 bits to store serial numbers. This method is orderly and does not require middleware, but it strongly relies on timestamps. If the server time is fast and recalibrated, the clock will be dialed back to cause ID duplication problems.

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

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

[0057] Specifically, the request for the contract text may be made by a department, and the application may be made by the department's employees. In this way, when extracting key fields from the contract text in subsequent steps, the company's department may be reflected in the contract text to facilitate the company's subsequent management of the contract text.

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

[0059] S200, obtaining key fields of the contract text according to the request.

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

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

[0062] S202: Obtain key fields according to the keyword features.

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

[0064] Specifically, when drafting the contract text, the contract text shall at least include the department, contract type and contract signing time.

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

[0066] The first area, the second area, and the third area in the contract text are obtained, wherein the first area indicates the area where the department is located, the second area indicates the area where the contract type is located, and the third area indicates the area where the contract signing time is located. That is to say, in multiple contract texts, for the department, contract type, and contract signing time, the positions of the areas where these three keywords are located can be fixed, for example, the department is in the upper left position of the contract, the contract type is in the upper left or upper right position of the contract, and the contract signing time is in the lower right position of the contract. In this way, regional division is performed according to the positions of the aforementioned keywords, and the first area, the second area, and the third area are formed accordingly.

[0067] Feature extraction is performed on the first area, the second area, and the third area to obtain keyword features, wherein conventional feature extraction methods (e.g., Bag of Words, TF-IDF (Term Frequency-Inverse Document Frequency), Word2Vec, etc.) are used to extract features from the first area, the second area, and the third area. After the features are extracted, the features are identified to obtain keyword features. In other words, for a contract text, it is only necessary to identify the designated first area, the second area, and the third area, and there is no need to identify the entire content of the contract text, thereby saving the time required for feature extraction and improving the accuracy, avoiding the problem of inaccurate feature extraction and incorrect keyword features due to the appearance of similar departments, contract types, and times in other locations in the contract text. Exemplarily, the contract text may be a framework contract. In this way, the positions of the corresponding first area, the second area, and the third area in the contract text are fixed, which facilitates targeted feature extraction of the above areas.

[0068] It should be noted that, after receiving the request, the aforementioned feature recognition of the content in the contract text is processed by the above processing method for the framework contract section, and the non-framework contract can be processed by the following method:

[0069] The first area, the second area, and the third area in the contract text are obtained. If the first area, the second area, and the third area at least partially fail to extract the key field, the full text of the contract text is subjected to feature recognition to obtain the key field. In other words, first determine whether the contract text is a framework contract. If it is a framework contract, directly perform feature recognition on the first area, the second area, and the third area. When it is determined that the contract text is not a framework contract, perform full-text feature extraction on the contract text to obtain keyword features. In this way, the problem of directly extracting the full text of the contract text and wasting resources is avoided.

[0070] S300: Obtain a first random number corresponding to the contract text according to the contract text.

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

[0072] S301, obtaining 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 point, which is usually a timestamp indicating the number of milliseconds since the start time.

[0074] S302: Compare the current time point with the historical time point when the sequence number was successfully generated last time.

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

[0076] S303: If the current time point is less than the historical time point when the sequence number was successfully generated last time, a clock is dialed back:

[0077] If the clock is dialed back less than the preset time, and the number of sequence numbers generated at the historical time point has not reached the maximum value, the current time point is set as the historical time point, and the sequence number is postponed based on the last successful generation of the sequence number to obtain the first random number with the next sequence number;

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

[0079] It should be noted that if the current time point is less than the historical time point, this indicates that the clock has been rolled back. Next, make judgments based on different situations:

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

[0081] If the clock is dialed back less than a threshold preset by the system (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), the system sets the current time point as the historical time point, and generates a new first random number (i.e., a new serial number) by postponing the serial number based on the last successfully generated serial number.

[0082] Case 2: The clock is set back less than the preset time but the sequence number has reached the maximum value.

[0083] If the clock is dialed back less than the preset threshold, but the number of sequence numbers generated at this historical time point has reached the maximum, the system cannot continue to generate sequence numbers without generating duplicate sequence numbers. In this case, the system will throw an exception.

[0084] The behavior of throwing an exception includes at least one of executing exception handling code, program termination, and user notification. Exception handling code may include recording error logs, releasing resources, etc. Program termination may involve safely shutting down or restarting services. User notification may include sending an alert to the system administrator or displaying an error message to the user.

[0085] For example, it is assumed that the clock dial-back threshold preset by the system is 2 seconds and the maximum value of the sequence number is 4095.

[0086] 1. Normal situation:

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

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

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

[0090] 2. The clock is set back and the sequence number does not reach the maximum value:

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

[0092] The system receives a new request and calls back to 1641014399900 at the current time.

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

[0094] 3. The clock is dialed back and the sequence number has reached the maximum value:

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

[0096] The system receives a new request and calls back to 1641014399900 at the current time.

[0097] Because the clock is set back less than 2 seconds, but the sequence number has reached the maximum value, the system throws an exception and executes the exception handling code, which may include recording an error log and notifying the system administrator or user. In this way, the system can effectively handle the clock setback while ensuring the uniqueness and continuity of the sequence number.

[0098] In addition, if the current timestamp is less than the historical timestamp of the last generated sequence number, the step of setting the clock back further includes:

[0099] If the clock dial-back time is greater than or equal to the preset time, and no sequence number is generated during the clock dial-back time period, the sequence number is postponed based on the last successful generation of the sequence number to obtain the first random number with the next sequence number;

[0100] If the clock is dialed back for a period greater than or equal to a preset time, and a sequence number is generated within the time period of the clock being dialed back, an exception is thrown.

[0101] It should be noted that when the system detects that the current timestamp is less than the historical timestamp of the last successful generation of the serial number, the clock will be rolled back. This may include the following two situations:

[0102] Case 1: The clock is set back to a time greater than or equal to the preset time, but no sequence number is generated during the time period.

[0103] If the length of the clock callback is greater than or equal to a system preset threshold (e.g., 2 seconds), and no sequence number is generated during this period, the system can safely postpone the sequence number based on the last successfully generated sequence number and generate a new first random number (i.e., a new sequence number). In this case, it is assumed that no other instances have generated sequence numbers during the callback period, so continuing the numbering will not cause duplication.

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

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

[0106] For example, it is assumed that the clock dial-back threshold preset by the system is 2 seconds and the maximum value of the sequence number is 4095.

[0107] 1. The clock is set back to a time 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 1641014400000, and the serial number was 4094.

[0109] The system time is dialed back to 1641014399000, the clock is dialed back 1000 milliseconds (1 second), and no other operations generate sequence numbers within this 1 second.

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

[0111] 2. The clock is set back to a time 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 1641014400000, and the serial number was 4094.

[0113] The system time is dialed back to 1641014398000, and the clock is dialed back 2000 milliseconds (2 seconds). Within these two seconds, the system generates sequence number 4095.

[0114] Because the clock is set back to the preset 2-second threshold and serial numbers have been generated during this period, the system cannot determine whether it is safe to continue generating serial numbers, so an exception is thrown.

[0115] Through the above strategy, the system can effectively handle the problem of serial number duplication caused by clock dialback while ensuring data consistency.

[0116] S400, combining 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, determining the number of tags according to a preset combination sequence.

[0119] Specifically, before generating a contract number, the system needs to have 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 label, and the system needs to determine how many labels are needed and their order based on the template. The number and order of labels are determined based on business needs and the specifications of the contract number.

[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 the previous steps, including at least department, contract type and contract signing time.

[0122] The system then matches these key fields with the labels 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 this order.

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

[0124] S403: Combine the key field with the tag and the first random number to obtain a first contract number of the contract text.

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

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

[0127] The system concatenates the key field and the first random number in the 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 may be "Sales Department-Lease Contract-2024-01-01-123456789".

[0128] Exemplarily

[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 of the contract number is: "Department Number-Contract Type-Contract Signing Date-Random Number", the contract number is: Sales Department-Lease Contract-2024-01-01-123456789.

[0134] This contract number combines key field information and random numbers, which not only contains the basic information of the contract but also ensures the uniqueness of the number.

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

[0136] It should be noted that a predefined template is constructed, that is, the combination order of key fields is determined. It can be understood that there are a corresponding number of spaces on the template, and the key fields are filled into the spaces to form the contract number. In addition, each space represents a label, so that in subsequent work, if you want to adjust the pre-set combination order, you can adjust the position of the label. After the label is adjusted, the key field represented by the label will be adjusted accordingly, which improves the convenience of adjusting the combination order. In particular, after the pre-set combination order has been formed, if you still want to add the contract number content, you can add a space in the template and add the corresponding label to this space. This method is particularly suitable for adjusting the content of the contract number after a large number of contract numbers have been formed, which improves processing efficiency and convenience of operation.

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

[0138] Specifically, the comparison method may be to use an SQL query command in a database to perform a query comparison.

[0139] S600, if the comparison result is a duplicate, regenerate a second random number according to the contract text, combine the second random number with the key field to obtain a second contract number, and store it 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, obtaining a pre-stored number in the database that is repeated with the first contract number.

[0143] S502: According to a pre-stored number, traverse a number of numbers after the pre-stored number to obtain a first temporary comparison number group.

[0144] S503, comparing 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 duplication, 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, and the third contract number is compared with the second temporary comparison number group, wherein the second temporary comparison number group represents a number that is repeated with the second contract number, and is formed by a combination of 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 during the process of generating the second contract number, other users have generated a new contract number, so the third contract number needs to be regenerated.

[0148] It should be noted that after a new contract number is generated, the system needs to check whether the same number already exists in the database. That is, the system performs a query operation to search the database for records that fully match the newly generated first contract number. When a number that is repeated with the first contract number is found, the contract number needs to be reconstructed, that is, the second contract number. However, when constructing the second contract number, it may be necessary to manually request it again, or the second contract number may be automatically generated. However, in the process of generating the second contract number, there is a possibility that other users are also making contract text requests, and the request is successful, and the contract number is generated, which results in several contract numbers after the pre-stored number (the contract text request of other users is successful, and the contract number is generated). Then, the pre-stored number and the subsequent several contract numbers are combined into a temporary temporary comparison number group. Next, according to the contract number generation method, the second contract number is generated, and then, only the second contract number needs to be compared with the temporary comparison number group, without the need to perform a global comparison of the database, saving resources. The purpose of the above method is to handle number conflicts that may be caused by concurrent operations.

[0149] In addition, when the comparison result is repeated again, the second temporary comparison number group is reconstructed according to the above method for comparison. If it is repeated, the temporary comparison number group needs to be reconstructed until the generated contract number is not repeated, and the generated non-repeating number is stored in the database.

[0150] It should be noted that since the existing numbers in the database are unique, when the generated contract number is compared with the numbers in the database, if there is a duplication, it will most likely be the same as the last number in the database. In the case of a duplication, when the contract number is regenerated, the serial number will be generated in a sequential manner. In other words, the temporary comparison number group formed only considers the numbers after the duplicate number, without considering the previous numbers. If no other numbers are generated after the number in the temporary comparison number group, there will be only one number in this temporary comparison number group that is the same as the newly generated contract number.

[0151] Exemplarily

[0152] Assume that the format of the contract number is: "Department Number-Contract Type-Contract Signing Date-Random Number", and the system presets the checking range to be the next 10 numbers.

[0153] 1. Initial situation:

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

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

[0156] 2. Concurrency:

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

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

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

[0160] User B's system proceeds to 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, and after confirming its uniqueness, 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 means that other users have already occupied this number during the process of generating the second contract number.

[0164] The system will regenerate 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 after the second contract number), and after confirming its uniqueness, stores it in the database.

[0166] The above method utilizes temporary comparison number groups to cache numbers, thereby avoiding frequent queries to the database that may cause performance degradation of the database.

[0167] Example

[0168] For example, if an enterprise has System 1 and System 2, they are 0001 and 0002 respectively; if the contract types are personnel contracts and procurement contracts, they are RSHT and CGHT respectively. Now there is a personnel contract with a contract signing date of January 1, 2024. After receiving a request to generate a contract text, this embodiment obtains the key fields of the contract, including department, contract type, and contract signing time, and generates a random number for the contract file. The optimized snowflake algorithm (SnowF lake) is used to generate random numbers. The optimization content mainly includes:

[0169] If the clock goes back by no more than 2 seconds, the current time point will be set to the time point when the last id was generated, and an exception will be thrown if it exceeds 2 seconds; if the id generated at the last time point does not reach 4095, an exception will be thrown if it exceeds 4095. Even if the clock is rewound, the id can continue to be generated. If the clock is rewound, assuming it is 5 seconds, then if no id needs to be generated within these 5 seconds, then the clock rewound will have no effect. This solves the problem of serial number duplication caused by the clock rewound when the contract serial number is generated using the snowflake algorithm (SnowF l ake). The algorithm optimization is implemented in JAVA language, and the core code is as follows:

[0170]

[0171]

[0172] For example, if the serial code obtained by the above algorithm is "49422236...8882773", the contract number corresponding to the personnel contract signed on January 1, 2024 in the system can be expressed as "0001+RSHT+20240101+49422236...8882773".

[0173] Determine whether there is an identical contract number in the database. If so, regenerate a random number for the contract to recombine it into 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 is not successfully generated for the first time according to this method, the contract is generated a second time or more according to this method until it is determined that there is no duplicate contract number in the database, and then the contract number can be truly persisted in the database.

[0175] In some embodiments, the contract number is in the format of "department number + contract type + contract signing date + random number", where the department number is 4 digits, the contract type is the Chinese abbreviation with the first letter capitalized, the contract date is 4 digits, and the length of the random number is 64 digits. The department number, the same type, the contract signing date, and the random number can be freely combined in a random order. It should be understood that the format of the contract number is not limited to the above-mentioned department number + contract type + contract signing date + random number, and the order can be arranged in any order.

[0176] In summary, the present application provides a method for generating a contract number based on a contract text, which receives a request for generating a contract text, obtains key fields of a contract, generates a random number for a contract document, and forms a contract number based on the obtained key fields and the generated random number, and determines whether there is an identical contract number in the database. If so, a random number is regenerated for the contract, thereby recombining it into a new contract number. Otherwise, the contract number and its corresponding contract information are successfully saved to the database. This solves the problem of duplicate IDs in contract number generation and improves the efficiency of contract number generation and management.

[0177] In a second aspect, the present application provides a system for generating a contract number based on a contract text, which is applied to the aforementioned method for generating a contract number based on a contract text, and the system comprises:

[0178] A receiving module, used for obtaining a request for generating a contract text;

[0179] A generating module, used for obtaining key fields of the contract text according to the request;

[0180] The generating module is further used to obtain a first random number corresponding to the contract text according to the contract text;

[0181] A combining module, used for combining the key field and the first random number to obtain a first contract number of the contract text;

[0182] A judgment module, used for comparing the first contract number with the number pre-stored in the database to obtain a comparison result;

[0183] If the comparison result is a duplicate, regenerate a second random number according to the contract text, combine the second random number with the key field to obtain a second contract number, and store it in the database;

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

[0185] In a third aspect, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the aforementioned method when executing the computer program.

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

[0187] In a fifth aspect, the present application provides a computer program, which implements the steps of the aforementioned method when executed by a processor.

[0188] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database 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. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0189] The various embodiments in the present disclosure are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0190] The protection scope of the present disclosure is not limited to the above-mentioned embodiments. Obviously, those skilled in the art can make various changes and modifications to the present disclosure without departing from the scope and spirit of the present disclosure. If these changes and modifications fall within the scope of the claims of the present disclosure and their equivalents, the intention of the present disclosure also includes these changes and modifications.

Claims

1. A method for generating a contract number based on a contract text, characterized in that: include: Get a request for generating a contract text; According to the request, obtain key fields of the contract text; According to the contract text, obtaining a first random number corresponding to the contract text; Combining the key field and the first random number to obtain a first contract number of the contract text; Compare the first contract number with the number pre-stored in the database to obtain a comparison result; If the comparison result is a duplicate, regenerate a second random number according to the contract text, combine the second random number with the key field to obtain a second contract number, and store it in the database; If the comparison result is non-duplicate, the first contract number is stored in the database.

2. The method for generating a contract number based on a contract text according to claim 1, characterized in that: The step of obtaining the key fields of the contract text according to the request includes: Extracting features from the contract text to obtain keyword features; According to the keyword features, key fields are obtained, wherein the key fields at least include department, contract type and contract signing time.

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

4. The method for generating a contract number based on a contract text according to claim 3, characterized in that: If the current timestamp is less than the historical timestamp of the last generated sequence number, the step of setting the clock back comprises: If the clock dial-back time is greater than or equal to the preset time, and no sequence number is generated during the clock dial-back time period, the sequence number is postponed based on the last successful generation of the sequence number to obtain the first random number with the next sequence number; If the clock is dialed back for a period greater than or equal to a preset time, and a sequence number is generated within the time period of the clock being dialed back, an exception is thrown.

5. The method for generating a contract number based on a contract text according to claim 1, characterized in that: The step of combining the key field and the first random number to obtain the first contract number of the contract text includes: Determine the number of labels according to the pre-set combination order; Matching the tag with the key field to obtain the key field with the tag; The key field with the label and the first random number are combined to obtain a first contract number of the contract text.

6. The method for generating a contract number based on a contract text according to claim 2, characterized in that: If the comparison result is a duplicate, the step of regenerating a second random number according to the contract text, combining the second random number with the key field to obtain a second contract number, and storing the second contract number in the database includes: Obtaining a pre-stored number in the database that is repeated with the first contract number; According to the pre-stored number, traverse a number of numbers after the pre-stored number to obtain a first temporary comparison number group; Compare the second contract number with the first temporary comparison number group to obtain a 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 duplication, 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, and the third contract number is compared with the second temporary comparison number group, wherein the second temporary comparison number group represents a number that is repeated with the second contract number, and is formed by a combination of several subsequent numbers.

7. A contract number generation system based on contract text, characterized in that: The method for generating a contract number based on a contract text as applied to any one of claims 1 to 6, the system comprising: A receiving module, used for obtaining a request for generating a contract text; A generating module, used for obtaining key fields of the contract text according to the request; The generating module is further used to obtain a first random number corresponding to the contract text according to the contract text; A combining module, used for combining the key field and the first random number to obtain a first contract number of the contract text; A judgment module, used for comparing the first contract number with the number pre-stored in the database to obtain a comparison result; If the comparison result is a duplicate, regenerate a second random number according to the contract text, combine the second random number with the key field to obtain a second contract number, and store it in the database; If the comparison result is non-duplicate, the first contract number is stored in the database.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

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

10. A computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Watermark generating method and system based on contract

    CN106096340A

  • Contract data processing method and device, computer equipment and storage medium

    CN109816327A

  • File filtering storage method and device

    CN110109883A

  • Information extraction method based on semantic comprehension

    CN112528665A

  • Contract generation method and device, electronic equipment and readable storage medium

    CN113313540A

Cited By

  • Multidimensional attribute fusion contract number recommendation method and device, equipment and medium

    CN120429450A