Method and device for generating line codes

By obtaining the machine time and application layer date in the server and selecting the appropriate serial number generation strategy, the line encoding generation problem of the prior art under the requirements of high concurrency and real-time is solved, and high-performance and unique line encoding generation is achieved.

CN120450408APending Publication Date: 2025-08-08BEIJING JINGDONG YUANSHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510583405.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-07
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

The existing line encoding generation technology is difficult to meet high performance requirements in dynamic line recommendation scenarios with high concurrency and real-time requirements, especially in distributed systems, where there are duplication probability and coding length constraints.

Method used

By receiving line number generation requests, obtain the server's machine time and the current date recorded by the application layer, select different serial number generation strategies based on date comparison, generate line encoding, and update the prefix sequence number and date during system initialization, failure recovery or date switching to ensure the uniqueness and validity of the encoding.

Benefits of technology

Without breaking the encoding generation rules, the reliability and performance of the system are improved, adapted to a high concurrency environment, and realized the intelligence and automation of line encoding generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120450408A_ABST
    Figure CN120450408A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a device for generating a line code, and relates to the technical field of computers. A specific embodiment of the method comprises the following steps: receiving a line number generation request, obtaining a first current date of a server, and obtaining a second current date recorded by an application layer for the server; responding to the condition that the first current date is earlier than or equal to the second current date, using a preset first serial number generation strategy to obtain a serial number; in response to the fact that the first current date is later than the second current date, using a preset second serial number generation strategy to obtain a serial number, and updating the second current date and a prefix serial number recorded by the application layer for the server; and according to a preset service prefix, the second current date, the prefix serial number and the serial number, generating a line code and returning the line code. According to the embodiment, the requirements of high concurrency and high performance in a supply chain dynamic optimization scene can be met, and intelligentization and automation of line code generation are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating line coding. Background Art

[0002] In supply chain management, route codes are a core abstraction used to uniquely identify routes within a logistics network. Current route code generation schemes focus on generating unique suffixes (purely numeric suffixes), primarily employing two approaches: incremental ID generation based on a database and distributed ID generation. The former suffers from poor performance and concurrency support, while the latter suffers from duplication in high-concurrency scenarios and imposes constraints on code length. These shortcomings are particularly pronounced in dynamic route recommendation scenarios, which require high concurrency and real-time performance, requirements that existing technologies struggle to meet. Summary of the Invention

[0003] In view of this, embodiments of the present invention provide a method and apparatus for generating line codes, which can at least solve the problem that the existing technology is difficult to meet the high concurrency and real-time requirements in the dynamic line recommendation scenario.

[0004] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for generating line code is provided, comprising:

[0005] receiving a line number generation request, obtaining a first current date of the server, and obtaining a second current date recorded by the application layer for the server; wherein the first current date is the machine time, and the second current date is the time obtained by processing one or more of system initialization, fault recovery, and date switching;

[0006] In response to the first current date being earlier than or equal to the second current date, obtaining a serial number using a preset first serial number generation strategy;

[0007] In response to the first current date being later than the second current date, obtaining a serial number using a preset second serial number generation strategy, and updating the second current date and prefix serial number recorded by the application layer for the server;

[0008] Generates and returns a line code based on the preset service prefix, second current date, prefix sequence number, and sequence number.

[0009] To achieve the above object, according to another aspect of an embodiment of the present invention, a device for generating line code is provided, comprising:

[0010] a receiving module, configured to receive a line number generation request, obtain a first current date from the server, and obtain a second current date recorded by the application layer for the server; wherein the first current date is the machine time, and the second current date is a time obtained by processing one or more of system initialization, fault recovery, and date switching;

[0011] A serial number generating module, configured to obtain a serial number using a preset first serial number generating strategy in response to the first current date being earlier than or equal to the second current date;

[0012] In response to the first current date being later than the second current date, obtaining a serial number using a preset second serial number generation strategy, and updating the second current date and prefix serial number recorded by the application layer for the server;

[0013] The line code generation module is used to generate and return a line code according to a preset service prefix, a second current date, a prefix sequence number and a sequence number.

[0014] To achieve the above objective, according to another aspect of an embodiment of the present invention, an electronic device for generating line coding is provided.

[0015] An electronic device according to an embodiment of the present invention includes: one or more processors; and a storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement any of the above-described methods for generating line coding.

[0016] To achieve the above object, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, any of the above methods for generating line codes is implemented.

[0017] To achieve the above object, according to another aspect of an embodiment of the present invention, a computer program product is provided. The computer program product of an embodiment of the present invention includes a computer program, which, when executed by a processor, implements the method for generating line coding provided in an embodiment of the present invention.

[0018] According to the solution provided by the present invention, one embodiment of the aforementioned invention has the following advantages or beneficial effects: Without violating the constraints of line code generation rules, a line code generation solution is proposed that adapts to the high concurrency and high performance requirements of dynamic supply chain optimization scenarios. By comparing machine time with the time recorded by the application layer for the server, different sequence number generation strategies can be flexibly selected to ensure the uniqueness and validity of the generated line code. This design significantly improves system reliability and performance, meets the requirements of high-concurrency environments, and realizes intelligent and automated line code generation.

[0019] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The accompanying drawings are provided for a better understanding of the present invention and are not intended to limit the present invention.

[0021] FIG1( a ) is a schematic diagram of existing line code generation rules;

[0022] FIG1( b ) is a schematic diagram of an existing scheme for line coding generation;

[0023] Figure 2(a) is the architecture diagram of this solution;

[0024] Figure 2(b) is a schematic diagram of the data layer design;

[0025] Figure 3 A schematic diagram of the main flow of a method for generating line code according to an embodiment of the present invention;

[0026] Figure 4 It is a schematic diagram of the external service process designed by the application layer;

[0027] Figure 5 is a flow chart of an optional method for generating line code according to an embodiment of the present invention;

[0028] Figure 6 It is a schematic diagram of the application layer design initialization and fault recovery process;

[0029] Figure 7 is a flowchart of another optional method for generating line code according to an embodiment of the present invention;

[0030] Figure 8(a) shows the initialization process executed concurrently by two servers A and B;

[0031] FIG8( b ) is a flow chart showing the process of concurrently executing initialization and updating database table records by two servers A and B;

[0032] Figure 9 1 is a schematic diagram of main modules of a device for generating line code according to an embodiment of the present invention;

[0033] Figure 10 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;

[0034] Figure 11 It is a schematic diagram of the structure of a computer system of a mobile device or server suitable for implementing the embodiments of the present invention. DETAILED DESCRIPTION

[0035] The following description of exemplary embodiments of the present invention is made in conjunction with the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding. These details should be considered as merely exemplary. Therefore, it should be appreciated by those skilled in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0036] It should be noted that the collection, collection, updating, analysis, processing, use, transmission, and storage of user personal information involved in the technical solutions disclosed herein all comply with relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken with respect to user personal information to prevent unauthorized access to user personal information data and to safeguard the security of user personal information, network security, and national security.

[0037] In the field of supply chain management, the logistics network is fundamental. The two core abstractions of the network are points and lines, with lines representing routes. Routes, as fundamental data for planning and optimization, underlie supply chain planning, scheduling, and contract execution. They directly map to physical factors and supply chain management processes, so the scale of this fundamental data is theoretically limited. Taking logistics as an example, the mapping relationship for routes is "originating point - destination point - departure time - transportation method - active / inactive state." Assuming a logistics system with 200 routes, three daily departures from each route, and three modes of transportation (land / rail / air), the theoretical maximum number of routes is 720,000 (200 * 200 * 3 * 3 * 2 = 720,000). In the era of heavily manual operations, the logistics network in the systems used by supply chain management service providers is relatively fixed (with low-frequency changes), and route data is also relatively stable.

[0038] As one of the core abstractions of supply chain management, routes are technically uniquely identified through route codes. The route code design ensures uniqueness while also taking into account readability for planners. It consists of an 18-bit code, 11 of which are used to enhance operational readability. The generation rules are shown in Figure 1(a). It should be noted that the bits here represent readable characters, not binary bits. Even ignoring the 8-bit infix used for planning dates, the final 7-bit suffix can still provide tens of millions of unique codes. The current route code generation rules can theoretically guarantee normal use for thousands of years, given the tens of millions of routes generated daily.

[0039] Current line code generation technology designs focus on generating a unique 7-bit suffix (a pure numeric suffix). There are two main implementation methods, as shown in Figure 1(b):

[0040] 1. Incremental ID generation based on the database suffers from poor performance and concurrency support. Using a single database to ensure uniqueness requires a database access (read and update) for each ID generation, as updates require locking the record. For example, the MySQL database has a 10ms SLA (Service Level Agreement) for a single data access, limiting concurrent access to 100 TPS (Transactions Per Second). Each request involves a database access, resulting in poor performance.

[0041] Here's an explanation of "locking records": Database locking is a common technique. For example, MySQL is a row-based database, where data is stored as a single atomic unit. Therefore, locking a record is called row locking. The purpose of locking is to prevent conflicts when multiple data accesses occur simultaneously.

[0042] 2. Distributed ID generation based on the snowflake algorithm. The snowflake algorithm relies on the server's machine clock, which has a certain probability of duplication. This probability increases significantly in high-concurrency scenarios. Furthermore, the snowflake algorithm imposes constraints on code length. In complex supply chain management systems, the impact of changes to fundamental data like line codes (such as altering the line code generation rules) is difficult to fully assess. Even if a perfect assessment were achieved, the cost of implementing the changes would be substantial.

[0043] Perfect assessment: Any change to an already running system requires an impact assessment. In the monolithic system stage, change assessment is simple and controllable, and a perfect assessment (such as exhaustively enumerating all impact areas) can be achieved. However, as systems evolve, such as distributed systems and large e-commerce systems (tens of thousands of applications), exhaustively enumerating all impact areas is practically impossible.

[0044] In summary, the two current technical solutions work well in applications involving static, pre-planned routes and subsequent, low-frequency adjustments. However, dynamic optimization is a perennial theme in supply chain management. In dynamic route recommendation scenarios, frequent route adjustments are made based on real-time analysis of data from the entire logistics network. These adjustments place stringent real-time requirements and typically involve high-concurrency access. Existing route code generation technologies are no longer well-suited for this application.

[0045] The design architecture of this solution is shown in Figure 2(a). It is divided into two parts: the data layer (e.g., DB, full name Database) and the application layer.

[0046] 1. Data Layer Design Description. The data layer is designed as a single point: single database, single table, single row record. The data table consists of four fields: date (t_date), prefix sequence length (t_len), prefix sequence value (t_seq), and version number (t_version), as shown in Figure 2(b).

[0047] 1. Date t_date: Stores the latest date of the application service cluster in the current application layer. For example, if the application layer has 10 machines deployed, the system time differences and errors among these 10 machines may vary. Therefore, near midnight, the machine dates of different application servers may differ by one day. This solution uses the maximum date (or the latest date) among the 10 machines. The date field is used for date switching, which has two functions: resetting the prefix sequence value (required) and adjusting the prefix sequence length (manual decision-making, only used in large-scale scaling scenarios of distributed application layer services).

[0048] 2. Prefix sequence length (t_len): Integer value, the specific value of which is constrained by two factors: the encoding length and the number of servers in the distributed cluster. The number of servers in the distributed cluster is also constrained by the encoding length. For example, if the number of servers exceeds 10 编码长度 The value of this field also constrains the range of the prefix number value. Assuming the number of services (one service per server by default) is 20, the prefix number length must be greater than or equal to 2. In theory, a prefix number length of 2 is sufficient. With a prefix number of 2, there are 100 different prefix number values. In a scenario with 20 machines, 80 machine failure restarts per day are supported, but this is extremely unlikely to occur in real production scenarios.

[0049] It's important to note that this length theoretically doesn't result in a significant loss of encoding range; it may only increase database access times. The prefix number shares a 7-bit encoding length with the application server's sequence number. A longer prefix reduces the range of possible sequence values. After a single server service is used up, the prefix number value must be retrieved again, and each retrieval requires a database access.

[0050] In addition, the effectiveness of the prefix number length adjustment in this solution is set in the date switching scenario to ensure that the uniqueness of the code is not destroyed. The logic of updating the prefix number length is set in both the initialization process and the date switching process of external services. This means that even if the number of servers in the application layer needs to be adjusted, such as changing from 100 to 101, it is necessary to wait until the next day. By setting it in the date switching scenario, the scale of the distributed service cluster can be essentially solved. When the scale of the application layer service cluster is fixed (for example, 10 machines are fixed), the prefix number length (t_len) is unchanged and only needs to be increased when more servers are needed.

[0051] 3. Prefix sequence value (t_seq): This field starts at 0 and increases by 1 after each allocation. The upper limit is 10. t _len -1. From the perspective of a single application service, sequence number generation relies solely on this field: the prefix sequence value and the sequence number sequence form the 7-bit suffix of the line code. From the perspective of the application service peer cluster, each service requires a unique value. Because the value changes (increments by 1) after each allocation, the value obtained by each service is guaranteed to be unique.

[0052] 4. Version number (t_version): The version number is a non-essential field. It is only because the concurrent access to the database in the design of the present invention has a low probability of conflict, so it is suitable for the optimistic locking design. For details, see Figure 7 shown.

[0053] 2. The application layer is designed as a distributed service with good scalability to provide better support for concurrent access. The number of services that the application service scales is adapted to the prefix sequence length (t_len) of the database table record. Ideally, the number of servers should be equal to 10 t_len -1, but considering that server failure is inevitable (low probability event, but unavoidable), the prefix sequence number length (t_len) should be guaranteed to be 10 t_len -1 is greater than the number of servers, providing room for failure recovery after service restart. This mutual constraint is determined based on the current status of different application servers.

[0054] The application layer defines four core attributes for the server: current date (currentDate), prefix length (prefixLength), prefix sequence number (prefix), and sequence number (sequence). Except for the sequence number, the other three attributes correspond to the database table record: date t_date, prefix length (t_len), and prefix sequence number value (t_seq).

[0055] 1. Current Date (currentDate): This field is used as an 8-bit infix code for generating the date. It is also required for logical processing during date switching. It should be noted that the current date (currentDate) is set by the application layer for the server. It is not the server's machine time. Instead, it reflects the time that changes automatically after system initialization and fault recovery, as well as after date switching.

[0056] 2. Prefix Length: This field is used to constrain the generation boundary of the sequence number. The server can generate up to 10 prefixes per day if the prefix sequence number remains unchanged. 7-prefixLength -1 different code, usually prefixLength = t_len, so the number of codes can also be considered as 10 7-t_len -1. This field is also used to format the prefix sequence number and serial number. For example, if the prefix sequence length is 2, if the prefix sequence number is 1 and the serial number is 1, the final generated prefix sequence number is 01 and the serial number is 00001, that is, the final encoded suffix is 0100001.

[0057] It's important to note that in this solution, the server will cease service after the serial number is exhausted each day. This design assumes that serial number exhaustion will not occur in the current usage scenario. If serial number exhaustion is highly likely, you can obtain a new prefix serial number and reset the serial number, just as in fault recovery.

[0058] 3. Prefix serial number (prefix): The serial number prefix used to ensure distributed uniqueness, obtained from the database in initialization / failure recovery / date switching scenarios.

[0059] 4. Sequence number: A single-server incrementing sequence number that increments by 1 each time. This only requires atomic increments on a single server. The date and prefix sequence number assignment ensures uniqueness across servers, and atomic increments ensure uniqueness across multiple calls to a single service.

[0060] See also Figure 3 , which shows a main flow chart of a method for generating line code provided by an embodiment of the present invention, including the following steps:

[0061] S301: Receive a line number generation request, obtain a first current date of the server, and obtain a second current date recorded by the application layer for the server; wherein the first current date is the machine time, and the second current date is the time obtained by processing one or more of system initialization, fault recovery, and date switching;

[0062] S302: In response to the first current date being earlier than or equal to the second current date, obtaining a serial number using a preset first serial number generation strategy;

[0063] S303: In response to the first current date being later than the second current date, obtaining a serial number using a preset second serial number generation strategy, and updating the second current date and prefix serial number recorded by the application layer for the server;

[0064] S304: Generate a line code according to the preset service prefix, the second current date, the prefix sequence number and the sequence number, and return the line code.

[0065] In the above implementation, for step S301, the external service is the process of using the line code generation solution. The server receives a line number generation request. For example, server A receives a line number generation request, and server B also receives a line number generation request. Taking server A as an example, the first current date tempDate of server A is obtained, and the second current date currentDate in the service core attribute set by the application layer for server A is obtained. The first current date tempDate is the machine time of server A, and the second current date currentDate is the time obtained by changing one or more of system initialization, fault recovery, and date switching. See the subsequent Figure 5 and Figure 6 Description shown.

[0066] For steps S302 and S303, based on the comparison results of the first current date tempDate and the service core attribute second current date currentDate, it is divided into two branches: 1) normal service, which is the branch that will be executed for most service requests; 2) service after date switching, which is only executed once when the system date switch occurs.

[0067] See also Figure 4 As shown, this is a specific flow chart of the solution "determining whether the first current date is later than the second current date, determining a corresponding serial number generation strategy based on the determination result, and generating a serial number using the serial number generation strategy":

[0068] 1. Determine whether the first current date tempDate is later than the second current date currentDate. If the first current date is earlier than or equal to the second current date, execute step 2; if the first current date is later than the second current date, execute step 4.

[0069] 2. If the first current date tempDate is earlier than or equal to the second current date currentDate, obtain the server's prefix sequence length prefixLength. Since the line code in this solution preferably has a 7-bit suffix, the prefix sequence length and the sequence number length are both 7. For example, if the prefix sequence number is 01 and the sequence number is 00001, the resulting coded suffix is 0100001. Therefore, the method of 7-prefixLength is used here to calculate the maximum sequence number sequence.

[0070] 3. Get the latest sequence number from the service core attributes set for server A at the application layer and determine whether the latest sequence number sequence is equal to the maximum sequence number:

[0071] a) If yes, it is determined that the serial number of server A at the second current date currentDate has been exhausted, and a failure result is returned;

[0072] b) If not, use the first preset auto-increment method, such as incrementing the current latest serial number by 1 to obtain a new current serial number;

[0073] 4. If the first current date tempDate is later than the second current date currentDate, read the database table record of the data layer; wherein the database table record includes the date t_date, the prefix sequence number length t_len, and the prefix sequence number value t_seq;

[0074] 5. Determine whether the date t_date is later than the first current date tempDate:

[0075] a) If the date t_date is earlier than the first current date tempDate, update the date t_date to the first current date tempDate, set the prefix sequence value t_seq to 0, and update the application layer prefix sequence number prefix to 0;

[0076] b) If the date t_date is later than or equal to the first current date tempDate, calculate the maximum prefix sequence number value t_seq based on the prefix sequence number length t_len. The calculation method is: 10 t_len -1. Then determine whether the prefix sequence number value t_seq of the database table record is equal to the maximum prefix sequence number value t_seq;

[0077] If I is equal, it is determined that the serial number of server A on the second current date currentDate has been exhausted, and a failure result is returned;

[0078] If II is not equal, the prefix sequence number value t_seq recorded in the database table is incremented by a second preset increment method, such as incrementing by 1, to obtain a new prefix sequence number value t_seq, and the prefix sequence number prefix of the application layer is updated to t_seq+1;

[0079] 6. After step 5, update the second current date currentDate of the application layer to the first current date tempDate, update the prefix sequence length prefixLength to the prefix sequence length t_len, and update the sequence number sequence to 0;

[0080] 7. After steps 3 and 6, the serial number is obtained, and the operation of generating the serial number is completed.

[0081] From the above description, we can see that 1) under normal service conditions, service failure only occurs when Server A's local sequence number is exhausted. In other cases, the memory processing circuit code returns, which is extremely time-consuming and meets high performance requirements. 2) After the date switch, service is resumed, with the addition of an in-memory core attribute update. This process is consistent with the initialization process, and there are two scenarios: Server A's local database record update succeeds or fails.

[0082] For step S304, refer to Figure 1(a), which is the existing line code generation rule. This solution makes adjustments based on this to obtain a new line code generation rule: service prefix + currentDate (yyyyMMdd format) + prefix (if the number of digits is insufficient, add 0 to the front to format, such as 01) + sequence (if the number of digits is insufficient, add 0 to the front to format, such as 00001). Figure 4 In the steps shown, after obtaining the second current date currentDate of the application layer, the prefix sequence number prefix and the sequence number sequence of the application layer, a line code is generated according to the above new line code generation rule and returned.

[0083] The method provided in the above embodiment flexibly selects different sequence number generation strategies by comparing machine time with time recorded at the application layer, thereby ensuring the uniqueness and validity of the generated line code. It also adapts to complex scenarios such as system initialization, fault recovery, and date switching. This design not only improves system reliability but also enhances adaptability to time changes, making the line code generation process more intelligent and automated.

[0084] See also Figure 5 , shows a schematic flow chart of an optional method for generating line code according to an embodiment of the present invention, comprising the following steps:

[0085] S501: In response to monitoring server failure recovery or system initialization, obtaining a first current date of the server and reading a database table record from the data layer; wherein the database table record includes a date, a prefix sequence number length, and a prefix sequence number value, and the date is a maximum date of the server cluster in the application layer;

[0086] S502: Determine whether the first current date is later than the date recorded in the database table, and adopt a corresponding assignment strategy based on the determination result to update the database table record, as well as update the second current date and prefix sequence number set by the application layer for the server;

[0087] S503: During the execution of the assignment policy, the prefix sequence length set by the application layer for the server is updated to the prefix sequence length, and the sequence number is updated to 0;

[0088] S504: In response to the second current date, prefix sequence number, prefix sequence length, and sequence number set by the application layer for the server being updated, the server status is updated to available.

[0089] In the above implementation, steps S501 to S504 are used to complete the assignment of the four core attributes of each application layer service (ie, server). After the attribute assignment is completed, the service is available. Figure 6 As shown, the initialization and fault recovery scenarios reuse the same flowchart, indicating that they are technically equivalent. Conventional initialization is the startup of a new service, and fault recovery is equivalent to the startup of a new service. This may result in some coding waste, but the fault scenario is a low-frequency event.

[0090] When the entire solution is first applied to the system, a record needs to be written to the data table during the initialization phase. Assuming the current date is T, the database should insert the record (T+1,2,0,0), and it is recommended to start the initialization operation at a time close to the early morning of T+1 on day T, where 2 is the length of the prefix sequence number mentioned above. This is because after the server is started, tempDate(T) is less than t_date(T+1), which triggers the currentDate to be updated to T+1. In this way, the use of date infixes can effectively avoid duplication with the codes generated by the previous encoding scheme. At the same time, choosing to start initialization close to the early morning can minimize the risk of the next day's sequence numbers being consumed in large quantities in advance due to a long time span.

[0091] Figure 6 The flowchart shown includes the following steps:

[0092] 1. In response to monitoring server failure recovery and system initialization, obtain the server's first current date tempDate and read the database table record from the data layer; wherein the database table record includes the date t_date, the prefix sequence number length t_len, and the prefix sequence number value t_seq, and the date t_date is the latest date (or maximum date) of the cluster composed of servers in the application layer.

[0093] 2. Determine whether the first current date tempDate is later than the date t_date. If the first current date tempDate is earlier than or equal to the date t_date, execute step 3. If the first current date tempDate is later than the date t_date, execute step 4. After executing steps 3 and 4, execute step 5.

[0094] 3. When the first current date tempDate is earlier than or equal to the date t_date, the maximum prefix sequence number value t_seq is determined according to the prefix sequence number length t_len. The calculation method is: 10 t_len -1, determines whether the prefix sequence number value t_seq of the database table record is equal to the maximum prefix sequence number value t_seq;

[0095] a) If it is equal, it is determined that the prefix sequence number value is exhausted, the initialization failure information is returned, and an alarm is triggered, and the system enters the cross-day retry queue. This is a special scenario, that is, the t_seq of the day is exhausted (t_seq=10 t_len -1). This scenario can only occur in two situations: 1. Excessive service deployment; 2. Excessive service restarts. Excessive service restarts never occur in mature production systems, and excessive service deployments eliminate the need to start new services or restore old ones.

[0096] b) If not, increment the prefix sequence number t_seq of the database table record by 1, update the current date currentDate of the application layer to the date t_date of the database table record, and update the prefix sequence number prefix of the application layer to the updated t_seq+1;

[0097] 4. When the first current date tempDate is later than the date t_date (i.e., date switching), the date t_date recorded in the database table is updated to the first current date tempDate, the prefix sequence number value t_seq of the database table record is set to 0, and the second current date currentDate set by the application layer for the server is updated to the first current date tempDate, and the prefix sequence number prefix of the application layer is updated to 0;

[0098] Date switching is also a special case. If a service initialization occurs at a specific time during a date switching, it is necessary to attempt to update the data table records to reflect the date switching. Update failures are permitted; failure indicates that other services have completed updating the data table records, allowing initialization to continue. A date switching represents a change from today to tomorrow, for example, November 7th at 23:59:59 -> November 8th at 00:00:00, which is different from clock rewinding. First, the current date, tempDate, is the server's machine time; second, the current date, currentDate, is not. The difference between the two is due to machine time errors. At the same time on two machines, there may be a brief period where one is today and the other is tomorrow.

[0099] 5. After steps 3 and 4, update the prefix sequence length prefixLength of the application layer to the prefix sequence length (t_len), and update the service variable sequence number sequence of the application layer to 0.

[0100] 6. After the system service is initialized successfully, it can provide services to the outside world, such as updating the server status to available.

[0101] The method provided in the above embodiment effectively obtains and updates relevant date and serial number information through the system's response to server failure recovery or initialization, thereby ensuring the accuracy and consistency of the four attributes set by the application layer for the server. This mechanism not only improves system recovery efficiency but also, by dynamically updating the four service attributes, ensures the uniqueness and validity of the codes generated in different states, thereby enhancing the stability and reliability of the system.

[0102] See also Figure 7 , shows a schematic flow chart of another optional method for generating line code according to an embodiment of the present invention, comprising the following steps:

[0103] S701: In response to multiple servers reading database table records from the data layer, using a preset locking strategy, the database table records are transmitted to a target server where the locking is successful;

[0104] S702: The target server updates the prefix serial number value of the database table record through the assignment strategy, and automatically increments the version number by a preset value to obtain a new database table record and write it into the data layer.

[0105] In the above implementation, steps S701 and S702 are similar to the previous description. The data table in this solution consists of four fields: date (t_date), prefix sequence number length (t_len), prefix sequence number value (t_seq), and version number (t_version). The version number is used to implement optimistic locking. Optimistic locking is a mechanism for handling database concurrency control. It assumes that multiple transactions will not conflict during execution, and therefore does not immediately lock data when it is updated. Optimistic locking is usually implemented using a version number or timestamp.

[0106] It's important to note that concurrent database access issues only occur during initialization and date change scenarios. During the initialization phase, server machine startup experiences time differences, while system clocks experience time differences during date change. Furthermore, service access during date change scenarios is random (only the first service access after a date change triggers an update). This introduces low concurrent access conflicts. Therefore, optimistic locking can be employed in the application-layer service process design. The database table version number (t_version) field provides support for this.

[0107] Regarding the explanation of "service access randomness," all service requests are random. Even if the application is designed as a scheduled task, technical imperfections can still cause slight errors in the scheduled task. This is especially true in this scenario, where multiple distributed services provide external services and requests randomly access a specific machine. The arrival time of multiple requests on a machine is also random.

[0108] Taking the initialization process as an example, optimistic locking occurs in the processing unit bounded by database reads and writes, as shown in Figure 8(a), which goes from database read to in-memory processing logic to database writes. For the data layer, if multiple servers request to read a database table record, an optimistic locking mechanism is used to attempt to lock the record. Upon successful lock, the record is returned to the server that successfully locked it. After Server A updates the prefix sequence number, it updates the prefix sequence number t_seq of the database table record and increments the version number of the database table record by 1. This creates a new record and returns it to the database for update.

[0109] As shown in Figure 8(b), the database table record is currently (20240814,2,1,1), which means version number version=1. Servers A and B both try to obtain the database table record. Server A successfully locks it and sends the database table record (20240814,2,1,1) to server A. After server A is initialized based on the database table record, since the maximum prefix sequence number value calculated based on the prefix sequence number length (t_len)2 is 99, and the prefix sequence number value (t_seq) in the current database table record is 1, which is less than 99, it uses Figure 6In the method "Update the t_seq field of the database table record with an auto-increment rule", the prefix sequence number value (t_seq) is updated to 2. At the same time, Server A also needs to increment the version number by 1 to 2. The updated database table record is (20240814,2,2,2). Then (20240814,2,2,2) is written to the data layer to replace (20240814,2,1,1).

[0110] Therefore, in this solution, when reading the same database table record, only one server will successfully update, while the other server will fail and retry. Because this invention incorporates system clock differences and the randomness of service access into the design, the probability of concurrent access is greatly reduced. Therefore, using optimistic locking can reap the performance advantages of not using locks.

[0111] The method provided in the above embodiment, through a preset locking strategy, ensures data consistency and security when multiple servers simultaneously access data layer database table records, avoiding data conflicts and inconsistencies. Furthermore, the target server updates the prefix sequence value and auto-increment version number through an assignment strategy, which not only maintains data integrity but also tracks record change history, improving system maintainability and scalability, thereby effectively supporting data processing requirements in highly concurrent environments.

[0112] Popular distributed ID generation algorithms (such as the Snowflake algorithm) often encounter system time issues that introduce a small probability of duplication. This solution is compatible with the problem of inconsistent system time. System time inconsistency can occur in two scenarios: one is when different machines have different times, and the other is when the system time on the same machine is repeated after a time callback.

[0113] In the first scenario, the times on different machines are inconsistent. Assume there are two application layer services (Service A and Service B): Service A [currentDate = T, prefixLength = 2, prefix = 0, sequence = 1] and Service B [currentDate = T, prefixLength = 2, prefix = 1, sequence = 1]. Service B's system date is changed to T+1. After the change, Service B's [currentDate = T+1, prefixLength = 2, prefix = 0, sequence = 1] is changed. The prefix is duplicated, but the date (currentDate) is different, so uniqueness is not compromised.

[0114] In the second scenario, a callback occurs on the same machine time. Suppose service B [currentDate = T, prefixLength = 2, prefix = 1, sequence = 1] changes the system date to T+1. After the change, service B [currentDate = T+1, prefixLength = 2, prefix = 0, sequence = 1] then experiences a system clock callback, and tempDate changes to T. However, the logic ensures that currentDate remains T+1, and uniqueness is not violated.

[0115] See also Figure 9 , which shows a schematic diagram of main modules of an apparatus 900 for generating line code according to an embodiment of the present invention, including:

[0116] Receiving module 901 is configured to receive a line number generation request, obtain a first current date from the server, and obtain a second current date recorded by the application layer for the server; wherein the first current date is the machine time, and the second current date is the time obtained by processing one or more of system initialization, fault recovery, and date switching;

[0117] A serial number generating module 902 is configured to obtain a serial number using a preset first serial number generating strategy in response to the first current date being earlier than or equal to the second current date;

[0118] In response to the first current date being later than the second current date, obtaining a serial number using a preset second serial number generation strategy, and updating the second current date and prefix serial number recorded by the application layer for the server;

[0119] The line code generating module 903 is configured to generate a line code according to a preset service prefix, a second current date, a prefix sequence number and a sequence number, and return the generated line code.

[0120] In the embodiment of the present invention, the serial number generation module 902 is used to:

[0121] Obtain the prefix sequence length recorded by the application layer for the server, and calculate the maximum sequence number based on the prefix sequence length;

[0122] Obtaining the latest sequence number recorded by the application layer for the server, and in response to the latest sequence number being equal to the maximum sequence number, determining that the server's sequence number for the second current date has been exhausted, and returning a failure result;

[0123] In response to the current latest sequence number being less than the maximum sequence number, the current latest sequence number is processed using a first preset auto-increment method to obtain a new current latest sequence number.

[0124] In the embodiment of the present invention, the serial number generation module 902 is used to:

[0125] Reading a database table record from the data layer; wherein the database table record includes a date, a prefix sequence number length, and a prefix sequence number value, and the date is the maximum date of the server cluster in the application layer;

[0126] Determine whether the first current date is later than the date recorded in the database table, determine a corresponding update strategy based on the determination result, update the database table record using the update strategy, and update the prefix sequence number set by the application layer for the server;

[0127] During the execution of the update strategy, the second current date set by the application layer for the server is updated to the first current date, the prefix sequence length is updated to the prefix sequence number length, and the sequence number is set to 0.

[0128] In the embodiment of the present invention, the serial number generation module 902 is used to:

[0129] In response to the database table record date being earlier than the first current date, updating the database table record date to the first current date, updating the prefix sequence number value to 0, and updating the prefix sequence number set by the application layer for the server to 0;

[0130] In response to the database table record date being later than or equal to the first current date, calculating a maximum prefix sequence number value according to the prefix sequence number length in the database table record, and comparing the prefix sequence number value with the maximum prefix sequence number value;

[0131] Determine the corresponding processing strategy based on the comparison results, use the processing strategy to update the database table record, and update the prefix sequence number set for the server at the application layer.

[0132] In the embodiment of the present invention, the serial number generation module 902 is used to:

[0133] When the prefix sequence number value is equal to the maximum prefix sequence number value, it is determined that the server's sequence number for the second current date has been exhausted, and a failure result is returned;

[0134] When the prefix sequence number value is less than the maximum prefix sequence number value, the prefix sequence number value is processed using the second preset self-increment method to obtain a new prefix sequence number value, and the prefix sequence number set for the server at the application layer is updated to the sum of the new prefix sequence number value and 1.

[0135] The implementation device of the present invention also includes an initialization and fault recovery module, which is used to:

[0136] In response to monitoring server failure recovery or system initialization, obtaining a first current date of the server, and reading a database table record from the data layer; wherein the database table record includes a date, a prefix sequence number length, and a prefix sequence number value, and the date is a maximum date of the server cluster in the application layer;

[0137] Determine whether the first current date is later than the date recorded in the database table, and adopt a corresponding assignment strategy based on the determination result to update the database table record, as well as update the second current date and prefix sequence number set by the application layer for the server;

[0138] During the execution of the assignment policy, the prefix sequence length set by the application layer for the server is updated to the prefix sequence length, and the sequence number is updated to 0;

[0139] In response to the second current date, prefix sequence number, prefix sequence length, and sequence number set by the application layer for the server being updated, the server status is updated to available.

[0140] In the implementation device of the present invention, the initialization and fault recovery module is used to:

[0141] In response to the first current date being later than the date recorded in the database table, the date recorded in the database table is updated to the first current date, and the prefix sequence number value is updated to 0; the second current date set by the application layer for the server is updated to the first current date, and the prefix sequence number is updated to 0;

[0142] In response to the first current date being earlier than or equal to the database table record date, determining a maximum prefix sequence number value according to the prefix sequence number length, and comparing the prefix sequence number value with the maximum prefix sequence number value;

[0143] Determine a processing strategy based on the comparison result, use the processing strategy to update the database table record, and update the second current date and prefix serial number set for the server at the application layer.

[0144] In the implementation device of the present invention, the initialization and fault recovery module is used to:

[0145] If the prefix sequence number value is equal to the maximum prefix sequence number value, the assignment failure information is returned and an alarm is triggered;

[0146] When the prefix sequence number value is less than the maximum prefix sequence number value, the prefix sequence number value is processed using the second preset self-increment method to obtain a new prefix sequence number value, and the second current date set by the application layer for the server is updated to the database table record date, and the prefix serial number is updated to the sum of the new prefix sequence number value and 1.

[0147] In the implementation device of the present invention, the database table record of the data layer also includes a version number, and the device also includes a lock management module for:

[0148] In response to multiple servers reading database table records from the data layer, using a preset locking strategy, the database table records are transmitted to a target server where the locking is successful;

[0149] Among them, the target server updates the prefix serial number value of the database table record through the assignment strategy, and automatically increments the version number by a preset value to obtain a new database table record and write it into the data layer.

[0150] In addition, the specific implementation content of the device in the embodiment of the present invention has been described in detail in the above method, so the repeated content will not be described again here.

[0151] Figure 10 An exemplary system architecture 1000 to which embodiments of the present invention may be applied is shown, including terminal devices 1001 , 1002 , 1003 , a network 1004 and a server 1005 (only an example).

[0152] Terminal devices 1001, 1002, and 1003 can be various electronic devices with display screens and support web browsing, and are installed with various communication client applications. Users can use terminal devices 1001, 1002, and 1003 to interact with server 1005 through network 1004 to receive or send messages, etc.

[0153] The network 1004 is used to provide a medium for communication links between the terminal devices 1001, 1002, 1003 and the server 1005. The network 1004 may include various connection types, such as wired or wireless communication links or fiber optic cables.

[0154] Server 1005 can be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using terminal devices 1001, 1002, and 1003 (for example only). The backend management server can analyze and process received data such as product information query requests, and feed back the processing results (such as target push information and product information - for example only) to the terminal device. It should be noted that the method provided in the embodiments of the present invention is generally executed by server 1005, and accordingly, the device is generally located in server 1005.

[0155] It should be understood that Figure 10 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0156] Reference below Figure 11 , which shows a schematic structural diagram of a computer system 1100 of a terminal device suitable for implementing an embodiment of the present invention. Figure 11The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0157] like Figure 11 As shown, the computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1102 or a program loaded from a storage unit 1108 into a random access memory (RAM) 1103. Various programs and data required for the operation of the system 1100 are also stored in the RAM 1103. The CPU 1101, the ROM 1102, and the RAM 1103 are connected to each other via a bus 1104. An input / output (I / O) interface 1105 is also connected to the bus 1104.

[0158] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, a mouse, and the like; an output section 1107 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 1108 including a hard disk; and a communication section 1109 including a network interface card such as a LAN card or a modem. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. Removable media 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1110 as needed, so that computer programs read therefrom can be installed into the storage section 1108 as needed.

[0159] In particular, according to the embodiments disclosed in the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 1109, and / or installed from a removable medium 1111. When the computer program is executed by the central processing unit (CPU) 1101, the above-mentioned functions defined in the system of the present invention are performed.

[0160] It should be noted that the computer-readable medium described in the present invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.

[0161] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.

[0162] The modules described in the embodiments of the present invention may be implemented via software or hardware. The modules described may also be located within a processor. For example, a processor may be described as comprising a receiving module, a sequence number generation module, and a line code generation module. The names of these modules do not, in some cases, limit the modules themselves. For example, a line code generation module may also be described as a "line code update module."

[0163] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiments, or may exist independently and not incorporated into the device. The computer-readable medium carries one or more programs, which, when executed by the device, cause the device to perform any of the above-described methods for generating line codes.

[0164] The computer program product of the present invention includes a computer program, and when the computer program is executed by a processor, the method for generating line coding in the embodiment of the present invention is implemented.

[0165] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A method for generating line code, characterized in that: include: receiving a line number generation request, obtaining a first current date of the server, and obtaining a second current date recorded by the application layer for the server; wherein the first current date is the machine time, and the second current date is the time obtained by processing one or more of system initialization, fault recovery, and date switching; In response to the first current date being earlier than or equal to the second current date, obtaining a serial number using a preset first serial number generation strategy; In response to the first current date being later than the second current date, obtaining a serial number using a preset second serial number generation strategy, and updating the second current date and prefix serial number recorded by the application layer for the server; Generates and returns a line code based on the preset service prefix, second current date, prefix sequence number, and sequence number.

2. The method according to claim 1, characterized in that The obtaining of the sequence number by using the preset first sequence number generation strategy includes: Obtain the prefix sequence length recorded by the application layer for the server, and calculate the maximum sequence number based on the prefix sequence length; Obtaining the latest sequence number recorded by the application layer for the server, and in response to the latest sequence number being equal to the maximum sequence number, determining that the server's sequence number for the second current date has been exhausted, and returning a failure result; In response to the current latest sequence number being less than the maximum sequence number, the current latest sequence number is processed using a first preset auto-increment method to obtain a new current latest sequence number.

3. The method according to claim 1 or 2, characterized in that The method of obtaining a sequence number by using a preset second sequence number generation strategy and updating the second current date and prefix sequence number recorded by the application layer for the server includes: Reading a database table record from the data layer; wherein the database table record includes a date, a prefix sequence number length, and a prefix sequence number value, and the date is the maximum date of the server cluster in the application layer; Determine whether the first current date is later than the date recorded in the database table, determine a corresponding update strategy based on the determination result, update the database table record using the update strategy, and update the prefix sequence number set by the application layer for the server; During the execution of the update strategy, the second current date set by the application layer for the server is updated to the first current date, the prefix sequence length is updated to the prefix sequence number length, and the sequence number is set to 0.

4. The method according to claim 3, characterized in that The determining whether the first current date is later than the date recorded in the database table and determining a corresponding update strategy according to the determination result includes: In response to the database table record date being earlier than the first current date, updating the database table record date to the first current date, updating the prefix sequence number value to 0, and updating the prefix sequence number set by the application layer for the server to 0; In response to the database table record date being later than or equal to the first current date, calculating a maximum prefix sequence number value according to the prefix sequence number length in the database table record, and comparing the prefix sequence number value with the maximum prefix sequence number value; Determine the corresponding processing strategy based on the comparison results, use the processing strategy to update the database table record, and update the prefix sequence number set for the server at the application layer.

5. The method according to claim 4, characterized in that Determining a corresponding processing strategy based on the comparison result, using the processing strategy to update the database table record, and updating the prefix sequence number set for the server by the application layer include: When the prefix sequence number value is equal to the maximum prefix sequence number value, it is determined that the server's sequence number for the second current date has been exhausted, and a failure result is returned; When the prefix sequence number value is less than the maximum prefix sequence number value, the prefix sequence number value is processed using the second preset self-increment method to obtain a new prefix sequence number value, and the prefix sequence number set for the server at the application layer is updated to the sum of the new prefix sequence number value and 1.

6. The method according to claim 1, characterized in that The method further comprises: In response to monitoring server failure recovery or system initialization, obtaining a first current date of the server, and reading a database table record from the data layer; wherein the database table record includes a date, a prefix sequence number length, and a prefix sequence number value, and the date is a maximum date of the server cluster in the application layer; Determine whether the first current date is later than the date recorded in the database table, and adopt a corresponding assignment strategy based on the determination result to update the database table record, as well as update the second current date and prefix sequence number set by the application layer for the server; During the execution of the assignment policy, the prefix sequence length set by the application layer for the server is updated to the prefix sequence length, and the sequence number is updated to 0; In response to the second current date, prefix sequence number, prefix sequence length, and sequence number set by the application layer for the server being updated, the server status is updated to available.

7. The method according to claim 6, characterized in that The method adopts a corresponding assignment strategy according to the judgment result to update the database table record, and updates the second current date and prefix sequence number set by the application layer for the server, including: In response to the first current date being later than the date recorded in the database table, the date recorded in the database table is updated to the first current date, and the prefix sequence number value is updated to 0; the second current date set by the application layer for the server is updated to the first current date, and the prefix sequence number is updated to 0; In response to the first current date being earlier than or equal to the database table record date, determining a maximum prefix sequence number value according to the prefix sequence number length, and comparing the prefix sequence number value with the maximum prefix sequence number value; Determine a processing strategy based on the comparison result, use the processing strategy to update the database table record, and update the second current date and prefix serial number set for the server at the application layer.

8. The method according to claim 7, characterized in that Determining a processing strategy based on the comparison result, updating a database table record using the processing strategy, and updating a second current date and a prefix sequence number set by the application layer for the server include: If the prefix sequence number value is equal to the maximum prefix sequence number value, the assignment failure information is returned and an alarm is triggered; When the prefix sequence number value is less than the maximum prefix sequence number value, the prefix sequence number value is processed using the second preset self-increment method to obtain a new prefix sequence number value, and the second current date set by the application layer for the server is updated to the database table record date, and the prefix serial number is updated to the sum of the new prefix sequence number value and 1.

9. The method according to claim 6, characterized in that The database table record of the data layer also includes a version number, and the method further includes: In response to multiple servers reading database table records from the data layer, using a preset locking strategy, the database table records are transmitted to a target server where the locking is successful; Among them, the target server updates the prefix serial number value of the database table record through the assignment strategy, and automatically increments the version number by a preset value to obtain a new database table record and write it into the data layer.

10. A device for generating line code, characterized in that: include: a receiving module, configured to receive a line number generation request, obtain a first current date from the server, and obtain a second current date recorded by the application layer for the server; wherein the first current date is the machine time, and the second current date is a time obtained by processing one or more of system initialization, fault recovery, and date switching; A serial number generating module, configured to obtain a serial number using a preset first serial number generating strategy in response to the first current date being earlier than or equal to the second current date; In response to the first current date being later than the second current date, obtaining a serial number using a preset second serial number generation strategy, and updating the second current date and prefix serial number recorded by the application layer for the server; The line code generation module is used to generate and return a line code according to a preset service prefix, a second current date, a prefix sequence number and a sequence number.

11. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 9.

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

13. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.