Code generation method based on code strategy

By adopting a code generation method based on code strategy in the project management information system, the problems of code continuity and resource waste under high concurrency are solved, and the effective continuity and efficient utilization of code are achieved.

CN114781987BActive Publication Date: 2025-04-11XIAN FLIGHT SELF CONTROL INST OF AVIC +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111498707.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2025-04-11
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

In project management information systems, it is difficult for the prior art to ensure the natural number continuity of project codes under high concurrency, and code resources are wasted, especially when user operations are improper or system abnormalities.

Method used

The code generation method based on the code policy is adopted, and the corresponding code is generated by obtaining the business type information and the code generator, and state management is carried out in the code buffer pool to release unused codes to ensure continuity.

Benefits of technology

It ensures the natural number continuity of project codes in the project management information system, reduces the waste of code resources, and improves the effective utilization rate of codes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114781987B_ABST
    Figure CN114781987B_ABST
Patent Text Reader

Abstract

The present invention discloses a code generation method based on a code strategy, the method comprising: obtaining business type information, the business type information including a code strategy bound to the business type; obtaining a code generator according to the code strategy, and generating a corresponding code according to the code generator; saving the corresponding code, and triggering a code saving event at the same time, a preset code buffer pool synchronously supervising the state of the corresponding code; releasing the leased but unused codes in the corresponding codes to obtain codes in an idle state; in a form information interface for project creation, switching back and forth of the project business type will not cause the continuous regeneration of the project code. In the form information interface for project creation, switching back and forth of the responsible department will not cause the continuous regeneration of the project code. In the form information interface for project creation, after the code is generated, the creator chooses to terminate the project creation and closes the interface, which will not cause the code to be wasted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of project management, and in particular relates to a code generation method based on a code strategy. Background Art

[0002] In the field of project management, projects are generally named in the form of project abbreviations and project codes to simplify and improve project management efficiency, eliminate the ambiguity and inconvenience of using the text in the project name, and solve application problems in sorting, statistical analysis, etc.

[0003] The management of project codes generally has different management rules depending on different business models. Typical rules include: prefix + year + separator + natural number with fixed digits. The acquisition of natural numbers can generally be achieved by using self-developed algorithms and database primary key strategies, such as SQLServer Identity and Oracle Sequence.

[0004] SQLServer's Identity can obtain natural numbers separately through SQL statements, or it can be automatically generated when data is persisted. Oracle's Sequence can obtain natural numbers separately through SQL statements. Although the continuity of natural numbers can be guaranteed when data is persisted, there are two disadvantages. First, the behavior is lagging and cannot meet the actual use needs. The actual business requirements often require that the project code must be clearly given before data persistence. Second, the code rules are often not simple natural numbers, and complex rules are required to finally generate the code. Obtaining natural numbers separately through SQL statements lacks subsequent tracking, management, and maintenance after the natural numbers are generated, and the continuity of natural numbers cannot be guaranteed.

[0005] In the actual business process, project codes are generally managed by using certain rules + natural numbers. Although general code generators can ensure that natural numbers are continuous when generating codes, they cannot guarantee that the codes actually used are continuous when placed in an information management system with a B / S architecture. In a complex network environment, code rule management faces the following problems:

[0006] In high-concurrency situations, there may be code duplication problems; users repeatedly apply for codes, resulting in a waste of code resources and discontinuous actual valid codes; after applying for a code, users actively close the web page, exit the system, etc., resulting in the code not being actually used after application and wasted; after applying for a code, users close the browser, disconnect from the network, shut down the computer, turn off the power, etc., resulting in the code not being actually used after application and wasted. Summary of the invention

[0007] In order to solve the above-mentioned technical problems, the present invention aims to provide a code generation method based on a code strategy to ensure the natural number continuity of project codes effectively used in the information system.

[0008] In order to solve the technical problem, the technical solution of the present invention is:

[0009] A code generation method based on a code strategy, the method comprising:

[0010] Acquire service type information, wherein the service type information includes a code strategy bound to the service type;

[0011] According to the code strategy, a code generator is obtained, and a corresponding code is generated according to the code generator;

[0012] The corresponding code is saved, and a code saving event is triggered at the same time, and a preset code buffer pool synchronously monitors the status of the corresponding code;

[0013] The leased but unused codes among the corresponding codes are released to obtain codes in an idle state.

[0014] Project code (code for short): In the field of project management, projects are generally given project codes to facilitate memory and communication of projects, to simplify and improve project management efficiency, to eliminate ambiguity and inconvenience in the use of Chinese characters in project names, and to solve application problems in sorting, statistical analysis, etc.

[0015] Codename status: After the codename is generated, the status of the entire life cycle of the codename is defined, including idle state, leased state, and persistent state;

[0016] Code buffer pool: responsible for tracking and managing code status;

[0017] Code Generator: Different business types have different project code management rules, and each rule is encapsulated as a code generator. All code generators implement a unified code generator interface.

[0018] Code strategy: The binding relationship between the code generator and the business type is the code strategy, which can support dynamic modification of the code strategy used by the business type. Currently, it only supports a one-to-one binding relationship between the business type and the code generator.

[0019] Furthermore, the binding relationship between the service type information and the code generator is a code strategy.

[0020] Further, the method of generating a corresponding code according to the code generator includes:

[0021] Referring to the type of the code generator, an idle code is obtained from the code buffer pool, and the idle code is modified into a leased code.

[0022] Furthermore, the method of generating a corresponding code according to the code generator also includes:

[0023] If no free code is obtained, query the preset database for the maximum value of the persistent code that matches the type of the code generator;

[0024] According to the maximum value of the persistent code, the maximum value of the code cached in the code buffer pool is compared to obtain the starting point for batch generation of free codes;

[0025] According to the starting point of the idle code and the number of one-time initialization codes configured by the code generator, the code generation rule is called to generate new idle codes in batches.

[0026] The code buffer pool receives the new idle codes, encapsulates each of the new idle codes into a code state management object, and marks each of the new idle codes as an idle state.

[0027] Furthermore, the corresponding code is saved and a code saving event is triggered at the same time, and the preset code buffer pool synchronously monitors the state of the corresponding code, specifically including:

[0028] Obtaining the code state management object of the corresponding code from the code buffer pool; after confirming that the state of the corresponding code is a leased state, saving the corresponding code;

[0029] After marking the code state management object, the lease state of the corresponding code is converted into a persistent state to obtain a persistent state code;

[0030] Transfer the marked code state management object to the preset persistence area for management;

[0031] The persistent code is cleared.

[0032] Further, the release process includes: active release;

[0033] The active release: based on the repeated application of the code number by the operation webpage and the closing of the operation webpage, the leased but unused code number is actively released through a rest request and turned into an idle state.

[0034] Furthermore, the release process further includes: automatic release;

[0035] The automatic release: based on the information system logout, browser closing, network disconnection, computer shutdown and power outage, the leased but unused code is released and turned into an idle state.

[0036] Furthermore, the active release includes: repeated application release and webpage closing release;

[0037] The repeated application release comprises: judging whether there is an attached code parameter according to the parameters passed in by the rest request;

[0038] If it exists, access the code buffer pool according to the attached code parameter to obtain the code state management object; after marking the code state management object as idle, obtain the business type information, the business type information includes the code strategy bound to the business type; according to the code strategy, obtain the code generator, and generate the corresponding code according to the code generator;

[0039] If it does not exist, directly obtain the business type information, the business type information includes the code strategy bound to the business type; according to the code strategy, obtain the code generator, and generate the corresponding code according to the code generator;

[0040] The webpage closing and releasing comprises: based on the release code parameter returned by the webpage front end, accessing the code buffer pool, acquiring the code state management object, and marking the code state management object as an idle state.

[0041] Further, the automatic release specifically includes the following steps:

[0042] S1: Start by triggering;

[0043] S2: Obtain all code state management objects from the code buffer pool, filter out a set of all code state management objects in a leased state, and then obtain a code state management object from the set. If the acquisition fails, end the current automatic code release process;

[0044] S3: Calculate the lease start time recorded in the code state management object and the current time to obtain the duration of the code being in the lease state;

[0045] Compare the duration with a preset expiration time threshold, if it exceeds the threshold, perform expiration processing on the one expired code state management object, and return to step S2;

[0046] Otherwise, the process directly returns to step S2 to continue acquiring all code state management objects from the code buffer pool.

[0047] Further, the expiration processing includes:

[0048] The expired code state management object is marked as expired, and its code state is changed from a leased state to an idle state, allowing the code to be leased again.

[0049] Compared with the prior art, the code generation method based on the code strategy of the present invention has the following advantages:

[0050] 1. In the form information interface of project creation, switching back and forth between project business types will not cause the project code to be constantly regenerated. The principle is that we have a release process for the previous leased code during the switching process. When the business type is switched back, the continued leased code will reacquire the previously released code.

[0051] 2. In the form information interface of project creation, switching back and forth between responsible departments will not cause the project code to be constantly regenerated. The principle is the same as above.

[0052] 3. In the form information interface of project creation, after the code is generated, the creator chooses to terminate the project creation and closes the interface. This will not cause the code to be wasted, and another person will continue to use the code when creating a project.

[0053] 4. After the creator opens the form information interface for project creation and the code is generated, if he does not take any action until the session expires, or directly exits the system, closes the browser, shuts down the network, shuts down the computer, or other abnormal exit behaviors, the code will not be wasted from then on, and another person will continue to use the code when creating a project. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] Figure 1 , a code state transition diagram of the code generation method based on the code strategy of the present invention;

[0055] Figure 2 , the main algorithm flow chart of the code generation method based on the code strategy of the present invention;

[0056] Figure 3 , a flowchart of leasing codes of a code generation method based on a code strategy of the present invention;

[0057] Figure 4 , a detailed flow chart of code generation of the code generation method based on the code strategy of the present invention;

[0058] Figure 5 , a detailed flow chart of saving codes of the code generation method based on the code strategy of the present invention;

[0059] Figure 6 , a detailed flow chart of releasing codes of the code generation method based on the code strategy of the present invention;

[0060] Figure 7 , a detailed flow chart of the active release of codes in the code generation method based on the code strategy of the present invention;

[0061] Figure 8 , a detailed flow chart of the code release of repeated application of the code generation method based on the code strategy of the present invention;

[0062] Fig. 9 , a detailed flow chart of releasing the web page closing code according to the code generation method based on the code strategy of the present invention;

[0063] Fig.10 , a detailed flow chart of the automatic release of codes in the code generation method based on the code strategy of the present invention. DETAILED DESCRIPTION

[0064] The specific implementation mode of the present invention is described below in conjunction with embodiments:

[0065] It should be noted that the structures, proportions, sizes, etc. shown in this specification are only used to match the contents disclosed in the specification so that people familiar with this technology can understand and read them, and are not used to limit the conditions under which the present invention can be implemented. Any structural modification, change in proportional relationship or adjustment of size should still fall within the scope of the technical content disclosed in the present invention without affecting the effects and purposes that can be achieved by the present invention.

[0066] At the same time, the terms such as "upper", "lower", "left", "right", "middle" and "one" cited in this specification are only for the convenience of description and are not used to limit the scope of implementation of the present invention. Changes or adjustments to their relative relationships should be regarded as the scope of implementation of the present invention without substantially changing the technical content.

[0067] Embodiment 1:

[0068] like Figure 1 As shown, a code generation method based on a code strategy comprises:

[0069] Acquire service type information, wherein the service type information includes a code strategy bound to the service type;

[0070] According to the code strategy, a code generator is obtained, and a corresponding code is generated according to the code generator;

[0071] The corresponding code is saved, and a code saving event is triggered at the same time, and a preset code buffer pool synchronously monitors the status of the corresponding code;

[0072] The leased but unused codes among the corresponding codes are released to obtain codes in an idle state.

[0073] Project code (code for short): In the field of project management, projects are generally given project codes to facilitate memory and communication of projects, to simplify and improve project management efficiency, to eliminate ambiguity and inconvenience in the use of Chinese characters in project names, and to solve application problems in sorting, statistical analysis, etc.

[0074] Codename status: After the codename is generated, the status of the entire life cycle of the codename is defined, including idle state, leased state, and persistent state;

[0075] Code buffer pool: responsible for tracking and managing code status;

[0076] Code Generator: Different business types have different project code management rules, and each rule is encapsulated as a code generator. All code generators implement a unified code generator interface.

[0077] Code strategy: The binding relationship between the code generator and the business type is the code strategy, which can support dynamic modification of the code strategy used by the business type. Currently, it only supports a one-to-one binding relationship between the business type and the code generator.

[0078] The binding relationship between the service type information and the code generator is a code strategy.

[0079] The method for generating a corresponding code according to a code generator comprises:

[0080] Referring to the type of the code generator, an idle code is obtained from the code buffer pool, and the idle code is modified into a leased code.

[0081] The method of generating a corresponding code according to the code generator also includes:

[0082] If no free code is obtained, query the preset database for the maximum value of the persistent code that matches the type of the code generator;

[0083] According to the maximum value of the persistent code, the maximum value of the code cached in the code buffer pool is compared to obtain the starting point for batch generation of free codes;

[0084] According to the starting point of the idle code and the number of one-time initialization codes configured by the code generator, the code generation rule is called to generate new idle codes in batches.

[0085] The code buffer pool receives the new idle codes, encapsulates each of the new idle codes into a code state management object, and marks each of the new idle codes as an idle state.

[0086] The storing of the corresponding code and triggering of a code saving event at the same time, wherein the preset code buffer pool synchronously monitors the state of the corresponding code, specifically includes:

[0087] Obtaining the code state management object of the corresponding code from the code buffer pool; after confirming that the state of the corresponding code is a leased state, saving the corresponding code;

[0088] After marking the code state management object, the lease state of the corresponding code is converted into a persistent state to obtain a persistent state code;

[0089] Transfer the marked code state management object to the preset persistence area for management;

[0090] The persistent code is cleared.

[0091] The release process includes: active release;

[0092] The active release: based on the repeated application of the code number by the operation webpage and the closing of the operation webpage, the leased but unused code number is actively released through a rest request and turned into an idle state.

[0093] The release process further includes: automatic release;

[0094] The automatic release: based on the information system logout, browser closing, network disconnection, computer shutdown and power outage, the leased but unused code is released and turned into an idle state.

[0095] The active release includes: repeated application release and web page closing release;

[0096] The repeated application release comprises: judging whether there is an attached code parameter according to the parameters passed in by the rest request;

[0097] If it exists, access the code buffer pool according to the attached code parameter to obtain the code state management object; after marking the code state management object as idle, obtain the business type information, the business type information includes the code strategy bound to the business type; according to the code strategy, obtain the code generator, and generate the corresponding code according to the code generator;

[0098] If it does not exist, directly obtain the business type information, the business type information includes the code strategy bound to the business type; according to the code strategy, obtain the code generator, and generate the corresponding code according to the code generator;

[0099] The webpage closing and releasing comprises: based on the release code parameter returned by the webpage front end, accessing the code buffer pool, acquiring the code state management object, and marking the code state management object as an idle state.

[0100] The automatic release specifically comprises the following steps:

[0101] S1: Start by triggering;

[0102] S2: Obtain all code state management objects from the code buffer pool, filter out a set of all code state management objects in a leased state, and then obtain a code state management object from the set. If the acquisition fails, end the current automatic code release process;

[0103] S3: Calculate the lease start time recorded in the code state management object and the current time to obtain the duration of the code being in the lease state;

[0104] Compare the duration with a preset expiration time threshold, if it exceeds the threshold, perform expiration processing on the one expired code state management object, and return to step S2;

[0105] Otherwise, the process directly returns to step S2 to continue acquiring all code state management objects from the code buffer pool.

[0106] The expiration processing includes:

[0107] The expired code state management object is marked as expired, and its code state is changed from a leased state to an idle state, allowing the code to be leased again.

[0108] Embodiment 2:

[0109] The second embodiment is applied to the code generation method based on the code strategy of the first embodiment, and specifically includes:

[0110] The key concepts include project code (code for short), code status, code buffer pool, code generator, and code strategy. The detailed explanations are as follows:

[0111] Project code (code for short): In the field of project management, projects are generally given project codes to facilitate memory and communication of projects, to simplify and improve project management efficiency, to eliminate ambiguity and inconvenience in the use of Chinese characters in project names, and to solve application problems in sorting, statistical analysis, etc.

[0112] Codename status: After the codename is generated, the status of the entire life cycle of the codename is defined, including idle state, leased state, and persistent state. The state diagram is as follows Figure 1 As shown:

[0113] Code buffer pool: responsible for tracking and managing code status.

[0114] Code Generator: Different business types have different project code management rules, and each rule is encapsulated as a code generator. All code generators implement a unified code generator interface.

[0115] Code strategy: The binding relationship between the code generator and the business type is the code strategy, which can support dynamic modification of the code strategy used by the business type. Currently, it only supports a one-to-one binding relationship between the business type and the code generator.

[0116] Detailed steps of this embodiment:

[0117] The main flow of the code generation algorithm based on the code strategy to ensure code continuity in this embodiment is as follows: Figure 2 As shown:

[0118] A code generation algorithm based on a code strategy to ensure code continuity includes the following steps:

[0119] 1. Rent a code

[0120] The user side provides business type information and obtains the project code through REST request

[0121] 2. Save the code

[0122] When the user saves the project information, the code save event is triggered synchronously, and the code buffer pool synchronously maintains the code status.

[0123] 3. Release code

[0124] Release the leased but unused code and turn it into an idle state for reuse.

[0125] Among them, 1. The detailed process of renting a code is as follows Figure 3 As shown:

[0126] 1.1 Obtaining business type

[0127] According to the business type passed by the user, detailed information related to the business type is obtained, including the code strategy bound to the business type.

[0128] 1.2 Get the code generator

[0129] According to the code strategy obtained in 1.1, get the instance object of the code generator.

[0130] 1.3 Code generation

[0131] The code is generated according to the code generator, and different code generators implement different code management rules. In order to solve the problem of code duplication in a concurrent environment, the entire code generation process adopts a thread-safe code implementation method.

[0132] Among them, 1.3, the detailed process of code generation is as follows Figure 4 As shown:

[0133] 1.3.1 Get free codes from the code buffer pool

[0134] Find the idle code from the code buffer pool, take the code with the smallest natural number, modify the code to the leased state after finding it, and record the lease start time. The code is successfully obtained. If there is no idle code, the acquisition fails.

[0135] 1.3.2 Query the code status in the database

[0136] According to the code rule, query the database for the maximum value of the code that matches the rule.

[0137] 1.3.3 Batch generate idle codes

[0138] Based on the maximum value of the code that has been persisted in the database and the maximum value of the code that has been cached in the code buffer pool, the starting point for batch generation of idle codes is determined. Then, based on the number of one-time initialization codes configured by the code generator, the code generation rules are called to generate idle codes in batches.

[0139] 1.3.4 Code stored in the buffer pool

[0140] The code buffer pool receives all codes, encapsulates a code state management object for each code, marks it as idle, and returns to step 1.3.1 to re-acquire the code.

[0141] Among them, 2. The detailed process of saving the code is as follows Figure 5 As shown:

[0142] 2.1 Get the code state management object from the code buffer pool

[0143] According to the passed in code, the corresponding code state management object is searched in the code buffer pool, and the code state must be in the leased state before the save action can be performed.

[0144] 2.2 Marking the code that has been persisted

[0145] According to the code state management object obtained in 2.1, the code state is marked, the lease state is changed to a persistent state, and the code state management object is transferred to the persistent area for management.

[0146] 2.3 Clear the persistent code

[0147] According to the code clearing configuration strategy, clear the persisted area data.

[0148] Among them, 3. The detailed process of releasing the code is as follows Figure 6 As shown:

[0149] 3.1 Actively release code

[0150] In the case of repeated code application on the operation webpage or closing the operation webpage, the leased code can be actively released through the REST request. The leased but unused code is released and turned into an idle state, which can be used continuously.

[0151] 3.2 Automatic release code

[0152] The system will automatically release the code when you log out of the information system, close the browser, disconnect from the network, shut down the computer, or when there is a power outage.

[0153] Among them, 3.1, the detailed process of actively releasing the code is as follows Figure 7 As shown:

[0154] 3.1.1 Repeated application for code release

[0155] The reason for repeatedly applying for code names is that the rest request for code name application is linked to the form data on the web page. Whenever the business type changes, or other determinants of the code name generation rules change, it is necessary to re-initiate the code name application to obtain the code name under the new code name rules. For example, when the business type changes from model development to pre-research type, it is necessary to re-apply for the pre-research type code name; or when the responsible department of the business type changes, the code name rules also need to be switched to the code name rules used by the relevant responsible department, and the code name application needs to be re-initiated under the new rules. Therefore, in the front-end web page interface for applying for a code name, each time a code name application is initiated, a code name that is no longer in use is attached.

[0156] 3.1.2 Web page closing code release

[0157] When the webpage is closed, the front-end interface can capture the relevant events. In the event processing of the webpage closing, a code release processing request is sent to the back-end to request code release.

[0158] Among them, 3.1.1, the detailed process of repeatedly applying for code release is as follows Figure 8 As shown:

[0159] 3.1.1.1 Obtaining the accompanying code

[0160] According to the input parameters, determine whether there is an attached code parameter. If so, continue to execute step 3.1.1.2. If not, return to step 1 to execute the normal code rental process.

[0161] 3.1.1.2 Get the code state management object from the code buffer pool

[0162] According to the attached code parameter, access the code buffer pool and obtain the code status management object.

[0163] 3.1.1.3 Marking released codes

[0164] Mark the code status management object obtained in 3.1.1.2 as idle.

[0165] Among them, 3.1.2, the detailed process of releasing the web page closing code is as follows Fig. 9 As shown:

[0166] 3.1.2.1 Get the code state management object from the code buffer pool

[0167] According to the release code parameter returned by the web page front end, access the code buffer pool and obtain the code status management object.

[0168] 3.1.2.2 Marking released codes

[0169] Mark the code status management object obtained in 3.1.2.1 as idle.

[0170] Among them, the detailed process of 3.2, automatic release code is as follows Fig.10 As shown:

[0171] 3.2.1 Triggering automatic code release

[0172] Automatic code release is started by triggering, supporting multiple triggering methods, mainly including event triggering and periodic task triggering, which can be set by configuration. Event triggering is triggered when the free codes in the code buffer pool are exhausted and before the code generator generates new codes in batches. Periodic tasks can be set by configuration to set the regular start time.

[0173] 3.2.2 Get the next lease status code

[0174] Get all code state management objects from the code buffer pool, filter out all code state management object sets in the leased state, and then get a code state management object from the set. If it exists, go to step 3.1.3. If it does not exist, end this automatic code release process.

[0175] 3.2.3 Code expiration judgment

[0176] Calculate the lease start time recorded in the code status management object obtained in step 3.2.2 with the current system time to obtain the duration of the code in the leased state. Compare the duration with the expiration time threshold configured by the system. If it exceeds the threshold, proceed to step 3.2.4 for expiration processing. Otherwise, skip the current code and continue to step 3.2.2.

[0177] 3.2.4 Marking expired codes

[0178] The code state management object determined to be expired in 3.2.3 is marked as expired, and its code state is changed from leased state to idle state, allowing the code to be leased again.

[0179] Embodiment three:

[0180] In this solution, the life cycle management of the code state is achieved through the code buffer pool. The code buffer pool has two functions: one is the task of caching codes, and the other is the task of managing the entire life cycle of codes. The alternative solution can further subdivide the code buffer pool into two components: the code buffer pool and the code life cycle manager.

[0181] The present invention is applied to a project management information system, and there are three steps as follows:

[0182] Code generator implementation for business type:

[0183] In the embodiment, the business types include innovative business, external cooperation business, and pre-research business, and the code management rules required for each business type are different. Based on our invention, different business rules are implemented by different code generators, but all these implementations must implement the unified generator interface IProjectCoder designed by us. The implemented code generator CXProjectCoder takes the code management rules of innovative business as a template, and its management rules are department code + year + classification + two-digit natural number.

[0184] Code strategy configuration for business types:

[0185] In order to adapt to the ever-changing code rules in the actual business management process, we adopt the method of setting code strategies for business types for management. For example, if the external cooperation business does not have its own code management rules at present and wants to borrow the management model of innovative business, we can set the code strategy of the external cooperation business to CXProjectCoder. Perhaps in the near future, the external cooperation business will have its own management ideas and generate new code management rules. We can develop a new code generator HZProjectCoder and implement the IProjectCoder interface, and then configure the code strategy of the external cooperation business to HZProjectCoder.

[0186] In the form information interface of project creation, the automatic code is generated after selecting the business type:

[0187] In project management information systems, the foundation of management

[0188] This is the process of project creation. When creating a project, the creator needs to provide basic information about the project, including project name, project leader, project funding, project cycle, project business type, project supervisory department, project code, etc. The project code is automatically generated by the system based on the project business type, project supervisory department, etc. entered by the creator in the form.

[0189] It can be understood that in the form information interface for project creation, switching back and forth between project business types will not lead to the continuous regeneration of project codes. The principle is that we have the release process of the previous leased code during the switching process. When the business type is switched back, continuing to lease the code will reacquire the previously released code. In the form information interface for project creation, switching back and forth between responsible departments will not lead to the continuous regeneration of project codes. The principle is the same as above. In the form information interface for project creation, after the code is generated, the creator chooses to terminate the project creation and closes the interface, which will not cause the code to be wasted, and another person will continue to use the code when creating a project. After the creator opens the form information interface for project creation and the code is generated, he will not operate until the session expires, or directly exits the system, closes the browser, shuts down the network, shuts down the computer, and other abnormal exit behaviors, which will not cause the code to be wasted from then on, and another person will continue to use the code when creating a project.

[0190] The preferred embodiments of the present invention are described in detail above, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.

[0191] Many other changes and modifications may be made without departing from the concept and scope of the present invention.It should be understood that the present invention is not limited to the specific embodiments, and the scope of the present invention is defined by the appended claims.

Claims

1. A code generation method based on a code strategy, characterized in that: The method comprises: Acquire service type information, wherein the service type information includes a code strategy bound to the service type; According to the code strategy, a code generator is obtained, and a corresponding code is generated according to the code generator; The corresponding code is saved, and a code saving event is triggered at the same time, and a preset code buffer pool synchronously monitors the status of the corresponding code; Releasing the leased but unused codes among the corresponding codes to obtain codes in an idle state; The release process includes: active release; The active release: based on the repeated application of the code on the operation webpage and the closing of the operation webpage, the leased but unused code is actively released through a rest request and turned into an idle state; The release process further includes: automatic release; The automatic release: based on the information system logout, browser closing, network disconnection, computer shutdown and power outage, the leased but unused code is released and turned into an idle state; The automatic release specifically comprises the following steps: S1: Start by triggering; S2: Obtain all code state management objects from the code buffer pool, filter out a set of all code state management objects in a leased state, and then obtain a code state management object from the set. If the acquisition fails, end the current automatic code release process; S3: Calculate the lease start time recorded in the code state management object and the current time to obtain the duration of the code being in the lease state; Compare the duration with a preset expiration time threshold, if it exceeds the threshold, perform expiration processing on an expired code state management object, and return to step S2; Otherwise, the process directly returns to step S2 to continue acquiring all code state management objects from the code buffer pool.

2. The code generation method based on code strategy according to claim 1, characterized in that: The binding relationship between the service type information and the code generator is a code strategy.

3. The code generation method based on code strategy according to claim 1, characterized in that: The method for generating a corresponding code according to the code generator comprises: Referring to the type of the code generator, an idle code is obtained from the code buffer pool, and the idle code is modified into a leased code.

4. The code generation method based on code strategy according to claim 3, characterized in that: The method of generating a corresponding code according to the code generator also includes: If no free code is obtained, query the preset database for the maximum value of the persistent code that matches the type of the code generator; According to the maximum value of the persistent code, the maximum value of the code cached in the code buffer pool is compared to obtain the starting point for batch generation of free codes; According to the starting point of the idle code and the number of one-time initialization codes configured by the code generator, the code generation rule is called to generate new idle codes in batches; The code buffer pool receives the new idle codes, encapsulates each of the new idle codes into a code state management object, and marks each of the new idle codes as an idle state.

5. The code generation method based on code strategy according to claim 1, characterized in that: Said The corresponding code is saved, and a code saving event is triggered at the same time. The preset code buffer pool synchronously monitors the status of the corresponding code, specifically including: Obtaining the code state management object of the corresponding code from the code buffer pool; after confirming that the state of the corresponding code is a leased state, saving the corresponding code; after marking the code state management object with a code state, converting the leased state of the corresponding code into a persistent state, and obtaining a code in a persistent state; Transfer the marked code state management object to the preset persistence area for management; The code of the persistent state is cleared.

6. The code generation method based on code strategy according to claim 1, characterized in that: The active release includes: repeated application release and web page closing release; The repeated application release comprises: judging whether there is an attached code parameter according to the parameters passed in by the rest request; If it exists, access the code buffer pool according to the attached code parameter to obtain the code state management object; after marking the code state management object as idle, obtain the business type information, the business type information includes the code strategy bound to the business type; according to the code strategy, obtain the code generator, and generate the corresponding code according to the code generator; If it does not exist, directly obtain the business type information, the business type information includes the code strategy bound to the business type; according to the code strategy, obtain the code generator, and generate the corresponding code according to the code generator; The webpage closing and releasing comprises: based on the release code parameter returned by the webpage front end, accessing the code buffer pool, acquiring the code state management object, and marking the code state management object as an idle state.

7. The code generation method based on code strategy according to claim 1, characterized in that: The expiration processing includes: The expired code state management object is marked as expired, and its code state is changed from a leased state to an idle state, allowing the code to be leased again.

Citation Information

Patent Citations

  • Method and device for workflow data persistence

    CN103425462A

  • Method, device, and system for resource allocation

    CN104205967A