Method and device for determining message turns

文档序号:1940014 发布日期:2021-12-07 浏览:10次 中文

阅读说明:本技术 消息轮次的确定方法和装置 (Method and device for determining message turns ) 是由 柴进 于 2020-09-29 设计创作,主要内容包括:本申请实施例提供了一种消息轮次的确定方法和装置,在获取到第一消息和第一消息的发送时间后,先确定第一消息对应的会话记录中的消息数量;并在会话记录中的消息数量大于预设阈值时,根据第一消息的发送时间和会话记录中最后一条消息的发送时间,判断第一消息是否为会话记录中的最新消息;并根据判断结果确定当前会话中的消息轮次,使得在统计当前会话中的消息轮次时,提高了统计出的消息轮次的准确度。(The embodiment of the application provides a method and a device for determining message turns, wherein after a first message and sending time of the first message are obtained, the number of messages in a session record corresponding to the first message is determined; when the number of the messages in the session record is larger than a preset threshold value, judging whether the first message is the latest message in the session record according to the sending time of the first message and the sending time of the last message in the session record; and determining the message turn in the current session according to the judgment result, so that the accuracy of the counted message turn is improved when the message turn in the current session is counted.)

1. A method for determining a message turn, comprising:

acquiring a first message and the sending time of the first message;

determining the number of messages in the session record corresponding to the first message;

if the number of the messages in the session record is larger than a preset threshold value, judging whether the first message is the latest message in the session record according to the sending time of the first message and the sending time of the last message in the session record;

and determining the message turn in the current session according to the judgment result.

2. The method of claim 1, wherein determining the turn of messages in the current session according to the determination result comprises:

and if the first message is the latest message in the session record, determining the message turn in the current session according to the user identifier to which the first message belongs and the user identifier to which the last message belongs in the session record.

3. The method of claim 2, wherein the determining the turn of messages in the current session according to the user identifier to which the first message belongs and the user identifier to which the last message in the session record belongs comprises:

and if the user identifier to which the first message belongs indicates that the user to which the first message belongs is a consultant user and the user identifier to which the last message belongs indicates that the user to which the last message belongs is a consulted user, updating the message turn in the current session.

4. The method of claim 1, wherein determining the turn of messages in the current session according to the determination result comprises:

if the first message is not the latest message in the session record, judging whether the first message exists in the session record;

if the first message does not exist in the session record, determining the context message of the first message in the session record according to the message identifier of the first message;

and determining the message turn in the current session according to the context message of the first message in the session record.

5. The method of claim 4, wherein the context message comprises a previous message immediately preceding the first message and a subsequent message immediately succeeding the first message, and wherein determining the turn of messages in the current session according to the context message recorded in the session by the first message comprises:

and if the user identification to which the previous message belongs is the same as the user identification to which the next message belongs and is different from the user identification to which the first message belongs, updating the message turn in the current session.

6. The method according to any one of claims 1-5, further comprising:

determining the remaining message turns in the current conversation according to the allowed maximum message turns and the message turns in the current conversation;

and if the remaining message turns are 0, controlling to close the current session.

7. The method of any of claims 1-5, wherein obtaining the first message comprises:

acquiring a distributed lock;

and acquiring the first message through the distributed lock control.

8. An apparatus for determining a message turn, comprising:

the device comprises an acquisition unit, a sending unit and a processing unit, wherein the acquisition unit is used for acquiring a first message and the sending time of the first message;

the processing unit is used for determining the number of messages in the session record corresponding to the first message; if the number of the messages in the session record is larger than a preset threshold value, judging whether the first message is the latest message in the session record according to the sending time of the first message and the sending time of the last message in the session record; and determining the message turn in the current session according to the judgment result.

9. The apparatus of claim 8,

the processing unit is specifically configured to determine, if the first message is the latest message in the session record, a message turn in the current session according to the user identifier to which the first message belongs and the user identifier to which the last message in the session record belongs.

10. The apparatus of claim 9,

the processing unit is specifically configured to update the message turn in the current session if the user identifier to which the first message belongs indicates that the user to which the first message belongs is the consulting user, and the user identifier to which the last message belongs indicates that the user to which the last message belongs is the consulted user.

11. The apparatus of claim 8,

the processing unit is specifically configured to determine whether the first message exists in the session record if the first message is not the latest message in the session record; if the first message does not exist in the session record, determining the context message of the first message in the session record according to the message identifier of the first message; and determining the message turn in the current session according to the context message of the first message in the session record.

12. The apparatus according to claim 11, wherein the context message includes a previous message immediately preceding the first message and a subsequent message immediately succeeding the first message, and the processing unit is specifically configured to update the message turn in the current session if the user identifier to which the previous message belongs and the user identifier to which the subsequent message belongs are the same and different from the user identifier to which the first message belongs.

13. The apparatus according to any one of claims 8 to 12,

the processing unit is further configured to determine a remaining message turn in the current session according to the allowed maximum message turn and the message turn in the current session; and if the remaining message turns are 0, controlling to close the current session.

14. The apparatus according to any one of claims 8 to 12,

the acquiring unit is specifically used for acquiring the distributed lock; and acquiring the first message through the distributed lock control.

15. An apparatus for determining a turn of messages, comprising a memory and a processor; wherein the content of the first and second substances,

the memory for storing a computer program;

the processor is configured to read the computer program stored in the memory, and execute the message round determination method according to any one of claims 1 to 7 according to the computer program in the memory.

16. A computer-readable storage medium having computer-executable instructions stored thereon, which when executed by a processor, implement the method for determining a message turn according to any one of claims 1 to 7.

Technical Field

The present invention relates to the field of data processing technologies, and in particular, to a method and an apparatus for determining a message turn.

Background

In some internet communication scenarios, such as a healthy internet hospital, a doctor may communicate with a patient online to provide online assistance to the patient. Because the doctor and the patient can only communicate for a limited number of times due to the limitation of conditions, the message rounds of the communication between the doctor and the patient need to be counted. Wherein, when the doctor asks a question and the patient answers, the communication between the doctor and the patient can be recorded as a message turn.

When the message round counting is carried out, the messages communicated between the doctor and the patient need to be acquired firstly. Due to the influence of the service architecture, the acquired messages are not arranged according to the order of the communication time, but are arranged out of order according to the communication time. In the prior art, when counting the message round of communication between a doctor and a patient based on the messages in the communication time disorder arrangement, the messages in the communication time disorder arrangement are sequenced through a database, whether the current message and the previous message are sent by the same person is judged, and if the current message and the previous message are not sent by the same person, the current message and the previous message are determined as a round.

However, with the existing method, the message round cannot be accurately counted, so that the accuracy of the counted message round is low.

Disclosure of Invention

The embodiment of the invention provides a method and a device for determining a message round, which improve the accuracy of the counted message round.

In a first aspect, an embodiment of the present application provides a method for determining a message turn, where the method for determining a message turn may include:

acquiring a first message and the sending time of the first message.

And determining the number of the messages in the session record corresponding to the first message.

If the number of the messages in the session record is larger than a preset threshold value, judging whether the first message is the latest message in the session record according to the sending time of the first message and the sending time of the last message in the session record.

And determining the message turn in the current session according to the judgment result.

In a possible implementation manner, the determining, according to the determination result, the message turn in the current session includes:

and if the first message is the latest message in the session record, determining the message turn in the current session according to the user identifier to which the first message belongs and the user identifier to which the last message belongs in the session record.

In a possible implementation manner, the determining, according to the user identifier to which the first message belongs and the user identifier to which the last message in the session record belongs, the message turn in the current session includes:

and if the user identifier to which the first message belongs indicates that the user to which the first message belongs is a consultant user and the user identifier to which the last message belongs indicates that the user to which the last message belongs is a consulted user, updating the message turn in the current session.

In a possible implementation manner, the determining, according to the determination result, the message turn in the current session includes:

and if the first message is not the latest message in the session record, judging whether the first message exists in the session record.

And if the first message does not exist in the session record, determining the context message of the first message in the session record according to the message identifier of the first message.

And determining the message turn in the current session according to the context message of the first message in the session record.

In a possible implementation manner, the determining, according to the context message recorded in the session by the first message, the turn of messages in the current session according to the context message recorded in the session record includes:

and if the user identification to which the previous message belongs is the same as the user identification to which the next message belongs and is different from the user identification to which the first message belongs, updating the message turn in the current session.

In one possible implementation, the method further includes:

and determining the remaining message turns in the current conversation according to the allowed maximum message turns and the message turns in the current conversation.

And if the remaining message turns are 0, controlling to close the current session.

In one possible implementation manner, the obtaining the first message includes:

a distributed lock is acquired.

And acquiring the first message through the distributed lock control.

In a second aspect, an embodiment of the present application further provides a device for determining a message turn, where the device for determining a message turn may include:

the device comprises an acquisition unit, a sending unit and a sending unit, wherein the acquisition unit is used for acquiring a first message and the sending time of the first message.

The processing unit is used for determining the number of messages in the session record corresponding to the first message; if the number of the messages in the session record is larger than a preset threshold value, judging whether the first message is the latest message in the session record according to the sending time of the first message and the sending time of the last message in the session record; and determining the message turn in the current session according to the judgment result.

In a possible implementation manner, the processing unit is specifically configured to determine, if the first message is a latest message in the session record, a message turn in a current session according to a user identifier to which the first message belongs and a user identifier to which a last message in the session record belongs.

In a possible implementation manner, the processing unit is specifically configured to update the message turn in the current session if the user identifier to which the first message belongs indicates that the user to which the first message belongs is the consulting user, and the user identifier to which the last message belongs indicates that the user to which the last message belongs is the consulted user.

In a possible implementation manner, the processing unit is specifically configured to determine whether the first message exists in the session record if the first message is not a latest message in the session record; if the first message does not exist in the session record, determining the context message of the first message in the session record according to the message identifier of the first message; and determining the message turn in the current session according to the context message of the first message in the session record.

In a possible implementation manner, the context message includes a previous message immediately adjacent to the first message and a next message immediately adjacent to the first message, and the processing unit is specifically configured to update the message turn in the current session if a user identifier to which the previous message belongs is the same as a user identifier to which the next message belongs and is different from the user identifier to which the first message belongs.

In a possible implementation manner, the processing unit is further configured to determine a remaining message turn in the current session according to the allowed maximum message turn and the message turn in the current session; and if the remaining message turns are 0, controlling to close the current session.

In a possible implementation manner, the obtaining unit is specifically configured to obtain a distributed lock; and acquiring the first message through the distributed lock control.

In a third aspect, an embodiment of the present application further provides a device for determining a message turn, where the device for determining a message turn may include a memory and a processor; wherein the content of the first and second substances,

the memory for storing a computer program;

the processor is configured to read the computer program stored in the memory, and execute the method for determining the message round in any one of the possible implementation manners of the first aspect according to the computer program in the memory.

In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, where a computer-executable instruction is stored in the computer-readable storage medium, and when a processor executes the computer-executable instruction, the method for determining a message turn in any one of the possible implementation manners of the first aspect is implemented.

Therefore, according to the method and the device for determining the message turns provided by the embodiment of the application, after the first message and the sending time of the first message are obtained, the number of messages in the session record corresponding to the first message is determined; judging whether the first message is the latest message in the session record or not according to the sending time of the first message and the sending time of the last message in the session record when the number of the messages in the session record is larger than a preset threshold value; and determining the message turn in the current session according to the judgment result, so that the accuracy of the counted message turn is improved when the message turn in the current session is counted.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.

Fig. 1 is a schematic diagram of an application scenario provided in an embodiment of the present application;

fig. 2 is a flowchart illustrating a method for determining a message turn according to an embodiment of the present application;

fig. 3 is a flowchart illustrating another method for determining a message turn according to an embodiment of the present application;

fig. 4 is a schematic structural diagram of an apparatus for determining a message turn according to an embodiment of the present application;

fig. 5 is a schematic structural diagram of a device for determining a message turn according to an embodiment of the present invention.

With the foregoing drawings in mind, certain embodiments of the disclosure have been shown and described in more detail below. These drawings and written description are not intended to limit the scope of the disclosed concepts in any way, but rather to illustrate the concepts of the disclosure to those skilled in the art by reference to specific embodiments.

Detailed Description

Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.

In the embodiments of the present invention, "at least one" means one or more, "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone, wherein A and B can be singular or plural. In the description of the present invention, the character "/" generally indicates that the former and latter associated objects are in an "or" relationship.

The method for determining the message turn can be applied to internet communication scenes, such as healthy internet hospitals. In a health internet hospital, a doctor can communicate with a patient on-line, thereby providing on-line help to the patient. For example, as shown in fig. 1, fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application, a doctor and a patient may communicate in advance, after acquiring an input message, a terminal sends the message to a device for determining a message turn, such as a server, and the server determines the message turn included in a current session according to the acquired message. When the server counts the message turns, due to the influence of the service architecture, the messages acquired by the server are not arranged according to the exchange time sequence, but are arranged out of order. In the prior art, when counting the message round of communication between a doctor and a patient based on the messages in the communication time disorder arrangement, the messages in the communication time disorder arrangement are sequenced through a database, whether the current message and the previous message are sent by the same person is judged, and if the current message and the previous message are not sent by the same person, the current message and the previous message are determined as a round. However, with the existing method, the message round cannot be accurately counted, so that the accuracy of the counted message round is low.

Assume that the communication between the doctor and the patient is: message 1, doctor ask questions: you get a question of what question you have to consult; message 2, patient answer: i recently slept poorly; message 3, doctor asks question again: your last few hours of sleep? Message 4, the patient answers again: for essentially 5 hours. Based on the communication between the doctor and the patient, under normal conditions, the message sequence that the server should acquire is as follows: message 1, message 2, message 3 and message 4, it can be seen that this exchange includes 2 message rounds; but is affected by the service architecture, so that the acquired messages are not arranged in the order of exchange time, but are arranged out of order, for example, message 1, message 3, message 2 and message 4, or message 1, message 2, message 4 and message 3 are possible. Assuming that the obtained messages are message 1, message 3, message 2 and message 4, when the message round included in the current communication is determined by adopting the scheme in the prior art, when the message 3 is obtained, because the user to which the message 3 belongs and the previous message, namely the user to which the message 1 belongs are both doctors and are the same user, the same user is not counted as a message round; when the message 2 is obtained, the user to which the message 2 belongs and the previous message, namely the user to which the message 3 belongs, are not the same user, and can count as a message turn; when the message 4 is obtained, since the user to which the message 4 belongs and the previous message, that is, the same user to which the message 2 belongs, are not counted as one message turn, it can be seen that, by adopting the scheme of the prior art, the message turn cannot be accurately counted, so that the accuracy of the counted message turn is low.

In order to effectively and accurately count the message round and improve the accuracy of the counted message round, an easily conceivable technical scheme is as follows: although the obtained messages are not arranged according to the exchange time sequence due to the influence of the service architecture, the identifiers of the messages are correct, so that when the message turns are counted, the messages of the session can be sorted according to the identifiers of the messages, and then the message turns of the session are counted based on the sorted messages. By adopting the scheme, although the message round can be counted more accurately, the message round can be executed only when all messages of the session are acquired, so that the counting of the message round is delayed.

Based on the above description, in order to effectively and accurately count the message round and thus improve the accuracy of the counted message round, the embodiment of the present application provides a method for determining the message round, where after the first message and the sending time of the first message are obtained, the number of messages in the session record corresponding to the first message is determined first; if the number of the messages in the session record is larger than a preset threshold value, judging whether the first message is the latest message in the session record according to the sending time of the first message and the sending time of the last message in the session record; and determining the message turn in the current session according to the judgment result. For example, the preset threshold may be 0, or may be other values, and may be specifically set according to actual needs. In the embodiment of the present application, the preset threshold is only illustrated as 0, but the embodiment of the present application is not limited thereto.

Therefore, in the embodiment of the application, when counting the message turns, the number of messages in the session record corresponding to the first message is determined; judging whether the first message is the latest message in the session record or not according to the sending time of the first message and the sending time of the last message in the session record when the number of the messages in the session record is larger than a preset threshold value; and determining the message turn in the current session according to the judgment result, thereby improving the accuracy of the counted message turn. In addition, by adopting the technical scheme of the application, after the method is applied to the actual communication service, the interface response speeds of the message round calculation and the message round inquiry reach the millisecond level, so that the message round can be accurately counted under the scene of a large number of disordered messages, the current message round can be checked in real time, and a control basis is provided for the conversation of a healthy internet hospital platform.

It can be understood that, in the embodiment of the present application, when the first message is the latest message, if the user to which the first message belongs is the consultant, for example, the patient, and the user to which the last message in the session record belongs is the consulted party, for example, the doctor, the first message and the last message in the session record constitute a message turn; when the first message is not the latest message and already exists in the session record, if the user identifier to which the message immediately before the first message belongs is the same as the user identifier to which the message immediately after the first message belongs, that is, the users to which the two messages belong are the same user, such as a doctor or a patient, and are different from the user identifier to which the first message belongs, the user to which the first message, the message immediately before the first message belongs, and the message immediately after the first message constitute a message turn.

After fully understanding the concept of the round, the following describes in detail the determination method of the message round provided by the embodiments of the present application through several specific embodiments. It is understood that, in the embodiments of the present application, the following specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. The following describes in detail a method for determining a message turn provided in an embodiment of the present application with reference to the accompanying drawings.

Fig. 2 is a flowchart illustrating a method for determining a message turn according to an embodiment of the present disclosure, where the method for determining a message turn may be executed by software and/or a hardware device, for example, the hardware device may be a server. For example, referring to fig. 2, the method for determining the message turn may include:

s201, acquiring the first message and the sending time of the first message.

It can be understood that, in the embodiment of the present application, in addition to obtaining the first message and the sending time of the first message, the user identifier to which the first message belongs and the identifier of the first message may also be obtained; the user identifier is used to indicate a user to which the first message belongs, and the identifier of the first message is used to identify the sequence of the messages, so that the obtained messages are not arranged according to the exchange time sequence, but the identifier of the messages is always correct, although the sequence is influenced by the service architecture.

For example, when a first message is acquired, two pieces of information may be acquired at the same time due to a network or the like, and the two pieces of information may be recorded as the first message and the plus + of the first message, because the first message and the plus + of the first message are received at the same time, an operation of acquiring a distributed lock may be performed in time, the first message is acquired first through the distributed lock, the first message is acquired successfully, and the plus + of the first message is not acquired; in this case, the message turn may be further determined, and the first message plus + enters a wait state. The distributed lock can be understood as providing a global lock mechanism through external components such as redis, and each server under the distributed state can avoid concurrent task competition under the distributed state by acquiring a unique external lock, so that the problem that dirty reading can occur if calculation is performed according to two same messages because the two same messages are acquired at the same time can be avoided. Dirty read, also called invalid data read, means that in a database access, the transaction T1 modifies a certain value, then the transaction T2 reads the value, and if the transaction T1 undoes the modification of the value for some reason thereafter, this results in the data read by the transaction T2 being invalid.

It can be seen that, in the embodiment of the present application, the first message is acquired through distributed lock control, so that not only can concurrent task competition under distributed conditions be avoided, but also when two identical messages are acquired simultaneously, the generation reasons of the two identical messages can be distinguished. The reasons for the generation include two cases, one is that the user to whom the message belongs actually sends two identical messages, and the other is that the same message is sent twice by mistake due to the network and the like. It will be appreciated that the distributed lock may be released after the first message is acquired by the distributed lock control.

After the first message is obtained through distributed lock control, the number of messages in the session record corresponding to the first message may be determined, that is, the following S202 is executed:

s202, determining the number of the messages in the session record corresponding to the first message.

In general, before each session, a session record is created for the session in advance, so that after a first message is acquired, the session record corresponding to the first message is checked to determine whether the number of messages in the session record corresponding to the first message is greater than a preset threshold, and if the number of messages in the session record is less than or equal to the preset threshold, assuming that the preset threshold is 0, the number of messages in the session record is equal to the preset threshold, the first message is directly recorded in the session record; conversely, if the number of messages in the session record is greater than the preset threshold, the following S203 is executed:

and S203, if the number of the messages in the session record is larger than the preset threshold, judging whether the first message is the latest message in the session record according to the sending time of the first message and the sending time of the last message in the session record.

It is understood that, similar to the acquired first message, the information stored in the session record may include, in addition to each message, a sending time of each message, an identifier of a user to which each message belongs, and an identifier of each message.

When judging whether the first message is the latest message in the session record, the last message in the session record can be found first, the sending time of the first message is compared with the sending time of the last message, and if the sending time of the first message is later than the sending time of the last message, the first message is determined to be the latest message in the session record; conversely, if the time of transmission of the first message is earlier than the time of transmission of the last message, then it is determined that the first message is not the latest message in the session record. After the judgment, the message turn in the current session can be determined according to the judgment result, that is, the following S204 is executed:

and S204, determining the message turn in the current session according to the judgment result.

Therefore, in the embodiment of the application, when counting the message turns, the number of messages in the session record corresponding to the first message is determined; judging whether the first message is the latest message in the session record or not according to the sending time of the first message and the sending time of the last message in the session record when the number of the messages in the session record is larger than a preset threshold value; and determining the message turn in the current session according to the judgment result, thereby improving the accuracy of the counted message turn.

Based on the embodiment shown in fig. 1, in S204, when determining the message turn in the current session according to the determination result, two possible scenarios may be included, where in one scenario, the first message is the latest message in the session record; in another scenario, the first message is not the latest message in the session record, and in the following, how to determine the message turn in the current session will be described in detail with reference to these two different scenarios, respectively.

In a scenario, when the first message is a latest message in the session record, as shown in fig. 3, fig. 3 is a flowchart of another method for determining a message turn according to the embodiment of the present application, and the method for determining a message turn may also be executed by a software and/or hardware device. For example, referring to fig. 3, the method for determining the message turn may include:

s301, determining the message turn in the current session according to the user identifier to which the first message belongs and the user identifier to which the last message belongs in the session record.

For example, when determining the message turn in the current session according to the user identifier to which the first message belongs and the user identifier to which the last message belongs in the session record, if the user identifier to which the first message belongs indicates that the user to which the first message belongs is the consulting user, and the user identifier to which the last message belongs indicates that the user to which the last message belongs is the consulted user, it is described that the first message and the last message in the session record form a message turn, when counting the message turn in the current session, the message turn is incremented by 1, thereby updating the message turn in the current session. It will be appreciated that after updating the message turn in the current session, the first message also needs to be recorded in the session record as the new last piece of information in the session record. If the condition is not satisfied, it is stated that the first message and the last message in the session record do not constitute a message turn, then only the first message is recorded in the session record and recorded as a message repository.

For example, assuming that the session record includes a doctor and a patient, the doctor may be regarded as a consulted user, and the patient may be regarded as a consulted user, in this scenario, when determining the turn of messages in the current session according to the user identifier to which the first message belongs and the user identifier to which the last message in the session record belongs, see table 1 below:

TABLE 1

As can be seen from table 1, when the first message is the latest message in the session record, only when the first message is the patient and the previous message is the doctor, the first message and the previous message can form a message turn, and otherwise, the first message and the previous message cannot form a message turn.

Therefore, in the embodiment of the application, when the first message is the latest message in the session record, the message turn in the current session can be determined according to the user identifier to which the first message belongs and the user identifier to which the last message belongs in the session record, so that the accuracy of the counted message turn is improved when the message turn included in the session record is counted.

In another scenario, when the first message is not the latest message in the session record, as shown in fig. 3, the method for determining the message turn may include:

s302, judging whether the first message exists in the session record.

When the first message is not the latest message in the conversation record, the first message may be determined to be present in the conversation record by traversing the conversation record, for example, traversing historical conversation messages within the last 100 days of the conversation record, and determining whether the first message is present in the conversation record based on the historical conversation messages; if the first message exists, the first message is indicated to be a repeated message, and the first message can be directly abandoned; on the contrary, if the first message does not exist, the following S303 is executed:

s303, if the first message does not exist in the session record, determining the context message of the first message in the session record according to the message identifier of the first message.

S304, determining the message turn in the current conversation according to the context message of the first message in the conversation record.

For example, the context message includes a previous message immediately adjacent to the first message and a next message immediately adjacent to the first message, when determining the message turn in the current session according to the context message recorded in the session by the first message, if the user identifier to which the previous message belongs is the same as the user identifier to which the next message belongs and is different from the user identifier to which the first message belongs, it is described that the first message, the previous message, and the last message constitute a message turn, and when counting the message turn in the current session, the message turn is incremented by 1, thereby updating the message turn in the current session. It will be appreciated that after updating the message turn in the current session, the first message also needs to be recorded in the session record as the new last piece of information in the session record. If the condition is not satisfied, the first message, the previous message and the last message do not form a message turn, and only the first message is recorded in the session record and recorded as a message storage.

For example, also assuming that the session record includes a doctor and a patient, in this scenario, when determining the message turn in the current session according to the context message of the first message in the session record, see the following table 2:

TABLE 2

As can be seen from table 2, when the first message is not the latest message in the session record, only when both the previous message and the next message are doctors and the first message is a patient, and both the previous message and the next message are patients and the first message is a doctor, the three messages, i.e., the first message, the previous message and the next message, can form a message turn, and otherwise, the message turn cannot be formed.

Therefore, in the embodiment of the application, when the first message is not the latest message in the session record, whether the first message exists in the session record can be judged, and if the first message does not exist in the session record, the context message of the first message in the session record is determined according to the message identifier of the first message; and determining the message turn in the current session according to the context message of the first message in the session record, so that the accuracy of the counted message turn is improved when the message turn included in the session record is counted.

Based on the embodiment shown in any of the above figures, after counting the message turns in the current conversation, the doctor and the patient can only communicate with the maximum allowed message turn due to the limitation of the condition, so the remaining message turns in the current conversation can be further determined based on the maximum allowed message turn and the message turns in the current conversation, that is, after counting each message turn, the current message turn is deducted from the maximum allowed message turn, and the remaining message turns can be understood as the message turns which can also be allowed to communicate in the current conversation; if the remaining message turns are larger than 0, controlling the current session to continue; conversely, if the remaining message turn is equal to 0, indicating that the maximum value of the message turn has been reached currently, then control closes the current session.

For example, when the current message round is deducted from the maximum allowed message round, JMQ deduction message queues may be adopted, that is, an asynchronous message queue mechanism is implemented by using message middleware, a large-traffic call record request is converted into a logic process, the stability of the database is guaranteed, and the accuracy of the counted message round is ensured. In addition, basic information of the inquiry packet can be set for recording the final deduction times, and the redis cache data loss is prevented.

In order to facilitate understanding of the method for determining the message round provided in the embodiment of the present application, it is assumed that a doctor a establishes an inquiry session with a patient B, and the message 1 and the doctor ask an inquiry: your good, what disease do you want to ask? For some network reasons, the server receives the messages of two doctors at the same time, and the two messages are called as message 1 and message 1 +; because the message 1 and the message 1+ are simultaneously acquired, the two messages can simultaneously acquire the distributed lock, and the message 1 successfully acquires the distributed lock and acquires the message 1 through distributed lock control; message 1+ fails to acquire the distributed lock, and message 1+ enters a wait state.

After the message 1 is obtained, the number of messages included in the session record corresponding to the message 1 is inquired, if the number of messages in the session record corresponding to the message 1 is 0, it is indicated that no message record exists in the current session, the message 1 is recorded in a cache corresponding to the session record, and meanwhile, the distributed lock can be released. At this time, if the message 1+ in the waiting state acquires the distributed lock released by the message 1, the message 1+ is added to the message 1+ through the distributed lock; after the message 1+ is obtained, the number of messages included in the session record corresponding to the message 1+ is inquired, since the message 1 exists in the session record, the number of messages in the session record is larger than 0, whether the message 1+ is the latest message in the session record is judged according to the sending time of the message 1+ and the last message in the session record, namely the sending time of the message 1, and since the sending time and the message content of the message 1+ are the same, it can be determined that the message 1+ is the repeated message of the message 1, and the message 1+ is discarded.

Proceeding with the advancement of the conversation scenario: after message 1, if message 2 is acquired, the patient replies with: you are good, I have headache and want to prescribe some medicines. After the message 2 is acquired, the number of messages included in the session record corresponding to the message 2 is firstly inquired, since the message 1 is already in the session record, the number of messages in the session record is larger than 0, whether the message 2 is the latest message in the session record or not is judged according to the sending time of the message 2 and the last message in the session record, namely the sending time of the message 1, and whether the message 2 and the message 1 form a message turn or not can be determined according to the user identifier to which the message 2 belongs and the user identifier to which the previous message 1 belongs because the message 2 is really the latest message, so that a doctor to which the message 1 belongs is a consulted user and a patient to which the message 2 belongs is a consultant user can form a message turn and the message 2 and the message 1 are recorded in a cache corresponding to the session record; in addition, one session turn can be deducted from the maximum allowable message turn of the session.

Proceeding with the advancement of the conversation scenario: assume that after message 2, including message 3, the doctor asks: how do you have the latest sleep condition? Message 4, doctor supplement question: several hours of sleep? Message 5, patient B replies: the sleep is good; message 6, patient reply: for substantially 8 hours. Under normal conditions, the message sequence that the server should acquire is as follows: message 3, message 4, message 5, and message 6; but is affected by the service architecture such that the messages retrieved are not in chronological order, but rather are out of chronological order, e.g., message 5, message 4, message 3, and message 6, or other out of order messages. Assume that the obtained out-of-order messages are message 5, message 4, message 3, and message 6.

When the message 5 is acquired, the number of messages included in the session record corresponding to the message 5 is queried, and since the session record already contains the message 1 and the message 2, if the number of messages in the session record is greater than 0, then according to the sending time of the message 5 and the last message in the session record, i.e., the time of transmission of message 2, determines whether message 5 is the latest message in the session record, since message 5 is indeed the latest message, it can be determined whether the message 5 and the message 2 form a message turn according to the user identifier to which the message 5 belongs and the user identifier to which the previous message 2 belongs, and it can be seen that the user to which the message 5 belongs and the user to which the message 2 belongs are both patients, then the message 5 and the message 2 do not form a message turn, and a session turn is not deducted from the maximum allowed message turn, and only the message 5 is recorded in the cache corresponding to the session record.

When the message 4 is acquired, the number of messages included in the session record corresponding to the message 4 is also queried first, because the session record already contains the message 1, the message 2 and the message 5, the number of messages in the session record is greater than 0, whether the message 4 is the latest message in the session record is judged according to the sending time of the message 4 and the last message in the session record, that is, the sending time of the message 5, and because the sending time of the message 4 is earlier than that of the message 5, whether the message 4 exists in the session record can be continuously judged if the message 4 does not exist in the session record, and because the message 4 does not exist in the session record, the context message of the message 4 in the session record can be determined according to the identifier of the message 4. It can be seen that message 4 precedes messages 2 and 5, i.e. the previous message is message 2 and the next message is message 5; because the users to which the messages 2 and 5 belong are patients and the user to which the message 4 belongs is a doctor, the message 4, the message 2 and the message 5 form a message turn, and the message 4 is recorded in a cache corresponding to the session record; in addition, one session turn can be deducted from the maximum allowable message turn of the session.

When acquiring the message 3, the number of messages included in the session record corresponding to the message 3 is also queried first, and because the session record already contains the message 1, the message 2, the message 4, and the message 5, the number of messages in the session record is greater than 0, whether the message 3 is the latest message in the session record is determined according to the sending time of the message 3 and the last message in the session record, that is, the sending time of the message 5, and because the sending time of the message 3 is earlier than that of the message 5, the message 3 is not the latest message, whether the message 3 exists in the session record can be continuously determined, and because the message 3 does not exist in the session record, the context message of the message 3 in the session record can be determined according to the identifier of the message 3. It can be seen that message 3 precedes messages 2 and 4, i.e. the previous message is message 2 and the next message is message 4; because the user to which the message 2 belongs is a patient, the user to which the message 4 belongs is a doctor, that is, the user to which the message 2 belongs is different, and the user to which the message 3 belongs is a doctor, the message 3, the message 2, and the message 4 do not form a message turn, and a conversation turn cannot be deducted from the maximum allowable message turn, and only the message 3 is recorded in the cache corresponding to the conversation record.

When the message 6 is acquired, the number of messages included in the session record corresponding to the message 6 is also inquired, since the message 1, the message 2, the message 3, the message 4 and the message 5 already exist in the session record, and therefore, the number of messages in the session record is greater than 0, whether the message 6 is the latest message in the session record is judged according to the sending time of the message 6 and the last message in the session record, that is, the sending time of the message 5, and since the sending time of the message 6 is later than that of the message 5, the message 6 is the latest message, whether the message 6 and the message 5 form a message turn can be determined according to the user identifier to which the message 6 belongs and the user identifier to which the message 5 belongs, it can be seen that the patient to which the message 6 belongs is a consultation user, the patient to which the message 5 also belongs to a consultation user, and the message 2 and the message 1 do not form a message turn, the session turn is not deducted once from the maximum allowed message turn, and only the message 6 is recorded in the corresponding buffer memory of the session record.

It can be seen that, by using the method for determining the message round provided by the embodiment of the present application, when counting the message round of the message 1, the message 2, the message 3, the message 4, the message 5, and the message 6, even if the obtained message is an out-of-order message, the message 1, the message 2, the message 5, the message 4, the message 3, and the message 6, the message round 3 included in the current session can be accurately counted, so that when counting the message round included in the session record, the accuracy of the counted message round is improved; in addition, the real-time counting of the message turns included in the session record is realized.

Fig. 4 is a schematic structural diagram of a device 40 for determining a message turn according to an embodiment of the present application, and for example, please refer to fig. 4, the device 40 for determining a message turn may include:

an obtaining unit 401 is configured to obtain the first message and a sending time of the first message.

A processing unit 402, configured to determine the number of messages in the session record corresponding to the first message; if the number of the messages in the session record is larger than a preset threshold value, judging whether the first message is the latest message in the session record according to the sending time of the first message and the sending time of the last message in the session record; and determining the message turn in the current session according to the judgment result.

Optionally, the processing unit 402 is specifically configured to, if the first message is the latest message in the session record, determine the message turn in the current session according to the user identifier to which the first message belongs and the user identifier to which the last message in the session record belongs.

Optionally, the processing unit 402 is specifically configured to update the message turn in the current session if the user identifier to which the first message belongs indicates that the user to which the first message belongs is the consulting user, and the user identifier to which the last message belongs indicates that the user to which the last message belongs is the consulted user.

Optionally, the processing unit 402 is specifically configured to determine whether the first message exists in the session record if the first message is not the latest message in the session record; if the first message does not exist in the session record, determining the context message of the first message in the session record according to the message identifier of the first message; and determining the message turn in the current session according to the context message of the first message in the session record.

Optionally, the context message includes a previous message immediately adjacent to the first message and a next message immediately adjacent to the first message, and the processing unit 402 is specifically configured to update the message turn in the current session if the user identifier to which the previous message belongs is the same as the user identifier to which the next message belongs and is different from the user identifier to which the first message belongs.

Optionally, the processing unit 402 is further configured to determine a remaining message turn in the current session according to the allowed maximum message turn and the message turn in the current session; and if the remaining message turns are 0, controlling to close the current session.

Optionally, the obtaining unit 401 is specifically configured to obtain a distributed lock; and acquiring the first message through distributed lock control.

The device 40 for determining a message round provided in this embodiment of the present application may execute the technical solution of the method for determining a message round in any embodiment, and its implementation principle and beneficial effect are similar to those of the method for determining a message round, and reference may be made to the implementation principle and beneficial effect of the method for determining a message round, which are not described herein again.

Fig. 5 is a schematic structural diagram of a device 50 for determining a message turn according to an embodiment of the present invention, for example, please refer to fig. 5, where the device 50 for determining a message turn may include a processor 501 and a memory 502; wherein the content of the first and second substances,

the memory 502 is used for storing computer programs.

The processor 501 is configured to read the computer program stored in the memory 502, and execute the technical solution of the sample data obtaining method in any of the embodiments according to the computer program in the memory 502.

Alternatively, the memory 502 may be separate or integrated with the processor 501. When the memory 502 is a device independent from the processor 501, the determining means of the message turn may further include: a bus for connecting the memory 502 and the processor 501.

Optionally, this embodiment further includes: a communication interface that may be connected to the processor 501 through a bus. The processor 501 may control the communication interface to implement the above-described functions of acquisition and transmission of the means for determining the message turn.

The device 50 for determining a message round shown in the embodiment of the present invention may execute the technical solution of the method for determining a message round in any embodiment, and its implementation principle and beneficial effect are similar to those of the method for determining a message round, and reference may be made to the implementation principle and beneficial effect of the method for determining a message round, which are not described herein again.

An embodiment of the present invention further provides a computer-readable storage medium, where a computer execution instruction is stored in the computer-readable storage medium, and when a processor executes the computer execution instruction, the technical solution for implementing the method for determining a message round in any of the above embodiments is implemented.

In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.

The units described as separate parts may or may not be physically separate, and parts shown as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment. In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.

The integrated module implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention.

It should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the present invention may be embodied directly in a hardware processor, or in a combination of the hardware and software modules within the processor.

The memory may comprise a high-speed RAM memory, and may further comprise a non-volatile storage NVM, such as at least one disk memory, and may also be a usb disk, a removable hard disk, a read-only memory, a magnetic or optical disk, etc.

The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present invention are not limited to only one bus or one type of bus.

The computer-readable storage medium may be implemented by any type or combination of volatile or non-volatile memory devices, 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 memory, flash memory, magnetic or optical disks. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.

Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种在线医疗问答方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!