Geographic entity encoding method and system based on Spring Batch
Through the Spring Batch framework and GB/T40087-2021 geospatial grid coding rules, combined with listeners and index tables, the problems of low efficiency and high error rate of traditional geographic entity coding are solved, and fast and reliable geographic entity coding is achieved.
Patent Information
- Application Number
- CN202311316298.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-12
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2043-10-12
AI Technical Summary
Traditional geographic entity coding methods are inefficient, resource-intensive, impact business functions, and have high error rates, making it difficult to achieve large-scale, rapid coding.
A geographic entity encoding method based on Spring Batch is adopted, using ItemReader, ItemProcessor and ItemWriter listeners, combined with GB/T40087-2021 earth space grid encoding rules, and paging query, listener and index table to achieve rapid generation and storage of geographic entity codes.
It improves the efficiency of geographic entity coding, reduces the error rate, ensures the uniqueness and query speed of data, reduces resource usage, and achieves efficient and reliable coding processing.
Smart Images

Figure CN117312474B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of geographic entity coding generation, in particular to a SpringBatch-based geographic entity coding method and system. Background Art
[0002] Spring Batch is a batch processing framework in the Spring Framework ecosystem, designed to help developers efficiently develop and execute large-scale, complex batch processing tasks.
[0003] Spring Batch provides a powerful and flexible API for building and executing various types of batch jobs. It supports a variety of data sources and data processing methods, including file processing, database operations, and remote calls. It also provides a variety of extensible mechanisms and components, such as readers, processors, writers, and filters, enabling developers to easily implement various complex batch processing scenarios.
[0004] Spring Batch also provides many additional features, such as transaction management, exception handling, restart mechanism, parallel processing, monitoring and reporting, etc., making the development and operation of batch jobs more reliable, efficient and easy to manage.
[0005] Geographic entity data is a new type of basic surveying and mapping product, as defined in the "Technical Outline for the Construction of a Smart City Spatiotemporal Big Data Platform (2019 Edition)." Based on topographic maps, geographic entity data materializes boundaries, administrative divisions, roads, water systems, courtyards, buildings, vegetation, and other content, assigning them unique codes that serve as the basis for linking with other industry and thematic data. Beyond its inherent significance, the core attribute of geographic entities is their unique code, which allows them to be linked to various industry and thematic data.
[0006] Geographic entity coding is an identification code suitable for the management and application of basic geographic entities. It enables globally proprietary and unique identification of basic geographic entities, as well as information-related sharing. The construction of geographic entity coding can effectively improve the efficiency of organizing, processing, analyzing, transmitting, and utilizing basic geographic entity data, achieve standardized and standardized management of basic geographic entities, and provide more user-friendly and convenient geographic information services for various applications. It effectively addresses the bottlenecks in the identification and expression of massive spatial information in the Internet of Things, big data, and cloud computing, and enables efficient organization of multi-source, multi-scale data in a grid-like manner.
[0007] In traditional geographic entity coding implementation methods, the coding process and business systems are mutually coupled. Compared with traditional data, spatial data has a particularly large amount of data, which will occupy a large amount of system resources such as CPU and memory, resulting in low efficiency and affecting the normal use of business functions.
[0008] Therefore, how to achieve large-scale rapid geographic entity coding, thereby improving geographic entity coding efficiency and reducing geographic entity coding error rate is a technical problem that needs to be solved urgently. Summary of the Invention
[0009] The technical task of the present invention is to provide a geographic entity encoding method and system based on Spring Batch to solve the problem of how to achieve large-scale rapid geographic entity encoding, thereby improving geographic entity encoding efficiency and reducing geographic entity encoding error rate.
[0010] The technical task of the present invention is achieved in the following manner: a geographic entity encoding method based on Spring Batch, the method is as follows:
[0011] Reading geographic entity data: Query the geographic entity table from the database based on the database's geographic information view table, and parse multimodal spatial metadata based on the entity table. Utilize the ItemReader and ItemWriter listeners provided by the Spring Batch framework to add a processing record table to record whether the data has been read and processed successfully. When subsequent tasks are restarted, data reading will be based on this record table, and records that have been successfully read and processed will be skipped.
[0012] Generate geographic entity codes: implement geographic entity codes through itemprocessor, and implement specific processing logic based on GB / T40087-2021 geospatial grid coding rules;
[0013] Storing geographic entity data encoding: Establish a coding table to record the coding information of geographic entities, and implement coding storage through the ItemWriter listener provided by SpringBatch; among them, the coding table is used to record data source information, table name, unique index ID of specific data and geographic entity code.
[0014] As a preference, the geographic entity data is read as follows:
[0015] Use the JdbcPagingItemReader provided by Spring Batch to query the database in pages and return the data to a list collection. The paging parameters are consistent with the chunk parameters configured in the job.
[0016] Read the data source information, columns, table names, where conditions, where parameters, and unique indexes. The data source information, columns, table names, where conditions, where parameters, and unique indexes are all passed through job parameters to implement dynamic business SQL execution for greater business flexibility.
[0017] Define a data reading listener that inherits the ItemReaderListener provided by Spring Batch and implements the beforeRead method, afterRead method, and onReadError method. In the beforeRead method, connect to the database to create a data processing task record. In the afterRead method, update the status of the data processing task record to read success based on the unique index. In the onReadError method, update the status of the data processing task record to read failure based on the unique index.
[0018] Preferably, the geographic entity code is generated by implementing the process method of ItemProcessor, and the geographic entity code is implemented in the process method according to the earth space grid coding rules based on GB / T40087-2021.
[0019] Preferably, the geographic entity coding adopts a three-part coding paradigm of "proprietary identification domain + standard domain + extension domain" to standardize the coding structure and content of basic geographic entities;
[0020] The "proprietary identification domain" consists of a 2-digit root identifier code and a 4-digit basic geographic entity dedicated code, which is used to uniquely identify basic geographic entities based on the MA international identification system;
[0021] The "standard domain" consists of a 26-bit (two-dimensional) or 44-bit (three-dimensional) location code, a 6-bit classification code, and a 4-bit sequence code to uniquely identify basic geographic entities;
[0022] The "extended domain" is a variable-length code used to interact with other codes or record information related to basic geographic entities, meeting the "one code, multiple forms" usage requirements of spatial identity coding.
[0023] Preferably, the geographic entity data is stored in the following encoding:
[0024] The Spring Batch framework uses JdbcBatchItemWriter, a JDBC support component, to encode and store geographic entity data in the database. The JdbcBatchItemWriter implements the ItemWriter interface to convert item objects into records in the database.
[0025] Define a data storage listener that inherits the ItemWriteListener provided by Spring Batch and implements the beforeWrite, afterWrite, and onWriteError methods. In the beforeWrite method, connect to the database to create a data storage task record. In the afterWrite method, update the status of the data processing task record to storage success based on the unique index. In the onWriteError method, update the status of the data processing task record to storage failure based on the unique index.
[0026] In order to ensure the security of the original data and ensure that the performance of the original database is not affected, a database and data table are established to record the geographic entity coding data. The recorded geographic entity coding data includes the geographic entity coding code, original data source information, original data table information, original data unique index information and spatial information, etc.; through a method similar to this index table, the unique correspondence between the geographic entity code and the original data is achieved, thereby improving the query speed, reducing the query time, and effectively strengthening the uniqueness control.
[0027] A geographic entity coding system based on Spring Batch, the system includes:
[0028] The reading module is used to query the geographic entity table from the database based on the database's geographic information view table and parse multimodal spatial metadata based on the entity table. It then uses the ItemReader and ItemWriter listeners provided by the Spring Batch framework to add a processing record table to record whether the data has been read and processed successfully. When subsequent tasks are restarted, the data reading will be judged based on this record table, and records that have been successfully read and processed will be skipped directly.
[0029] Generate a module for implementing geographic entity coding through itemprocessor and implementing specific processing logic based on GB / T40087-2021 geospatial grid coding rules;
[0030] The storage module is used to establish a coding table to record the coding information of geographic entities and implement coding storage through the ItemWriter listener provided by Spring Batch; among them, the coding table is used to record data source information, table name, unique index ID of specific data and geographic entity code.
[0031] Preferably, the reading module includes:
[0032] The query submodule is used to use the JdbcPagingItemReader provided by Spring Batch to implement paging queries in the database and return data to a list collection. The paging parameters are consistent with the chunk parameters configured in the job.
[0033] The transfer submodule is used to read the data source information, columns, table names, where conditions, where parameters, and unique indexes of the data. The data source information, columns, table names, where conditions, where parameters, and unique indexes are all transferred through job parameters to implement dynamic business SQL execution for greater business flexibility.
[0034] The data reading definition submodule is used to define a data reading listener, which inherits the ItemReaderListener provided by Spring Batch and implements the beforeRead method, afterRead method, and onReadError method. In the beforeRead method, a data processing task record is created by connecting to the database. In the afterRead method, the status of the data processing task record is updated to read success based on the unique index. In the onReadError method, the status of the data processing task record is updated to read failure based on the unique index.
[0035] The generation module is generated by implementing the process method of ItemProcessor, and the geographic entity coding is implemented in the process method according to the provided earth space grid coding rules based on GB / T40087-2021; among them, the geographic entity coding adopts a coding paradigm divided into three sections of "proprietary identification domain + standard domain + extended domain" to standardize the coding structure and content of the basic geographic entity; the "proprietary identification domain" consists of a 2-bit root identifier code and a 4-bit basic geographic entity dedicated code, which is used to uniquely identify the basic geographic entity based on the MA international identification system; the "standard domain" consists of a 26-bit (two-dimensional) or 44-bit (three-dimensional) location code, a 6-bit classification code and a 4-bit sequence code to achieve unique identification of the basic geographic entity; the "extended domain" is a variable-length code used to interact with other codes or record information related to the basic geographic entity, meeting the "one code multiple forms" usage requirements of spatial identity coding.
[0036] More preferably, the storage module includes:
[0037] The encoding and storage submodule is used to use the JdbcBatchItemWriter component provided by the Spring Batch framework to encode and store geographic entity data in the database. The JdbcBatchItemWriter implements the ItemWriter interface to convert item objects into records in the database.
[0038] The data storage definition submodule is used to define a data storage listener that inherits the ItemWriteListener provided by Spring Batch and implements the beforeWrite method, afterWrite method, and onWriteError method. In the beforeWrite method, a database connection is created to create a data storage task record. In the afterWrite method, the status of the data processing task record is updated to storage success based on the unique index. In the onWriteError method, the status of the data processing task record is updated to storage failure based on the unique index.
[0039] A submodule is established to establish another database and data table to record geographic entity coding data, ensure the security of original data, ensure that the performance of the original database is not affected, and record geographic entity coding data including geographic entity coding code, original data source information, original data table information, original data unique index information and spatial information; through a method similar to this index table, the unique correspondence between geographic entity coding and original data is achieved, thereby improving query speed, reducing query time, and effectively strengthening uniqueness control.
[0040] An electronic device comprising: a memory and at least one processor;
[0041] Wherein, the memory stores a computer program;
[0042] The at least one processor executes the computer program stored in the memory, so that the at least one processor executes the above-mentioned Spring Batch-based geographic entity encoding method.
[0043] A computer-readable storage medium stores a computer program, which can be executed by a processor to implement the above-mentioned Spring Batch-based geographic entity encoding method.
[0044] The geographic entity encoding method and system based on Spring Batch of the present invention have the following advantages:
[0045] (1) The present invention utilizes the powerful large-scale data processing capability and scalability of Spring Batch to achieve large-scale rapid geographic entity coding, aiming to improve geographic entity coding efficiency and reduce geographic entity coding error rate;
[0046] (2) The present invention is applied to project construction, realizing the rapid generation of large quantities of geographic entity codes, which can effectively improve the generation efficiency. By storing geographic entity codes in a manner similar to an index table, it can effectively ensure uniqueness, guarantee the security of original data, improve query speed, and reduce the query time of subsequent use of geographic entity codes;
[0047] (3) The present invention makes full use of the Spring Batch framework to achieve reliability and high efficiency in geographic entity coding, and provides external services through an interface, which is easy to use and highly scalable;
[0048] (4) The present invention uses the Spring Batch framework to query the geographic entity table from the database according to the geographic information view table of the database, and parses the multimodal spatial metadata according to the entity table to implement geographic entity encoding through the itemprocessor, and implements the encoding into the database through the itemwriter provided by Spring Batch;
[0049] (5) The present invention utilizes the Spring Batch framework to read geographic entity data through readers and listeners, and automatically monitors the reading status;
[0050] (6) The present invention utilizes the Spring Batch framework and a custom processor to implement geographic entity encoding;
[0051] (7) The present invention utilizes the Spring Batch framework, customizes the storage executor and listener, encodes and stores geographic entity data, and automatically monitors the storage status;
[0052] (8) The present invention achieves unique correspondence between geographic entity codes and original data by defining an index table, thereby improving query speed, reducing query time, and effectively strengthening uniqueness control. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The present invention will be further described below with reference to the accompanying drawings.
[0054] Attachment Figure 1 A flowchart for the process of coding geographic entities. DETAILED DESCRIPTION
[0055] The Spring Batch-based geographic entity encoding method and system of the present invention are described in detail below with reference to the accompanying drawings and specific embodiments.
[0056] Example 1:
[0057] This embodiment provides a geographic entity encoding method based on Spring Batch, which is as follows:
[0058] S1. Reading geographic entity data: Query the geographic entity table from the database based on the database's geographic information view table, and parse multimodal spatial metadata based on the entity table. Utilize the ItemReader and ItemWriter listeners provided by the Spring Batch framework to add a processing record table to record whether the data has been read and processed successfully. When subsequent tasks are restarted, data reading will be based on this record table, and records that have been successfully read and processed will be skipped.
[0059] S2. Generate geographic entity code: Implement geographic entity coding through itemprocessor and implement specific processing logic based on GB / T40087-2021 geospatial grid coding rules;
[0060] S3. Storing geographic entity data codes: Establish a code table to record the code information of geographic entities, and implement code storage through the ItemWriter listener provided by SpringBatch; the code table is used to record data source information, table name, unique index ID of specific data, and geographic entity code.
[0061] The specific steps of reading geographic entity data in step S1 of this embodiment are as follows:
[0062] S101. Use the JdbcPagingItemReader provided by Spring Batch to query the database in pages and return the data to a list collection. The paging parameters should be consistent with the chunk parameters configured in the job.
[0063] S102. Read the data source information, columns, table names, where conditions, where parameters, and unique index of the data. The data source information, columns, table names, where conditions, where parameters, and unique index are all passed through job parameters to implement dynamic business SQL execution for greater business flexibility.
[0064] S103. Define a data reading listener that inherits the ItemReaderListener provided by Spring Batch and implements the beforeRead method, afterRead method, and onReadError method. In the beforeRead method, connect to the database to create a data processing task record. In the afterRead method, update the status of the data processing task record to read successfully based on the unique index. In the onReadError method, update the status of the data processing task record to read failed based on the unique index.
[0065] The geographic entity code in this embodiment is generated by implementing the process method of ItemProcessor, and the geographic entity code is implemented in the process method according to the earth space grid coding rules based on GB / T40087-2021.
[0066] The geographic entity coding in this embodiment adopts a three-segment coding paradigm of "proprietary identification domain + standard domain + extension domain" to standardize the coding structure and content of basic geographic entities;
[0067] The "proprietary identification domain" consists of a 2-digit root identifier code and a 4-digit basic geographic entity dedicated code, which is used to uniquely identify basic geographic entities based on the MA international identification system;
[0068] The "standard domain" consists of a 26-bit (two-dimensional) or 44-bit (three-dimensional) location code, a 6-bit classification code, and a 4-bit sequence code to uniquely identify basic geographic entities;
[0069] The "extended domain" is a variable-length code used to interact with other codes or record information related to basic geographic entities, meeting the "one code, multiple forms" usage requirements of spatial identity coding.
[0070] The stored geographic entity data encoding in step S3 of this embodiment is specifically as follows:
[0071] S301. Using the JdbcBatchItemWriter component provided by the Spring Batch framework to support JDBC, the geographic entity data is encoded and stored in the database. The ItemWriter interface is implemented by JdbcBatchItemWriter to convert the Item object into a record in the database.
[0072] S302. Define a data storage listener that inherits the ItemWriteListener provided by Spring Batch and implements the beforeWrite method, afterWrite method, and onWriteError method. In the beforeWrite method, connect to the database to create a data storage task record. In the afterWrite method, update the status of the data processing task record to storage success based on the unique index. In the onWriteError method, update the status of the data processing task record to storage failure based on the unique index.
[0073] S303. In order to ensure the security of the original data and ensure that the performance of the original database is not affected, a database and data table are established to record the geographic entity coding data. The recorded geographic entity coding data includes the geographic entity coding code, original data source information, original data table information, original data unique index information and spatial information, etc.; through a method similar to this index table, the unique correspondence between the geographic entity code and the original data is achieved, thereby improving the query speed, reducing the query time, and effectively strengthening the control of uniqueness.
[0074] Example 2:
[0075] This embodiment provides a geographic entity encoding system based on Spring Batch, which includes:
[0076] The reading module is used to query the geographic entity table from the database based on the database's geographic information view table and parse multimodal spatial metadata based on the entity table. It then uses the ItemReader and ItemWriter listeners provided by the Spring Batch framework to add a processing record table to record whether the data has been read and processed successfully. When subsequent tasks are restarted, the data reading will be judged based on this record table, and records that have been successfully read and processed will be skipped directly.
[0077] Generate a module for implementing geographic entity coding through itemprocessor and implementing specific processing logic based on GB / T40087-2021 geospatial grid coding rules;
[0078] The storage module is used to establish a coding table to record the coding information of geographic entities and implement coding storage through the ItemWriter listener provided by Spring Batch; among them, the coding table is used to record data source information, table name, unique index ID of specific data and geographic entity code.
[0079] The reading module in this embodiment includes:
[0080] The query submodule is used to use the JdbcPagingItemReader provided by Spring Batch to implement paging queries in the database and return data to a list collection. The paging parameters are consistent with the chunk parameters configured in the job.
[0081] The transfer submodule is used to read the data source information, columns, table names, where conditions, where parameters, and unique indexes of the data. The data source information, columns, table names, where conditions, where parameters, and unique indexes are all transferred through job parameters to implement dynamic business SQL execution for greater business flexibility.
[0082] The data reading definition submodule is used to define a data reading listener, which inherits the ItemReaderListener provided by Spring Batch and implements the beforeRead method, afterRead method, and onReadError method. In the beforeRead method, the database is connected to create a data processing task record. In the afterRead method, the status of the data processing task record is updated to read success based on the unique index. In the onReadError method, the status of the data processing task record is updated to read failure based on the unique index.
[0083] The generation module in this embodiment is generated by implementing the process method of ItemProcessor. The process method implements geographic entity coding according to the provided earth space grid coding rules based on GB / T40087-2021; wherein, the geographic entity coding adopts a coding paradigm divided into three sections: "proprietary identification domain + standard domain + extended domain" to standardize the coding structure and content of the basic geographic entity; the "proprietary identification domain" consists of a 2-bit root identifier code and a 4-bit basic geographic entity dedicated code, which is used to uniquely identify the basic geographic entity based on the MA international identification system; the "standard domain" consists of a 26-bit (two-dimensional) or 44-bit (three-dimensional) location code, a 6-bit classification code and a 4-bit sequence code, which is used to uniquely identify the basic geographic entity; the "extended domain" is a variable-length code used to interact with other codes or record information related to the basic geographic entity, meeting the "one code multiple forms" usage requirements of spatial identity coding.
[0084] The storage module in this embodiment includes:
[0085] The encoding and storage submodule is used to use the JdbcBatchItemWriter component provided by the Spring Batch framework to encode and store geographic entity data in the database. The JdbcBatchItemWriter implements the ItemWriter interface to convert item objects into records in the database.
[0086] The data storage definition submodule is used to define a data storage listener that inherits the ItemWriteListener provided by Spring Batch and implements the beforeWrite method, afterWrite method, and onWriteError method. In the beforeWrite method, a database connection is created to create a data storage task record. In the afterWrite method, the status of the data processing task record is updated to storage success based on the unique index. In the onWriteError method, the status of the data processing task record is updated to storage failure based on the unique index.
[0087] A submodule is established to establish another database and data table to record geographic entity coding data, ensure the security of original data, ensure that the performance of the original database is not affected, and record geographic entity coding data including geographic entity coding code, original data source information, original data table information, original data unique index information and spatial information; through a method similar to this index table, the unique correspondence between geographic entity coding and original data is achieved, thereby improving query speed, reducing query time, and effectively strengthening uniqueness control.
[0088] As attached Figure 1 As shown in the figure, the process of generating geographic entity codes is as follows:
[0089] (1) Read geographic entity code:
[0090] (2) Create a build task;
[0091] (3) Determine whether there is an error in the monitoring reading:
[0092] ①If there is an error, record the error log and update the task;
[0093] ②If there is no error, proceed to step (4);
[0094] (4) Update task information;
[0095] (5) Perform geographic entity coding;
[0096] (6) Store geographic entity codes;
[0097] (7) Determine whether there is an error in the monitoring storage:
[0098] ①If there is an error, record the error log and update the task information;
[0099] ②If there is no error, proceed to step (8);
[0100] (8) Update task information.
[0101] Example 3:
[0102] This embodiment also provides an electronic device, including: a memory and a processor;
[0103] wherein the memory stores computer-executable instructions;
[0104] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the geographic entity encoding method based on Spring Batch in any embodiment of the present invention.
[0105] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor may be a microprocessor or any conventional processor, etc.
[0106] The memory can be used to store computer programs and / or modules. The processor implements various functions of the electronic device by running or executing the computer programs and / or modules stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area. The program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created based on the use of the terminal, etc. In addition, the memory can also include high-speed random access memory and non-volatile memory, such as a hard disk, internal memory, a plug-in hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, at least one disk storage period, a flash memory device, or other volatile solid-state memory devices.
[0107] Example 4:
[0108] This embodiment also provides a computer-readable storage medium storing a plurality of instructions. The instructions are loaded by a processor, causing the processor to execute the Spring Batch-based geographic entity encoding method according to any embodiment of the present invention. Specifically, a system or device equipped with a storage medium can be provided. The storage medium stores software program code that implements the functions of any of the above-described embodiments, and a computer (or CPU or MPU) of the system or device can read and execute the program code stored in the storage medium.
[0109] In this case, the program code itself read from the storage medium can realize the function of any one of the above-mentioned embodiments, and thus the program code and the storage medium storing the program code constitute part of the present invention.
[0110] Examples of storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (e.g., CD-ROMs, CD-Rs, CD-RWs, DVD-ROMs, DVD-RYMs, DVD-RWs, DVD+RWs), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer via a communications network.
[0111] In addition, it should be clear that the functions of any of the above embodiments can be achieved not only by executing the program code read by the computer, but also by enabling the operating system operating on the computer to complete part or all of the actual operations based on the instructions of the program code.
[0112] In addition, it can be understood that the program code read from the storage medium is written into the memory provided in the expansion board inserted into the computer or into the memory provided in the expansion unit connected to the computer, and then based on the instructions of the program code, the CPU installed on the expansion board or expansion unit is enabled to perform part or all of the actual operations, thereby realizing the functions of any of the above embodiments.
[0113] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A geographic entity encoding method based on Spring Batch, characterized in that: The method is as follows: Reading geographic entity data: Query the geographic entity table from the database based on the database's geographic information view table, and parse multimodal spatial metadata based on the entity table. Utilize the ItemReader and ItemWriter listeners provided by the Spring Batch framework to add a processing record table to record whether the data has been read and processed successfully. When subsequent tasks are restarted, data reading will be based on this record table, and records that have been successfully read and processed will be skipped. Generate geographic entity codes: implement geographic entity codes through itemprocessor, and implement specific processing logic based on GB / T40087-2021 geospatial grid coding rules; Storing geographic entity data codes: Create a code table to record the code information of geographic entities and store the codes in the database through the ItemWriter listener provided by Spring Batch. The code table is used to record data source information, table name, unique index ID of specific data, and geographic entity code. The specific steps for reading geographic entity data are as follows: Use the JdbcPagingItemReader provided by Spring Batch to query the database in pages and return the data to a list collection. The paging parameters are consistent with the chunk parameters configured in the job. Read the data source information, columns, table names, where conditions, where parameters and unique indexes of the data. The data source information, columns, table names, where conditions, where parameters and unique indexes are all passed through job parameters to implement dynamic business SQL execution; Define a data reading listener that inherits the ItemReaderListener provided by Spring Batch and implements the beforeRead, afterRead, and onReadError methods. In the beforeRead method, connect to the database to create a data processing task record. In the afterRead method, update the status of the data processing task record to read success based on the unique index. In the onReadError method, update the status of the data processing task record to read failure based on the unique index. The geographic entity code is generated by implementing the process method of ItemProcessor. The process method implements the geographic entity code according to the geospatial grid coding rules based on GB / T40087-2021. Geographic entity coding adopts a three-part coding paradigm of "proprietary identification domain + standard domain + extension domain" to standardize the coding structure and content of basic geographic entities; The "proprietary identification domain" consists of a 2-digit root identifier code and a 4-digit basic geographic entity dedicated code, which is used to uniquely identify basic geographic entities based on the MA international identification system; The "standard domain" consists of a 26-bit or 44-bit location code, a 6-bit classification code, and a 4-bit sequence code, used to uniquely identify basic geographic entities; The "Extended Field" is a variable-length code used to interact with other codes or record information related to basic geographic entities, meeting the "one code, multiple states" usage requirements of spatial identity coding; The encoding for storing geographic entity data is as follows: The Spring Batch framework uses JdbcBatchItemWriter, a JDBC support component, to encode and store geographic entity data in the database. The JdbcBatchItemWriter implements the ItemWriter interface to convert item objects into records in the database. Define a data storage listener that inherits the ItemWriteListener provided by Spring Batch and implements the beforeWrite, afterWrite, and onWriteError methods. In the beforeWrite method, connect to the database to create a data storage task record. In the afterWrite method, update the status of the data processing task record to storage success based on the unique index. In the onWriteError method, update the status of the data processing task record to storage failure based on the unique index. In addition, a database and data table are established to record geographic entity coding data, which includes geographic entity coding code, original data source information, original data table information, original data unique index information and spatial information; through the index table, the unique correspondence between geographic entity coding and original data is achieved.
2. A geographic entity coding system based on Spring Batch, characterized in that: The system includes: The reading module is used to query the geographic entity table from the database based on the database's geographic information view table and parse multimodal spatial metadata based on the entity table. It then uses the ItemReader and ItemWriter listeners provided by the Spring Batch framework to add a processing record table to record whether the data has been read and processed successfully. When subsequent tasks are restarted, the data reading will be judged based on this record table, and records that have been successfully read and processed will be skipped directly. Generate a module for implementing geographic entity coding through itemprocessor and implementing specific processing logic based on GB / T40087-2021 geospatial grid coding rules; The storage module is used to establish a code table to record the coding information of geographic entities and implement the coding storage through the ItemWriter listener provided by Spring Batch. The code table is used to record data source information, table name, unique index ID of specific data and geographic entity code; The reading module includes: The query submodule is used to use the JdbcPagingItemReader provided by Spring Batch to implement paging queries in the database and return data to a list collection. The paging parameters are consistent with the chunk parameters configured in the job. The transfer submodule is used to read the data source information, columns, table names, where conditions, where parameters and unique indexes of the data. The data source information, columns, table names, where conditions, where parameters and unique indexes are all transferred through job parameters to realize dynamic business SQL execution; The data reading definition submodule is used to define a data reading listener, which inherits the ItemReaderListener provided by Spring Batch and implements the beforeRead method, afterRead method, and onReadError method. In the beforeRead method, a data processing task record is created by connecting to the database. In the afterRead method, the status of the data processing task record is updated to read success based on the unique index. In the onReadError method, the status of the data processing task record is updated to read failure based on the unique index. The generation module is generated by implementing the process method of ItemProcessor. The process method implements geographic entity coding according to the provided GB / T40087-2021 earth space grid coding rules; wherein, the geographic entity coding adopts a coding paradigm divided into three sections: "proprietary identification domain + standard domain + extension domain" to standardize the coding structure and content of the basic geographic entity; the "proprietary identification domain" consists of a 2-bit root identifier code and a 4-bit basic geographic entity dedicated code, which is used to uniquely identify the basic geographic entity based on the MA international identification system; the "standard domain" consists of a 26-bit or 44-bit location code, a 6-bit classification code and a 4-bit sequence code, which is used to uniquely identify the basic geographic entity; the "extension domain" is a variable-length code used to interact with other codes or record information related to the basic geographic entity, meeting the "one code multiple states" usage requirements of spatial identity coding; The storage module includes: The encoding and storage submodule is used to use the JdbcBatchItemWriter component provided by the Spring Batch framework to encode and store geographic entity data in the database. The JdbcBatchItemWriter implements the ItemWriter interface to convert item objects into records in the database. The data storage definition submodule is used to define a data storage listener that inherits the ItemWriteListener provided by Spring Batch and implements the beforeWrite method, afterWrite method, and onWriteError method. In the beforeWrite method, a database connection is created to create a data storage task record. In the afterWrite method, the status of the data processing task record is updated to storage success based on the unique index. In the onWriteError method, the status of the data processing task record is updated to storage failure based on the unique index. A submodule is established to establish another database and data table to record geographic entity coding data. The recorded geographic entity coding data includes geographic entity coding code, original data source information, original data table information, original data unique index information and spatial information; through the index table, the unique correspondence between geographic entity coding and original data is achieved.
3. An electronic device, characterized in that: include: memory and at least one processor; Wherein, the memory stores a computer program; The at least one processor executes the computer program stored in the memory, so that the at least one processor performs the Spring Batch-based geographic entity encoding method according to claim 1.
4. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which can be executed by a processor to implement the geographic entity encoding method based on Spring Batch as claimed in claim 1.
Citation Information
Patent Citations
Geographic entity coding method and device, equipment and storage medium
CN113220808A