Disclosure of Invention
In order to solve the problems in the prior art, the invention provides a data processing method, a data processing device and a data processing system, wherein the method can quickly respond to a processing request of a user, cannot cause thread blockage to influence the response speed, and enables the processing system to be easy to expand, maintainable and quick to respond.
The embodiment of the invention provides the following specific technical scheme:
in a first aspect, the present invention provides a data processing method, including:
acquiring a service processing request sent by a user;
extracting key fields in the service processing request, and matching in a pre-constructed service scene rule table to obtain a target service scene corresponding to the key fields;
and acquiring the service scene under the dimension of other service scenes associated with the target service scene according to the service processing request to obtain the target service content.
Preferably, the process of constructing the business scenario rule table includes:
extracting service attributes of different service scenes;
judging whether the service attributes of the different service scenes have common characteristics or not;
when the service scene dimension exists, generating a first type of service scene dimension according to the service attribute with the common characteristic, wherein the first type of service scene dimension comprises different service scenes corresponding to the service attribute with the common characteristic;
when the service attribute does not have the common characteristic, generating a service scene dimension of a second type according to the service attribute not having the common characteristic, wherein the service scene dimension of the second type comprises the service scene corresponding to the service attribute not having the common characteristic;
and generating the service scene rule table according to the service scene dimension of the first type, the service scene dimension of the second type, the service scene under the service scene dimension of the first type and the service scene under the service scene dimension of the second type.
Preferably, the service scenario rule table is stored in a memory.
Preferably, the method further comprises:
calculating the number of threads for processing the service processing request;
judging whether the number of the threads exceeds the preset optimal thread number or not;
when the number of the threads exceeds the preset number, processing the service processing request according to the preset number of the optimal threads;
and when the number of the threads is not exceeded, processing the service processing request according to the calculated number of the threads.
Preferably, the method further comprises:
judging whether the processing result of the thread exceeds a preset value or not;
when the processing result exceeds the preset threshold value, returning the processing result in an asynchronous response mode;
and generating the target service content according to all returned processing results.
In a second aspect, the present invention provides a data processing apparatus, comprising:
the acquisition module is used for acquiring a service processing request sent by a user;
the processing module is used for extracting key fields in the service processing request and matching the key fields in a pre-constructed service scene rule table to obtain target service scenes corresponding to the key fields; and the service processing module is used for acquiring the service scene under the dimension of other service scenes associated with the target service scene according to the service processing request so as to obtain the target service content.
Preferably, the apparatus further comprises:
the construction module is used for constructing the business scene rule table;
the building module specifically comprises:
the extraction module is used for extracting the service attribute of the service scene;
the judging module is used for judging whether the service attributes of the different service scenes have common characteristics or not;
the generating module is used for generating a first type of service scene dimension according to the service attribute with the common feature when the common feature exists, wherein the first type of service scene dimension comprises different service scenes corresponding to the service attribute with the common feature; when the common features do not exist, generating a service scene dimension of a second type according to the service attribute without the common features, wherein the service scene dimension of the second type comprises the service scene corresponding to the service attribute without the common features;
and the association module is used for generating the business scenario rule table according to the first type business scenario dimension, the second type business scenario dimension, the business scenario under the first type business scenario dimension and the business scenario under the second type business scenario dimension.
Preferably, the service scenario rule table is stored in a memory.
Preferably, the obtaining module is further configured to calculate the number of threads for processing the service processing request;
the processing module is also used for judging whether the number of the threads exceeds the preset optimal thread number or not;
when the number of the threads exceeds the preset number, processing the service processing request according to the preset number of the optimal threads;
and when the number of the threads is not exceeded, processing the service processing request according to the calculated number of the threads.
Preferably, the processing module is further configured to determine whether a processing result of the thread exceeds a preset value;
when the processing result exceeds the preset threshold value, returning the processing result in an asynchronous response mode;
and generating the target service content according to all returned processing results.
In a third aspect, the present invention provides a computer system comprising:
one or more processors; and:
a memory associated with the one or more processors for storing program instructions that, when read and executed by the one or more processors, perform operations comprising:
acquiring a service processing request sent by a user;
extracting key fields in the service processing request, and matching in a pre-constructed service scene rule table to obtain a target service scene corresponding to the key fields;
and acquiring service scenes under other service scene dimensions associated with the target service scene according to the service processing request to obtain target service content.
The invention has the following beneficial effects:
1. the method carries out modeling processing on the service scene, generates a service scene rule table and stores the service scene rule table in the database, does not need to write redundant service codes, only simply increases and changes data in the database, and can realize complex service logic, so that a user request can be quickly responded according to the service scene rule table, the response speed cannot be influenced by thread blockage, the processing system is easy to expand, can be maintained and quickly responds, and meanwhile, the system can be free from release and takes effect in real time by controlling the service scene rule table in real time;
2. the method designs the optimal thread number according to the service processing request, thereby improving the service processing capacity;
3. the method optimizes the response returning mode, and returns in an asynchronous response mode when the processing result of the thread exceeds the preset value, thereby further improving the response speed;
of course, the method does not necessarily need to satisfy all of the above effects at the same time, but only needs to satisfy one of them.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, belong to the protection scope of the present invention.
The application provides a data processing method which can be applied to an application environment shown in figure 1. The server 12 communicates with the database 11 and the terminal 13 via a network. The terminal 13 may be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices, and the server 12 may be implemented by an independent server or a server cluster composed of a plurality of servers; the database 11 may store the business scenario rule table of the present invention.
Example one
As shown in fig. 2, a data processing method, which can be applied to a shopping platform system, includes the following steps:
and S21, acquiring a service processing request sent by a user.
The business processing request can be an order settlement request sent by a user on a shopping platform.
And S22, extracting key fields in the service processing request, and matching in a pre-constructed service scene rule table to obtain a target service scene corresponding to the key fields.
Wherein the business scenario rule table is stored in a database, which includes different business scenario dimensions.
The construction process of the business scenario rule table comprises the following steps:
1. extracting service attributes of different service scenes;
for example, for a shopping platform, the service scenario may be: common members, enterprise members, super members, self-operated commodities, commodities of in-dwelling merchants, virtual card commodities, service commodities, self-pickup modes, payment modes and the like.
Extracting the service attributes of different service scenes as follows: and extracting the service attributes of common members, enterprise members, super members and the like.
Such as: the service attributes of the common member, the enterprise member and the super member are all member types; the service attributes of common express delivery and self-service are distribution modes.
2. Judging whether the service attributes of different service scenes have common characteristics or not;
illustratively, when the service scenes are common members, business members and super members respectively, since the extracted service attributes are all member types, common characteristics exist. When the service scenes are respectively common members and self-service, common characteristics do not exist because the service attributes are respectively member types and distribution modes.
3. When the service scene dimension exists, generating a first type of service scene dimension according to the service attributes with the common characteristics, wherein the first type of service scene dimension comprises different service scenes corresponding to the service attributes with the common characteristics;
for example, for service scenarios such as common members, enterprise members, super members, etc., since service attributes thereof have common characteristics, a service scenario dimension of a first type is generated according to the service attributes having common characteristics, such as: the member types comprise: common members, enterprise members, super members and other different service scenes; for common express delivery, self-service and other service scenes, because the service attributes of the service scenes have common characteristics, a first type of service scene dimension is generated according to the service attributes with the common characteristics, such as: the delivery mode, include under the delivery mode: common express delivery, self-service and other different service scenes.
In addition, different first-type service scenes such as factory delivery, commodity types, operating equipment, service channels, activity types, self-service modes, payment modes and the like can be generated according to actual conditions.
4. When the service scene dimensionality does not exist, generating a second type of service scene dimensionality according to the service attribute without the common characteristic, wherein the second type of service scene dimensionality comprises a service scene corresponding to the service attribute without the common characteristic;
for example, for the shopping platform, in order to adapt to all the service attributes one hundred percent, a special process is further required to be performed on a special service scenario to generate a service scenario dimension of a second type, where the service scenario dimension of the second type includes a single service scenario corresponding to the service scenario dimension, for example, the service scenario may be an installments rule or some other rules that can be changed in real time.
Because the rules are often changed in real time in the actual process, in the scheme, the rules are designed according to the principle of an abstract factory, namely: a service scenario in a second type of service scenario dimension. Therefore, the implementation code is clearer, redundancy is not generated, and the low coupling and the expandability are achieved.
5. And generating a business scene rule table according to the business scene under the first type of business scene dimension and the business scene under the second type of business scene dimension.
Specifically, referring to fig. 3, fig. 3 is a table of business scenario rules applicable to a certain shopping platform. The business scenario rule table includes a business scenario dimension and a business scenario under the business scenario dimension. Wherein, the service scene dimension comprises: a first type of service scenario dimension, a second type of service scenario dimension. The first type of service scene dimension comprises a user type, a commodity attribute, whether a factory is delivered or not, a commodity category, an operation device, a service channel, an activity type, a distribution mode, a self-service mode, a payment mode and a rule type; the second type of traffic scenario dimension includes some special policies, such as: and the self-picking rule of the WeChat non-central bin is met.
The above-mentioned service scenarios may be represented by different numbers for easy storage in the database.
In addition, in order to improve the read-write speed and improve the response, the service scenario rule table may also be stored in the memory.
In the scheme, the service scene rule table is obtained by abstracting different service scenes, so the table can realize real-time control, and the service scene rule table can be modified in real time according to actual requirements, thereby avoiding system release and realizing real-time effect.
In addition, for the shopping platform, the key field in the service processing request can be a commodity attribute, and a target service scene corresponding to the commodity attribute is obtained by matching in a service scene rule table constructed in advance according to the commodity attribute. Such as: referring to fig. 3, a target service scenario 3-overseas purchased goods is obtained by matching in the service scenario rule table according to the goods attributes.
In addition, the service processing request may also pass other parameters, such as: and the installment rule is a service scene under the dimension of the second type of service scene in the service scene rule table, so that the corresponding target service scene is obtained by matching in the service scene rule table constructed in advance according to the installment rule.
And S23, acquiring service scenes under other service scene dimensions related to the target service scene according to the service processing request to obtain target service content.
Different service scene dimensions have relevance with each other, so that when a service scene under a certain service scene dimension is matched, all matched service scenes under other service scene dimensions related to the service scene can be obtained.
Such as: referring to fig. 3, when the target service scene is a 3-overseas enough commodity, whether all matched service scenes in service scene dimensions such as factory delivery, commodity category, operating equipment, service channels, and the like associated with the target service scene are obtained, so as to obtain target service content.
The scheme can also comprise the following steps:
s31, calculating the number of threads for processing the service processing request;
s32, judging whether the number of the threads exceeds the preset optimal thread number or not;
s33, when the number of the threads exceeds the preset number of the optimal threads, processing the service processing request;
and S34, processing the service processing request according to the number of the calculated threads when the number of the threads is not exceeded.
For example, a user needs to settle 10 items in his/her shopping cart, and calculate the number of threads for processing the settlement request according to the settlement request of the user, and since the calculated number of threads is 10 when the settlement of 10 items is processed, the user cannot process the request of another user after allocating 10 threads, and thus, the user needs to process the settlement request according to the preset optimal number of threads (set to 5 in this embodiment). Thus, the service processing capacity of the whole system can be enhanced.
In addition, the scheme also comprises the following steps:
s41, judging whether the processing result of the thread exceeds a preset value or not;
s42, when the result exceeds the preset value, returning a processing result in an asynchronous response mode;
and S43, generating target business content according to all returned processing results.
According to the scheme, the response returning mode is optimized, when the processing result of the thread exceeds the preset value, the thread is returned in an asynchronous response mode, and the response speed is further improved.
Example two
As shown in fig. 4, a data processing apparatus includes:
an obtaining module 51, configured to obtain a service processing request sent by a user;
the processing module 52 is configured to extract a key field in the service processing request, and match the key field in a pre-constructed service scene rule table to obtain a target service scene corresponding to the key field; and the service processing module is used for acquiring the service scene under other service scene dimensions related to the target service scene according to the service processing request so as to obtain the target service content.
Preferably, the above apparatus further comprises:
a construction module 53, configured to construct a business scenario rule table;
the building block 53 specifically includes:
an extracting module 531, configured to extract a service attribute of a service scene;
a judging module 532, configured to judge whether there is a common feature in service attributes of different service scenarios;
a generating module 533, configured to, when the common feature exists, generate a service scene dimension of a first type according to the service attribute having the common feature, where the service scene dimension of the first type includes different service scenes corresponding to the service attribute having the common feature; when the common features do not exist, generating a second type of service scene dimension according to the service attributes without the common features, wherein the second type of service scene dimension comprises service scenes corresponding to the service attributes without the common features;
the association module 534 is configured to generate a service scenario rule table according to the service scenario dimension of the first type, the service scenario dimension of the second type, the service scenario under the service scenario dimension of the first type, and the service scenario under the service scenario dimension of the second type.
Preferably, the service scenario rule table is stored in a memory.
Preferably, the obtaining module 51 is further configured to calculate the number of threads for processing the service processing request;
the processing module 52 is further configured to determine whether the number of threads exceeds a preset optimal number of threads;
when the number of threads exceeds the preset optimal number, processing the service processing request according to the preset optimal number of threads;
and when the number of the threads is not exceeded, processing the service processing request according to the calculated number of the threads.
Preferably, the processing module 52 is further configured to determine whether a processing result of the thread exceeds a preset value;
when the data exceeds the preset threshold value, returning a processing result in an asynchronous response mode;
and generating target service content according to all returned processing results.
EXAMPLE III
A computer system, comprising:
one or more processors; and:
memory associated with the one or more processors, the memory for storing program instructions that, when read and executed by the one or more processors, perform operations comprising:
acquiring a service processing request sent by a user;
extracting key fields in the service processing request, and matching in a pre-constructed service scene rule table to obtain target service scenes corresponding to the key fields;
and acquiring service scenes under other service scene dimensions associated with the target service scene according to the service processing request to obtain target service content.
FIG. 5 illustrates an architecture of a computer system that may include, in particular, a processor 62, a video display adapter 64, a disk drive 66, an input/output interface 68, a network interface 610, and a memory 612. The processor 62, video display adapter 64, disk drive 66, input/output interface 68, network interface 610, and memory 612 may be communicatively coupled via a communication bus 614.
The processor 62 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits, and is configured to execute related programs to implement the technical solution provided in the present Application.
The Memory 612 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, or the like. The memory 612 may store an operating system 616 for controlling the operation of the computer system 60, a Basic Input Output System (BIOS) 618 for controlling low-level operations of the computer system. In addition, a web browser 620, a data storage management system 622, and the like may also be stored. In summary, when the technical solution provided in the present application is implemented by software or firmware, the relevant program codes are stored in the memory 612 and called for execution by the processor 62.
The input/output interface 68 is used for connecting an input/output module to input and output information. The i/o module may be configured as a component in a device (not shown) or may be external to the device to provide a corresponding function. The input devices may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices may include a display, a speaker, a vibrator, an indicator light, etc.
The network interface 610 is used for connecting a communication module (not shown in the figure) to realize communication interaction between the device and other devices. The communication module can realize communication in a wired mode (such as USB, network cable and the like) and also can realize communication in a wireless mode (such as mobile network, WIFI, bluetooth and the like).
The communication bus 614 includes a path that transfers information between the various components of the device, such as the processor 62, the video display adapter 64, the disk drive 66, the input/output interface 68, the network interface 610, and the memory 612.
In addition, the computer system can also obtain the information of specific receiving conditions from the virtual resource object receiving condition information database for condition judgment and the like.
It should be noted that although the above-described device only shows the processor 62, the video display adapter 64, the disk drive 66, the input/output interface 68, the network interface 610, the memory 612, the communication bus 614, etc., in a specific implementation, the device may also include other components necessary for proper operation. Furthermore, it will be understood by those skilled in the art that the apparatus described above may also include only the components necessary to implement the solution of the present application, and not necessarily all of the components shown in the figures.
From the above description of the embodiments, it is clear to those skilled in the art that the present application can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, or the like, and includes several instructions for enabling a computer device (which may be a personal computer, a cloud server, or a network device) to execute the method according to the embodiments or some parts of the embodiments of the present application.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention. In addition, the data processing apparatus, the computer system and the data processing method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments and are not described herein again.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.