CN111488224A - Distributed metering charging method and system - Google Patents
Distributed metering charging method and system Download PDFInfo
- Publication number
- CN111488224A CN111488224A CN202010239690.1A CN202010239690A CN111488224A CN 111488224 A CN111488224 A CN 111488224A CN 202010239690 A CN202010239690 A CN 202010239690A CN 111488224 A CN111488224 A CN 111488224A
- Authority
- CN
- China
- Prior art keywords
- tenant
- metering
- room
- charging
- queue
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 47
- 238000004364 calculation method Methods 0.000 claims abstract description 57
- 238000012545 processing Methods 0.000 claims abstract description 13
- 238000012544 monitoring process Methods 0.000 claims abstract description 10
- 238000004806 packaging method and process Methods 0.000 claims abstract description 7
- 230000014509 gene expression Effects 0.000 claims description 42
- 238000009434 installation Methods 0.000 claims description 18
- 238000012216 screening Methods 0.000 claims description 6
- 238000012423 maintenance Methods 0.000 abstract description 8
- 230000008569 process Effects 0.000 description 13
- 238000007726 management method Methods 0.000 description 9
- 238000011161 development Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 5
- 230000009471 action Effects 0.000 description 3
- 238000009825 accumulation Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000003139 buffering effect Effects 0.000 description 1
- 239000000306 component Substances 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 239000008358 core component Substances 0.000 description 1
- 238000013500 data storage Methods 0.000 description 1
- 230000003111 delayed effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000005259 measurement Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 239000010453 quartz Substances 0.000 description 1
- VYPSYNLAJGMNEJ-UHFFFAOYSA-N silicon dioxide Inorganic materials O=[Si]=O VYPSYNLAJGMNEJ-UHFFFAOYSA-N 0.000 description 1
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q30/00—Commerce
- G06Q30/02—Marketing; Price estimation or determination; Fundraising
- G06Q30/0283—Price estimation or determination
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q30/00—Commerce
- G06Q30/06—Buying, selling or leasing transactions
- G06Q30/0645—Rental transactions; Leasing transactions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/548—Queue
Landscapes
- Business, Economics & Management (AREA)
- Engineering & Computer Science (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Development Economics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Physics & Mathematics (AREA)
- Strategic Management (AREA)
- Software Systems (AREA)
- Economics (AREA)
- Marketing (AREA)
- General Business, Economics & Management (AREA)
- General Engineering & Computer Science (AREA)
- Entrepreneurship & Innovation (AREA)
- Game Theory and Decision Science (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
The application relates to a distributed metering charging method and a distributed metering charging system, which relate to the technical field of multi-tenant and multi-terminal metering charging, and are used for packaging tenant and room information which need to be metered and charged into queue data and establishing a plurality of independent message queues and public message queue receiving queue data; the independent message queue is used for receiving queue data needing to be monitored by establishing an independent thread, the common message queue is used for receiving queue data needing not to be monitored by establishing the independent thread, the thread pools are respectively established for each independent message queue and the common message queue to realize multi-thread monitoring and processing of the queue data, and finally distributed calculation of the usage and the cost with a room as a main body is realized. Therefore, the method and the device can improve the calculation efficiency and timeliness, reduce the calculation delay, facilitate the maintenance of the codes at the later stage, and can independently extract the metering and charging service to be applied to different metering systems, thereby having strong universality.
Description
Technical Field
The present application relates to the technical field of multi-tenant multi-terminal metering charging, and in particular, to a distributed metering charging method and system.
Background
With the development of the internet of things and cloud computing, the traditional application system is developed through customization requirements, and the problems of long construction period, high cost, difficulty in maintenance and the like exist, so that the problem is well solved to a certain extent by the birth of the SaaS application system. The SaaS application system is characterized in that a provider of the SaaS application system builds all network infrastructure, software and hardware operation platforms required by informatization for enterprises, is responsible for a series of services such as all early implementation, later maintenance and the like, is a software layout model, is specially designed for network delivery, and is convenient for users to host, deploy and access through the Internet; the system can provide a unified functional system meeting the requirements in various aspects for different enterprises (tenants) to use; for enterprises, the method has the advantages of no need of purchasing software and hardware, building a machine room, recruiting professional IT technical personnel, short development period and the like, and the enterprises can use the information system directly through the Internet.
In the related technology, more and more application systems with metering and charging functions are developed based on a SaaS platform, but the development process usually does not disassemble and separate the functions, the adhesion degree between the functions is too high, and even all the functions are realized in one method, so that the problems of inconvenient iteration, maintenance and the like of codes occur, and when users of the system are increased greatly, the problems of poor service performance, charging delay, charging information loss and the like of the SaaS application system can also occur; for a simple SaaS application system with a small user amount, for charging, the room charging below each tenant is often executed in a single application and single thread sequence, that is, room information below the next tenant can be calculated only after one tenant finishes calculating, which may cause problems of calculation delay and low efficiency, and if an error occurs in the intermediate calculation process, the whole process may not be executed.
Disclosure of Invention
The embodiment of the application provides a distributed metering and charging method and system, and aims to solve the problems that in the related art, a metering and charging system developed based on a SaaS platform is delayed in calculation, poor in timeliness, low in efficiency and inconvenient to maintain later codes.
In a first aspect, a method for distributed metering charging is provided, which includes the following steps:
creating a tenant and configuring tenant information, wherein the tenant information comprises a function expression needing to be measured, a function expression needing to be charged and an independent queue identifier needing to be independently queued, and creating a room under the tenant and configuring room information, wherein the room information comprises measuring terminal information, charging unit price and rules;
creating a trigger calculation function, and acquiring a real-time state quantity which enables the trigger calculation function to occur;
comparing the real-time state quantity with the function expression to be metered, screening out the real-time state quantity meeting the function expression to be metered, matching the real-time state quantity with the function expression to be charged, and packaging a matching result, tenant information and room information into queue data;
creating a message queue, the message queue comprising a plurality of independent message queues and a common message queue; if the identifier of the queue needing to be independent is preset as true, inserting the queue data into the independent message queue, otherwise, inserting the queue data into a public message queue;
and establishing a plurality of thread pools, wherein the thread pools correspond to the message queues one by one respectively and are used for carrying out multi-thread monitoring and processing on queue data in the message queues, acquiring the information of the metering terminal, the unit price and the rule of charging, and calculating the usage and the cost of the room.
In some embodiments, the tenant information further comprises a tenant ID and a tenant name; the room information further includes a room ID, a room number, a room name, and a tenant ID; the metering terminal information comprises a metering terminal number, a tenant ID, a metering type, an installation metering stop code, a latest metering stop code and latest uploading time.
The calculation of the usage and the cost of the tenant comprises the following steps: carrying out subtraction operation on the latest metering stop code and the installation metering stop code, and calculating the usage amount of the room; obtaining the matching result, if the matching result is marked as true, subtracting the latest metering stop code and the installation metering stop code to obtain the usage, and calculating the cost of the room by combining the charging unit price and the rule; and if the matching result is marked as false, the charging operation is not needed, and the method is ended.
The method further comprises the steps of: the usage and cost may also generate corresponding usage records and cost records.
The trigger calculation function is a timing trigger function or a quantitative trigger function.
In a second aspect, a system for distributed metering charging is provided, including: the system comprises a file management module, a service management module and a service management module, wherein the file management module is used for creating tenants and configuring tenant information, the tenant information comprises function expressions needing to be measured, function expressions needing to be charged and independent queue identifications needing to be independently queued, rooms are created under the tenants and room information is configured, and the room information comprises measuring terminal information, charging unit price and rules;
the trigger scheduling module is used for creating a trigger calculation function and acquiring real-time state quantity which enables the trigger calculation function to occur; comparing the real-time state quantity with the function expression to be metered, screening out the real-time state quantity meeting the function expression to be metered, matching the real-time state quantity with the function expression to be charged, and packaging a matching result, tenant information and room information into queue data;
the message queue module is used for creating a message queue, and the message queue comprises a plurality of independent message queues and a common message queue; the independent message queue is used for receiving queue data of which the identifier of the queue to be independent is preset as true, and the public message queue is used for receiving queue data of which the identifier of the queue to be independent is preset as false;
and the charging module is used for establishing a plurality of thread pools, the thread pools respectively correspond to the message queues one by one, and the charging module is used for carrying out multi-thread monitoring and processing on queue data in the message queues, acquiring the information of the metering terminal, the unit price and the rule of charging, and calculating the usage and the cost of the room.
In some embodiments, the tenant information further comprises a tenant ID and a tenant name; the room information further includes a room ID, a room number, a room name, and a tenant ID; the metering terminal information comprises a metering terminal number, a tenant ID, a metering type, an installation metering stop code, a latest metering stop code and latest uploading time.
The calculation of the usage amount and the cost of the tenant specifically comprises the following steps: carrying out subtraction operation on the latest metering stop code and the installation metering stop code, and calculating the usage amount of the room; obtaining the matching result, if the matching result is marked as true, subtracting the latest metering stop code and the installation metering stop code to obtain the usage, and calculating the cost of the room by combining the charging unit price and the rule; and if the matching result is marked as false, the charging operation is not needed, and the method is ended.
The charging module is also used for generating usage records and expense records.
The trigger calculation function is a timing trigger function or a quantitative trigger function.
The beneficial effect that technical scheme that this application provided brought includes: the metering and charging of the multi-tenant are performed by distributed calculation with the room as a main body, so that the calculation efficiency and timeliness of the multi-tenant can be improved, the calculation delay is reduced, and the maintenance of codes at the later stage is facilitated.
The embodiment of the application provides a distributed metering charging method and a distributed metering charging system, as tenant and room information needing to be metered and charged are encapsulated into queue data, and a plurality of independent message queues and public message queue receiving queue data are established; the independent message queue is used for receiving queue data needing to be monitored by establishing an independent thread, the common message queue is used for receiving queue data needing not to be monitored by establishing the independent thread, the thread pools are respectively established for each independent message queue and the common message queue to realize multi-thread monitoring and processing of the queue data, and finally distributed calculation of the usage and the cost with a room as a main body is realized. Therefore, by creating different thread pools and simultaneously performing multi-thread calculation on room data of different tenants, the calculation efficiency and timeliness of the room data are improved, calculation delay is reduced, maintenance of codes at the later stage is facilitated, metering and charging services can be extracted independently and applied to different metering systems, and the method has strong universality.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a distributed metering charging method according to an embodiment of the present application;
fig. 2 is a schematic flowchart of distributed metering charging provided in an embodiment of the present application;
fig. 3 is a schematic timing trigger flow chart according to an embodiment of the present application;
FIG. 4 is a schematic diagram of the calculation of usage and cost provided by an embodiment of the present application;
fig. 5 is a schematic structural diagram of an association relationship between different information provided in the embodiment of the present application;
fig. 6 is a schematic structural diagram of a distributed metering and charging system according to an embodiment of the present application;
fig. 7 is a diagram of a distributed computing architecture provided in an embodiment of the present application.
In the figure: 1-file management module, 2-trigger scheduling module, 3-message queue module and 4-charging module.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a distributed metering and charging method and system, which can solve the problems of calculation delay, poor timeliness, low efficiency and inconvenience in later code maintenance of a metering and charging system developed based on a SaaS platform in the related art.
Fig. 1 is a schematic flowchart of a method for distributed metering charging according to an embodiment of the present application, where the method includes:
s1: and establishing a tenant and configuring tenant information, wherein the tenant information comprises a function expression to be metered, a function expression to be charged and an independent queue identifier to be charged, establishing a room under the tenant and configuring room information, and the room information comprises metering terminal information, charging unit price and rules.
The tenant information further comprises a tenant ID and a tenant name; the room information further includes a room ID, a room number, a room name, and a tenant ID; the information of the metering terminal comprises a metering terminal number, a tenant ID, a metering type, an installation metering stop code, a latest metering stop code and latest uploading time, the installation metering stop code represents the stop code of the last calculated amount of the metering terminal, the latest metering stop code represents the stop code of the latest calculated amount of the metering terminal, and the latest uploading time represents the uploading time of the latest metering stop code.
S2: and creating a trigger calculation function and acquiring the real-time state quantity for the trigger calculation function.
Preferably, the trigger calculation function is a timed trigger function or a quantitative trigger function.
S3: and comparing the real-time state quantity with the function expression to be metered, screening out the real-time state quantity meeting the function expression to be metered, matching the real-time state quantity with the function expression to be charged, and packaging a matching result, tenant information and room information into queue data.
S4: creating a message queue, wherein the message queue comprises a plurality of independent message queues and a common message queue; and if the identifier of the independent queue is required to be preset as true, inserting the queue data into the independent message queue, otherwise, inserting the queue data into the public message queue.
S5: and establishing a plurality of thread pools, wherein the thread pools are respectively in one-to-one correspondence with the message queues and are used for carrying out multi-thread monitoring and processing on queue data in the message queues, acquiring the information of the metering terminal, the unit price and the rule of charging, and calculating the usage and the cost of the room.
An embodiment of the method of the present application is described in detail below with reference to fig. 2.
Fig. 2 is a schematic flowchart of distributed metering charging according to an embodiment of the present application.
Firstly, creating tenant information and setting related configuration information, wherein the main configuration information comprises a function expression needing metering, a function expression needing charging and an independent queue identification needing charging; different room information is created under different tenants, the room information comprises metering terminal information, charging unit price and rules, and different metering terminal information is associated in different rooms, wherein the metering terminals include but are not limited to an electric meter, a water meter and a gas meter; for a metering terminal, real-time metering data needs to be acquired and stored in a database.
Then, a trigger calculation function is created, and a real-time state quantity for the trigger calculation function to occur is acquired. Referring to fig. 3, taking the timing trigger function as the trigger calculation function as an example, the real-time state quantity is the current time for triggering the timing schedule: the method is realized by adopting a quartz framework, the execution is carried out once in 1 minute by default, meanwhile, a global worker thread pool with the specified number of threads is created for executing the judgment logic of each tenant, wherein each thread is used for calculating and inquiring the information list of the metering terminal under different tenants, at the moment, all tenants, the information of the consumption and the cost calculation configuration information are inquired by executing at the fixed time of every minute, then, each tenant is subjected to circular traversal, and the execution is carried out through the threads in the global worker thread pool in the traversal process.
The process executed by each thread is as follows: matching a function expression to be metered of the tenant with a trigger time of the current timing schedule, for example, the function expression to be metered is 0? If the current trigger timing scheduling time is 10 o' clock 15 of a certain day, the current time meets the expression of the function to be metered, and the tenant needs to perform calculation operation of the usage at the moment, all room information below the tenant can be requested to be acquired through an http protocol and the tenant ID, otherwise, if the room information is not matched, the program is terminated; if the current time meets the expression of the function needing to be metered, then continuing to match the current time with the expression of the function needing to be charged (the charging matching rule is consistent with the metering matching rule), if the current time does not meet the expression of the function needing to be charged, indicating that the tenant only needs to calculate the usage but does not need to perform charging operation, setting the identification field of the tenant needing to be an independent queue as false, and assembling the matching result, tenant information and room information into queue data in a json format, such as { "tentld": "10001", "roommid": "782212", "meterType": "elec", "iscalcost": false, isCalcCost is false, which means that the charging is not needed after the usage is calculated; if the current time meets the charging function expression, the tenant needs not only to calculate the usage amount but also to perform charging operation, the independent queue identification field of the tenant is set as true, and the matching result, tenant information and room information are assembled into queue data in a json format, such as { "tentld": "10001", "roommid": "782212", "meterType": "elec", "iscalcost": true, IsCalcCost is true, which indicates that the usage needs to be charged after being calculated.
Referring to fig. 2, a message queue is created, which includes a plurality of independent message queues and a common message queue, where the independent message queues are used to receive queue data that needs to be monitored by creating an independent thread, and the common message queue is used to receive queue data that does not need to be monitored by creating an independent thread; through the configuration judgment of database information 'an independent queue identifier is required' of the tenant, if the independent queue identifier is preset as true, the queue data of the tenant is inserted into an independent message queue based on a JMS standard; and if the required independent queue identifier is preset as false or empty, inserting the queue data of the tenant into the common message queue based on the JMS standard.
Referring to fig. 4, according to the configuration of whether a tenant needs an independent queue identifier, if the independent queue identifier is preset as true, an independent thread is started and created to monitor queue data in an independent message queue where the tenant is located, and an independent work thread pool is created for processing and calculating the queue data; if the independent queue identifier is required to be preset as false or empty, starting a default thread to monitor queue data in a public queue where the tenant is located; the monitoring thread is blocked when no queue data exists, if the queue has data, the obtained queue data is handed to the working thread pool corresponding to the monitoring thread to carry out multithread processing, each thread acquires the information of the metering terminal, calls the latest metering stop code and the installation metering stop code through the ID of the metering terminal, and performing subtraction usage calculation operation, performing storage operation such as accumulation or new addition of usage records of time period according to hour, day and month, meanwhile, the metering stop code is updated and installed in the metering terminal stop code calculation record of the database, and the optimistic lock is used for ensuring the accuracy of the database data calculation, namely, a version field is added in a terminal stop code calculation table maintained in a database, 1 is added after the last calculated stop code is calculated each time, and the safety of the thread is further ensured through the locking of the database.
After the usage calculation is completed, judging whether each metering terminal in the queue needs to be charged or not by acquiring a field of 'charging required' of each metering terminal, if the isCalcCost is false, indicating that charging is not required, executing subsequent codes and directly ending the program; if the iscalcost is true, which indicates that charging operation is required, the information of the unit price of the room, the charging rule and the like is obtained, charging operation is carried out by combining the calculated usage, the cost is finally calculated, storage operation such as accumulation or new addition of the charging record is carried out, and real-time fee deduction operation can be carried out according to the requirement of the user.
As shown in fig. 5, the charging is performed by taking a room as a main body, and there may be a plurality of metering terminals in a room that need to perform the calculation operation and data storage of the usage and charging, so the message queue is also inserted by taking a room as a main body, which indicates which rooms of the tenant need to perform the calculation operation of the usage and charging. The charging process design firstly calculates the usage, then judges whether the charge is calculated or not according to corresponding conditions, and then carries out charging calculation.
Referring to fig. 6, an embodiment of the present application further provides a schematic structural diagram of a distributed metering and charging system, where the system includes a file management module 1, a trigger scheduling module 2, a message queue module 3, and a charging module 4, each of which is an independent deployment module and provides a corresponding service IP and a port to provide resource access and call of http/tcp between the modules; the system comprises a file management module 1, a trigger scheduling module 2 and a charging module 4, wherein the file management module 1 is used for creating tenants and configuring tenant information, the tenant information comprises a function expression to be metered, a function expression to be charged and an independent queue identifier to be independently queued, rooms are created under the tenants and room information is configured, the room information comprises metering terminal information, charging unit price and rules and the incidence relation between the rooms and the metering terminals, and the file management module 1 is also used for updating metering stop code information of the metering terminals into a metering terminal information base in real time and finally providing the metering stop code information for the trigger scheduling module 2 and the charging module 4 to call http interfaces.
As shown in table 1, the tenant information further includes a tenant ID and a tenant name; referring to table 2, the room information further includes a room ID, a room number, a room name, and a tenant ID; referring to table 3, the metering terminal information includes a metering terminal number, a tenant ID, a metering type, an installation metering stop code, a latest metering stop code, and latest uploading time, the installation metering stop code represents a stop code of the last calculated amount of the metering terminal, the latest metering stop code represents a stop code of the latest calculated amount of the metering terminal, and the latest uploading time represents the uploading time of the latest metering stop code; see table 4 for an association of the room with the metering terminal.
Table 1 tenant information table
Tenant ID | Tenant name | Expression of function to be measured | Function expression for charging | Requiring independent queue identification |
10001 | Tenant A | 0*/10***? | 0 0 24**? | true |
10002 | Tenant B | 0*/10***? | 0 0 8**? | true |
TABLE 2 Room information Table
Room ID | Room number | Name of room | Tenant ID | Unit price and rule of charging |
782212 | 110 | 110 | 10001 | {“elecPrice”:0.5} |
782213 | 101 | 101 | 10002 | {“elecPrice”:0.5} |
TABLE 3 metering terminal information
Metering terminal number | Tenant ID | Type of metering | Installation measurement stop code | Latest metering stop code | Latest upload time |
0000000101 | 10001 | Electric meter | 0 | 50 | 2020-2-22 |
0000000102 | 10002 | Electric meter | 0 | 60 | 2020-2-22 |
Table 4 relationship table of room-measuring terminal
Room ID | Metering terminal number |
782212 | 0000000101 |
782213 | 0000000102 |
The trigger scheduling module 2 is used for creating a trigger calculation function and acquiring a real-time state quantity which enables the trigger calculation function to occur; and comparing the real-time state quantity with the function expression to be metered, screening out the real-time state quantity meeting the function expression to be metered, matching the real-time state quantity with the function expression to be charged, and packaging a matching result, tenant information and room information into queue data. The whole system is realized by taking json queue data as a target, taking a timing trigger function as a trigger condition, carrying out rule matching on tenant information, judging whether the tenant really reaches the calculated time, and sending queue data to the charging module 4 for calculation processing through different message queues. The trigger scheduling module 2 acquires corresponding queue data through the queue data format standard provided by the charging module 4 to assemble, sets whether charging is needed or not through a function expression needing charging, and then inserts the message queue, and the subsequent process does not need excessive development and realization.
The message queue module 3 is used for creating a message queue which is an independent component, is based on JMS standard open source service, and is used for decoupling and buffering data among systems, receiving json data transmitted by the trigger scheduling module 2, and enabling data acquisition and multithreading processing to be adopted; the message queue comprises a plurality of independent message queues and a public message queue, wherein the independent message queues are used for receiving queue data needing the independent queue identification to be preset as true, and the public message queue is used for receiving the queue data needing the independent queue identification to be preset as false.
The charging module 4 is used as a core component for calculating the charge, and is used for creating a plurality of thread pools, the thread pools are respectively in one-to-one correspondence with the message queues, and are used for carrying out multithread monitoring and processing on queue data in the message queues, acquiring the information of the metering terminal, the charging unit price and the rules, calculating the usage and the charge of the room, finally generating a usage record and a charging record, and carrying out updating and storing of the data and real-time fee deduction operation.
Referring to fig. 7, in the prior art, a charging module is arranged to process all queue data, which has the problems of low performance and low calculation efficiency; the method comprises the steps of establishing a plurality of charging modules to perform distributed processing on queue data, relocating a charging module with the same function at any time if the charging service has low performance, configuring a tenant object to be processed by each charging module, and then distributing the charging modules on different servers to process different json data in the message queue at the same time. Therefore, distributed charging can simultaneously process data calculation of rooms below different tenants through multiple threads, the problem of mutual charging influence among the multiple tenants is solved, the calculation efficiency and timeliness can be improved, the calculation delay can be reduced, and the maintenance of later codes is facilitated.
With the continuous development of platforms and the continuous increase of metering terminals, in the face of the calculation of massive computing terminals, the method can calculate the real-time usage and cost, generate corresponding usage records and charging records, and provide subsequent fee deduction services; the metering and charging module can be separately extracted and applied to different metering systems, so that the method has strong universality, not only solves the problem of transverse data calculation, but also has the characteristics of high performance and low delay under the condition of ensuring the calculation accuracy.
In the description of the present application, it should be noted that the terms "upper", "lower", and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, which are only for convenience in describing the present application and simplifying the description, and do not indicate or imply that the referred device or element must have a specific orientation, be constructed in a specific orientation, and operate, and thus, should not be construed as limiting the present application. Unless expressly stated or limited otherwise, the terms "mounted," "connected," and "connected" are intended to be inclusive and mean, for example, that they may be fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meaning of the above terms in the present application can be understood by those of ordinary skill in the art as appropriate.
It is noted that, in the present application, relational terms such as "first" and "second", and the like, are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above description is merely exemplary of the present application and is presented to enable those skilled in the art to understand and practice the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (10)
1. A method for distributed metering charging, comprising the steps of:
creating a tenant and configuring tenant information, wherein the tenant information comprises a function expression needing to be measured, a function expression needing to be charged and an independent queue identifier needing to be independently queued, and creating a room under the tenant and configuring room information, wherein the room information comprises measuring terminal information, charging unit price and rules;
creating a trigger calculation function, and acquiring a real-time state quantity which enables the trigger calculation function to occur;
comparing the real-time state quantity with the function expression to be metered, screening out the real-time state quantity meeting the function expression to be metered, matching the real-time state quantity with the function expression to be charged, and packaging a matching result, tenant information and room information into queue data;
creating a message queue, the message queue comprising a plurality of independent message queues and a common message queue; if the identifier of the queue needing to be independent is preset as true, inserting the queue data into the independent message queue, otherwise, inserting the queue data into a public message queue;
and establishing a plurality of thread pools, wherein the thread pools correspond to the message queues one by one respectively and are used for carrying out multi-thread monitoring and processing on queue data in the message queues, acquiring the information of the metering terminal, the unit price and the rule of charging, and calculating the usage and the cost of the room.
2. The method of distributed metered charging according to claim 1, wherein: the tenant information further comprises a tenant ID and a tenant name; the room information further includes a room ID, a room number, a room name, and a tenant ID; the metering terminal information comprises a metering terminal number, a tenant ID, a metering type, an installation metering stop code, a latest metering stop code and latest uploading time.
3. The method of distributed metered charging according to claim 2, wherein: the calculation of the usage and the cost of the tenant comprises the following steps:
carrying out subtraction operation on the latest metering stop code and the installation metering stop code, and calculating the usage amount of the room;
obtaining the matching result, if the matching result is marked as true, subtracting the latest metering stop code and the installation metering stop code to obtain the usage, and calculating the cost of the room by combining the charging unit price and the rule; and if the matching result is marked as false, the charging operation is not needed, and the method is ended.
4. The method of distributed metered charging according to claim 1, wherein: the method further comprises the steps of: the usage and cost may also generate corresponding usage records and cost records.
5. The method of distributed metered charging according to claim 1, wherein: the trigger calculation function is a timing trigger function or a quantitative trigger function.
6. A system for distributed metered billing, comprising:
the system comprises a file management module (1), a server and a server, wherein the file management module (1) is used for creating tenants and configuring tenant information, the tenant information comprises metering function expressions, charging function expressions and independent queue identifiers, rooms are created under the tenants and room information is configured, and the room information comprises metering terminal information, charging unit prices and rules;
the trigger scheduling module (2), the trigger scheduling module (2) is used for creating a trigger calculation function, and acquiring the real-time state quantity of the trigger calculation function; comparing the real-time state quantity with the function expression to be metered, screening out the real-time state quantity meeting the function expression to be metered, matching the real-time state quantity with the function expression to be charged, and packaging a matching result, tenant information and room information into queue data;
a message queue module (3), the message queue module (3) being configured to create a message queue, the message queue comprising a plurality of independent message queues and a common message queue; the independent message queue is used for receiving queue data of which the identifier of the queue to be independent is preset as true, and the public message queue is used for receiving queue data of which the identifier of the queue to be independent is preset as false;
and the charging module (4) is used for creating a plurality of thread pools, the thread pools are respectively in one-to-one correspondence with the message queues, and are used for carrying out multi-thread monitoring and processing on queue data in the message queues, acquiring the information of the metering terminal, the unit price and the rule of charging, and calculating the usage and the cost of the room.
7. The system for distributed metered charging of claim 6 wherein: the tenant information further comprises a tenant ID and a tenant name; the room information further includes a room ID, a room number, a room name, and a tenant ID; the metering terminal information comprises a metering terminal number, a tenant ID, a metering type, an installation metering stop code, a latest metering stop code and latest uploading time.
8. The system for distributed metered billing according to claim 7 wherein: the calculation of the usage amount and the cost of the tenant specifically comprises the following steps:
carrying out subtraction operation on the latest metering stop code and the installation metering stop code, and calculating the usage amount of the room;
obtaining the matching result, if the matching result is marked as true, subtracting the latest metering stop code and the installation metering stop code to obtain the usage, and calculating the cost of the room by combining the charging unit price and the rule; and if the matching result is marked as false, the charging operation is not needed, and the method is ended.
9. The system for distributed metered charging of claim 6 wherein: the charging module (4) is also used for generating usage records and charge records.
10. The system for distributed metered charging of claim 6 wherein: the trigger calculation function is a timing trigger function or a quantitative trigger function.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010239690.1A CN111488224A (en) | 2020-03-30 | 2020-03-30 | Distributed metering charging method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010239690.1A CN111488224A (en) | 2020-03-30 | 2020-03-30 | Distributed metering charging method and system |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111488224A true CN111488224A (en) | 2020-08-04 |
Family
ID=71798637
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010239690.1A Pending CN111488224A (en) | 2020-03-30 | 2020-03-30 | Distributed metering charging method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111488224A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113495797A (en) * | 2021-06-22 | 2021-10-12 | 上海百秋电子商务有限公司 | Message queue and consumer dynamic creation method and system |
CN113986497A (en) * | 2021-10-27 | 2022-01-28 | 北京百度网讯科技有限公司 | Queue scheduling method, device and system based on multi-tenant technology |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020198888A1 (en) * | 1999-05-04 | 2002-12-26 | Metratech | Method and apparatus for ordering data processing by multiple processing modules |
CN106097587A (en) * | 2016-08-04 | 2016-11-09 | 刘世和 | Based on cloud platform, the distributed electric vehicle charging management system of many tenants and method |
US20170168472A1 (en) * | 2015-09-29 | 2017-06-15 | Kabushiki Kaisha Toshiba | Information processing apparatus or information communication terminal, and information processing method |
CN110233741A (en) * | 2019-05-21 | 2019-09-13 | 深圳壹账通智能科技有限公司 | Service charging method, device, equipment and storage medium |
CN110535787A (en) * | 2019-07-25 | 2019-12-03 | 北京奇艺世纪科技有限公司 | Information consumption method, apparatus and readable storage medium storing program for executing |
-
2020
- 2020-03-30 CN CN202010239690.1A patent/CN111488224A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020198888A1 (en) * | 1999-05-04 | 2002-12-26 | Metratech | Method and apparatus for ordering data processing by multiple processing modules |
US20170168472A1 (en) * | 2015-09-29 | 2017-06-15 | Kabushiki Kaisha Toshiba | Information processing apparatus or information communication terminal, and information processing method |
CN106097587A (en) * | 2016-08-04 | 2016-11-09 | 刘世和 | Based on cloud platform, the distributed electric vehicle charging management system of many tenants and method |
CN110233741A (en) * | 2019-05-21 | 2019-09-13 | 深圳壹账通智能科技有限公司 | Service charging method, device, equipment and storage medium |
CN110535787A (en) * | 2019-07-25 | 2019-12-03 | 北京奇艺世纪科技有限公司 | Information consumption method, apparatus and readable storage medium storing program for executing |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113495797A (en) * | 2021-06-22 | 2021-10-12 | 上海百秋电子商务有限公司 | Message queue and consumer dynamic creation method and system |
CN113495797B (en) * | 2021-06-22 | 2023-03-07 | 上海百秋新网商数字科技有限公司 | Message queue and consumer dynamic creation method and system |
CN113986497A (en) * | 2021-10-27 | 2022-01-28 | 北京百度网讯科技有限公司 | Queue scheduling method, device and system based on multi-tenant technology |
CN113986497B (en) * | 2021-10-27 | 2022-11-22 | 北京百度网讯科技有限公司 | Queue scheduling method, device and system based on multi-tenant technology |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019006654A1 (en) | Financial self-service equipment maintenance dispatch generation method, hand-held terminal and electronic device | |
CN106548402B (en) | Resource transfer monitoring method and device | |
CN111488224A (en) | Distributed metering charging method and system | |
CN101520863A (en) | Management platform and associated method for managing smart meters | |
EP3850516B1 (en) | Optimized execution of fraud detection rules | |
CN108345537A (en) | The concurrently execution control method of TPC-C benchmark test tools | |
US11695673B2 (en) | System and method for collecting consumption | |
CN108632047B (en) | Method and device for determining tariff data | |
CN110689223A (en) | Robot batch management system based on RPA control | |
CN105490864A (en) | Business module monitoring method based on OSGI | |
CN109035063A (en) | A kind of personal terminal service system inquired and paid the fees for electricity consumption | |
CN108919172A (en) | A kind of automatic time synchronization method of electric energy meter, device and terminal device | |
KR102130003B1 (en) | Remote power monitoring system | |
CN111192123A (en) | Account checking system based on hybrid cloud computing platform and account checking method thereof | |
CN111581483A (en) | Charging method, electronic device and storage medium | |
CN116613894B (en) | Method and device for processing electricity consumption data | |
CN113034307B (en) | Data acquisition method for power enterprise | |
Dujak et al. | Machine-to-machine communication as key enabler in smart metering systems | |
CN106095856A (en) | A kind of analysis method and device of client's outage information | |
WO2021258719A1 (en) | Billing method and system for container platform | |
CN113780625A (en) | Method, system, terminal and storage medium for predicting user electric charge | |
CN114765562B (en) | Cloud service charging method and system, storage medium and electronic terminal | |
CN114493756A (en) | Resource management method, device, equipment and storage medium | |
CN110197367A (en) | Big data quantity automatic settlement method based on electric business platform | |
CN111506633A (en) | Expense allocation method, device, equipment, system and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200804 |