Methods for processing inconsistent data from different sources
By storing and updating the status flag values of non-source inconsistent data in the database, the problem of inaccurate update of grid status information in the data acquisition system is solved, and the credibility and consistency of the data are improved.
Patent Information
- Application Number
- CN202111477407.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2024-10-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the data acquisition system, inaccurate updates of grid status information lead to inconsistencies in data source records, affecting the accuracy of the data acquisition system.
By storing non-original inconsistent data in the database, specific steps are used to set the status flag value to ensure the accuracy and reliability of data processing, including sorting and updating the status flag value according to the user ID and grid ID to ensure data consistency. sex.
It improves the credibility of data in the data acquisition system, ensures the accuracy and consistency of grid status information, and reduces the inaccuracy of data source records.
Smart Images

Figure CN114154027B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a method for processing non-homologous inconsistent data. Background Art
[0002] In some specific application scenarios, the data acquisition system needs to obtain the status information of specific grids in a preset geographical area. The status information of these specific grids needs to be actively informed to the corresponding data source by the user corresponding to the grid, and then the corresponding data source reports to the data acquisition system. This acquisition method will cause inaccuracy in the status information recorded in the data source. For example, a specific grid is in state 1 at time t1, and may have changed at time t2. Since the user of the specific grid did not inform the corresponding data source, this will cause the status information stored in the data source to be inaccurate. As a result, the data obtained by the data acquisition system from multiple data sources will be inconsistent. Summary of the invention
[0003] In response to the above technical problems, the present application provides a method for processing inconsistent data from different sources, which can obtain the status information of a specific grid as accurately as possible.
[0004] This application provides a method for processing inconsistent data from different sources.
[0005] The embodiment of the present invention provides a method for processing inconsistent data of different sources, wherein M inconsistent data of different sources are stored in a database in a record manner, wherein each record in the database includes a first user identifier U1ID, a second user identifier U2ID, a grid identifier GID, an agreed start time T S , agreed end time T E and a state flag value Stateflag, the initial value of Stateflag is Null; the agreed start time refers to the start time agreed upon by the first user and the second user to establish a connection between the grid and the first user, and the agreed end time refers to the time agreed upon by the first user and the second user to terminate the connection between the grid and the first user;
[0006] The method comprises the following steps:
[0007] S100, get T from the database E >T(or T E ≥T) and obtain T E ≤T(or T E <T), T is the current time, N1+N2=M;
[0008] S120, traverse N1 records, if the GID and U1ID in a certain record are not found to be the same in any of the M records, set the corresponding Stateflag to the first state value; obtain A records without a state flag value set in the N1 records; execute S140;
[0009] S140, traverse A records, if the GID in a record is the same as the GID in M records, then T in all records containing the GID in A record is S The Stateflag in the latest record is set to the first state value, and the Stateflag in the remaining records is set to the second state value; B records without a state flag value set in the N1 records are obtained; S160 is executed;
[0010] S160, traverse B records, if the U1ID in a record is the same as the U1ID in M records, then T in all records in B records containing the U1ID in the record is S The Stateflag in the latest record is set to the first state value, and the Stateflag in the remaining records is set to the third state value;
[0011] S200, traverse the records without setting the state flag value, if the U2ID in a certain record retrieves the same U1ID in M records, and the Stateflag of the retrieved record is the first state value, then set the Stateflag of the record to the first state value; execute S220;
[0012] S220, continue to traverse the records without setting the state flag value, if the U1ID in a certain record retrieves the same U1ID in M records, and the Stateflag of the retrieved record is the first state value, then set the Stateflag of the record to the second state value; execute S240;
[0013] S240, continue to traverse the records without setting the state flag value, if the GID and U1ID in a certain record are not found to be the same in any of the M records, then set the Stateflag of the record to the fourth state value.
[0014] The method for processing inconsistent data of non-homologous origin provided by an embodiment of the present invention firstly searches for records in the database whose agreed end time is less than the current time in the order of the first user identifier U1ID and the grid identifier GID, the grid identifier GID, and the first user identifier U1ID to obtain the status flag value of each record; then, searches for records without a status flag value set in the order of the second user identifier U2ID, the first user identifier U1ID, and the first user identifier U1ID and the grid identifier GID to obtain the status flag value of each record, so that the processed data becomes reliable and the credibility of the data can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0016] Figure 1 A flowchart of a method for processing inconsistent data of different origins provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0018] The embodiment of the present invention provides a method for processing inconsistent data from different sources, which is used to process inconsistent data reported by different data sources. M inconsistent data from different sources are stored in a database in a record manner, wherein each record in the database may include a first user identifier U1ID, a second user identifier U2ID, a grid identifier GID, an agreed start time T S , agreed end time T E and state flag value Stateflag, for example, the i-th record includes (i, U1ID i , U2ID i , GID i , TS i ,TE i , M.T. i ), the initial value of Stateflag is Null. In an exemplary embodiment, M records are stored in the grid state record table, as shown in Table 1 below.
[0019] Table 1 Grid status record table
[0020] Serial number U1ID U2ID GID TS TE MT
[0021] In an embodiment of the present invention, the first user and the second user in each record are users associated with the corresponding grid. The grid is a grid within a preset geographical area. The preset geographical area is a user-defined setting. The agreed start time refers to the start time agreed upon by the first user and the second user for the grid to establish a connection with the first user, and the agreed end time refers to the time agreed upon by the first user and the second user to terminate the connection between the grid and the first user. In a specific application scenario, the grid may be a house, the first user may be a tenant, and the second user may be a landlord, that is, GID may be a house ID, U2ID may be a landlord ID, and U1ID may be a tenant ID.
[0022] In an embodiment of the present invention, Stateflag is used to indicate the state of a grid. In an illustrative embodiment, Stateflag may be indicated by a first state value, a second state value, a third state value, and a fourth state value. Among them, the first state value indicates that the grid has not terminated its relationship with the corresponding first user, for example, the house is in a rented state, the second state value indicates that the grid has terminated its relationship with the corresponding first user, for example, the house is not rented out, and the third state value and the fourth state value indicate that the probability that the grid has not terminated its relationship with the corresponding first user is P1 and P2, respectively. For example, the probability of renting a house, P1 and P2 are different, and the values of P1 and P2 are 0 to 1. In an illustrative embodiment, the first state value is 0x01, the second state value is 0x00, the third state value is 0x11, and the fourth state value is 0x10.
[0023] In an exemplary embodiment, each record may further include a probability value, wherein for the first state value, the corresponding probability is 1, for the second state value, the corresponding probability is 0, for the third state value, the corresponding probability is P1, and for the fourth state value, the corresponding probability is P2.
[0024] In the embodiment of the present invention, the database is connected to multiple data sources for communication, and is used to receive grid status information reported by the multiple data sources and update the grid status record table.
[0025] Furthermore, if Figure 1 As shown, the method for processing non-homologous inconsistent data provided by the embodiment of the present invention includes the following steps:
[0026] S100, get T from the database E >T(or T E ≥T) and obtain N1 records of TE≤T (or T E <T), T is the current time, N1+N2=M;
[0027] S120, traverse N1 records, if the GID and U1ID in a certain record are not found to be the same in any of the M records, that is, the GID and U1ID in the record are unique, then set the corresponding Stateflag to the first state value; execute S140;
[0028] After this step, A records without setting the status flag value will be obtained among the N1 records, that is, the remaining A records without setting the status flag value among the N1 records. Obviously, A≤N1.
[0029] S140, traverse A records, if the GID in a record is the same as the GID in M records, then T in all records containing the GID in A record is S The Stateflag in the latest record is set to the first state value, and the Stateflag in the remaining records is set to the second state value; execute S160;
[0030] After this step, A records without a status flag value set in the N1 records will be obtained, that is, the remaining B records without a status flag value set in the N1 records. Obviously, B≤A.
[0031] In this step, all records in record A that contain the GID in this record are replaced by T. S The Stateflag in the latest record is set to the first state value, and the Stateflag in the remaining records is set to the second state value, indicating that the T in all records containing the GID in this record S There is a connection between the grid corresponding to the latest record and the first user, while the grids corresponding to the remaining records have been disconnected from the first user, that is, there is no connection between them.
[0032] S160, traverse B records, if the U1ID in a record is the same as the U1ID in M records, then T in all records in B records containing the U1ID in the record is S The Stateflag in the latest record is set to the first state value, and the Stateflag in the remaining records is set to the third state value;
[0033] In this step, all records in B containing the U1ID in this record are replaced by T S The MT in the latest record is set to the first state value, and the Stateflag in the remaining records is set to the third state value, indicating that the T in all records containing the U1ID in this record in B records is SThere is a connection between the grid corresponding to the latest record and the first user, and the probability that there is a connection between the grids corresponding to the remaining records and the first user is P1.
[0034] S200, traverse the records without setting the state flag value, if the U2ID in a certain record retrieves the same U1ID in M records, and the Stateflag of the retrieved record is the first state value, then set the Stateflag of the record to the first state value; execute S220;
[0035] In this step, if the U2ID in a certain record retrieves the same U1ID in M records, and the Stateflag of the retrieved record is the first state value, it means that there is still a connection between the grid corresponding to the record and the first user, even if the agreed end time is less than the current time.
[0036] S220, continue to traverse the records without setting the state flag value, if the U1ID in a certain record retrieves the same U1ID in M records, and the Stateflag of the retrieved record is the first state value, then set the Stateflag of the record to the second state value; execute S240;
[0037] In this step, if the same U1ID as the U1ID in a certain record is retrieved in M records, and the Stateflag of the retrieved record is the second state value, it means that there is no connection between the grid corresponding to the record and the first user.
[0038] S240, continue to traverse the records without setting the state flag value, if the GID and U1ID in a certain record are not found to be the same in any of the M records, then set the Stateflag of the record to the fourth state value.
[0039] In this step, if the GID and U1ID in a certain record are not found to be the same in any of the M records, it means that the probability that there is a connection between the grid corresponding to the record and the first user is P2.
[0040] In the embodiment of the present invention, S120 to S160 must be executed in sequence, and after S120 to S160, the status flag values of N1 records will be set. S200 to S220 must be executed in sequence, and after S200 to S220, the status flag values of N2 records will be set.
[0041] Furthermore, before step S200, the method further includes:
[0042] S180, traverse the records without setting the state flag value, if the GID in a certain record retrieves the same GID in M records, and the Stateflag of the retrieved record is the first state value or the third state value, then set the Stateflag of the record to the second state value.
[0043] In this step, if the GID in a certain record is retrieved from M records with the same GID, and the Stateflag of the retrieved record is the first state value or the third state value, it means that there is no connection between the grid corresponding to the record and the first user.
[0044] Through S120 to S240, M records each having a status flag value set therein can be obtained.
[0045] The database in the embodiment of the present invention is also connected to the server. The server includes a processor and a memory, and the memory stores a computer program. The processor executes the above steps when executing the computer program.
[0046] Furthermore, it also includes:
[0047] S260, respectively determine the actual number of records Q1 corresponding to the first state value, the actual number of records Q2 corresponding to the third state value, and the actual number of records Q3 corresponding to the fourth state value, wherein the actual number of records Q1 corresponding to the first state value is the number C1 of the first state value, the actual number of records Q2 corresponding to the third state value is the number C2*P1 of the third state value, and the actual number of records Q3 corresponding to the fourth state value is the number C3*P2 of the fourth state value.
[0048] S280, obtain Q1+Q2+Q3.
[0049] Furthermore, it also includes: visually presenting the acquired Q1+Q2+Q3.
[0050] Further, in an exemplary embodiment of the present invention, the value of P1 is 0.95 to 1, preferably, a number randomly generated from 0.95 to 1. That is, the probabilities corresponding to all third state values are the same number randomly generated from 0.95 to 1, for example, 0.98. In this way, the actual number of records corresponding to the third state value Q2 = C2*0.98.
[0051] Further, in another embodiment of the present invention, the actual number of records Q2 corresponding to the third state value can be obtained by the following steps:
[0052] S261, obtain the number C1 of the state flag value being the first state value and the number C2 of the state flag value being the third state value, if C2 / C1<a, execute S262; otherwise, execute S263; a is a preset threshold, preferably, it can be 0.3%.
[0053] S262, setting the probability P1 of each record in C2 records to any value between 0.95 and 1, and obtaining Q2=C2*P1.
[0054] S263, sending confirmation information to the first user in any record in C2 records, for example, the confirmation information can be sent by sending an email, a message or making a phone call to the mobile terminal of the first user. If confirmation information indicating that the first user has not terminated the relationship with the corresponding grid is received, the probability P1 of the record is set to 1, otherwise, the probability P1 of the record is set to 0.
[0055] S264, obtaining the number of records C21 with probability P1=1, and obtaining Q2=C21.
[0056] In this way, the actual number of records Q2 corresponding to the third state value is equal to the number of records in C2 in which the first user has not terminated the relationship with the corresponding grid.
[0057] In the embodiment of the present invention, P2 = D1 / (D1+D2), where D1 is the number of GIDs in all records whose agreed end time is less than the preset time before the current time that appear only once in all records, and D2 is the number of GIDs in all records that appear more than or equal to twice. The preset time is the grid status update cycle, which is a custom setting.
[0058] The method for processing inconsistent data of non-homologous origin provided by an embodiment of the present invention firstly searches for records in the database whose agreed end time is less than the current time in the order of the first user identifier U1ID and the grid identifier GID, the grid identifier GID, and the first user identifier U1ID to obtain the status flag value of each record; then, searches for records without a status flag value set in the order of the second user identifier U2ID, the first user identifier U1ID, and the first user identifier U1ID and the grid identifier GID to obtain the status flag value of each record, so that the processed data becomes reliable and the credibility of the data can be improved.
[0059] Although some specific embodiments of the present application have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are only for illustration and not for limiting the scope of the present application. It will also be appreciated by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present application. The scope of the present application is defined by the appended claims.
Claims
1. A method for processing inconsistent data from different sources. It is characterized in that M non-homologous inconsistent data are stored in a database in a record format, wherein each record in the database includes a first user identifier U1ID, a second user identifier U2ID, a grid identifier GID, an agreed start time T S , agreed end time T E and a state flag value Stateflag, the initial value of Stateflag is Null; the agreed start time refers to the start time agreed upon by the first user and the second user to establish a connection between the grid and the first user, and the agreed end time refers to the time agreed upon by the first user and the second user to terminate the connection between the grid and the first user; The method comprises the following steps: S100, get T from the database E > N1 records of T and get T E N2 records ≤ T, or obtain T from the database E N1 records ≥ T and get T E <N2 records of T, T is the current time, N1+N2=M; S120, traverse N1 records, if the GID and U1ID in a certain record are not found to be the same in any of the M records, set the corresponding Stateflag to the first state value; obtain A records without a state flag value set in the N1 records; execute S140; S140, traverse A records, if the GID in a record is the same as the GID in M records, then T in all records containing the GID in A record is S The Stateflag in the latest record is set to the first state value, and the Stateflag in the remaining records is set to the second state value; B records without a state flag value set in the N1 records are obtained; S160 is executed; S160, traverse B records, if the U1ID in a record is the same as the U1ID in M records, then T in all records in B records containing the U1ID in the record is S The Stateflag in the latest record is set to the first state value, and the Stateflag in the remaining records is set to the third state value; S200, traverse the records without setting the state flag value, if the U2ID in a certain record retrieves the same U1ID in M records, and the Stateflag of the retrieved record is the first state value, then set the Stateflag of the record to the first state value; execute S220; S220, continue to traverse the records without setting the state flag value, if the U1ID in a certain record retrieves the same U1ID in M records, and the Stateflag of the retrieved record is the first state value, then set the Stateflag of the record to the second state value; execute S240; S240, continue to traverse the records without setting the state flag value, if the GID and U1ID in a certain record are not found to be the same in any of the M records, then set the Stateflag of the record to the fourth state value.
2. The method according to claim 1, It is characterized in that Before step S200, the method further includes: S180, traverse the records without setting the state flag value, if the GID in a certain record retrieves the same GID in M records, and the Stateflag of the retrieved record is the first state value or the third state value, then set the Stateflag of the record to the second state value.
3. The method according to claim 1, It is characterized in that The first state value indicates that the grid has not terminated its relationship with the corresponding first user, the second state value indicates that the grid has terminated its relationship with the corresponding first user, the third state value and the fourth state value respectively indicate that the probability that the grid has not terminated its relationship with the corresponding first user is P1 and P2, P1 and P2 are different, and the values of P1 and P2 are 0 to 1.
4. The method according to claim 3, It is characterized in that Also includes: S260, respectively determining that the state flag value is the actual number of records Q1 corresponding to the first state value, the actual number of records Q2 corresponding to the third state value, and the actual number of records Q3 corresponding to the fourth state value, wherein the actual number of records Q1 corresponding to the first state value is the number C1 of the first state value, the actual number of records Q2 corresponding to the third state value is the number C2*P1 of the third state value, and the actual number of records Q3 corresponding to the fourth state value is the number C3*P2 of the fourth state value; S280, obtain Q1+Q2+Q3.
5. The method according to claim 4, It is characterized in that The value of P1 is 0.95~1.
6. The method according to claim 4, It is characterized in that The actual number of records Q2 corresponding to the third state value is obtained by the following steps: S261, obtaining the number C1 of the state flag value being the first state value and the number C2 of the state flag value being the third state value, if C2 / C1<a, executing S262; Otherwise, execute S263; a is a preset threshold; S262, setting the probability P1 of each record in C2 records to any value between 0.95 and 1, and obtaining Q2 = C2*P1; S263, sending confirmation information to the first user in any record of the C2 records, if the confirmation information indicating that the first user has not terminated the relationship with the corresponding grid is received, setting the probability P1 of the record to 1, otherwise, setting the probability P1 of the record to 0; S264, obtain the number of records C2 with probability P1=1 1 , we get Q2=C2 1 .
7. The method according to claim 6, It is characterized in that a is 0.3%.
8. The method according to claim 4, It is characterized in that P2=D1 / (D1+D2), where D1 is the number of GIDs in all records whose agreed end time is less than the preset time before the current time that appear only once in all records, and D2 is the number of GIDs in all records that appear greater than or equal to twice.
9. The method according to claim 7, It is characterized in that The preset time is the grid status update cycle.
10. The method according to any one of claims 1 to 9, It is characterized in that The first state value is 0x01, the second state value is 0x00, the third state value is 0x11, and the fourth state value is 0x10.
