SMS generation methods, devices, equipment, media and products
By introducing query field information into the SMS template and generating query statements based on database relationships, the limitations of SMS generation in existing technologies are solved, enabling flexible and efficient SMS content generation that adapts to changes in database structure and personalized needs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2026-03-06
AI Technical Summary
In existing SMS generation methods, the setting of SMS templates depends on predefined data items, which limits the content of the generated SMS messages, makes it difficult to flexibly respond to changes in database structure, and prevents the use of undefined data items, thus increasing the complexity of system development and maintenance.
By identifying target identifiers in SMS templates, query statements are generated based on the relationships between various data tables in the database, thereby dynamically reading data from the database, expanding the data content available in SMS templates, supporting more complex queries and data combinations, and generating personalized SMS content.
It achieves flexibility and diversity in SMS templates, can adapt to changes in database structure, generate personalized SMS content, reduce the complexity of system development and maintenance, and provides a more flexible and efficient SMS generation solution.
Smart Images

Figure CN119829570B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data analysis technology, and in particular to a method, apparatus, device, medium and product for generating text messages. Background Technology
[0002] The technology of automatically generating SMS content by populating SMS templates with data from a database has become widely used.
[0003] In existing technologies, it is typically necessary to predefine data items and their usage methods, and set up a data item parsing interface in the backend of the SMS generation system. Then, an SMS template is written based on these predefined data items. Finally, the SMS generation system reads the corresponding data from the database by calling the backend parsing interface to replace the data items in the SMS template, thereby generating the SMS message.
[0004] However, in existing SMS generation methods, the SMS template settings rely on predefined data items, which limits the content of the generated SMS messages. Summary of the Invention
[0005] This application provides a method, apparatus, device, medium, and product for generating text messages, which expands the data content available in text message templates by leveraging the relationships between various data tables in a database.
[0006] Firstly, this application provides a method for generating SMS messages, the method comprising:
[0007] Obtain the SMS template, parse the SMS template, identify the target identifier from the SMS template, extract the target identifier, determine the first position of the target identifier in the SMS template, and extract query field information from the SMS template based on the target identifier and the first position. The second position of the query field information is associated with the first position of the target identifier.
[0008] Retrieve at least one query field and the query table containing each query field from the query field information;
[0009] If the number of query tables is greater than or equal to 2, the multiple query tables will be divided into at least one pair of related tables according to the database's preset relationship information. When there are at least two pairs of related tables, the at least two pairs of related tables can be associated into a virtual table. Each pair of related tables consists of two query tables, and / or consists of one query table and other data tables other than one query table. The preset relationship information is used to indicate the relationship between fields and tables in the database.
[0010] Generate a query statement based on at least one related table pair and the query field, and retrieve the query result data from the database based on the query statement;
[0011] The query results data is parsed to determine the field data corresponding to the query field information, and the field data is extracted.
[0012] The data format of the field data is validated. If the data format is inconsistent with the preset format, the data format of the field data is converted to the preset format to obtain the field data in the preset format.
[0013] Based on the second position of the query field information in the SMS template, the query field information in the SMS template is replaced with field data in a preset format to obtain the SMS content.
[0014] In one possible design, multiple query tables are divided into at least one pair of related tables based on pre-defined relational information in the database, including:
[0015] Obtain at least one first associated table for each query table from the preset relation information;
[0016] At least one first association group is determined from multiple query tables based on each first association table. Each first association group is one of the following: a single query table, a table pair, or a table group. A single query table does not exist in the first association table of any query table. One query table in a table pair is the first association table of the other query table in the table pair. The first association table in a table group is the same first association table of the two query tables in the table group.
[0017] Extract the association table pairs from at least one first association group.
[0018] In one possible design, extracting association table pairs from at least one first association group includes:
[0019] Treat each table pair as a join pair, and split each group of tables into two join pairs;
[0020] Use the first association group as the current association group, and execute the relationship iteration process multiple times:
[0021] Combine at least two current associations that include the same data table into a second association group;
[0022] If a second association group exists, stop extracting the association table pairs;
[0023] If there are multiple second association groups, at least one second association table is determined for each data table in each second association group, and at least one third association group is determined from the multiple second association groups based on each second association table, and the third association group is taken as the current association group. Each third association group is one of the following: a single second association group, a pair, or a group. The first data table of a second association group in a pair is the second association table of the second data table of another second association group in the pair. The second association table in a group is the same second association table of the third data tables of the two second association groups in the group.
[0024] The first and second data tables are treated as a pair of related tables, and two pairs of related tables are generated based on the third data table of the two second related groups in the group and the same second related table.
[0025] In one possible design, a query statement is generated based on at least one related table pair and a query field, including:
[0026] Parse the preset relationship information to obtain the relationship between the two data tables in the association table pair;
[0027] Based on the association relationship, determine the associated fields between the two data tables in the association table pair;
[0028] Generate a query statement based on the query fields, related fields, and related table pairs.
[0029] In one possible design, after generating the query statement, the method further includes:
[0030] Optimize query statements by creating composite indexes.
[0031] In one possible design, the process of generating the SMS template includes:
[0032] Displays preset relationship information;
[0033] Receive query field information selected by the user from the preset relationship information;
[0034] Generate SMS templates based on the query field information.
[0035] In one possible design, an SMS template is generated based on the query field information, including:
[0036] Receive text information input by the user, which includes the insertion position of the query field information, and the insertion position is the second position;
[0037] Generate an SMS template based on the text information and query field information.
[0038] Secondly, this application provides a text message generation device, comprising:
[0039] The acquisition module is used to acquire SMS templates, parse SMS templates, identify target identifiers from SMS templates, extract target identifiers, determine the first position of target identifiers in SMS templates, and extract query field information from SMS templates based on target identifiers and the first position. The second position of query field information is associated with the first position of target identifiers.
[0040] The query table module is used to retrieve at least one query field and the query table containing each query field from the query field information;
[0041] The associated table pair module is used to divide multiple query tables into at least one associated table pair according to the database's preset relationship information if the number of query tables is greater than or equal to 2. When there are at least two associated table pairs, the at least two associated table pairs can be associated into a virtual table. Each associated table pair consists of two query tables, and / or consists of one query table and other data tables other than one query table. The preset relationship information is used to indicate the relationship between fields and tables in the database.
[0042] The query module is used to generate a query statement based on at least one related table pair and a query field, and retrieve query result data from the database based on the query statement;
[0043] The extraction module is used to parse the query result data, determine the field data corresponding to the query field information from the query result data, and extract the field data;
[0044] The format conversion module is used to validate the data format of field data. If the data format is inconsistent with the preset format, the data format of the field data is converted to the preset format to obtain the field data in the preset format.
[0045] The replacement module is used to replace the query field information in the SMS template with field data in a preset format based on the second position of the query field information in the SMS template, so as to obtain the SMS content.
[0046] In one possible design, the association table pair module includes: a first association table module, a first association group module, and an association table pair module;
[0047] The first association table module is used to obtain at least one first association table for each query table from the preset relationship information;
[0048] The first association group module is used to determine at least one first association group from multiple query tables based on each first association table. Each first association group is one of the following: a single query table, a table pair, or a table group. A single query table does not exist in the first association table of any query table. One query table in a table pair is the first association table of the other query table in the table pair. The first association table in a table group is the same first association table of the two query tables in the table group.
[0049] The module for extracting association table pairs is used to extract association table pairs from at least one first association group.
[0050] In one possible design, the module for extracting association table pairs includes: a first confirmation module and an iteration module; wherein the iteration module includes: a second association group module, a stop extraction module, a third association group module, and a second confirmation module;
[0051] The first confirmation module is used to treat each table pair as a related table pair and split each table group into two related table pairs;
[0052] The iteration module is used to take the first association group as the current association group and execute the relationship iteration process multiple times:
[0053] The second association group module is used to combine at least two current association groups that include the same data table into a second association group;
[0054] The Stop Extraction module is used to stop extracting the associated table pairs if a second associated group exists.
[0055] The third association group module is used to determine at least one second association table of each data table in each second association group if multiple second association groups exist, and to determine at least one third association group from the multiple second association groups based on each second association table, and to take the third association group as the current association group. Each third association group is one of the following: a single second association group, a pair, or a group. The first data table of one second association group in a pair is the second association table of the second data table of another second association group in the pair. The second association table in a group is the same second association table of the third data tables of the two second association groups in the group.
[0056] The second confirmation module is used to treat the first data table and the second data table as a pair of related tables, and to generate two pairs of related tables based on the third data table of the two second related groups in the group and the same second related table.
[0057] In one possible design, the query module includes: a parsing module, a related field module, and a query statement module;
[0058] The parsing module is used to parse the preset relationship information to obtain the relationship between the two data tables in the association table pair;
[0059] The Association Fields module is used to determine the association fields between two data tables in an association table pair based on the association relationship.
[0060] The query statement module is used to generate query statements based on the query fields, related fields, and related table pairs.
[0061] In one possible design, the SMS generation device further includes: an optimization module.
[0062] The optimization module is used to optimize query statements by creating composite indexes.
[0063] In one possible design, the SMS generation device further includes a display module, a receiving module, and a first generation module;
[0064] The display module is used to display preset relationship information;
[0065] The receiving module is used to receive the query field information selected by the user in the preset relationship information;
[0066] The first generation module is used to generate SMS templates based on the query field information.
[0067] In one possible design, the first generation module includes: an input module and a second generation module;
[0068] The input module is used to receive text information input by the user, including the insertion position of the query field information;
[0069] The second generation module is used to generate SMS templates based on text information and query field information.
[0070] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0071] The memory stores the instructions that the computer executes;
[0072] The processor executes computer execution instructions stored in memory to implement a text message generation method according to the first aspect of the invention.
[0073] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement a text message generation method as described in the first aspect of the invention.
[0074] Fifthly, embodiments of this application provide a computer program product, including a computer program, which, when executed by a processor, is used to implement a text message generation method as described in the first aspect of the invention.
[0075] This application provides a method, apparatus, device, medium, and product for generating SMS messages. The method includes: acquiring an SMS template; parsing the SMS template; identifying a target identifier from the SMS template to extract the target identifier; determining the first position of the target identifier in the SMS template; and extracting query field information from the SMS template based on the target identifier and the first position, wherein the second position of the query field information is associated with the first position of the target identifier; obtaining at least one query field and a query table containing each query field from the query field information; if the number of query tables is greater than or equal to two, dividing the multiple query tables into at least one pair of related tables according to preset relational information in the database; when there are at least two pairs of related tables, the at least two pairs of related tables can be associated into a virtual table, and each pair of related tables consists of two... The query table is composed of, and / or, a query table and other data tables besides the query table. Preset relationship information is used to indicate the associations between fields and tables in the database. A query statement is generated based on at least one associated table pair and the query field, and query result data is retrieved from the database based on the query statement. The query result data is parsed to determine the field data corresponding to the query field information and extract the field data. The data format of the field data is validated; if the data format is inconsistent with the preset format, the data format of the field data is converted to the preset format to obtain the field data in the preset format. Based on the second position of the query field information in the SMS template, the query field information in the SMS template is replaced with the field data in the preset format to obtain the SMS content.The following technical effects were achieved: By leveraging the relationships between tables in the database, the usable data content in SMS templates was expanded, allowing all fields in the database to be used in the SMS templates, thus no longer being limited to reading data from the database based on predefined data items and parsing interfaces; by establishing relationships between multiple related table pairs, direct or indirect relationships could be formed between all related table pairs in the database. This means that by associating at least two related table pairs into a virtual table, it is easier to generate query statements and retrieve query results from the database; based on the query statement, data is dynamically read from the database. Even if the data structure in the database changes, the server can still accurately obtain query results based on the query statement through the relationships between the tables in the database, thus still being able to... The system correctly generates SMS messages. By leveraging the relationships between tables in the database, it supports more complex queries and data combinations. For example, it can generate more personalized and customized SMS content based on users' transaction history and preferences. By introducing query fields into the SMS template, the SMS content can be dynamically generated according to the actual situation, making the SMS template more flexible and adaptable to different data content without having to manually write static text for each possible SMS message. By filling the query fields into the placeholders in the SMS template, the system can flexibly reference data from the database as needed when writing the SMS template. This allows the generated SMS content to no longer be limited by predefined data items, thus overcoming the limitations of existing technologies in SMS generation and providing a more flexible and efficient solution for SMS communication. Attached Figure Description
[0076] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0077] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0078] Figure 1 A flowchart illustrating a method for generating text messages provided in this application embodiment. Figure 1 ;
[0079] Figure 2 A flowchart illustrating a method for generating text messages provided in this application embodiment. Figure 2 ;
[0080] Figure 3 A schematic diagram illustrating the relationship between fields provided in an embodiment of this application;
[0081] Figure 4 This is a schematic diagram of the structure of a text message generation device provided in an embodiment of this application;
[0082] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0083] Figure label:
[0084] 410 - Acquisition Module; 420 - Query Table Module; 430 - Join Table Module; 440 - Query Module; 450 - Extraction Module; 460 - Format Conversion Module; 470 - Replacement Module;
[0085] 510 - Processor; 520 - Memory; 530 - Communication components; 540 - Bus. Detailed Implementation
[0086] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0087] In the embodiments of this application, the terms "first" and "second" are used to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply difference. It should be noted that in the embodiments of this application, the words "exemplary" or "for example" are used to indicate that something is being used as an example, illustration, or description. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being better or more advantageous than other embodiments or design schemes. Specifically, the use of "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner. In the embodiments of this application, "at least one" refers to one or more, and "more than one" refers to two or more.
[0088] It should be noted that the phrase "at...time" in the embodiments of this application can refer to the instant at which a certain situation occurs, or to a period of time after the occurrence of a certain situation; the embodiments of this application do not specifically limit this. Furthermore, the SMS generation method provided in the embodiments of this application is merely an example; an SMS generation method may include more or less content.
[0089] The collection, storage, use, processing, transmission, provision, and disclosure of financial data or user data involved in the technical solution of this application all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0090] It should be noted that in the embodiments of this application, certain software, components, models and other existing solutions in the industry may be mentioned. These should be regarded as exemplary and are only intended to illustrate the feasibility of implementing the technical solution of this application. However, it does not mean that the applicant has used or necessarily used the solution.
[0091] In modern communication, SMS, as a fast, direct, and widely used method of information transmission, is extensively applied in various scenarios. The technology of automatically generating SMS content through an SMS generation system by filling SMS templates with data from a database has become an important means of improving communication efficiency.
[0092] In existing SMS generation methods, the data items to be displayed in the SMS message, such as user name, order number, and product name, need to be determined in advance based on actual needs. Then, in the SMS generation system's backend, corresponding parsing interfaces are set up for these data items to retrieve the corresponding data from the database. Next, an SMS template is written based on these predefined data items. The template typically includes placeholders that will be replaced by the actual data later. Finally, the SMS generation system calls the backend parsing interface based on the data items in the SMS template, retrieves the corresponding data from the database, replaces the placeholders in the template, and generates the final SMS content.
[0093] However, existing technologies have the following limitations:
[0094] First, the data content is limited: because SMS template settings rely on predefined data items, the generated SMS content is restricted by these predefined data items. It can only use a limited amount of data from the database to generate SMS content and cannot select data corresponding to undefined data items. When more diverse data needs to be displayed, the data items and parsing interfaces need to be reconfigured, increasing the complexity of developing and maintaining the SMS generation system.
[0095] Secondly, there is a lack of flexibility: when the data structure in the database changes, such as adding new data tables or data fields, the existing SMS templates and parsing interfaces cannot directly adapt to these changes, resulting in SMS generation failures or inaccurate content, thus limiting the flexibility and diversity of the generated SMS content.
[0096] Based on this, embodiments of this application provide a method, apparatus, device, medium, and product for generating SMS messages, which can be used in the field of data analysis technology and aims to solve the above-mentioned technical problems of the prior art. When using an SMS template, a query statement is generated based on the relationships between fields in the database and the pre-defined relationships between fields and data tables. The database is then queried according to the query statement to obtain query result data, and SMS content is generated based on the query result data. In this way, the relationships between various data tables in the database expand the data content that can be used in the SMS template, allowing all fields in the database to be used in the SMS template. This eliminates the need to read data from the database based on predefined data items and parsing interfaces; instead, data is dynamically read from the database based on the query statement. Thus, even if the data structure in the database changes, the SMS generation system can still correctly generate SMS messages based on the query statement. Moreover, due to the utilization of data relationships in the database, the method in this application embodiment can support more complex queries and data combinations. For example, more personalized and customized SMS content can be generated based on user transaction history, preferences, and other information. Secondly, the method in this application embodiment can flexibly reference data from the database as needed when writing SMS templates, so that the generated SMS content is no longer limited to predefined data items. It overcomes the limitations of existing technologies in SMS generation, providing a more flexible and efficient solution for SMS communication.
[0097] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0098] According to the first aspect of this application, this embodiment discloses a method for generating text messages.
[0099] Figure 1 A flowchart illustrating a method for generating text messages provided in this application embodiment. Figure 1 .like Figure 1 As shown, the method includes:
[0100] S101. Obtain the SMS template, parse the SMS template, identify the target identifier from the SMS template, extract the target identifier, determine the first position of the target identifier in the SMS template, and extract query field information from the SMS template based on the target identifier and the first position.
[0101] In this embodiment of the application, the execution subject of the SMS generation method can be a server. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server, etc. No specific restrictions are made here.
[0102] The server can pre-store SMS templates. When the server needs to automatically generate an SMS message, it can retrieve the template from its storage and extract query field information. This query field information indicates the data type of the fields to be populated into the SMS template, as well as the type of the table containing those fields. Furthermore, the query field information may also include fields that the database can provide externally and their corresponding tables.
[0103] In one possible implementation, the process of generating an SMS template includes: displaying preset relationship information; receiving query field information selected by the user in the preset relationship information; and generating an SMS template based on the query field information.
[0104] Specifically, in a database, predefined relationship information indicates the relationships between fields and tables. A table refers to a data table stored in the database, and a field refers to the specific data field in the data table. The server can provide a user interface and / or Application Programming Interface (API) that can be displayed and manipulated. Through this interface and / or API, the server can display the relationships between fields and tables in the database to the user, and receive query field information selected by the user from the predefined relationship information. Based on the query field information, an SMS template is then generated.
[0105] Furthermore, generating an SMS template based on the query field information includes: receiving text information input by the user, which includes the insertion position of the query field information; and generating an SMS template based on the text information and the query field information. In other words, the server receives text information input by the user through the user interface and / or API, and then generates an SMS template based on the text information and the query field information.
[0106] A specific SMS template could be as follows: "Dear ${cust.custname}, your order ${ordr.orderid} amount: ${sum(ordr.payamount)} is not yet completed. Please complete the transaction promptly." Here, the identified target identifier is ${}, which can specifically represent a placeholder. The information filled in the placeholder ${} is the query field information. ${cust.custname} represents the customer's name in the customer table. The first part, cust, refers to the customer table, and the second part, custname, refers to the customer's name. This position will be replaced by the actual customer name. ${ordr.orderid} represents the order number in the order table. The first part, ordr, refers to the order table, and the second part, orderid, refers to the order number. This position will be replaced by the actual order number. ${sum(ordr.payamount)} represents the total amount of the orders in the order table. Here, sum is the summation function used to calculate the total amount of the orders, ordr refers to the order table, and payamount refers to the order amount. This position will be replaced by the actual amount value. For example, if the customer's name is Zhang San, the order number is 123456, and the total order amount is 200 yuan, then the final SMS message will be:
[0107] "Dear Zhang San, your order 123456, amount: 200, is not yet completed. Please complete the transaction promptly."
[0108] Specifically, the server can parse the obtained SMS template to find the target identifier. This can be achieved through regular expressions or other string matching techniques. For example, if the target identifier is enclosed in double curly braces (such as {{name}}, indicating that the user's name needs to be retrieved), then the regular expression {{(.*?)}} can be used to match all target identifiers.
[0109] After identifying the target identifier from the SMS template, the target identifier can be extracted, and its first position in the SMS template can be determined, along with the corresponding query field information. Since the second position of the query field information is related to the first position of the target identifier, the query field information can be extracted from the SMS template based on the target identifier and this first position. For example, the target identifier can be a placeholder ${}, thus the query field information filled in each placeholder ${} can be determined based on the placeholder ${}.
[0110] This embodiment introduces query field information into the SMS template, enabling the SMS content to be dynamically generated according to the actual situation. This makes the SMS template more flexible and adaptable to different data content, without the need to manually write static text for each possible SMS content.
[0111] S102. Obtain at least one query field and the query table containing each query field from the query field information.
[0112] Specifically, the server can determine the query fields and the query table containing each query field from the query field information of each query field in the SMS template.
[0113] Specifically, the query fields can be cust.custname (customer's name in the customer table), ordr.orderid (order number in the order table), and sum(ordr.payamount) (total amount of orders in the order table) as described in the above example.
[0114] The query fields are custname (username), orderid (order number), and payamount (order amount).
[0115] The query table containing the custname field is cust (customer table), and the query tables containing the orderid and payamount fields are ordr (order table).
[0116] S103. If the number of query tables is greater than or equal to 2, then the multiple query tables are divided into at least one pair of related tables according to the preset relationship information of the database.
[0117] Specifically, when there are at least two related table pairs, the at least two related table pairs can be associated into a virtual table. Each related table pair consists of two query tables, and / or consists of one query table and other data tables besides the query table.
[0118] By establishing relationships between multiple related table pairs, all related table pairs in the database can be directly or indirectly linked. In other words, by linking at least two related table pairs into a virtual table, it is easier to generate query statements and retrieve query results from the database.
[0119] If there is only one associated table pair, the query statement can be generated directly based on the two query tables in that associated table pair.
[0120] Specifically, predefined relationship information can be represented by the symbol <->. Specifically, the symbol <-> represents a bidirectional association, meaning that in the database, the field to the left of the symbol <-> can be used to find the field to the right of the symbol <->, and vice versa. For example, in the cust (customer table) mentioned above, the fields in this table have the following relationships:
[0121] The relationship between a customer's identifier (custid, i.e., a unique identifier for the customer) and their name (custname) is explained. In a data table, the customer's name can be found from the customer's identifier, and vice versa.
[0122] custid <-> custphone (customer's phone number) indicates that the customer identifier is associated with the customer's phone number.
[0123] custid<->custaddress (customer's address) indicates that the customer identifier is associated with the customer's address.
[0124] In the ORDROP (order table), the fields have the following relationships:
[0125] custid<->orderid indicates that the customer identifier is associated with the order number.
[0126] orderid<->ordertime indicates that the order number is associated with the order time.
[0127] orderid<->payamount indicates that the order number is associated with the order amount.
[0128] The relationship between the customer table and the order table is as follows:
[0129] `cust.custid <-> ordr.custid` indicates a relationship between a customer identifier in the customer table and a customer identifier in the order table. In the database, a customer identifier in the customer table can be used to find a customer identifier in the order table, and vice versa.
[0130] In other words, customer identifiers can be used to establish a relationship between the customer table and the order table. A relationship between fields can exist either because the two fields belong to the same data table, or because they correspond to the same meaning.
[0131] S104. Generate a query statement based on at least one related table pair and the query field, and retrieve the query result data from the database based on the query statement.
[0132] Specifically, after dividing multiple query tables into at least one join pair and linking all data tables in the database into a single virtual table using these join pairs, the server can generate a corresponding query statement based on the join pairs and query fields. Then, based on this query statement, it retrieves the query result data from the database to be populated into the SMS template.
[0133] In other words, the server can generate query statements from the database's preset relational information based on the query field information in the SMS template, such as query statements in Structured Query Language (SQL).
[0134] S105. Parse the query result data, determine the field data corresponding to the query field information from the query result data, and extract the field data.
[0135] Specifically, after obtaining the query results, the field data corresponding to the query field information in the SMS template can be extracted from the query results. First, the query results data can be parsed to determine its specific data structure. Then, the field data corresponding to the query field information can be found and extracted from the query results data.
[0136] S106. Validate the data format of the field data. If the data format is inconsistent with the preset format, convert the data format of the field data to the preset format to obtain the field data in the preset format.
[0137] Specifically, after extracting the field data, the server can further verify whether the extracted field data conforms to the preset data format. If the field data format is inconsistent with the preset format of the SMS template to be filled, the data format of the field data is converted to the preset format to obtain the field data in the preset format.
[0138] S107. Based on the second position of the query field information in the SMS template, replace the query field information in the SMS template with field data in a preset format to obtain the SMS content.
[0139] Specifically, the query field information is filled in the placeholders of the SMS template. By determining the first position of the placeholders in the SMS template, the second position of the query field information in the SMS template can be determined. Then, the SMS content can be automatically generated by replacing the query field information in the SMS template with field data in a preset format.
[0140] This embodiment provides a method for generating SMS messages, including: obtaining an SMS template; parsing the SMS template; identifying a target identifier from the SMS template to extract the target identifier; determining the first position of the target identifier in the SMS template; extracting query field information from the SMS template based on the target identifier and the first position; associating the second position of the query field information with the first position of the target identifier; obtaining at least one query field and a query table containing each query field from the query field information; if the number of query tables is greater than or equal to two, dividing the multiple query tables into at least one pair of related tables according to preset relationship information in the database; when there are at least two pairs of related tables, the at least two pairs of related tables can be associated into a virtual table, each pair of related tables consisting of two query tables, and... Alternatively, it consists of a query table and other data tables besides the query table. Preset relationship information is used to indicate the associations between fields and tables in the database. Based on at least one associated table pair and the query field, a query statement is generated, and query result data is retrieved from the database according to the query statement. The query result data is parsed to determine the field data corresponding to the query field information and extract the field data. The data format of the field data is validated; if the data format is inconsistent with the preset format, the data format of the field data is converted to the preset format to obtain the field data in the preset format. Based on the second position of the query field information in the SMS template, the query field information in the SMS template is replaced with the field data in the preset format to obtain the SMS content.The following technical effects were achieved: By leveraging the relationships between tables in the database, the usable data content in SMS templates was expanded, allowing all fields in the database to be used in the SMS templates, thus no longer being limited to reading data from the database based on predefined data items and parsing interfaces; by establishing relationships between multiple related table pairs, direct or indirect relationships could be formed between all related table pairs in the database. This means that by associating at least two related table pairs into a virtual table, it is easier to generate query statements and retrieve query results from the database; based on the query statement, data is dynamically read from the database. Even if the data structure in the database changes, the server can still accurately obtain query results based on the query statement through the relationships between the tables in the database, thus still being able to... The system correctly generates SMS messages. By leveraging the relationships between tables in the database, it supports more complex queries and data combinations. For example, it can generate more personalized and customized SMS content based on users' transaction history and preferences. By introducing query fields into the SMS template, the SMS content can be dynamically generated according to the actual situation, making the SMS template more flexible and adaptable to different data content without having to manually write static text for each possible SMS message. By filling the query fields into the placeholders in the SMS template, the system can flexibly reference data from the database as needed when writing the SMS template. This allows the generated SMS content to no longer be limited by predefined data items, thus overcoming the limitations of existing technologies in SMS generation and providing a more flexible and efficient solution for SMS communication.
[0141] Figure 2 A flowchart illustrating a method for generating text messages provided in this application embodiment. Figure 2 In one possible example, such as Figure 2 As shown, in this embodiment... Figure 1 Based on the example, further detailed explanations are provided on how to divide the related table pairs and how to generate query statements. For example... Figure 2 As shown, the method includes:
[0142] S201. Obtain the SMS template, parse the SMS template, identify the target identifier from the SMS template, extract the target identifier, determine the first position of the target identifier in the SMS template, and extract query field information from the SMS template based on the target identifier and the first position.
[0143] S202. Obtain at least one query field and the query table containing each query field from the query field information.
[0144] S201-S202 are similar to S101-S102, and will not be described again in this embodiment.
[0145] S203. If the number of query tables is greater than or equal to 2, then obtain at least one first associated table for each query table from the preset relation information.
[0146] Specifically, as shown in the above embodiments, if the customer table is used as the query table, then the order table can be the first associated table of the customer table.
[0147] If the database provides the parameters cust.custphone (the customer's phone number in the customer table) and ordr.ordertime (the order time in the order table), then the query fields are custname, orderid, payamount, custphone, and ordertime. By querying the field cust.custphone, each of these fields can be retrieved from the database. Specifically, using the relationship custphone<->custid, we can retrieve custid; then using custid<->custname, we can retrieve the custname field. Similarly, using cust.custid<->ordr.custid, we can find the order table from the customer table; then, in the order table, using custid<->orderid, we can find the orderid field; and finally, using orderid<->payamount, we can find the payamount field.
[0148] Alternatively, you can retrieve each query field from the database by querying the field information ordertime. The method is similar to finding each query field by querying the field information cust.custphone, so it will not be described in detail here.
[0149] Furthermore, Figure 3 This is a schematic diagram illustrating the relationship between fields provided in an embodiment of this application. For example... Figure 3 As shown, the database includes three tables: Table 1, Table 2, and Table 3. Table 1 contains fields 11, 12, 13, 14, and 15, and these fields are interconnected. Table 2 contains fields 21, 23, 24, and 25, and these fields are also interconnected. Table 3 contains fields 31, 32, 33, 34, and 15, and these fields are also interconnected. Furthermore, field 11 in Table 1 is interconnected with field 11 in Table 2, and field 15 in Table 1 is interconnected with field 15 in Table 3.
[0150] If Table 1 is used as the query table, then both Table 2 and Table 3 can be the first associated table of Table 1; if Table 2 and Table 3 are used as the query tables, then Table 1 is the first associated table of both Table 2 and Table 3.
[0151] If the field to be queried is field 33, and the provided parameter is field 25, then we can first determine that the query tables are Table 3 and Table 2. Then, based on the preset relationship information—that field 15 in Table 1 and field 15 in Table 3 are related—we determine that the first associated table for querying Table 3 is Table 1. Simultaneously, based on the preset relationship information—that field 11 in Table 1 and field 11 in Table 2 are related—we determine that the first associated table for querying Table 2 is Table 1. Since there are relationships between the fields in Table 1, field 15 and field 11 in Table 1 are related. Therefore, based on the provided query field 25, we can determine the path to find query field 33.
[0152] S204. Determine at least one first association group from multiple query tables based on each first association table.
[0153] In this embodiment, each first association group is one of the following: a single query table, a table pair, or a table group. A single query table does not exist in the first association table of any query table. In a table pair, one query table is the first association table of the other query table in the pair. In a table group, the first association table is the same first association table of the two query tables in the group. For example, in the above embodiment, the query tables are Table 2 and Table 3. Since Table 1 is the first association table of both Table 2 and Table 3, Table 1, Table 2, and Table 3 form a table group.
[0154] S205. Treat each table pair as a related table pair, and split each table group into two related table pairs.
[0155] Specifically, extracting associated table pairs from at least one first association group includes: treating each table pair directly as an associated table pair; and splitting each table group into two associated table pairs, each of which consists of a query table and a separate data table. For example, in the above embodiment, the query tables are Table 2 and Table 3. Splitting the table group consisting of Table 1, Table 2, and Table 3 into two associated table pairs results in one associated table pair consisting of Table 1 and Table 2, and the other associated table pair consisting of Table 1 and Table 3.
[0156] S206. Set the first association group as the current association group.
[0157] Specifically, the first association group is used as the current association group, and the relationship iteration process is executed multiple times. This facilitates the extraction of multiple association table pairs from the database that are directly or indirectly related to the queried fields.
[0158] S207. Combine at least two current associations that include the same data table into a second association group.
[0159] Specifically, the relation iteration process includes: if there are at least two current association groups in the database that include the same data table, then the current association groups that include the same data table will be merged into a second association group.
[0160] S208. If a second association group exists, stop extracting the association table pairs.
[0161] Specifically, if there is only one second association group, since at least two current groups that are merged into the second association group include the same data table, the association table pairs have already been extracted between all the data tables with related relationships in the second association group, and a direct or indirect relationship has been established. Therefore, there is no need to extract the association table pairs again.
[0162] S209. If there are multiple second association groups, determine at least one second association table for each data table in each second association group, and determine at least one third association group from the multiple second association groups based on each second association table, and take the third association group as the current association group.
[0163] In this embodiment of the application, each third association group is one of the following: a single second association group, a pair, or a group. The first data table of one second association group in a pair is the second association table of the second data table of another second association group in the pair. The second association table in a group is the same second association table of the third data tables of the two second association groups in the group.
[0164] Specifically, a data table in a single second association group does not exist in the second association tables of any other data tables in any other second association group. In a pair of second association groups, the first data table in one second association group is the second association table of the second data table in the other second association group. For example, suppose a pair includes second association group A and second association group B. If a data table c in second association group A is the second association table of a data table d in second association group B, then data table c is the first data table, and data table d is the second data table.
[0165] To understand the concept of a group, this implementation assumes that the group includes a second association group E, a second association group F, and a second association table g. The second association table g is the second association table shared by data table e in the second association group E and data table f in the second association group F. The third data table refers to data table e and data table f.
[0166] The existence of multiple second association groups means that the number of second association groups is greater than or equal to 2.
[0167] S210. Treat the first data table and the second data table as a pair of related tables, and generate two pairs of related tables based on the third data table of the two second related groups in the group and the same second related table.
[0168] Specifically, the process of extracting association table pairs based on the second association table includes: forming an association table pair by combining the first and second data tables with a direct relationship in the group pair; and forming association table pairs by combining the third data tables of the two second association groups in the group with the second association table in the group, respectively.
[0169] After extracting the association table pairs, the process returns to step S207. Since the third association group was already used as the current association group in step S209, the current association group in the returned step S207 refers to the third association group. The process continues to merge at least two current association groups that include the same data table into a second association group. Then, the number of second association groups is determined. If there are multiple second association groups, the relationship iteration steps S207-S210 are executed multiple times until there is only one second association group, at which point the extraction of association table pairs stops.
[0170] S211. Parse the preset relationship information to obtain the relationship between the two data tables in the association table pair.
[0171] Specifically, the server extracts all the related table pairs from the database, and then associates all the related table pairs into a virtual table. It can then further read the preset relationship information stored in the database and parse out the relationship between the two data tables in the related table pair.
[0172] S212. Based on the association relationship, determine the association fields between the two data tables in the association table pair.
[0173] Specifically, the server can determine the related fields between two tables based on their relationship. These related fields can be fields with the same meaning in both tables, or they can be a primary key field in one table and a foreign key field in the other.
[0174] S213. Generate a query statement based on the query fields, related fields, and related table pairs.
[0175] Specifically, query fields are typically data columns that the user expects to retrieve from the database. These fields can come from a single table or from multiple tables connected by relationships. The server selects the relevant table pairs to join based on the tables containing the query fields and the relationship fields between them. Then, using the join clauses and related fields, the server constructs the SQL query statement's join clause and select clauses to specify the query fields, thereby generating a complete query statement.
[0176] S214. Optimize query statements by creating composite indexes.
[0177] Specifically, after generating the query statement, the server can further check its correctness, such as ensuring the SQL statement's syntax is correct to avoid query failures due to syntax errors, and ensuring the generated query statement can be executed correctly. It also verifies whether the query logic meets expectations, ensuring there are no redundant table joins or unnecessary field joins, and ensuring that the select clause contains only the necessary query fields to reduce data transfer volume and processing time. In one possible implementation, to improve query efficiency for multiple query fields, a composite index can be created in the query statement by selecting an appropriate column order to further optimize the query statement.
[0178] S215. Obtain the query result data from the database based on the query statement.
[0179] S216. Parse the query result data, determine the field data corresponding to the query field information from the query result data, and extract the field data.
[0180] S217. Validate the data format of the field data. If the data format is inconsistent with the preset format, convert the data format of the field data to the preset format to obtain the field data in the preset format.
[0181] S218. Based on the second position of the query field information in the SMS template, replace the query field information in the SMS template with field data in a preset format to obtain the SMS content.
[0182] S215-S218 are similar to S104-S107, and the parts with the same content will not be described again in this embodiment.
[0183] The SMS generation method provided in this application optimizes the query statement by checking its correctness and creating a composite index after generating the query statement. This ensures that the generated query statement is not only correct but also optimized in performance, thereby improving the efficiency and response speed of database queries, and thus improving the efficiency and accuracy of SMS generation.
[0184] In this embodiment of the invention, electronic devices or main control devices can be divided into functional modules according to the above method examples. For example, each function can be divided into its own functional modules, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or as a software functional module. It should be noted that the module division in this embodiment of the invention is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0185] Figure 4 This is a schematic diagram of a text message generation device provided in an embodiment of this application. Figure 4 As shown, the SMS generation device includes: an acquisition module 410, a query table module 420, a relational table pair module 430, a query module 440, an extraction module 450, a format conversion module 460, and a replacement module 470.
[0186] The acquisition module 410 is used to acquire the SMS template, parse the SMS template, identify the target identifier from the SMS template, extract the target identifier, determine the first position of the target identifier in the SMS template, and extract query field information from the SMS template based on the target identifier and the first position. The second position of the query field information is associated with the first position of the target identifier.
[0187] The query table module 420 is used to obtain at least one query field and the query table containing each query field from the query field information;
[0188] The association table pair module 430 is used to divide multiple query tables into at least one association table pair according to the preset relationship information of the database if the number of query tables is greater than or equal to 2. When there are at least two association table pairs, the at least two association table pairs can be associated into a virtual table. Each association table pair consists of two query tables, and / or consists of one query table and other data tables other than one query table. The preset relationship information is used to indicate the association relationship between fields and tables in the database.
[0189] The query module 440 is used to generate a query statement based on at least one related table pair and a query field, and to retrieve query result data from the database based on the query statement;
[0190] The extraction module 450 is used to parse the query result data, determine the field data corresponding to the query field information from the query result data, and extract the field data.
[0191] The format conversion module 460 is used to validate the data format of the field data. If the data format is inconsistent with the preset format, the data format of the field data is converted to the preset format to obtain the field data in the preset format.
[0192] The replacement module 470 is used to replace the query field information in the SMS template with field data in a preset format based on the second position of the query field information in the SMS template, so as to obtain the SMS content.
[0193] In one possible design, the association table pair module 430 includes: a first association table module, a first association group module, and an association table pair module;
[0194] The first association table module is used to obtain at least one first association table for each query table from the preset relationship information;
[0195] The first association group module is used to determine at least one first association group from multiple query tables based on each first association table. Each first association group is one of the following: a single query table, a table pair, or a table group. A single query table does not exist in the first association table of any query table. One query table in a table pair is the first association table of the other query table in the table pair. The first association table in a table group is the same first association table of the two query tables in the table group.
[0196] The module for extracting association table pairs is used to extract association table pairs from at least one first association group.
[0197] In one possible design, the module for extracting association table pairs includes: a first confirmation module and an iteration module; wherein the iteration module includes: a second association group module, a stop extraction module, a third association group module, and a second confirmation module;
[0198] The first confirmation module is used to treat each table pair as a related table pair and split each table group into two related table pairs;
[0199] The iteration module is used to take the first association group as the current association group and execute the relationship iteration process multiple times:
[0200] The second association group module is used to combine at least two current association groups that include the same data table into a second association group;
[0201] The Stop Extraction module is used to stop extracting the associated table pairs if a second associated group exists.
[0202] The third association group module is used to determine at least one second association table of each data table in each second association group if multiple second association groups exist, and to determine at least one third association group from the multiple second association groups based on each second association table, and to take the third association group as the current association group. Each third association group is one of the following: a single second association group, a pair, or a group. The first data table of one second association group in a pair is the second association table of the second data table of another second association group in the pair. The second association table in a group is the same second association table of the third data tables of the two second association groups in the group.
[0203] The second confirmation module is used to treat the first data table and the second data table as a pair of related tables, and to generate two pairs of related tables based on the third data table of the two second related groups in the group and the same second related table.
[0204] In one possible design, the query module 440 includes: a parsing module, a related field module, and a query statement module;
[0205] The parsing module is used to parse the preset relationship information to obtain the relationship between the two data tables in the association table pair;
[0206] The Association Fields module is used to determine the association fields between two data tables in an association table pair based on the association relationship.
[0207] The query statement module is used to generate query statements based on the query fields, related fields, and related table pairs.
[0208] In one possible design, the SMS generation device further includes: an optimization module.
[0209] The optimization module is used to optimize query statements by creating composite indexes.
[0210] In one possible design, the SMS generation device further includes a display module, a receiving module, and a first generation module;
[0211] The display module is used to display preset relationship information;
[0212] The receiving module is used to receive the query field information selected by the user in the preset relationship information;
[0213] The first generation module is used to generate SMS templates based on the query field information.
[0214] In one possible design, the first generation module includes: an input module and a second generation module;
[0215] The input module is used to receive text information input by the user, including the insertion position of the query field information;
[0216] The second generation module is used to generate SMS templates based on text information and query field information.
[0217] The SMS generation device provided in this embodiment can execute an SMS generation method of the above embodiment. Its implementation principle and technical effect are similar, and will not be described again here.
[0218] In a specific implementation of the aforementioned SMS generation device, each module can be implemented as a processor. The processor can execute computer execution instructions stored in the memory, thereby enabling the processor to execute the aforementioned SMS generation method.
[0219] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device includes at least one processor 510 and a memory 520. The electronic device also includes a communication component 530. The processor 510, memory 520, and communication component 530 are connected via a bus 540.
[0220] In the specific implementation process, at least one processor 510 executes computer execution instructions stored in memory 520, causing at least one processor 510 to execute a text message generation method as executed on the electronic device side.
[0221] The specific implementation process of processor 510 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0222] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0223] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage.
[0224] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0225] The above description of the functions implemented by electronic devices and main control devices has introduced the solutions provided by the embodiments of the present invention. It is understood that, in order to implement the above functions, the electronic device or main control device includes hardware structures and / or software modules corresponding to the execution of each function. By combining the units and algorithm steps of the various examples described in the embodiments of the present invention, the embodiments of the present invention can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the technical solutions of the embodiments of the present invention.
[0226] This application also provides a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are run on a computer, the computer executes the technical solution of the SMS generation method described above.
[0227] This application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium, and when the at least one processor executes the computer program, it can implement the technical solution of the SMS generation method in the above embodiments.
[0228] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.
[0229] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to implement the solution of this embodiment according to actual needs.
[0230] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The unit composed of the above modules can be implemented in hardware or in the form of hardware plus software functional units.
[0231] The integrated modules described above, implemented as software functional modules, can be stored in a computer-readable storage medium. These software functional modules, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods of the various embodiments of this application.
[0232] The aforementioned storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0233] An exemplary storage medium is coupled to a processor, enabling the processor to read information from and write information to the storage medium. Alternatively, the storage medium can be an integral part of the processor. The processor and storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and storage medium can exist as discrete components in an electronic control unit or main control device.
[0234] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0235] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method of short message generation, characterized by, The method comprises the following steps: acquiring a short message template, parsing the short message template, identifying a target identifier from the short message template to extract the target identifier, determining a first position of the target identifier in the short message template, and extracting query field information from the short message template according to the target identifier and the first position, wherein a second position of the query field information is associated with the first position of the target identifier; acquiring at least one query field and a query table in which each query field is located from the query field information; if the number of the query tables is greater than or equal to 2, dividing a plurality of the query tables into at least one associated table pair according to preset relationship information of a database, when there are at least two associated table pairs, the at least two associated table pairs can be associated into a virtual table, each associated table pair is composed of two query tables, and / or is composed of one query table and other data tables other than the one query table, and the preset relationship information is used to indicate the association relationship between fields and tables in the database; generating a query statement according to the at least one associated table pair and the query field, and querying the database to obtain query result data according to the query statement; parsing the query result data, determining field data corresponding to the query field information from the query result data, and extracting the field data; checking the data format of the field data, converting the data format of the field data into a preset format when the data format is inconsistent with the preset format, and obtaining field data in the preset format; replacing the query field information in the short message template with the field data in the preset format according to the second position of the query field information in the short message template, and obtaining short message content.
2. The method of claim 1, wherein, The method of dividing a plurality of the query tables into at least one associated table pair according to preset relationship information of a database comprises the following steps: acquiring at least one first associated table of each query table from the preset relationship information; determining at least one first associated group from a plurality of the query tables according to each first associated table, wherein each first associated group is one of the following: a single query table, a table pair, and a table group, the single query table does not exist in the first associated table of any one of the query tables, one query table in the table pair is the first associated table of another query table in the table pair, and the first associated table in the table group is the same first associated table of two query tables in the table group; extracting the associated table pair from at least one first associated group.
3. The method of claim 2, wherein, The method of extracting the associated table pair from at least one first associated group comprises the following steps: regarding each table pair as one associated table pair, and splitting each table group into two associated table pairs; regarding the first associated group as a current associated group, and performing a relationship iteration process multiple times: merging at least two current associated groups including the same data table into a second associated group; if there is one second associated group, stopping extracting the associated table pair; If there are multiple second association groups, at least one second association table of each data table in each second association group is determined, at least one third association group is determined from the multiple second association groups according to the second association tables, and the third association group is taken as the current association group, each third association group being one of a single second association group, a pair of second association groups, a group of second association groups, a first data table of one second association group in the pair being a second association table of a second data table of the other second association group in the pair, and a second association table in the group being a same second association table of third data tables of two second association groups in the group; The first data table and the second data table are taken as one association table pair, and two association table pairs are generated according to the third data tables of the two second association groups in the group and the same second association table.
4. The method of claim 3, wherein, The generating of the query statement according to the at least one association table pair and the query field includes: The preset relationship information is parsed to obtain an association relationship between two data tables in the association table pair; The association fields between the two data tables in the association table pair are determined according to the association relationship; The query statement is generated according to the query field, the association fields, and the association table pair.
5. The method of claim 4, wherein, After the query statement is generated, the method further includes: The query statement is optimized by creating a composite index.
6. The method according to any one of claims 1 to 5, characterized in that, The generation process of the short message template includes: The preset relationship information is displayed; Query field information selected by a user in the preset relationship information is received; The short message template is generated according to the query field information.
7. The method of claim 6, wherein, The generation of the short message template according to the query field information includes: Text information input by the user is received, the text information including an insertion position of the query field information, the insertion position being the second position; The short message template is generated according to the text information and the query field information.
8. A short message generating apparatus characterized by comprising: It includes: An acquisition module is configured to acquire a short message template, parse the short message template, identify a target identifier from the short message template, extract the target identifier, determine a first position of the target identifier in the short message template, and extract query field information from the short message template according to the target identifier and the first position, a second position of the query field information being associated with the first position of the target identifier; A query table module is configured to acquire at least one query field and a query table in which each query field is located from the query field information; An association table pair module is configured to divide multiple query tables into at least one association table pair according to preset relationship information of a database if the number of the query tables is greater than or equal to 2, at least two association table pairs being able to be associated into a virtual table when there are at least two association table pairs, each association table pair being composed of two query tables and / or one query table and other data tables other than the query table, and the preset relationship information being used to indicate an association relationship between fields and tables in the database. The query module is configured to generate a query statement according to the at least one association table and the query field, and query result data from the database according to the query statement; The extraction module is configured to parse the query result data, determine field data corresponding to the query field information from the query result data, and extract the field data; The format conversion module is configured to check a data format of the field data, convert the data format of the field data into a preset format when the data format is inconsistent with the preset format, and obtain field data in the preset format; The replacement module is configured to replace the query field information in the SMS template with the field data in the preset format according to a second position of the query field information in the SMS template, and obtain SMS content.
9. An electronic device, comprising: Comprise: A processor, and a memory connected with the processor in communication; The memory stores computer execution instructions; The processor executes the computer execution instructions stored in the memory to implement the method of any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to implement the method of any one of claims 1-7.
11. A computer program product, characterised in that, A computer program is executed by the processor to implement the method of any one of claims 1-7.
Citation Information
Patent Citations
SQL statement generation method and system oriented to medical data and medium
CN117609277A
Push message generation method and device, equipment, storage medium and program product
CN118200394A