Insurance policy processing method and apparatus, device, medium

By creating task clusters and dynamically allocating task instances, the problem of inconsistent database settlement speeds was solved, thereby improving settlement efficiency and achieving efficient resource utilization.

CN114968577BActive Publication Date: 2026-02-17CHINA PING AN LIFE INSURANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210581972.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-26
Publication Date
2026-02-17
Estimated Expiration
2042-05-26

AI Technical Summary

Technical Problem

In existing technologies, the different number of policies to be settled in different databases leads to inconsistent database settlement speeds, resulting in low overall settlement efficiency and an inability to process subsequent business in a timely manner.

Method used

By creating a task cluster, preempting the distributed lock and allocating task instances, dynamically allocating task instances to the settlement database, using idle task instances to concurrently execute pending insurance policies, and dynamically adjusting task instance allocation through an election algorithm, multiple uses of task instances can be achieved.

Benefits of technology

It improved the overall settlement efficiency of the settlement database, shortened the settlement time, increased resource utilization, and ensured the consistency and rationality of the allocation of work.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114968577B_ABST
    Figure CN114968577B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a policy processing method and device, equipment and medium, and belongs to the technical field of databases. The method comprises the following steps: allocating task instances to a plurality of settlement databases through a target task instance, and executing the unsettled policies in the corresponding settlement databases through the task instances in parallel; for a first settlement database for which the unsettled policies have been executed, recording the task instance corresponding to the first settlement database as an idle task instance, finding a second settlement database for which the unsettled policies have not been executed through a preset election algorithm, allocating the idle task instance to the second settlement database, and executing the unsettled policies of the second settlement database through the idle task instance in parallel until the unsettled policies of all the settlement databases are executed. The embodiment can guarantee the consistency of the allocation of the task instances, and through the dynamic allocation of the task instances, the multiple utilization of the task instances is realized, and the overall settlement efficiency of the settlement databases is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database, and particularly relates to a policy processing method and device, equipment and medium. BACKGROUND

[0002] The existing universal batch settlement is realized through a stored procedure and is scheduled by a database job in a time manner. All calculations and table writing are completed in the database. Currently, business data is stored in multiple databases, and these databases need to be settled. Because the number of policies to be settled in different databases is different, the settlement speed of some databases is faster, and the settlement speed of some databases is slower. For other businesses after the universal settlement, such as actuarial, the subsequent other businesses need to wait until all databases are settled as a whole before being processed, which causes a very slow overall time efficiency. Therefore, how to improve the efficiency of the overall settlement of the database has become a technical problem to be solved urgently. SUMMARY

[0003] The main purpose of the embodiments of the present application is to provide a task processing method and device, equipment and medium, which can dynamically allocate task instances and dynamically allocate idle task instances to other settlement databases to speed up the execution efficiency of the other settlement databases and improve the overall settlement efficiency of the database.

[0004] To achieve the above purpose, a first aspect of the embodiments of the present application provides a policy processing method, which comprises the following steps:

[0005] Creating a task cluster, wherein the task cluster comprises a plurality of task instances;

[0006] Occupying a distributed lock through the plurality of task instances, and taking a task instance occupying the distributed lock as a target task instance;

[0007] Allocating the task instances to a plurality of settlement databases through the target task instance, wherein each settlement database is allocated at least one task instance;

[0008] Concurrently executing the policies to be settled in a corresponding settlement database through the task instances;

[0009] For a first settlement database in which the policies to be settled have been executed, taking the task instance corresponding to the first settlement database as an idle task instance, finding a second settlement database in which the policies to be settled have not been executed through a preset election algorithm, allocating the idle task instance to the second settlement database, and concurrently executing the policies to be settled in the second settlement database through the idle task instance until the policies to be settled in all settlement databases are executed.

[0010] According to the policy processing method of the first aspect of the embodiments of the present disclosure, at least the following beneficial effects are achieved: the target task instance is used to allocate task instances to multiple settlement databases, ensuring the consistency of the allocation work. When the settlement of a policy to be settled in a settlement database is completed, the idle task instance of the settlement database is released, and the idle task instance is allocated to the settlement database that fails to complete the settlement of the policy to be settled through an election algorithm, so that the task instance is used multiple times, improving the resource utilization rate. Moreover, the idle task instance can accelerate the execution efficiency of the settlement of the policy to be settled in other settlement databases, shorten the execution time of other settlement databases, and improve the overall settlement efficiency of the settlement databases.

[0011] In some embodiments, the creating the task cluster comprises:

[0012] Obtaining a single quantity of the multiple settlement databases, the single quantity being a quantity of the policies to be settled in each of the settlement databases;

[0013] Determining a quantity of task instances according to the single quantity, and creating a task cluster by the task instances.

[0014] In some embodiments, after the target task instance allocates the task instances to the multiple settlement databases, a distribution completion identifier is created, and the method further comprises:

[0015] Querying the distribution completion identifier, and if the distribution completion identifier does not exist, obtaining a duration for which the target task instance occupies a distributed lock;

[0016] If the duration is greater than a preset duration threshold, releasing the distributed lock corresponding to the target task instance, so as to trigger the task instance of the distributed lock that is not occupied to occupy the released distributed lock.

[0017] In some embodiments, the allocating the task instances to the multiple settlement databases by the target task instance comprises:

[0018] Discovering a plurality of live task instances in the task cluster through a registration center;

[0019] Obtaining a single quantity of the multiple settlement databases, the single quantity being a quantity of the policies to be settled in each of the settlement databases, wherein the single quantity is used to determine a quantity of the live task instances corresponding to the settlement database, so that the target task instance allocates the corresponding quantity of the live task instances to the settlement database according to the single quantity.

[0020] In some embodiments, the concurrently executing the policy to be settled in the corresponding settlement database by the task instance comprises:

[0021] The task instance's IP address is used to query the assigned settlement database and retrieve the insurance policies pending settlement from the settlement database.

[0022] A thread pool is created based on the settlement database, and several execution threads are created based on the task instance, and the several execution threads are loaded into the thread pool;

[0023] The policies to be settled are paginated to obtain multiple pages, and each page includes multiple policies to be settled.

[0024] The execution threads concurrently execute multiple unsettled insurance policies on the pages.

[0025] In some embodiments, the concurrent execution of multiple unsettled policies on the pages according to a plurality of execution threads includes:

[0026] The page is retrieved, and all the policies pending settlement on the page are added to the master table. At the same time, the execution status field corresponding to each policy pending settlement is set.

[0027] Each execution thread executes the policy to be settled and updates the status record of the corresponding execution status field.

[0028] Once all pending policies on all pages of each settlement database have been processed, the status record is used to identify and record any missed policies.

[0029] All missed orders are captured into the error order table, and the pending insurance policies on the error order table are re-executed through the task instance.

[0030] In some embodiments, finding the second settlement database of the policies to be settled that have not yet been fully executed through a preset election algorithm includes:

[0031] The first set of settlement databases that has not yet been fully executed for the pending settlement policies is selected from multiple settlement databases;

[0032] Obtain the current task instance count of each settlement database in the first settlement database set, and filter out the second settlement database set from the first settlement database set based on the current task instance count and the preset maximum number of execution task instances;

[0033] Obtain the number of unprocessed pending settlement policies in each settlement database in the second settlement database set, and filter out the second settlement database from the second settlement database set based on the number of unprocessed pending settlement policies.

[0034] To achieve the above objectives, a second aspect of this application provides a policy processing apparatus, comprising:

[0035] A creation module is used to create a task cluster, which includes several task instances;

[0036] The preemption module is used to preempt the distributed lock through several task instances, and to use the task instance that preempts the distributed lock as the target task instance.

[0037] An allocation module is configured to allocate task instances to multiple settlement databases through the target task instance, wherein each settlement database is allocated to at least one task instance;

[0038] The first execution module is used to concurrently execute the insurance policies to be settled in the corresponding settlement database through the task instance;

[0039] The second execution module is used to, for the first settlement database where the pending settlement policies have been completed, record the task instance corresponding to the first settlement database as an idle task instance, find the second settlement database where the pending settlement policies have not been completed through a preset election algorithm, allocate the idle task instance to the second settlement database, and concurrently execute the pending settlement policies of the second settlement database through the idle task instance until the pending settlement policies of all settlement databases have been completed.

[0040] To achieve the above objectives, a third aspect of this application provides a computer device, the computer device including a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for implementing communication between the processor and the memory, wherein the program, when executed by the processor, implements the method described in the first aspect.

[0041] To achieve the above objectives, a fourth aspect of the present application provides a storage medium, which is a computer-readable storage medium for computer-readable storage, wherein the storage medium stores one or more programs that can be executed by one or more processors to implement the method described in the first aspect.

[0042] The policy processing method and device, equipment and medium provided in the application can assign task instances to multiple settlement databases through target task instances, ensuring the consistency of the assignment work. The settlement database is assigned a task instance through the number of to-be-settled policies of the settlement database, and the assignment method is more reasonable, which helps to improve the settlement efficiency of the settlement database. The number of task instances can also be dynamically expanded through the number of to-be-settled policies of the settlement database, so as to improve the settlement efficiency of the settlement database as the number of task instances increases. The to-be-settled policies are processed by paging to obtain multiple pages, each page including multiple to-be-settled policies, and the to-be-settled policies on the multiple pages are concurrently executed according to a plurality of execution threads, so that the to-be-settled policies of each page can only be processed by one execution thread under multi-threading, avoiding data errors caused by the same to-be-settled policy being processed by different threads. The idle task instances of a settlement database are released when the to-be-settled policies of the settlement database are executed, and the idle task instances are assigned to the settlement databases that have not completed the execution of the to-be-settled policies through an election algorithm, so as to achieve multiple uses of the task instances and improve the resource utilization rate. In addition, the idle task instances can accelerate the execution efficiency of the to-be-settled policies of other settlement databases, shorten the execution time of other settlement databases, and improve the overall settlement efficiency of the settlement databases. BRIEF DESCRIPTION OF DRAWINGS

[0043] Figure 1 is a flowchart of a policy processing method provided by an embodiment of the present disclosure;

[0044] Figure 2 is a flowchart of step S110 in Figure 1

[0045] Figure 3 is a flowchart of step S130 in Figure 1

[0046] Figure 4 is a flowchart of step S140 in Figure 1

[0047] Figure 5 is a flowchart of step S440 in Figure 4

[0048] Figure 6 is a flowchart of step S150 in Figure 1

[0049] Figure 7 is a block diagram of the module structure of a policy processing device provided by an embodiment of the present disclosure;

[0050] Figure 8 is a hardware structure schematic diagram of a computer device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION ​​​​​

[0051] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not intended to limit the present application.

[0052] It should be noted that although the functional modules are divided in the device schematic diagram, and the logical sequence is shown in the flowchart, in some cases, the steps shown or described can be performed in a manner different from the module division in the device or the sequence in the flowchart. The terms "first", "second", etc. in the specification and claims and the above-described drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.

[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0054] First, the terms involved in the present application are analyzed:

[0055] Distributed system: A group of independent computers presents a unified whole to the user, just like a system. The system has multiple common physical and logical resources, and can dynamically allocate tasks. The distributed physical and logical resources exchange information through a computer network. There is a distributed operating system in the system that manages computer resources in a global manner.

[0056] Distributed database: A distributed database is logically a unified whole, and physically stored on different physical nodes. An application program can access databases distributed in different geographical locations through network connection. Its distribution is reflected in that the data in the database is not stored in the same place. More precisely, it is not stored on the storage device of the same computer.

[0057] The existing universal batch settlement is implemented through a stored procedure and scheduled by a database job. All calculations and table writing are completed in the settlement database. Due to excessive batch data, there is a hot block problem, and the settlement efficiency cannot be improved by horizontally expanding task instances. In addition, the current business data exists in multiple settlement databases, and related settlements need to be performed on these settlement databases. Due to the different quantities of policies to be settled in different settlement databases, some settlement databases settle monthly faster, and some settlement databases settle slower, which causes the subsequent other businesses such as actuarial calculation to wait until all settlement databases complete the overall settlement before processing, resulting in very slow overall time efficiency.

[0058] Based on this, the main purpose of the embodiments of the present disclosure is to propose a policy processing method and device, equipment and medium, aiming to improve the overall settlement efficiency of the settlement database. The method comprises: creating a task cluster, the task cluster comprising a plurality of task instances; seizing the distributed lock through the plurality of task instances, and taking the task instance that seizes the distributed lock as a target task instance; allocating the plurality of settlement databases with the target task instance, wherein each settlement database is allocated with at least one task instance; executing the to-be-settled policies in the corresponding settlement database through the task instance in parallel; for a first settlement database whose to-be-settled policies have been executed, recording the task instance corresponding to the first settlement database as an idle task instance, finding a second settlement database whose to-be-settled policies have not been executed through a preset election algorithm, allocating the idle task instance to the second database, and executing the to-be-settled policies of the second settlement database through the idle task instance in parallel, until the to-be-settled policies of all settlement databases are executed. The embodiments of the present disclosure allocate the plurality of settlement databases with the target task instance, ensuring the consistency of the allocation work. When the to-be-settled policies of a certain settlement database are executed, the idle task instance of the settlement database is released, and the idle task instance is allocated to the settlement database whose to-be-settled policies have not been executed through the election algorithm, achieving the multiple use of the task instance. Through the idle task instance, the execution efficiency of the to-be-settled policies of other settlement databases is accelerated, the execution time of other settlement databases is reduced, and the overall settlement efficiency of the settlement database is improved.

[0059] The policy processing method provided by the embodiments of the present disclosure can be applied to a terminal, can be applied to a server side, and can also be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart watch, or the like; the server side can be configured as a separate physical server, can be configured as a server cluster or a distributed system composed of a plurality of physical servers, can also be configured as a cloud server providing basic cloud computing services such as cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and big data and artificial intelligence platform; and the software can be an application or the like for implementing the above method, but is not limited to the above forms.

[0060] The embodiments of the present disclosure can be used in numerous computing environments or configurations. For example, these computing devices and environments can include personal computers, server computers, handheld or laptop devices, tablet devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application can be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like, that perform particular tasks or implement particular abstract data types. The application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules can be located in both local and remote computer storage media including memory storage devices.

[0061] The embodiments of the present disclosure provide a policy processing method and device, equipment and medium, which are specifically described through the following embodiments. First, the policy processing method in the embodiments of the present disclosure is described.

[0062] Figure 1 is an optional flowchart of the policy processing method provided by the embodiments of the present disclosure, Figure 1 The method in the embodiment can include, but is not limited to, steps S110 to S150.

[0063] Step S110, creating a task cluster, the task cluster including a plurality of task instances;

[0064] Step S120, preoccupying a distributed lock through the plurality of task instances, and taking the task instance preoccupying the distributed lock as a target task instance;

[0065] Step S130, allocating task instances for a plurality of settlement databases through the target task instance, wherein each settlement database is allocated to at least one task instance;

[0066] Step S140, concurrently executing the to-be-settled policies in the corresponding settlement database through the task instances;

[0067] Step S150, for a first settlement database for which the to-be-settled policies have been executed completely, taking the task instance corresponding to the first settlement database as an idle task instance, finding a second settlement database for which the to-be-settled policies have not been executed completely through a preset election algorithm, and allocating the idle task instance to the second database, and concurrently executing the to-be-settled policies of the second settlement database through the idle task instance, until the to-be-settled policies of all the settlement databases are executed completely.

[0068] Specifically, by steps S110 to S150, the embodiment of the disclosure allocates task instances to multiple settlement databases through target task instances, ensuring the consistency of the allocation work. When the settlement of a certain settlement database is completed, the idle task instance of the settlement database is released, and the idle task instance is allocated to the settlement database that fails to complete the settlement of the policy through the election algorithm, achieving multiple utilization of the task instance. Through the idle task instance, the execution efficiency of the settlement policy of other settlement databases is accelerated, the execution time of other settlement databases is shortened, and the overall settlement efficiency of the settlement database is improved.

[0069] In step S110, a task cluster is created, and the task cluster includes a plurality of task instances. Specifically, the task cluster is also called a micro-service cluster, and the task cluster is generally composed of a plurality of task instances. In actual application, a large number of settlement scenarios of the policy are often encountered. For a large number of settlement of the policy, the settlement of the policy can be quickly performed through the task cluster, mainly through a plurality of task instances to concurrently execute the settlement policy in the corresponding settlement database, thereby improving the efficiency of the policy processing.

[0070] In step S120, the plurality of task instances are used to seize the distributed lock, and the task instance that seizes the distributed lock is used as the target task instance. Specifically, the redis distributed lock is used to compete, and the task instance that obtains the distributed lock is used to allocate the settlement database, and the other task instances that do not obtain the distributed lock are used to wait for the allocation of the settlement database to be completed. It should be noted that the distributed lock based on ZooKeeper can also be used. In a specific example, the target task instance performs checking work before allocating the settlement database, and then decides whether to allocate the settlement database according to the checking work. The checking work specifically refers to judging whether the settlement task is started in the current period, continuously timing the current period through the system timer, comparing the current period with the preset period, and judging whether the settlement task is started according to the comparison result. For example, if the current period does not belong to a specific period such as the end of the month or the end of the year, the settlement task is not started, and the allocation of the task instance of the settlement database is not performed.

[0071] In step S130, the target task instance allocates task instances to the plurality of settlement databases, wherein each settlement database is allocated to at least one task instance. Specifically, there are a plurality of settlement databases, and there are also a plurality of task instances. One settlement database is allocated to at least one task instance, and can also be allocated to multiple task instances. That is, one settlement database can correspond to multiple task instances, but one task instance can only correspond to one settlement database. It should be noted that the number of task instances is greater than the number of settlement databases. When the target task instance allocates task instances to the settlement databases, the IP address of the task instance is actually connected with the corresponding settlement database, the mapping relationship between the task instance and the settlement database is obtained and recorded, so that the corresponding settlement database can be determined according to the IP of the task in the subsequent. In an embodiment, before the target task instance allocates task instances to the plurality of settlement databases, a business check is performed. The business check refers to data verification before the settlement task is executed, that is, it is judged whether the settlement task can be started. Because the universal batch settlement needs to verify whether the corresponding settlement interest rate has been completely entered, the settlement task can be executed only after all the entries are completed, otherwise it will not be processed.

[0072] In an embodiment, after the target task instance allocates task instances to the plurality of settlement databases, a distribution completion identifier is created, and the policy processing method according to the embodiment of the present disclosure further includes but is not limited to:

[0073] The distribution completion identifier is queried, if the distribution completion identifier does not exist, the duration of the target task instance seizing the distributed lock is obtained; if the duration is greater than a preset duration threshold, the distributed lock corresponding to the target task instance is released, so as to trigger the task instance of the distributed lock that has not been seized to seize the released distributed lock.

[0074] Specifically, in order to avoid the situation that the target task instance is down after pre-empting the distributed lock, causing the allocation to fail, therefore, after the target task instance allocates the task instances for the plurality of settlement databases, the allocation completion identifier needs to be created. If the allocation completion identifier can be queried, it means that the allocation work of the target task instance has been completed, at this time, other task instances do not need to wait for the distributed lock and directly proceed to the next step. If the allocation completion identifier is not queried, it means that the allocation work of the target task instance has not been completed, and it is possible that the allocation is still being performed, or the target task instance has failed and is down. Therefore, the duration of the target task instance pre-empting the distributed lock is obtained; if the duration is greater than a preset duration threshold, the distributed lock corresponding to the target task instance is released, so as to trigger the task instance that has not pre-empted the distributed lock to pre-empt the released distributed lock. In another embodiment, the distributed lock is set to expire in 3 minutes, and the distributed lock is released when it expires, preventing the target task instance that obtains the distributed lock from being down, and other task instances can compete for the distributed lock again to perform the allocation work again, ensuring high availability.

[0075] In step S140, the task instances concurrently execute the to-be-settled policies in the corresponding settlement database. Specifically, each task instance executes the to-be-settled policies in the corresponding settlement database, and the plurality of task instances implement the concurrent execution of the plurality of settlement databases, and the to-be-settled policies in each settlement database do not interfere with each other, so that each task instance can execute the to-be-settled policies in the settlement database at the same time, and the settlement databases are concurrently executed, realizing the distributed calculation of the to-be-settled policies.

[0076] In step S150, for the first settlement database whose to-be-settled policies have been executed, the task instance corresponding to the first settlement database is recorded as an idle task instance, a second settlement database whose to-be-settled policies have not been executed is found through a preset election algorithm, and the idle task instance is allocated to the second database, and the to-be-settled policies of the second settlement database are concurrently executed by the idle task instance until the to-be-settled policies of all settlement databases are executed.

[0077] Please refer to Figure 2 In some embodiments, step S110 can include but is not limited to steps S210 to S220:

[0078] Step S210, obtaining the quantity of the plurality of settlement databases, the quantity being the number of to-be-settled policies of each settlement database;

[0079] Step S220, determining the number of task instances according to the quantity, and creating a task cluster by the task instances.

[0080] Specifically, in steps S210 to S220, as the number of the policies to be settled in the settlement database increases, the number of the current task instances is insufficient to ensure the efficiency of the settlement of the policies, and the number of the task instances needs to be increased. In the embodiment, the number of the task instances can be increased according to the increase of the number of the policies in the settlement database, and the increase of the number of the task instances can improve the execution efficiency of the settlement database, thereby improving the overall settlement speed. Even in the future large business growth mode, the universal monthly settlement task can be successfully completed on time. In an embodiment, for example, a certain settlement database has 2 million policies, and it is assumed that one task instance can process 1 million policies per hour, so it takes 2 hours to process the settlement database. If the number of task instances is expanded to 2, then 2 million policies can be processed per hour, and the entire settlement of the policies only takes 1 hour, greatly improving the settlement efficiency.

[0081] Referring to Figure 3 In some embodiments, step S130 can include but is not limited to steps S310 to S320:

[0082] In step S310, a number of live task instances in the task cluster are discovered through the registration center;

[0083] In step S320, the number of policies in a plurality of settlement databases is obtained, the number of policies being the number of the policies to be settled in each settlement database, wherein the number of policies is used to determine the number of live task instances corresponding to the settlement database, so that the target task instance allocates the corresponding number of live task instances to the settlement database according to the number of policies.

[0084] In steps S310 to S320, the availability of the task instances is improved by live checking the task instances, and the execution efficiency of the settlement database is further improved by allocating the corresponding number of task instances according to the number of policies in the settlement database, so as to realize the balanced use of the task instances.

[0085] Specifically, the task cluster includes a plurality of task instances, some of which are invalid or down. The registration center, also known as a micro-service management platform, can discover the IP of the live task instances under the task cluster through the registration center, and then allocate the task instances. For example, there are 10 task instances in the task cluster, 6 of which are normal and the other 4 of which are down. The registration center first detects the 6 live task instances, and the allocation of the task instances in the later stage will only allocate the 6 live task instances to the plurality of settlement databases, so as not to allocate the 4 down task instances to the settlement databases.

[0086] In an embodiment, the settlement database adopts oracle, the target task instance is equivalent to a leader, and each task instance needs to be assigned by the target task instance to execute the settlement database. The target task instance assigns a corresponding number of survival task instances to the settlement database according to the single quantity. Specifically, the instance weight of a plurality of settlement databases can be determined according to the single quantity, and a corresponding number of task instances are assigned to the plurality of settlement databases according to the instance weight. For example, there are 6 task instances, 3 settlement databases A-C, and if the corresponding instance weight ratio is 1:2:3 according to the single quantity of the settlement database, then after allocation, task instance 1 executes the settlement task of settlement database A, task instances 2-3 execute the B database task, and task instances 4-6 execute the C database task.

[0087] Please refer to Figure 4 In some embodiments, step S140 can include but is not limited to steps S410 to S440:

[0088] Step S410, querying the assigned settlement database according to the IP address of the task instance, and obtaining the to-be-settled policies in the settlement database;

[0089] Step S420, creating a thread pool according to the settlement database, creating a plurality of execution threads according to the task instance, and loading the plurality of execution threads into the thread pool;

[0090] Step S430, performing paging processing on the to-be-settled policies to obtain a plurality of pages, each page including a plurality of to-be-settled policies;

[0091] Step S440, concurrently executing the to-be-settled policies on the plurality of pages according to the plurality of execution threads.

[0092] Specifically, in steps S410 to S440, the IP address of the task instance can be used to find the corresponding settlement database, and the thread pool is created after the settlement database is found successfully. A plurality of execution threads are created according to the task instance, and the plurality of execution threads are loaded into the thread pool, the purpose being to ensure that the plurality of execution threads can ensure consistency when executing tasks. It should be noted that since the settlement database can have multiple task instances, but the thread pool is only one, the execution threads of multiple task instances are loaded into the same thread pool, which ensures that the same settlement database is not prone to errors during the execution of the policy. However, the execution threads of different task instances do not affect each other, and different execution threads of the same task instance also do not affect each other. In order to avoid different execution threads processing the same to-be-settled policy at the same time, in the embodiment, the to-be-settled policies are processed by paging to obtain a plurality of pages, each page including a plurality of to-be-settled policies, and the to-be-settled policies on the plurality of pages are executed concurrently according to the plurality of execution threads, it should be noted that one execution thread corresponds to the to-be-settled policies on one page. In an embodiment, the paging component of the framework uses pagehelper, which is a plugin of mybatis, and its function is to facilitate paging query. A single task instance uses multi-thread processing, in order to avoid different threads processing a single at the same time, taking 100 to-be-settled policies as one page. For example, A task instance starts 5 threads, and there are a total of 1 million single data, so a total of 10,000 pages can be divided, and the 5 execution threads execute pages 1-5 respectively, when the second thread finishes processing page 2 first, it continues to take the next page, that is, page 6, and then other threads process pages 7, 8 and 9 respectively on this basis, and so on. It is ensured that each to-be-settled policy is only in one page, and the to-be-settled policies in each page can only be processed by one execution thread under multi-thread, avoiding data errors caused by different threads processing the same to-be-settled policy.

[0093] Please refer to Figure 5 In some embodiments, step S440 can include but is not limited to steps S510 to S540:

[0094] Step S510, get the page, add all the to-be-settled policies on the page to the total table, and set the execution state field corresponding to each to-be-settled policy;

[0095] Step S520, execute the to-be-settled policies by each execution thread, and update the state record of the corresponding execution state field;

[0096] Step S530, when all the to-be-settled policies on each page of the settlement database are executed, judge the missing single through the state record and record the missing single;

[0097] Step S540, all the missing single is grabbed into the error single table, and the pending settlement policy on the error single table is re-executed through the task instance.

[0098] Specifically, in steps S510 to S540, the pages are acquired, and the pending settlement policies on the pages are all added to the total table, and the execution state field corresponding to each pending settlement policy is set, and the execution state field has corresponding state records. For example, the state record of the unprocessed pending settlement policy is 0, the state record of the normally executed successful pending settlement policy is 1, the state record of the error reported pending settlement policy is 2, and the state of the completed pending settlement policy in the area is 0. Each execution thread executes the pending settlement policy and updates the corresponding state record field. After the first full execution of all pages is completed, the missing single is determined through the state record, the error single table is grabbed, and the second supplementary processing is performed. The missing single includes the unprocessed pending settlement policy and the error reported pending settlement policy. The second supplementary processing is to re-execute the pending settlement policy on the error single table through the task instance.

[0099] In an embodiment, the execution thread executes each pending settlement policy by calling the single method, and specifically, the settlement involves the specific business processing of each pending settlement policy. For example, there are 1 million pending settlement policies to be settled, and each pending settlement policy needs to go through settlement policy interest, guarantee interest, deduction of guarantee cost, and calculation and update of continuous rewards to the corresponding account. Taking settlement policy interest as an example, the monthly settlement of each pending settlement policy is to use the settlement interest rate to calculate the interest generated in the month with the money in the customer's account as the principal, and the account value table will have an additional interest calculation data, and the total account value will also increase. The guarantee cost and the continuous reward are similar, the difference is that the account value is increased or decreased. For example, the guarantee cost deduction is the deduction of the guarantee fee of the pending settlement policy to the customer, and the account value will decrease.

[0100] In an embodiment, step S150 specifically includes the steps of: screening a first settlement database set in which the pending settlement policies have not been executed completely from the plurality of settlement databases, and randomly obtaining a second settlement database from the first settlement database set.

[0101] In an embodiment, step S150 specifically includes the steps of: screening a first settlement database set in which the pending settlement policies have not been executed completely from the plurality of settlement databases, and selecting a second settlement database from the first settlement database set according to a comparison between the current task instance number of the settlement database and the preset maximum execution task instance number.

[0102] Please refer to Figure 6 In some embodiments, step S150 can include but is not limited to steps S610 to S630.

[0103] Step S610, a first settlement database set in which the to-be-settled insurance policies have not been executed completely is filtered out from the plurality of settlement databases;

[0104] Step S620, a current task instance number of each settlement database in the first settlement database set is obtained, and a second settlement database set is filtered out from the first settlement database set according to the current task instance number and a preset maximum execution task instance number;

[0105] Step S630, a number of unprocessed to-be-settled insurance policies of each settlement database in the second settlement database set is obtained, and a second settlement database is filtered out from the second settlement database set according to the number of unprocessed to-be-settled insurance policies.

[0106] In steps S610 to S630, the idea of the election algorithm is that, first, the settlement databases in which the to-be-settled insurance policies have not been executed completely are found to obtain the first settlement database set. If there are at least two settlement databases in the first settlement database set, the current task instance number of the settlement database is compared with the preset maximum execution task instance number to select the second settlement database set in which the current task instance number does not exceed the preset maximum execution task instance number. If there are at least two settlement databases in the second settlement database set, the number of to-be-settled insurance policies of the settlement database is compared to select the second database in which the number of to-be-settled insurance policies is the most. The second settlement database is selected by the election algorithm in the embodiment of the present disclosure, and the to-be-settled insurance policies of the second settlement database are executed concurrently by the idle task instances, so that the idle task instances can be fully utilized, and the execution efficiency of the overall settlement database is improved.

[0107] The policy processing method provided by the embodiments of the present disclosure assigns task instances to multiple settlement databases through target task instances, ensuring the consistency of the allocation work. The task instances are assigned to the settlement databases according to the number of the to-be-settled policies of the settlement databases, and the assignment is more reasonable, which helps to improve the settlement efficiency of the settlement databases. The number of the task instances can also be dynamically expanded according to the number of the to-be-settled policies of the settlement databases, so as to improve the settlement efficiency of the settlement databases as the number of the task instances increases. The to-be-settled policies are processed by paging to obtain multiple pages, each page including multiple to-be-settled policies, and the to-be-settled policies on the multiple pages are concurrently executed according to a plurality of execution threads, so that the to-be-settled policies on each page can only be processed by one execution thread under multi-threading, avoiding data errors caused by the same to-be-settled policy being processed by different threads. The idle task instances of a settlement database are released when the to-be-settled policies of the settlement database are executed, and the idle task instances are assigned to the settlement databases that have not completed the execution of the to-be-settled policies through an election algorithm, so as to achieve multiple uses of the task instances and improve the resource utilization. In addition, the idle task instances can accelerate the execution efficiency of the to-be-settled policies of other settlement databases, shorten the execution time of other settlement databases, and improve the overall settlement efficiency of the settlement databases.

[0108] Please refer to Figure 7 The embodiments of the present disclosure also provide a policy processing device, which can implement the above policy processing method, Figure 7 A module structure block diagram of the policy processing device provided by the embodiments of the present disclosure is provided, and the device includes a creation module 710, a preemption module 720, an assignment module 730, a first execution module 740, and a second execution module 750. The creation module 710 is configured to create a task cluster, and the task cluster includes a plurality of task instances. The preemption module 720 is configured to preempt a distributed lock through the plurality of task instances, and the task instance that preempts the distributed lock is used as a target task instance. The assignment module 730 is configured to assign task instances to multiple settlement databases through the target task instance, and each settlement database is assigned to at least one task instance. The first execution module 740 is configured to concurrently execute the to-be-settled policies in the corresponding settlement database through the task instances. The second execution module 750 is configured to, for a first settlement database in which the to-be-settled policies have been executed, record the task instance corresponding to the first settlement database as an idle task instance, find a second settlement database in which the to-be-settled policies have not been executed through a preset election algorithm, assign the idle task instance to the second settlement database, and concurrently execute the to-be-settled policies of the second settlement database through the idle task instance, until the to-be-settled policies of all the settlement databases are executed.

[0109] The policy processing device provided in the embodiments of the present disclosure can assign task instances to a plurality of settlement databases through target task instances, thereby ensuring consistency of the assignment work. When the settlement of a policy to be settled by a certain settlement database is completed, the idle task instance of the settlement database is released, and the idle task instance is assigned to the settlement database that fails to complete the settlement of the policy to be settled through an election algorithm, so as to achieve multiple utilization of the task instance. The idle task instance can accelerate the execution efficiency of the settlement of the policy to be settled by other settlement databases, shorten the execution time of the other settlement databases, and improve the overall settlement efficiency of the settlement databases.

[0110] The specific implementation of the policy processing device is basically the same as that of the above-mentioned embodiments of the policy processing method, and will not be described here again.

[0111] The embodiments of the present disclosure further provide a computer device, which comprises a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing the connection and communication between the processor and the memory, and the program is executed by the processor to realize the above-mentioned policy processing method. The computer device can be any intelligent terminal including a tablet computer, a vehicle-mounted computer, etc.

[0112] Please refer to Figure 8 , Figure 8 The hardware structure of the computer device of another embodiment is illustrated, which comprises:

[0113] The processor 801 can be implemented in the form of a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, etc., for executing related programs to realize the technical solutions provided by the embodiments of the present disclosure.

[0114] The memory 802 can be implemented in the form of a ROM (Read Only Memory), a static storage device, a dynamic storage device, or a RAM (Random Access Memory), etc. The memory 802 can store an operating system and other application programs, and when the technical solutions provided by the embodiments of the present disclosure are implemented by software or firmware, the related program codes are stored in the memory 802 and called and executed by the processor 801 to realize the policy processing method of the embodiments of the present disclosure.

[0115] The input / output interface 803 is used to realize information input and output.

[0116] The communication interface 804 is configured to realize the communication interaction between the device and other devices. The communication can be realized in a wired manner (for example, a USB, a network cable, and the like) or in a wireless manner (for example, a mobile network, WIFI, Bluetooth, and the like).

[0117] The bus 805 is configured to transmit information between various components (for example, the processor 801, the memory 802, the input / output interface 803, and the communication interface 804) of the device.

[0118] The processor 801, the memory 802, the input / output interface 803, and the communication interface 804 are connected to each other through the bus 805 to realize the communication connection between the device.

[0119] The embodiment of the present application further provides a storage medium, which is a computer readable storage medium, is used for computer readable storage, and stores one or more programs. The one or more programs can be executed by one or more processors to realize the above-mentioned insurance processing method.

[0120] The memory is a non-transitory computer readable storage medium, and can be used to store a non-transitory software program and a non-transitory computer executable program. In addition, the memory can include a high-speed random access memory, and can further include a non-transitory memory, for example, at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory remotely arranged relative to the processor, and the remote memory can be connected to the processor through a network. Examples of the network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0121] The policy processing method and device, computer device and storage medium provided by the embodiments of the present application can assign task instances to a plurality of settlement databases through a target task instance, thereby ensuring the consistency of the assignment work. The task instances are assigned to the settlement databases according to the number of the to-be-settled policies of the settlement databases, and the assignment mode is more reasonable, which helps to improve the settlement efficiency of the settlement databases. The number of the task instances can also be dynamically expanded according to the number of the to-be-settled policies of the settlement databases, so as to improve the settlement efficiency of the settlement databases as the number of the task instances increases. The to-be-settled policies are subjected to page processing to obtain a plurality of pages, each page including a plurality of to-be-settled policies, and the to-be-settled policies on the plurality of pages are concurrently executed according to a plurality of execution threads, so that the to-be-settled policies of each page can only be processed by one execution thread under the multi-thread mode, thereby avoiding data errors caused by the same to-be-settled policy being processed by different threads. The idle task instances of a settlement database are released when the to-be-settled policies of the settlement database are executed, and the idle task instances are assigned to the settlement databases that fail to execute the to-be-settled policies through an election algorithm, so as to achieve multiple utilization of the task instances and improve the resource utilization rate. In addition, the idle task instances can accelerate the execution efficiency of the to-be-settled policies of other settlement databases, thereby shortening the execution time of the other settlement databases and improving the overall settlement efficiency of the settlement databases.

[0122] The embodiments described in the embodiments of the present application are used to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of technology and the appearance of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.

[0123] Those skilled in the art can understand that, Figures 1-6 The technical solutions shown in the foregoing embodiments do not constitute a limitation on the embodiments of the present application, and can include more or fewer steps than those shown in the figures, or combine certain steps or different steps.

[0124] The device embodiments described above are only schematic, and the units described as separate components can or can not be physically separate, that is, can be located in one place, or can be distributed on a plurality of network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of the present application.

[0125] Those skilled in the art can understand that all or some of the steps in the methods disclosed above, the function modules / units in the systems and devices can be implemented as software, firmware, hardware and appropriate combinations thereof.

[0126] The terms "first", "second", "third", "fourth", and the like in the description and in the claims of this application, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of the terms so termed is interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of orderly or chronological mundane operation, reverse order operation, based on circuitry availability, based on stated preference or the like, and that "default" or other orderings are thus permissible. Further, the terms "comprise", "comprising", "include", "including", and the like, are specifically intended to be open-ended. That is, references to individual steps and the like do not suhstantially exclude the presence of two or more of a given step or its integral presence in the process, method, system, article, or apparatus having been made with a wider scope. The use of notation such as "first", "second", "third", etc. does not generally limit the areas, but is used to connect like elements or to distinguish one claim from another. These terms can be used interchangeably when appropriate. Terms concerning the relative position of elements can be interpreted such that their use adheres to their normal meaning, but they can also be interpreted to mean the opposite according to specific claims.

[0127] It should be understood that, in the application, "at least one" refers to one or more, and "multiple" refers to two or more. "And / or", used to describe the relationship between associated objects, means that there can be three relationships, for example, "A and / or B" can mean that there are only A, only B, and A and B at the same time, where A and B can be singular or plural. The character " / " generally represents that the associated objects before and after are in an "or" relationship. "At least one of the following" or the like means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c can mean a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0128] In several embodiments provided in the application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the above-described device embodiments are only illustrative, for example, the division of the units is only a logical functional division, and actual implementation can have another division manner, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0129] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or they can be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0130] In addition, each of the functional units in the various embodiments of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0131] When the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such an understanding, the technical solutions of the present application, essentially or in part, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes multiple instructions used to cause a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various other media that can store programs.

[0132] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, and are not intended to limit the scope of the embodiments of the present application. Any modifications, equivalent replacements and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the embodiments of the present application.

Claims

1. A method of processing insurance policies, characterized by, The method comprises: obtaining a single quantity of a plurality of settlement databases, the single quantity being the number of policies to be settled of each of the settlement databases; determining the number of task instances according to the single quantity, and creating a task cluster by the task instances, the task cluster comprising a plurality of task instances; wherein the number of task instances is greater than the number of settlement databases; occupying a distributed lock by a plurality of task instances, and taking a task instance that has occupied the distributed lock as a target task instance; allocating the task instances to a plurality of settlement databases by the target task instance, wherein each of the settlement databases is allocated to at least one of the task instances; concurrently executing the policies to be settled in the corresponding settlement database by the task instances; for a first settlement database in which the policies to be settled have been executed, taking the task instance corresponding to the first settlement database as an idle task instance, finding a second settlement database in which the policies to be settled have not been executed by a preset election algorithm, and allocating the idle task instance to the second settlement database, and concurrently executing the policies to be settled in the second settlement database by the idle task instance, until all the policies to be settled in all the settlement databases are executed.

2. The method of claim 1, wherein, After the target task instance allocates the task instances to a plurality of settlement databases, a distribution completion identifier is created, and the method further comprises: querying the distribution completion identifier, if the distribution completion identifier does not exist, obtaining the duration of the target task instance occupying the distributed lock; if the duration is greater than a preset duration threshold, releasing the distributed lock corresponding to the target task instance, so as to trigger the task instance that has not occupied the distributed lock to occupy the released distributed lock.

3. The method of claim 1, wherein, The method further comprises: discovering a plurality of surviving task instances in the task cluster through a registration center; obtaining a single quantity of a plurality of settlement databases, the single quantity being the number of policies to be settled of each of the settlement databases, wherein the single quantity is used to determine the number of surviving task instances corresponding to the settlement database, so that the target task instance allocates a corresponding number of surviving task instances to the settlement database according to the single quantity.

4. The method of claim 1, wherein, The method further comprises: querying the allocated settlement database according to the IP address of the task instance, and obtaining the policies to be settled in the settlement database; creating a thread pool according to the settlement database, creating a plurality of execution threads according to the task instances, and loading a plurality of the execution threads into the thread pool; performing paging processing on the policies to be settled to obtain a plurality of pages, each of the pages comprising a plurality of the policies to be settled; concurrently executing the policies to be settled on a plurality of pages according to a plurality of execution threads.

5. The method of claim 4, wherein, The method further comprises: Obtaining the pages, adding all the to-be-settled policies on the pages to a total table while setting a corresponding execution state field of each to-be-settled policy; Executing the to-be-settled policies through each execution thread and updating the state record of the corresponding execution state field; When all the to-be-settled policies on each page of each settlement database are executed, judging the missing policies through the state record and recording the missing policies; Grabbing all the missing policies into a wrong policy table and re-executing the to-be-settled policies on the wrong policy table through the task instance.

6. The method according to any one of claims 1 to 5, characterized in that, The second settlement database in which the to-be-settled policies have not been executed completely is found through a preset election algorithm, including: Filtering a first settlement database set in which the to-be-settled policies have not been executed completely from a plurality of settlement databases; Obtaining the current task instance number of each settlement database of the first settlement database set, filtering a second settlement database set from the first settlement database set according to the current task instance number and a preset maximum execution task instance number; Obtaining the number of unprocessed to-be-settled policies of each settlement database in the second settlement database set, and filtering a second settlement database from the second settlement database set according to the number of unprocessed to-be-settled policies.

7. A policy processing apparatus characterized by comprising: Including: A creating module is configured to obtain the single quantity of a plurality of settlement databases, the single quantity being the number of to-be-settled policies of each settlement database, determine the number of task instances according to the single quantity, and create a task cluster by the task instances, the task cluster including a plurality of task instances; wherein the number of task instances is greater than the number of settlement databases; A preemption module is configured to preempt a distributed lock by the plurality of task instances, and take a task instance preempts the distributed lock as a target task instance; A distribution module is configured to distribute the task instances to a plurality of settlement databases by the target task instance, wherein each settlement database is distributed to at least one task instance; A first execution module is configured to execute the to-be-settled policies in the corresponding settlement database by the task instances in parallel; A second execution module is configured to, for a first settlement database in which the to-be-settled policies have been executed completely, record the corresponding task instance of the first settlement database as an idle task instance, find a second settlement database in which the to-be-settled policies have not been executed completely through a preset election algorithm, distribute the idle task instance to the second settlement database, and execute the to-be-settled policies of the second settlement database by the idle task instance in parallel until all the to-be-settled policies of all the settlement databases are executed completely.

8. A computer device, comprising: The computer device includes a memory, a processor, a program stored on the memory and executable on the processor, and a data bus for realizing the connection communication between the processor and the memory, and the program is executed by the processor to realize the steps of the method of any one of claims 1 to 6.

9. A storage medium, the storage medium being a computer-readable storage medium for computer-readable storage, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement steps of the method of any one of claims 1 to 6.

Citation Information

Patent Citations

  • Timed task processing method and device and computing equipment

    CN106874094A