[go: up one dir, main page]

CN114416789A - System and method for realizing Excel data import and export based on SQL-like - Google Patents

System and method for realizing Excel data import and export based on SQL-like Download PDF

Info

Publication number
CN114416789A
CN114416789A CN202111576217.3A CN202111576217A CN114416789A CN 114416789 A CN114416789 A CN 114416789A CN 202111576217 A CN202111576217 A CN 202111576217A CN 114416789 A CN114416789 A CN 114416789A
Authority
CN
China
Prior art keywords
task
template
excel
file
export
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.)
Granted
Application number
CN202111576217.3A
Other languages
Chinese (zh)
Other versions
CN114416789B (en
Inventor
柏广城
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiangsu Carzone Automobile Accessories Co ltd
Original Assignee
Jiangsu Carzone Automobile Accessories Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Jiangsu Carzone Automobile Accessories Co ltd filed Critical Jiangsu Carzone Automobile Accessories Co ltd
Priority to CN202111576217.3A priority Critical patent/CN114416789B/en
Publication of CN114416789A publication Critical patent/CN114416789A/en
Application granted granted Critical
Publication of CN114416789B publication Critical patent/CN114416789B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a system and a method for realizing Excel data import and export based on similar SQL, which comprises a display layer, a universal import and export system and a service system, wherein the universal import and export system comprises a task manager, a template analyzer, an actuator and an output device, and the universal import and export system realizes the execution function of the whole task. The process of business development is greatly accelerated, the development task of 2-3 days is shortened to less than one day, most logics which are easy to generate errors are avoided, and the business is supported quickly and stably. After the import and export logic is imported, the system is upgraded in the later period, the functions are newly added, and more universal expansibility is achieved.

Description

基于类SQL实现Excel数据导入导出系统及方法Implementing Excel data import and export system and method based on SQL-like

技术领域technical field

本发明属于数据处理技术领域,具体涉及一种基于类SQL实现Excel数据导入导出系统及方法。The invention belongs to the technical field of data processing, and in particular relates to a system and method for implementing Excel data import and export based on SQL.

背景技术Background technique

作为面向商家、运营的管理型后台,通常对于配置型数据,销售型数据有较多的管理需求,诸如批量上/下线商品、订单对账等,这样就需要系统提供较多的通过文件进行数据上传和下载的功能,现有的Excel数据导入导出存在以下问题:导入导出大文件,耗时较长情况下,同步失败;单一功能开发周期长且易出错,代码冗余无法公用。As a management background for businesses and operations, there are usually more management requirements for configuration data and sales data, such as batch online/offline products, order reconciliation, etc., so the system needs to provide more files for processing For the data upload and download functions, the existing Excel data import and export have the following problems: importing and exporting large files takes a long time, and synchronization fails; a single function has a long development cycle and is prone to errors, and code redundancy cannot be shared.

发明内容SUMMARY OF THE INVENTION

本发明解决的技术问题:提供一种减轻系统负载、提高业务开发进程、对客户友好的基于类SQL实现Excel数据导入导出系统及方法。The technical problem solved by the present invention is to provide a system and method for importing and exporting Excel data based on SQL-like, which can reduce the system load, improve the business development process, and be friendly to customers.

技术方案:为了解决上述技术问题,本发明采用的技术方案如下:Technical scheme: in order to solve the above-mentioned technical problems, the technical scheme adopted in the present invention is as follows:

一种基于类SQL实现Excel数据导入导出系统,包括:展示层、通用导入导出系统和业务系统;通用导入导出系统包括任务管理器、模板解析器、执行器和输出器,通用导入导出系统实现整体任务的执行功能,A system for importing and exporting Excel data based on class SQL, comprising: a presentation layer, a general importing and exporting system and a business system; the general importing and exporting system includes a task manager, a template parser, an executor and an exporter, and the general importing and exporting system realizes the overall task execution function,

所述展示层实现用户创建任务和结果查询,与通用导入导出系统进行任务交互,首先与任务管理器进行交互,由任务管理器实现具体的任务创建;The presentation layer realizes user creation of tasks and result query, and performs task interaction with the general import and export system, first interacts with the task manager, and the task manager realizes the creation of specific tasks;

所述任务管理器接收创建任务的指令后,查找任务模板,并提交异步任务至模板解析器进行解析;After the task manager receives the instruction to create the task, it searches for the task template, and submits the asynchronous task to the template parser for parsing;

所述模板解析器实现模板解析,首先获取模板缓存,然后判断是否有模板,如果没有模板,则利用解析器进行模板解析,并将解析结果存入模板缓存区;The template parser realizes template parsing, first obtains the template cache, then judges whether there is a template, if there is no template, the parser is used to perform template parsing, and the parsing result is stored in the template cache area;

所述执行器实现任务执行,执行时要按照不同的业务场景进行执行,导入解析文件并依赖业务结果生成错误记录文件;导出生成业务结果文件,并输出结果。The executor implements task execution, and executes according to different business scenarios, importing parsing files and generating error record files depending on business results; exporting to generate business result files, and outputting the results.

作为优选,任务执行模块的具体业务执行通过调用外部的业务执行模块实现,导入时通过解析文件,通过远程调用上传至业务执行模快,导出时直接通过远程调用业务执行模块下载数据至执行器,最后保存执行信息,并记录结果。Preferably, the specific business execution of the task execution module is implemented by calling an external business execution module, by parsing the file when importing, uploading it to the business execution module by remote calling, and directly downloading data to the executor by remotely calling the business execution module when exporting, Finally, save the execution information and record the results.

一种基于类SQL实现Excel数据导入导出方法,A method for importing and exporting Excel data based on SQL-like,

S1:用户创建任务:用户发出任务创建指令至通用导入导出系统;S1: User creation task: the user sends a task creation instruction to the general import and export system;

S2:通用导入导出系统根据用户任务进行任务创建:首先查找任务模板,并判断是否有模板,如果有模板,则持久化任务,并提交一步任务至模板解析器,如果没有模板则任务创建失败,并将失败警告反馈给用户;S2: The general import and export system creates tasks according to user tasks: first, find the task template, and determine whether there is a template. If there is a template, the task is persisted, and a one-step task is submitted to the template parser. If there is no template, the task creation fails. and feedback failure warnings to users;

S3:模板解析:首先获取模板缓存,然后判断是否有模板,如果有模板,则进行下一步骤:任务执行;如果没有模板,则利用解析器进行模板解析,并将解析结果存入模板缓存区;模板解析包括导入模板解析和导出模板解析;S3: Template parsing: first obtain the template cache, and then determine whether there is a template. If there is a template, proceed to the next step: task execution; if there is no template, use the parser to parse the template, and store the parsing result in the template cache area ;Template parsing includes import template parsing and export template parsing;

S4:任务执行:导入时,通过解析文件,远程上传至业务系统的业务执行模块,远程结果生成提示文件;导出时,直接调用业务系统的业务执行模块,远程结果生成导出文件,最后保存执行信息,并记录结果,用户在结果页通过轮询进行结果查询或者到指定系统位置查询任务结果。任务执行具体包括导入任务执行和导出任务执行。S4: Task execution: When importing, by parsing the file, upload it to the business execution module of the business system remotely, and generate a prompt file for the remote result; when exporting, directly call the business execution module of the business system, generate an export file for the remote result, and finally save the execution information , and record the results. Users can query the results through polling on the results page or go to the specified system location to query the task results. Task execution specifically includes import task execution and export task execution.

作为优选,步骤S3中,导入模板解析的具体步骤为:Preferably, in step S3, the specific steps of importing template analysis are as follows:

S311:读取模板字串,然后按空格分割字串;S311: Read the template string, and then divide the string by spaces;

S312:读取“by”位置,读取by前一个字符和by后一个字符,组装成明细输入信息;S312: Read the "by" position, read the character before by and the character after by, and assemble into detailed input information;

S313:读取“parent-by”位置,读取parent-by前一个字符和parent-by后一个字符,组装成父类包装输入信息;S313: Read the position of "parent-by", read the previous character of parent-by and the next character of parent-by, and assemble it into a parent class to package the input information;

S314:读取“form”位置,取后一个字符,获取上传文件参数字段;S314: Read the "form" position, take the last character, and obtain the upload file parameter field;

S315:读取“unique”位置,去后一个字符,获取唯一性配置;S315: Read the "unique" position, go to the next character, and obtain the unique configuration;

S316:读取“exception”位置,往后读取as位置,包括as前一个字符和as后一个字符,组装成异常输出信息;S316: Read the "exception" position, and then read the as position, including the character before as and the character after as, and assemble the abnormal output information;

S317:读取“#”位置,组装成额外条件Map。S317: Read the "#" position and assemble it into an additional conditional Map.

作为优选,步骤S3中,导出模板解析的具体步骤为:Preferably, in step S3, the specific steps of exporting template analysis are:

S321:导出模板解析,读取模板字串并按空格分割字串;S321: Export template parsing, read the template string and split the string by spaces;

S322:读取“as”位置,读取as前一个字符和as后一个字符,组装成输出信息配置;S322: Read the "as" position, read the character before as and the character after as, and assemble it into an output information configuration;

S323:读取“form”位置,取后一个字符,组装获取数据方式;S323: Read the "form" position, take the last character, and assemble the data acquisition method;

S324:读取“where”位置,判断该位置是否存在,如果存在,则读取,直到遇到关键字into,组装连接符与字段,形成条件映射;S324: Read the "where" position, determine whether the position exists, and if so, read until the keyword into is encountered, assemble the connector and the field, and form a conditional mapping;

S325:如果“where”位置不存在,则读取“into”位置,取后一个字符,组装成输出器;S325: If the "where" position does not exist, read the "into" position, take the last character, and assemble it into an output device;

S326:读取“#”位置,组装成额外条件Map。S326: Read the "#" position and assemble into an additional conditional Map.

作为优选,步骤S4中,导入任务执行的具体步骤如下:Preferably, in step S4, the specific steps for executing the import task are as follows:

S411:导入执行任务,读取模板配置;S411: Import the execution task, and read the template configuration;

S412:从文件系统下载导入的文件;S412: Download the imported file from the file system;

S413:生成失败excel文件:生成的excel文件包含错误信息;S413: Failed to generate excel file: The generated excel file contains error information;

S414:读取上传excel文件:对上传的excel文件进行逐行读取,判断是否满足批量设置,如果满足批量设置则跳转至步骤S416;如果不满足批量设置,则跳转至步骤S415;S414: Read and upload the excel file: read the uploaded excel file line by line to determine whether the batch setting is satisfied, if the batch setting is satisfied, jump to step S416; if the batch setting is not satisfied, jump to step S415;

S415:判断读取的数据是否是excel行尾数据,如果是行尾数据,则进行步骤S416和步骤S417;如果不是行尾数据则返回继续执行步骤S414;S415: Determine whether the read data is excel end-of-line data, if it is end-of-line data, go to step S416 and step S417; if it is not end-of-line data, return to continue to execute step S414;

S416:数据处理,业务接口参数,上传数据至业务系统;如果单次全部成功,则继续执行步骤S414,如果没有单次全部成功,向excel文件写入失败原因;S416: data processing, business interface parameters, uploading data to the business system; if all successes are performed in one time, proceed to step S414, if not all successes in one time, write the failure reason to the excel file;

S417:文件读完触发excel文件流关闭;S417: After the file is read, the excel file stream is closed;

S418:上传excel到文件服务器,并删除本地excel,然后持久化任务结果。S418: Upload excel to the file server, delete the local excel, and persist the task result.

作为优选,步骤S4中,导出任务执行的具体步骤如下:Preferably, in step S4, the specific steps of exporting task execution are as follows:

S421:导出执行任务,读取模板配置;S421: Export the execution task and read the template configuration;

S422:创建空excel文件;S422: Create an empty excel file;

S423:组装接口参数,执行调用业务系统的业务执行模块执行具体的任务;执行完成后,返回数据,并进行数据处理,写入文件至excel文件;S423: Assemble the interface parameters, and execute the business execution module that invokes the business system to execute specific tasks; after the execution is completed, return data, perform data processing, and write the file to the excel file;

S424:判断返回数据是否满足继续条件,如果满足继续条件,则重复执行步骤S423,如果不满足继续条件,则说明导出数据完毕,则excel文件流关闭;S424: Determine whether the returned data satisfies the continuation condition, if the continuation condition is satisfied, repeat step S423, if the continuation condition is not satisfied, it means that the export of data is completed, and the excel file stream is closed;

S425:上传excel到文件服务器,并删除本地excel,然后持久化任务结果。有益效果:与现有技术相比,本发明具有以下优点:S425: Upload excel to the file server, delete the local excel, and persist the task result. Beneficial effect: Compared with the prior art, the present invention has the following advantages:

(1)关于任务执行方式(异步),本发明的方法通过生产的验证,不再出现过往同步导入、导出等候时间过长(网关超时),导入、导出任务直接失败,无法获取执行结果的问题。(1) Regarding the task execution mode (asynchronous), the method of the present invention has passed the verification of production, and no longer has the problem that the past synchronous import and export wait time is too long (gateway timeout), the import and export tasks fail directly, and the execution result cannot be obtained. .

(2)关于重复历史数据,无需重新增加对系统的负载,直接通过历史可以查询过往数据,对客户使用友好度大大提升。(2) Regarding the repeated historical data, there is no need to increase the load on the system again, and the past data can be queried directly through the history, which greatly improves the user-friendliness of customers.

(3)关于交互设计,解决了导入数据部分失败时,如果数据量过多,无法在页面进行友好信息提示的问题。(3) Regarding the interaction design, it solved the problem that when the import data part fails, if the amount of data is too much, friendly information cannot be prompted on the page.

(4)关于开发易用性,大大提速了业务开发的进程,过往2-3天的开发任务,缩短到一天以内,且避免了很多易出错的地方(诸如Excel读取,写出占用系统内存),保障业务快速稳定的支撑。(4) Regarding the ease of use of development, the process of business development has been greatly accelerated. The development tasks of the past 2-3 days have been shortened to less than one day, and many error-prone places (such as Excel reading and writing occupying system memory are avoided) ) to ensure fast and stable business support.

(5)关于功能升级,导入导出逻辑收编后,对于后期系统升级,功能新增,则有了更多的通用扩展性。(5) Regarding function upgrades, after the import and export logic is incorporated, for later system upgrades and new functions, there will be more general extensibility.

附图说明Description of drawings

图1是基于类SQL实现Excel数据导入导出系统框图;Figure 1 is a block diagram of the Excel data import and export system based on class SQL;

图2是基于类SQL实现Excel数据导入导出方法流程图;Figure 2 is a flow chart of the method for importing and exporting Excel data based on SQL-like;

图3是基于类SQL实现Excel数据导入模板解析流程图;Figure 3 is a flow chart of implementing Excel data import template parsing based on SQL-like;

图4是基于类SQL实现Excel数据导入模板解析实例图;Figure 4 is an example diagram of implementing Excel data import template analysis based on class SQL;

图5是基于类SQL实现Excel数据导出模板解析流程图;Figure 5 is a flow chart of implementing Excel data export template parsing based on SQL-like;

图6是基于类SQL实现Excel数据导出模板解析实例图;Figure 6 is an example diagram of the realization of Excel data export template parsing based on class SQL;

图7是基于类SQL实现Excel数据导入任务执行流程图;Fig. 7 is the execution flow chart of implementing Excel data import task based on class SQL;

图8是基于类SQL实现Excel数据导出任务执行流程图。Figure 8 is a flow chart of implementing the Excel data export task execution based on SQL-like.

具体实施方式Detailed ways

下面结合具体实施例,进一步阐明本发明,实施例在以本发明技术方案为前提下进行实施,应理解这些实施例仅用于说明本发明而不用于限制本发明的范围。The present invention will be further illustrated below in conjunction with specific examples, which are implemented on the premise of the technical solutions of the present invention. It should be understood that these examples are only used to illustrate the present invention and not to limit the scope of the present invention.

如图1所示,本申请的基于类SQL实现Excel数据导入导出系统,包括展示层(用户)、通入导入导出系统和业务系统,通用导入导出系统包括任务管理器、模板解析器、执行器和输出器(结果记录)。As shown in Figure 1, the application's SQL-based implementation of Excel data import and export system, including display layer (user), access import and export system and business system, general import and export system includes task manager, template parser, executor and exporter (result record).

展示层实现用户创建任务和结果查询,与通用导入导出系统进行任务交互,首先与任务管理器进行交互,由任务管理器实现具体的任务创建。通入导入导出系统将任务执行完毕并输出结果后,用户进行结果查询。The presentation layer implements user creation tasks and result queries, and interacts with the general import and export system. First, it interacts with the task manager, and the task manager realizes the creation of specific tasks. After the access import and export system completes the task execution and outputs the results, the user queries the results.

通用导入导出系统实现整体任务的执行功能,任务管理器接收创建任务的指令后,查找任务模板,并判断是否有模板,如果有模板,则持久化任务,并提交一步任务至模板解析器,如果没有模板则任务创建失败,并将失败警告反馈给用户。The general import and export system implements the execution function of the overall task. After the task manager receives the instruction to create the task, it searches for the task template and determines whether there is a template. If there is a template, the task is persisted, and a one-step task is submitted to the template parser. If there is no template, the task creation fails, and the failure warning is fed back to the user.

模板解析器实现模板解析,首先获取模板缓存,然后判断是否有模板,如果没有模板,则利用解析器进行模板解析,并将解析结果存入模板缓存区。The template parser implements template parsing. First, it obtains the template cache, and then determines whether there is a template. If there is no template, the parser is used for template parsing, and the parsing result is stored in the template cache area.

执行器实现任务执行,执行时要按照不同的业务场景进行执行,导入解析文件并依赖业务结果生成错误记录文件;导出生成业务结果文件,任务执行模块的具体业务执行通过调用外部的业务执行模块实现,导入时通过解析文件,通过远程调用上传至业务执行模快,导出时直接通过远程调用业务执行模块下载数据至执行器,最后保存执行信息,并记录结果。,并记录结果。本发明采用异步任务的方式解耦,不再同步获取结果,结果由前端交互引导至任务管理处查看,如需实时查看同步结果(比如上传数据后,刷新当前页面),则由前端轮询任务结果,直至成功或者失败。The executor implements task execution, and executes it according to different business scenarios, importing parsing files and generating error record files depending on business results; exporting and generating business result files, and the specific business execution of the task execution module is realized by calling an external business execution module. , when importing, it parses the file, uploads it to the business execution module by remote calling, and directly downloads the data to the executor by calling the business execution module remotely when exporting, and finally saves the execution information and records the result. , and record the results. The present invention adopts the method of asynchronous task decoupling, and no longer obtains the results synchronously. The results are guided by the front-end interaction to the task management office for viewing. If you need to view the synchronous results in real time (for example, after uploading data, refresh the current page), the front-end polls the task. result, until success or failure.

本发明还公开一种基于类SQL实现Excel数据导入导出方法,如图2所示,具体包括以下步骤:The invention also discloses a method for importing and exporting Excel data based on class SQL, as shown in Figure 2, which specifically includes the following steps:

S1:用户创建任务:用户发出任务创建指令至通用导入导出系统;S1: User creation task: the user sends a task creation instruction to the general import and export system;

S2:通用导入导出系统根据用户任务进行任务创建:首先查找任务模板,并判断是否有模板,如果有模板,则持久化任务,并提交异步任务至模板解析器,如果没有模板则任务创建失败,并将失败警告反馈给用户;S2: The general import and export system creates tasks according to user tasks: first, find the task template, and determine whether there is a template. If there is a template, the task is persistent, and the asynchronous task is submitted to the template parser. If there is no template, the task creation fails. and feedback failure warnings to users;

S3:模板解析:首先获取模板缓存,然后判断是否有模板,如果有模板,则进行下一步骤:任务执行;如果没有模板,则利用解析器进行模板解析,并将解析结果存入模板缓存区。模板解析的具体内容包括导入模板解析和导出模板解析。S3: Template parsing: first obtain the template cache, and then determine whether there is a template. If there is a template, proceed to the next step: task execution; if there is no template, use the parser to parse the template, and store the parsing result in the template cache area . The specific content of template parsing includes import template parsing and export template parsing.

如图3所示,为导入模板解析流程图,导入模板解析的具体步骤为:As shown in Figure 3, for the import template analysis flowchart, the specific steps of import template analysis are:

S311:读取模板字串,然后按空格分割字串;S311: Read the template string, and then divide the string by spaces;

S312:读取“by”位置,读取by前一个字符和by后一个字符,组装成明细输入信息;采用的语法为模拟sql语法自定义的语法。S312: Read the position of "by", read the character before by and the character after by, and assemble the detailed input information; the syntax used is a syntax customized by simulating sql syntax.

例如:图4中所示,标号①~④为读取的“by”位置的信息,包括有单号、生效时间、失效时间、价格、上架、下架信息等,by位置的这些信息组装成明细输入信息。标号①:说明导入Excel时业务接口的orderNo入参取自Excel列名为“单号”的数据;标号②:在标号①的基础上,支持了字段类型的反序列化,“YYYY-MM-DD HH:mm:ss”反序列化为Date类型;标号③:在标号①的基础上,支持了字段类型的反序列化,读取的数字字符串反序列化BigDecimal类型;标号④:在标号①的基础上,支持了字段映射,读取“1”映射为true。For example: as shown in Figure 4, the labels ① to ④ are the information of the read "by" position, including the order number, effective time, expiry time, price, information on the shelf and off the shelf, etc. The information in the by position is assembled into Detailed input information. Label ①: Indicates that the orderNo input parameter of the business interface when importing into Excel is taken from the data in the Excel column named "Order No."; Label ②: On the basis of label ①, it supports the deserialization of field types, "YYYY-MM- DD HH:mm:ss" is deserialized into Date type; label ③: On the basis of label ①, it supports the deserialization of field types, and the read number string is deserialized into BigDecimal type; label ④: in label On the basis of ①, field mapping is supported, and reading "1" is mapped to true.

S313:读取“parent-by”位置,读取parent-by前一个字符和parent-by后一个字符,组装成父类包装输入信息。S313: Read the position of "parent-by", read the character before parent-by and the character after parent-by, and assemble the input information into a parent class package.

例如图4标号⑤:operatorId、operatorName为保留字段,默认带入插入条件,插入条件为导入文件的原信息,包括创建者信息等。For example, the symbol ⑤ in Figure 4: operatorId and operatorName are reserved fields, and the insertion condition is brought in by default. The insertion condition is the original information of the imported file, including the creator information.

S314:读取“form”位置,取后一个字符,获取上传文件参数字段;S314: Read the "form" position, take the last character, and obtain the upload file parameter field;

例如图4标号⑥:描述了导入文件的来源url为创建任务参数字段,内容为导入文件上传服务器的地址。For example, the symbol ⑥ in Figure 4 describes that the source url of the imported file is the creation task parameter field, and the content is the address of the import file upload server.

S315:读取“unique”位置,去最后一个字符,获取唯一性配置;S315: Read the "unique" position, go to the last character, and obtain the unique configuration;

例如标号⑦:描述了上传文件中,哪些字段能保障数据的唯一性。For example, label ⑦: describes which fields in the uploaded file can ensure the uniqueness of the data.

S316:读取“exception”位置,往后读取as位置(循环处理),包括as前一个字符和as后一个字符,组装成异常输出信息;S316: Read the "exception" position, and then read the as position (loop processing), including the character before as and the character after as, and assemble into abnormal output information;

例如,标号⑧:描述了导入数据部分失败的情况下,错误信息需要展示哪些信息。For example, label ⑧: describes what information should be displayed in the error message when the import data part fails.

S317:读取“#”位置,组装成额外条件Map。S317: Read the "#" position and assemble it into an additional conditional Map.

例如

Figure BDA0003424174760000061
所定义的各类信息:标号⑨:描述了业务接口相关信息;标号⑩:描述了批量导入时一批次的数据量;标号
Figure BDA0003424174760000062
描述了部分导入返回失败时,错误信息的路由位置;标号
Figure BDA0003424174760000063
描述了上传文件的头信息相关;insert/by/insert-parent/parent-byfrom/unique/exception为保留关键字,描述了整个模板的框架。E.g
Figure BDA0003424174760000061
Various types of information defined: Label ⑨: Describes business interface-related information; Label ⑩: Describes the amount of data in a batch when importing in batches; Label
Figure BDA0003424174760000062
Describes the routing location of error information when some import returns fail; label
Figure BDA0003424174760000063
Describes the header information related to the uploaded file; insert/by/insert-parent/parent-byfrom/unique/exception is a reserved keyword, describing the framework of the entire template.

如图5所示,为导出模板解析流程图,导出模板解析的具体步骤为:As shown in Figure 5, in order to export the template parsing flowchart, the specific steps of exporting template parsing are:

S321:导出模板解析,读取模板字串并按空格分割字串;S321: Export template parsing, read the template string and split the string by spaces;

S322:读取“as”位置:读取as前一个字符和as后一个字符,组装成输出信息配置;S322: Read "as" position: read the character before as and the character after as, and assemble it into an output information configuration;

如图6所示,标号①~⑥读取的“as”位置的信息,包括单号,生效时间,失效时间,价格,退货原因、价格等等,这些信息组装成输出信息配置;标号①:说明了导出Excel时的字段取自业务接口的orderNo,Excel列的头信息为“单号”标号②:在标号①的基础上,支持了字段类型的序列化,显示Date类型为“YYYY-MM-DD HH:mm:ss”标号③:在标号①的基础上,支持了字段类型的序列化,显示BigDecimal类型为数字2位小数标号④:在标号①的基础上,支持了字段映射,显示1->”不想要了”标号⑤:在标号③的基础上,Excel列变为数字类型,支持快速数据透视标号⑥:在标号①的基础上,支持动态变化的数据列。As shown in Figure 6, the information of the "as" position read by the labels ① to ⑥ includes the order number, effective time, expiration time, price, return reason, price, etc. These information are assembled into the output information configuration; label ①: It is explained that the field when exporting Excel is taken from the orderNo of the business interface, and the header information of the Excel column is the "single number" label ②: On the basis of the label ①, the serialization of the field type is supported, and the Date type is displayed as "YYYY-MM" -DD HH:mm:ss" label ③: On the basis of label ①, it supports the serialization of field types, showing that the BigDecimal type is a number with 2 decimal places. Label ④: On the basis of label ①, it supports field mapping and displays 1->"I don't want it anymore" label ⑤: On the basis of label ③, the Excel column becomes a numeric type, supporting quick pivot. Label ⑥: On the basis of label ①, it supports dynamically changing data columns.

S323:读取“form”位置,取后一个字符,组装获取数据方式;S323: Read the "form" position, take the last character, and assemble the data acquisition method;

S324:读取“where”位置,判断该位置是否存在,如果存在,则读取,直到遇到关键字into,组装连接符与字段,形成条件映射。如图6标号⑦~⑩,标号⑦:说明了一种参数转换映射标号;⑧:在标号⑦的基础上,参数类型的转换,“YYYY-MM-DD HH:mm:ss”反序列化为Date类型;标号⑨:在标号①的基础上,为保留字段,记录操作人ID;标号⑩:在标号①的基础上,为保留字段,记录操作人名。S324: Read the "where" position, determine whether the position exists, and if so, read it until the keyword into is encountered, assemble the connector and the field, and form a conditional mapping. Labels ⑦~⑩ as shown in Figure 6, label ⑦: illustrates a parameter conversion mapping label; ⑧: On the basis of label ⑦, the conversion of parameter types, "YYYY-MM-DD HH:mm:ss" is deserialized as Date type; label ⑨: on the basis of label ①, it is a reserved field to record the operator ID; label ⑩: on the basis of label ①, it is a reserved field to record the operator's name.

S325:如果“where”位置不存在,则读取“into”位置,取最后一个字符,组装成输出器。标号

Figure BDA0003424174760000071
into Excel说明了数据输出为Excel形式S325: If the "where" position does not exist, read the "into" position, take the last character, and assemble it into an output device. label
Figure BDA0003424174760000071
into Excel indicates that the data is output in Excel form

S326:读取“#”位置,组装成额外条件Map。例如:标号

Figure BDA0003424174760000072
上下信息,描述了业务接口的详情;标号
Figure BDA0003424174760000073
数据游标,描述了业务接口反参数据的位置。select/from/where/into/as/and/=为保留关键字,描述了整个模板的框架。S326: Read the "#" position and assemble into an additional conditional Map. For example: label
Figure BDA0003424174760000072
Up and down information, describing the details of the business interface; label
Figure BDA0003424174760000073
A data cursor, which describes the location of the business interface counter-parameter data. select/from/where/into/as/and/=are reserved keywords that describe the framework of the entire template.

S4:导入通过解析文件,远程上传至业务系统的业务执行模块,远程结果生成提示文件;导出则直接调用业务系统的业务执行模块,远程结果生成导出文件,最后保存执行信息,并记录结果,用户在结果页通过轮询进行结果查询或者到指定系统位置查询任务结果。任务执行具体包括导入任务执行和导出任务执行。S4: Import through the analysis file, upload it to the business execution module of the business system remotely, and generate a prompt file for the remote result; for export, directly call the business execution module of the business system, generate an export file for the remote result, and finally save the execution information and record the result. Query the result by polling on the result page or query the task result from the specified system location. Task execution specifically includes import task execution and export task execution.

任务执行具体包括导入任务执行和导出任务执行。Task execution specifically includes import task execution and export task execution.

如图7所示,为导入任务执行的流程图,导入任务执行的具体步骤如下:As shown in Figure 7, which is a flowchart of import task execution, the specific steps of import task execution are as follows:

S411:导入执行任务,读取模板配置;S411: Import the execution task, and read the template configuration;

S412:从文件系统下载导入文件;S412: Download the import file from the file system;

S413:生成失败excel文件:生成的excel文件包含错误信息。S413: Failed to generate excel file: The generated excel file contains error information.

S414:读取上传excel文件:对上传的excel文件进行逐行读取,判断是否满足批量设置,如果满足批量设置则跳转至步骤S416;如果不满足批量设置,则跳转至步骤S415;S414: Read and upload the excel file: read the uploaded excel file line by line to determine whether the batch setting is satisfied, and if the batch setting is satisfied, jump to step S416; if the batch setting is not satisfied, jump to step S415;

S415:判断读取的数据是否是excel行尾数据,如果是行尾数据,则进行步骤S416和步骤S417;如果不是行尾数据则返回继续执行步骤S414;S415: Determine whether the read data is excel end-of-line data, if it is end-of-line data, go to step S416 and step S417; if it is not end-of-line data, return to step S414;

S416:数据处理,业务接口参数,上传数据至业务系统;如果单次全部成功,则继续执行步骤S414,如果没有单次全部成功,向excel文件写入失败原因;S416: data processing, business interface parameters, uploading data to the business system; if all successes are performed in one time, proceed to step S414, if not all successes in one time, write the failure reason to the excel file;

S417:文件读完触发excel文件流关闭;S417: After the file is read, the excel file stream is closed;

S418:上传excel到文件服务器,并删除本地excel,然后持久化任务结果。S418: Upload excel to the file server, delete the local excel, and persist the task result.

如图8所示,为导出任务执行的流程图,导出任务执行的具体步骤如下:As shown in Figure 8, for the flowchart of export task execution, the specific steps of export task execution are as follows:

S421:导出执行任务,读取模板配置;S421: Export the execution task and read the template configuration;

S422:创建空excel文件;S422: Create an empty excel file;

S423:组装接口参数,执行调用业务系统的业务执行模块执行具体的任务;执行完成后,返回数据,并进行数据处理,写入文件至excel文件;S423: Assemble the interface parameters, and execute the business execution module that invokes the business system to execute specific tasks; after the execution is completed, return data, perform data processing, and write the file to the excel file;

S424:判断返回数据是否满足继续条件,如果满足继续条件,则重复执行步骤S423,如果不满足继续条件,则说明导出数据完毕,则excel文件流关闭;S424: Determine whether the returned data satisfies the continuation condition, if the continuation condition is satisfied, repeat step S423, if the continuation condition is not satisfied, it means that the export of data is completed, and the excel file stream is closed;

S425:上传excel到文件服务器,并删除本地excel,然后持久化任务结果。S425: Upload excel to the file server, delete the local excel, and persist the task result.

本发明的通用主要体现在多样业务的开发,并不需要额外进行代码的处理,使用通用代码基于不同的配置便可执行不同的结果,而如何描述配置便是重重之重,通过调研,JSON在配置上会十分复杂,无法直观描述一个场景,但是类SQL的样式对于研发来说,易读与易用性就大大提高,通过研发解析类SQL的解析器,来实现配置的解读,并完成流程的执行。The generality of the present invention is mainly reflected in the development of various services, and no additional code processing is required. Different results can be performed based on different configurations using the general code, and how to describe the configuration is very important. Through research, JSON is used in The configuration will be very complicated, and it is impossible to describe a scene intuitively, but the SQL-like style is greatly improved in readability and ease of use for research and development. By developing a parser that parses SQL-like, the configuration interpretation is realized and the process is completed. execution.

以上所述仅是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本发明的保护范围。The above are only the preferred embodiments of the present invention. It should be pointed out that for those skilled in the art, without departing from the principles of the present invention, several improvements and modifications can be made. It should be regarded as the protection scope of the present invention.

Claims (7)

1. A system for realizing Excel data import and export based on SQL-like data comprises: the system comprises a display layer, a general import and export system and a service system; the general import and export system comprises a task manager, a template parser, an executor and an outputter, and the general import and export system realizes the execution function of the whole task.
The display layer realizes the establishment of tasks and result query by users, performs task interaction with a general import and export system, firstly interacts with a task manager, and realizes the establishment of specific tasks by the task manager;
after receiving a task creating instruction, the task manager searches a task template and submits an asynchronous task to a template analyzer for analysis;
the template analyzer realizes template analysis, firstly, a template cache is obtained, then, whether a template exists or not is judged, if no template exists, the analyzer is used for analyzing the template, and an analysis result is stored in a template cache area;
the executor executes tasks according to different service scenes, imports an analysis file and generates an error record file depending on a service result; and exporting a generated service result file and outputting a result.
2. The system according to claim 1, wherein the system for importing and exporting Excel data based on SQL-like implementation is characterized in that: the specific service execution of the task execution module is realized by calling an external service execution module, the specific service execution is realized by analyzing a file during import, uploading the specific service execution to a service execution module through remote calling, directly downloading data to an actuator through the remote calling service execution module during export, and finally storing execution information and recording a result.
3. A method for realizing Excel data import and export based on SQL-like is characterized in that:
s1: the user creates a task: a user sends a task creating instruction to the general import and export system;
s2: the general import and export system carries out task creation according to the user task: firstly, searching a task template, judging whether the template exists, if so, persisting the task, submitting an asynchronous task to a template analyzer, if not, failing to create the task, and feeding a failure warning back to a user;
s3: template analysis: firstly, obtaining a template cache, then judging whether a template exists, and if so, carrying out the next step: executing the task; if no template exists, the template is analyzed by using an analyzer, and the analysis result is stored in a template cache region; the template analysis comprises import template analysis and export template analysis;
s4: and (3) task execution: when the client is imported, the file is analyzed and remotely uploaded to a service execution module of a service system, and a prompt file is generated by a remote result; and during exporting, directly calling a service execution module of the service system, generating a export file by remote results, finally storing execution information, recording results, and inquiring results or inquiring task results at a specified system position by a user through polling on a result page. The task execution specifically includes import task execution and export task execution.
4. The method for realizing Excel data import and export based on SQL like of claim 3, wherein: in step S3, the specific steps of importing template analysis are:
s311: reading the template character string and then dividing the character string according to spaces;
s312: reading the position of the 'by', reading the previous character of the by and the next character of the by, and assembling into detailed input information;
s313: reading the position of parent-by, reading the previous character of the parent-by and the next character of the parent-by, and assembling into parent package input information;
s314: reading the 'form' position, taking the next character, and acquiring the parameter field of the uploaded file;
s315: reading the position of the unique, and taking the next character to obtain the unique configuration;
s316: reading the 'exception' position, and reading the as position backwards, wherein the as position comprises a character before the as and a character after the as, and assembling the as position and the as position into abnormal output information;
s317: the "#" position is read and an additional conditional Map is assembled.
5. The method for realizing Excel data import and export based on SQL like of claim 3, wherein: in step S3, the specific steps of deriving template analysis are:
s321: deriving template analysis, reading template character strings and dividing the character strings according to spaces;
s322: reading the position of the 'as', reading the previous character and the next character of the as, and assembling into an output information configuration;
s323: reading the 'form' position, taking the next character, and assembling to obtain a data mode;
s324: reading the 'where' position, judging whether the position exists, if so, reading until the keyword intos is encountered, assembling a connector and a field to form condition mapping;
s325: if the 'where' position does not exist, reading the 'into' position, taking the next character, and assembling into an output device;
s326: the "#" position is read and an additional conditional Map is assembled.
6. The method for realizing Excel data import and export based on SQL like of claim 3, wherein: in step S4, the specific steps for executing the import task are as follows:
s411: importing an execution task, and reading template configuration;
s412: downloading an import file from a file system;
s413: generating a failure excel file: the generated excel file contains error information;
s414: reading an uploaded excel file: reading the uploaded excel file line by line, judging whether batch setting is met, and jumping to the step S416 if the batch setting is met; if the batch setting is not satisfied, jumping to step S415;
s415: judging whether the read data is excel line tail data or not, and if the read data is the excel line tail data, performing step S416 and step S417; if not, returning to continue the step S414;
s416: processing data, uploading data to a service system by using service interface parameters; if the single time is completely successful, continuing to execute the step S414, and if the single time is not completely successful, writing failure reasons into the excel file;
s417: triggering excel file stream closing after the file is read;
s418: and uploading the excel to a file server, deleting the local excel, and then persisting the task result.
7. The method for realizing Excel data import and export based on SQL like of claim 3, wherein: in step S4, the specific steps of deriving task execution are as follows:
s421: exporting an execution task, and reading template configuration;
s422: creating an empty excel file;
s423: assembling interface parameters, and executing a specific task by a service execution module of a calling service system; after the execution is finished, returning data, performing data processing, and writing the file into an excel file;
s424: judging whether the returned data meet the continuing condition, if so, repeatedly executing the step S423, and if not, indicating that the data export is finished, and closing the excel file stream;
s425: and uploading the excel to a file server, deleting the local excel, and then persisting the task result.
CN202111576217.3A 2021-12-21 2021-12-21 SQL-based Excel data import and export system and method Active CN114416789B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111576217.3A CN114416789B (en) 2021-12-21 2021-12-21 SQL-based Excel data import and export system and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111576217.3A CN114416789B (en) 2021-12-21 2021-12-21 SQL-based Excel data import and export system and method

Publications (2)

Publication Number Publication Date
CN114416789A true CN114416789A (en) 2022-04-29
CN114416789B CN114416789B (en) 2024-11-08

Family

ID=81268306

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111576217.3A Active CN114416789B (en) 2021-12-21 2021-12-21 SQL-based Excel data import and export system and method

Country Status (1)

Country Link
CN (1) CN114416789B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115525702A (en) * 2022-09-06 2022-12-27 浪潮软件股份有限公司 A work information registration management method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7849108B1 (en) * 2007-03-13 2010-12-07 Fundriver, Inc. Methods and systems for establishing a database
CN103744982A (en) * 2014-01-15 2014-04-23 北京神州普惠科技股份有限公司 Method for importing Excel data into database
US20170011135A1 (en) * 2015-07-06 2017-01-12 IGATE Global Solutions Ltd. Conversion Automation through Data and Object Importer
CN111914008A (en) * 2020-06-20 2020-11-10 中国建设银行股份有限公司 Method and device for batch export of work order data, electronic equipment and medium
CN112559837A (en) * 2021-01-05 2021-03-26 广州华资软件技术有限公司 Business electronic file development method
CN112949275A (en) * 2021-03-12 2021-06-11 中国平安财产保险股份有限公司 Method, device, equipment and storage medium for importing electronic forms into database

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7849108B1 (en) * 2007-03-13 2010-12-07 Fundriver, Inc. Methods and systems for establishing a database
CN103744982A (en) * 2014-01-15 2014-04-23 北京神州普惠科技股份有限公司 Method for importing Excel data into database
US20170011135A1 (en) * 2015-07-06 2017-01-12 IGATE Global Solutions Ltd. Conversion Automation through Data and Object Importer
CN111914008A (en) * 2020-06-20 2020-11-10 中国建设银行股份有限公司 Method and device for batch export of work order data, electronic equipment and medium
CN112559837A (en) * 2021-01-05 2021-03-26 广州华资软件技术有限公司 Business electronic file development method
CN112949275A (en) * 2021-03-12 2021-06-11 中国平安财产保险股份有限公司 Method, device, equipment and storage medium for importing electronic forms into database

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
HORA, JOHN MILAN等: "An Excel-based tool for evaluating and visualizing geothermobarometry data", 《COMPUTERS & GEOSCIENCES》, 17 July 2013 (2013-07-17) *
陈瑞勋;李青;解海涛;: "基于C#的数据导入导出功能的实现与应用", 电脑编程技巧与维护, no. 05, 3 March 2014 (2014-03-03) *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115525702A (en) * 2022-09-06 2022-12-27 浪潮软件股份有限公司 A work information registration management method and system

Also Published As

Publication number Publication date
CN114416789B (en) 2024-11-08

Similar Documents

Publication Publication Date Title
US9483257B2 (en) Universal and adaptive software development platform for data-driven applications
JP5407043B2 (en) Efficient piecewise update of binary encoded XML data
US7693911B2 (en) Uniform metadata retrieval
US8321450B2 (en) Standardized database connectivity support for an event processing server in an embedded context
CN112015413A (en) Programming-free data visualization Web display system and implementation method thereof
CN109491989B (en) Data processing method and device, electronic equipment and storage medium
CN114036425B (en) Page access method, client, server and system
US11593357B2 (en) Databases and methods of storing, retrieving, and processing data
US20220114483A1 (en) Unified machine learning feature data pipeline
CN115729938B (en) A method for implementing a fast data upload engine based on DataX
CN108762743A (en) Data table operation code generation method and device
CN114218906A (en) Vue-based table data formatting component implementation method
CN113761040A (en) Database and application program bidirectional mapping method, device, medium and program product
CN107515866B (en) Data operation method, device and system
CN112507067A (en) Cache plug-in annotating device and annotation method
CN117453713A (en) SQL sentence generation method, device and storage medium for multi-type database
CN114416789B (en) SQL-based Excel data import and export system and method
CN116456021B (en) Page data request method, device, electronic device and readable storage medium
CN112181996A (en) Relational database unified data access middleware method and system
CN116975087A (en) Heterogeneous data source retrieval method, device, equipment and medium
CN114970474B (en) A method and system for importing and exporting Excel files based on data monitoring
CN110413278A (en) Method, device, storage medium, and computer equipment for displaying number of records in pages
CN116257673A (en) Data query method, device, equipment and storage medium based on ElasticSearch
CN101976255A (en) Method and device for large-quantity export of webpage information to generate WORD document
CN116506540B (en) Page data request method and device, electronic equipment and 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
GR01 Patent grant
GR01 Patent grant