WO2018201697A1 - Method, device and equipment for generating a file and computer readable storage medium - Google Patents

Method, device and equipment for generating a file and computer readable storage medium Download PDF

Info

Publication number
WO2018201697A1
WO2018201697A1 PCT/CN2017/112009 CN2017112009W WO2018201697A1 WO 2018201697 A1 WO2018201697 A1 WO 2018201697A1 CN 2017112009 W CN2017112009 W CN 2017112009W WO 2018201697 A1 WO2018201697 A1 WO 2018201697A1
Authority
WO
WIPO (PCT)
Prior art keywords
row
data
file
generating
preset table
Prior art date
Application number
PCT/CN2017/112009
Other languages
French (fr)
Chinese (zh)
Inventor
丁志勇
Original Assignee
平安科技(深圳)有限公司
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 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2018201697A1 publication Critical patent/WO2018201697A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented

Definitions

  • the present application relates to the field of data processing technologies, and in particular, to a file generating method, apparatus, device, and computer readable storage medium.
  • the existing manifest download framework is based on the open source library poi, with DOM (Document Object Model, Document Object Model)
  • the model is the core list download framework.
  • the developer needs to write the template file corresponding to the list downloading framework in the form of code, and generate the corresponding file through the template file, but the downloading frame corresponding to the template file is based on the DOM model.
  • the xls or xlsx format is not supported, so the format of the resulting file cannot be in xls or xlsx format.
  • the main purpose of the present application is to provide a file generation method, apparatus, device, and computer readable storage medium, which are intended to solve the technical problem that a file generated by a manifest download framework with a DOM model as a core does not support the xls or xlsx format.
  • the present application provides a file generating method, where the file generating method includes the following steps:
  • the present application further provides a file generating apparatus, where the file generating apparatus includes:
  • An obtaining module configured to acquire configuration information of a preset type downloading framework when detecting a startup instruction of the business system
  • a creating module configured to create a preset table according to the configuration information, and write the first row of data into the preset table
  • the generating module is further configured to: if the first row of data meets the condition of the preset table, generate a file corresponding to the preset table according to the first row of data.
  • the generating module comprises:
  • An obtaining unit configured to obtain second row data from a database
  • a determining unit configured to determine a correspondence between the second row of data and a variable in a template file of the manifest download framework
  • a generating unit configured to generate first row data of the map structure according to the correspondence relationship based on the second row data.
  • the creating unit is further configured to create an Excel table according to the configuration information, and write the first row data of the map structure into the Excel table in a stream form;
  • the generating module is further configured to: if the row data satisfies the condition of the Excel table, generate a sheet page header and content corresponding to the Excel file, and determine whether the data according to the size of the first row is Need to change pages to generate an Excel file.
  • the template file corresponding to the manifest download framework includes a header file template, a content header template, and a content body template.
  • the obtaining module comprises:
  • a loading unit configured to load a JAR package of the list download framework when detecting a startup instruction of the business system
  • an obtaining unit configured to acquire configuration information of the manifest download framework in the JAR package if the JAR package is successfully loaded.
  • the file generating apparatus further includes:
  • a detecting module configured to detect whether a mandatory parameter field of the first row of data written in the preset table is empty, and detecting whether a number of columns corresponding to the first row of data is greater than a maximum of the configuration information The number of columns.
  • the present application further provides a file generating device, the file generating device including a memory, a processor, and a file generating program stored on the memory and executable on the processor, The steps of the file generation method as described above are implemented when the file generation program is executed by the processor.
  • the present application further provides a computer readable storage medium having a file generation program stored thereon, and the file generation program is executed by a processor to implement file generation as described above. The steps of the method.
  • the present application obtains the configuration information of the preset type of the download framework of the list when the startup command of the business system is detected, and generates the first line of data of the preset structure; and creates a preset table according to the configuration information, and The first row of data is written into the preset table; if the first row of data satisfies the condition of the preset table, a file corresponding to the preset table is generated according to the first row of data.
  • the corresponding file is generated by the preset type list downloading framework, and the file can support the xls or xlsx format, that is, the file generated by the support is diversified.
  • FIG. 1 is a schematic structural diagram of a device in a hardware operating environment involved in an embodiment of the present application
  • FIG. 2 is a schematic flowchart diagram of a preferred embodiment of a method for generating a file according to the present application.
  • the solution of the embodiment of the present application is: when detecting a startup instruction of the service system, acquiring configuration information of a preset type of download framework, and generating first row data of the preset structure; and creating according to the configuration information Presetting a table, and writing the first row of data into the preset table; if the first row of data satisfies a condition of the preset table, generating and pre-determining according to the first row of data Set the file corresponding to the form.
  • the file generated by the download framework based on the DOM model does not support the xls or xlsx format.
  • FIG. 1 is a schematic structural diagram of a device in a hardware operating environment according to an embodiment of the present application.
  • the file generating device in the embodiment of the present application may be a PC, or may be a smart phone, a tablet computer, an e-book reader, and an MP3 (Moving). Picture Experts Group Audio Layer III, motion picture expert compresses standard audio layer 3) player, MP4 (Moving Picture Experts Group Audio Layer IV, dynamic video experts compress standard audio layers 3) Players, portable computers and other portable terminal devices with display functions.
  • MP3 Motion Picture Experts Group Audio Layer III, motion picture expert compresses standard audio layer 3
  • MP4 Moving Picture Experts Group Audio Layer IV, dynamic video experts compress standard audio layers 3) Players
  • portable computers and other portable terminal devices with display functions may be a PC, or may be a smart phone, a tablet computer, an e-book reader, and an MP3 (Moving). Picture Experts Group Audio Layer III, motion picture expert compresses standard audio layer 3) player, MP4 (Moving Picture Experts Group Audio Layer IV, dynamic video experts compress standard audio layers 3) Players, portable computers and other portable terminal devices with display functions
  • the file generating device may include a processor 1001, such as a CPU, a user interface 1003, a memory 1005, and a communication bus 1002.
  • the communication bus 1002 is used to implement connection communication between these components.
  • the user interface 1003 can include a display, an input unit such as a keyboard, and the optional user interface 1003 can also include a standard wired interface, a wireless interface.
  • the memory 1005 may be a high speed RAM memory or a stable memory (non-volatile) Memory), such as disk storage.
  • the memory 1005 can also optionally be a storage device independent of the aforementioned processor 1001.
  • the file generating device may further include a camera, RF (Radio) Frequency, RF) circuits, sensors, audio circuits, WiFi modules, and more.
  • RF Radio
  • RF Radio Frequency
  • file generating device structure shown in FIG. 1 does not constitute a limitation to the terminal, and may include more or less components than those illustrated, or combine some components, or different component arrangements.
  • an operating system and a file generation program may be included in the memory 1005 as a computer storage medium.
  • the operating system is a program that manages and controls the file generation device hardware and software resources, and supports the operation of the file generation program and other software and/or programs.
  • the user interface 1003 is mainly used to receive a startup command or the like.
  • the processor 1001 can be used to call a file generation program stored in the memory 1005 and perform the following operations:
  • step of generating the first row of data of the preset structure includes:
  • the first row of data of the map structure is generated according to the correspondence.
  • the step of creating a preset table according to the configuration information, and writing the first row of data into the preset table includes:
  • the step of generating a file corresponding to the preset table according to the first row of data includes:
  • the processor 1001 may further be configured to invoke the file generation program stored in the memory 1005 to perform the following operations. :
  • the second row of data is stored in a Java virtual machine
  • the processor 1001 may further be configured to invoke the memory 1005 after the step of generating the file corresponding to the preset table according to the first row of data, if the first row of data meets the condition of the preset table.
  • the file generator stored in the file do the following:
  • the template file corresponding to the manifest download framework includes a header file template, a content header template, and a content body template.
  • the step of acquiring configuration information of the preset type of download framework includes:
  • the configuration information of the manifest download framework is obtained in the JAR package.
  • the processor 1001 may further be used before the step of generating a file corresponding to the preset table according to the first row data, if the first row data satisfies the condition of the preset table.
  • the file generation program stored in the memory 1005 is called to perform the following operations:
  • FIG. 2 is a schematic flowchart of a first embodiment of a method for generating a file according to the present application.
  • the file generation method includes:
  • step S10 when the startup command of the service system is detected, the configuration information of the list download framework of the preset type is acquired, and the first row data of the preset structure is generated.
  • the startup instruction may be triggered by the user, or may be set to automatically trigger the service system at a fixed time. If the business system is set to start automatically at 6 o'clock every day to trigger the start command.
  • the preset type of download framework is a String Template list download framework.
  • String Template (referred to as ST) is a Java-based template engine library (currently supporting C#, Python, Ruby), which can be used to generate various formatted texts such as source code, web pages, and emails.
  • the preset type of download framework can be and String
  • the Template List download framework has a list download framework with the same functionality. Configuration information includes, but is not limited to, the number of rows and columns of template files in the manifest download framework.
  • String The Template list download framework includes ElisRbsStartup, XlsClassLoader, DsmsXlsCommonIOHandler, DsmsXlsIOHandler, XlsColumnDef, XlsRowDefDTO, RbsXlsIOHandler, DsmsXlsBaseIOHandler, DsmsXlsMgIOHandler, RbsXlsMgIOHandler, and XlsUtli modules.
  • the names of the modules are custom names, which are only used to assist in understanding various program function modules of the list downloading framework, and are not used to limit the present application.
  • the technical solution, the core of the technical solution of the present application is the function to be achieved by the modules respectively defining the names.
  • ElisRbsStartup When ElisRbsStartup initializes the JAR package of the manifest download framework, ElisRbsStartup is used to call XlsClassLoader to load the JAR package of the manifest download framework and check if the JAR package of the manifest download framework is loaded successfully.
  • JAR Java Archive, a Java archive file
  • the JAR file format is based on the popular ZIP file format, with ZIP
  • the difference between files is that JAR files are not only used for compression and publishing, but also for deploying and packaging libraries, components, and plug-ins, and can be used like compilers and JVMs (Java Virtual Machine, Java virtual machine) such a tool is used directly.
  • DsmsXlsCommonIOHandler is used to define the common header of the manifest download framework, such as defining the common parameters required for each template file, as well as defining the output file path and callback function, and checking whether the manifest download framework is initialized successfully.
  • DsmsXlsIOHandler is used to read the configuration information of the manifest download framework, and execute the callback function in the common header.
  • the callback function is mainly used to read the first row of data from the database, and download the template in the framework according to the read row data and the list.
  • the correspondence between the file variables generates row data of the map structure, and the row data of the map structure is the second row of data.
  • DsmsXlsIOHandler is also used for file splitting when the file generated by the first line of data needs to be changed.
  • XlsColumnDef is used to determine the correspondence between the first row of data and the template file variables in the manifest download framework.
  • XlsRowDefDTO is a data carrier.
  • DsmsXlsBaseIOHandler is used to get the public header of the manifest download framework.
  • RbsXlsIOHandler The DsmsXlsMgIOHandler and the RbsXlsMgIOHandler are used to obtain the row data to be configured from different databases, that is, to obtain the second row of data.
  • RbsXlsIOHandler can be used to obtain the row data to be configured from the database of the business system
  • DsmsXlsMgIOHandler and RbsXlsMgIOHandler can be used to obtain the row data to be configured from MongoDB.
  • MongoDB is a product between a relational database and a non-relational database. It is the most versatile of the non-relational database, most like a relational database. It supports a very loose data structure and is similar to JSON (Java). Script Object Notation (JS object tag) BJSON (Binary JSON) format, so you can store more complex data types.
  • XlsUtl is the core module of the list download framework. It is mainly used to define the basic parameters of the list download framework, set the corresponding default values, and support multiple ways to create preset tables.
  • an Excel spreadsheet can be created in multiple files to support writing multiple rows of data to the created Excel spreadsheet at a time; an Excel spreadsheet can be created in a single file and multiple sheets to support writing multiple rows of data to the created Excel spreadsheet at a time.
  • An Excel spreadsheet can be created in a single file breakpoint to support writing a row of data to the created Excel spreadsheet at a time.
  • XlsUtl can also be used for parameter detection, such as detecting whether the written row data field is empty, whether the required field corresponding to the written row data is empty, and detecting whether the row data is correctly written into the Excel table; Whether the number of columns corresponding to the entered row data exceeds the maximum number of columns set by the template file; detecting whether the template file exists; generating the sheet page header and sheet page contents, and detecting whether the generated Excel file needs to be changed.
  • the step of acquiring the configuration information of the preset type download framework includes:
  • Step a when the startup command of the business system is detected, loading the JAR package of the list download framework.
  • Step b If the JAR package is successfully loaded, obtaining configuration information of the manifest download framework in the JAR package.
  • the JAR package of the list download framework is loaded.
  • the configuration information of the list download framework is obtained in the JAR package;
  • the prompt information may be output, prompting the user that the JAR package fails to load, please reload the list.
  • the preset number of times may be set according to specific needs, such as 2 times, or 3 times.
  • step of generating the first row of data of the preset structure includes:
  • Step c obtaining the second row of data from the database.
  • Step d determining a correspondence between the second row of data and a variable in a template file of the manifest download framework.
  • Step e based on the second row of data, generating first row data of the map structure according to the correspondence relationship.
  • the second row of data is obtained from the database, and the template file of the manifest download framework is obtained.
  • the second row of data is obtained from the database, parsing the second row of data, determining a correspondence between the second row of data and variables in the template file, and generating a map structure according to the determined correspondence relationship based on the second row of data
  • the first line of data It can be understood that the first row of data can be obtained through the second row of data.
  • a map is a data structure stored in the form of a key-value pair.
  • the key value is equivalent to the subscript in the list and the array.
  • the key value can be any type of object, and there can be no duplicate key values in the graph and each The key value must be stored in correspondence with a corresponding value.
  • the manifest download framework includes three template files, which are a header file template, a content header template, and a content body template.
  • the header file template is used to define the style of the entire file, such as field type, color, etc., similar to CSS (Cascading) Style Sheets, Cascading Style Sheets) .
  • the content header template is used to define common parameters in the sheet page, such as list names, public parameters, and column field definitions.
  • the content body template is used to bind dynamic column fields to corresponding variables.
  • the format of the template file of the list download frame is a file ending with st.
  • the head file template is represented by head.st
  • the content header template is represented by body_head.st, with body_row. St represents the content body template.
  • the manifest downloading framework may further include an optional template for implementing special requirements of the user, such as when the generated file is required to have a drop-down list, data verification, etc., and may be implemented by an optional template.
  • Step S20 Create a preset table according to the configuration information, and write the first row of data into the preset table.
  • a preset table is created according to the configuration information, and the first line of data is written into the created preset table.
  • the preset table can be created in various ways, and the writing method of writing the first row of data into the preset table is different according to the manner of creating the table, such as writing more at one time.
  • the preset form is an Excel table, and in other embodiments, the form may also be a CSV (Comma-Separated) Values, comma-separated values), a table in TXT format.
  • step S20 includes:
  • Step f Create an Excel table according to the configuration information, and write the first row data of the map structure into the Excel table in a stream form.
  • an Excel table is created according to the acquired configuration information, and the first row data of the map structure is written into the Excel table in a stream form.
  • Step S30 If the first row data satisfies the condition of the preset table, generate a file corresponding to the preset table according to the first row data.
  • the file corresponding to the preset table is generated according to the first row of data.
  • the file corresponding to the preset table is not generated; or the data in the first row data that does not satisfy the preset table condition is deleted, and then the corresponding table is generated. document.
  • the process of detecting whether the first row of data in the preset table satisfies the condition of the preset table is: detecting whether a mandatory parameter field of the first row of data written in the preset table is empty; and detecting the first Whether the number of columns corresponding to the row data is greater than the maximum number of columns in the configuration information.
  • the required parameter field of the first row of data written in the preset table is not empty, and the number of columns corresponding to the first row of data is less than or equal to the maximum number of columns in the configuration information, it is determined that the first row of data satisfies the preset table.
  • the condition is that when the mandatory parameter field of the first row of data written in the preset table is empty, and/or the number of columns corresponding to the first row of data is greater than the maximum number of columns in the configuration information, it is determined that the first row of data is not satisfied.
  • Preset the conditions of the form It can be understood that the mandatory parameters in the line data differ according to the content of the generated file.
  • step S30 includes:
  • Step h if the first row of data satisfies the condition of the Excel table, generate a sheet page header and content corresponding to the Excel file, and determine whether it needs to be changed according to the size of the first row of data. Page to generate an Excel file.
  • the first row data of the map structure is written into the Excel table in a stream form, it is detected whether the first row data written in the Excel table satisfies the condition of the Excel table. If the first line of data satisfies the condition of the Excel table, the sheet page header and the sheet page contents corresponding to the Excel file are generated, and the page size is determined according to the size of the first line of data, that is, according to the first line of data. The number of rows and columns determines if a page break is required.
  • the format of the Excel file may be xls or xlsx format.
  • the configuration information of the preset type of the download frame is acquired, and the first row of the preset structure is generated; and the preset table is created according to the configuration information, and The first row of data is written into the preset table; if the first row of data satisfies the condition of the preset table, a file corresponding to the preset table is generated according to the first row of data.
  • the corresponding file is generated by the preset type list downloading framework, and the file can support the xls or xlsx format, that is, the file generated by the support is diversified.
  • step i the second row of data is stored in the Java virtual machine.
  • Step g deleting the second row of data stored by the Java virtual machine.
  • the acquired second row of data is stored in the Java virtual machine.
  • the file corresponding to the preset table is generated according to the first row of data
  • the second row of data stored in the Java virtual machine is deleted.
  • the two rows of data are regenerated according to the second row of data to generate the required file.
  • the Java virtual machine has its own complete hardware architecture, such as processors, stacks, registers, etc., and has a corresponding instruction system.
  • the Java virtual machine by storing the original data (the second row of data) acquired from the database in the Java virtual machine, when the data related to the original data has an error during the process of generating the file, the The Java virtual machine obtains the original data without looking up the original data in the business system database, which improves the file generation efficiency. After the file is successfully generated, the data stored in the Java virtual machine is deleted, which saves the storage space of the Java virtual machine to improve the utilization of the Java virtual machine storage space.
  • the embodiment of the present application further provides a file generating apparatus, where the file generating apparatus includes:
  • An obtaining module configured to acquire configuration information of a preset type downloading framework when detecting a startup instruction of the business system
  • a creating module configured to create a preset table according to the configuration information, and write the first row of data into the preset table
  • the generating module is further configured to: if the first row of data meets the condition of the preset table, generate a file corresponding to the preset table according to the first row of data.
  • the generating module includes:
  • An obtaining unit configured to obtain second row data from a database
  • a determining unit configured to determine a correspondence between the second row of data and a variable in a template file of the manifest download framework
  • a generating unit configured to generate first row data of the map structure according to the correspondence relationship based on the second row data.
  • the creating unit is further configured to create an Excel table according to the configuration information, and write the first row data of the map structure into the Excel table in a stream form;
  • the generating module is further configured to: if the row data satisfies the condition of the Excel table, generate a sheet page header and content corresponding to the Excel file, and determine whether the data according to the size of the first row is Need to change pages to generate an Excel file.
  • the template file corresponding to the manifest download framework includes a header file template, a content header template, and a content body template.
  • the obtaining module includes:
  • a loading unit configured to load a JAR package of the list download framework when detecting a startup instruction of the business system
  • an obtaining unit configured to acquire configuration information of the manifest download framework in the JAR package if the JAR package is successfully loaded.
  • the file generating apparatus further includes:
  • a detecting module configured to detect whether a mandatory parameter field of the first row of data written in the preset table is empty, and detecting whether a number of columns corresponding to the first row of data is greater than a maximum of the configuration information The number of columns.
  • the embodiment of the present application further provides a computer readable storage medium, where the file readable storage medium is stored, and when the file generating program is executed by the processor, the following steps are implemented:
  • step of generating the first row of data of the preset structure includes:
  • the first row of data of the map structure is generated according to the correspondence.
  • the step of creating a preset table according to the configuration information, and writing the first row of data into the preset table includes:
  • the step of generating a file corresponding to the preset table according to the first row of data includes:
  • the file generating program is executed by the processor to implement the following steps:
  • the second row of data is stored in a Java virtual machine
  • the template file corresponding to the manifest download framework includes a header file template, a content header template, and a content body template.
  • the step of acquiring configuration information of the preset type of download framework includes:
  • the configuration information of the manifest download framework is obtained in the JAR package.
  • the file generating program is processed before the step of generating a file corresponding to the preset table according to the first row of data.
  • the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better.
  • Implementation Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • the optical disc includes a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present application.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A method, device and equipment for generating a file and a computer readable storage medium, wherein the method comprises the steps of: when a starting instruction from a service system is detected, acquiring the configuration information for a list downloading frame of a predetermined type, and generating a first line of data having a predetermined structure (S10); creating a preset form according to the configuration information, and writing the first line of data into the preset form (S20); if the first line of data satisfies the criteria of the preset form, then a file corresponding to the preset form will be generated according to the first line of data (S30). The described method achieves the generation of corresponding files by means of the list downloading frame of a preset-type, wherein the files may support xls or xlsx formats, thus being able to support the diversification of generated files.

Description

文件生成方法、装置、设备以及计算机可读存储介质  File generation method, device, device, and computer readable storage medium
本申请要求于2017年5月5日提交中国专利局、申请号为201710319543.3、发明名称为“文件生成方法、设备以及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。The present application claims priority to Chinese Patent Application No. JP-A No. No. No. No. No. No. No. No. No. No. No. No. No. No. No. In the application.
技术领域Technical field
本申请涉及数据处理技术领域,尤其涉及一种文件生成方法、装置、设备以及计算机可读存储介质。The present application relates to the field of data processing technologies, and in particular, to a file generating method, apparatus, device, and computer readable storage medium.
背景技术Background technique
现有的清单下载框架是基于开放源码函式库poi的,以DOM(Document Object Model,文档对象模型)模型为核心的清单下载框架。在使用该种清单下载框架过程中,每次都需要开发人员以代码形式编写清单下载框架对应的模板文件,并通过该模板文件生成对应文件,但是由于以DOM模型为核心的下载框架对应模板文件不支持xls或xlsx格式,因此最终生成的文件的格式不能为xls或xlsx格式。The existing manifest download framework is based on the open source library poi, with DOM (Document Object Model, Document Object Model) The model is the core list download framework. In the process of using the list downloading framework, the developer needs to write the template file corresponding to the list downloading framework in the form of code, and generate the corresponding file through the template file, but the downloading frame corresponding to the template file is based on the DOM model. The xls or xlsx format is not supported, so the format of the resulting file cannot be in xls or xlsx format.
发明内容Summary of the invention
本申请的主要目的在于提供一种文件生成方法、装置、设备以及计算机可读存储介质,旨在解决以DOM模型为核心的清单下载框架所生成的文件不支持xls或xlsx格式的技术问题。The main purpose of the present application is to provide a file generation method, apparatus, device, and computer readable storage medium, which are intended to solve the technical problem that a file generated by a manifest download framework with a DOM model as a core does not support the xls or xlsx format.
为实现上述目的,本申请提供一种文件生成方法,所述文件生成方法包括步骤:To achieve the above objective, the present application provides a file generating method, where the file generating method includes the following steps:
当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息,以及生成预设结构的第一行数据;When the startup command of the service system is detected, acquiring configuration information of the preset type download framework and generating the first row of data of the preset structure;
根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;Forming a preset table according to the configuration information, and writing the first row of data into the preset table;
若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。And if the first row data satisfies the condition of the preset table, generating a file corresponding to the preset table according to the first row data.
此外,为实现上述目的,本申请还提供一种文件生成装置,所述文件生成装置包括:In addition, in order to achieve the above object, the present application further provides a file generating apparatus, where the file generating apparatus includes:
获取模块,用于当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息;An obtaining module, configured to acquire configuration information of a preset type downloading framework when detecting a startup instruction of the business system;
生成模块,用于生成预设结构的第一行数据;Generating a module for generating a first line of data of the preset structure;
创建模块,用于根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;a creating module, configured to create a preset table according to the configuration information, and write the first row of data into the preset table;
所述生成模块还用于若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。The generating module is further configured to: if the first row of data meets the condition of the preset table, generate a file corresponding to the preset table according to the first row of data.
优选地,所述生成模块包括:Preferably, the generating module comprises:
获取单元,用于从数据库中获取第二行数据;An obtaining unit, configured to obtain second row data from a database;
确定单元,用于确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系;a determining unit, configured to determine a correspondence between the second row of data and a variable in a template file of the manifest download framework;
生成单元,用于基于所述第二行数据,根据所述对应关系生成map结构的第一行数据。And a generating unit, configured to generate first row data of the map structure according to the correspondence relationship based on the second row data.
优选地,所述创建单元还用于根据所述配置信息创建Excel表格,并将map结构的第一行数据以流形式写入所述Excel表格中;Preferably, the creating unit is further configured to create an Excel table according to the configuration information, and write the first row data of the map structure into the Excel table in a stream form;
所述生成模块还用于若所述行数据满足所述Excel表格的条件,则生成与所述Excel表格对应Excel文件的sheet页头部和内容,并根据所述第一行数据的大小确定是否需要换页,以生成Excel文件。The generating module is further configured to: if the row data satisfies the condition of the Excel table, generate a sheet page header and content corresponding to the Excel file, and determine whether the data according to the size of the first row is Need to change pages to generate an Excel file.
优选地,所述清单下载框架对应的模板文件包括头文件模板、内容头模板和内容体模板。Preferably, the template file corresponding to the manifest download framework includes a header file template, a content header template, and a content body template.
优选地,所述获取模块包括:Preferably, the obtaining module comprises:
加载单元,用于当侦测到业务系统的启动指令时,加载所述清单下载框架的JAR包;a loading unit, configured to load a JAR package of the list download framework when detecting a startup instruction of the business system;
获取单元,用于若所述JAR包加载成功,则在所述JAR包中获取所述清单下载框架的配置信息。And an obtaining unit, configured to acquire configuration information of the manifest download framework in the JAR package if the JAR package is successfully loaded.
优选地,所述文件生成装置还包括:Preferably, the file generating apparatus further includes:
检测模块,用于检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。a detecting module, configured to detect whether a mandatory parameter field of the first row of data written in the preset table is empty, and detecting whether a number of columns corresponding to the first row of data is greater than a maximum of the configuration information The number of columns.
此外,为实现上述目的,本申请还提供一种文件生成设备,所述文件生成设备包括存储器、处理器和存储在所述存储器上并可在所述处理器上运行的文件生成程序,所述文件生成程序被所述处理器执行时实现如上所述的文件生成方法的步骤。In addition, in order to achieve the above object, the present application further provides a file generating device, the file generating device including a memory, a processor, and a file generating program stored on the memory and executable on the processor, The steps of the file generation method as described above are implemented when the file generation program is executed by the processor.
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有文件生成程序,所述文件生成程序被处理器执行时实现如上所述的文件生成方法的步骤。In addition, in order to achieve the above object, the present application further provides a computer readable storage medium having a file generation program stored thereon, and the file generation program is executed by a processor to implement file generation as described above. The steps of the method.
本申请通过当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息,以及生成预设结构的第一行数据;根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。实现了通过预设类型清单下载框架生成对应的文件,该文件可支持xls或xlsx格式,即实现了支持所生成文件多样化。The present application obtains the configuration information of the preset type of the download framework of the list when the startup command of the business system is detected, and generates the first line of data of the preset structure; and creates a preset table according to the configuration information, and The first row of data is written into the preset table; if the first row of data satisfies the condition of the preset table, a file corresponding to the preset table is generated according to the first row of data. The corresponding file is generated by the preset type list downloading framework, and the file can support the xls or xlsx format, that is, the file generated by the support is diversified.
附图说明DRAWINGS
图1是本申请实施例方案涉及的硬件运行环境的设备结构示意图;1 is a schematic structural diagram of a device in a hardware operating environment involved in an embodiment of the present application;
图2为本申请文件生成方法较佳实施例的流程示意图。FIG. 2 is a schematic flowchart diagram of a preferred embodiment of a method for generating a file according to the present application.
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings.
具体实施方式detailed description
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。It is understood that the specific embodiments described herein are merely illustrative of the application and are not intended to be limiting.
本申请实施例的解决方案主要是:当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息,以及生成预设结构的第一行数据;根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。以解决以DOM模型为核心的下载框架所生成的文件不支持xls或xlsx格式的问题。The solution of the embodiment of the present application is: when detecting a startup instruction of the service system, acquiring configuration information of a preset type of download framework, and generating first row data of the preset structure; and creating according to the configuration information Presetting a table, and writing the first row of data into the preset table; if the first row of data satisfies a condition of the preset table, generating and pre-determining according to the first row of data Set the file corresponding to the form. The file generated by the download framework based on the DOM model does not support the xls or xlsx format.
如图1所示,图1是本申请实施例方案涉及的硬件运行环境的设备结构示意图。As shown in FIG. 1 , FIG. 1 is a schematic structural diagram of a device in a hardware operating environment according to an embodiment of the present application.
本申请实施例文件生成设备可以是PC,也可以是智能手机、平板电脑、电子书阅读器、MP3(Moving Picture Experts Group Audio Layer III,动态影像专家压缩标准音频层面3)播放器、MP4(Moving Picture Experts Group Audio Layer IV,动态影像专家压缩标准音频层面3)播放器、便携计算机等具有显示功能的可移动式终端设备。The file generating device in the embodiment of the present application may be a PC, or may be a smart phone, a tablet computer, an e-book reader, and an MP3 (Moving). Picture Experts Group Audio Layer III, motion picture expert compresses standard audio layer 3) player, MP4 (Moving Picture Experts Group Audio Layer IV, dynamic video experts compress standard audio layers 3) Players, portable computers and other portable terminal devices with display functions.
如图1所示,该文件生成设备可以包括:处理器1001,例如CPU,用户接口1003,存储器1005,通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 1, the file generating device may include a processor 1001, such as a CPU, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to implement connection communication between these components. The user interface 1003 can include a display, an input unit such as a keyboard, and the optional user interface 1003 can also include a standard wired interface, a wireless interface. The memory 1005 may be a high speed RAM memory or a stable memory (non-volatile) Memory), such as disk storage. The memory 1005 can also optionally be a storage device independent of the aforementioned processor 1001.
可选地,文件生成设备还可以包括摄像头、RF(Radio Frequency,射频)电路,传感器、音频电路、WiFi模块等等。Optionally, the file generating device may further include a camera, RF (Radio) Frequency, RF) circuits, sensors, audio circuits, WiFi modules, and more.
本领域技术人员可以理解,图1中示出的文件生成设备结构并不构成对终端的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。It will be understood by those skilled in the art that the file generating device structure shown in FIG. 1 does not constitute a limitation to the terminal, and may include more or less components than those illustrated, or combine some components, or different component arrangements.
如图1所示,作为一种计算机存储介质的存储器1005中可以包括操作系统以及文件生成程序。其中,操作系统是管理和控制文件生成设备硬件和软件资源的程序,支持文件生成程序以及其它软件和/或程序的运行。As shown in FIG. 1, an operating system and a file generation program may be included in the memory 1005 as a computer storage medium. Among them, the operating system is a program that manages and controls the file generation device hardware and software resources, and supports the operation of the file generation program and other software and/or programs.
在图1所示的文件生成设备中,用户接口1003主要用于接收启动指令等。而处理器1001可以用于调用存储器1005中存储的文件生成程序,并执行以下操作:In the file generating device shown in FIG. 1, the user interface 1003 is mainly used to receive a startup command or the like. The processor 1001 can be used to call a file generation program stored in the memory 1005 and perform the following operations:
当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息,以及生成预设结构的第一行数据;When the startup command of the service system is detected, acquiring configuration information of the preset type download framework and generating the first row of data of the preset structure;
根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;Forming a preset table according to the configuration information, and writing the first row of data into the preset table;
若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。And if the first row data satisfies the condition of the preset table, generating a file corresponding to the preset table according to the first row data.
进一步地,所述生成预设结构的第一行数据的步骤包括:Further, the step of generating the first row of data of the preset structure includes:
从数据库中获取第二行数据;Get the second row of data from the database;
确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系;Determining a correspondence between the second row of data and a variable in a template file of the manifest download framework;
基于所述第二行数据,根据所述对应关系生成map结构的第一行数据。Based on the second row of data, the first row of data of the map structure is generated according to the correspondence.
进一步地,所述根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中的步骤包括:Further, the step of creating a preset table according to the configuration information, and writing the first row of data into the preset table includes:
根据所述配置信息创建Excel表格,并将map结构的第一行数据以流形式写入所述Excel表格中;Creating an Excel table according to the configuration information, and writing the first row data of the map structure into the Excel table in a stream form;
所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤包括:If the first row of data meets the condition of the preset table, the step of generating a file corresponding to the preset table according to the first row of data includes:
若所述行数据满足所述Excel表格的条件,则生成与所述Excel表格对应Excel文件的sheet页头部和内容,并根据所述第一行数据的大小确定是否需要换页,以生成Excel文件。If the row data satisfies the condition of the Excel table, generating a sheet page header and content corresponding to the Excel file, and determining whether a page change is required according to the size of the first row data to generate an Excel file.
进一步地,所述确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系的步骤之前,处理器1001还可以用于调用存储器1005中存储的文件生成程序,执行以下操作:Further, before the step of determining the correspondence between the second row data and the variables in the template file of the list download frame, the processor 1001 may further be configured to invoke the file generation program stored in the memory 1005 to perform the following operations. :
将所述第二行数据存储至Java虚拟机中;The second row of data is stored in a Java virtual machine;
所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之后,处理器1001还可以用于调用存储器1005中存储的文件生成程序,执行以下操作:The processor 1001 may further be configured to invoke the memory 1005 after the step of generating the file corresponding to the preset table according to the first row of data, if the first row of data meets the condition of the preset table. The file generator stored in the file, do the following:
删除所述Java虚拟机所存储的所述第二行数据。Deleting the second row of data stored by the Java virtual machine.
进一步地,所述清单下载框架对应的模板文件包括头文件模板、内容头模板和内容体模板。Further, the template file corresponding to the manifest download framework includes a header file template, a content header template, and a content body template.
进一步地,所述当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息的步骤包括:Further, when the startup command of the service system is detected, the step of acquiring configuration information of the preset type of download framework includes:
当侦测到业务系统的启动指令时,加载所述清单下载框架的JAR包;Loading a JAR package of the manifest download framework when a startup command of the business system is detected;
若所述JAR包加载成功,则在所述JAR包中获取所述清单下载框架的配置信息。If the JAR package is successfully loaded, the configuration information of the manifest download framework is obtained in the JAR package.
进一步地,所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之前,处理器1001还可以用于调用存储器1005中存储的文件生成程序,执行以下操作:Further, the processor 1001 may further be used before the step of generating a file corresponding to the preset table according to the first row data, if the first row data satisfies the condition of the preset table. The file generation program stored in the memory 1005 is called to perform the following operations:
检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;Detecting whether a mandatory parameter field of the first row of data written in the preset table is empty;
以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。And detecting whether the number of columns corresponding to the first row of data is greater than a maximum number of columns in the configuration information.
基于上述的硬件结构,提出文件生成方法的各个实施例。Based on the hardware configuration described above, various embodiments of the file generation method are proposed.
参照图2,图2为本申请文件生成方法第一实施例的流程示意图。Referring to FIG. 2, FIG. 2 is a schematic flowchart of a first embodiment of a method for generating a file according to the present application.
在本实施例中,提供了文件生成方法的实施例,需要说明的是,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。In the present embodiment, an embodiment of a file generating method is provided. It should be noted that although the logical order is shown in the flowchart, in some cases, the illustrated may be performed in a different order than here. Or the steps described.
所述文件生成方法包括:The file generation method includes:
步骤S10,当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息,以及生成预设结构的第一行数据。In step S10, when the startup command of the service system is detected, the configuration information of the list download framework of the preset type is acquired, and the first row data of the preset structure is generated.
当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息,以及生成预设结构的第一行数据。在本申请实施例中,该启动指令可由用户触发,也可设置为业务系统在固定时间自动触发。如设置业务系统在每天6点时自动启动,以触发启动指令。When the startup command of the business system is detected, the configuration information of the preset type download framework is obtained, and the first row of data of the preset structure is generated. In the embodiment of the present application, the startup instruction may be triggered by the user, or may be set to automatically trigger the service system at a fixed time. If the business system is set to start automatically at 6 o'clock every day to trigger the start command.
在本实施例中,预设类型的清单下载框架为String Template清单下载框架。String Template(简称ST)是一个基于Java的模板引擎库(目前同时支持C#、Python、Ruby),可以用于生成源代码、Web页面、电子邮件等各种有格式的文本。在其它实施例中,预设类型的清单下载框架可为和String Template清单下载框架具备同样功能的清单下载框架。配置信息包括但不限于清单下载框架中模板文件的行数和列数。In this embodiment, the preset type of download framework is a String Template list download framework. String Template (referred to as ST) is a Java-based template engine library (currently supporting C#, Python, Ruby), which can be used to generate various formatted texts such as source code, web pages, and emails. In other embodiments, the preset type of download framework can be and String The Template List download framework has a list download framework with the same functionality. Configuration information includes, but is not limited to, the number of rows and columns of template files in the manifest download framework.
在本申请实施例中,String Template清单下载框架包括ElisRbsStartup、XlsClassLoader、DsmsXlsCommonIOHandler、DsmsXlsIOHandler、XlsColumnDef、XlsRowDefDTO、RbsXlsIOHandler、DsmsXlsBaseIOHandler、DsmsXlsMgIOHandler、RbsXlsMgIOHandler和XlsUtli模块。需要说明的是,本领域的技术人员可对清单下载框架进行新模块的补充,各模块的名称是自定义名称,仅用于辅助理解该清单下载框架的各个程序功能模块,不用于限定本申请的技术方案,本申请技术方案的核心是,各自定义名称的模块所要达成的功能。In the embodiment of the present application, String The Template list download framework includes ElisRbsStartup, XlsClassLoader, DsmsXlsCommonIOHandler, DsmsXlsIOHandler, XlsColumnDef, XlsRowDefDTO, RbsXlsIOHandler, DsmsXlsBaseIOHandler, DsmsXlsMgIOHandler, RbsXlsMgIOHandler, and XlsUtli modules. It should be noted that those skilled in the art can supplement the new module of the list downloading framework, and the names of the modules are custom names, which are only used to assist in understanding various program function modules of the list downloading framework, and are not used to limit the present application. The technical solution, the core of the technical solution of the present application is the function to be achieved by the modules respectively defining the names.
当业务系统启动时,调用ElisRbsStartup,初始化清单下载框架的JAR包。When the business system starts, it calls ElisRbsStartup to initialize the JAR package of the manifest download framework.
当ElisRbsStartup初始化清单下载框架的JAR包后,ElisRbsStartup用于调用XlsClassLoader,以加载清单下载框架的JAR包,并检测清单下载框架的JAR包是否加载成功。JAR(Java Archive,Java 归档文件)是与平台无关的文件格式,它允许将许多文件组合成一个压缩文件。JAR 文件格式以流行的 ZIP 文件格式为基础,与 ZIP 文件不同的是,JAR 文件不仅用于压缩和发布,而且还用于部署和封装库、组件和插件程序,并可被像编译器和 JVM(Java Virtual Machine,Java虚拟机)这样的工具直接使用。When ElisRbsStartup initializes the JAR package of the manifest download framework, ElisRbsStartup is used to call XlsClassLoader to load the JAR package of the manifest download framework and check if the JAR package of the manifest download framework is loaded successfully. JAR (Java Archive, a Java archive file) is a platform-independent file format that allows many files to be combined into one compressed file. The JAR file format is based on the popular ZIP file format, with ZIP The difference between files is that JAR files are not only used for compression and publishing, but also for deploying and packaging libraries, components, and plug-ins, and can be used like compilers and JVMs (Java Virtual Machine, Java virtual machine) such a tool is used directly.
DsmsXlsCommonIOHandler用于定义清单下载框架的公共头,如定义各个模板文件所需的公共参数,以及定义输出文件路径和回调函数,以及检测清单下载框架初始化是否成功。DsmsXlsCommonIOHandler is used to define the common header of the manifest download framework, such as defining the common parameters required for each template file, as well as defining the output file path and callback function, and checking whether the manifest download framework is initialized successfully.
DsmsXlsIOHandler用于读取清单下载框架的配置信息,执行公共头中的回调函数,该回调函数主要用于从数据库中读取第一行数据,并根据所读取的行数据与清单下载框架中模板文件变量的对应关系生成map结构的行数据,该map结构的行数据即为第二行数据。DsmsXlsIOHandler还用于第一行数据生成的文件需要换页时,进行文件拆分。DsmsXlsIOHandler is used to read the configuration information of the manifest download framework, and execute the callback function in the common header. The callback function is mainly used to read the first row of data from the database, and download the template in the framework according to the read row data and the list. The correspondence between the file variables generates row data of the map structure, and the row data of the map structure is the second row of data. DsmsXlsIOHandler is also used for file splitting when the file generated by the first line of data needs to be changed.
XlsColumnDef用于确定第一行数据与清单下载框架中模板文件变量的对应关系。XlsColumnDef is used to determine the correspondence between the first row of data and the template file variables in the manifest download framework.
XlsRowDefDTO是数据载体。XlsRowDefDTO is a data carrier.
DsmsXlsBaseIOHandler用于获取清单下载框架的公共头。DsmsXlsBaseIOHandler is used to get the public header of the manifest download framework.
RbsXlsIOHandler 、DsmsXlsMgIOHandler和RbsXlsMgIOHandler用于获取来源于不同数据库的待配置的行数据,即获取第二行数据。如RbsXlsIOHandler可用于从业务系统的数据库中获取待配置的行数据,而DsmsXlsMgIOHandler和RbsXlsMgIOHandler可用于从MongoDB获取待配置的行数据。MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的,它支持的数据结构非常松散,是类似JSON(Java Script Object Notation,JS 对象标记)的BJSON(Binary JSON)格式,因此可以存储比较复杂的数据类型。RbsXlsIOHandler The DsmsXlsMgIOHandler and the RbsXlsMgIOHandler are used to obtain the row data to be configured from different databases, that is, to obtain the second row of data. For example, RbsXlsIOHandler can be used to obtain the row data to be configured from the database of the business system, and DsmsXlsMgIOHandler and RbsXlsMgIOHandler can be used to obtain the row data to be configured from MongoDB. MongoDB is a product between a relational database and a non-relational database. It is the most versatile of the non-relational database, most like a relational database. It supports a very loose data structure and is similar to JSON (Java). Script Object Notation (JS object tag) BJSON (Binary JSON) format, so you can store more complex data types.
XlsUtl是清单下载框架得核心模块,主要用于定义清单下载框架的基础参数,并设置对应的默认值,并支持多种方式创建预设表格。如可以多文件方式创建Excel表格,以支持一次写入多行数据到所创建的Excel表格中;可以单文件多sheet方式创建Excel表格,以支持一次写入多行数据到所创建的Excel表格中;可以单文件断点续写的方式创建Excel表格,以支持一次写入一行数据到所创建的Excel表格中。XlsUtl is the core module of the list download framework. It is mainly used to define the basic parameters of the list download framework, set the corresponding default values, and support multiple ways to create preset tables. For example, an Excel spreadsheet can be created in multiple files to support writing multiple rows of data to the created Excel spreadsheet at a time; an Excel spreadsheet can be created in a single file and multiple sheets to support writing multiple rows of data to the created Excel spreadsheet at a time. An Excel spreadsheet can be created in a single file breakpoint to support writing a row of data to the created Excel spreadsheet at a time.
XlsUtl还可用于参数检测,如检测所写入的行数据字段是否为空,所写入的行数据对应的必选字段是否为空;检测行数据是否全部正确写入Excel表格中;检测所写入的行数据对应的列数是否超过模板文件设置的最大列数;检测模板文件是否存在;生成sheet页头部和sheet页内容,并检测所生成的Excel文件是否需要换页等。XlsUtl can also be used for parameter detection, such as detecting whether the written row data field is empty, whether the required field corresponding to the written row data is empty, and detecting whether the row data is correctly written into the Excel table; Whether the number of columns corresponding to the entered row data exceeds the maximum number of columns set by the template file; detecting whether the template file exists; generating the sheet page header and sheet page contents, and detecting whether the generated Excel file needs to be changed.
进一步地,当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息的步骤包括:Further, when the startup instruction of the service system is detected, the step of acquiring the configuration information of the preset type download framework includes:
步骤a,当侦测到业务系统的启动指令时,加载所述清单下载框架的JAR包。Step a, when the startup command of the business system is detected, loading the JAR package of the list download framework.
步骤b,若所述JAR包加载成功,则在所述JAR包中获取所述清单下载框架的配置信息。Step b: If the JAR package is successfully loaded, obtaining configuration information of the manifest download framework in the JAR package.
进一步地,当侦测到业务系统的启动指令时,加载清单下载框架的JAR包。当清单下载框架的JAR包加载成功时,在JAR包中获取清单下载框架的配置信息;当清单下载框架的JAR包加载失败时,可输出提示信息,提示用户JAR包加载失败,请重新加载清单下载框架的JAR包;或者当清单下载框架的JAR包加载失败时,业务系统自动重新加载清单下载框架的JAR包,当业务系统自动加载JAR包失败的次数大于预设次数时,结束加载JAR包的工作流程。在本实施例中,预设次数可根据具体需要而设置,如可设置为2次,或者3次。Further, when the startup command of the business system is detected, the JAR package of the list download framework is loaded. When the JAR package of the list download framework is successfully loaded, the configuration information of the list download framework is obtained in the JAR package; when the JAR package of the list download framework fails to load, the prompt information may be output, prompting the user that the JAR package fails to load, please reload the list. Download the JAR package of the framework; or when the JAR package of the list download framework fails to load, the business system automatically reloads the JAR package of the list download framework. When the number of failed automatic loading of the JAR package by the business system is greater than the preset number of times, the JAR package is loaded. Workflow. In this embodiment, the preset number of times may be set according to specific needs, such as 2 times, or 3 times.
进一步地,生成预设结构的第一行数据的步骤包括:Further, the step of generating the first row of data of the preset structure includes:
步骤c,从数据库中获取第二行数据。Step c, obtaining the second row of data from the database.
步骤d,确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系。Step d: determining a correspondence between the second row of data and a variable in a template file of the manifest download framework.
步骤e,基于所述第二行数据,根据所述对应关系生成map结构的第一行数据。Step e, based on the second row of data, generating first row data of the map structure according to the correspondence relationship.
进一步地,从数据库中获取第二行数据,以及获取清单下载框架的模板文件。当从数据库中获取到第二行数据时,解析所述第二行数据,确定第二行数据与模板文件中变量的对应关系,并基于第二行数据,根据所确定的对应关系生成map结构的第一行数据。可以理解的是,通过第二行数据可得到第一行数据。 map是一种依照键值对的形式进行存储的数据结构,键值相当于list和数组中的下标,键值可以是任何类型的对象,同时在图中不能存在重复的键值并且每个键值必须与一个相应的值对应存储。Further, the second row of data is obtained from the database, and the template file of the manifest download framework is obtained. When the second row of data is obtained from the database, parsing the second row of data, determining a correspondence between the second row of data and variables in the template file, and generating a map structure according to the determined correspondence relationship based on the second row of data The first line of data. It can be understood that the first row of data can be obtained through the second row of data. A map is a data structure stored in the form of a key-value pair. The key value is equivalent to the subscript in the list and the array. The key value can be any type of object, and there can be no duplicate key values in the graph and each The key value must be stored in correspondence with a corresponding value.
在本实施例中,清单下载框架包括3个模板文件,分别为头文件模板,内容头模板和内容体模板。其中,头文件模板用于定义整个文件的样式,比如字段类型、颜色等,类似于CSS(Cascading Style Sheets, 层叠样式表)文件 。内容头模板用于定义sheet页中公共参数,如清单名称、公共参数、列字段定义。内容体模板用于将动态列字段绑定到对应变量。为了区分不同的文件,在本实施例中,清单下载框架的模板文件的格式都是以st结尾的文件,如用head.st表示头文件模板,用body_head.st表示内容头模板,用body_row.st表示内容体模板。In this embodiment, the manifest download framework includes three template files, which are a header file template, a content header template, and a content body template. Among them, the header file template is used to define the style of the entire file, such as field type, color, etc., similar to CSS (Cascading) Style Sheets, Cascading Style Sheets) . The content header template is used to define common parameters in the sheet page, such as list names, public parameters, and column field definitions. The content body template is used to bind dynamic column fields to corresponding variables. In order to distinguish different files, in this embodiment, the format of the template file of the list download frame is a file ending with st. For example, the head file template is represented by head.st, and the content header template is represented by body_head.st, with body_row. St represents the content body template.
进一步地,清单下载框架还可以包括可选模板,用于实现用户的特殊需求,如当要求所生成的文件具备下拉列表、数据校验等功能时,可通过可选模板来实现。Further, the manifest downloading framework may further include an optional template for implementing special requirements of the user, such as when the generated file is required to have a drop-down list, data verification, etc., and may be implemented by an optional template.
步骤S20,根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中。Step S20: Create a preset table according to the configuration information, and write the first row of data into the preset table.
当得到清单下载框架的配置信息时,根据配置信息创建预设表格,并将第一行数据写入所创建的预设表格中。在根据配置信息创建预设表格时,可通过多种方式创建预设表格,根据创建表格方式的不同,将第一行数据写入预设表格中的写入方式不同,如一次可以写入多行的第一行数据,或者一次只写入一行的第一行数据。在本实施例中,预设表格为Excel表格,在其它实施例中,该表格也可为CSV(Comma-Separated Values,逗号分隔值)、TXT格式的表格。When the configuration information of the list download frame is obtained, a preset table is created according to the configuration information, and the first line of data is written into the created preset table. When creating a preset table according to the configuration information, the preset table can be created in various ways, and the writing method of writing the first row of data into the preset table is different according to the manner of creating the table, such as writing more at one time. The first row of data in a row, or the first row of data in a row at a time. In this embodiment, the preset form is an Excel table, and in other embodiments, the form may also be a CSV (Comma-Separated) Values, comma-separated values), a table in TXT format.
进一步地,所述步骤S20包括:Further, the step S20 includes:
步骤f,根据所述配置信息创建Excel表格,并将map结构的第一行数据以流形式写入所述Excel表格中。Step f: Create an Excel table according to the configuration information, and write the first row data of the map structure into the Excel table in a stream form.
进一步地,当获取到清单下载框架的配置信息时,根据所获取的配置信息创建Excel表格,并将map结构的第一行数据以流形式写入Excel表格中。Further, when the configuration information of the list download frame is acquired, an Excel table is created according to the acquired configuration information, and the first row data of the map structure is written into the Excel table in a stream form.
步骤S30,若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。Step S30: If the first row data satisfies the condition of the preset table, generate a file corresponding to the preset table according to the first row data.
当将map结构的第一行数据以流形式写入预设表格后,检测写入预设表格中的第一行数据是否满足预设表格的条件。当第一行数据满足预设表格的条件时,根据第一行数据生成与预设表格对应的文件。当第一行数据不满足预设表格的条件时,则不生成与预设表格对应的文件;或者将第一行数据中不满足预设表格条件的数据删除后,再生成与预设表格对应的文件。After the first row data of the map structure is written to the preset table in a stream form, it is detected whether the first row data written in the preset table satisfies the condition of the preset table. When the first row of data satisfies the condition of the preset table, the file corresponding to the preset table is generated according to the first row of data. When the first row data does not satisfy the condition of the preset table, the file corresponding to the preset table is not generated; or the data in the first row data that does not satisfy the preset table condition is deleted, and then the corresponding table is generated. document.
具体地,检测写入预设表格中的第一行数据是否满足预设表格的条件的过程为:检测写入预设表格的第一行数据的必选参数字段是否为空;以及检测第一行数据对应的列数是否大于配置信息中的最大列数。Specifically, the process of detecting whether the first row of data in the preset table satisfies the condition of the preset table is: detecting whether a mandatory parameter field of the first row of data written in the preset table is empty; and detecting the first Whether the number of columns corresponding to the row data is greater than the maximum number of columns in the configuration information.
当写入预设表格的第一行数据的必选参数字段不为空,且第一行数据对应的列数小于或者等于配置信息中的最大列数时,确定第一行数据满足预设表格的条件;当写入预设表格的第一行数据的必选参数字段为空,和/或第一行数据对应的列数大于配置信息中的最大列数时,确定第一行数据不满足预设表格的条件。可以理解的是,行数据中必选参数根据所生成文件内容的不同而不同。When the required parameter field of the first row of data written in the preset table is not empty, and the number of columns corresponding to the first row of data is less than or equal to the maximum number of columns in the configuration information, it is determined that the first row of data satisfies the preset table. The condition is that when the mandatory parameter field of the first row of data written in the preset table is empty, and/or the number of columns corresponding to the first row of data is greater than the maximum number of columns in the configuration information, it is determined that the first row of data is not satisfied. Preset the conditions of the form. It can be understood that the mandatory parameters in the line data differ according to the content of the generated file.
进一步地,还可检测写入预设表格中的第一行数据对应的各个字段是否为空,以及检测清单下载框架的模板文件是否存在等。Further, it is also possible to detect whether each field corresponding to the first row data in the write preset table is empty, and whether the template file of the list download frame exists or the like.
进一步地,所述步骤S30包括:Further, the step S30 includes:
步骤h,若所述第一行数据满足所述Excel表格的条件,则生成与所述Excel表格对应Excel文件的sheet页头部和内容,并根据所述第一行数据的大小确定是否需要换页,以生成Excel文件。Step h, if the first row of data satisfies the condition of the Excel table, generate a sheet page header and content corresponding to the Excel file, and determine whether it needs to be changed according to the size of the first row of data. Page to generate an Excel file.
进一步地,当将map结构的第一行数据以流形式写入Excel表格后,检测写入Excel表格的第一行数据是否满足Excel表格的条件。若第一行数据满足Excel表格的条件,则生成与Excel表格对应Excel文件的sheet页头部和sheet页内容,并根据第一行数据的大小确定是否需要换页,即根据第一行数据的行数和列数确定是否需要换页。当第一行数据的行数大于一个sheet页的最大行数,和/或第一行数据的列数大于一个sheet页的最大列数时,表明需要换页,则执行换页操作,生成多页的Excel文件;当第一行数据的行数小于或者等于一个sheet页的最大行数,且第一行数据的列数小于或者等于一个sheet页的最大列数时,表明不需要换页,则生成单页的Excel文件。可以理解的是,在本实施例中,Excel文件的格式可为xls或xlsx格式。Further, when the first row data of the map structure is written into the Excel table in a stream form, it is detected whether the first row data written in the Excel table satisfies the condition of the Excel table. If the first line of data satisfies the condition of the Excel table, the sheet page header and the sheet page contents corresponding to the Excel file are generated, and the page size is determined according to the size of the first line of data, that is, according to the first line of data. The number of rows and columns determines if a page break is required. When the number of rows of the first row of data is greater than the maximum number of rows of one sheet page, and/or the number of columns of the first row of data is greater than the maximum number of columns of one sheet page, indicating that a page change is required, a page change operation is performed, generating more The Excel file of the page; when the number of rows of the first row of data is less than or equal to the maximum number of rows of a sheet page, and the number of columns of the first row of data is less than or equal to the maximum number of columns of a sheet page, it indicates that no page change is required. Then generate a single page Excel file. It can be understood that, in this embodiment, the format of the Excel file may be xls or xlsx format.
在本实施例中,由于Excel文件可分页,避免了当行数据的数据过大时,内存溢出的风险。在使用String Template清单下载框架过程中,开发人员只需要修改变量部分的内容,即可生成所需要的文件,减少了开发人员的工作量,也便于开发人员对清单下载框架的维护。In this embodiment, since the Excel file can be paged, the risk of memory overflow when the data of the line data is too large is avoided. Using String In the template list download framework process, the developer only needs to modify the contents of the variable part to generate the required files, which reduces the workload of the developer and facilitates the maintenance of the list download framework by the developer.
本实施例通过当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息,以及生成预设结构的第一行数据;根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。实现了通过预设类型清单下载框架生成对应的文件,该文件可支持xls或xlsx格式,即实现了支持所生成文件多样化。In this embodiment, when the startup command of the service system is detected, the configuration information of the preset type of the download frame is acquired, and the first row of the preset structure is generated; and the preset table is created according to the configuration information, and The first row of data is written into the preset table; if the first row of data satisfies the condition of the preset table, a file corresponding to the preset table is generated according to the first row of data. The corresponding file is generated by the preset type list downloading framework, and the file can support the xls or xlsx format, that is, the file generated by the support is diversified.
进一步地,提出本申请文件生成方法第二实施例。Further, a second embodiment of the present document generating method is proposed.
所述文件生成方法第二实施例与所述文件生成方法第一实施例的区别在于,文件生成方法还包括:The difference between the second embodiment of the file generation method and the first embodiment of the file generation method is that the file generation method further includes:
步骤i,将所述第二行数据存储至Java虚拟机中。In step i, the second row of data is stored in the Java virtual machine.
步骤g,删除所述Java虚拟机所存储的所述第二行数据。Step g, deleting the second row of data stored by the Java virtual machine.
当获取到待配置的第二行数据时,将所获取的第二行数据存储至Java虚拟机中。当根据第一行数据生成与预设表格对应的文件后,删除Java虚拟机中存储的第二行数据。在将第一行数据写入预设表格的过程中,若第一行数据写入错误,或者第一行数据丢失导致写入失败等情况出现时,可重新在Java虚拟机中获取对应的第二行数据,根据该第二行数据重新生成第一行数据,以生成与所需文件。Java虚拟机有自己完善的硬体架构,如处理器、堆栈、寄存器等,还具有相应的指令系统。When the second row of data to be configured is acquired, the acquired second row of data is stored in the Java virtual machine. After the file corresponding to the preset table is generated according to the first row of data, the second row of data stored in the Java virtual machine is deleted. In the process of writing the first row of data into the preset table, if the first row of data is written incorrectly, or the first row of data is lost, the write failure occurs, etc., and the corresponding corresponding number can be obtained in the Java virtual machine. The two rows of data are regenerated according to the second row of data to generate the required file. The Java virtual machine has its own complete hardware architecture, such as processors, stacks, registers, etc., and has a corresponding instruction system.
在本实施例中,通过将从数据库中所获取的原始数据(第二行数据)存储在Java虚拟机,当在生成文件过程中,若与该原始数据有关的数据出现错误时,可重新在Java虚拟机获取该原始数据,而不需要在业务系统数据库中查找该原始数据,提高了文件生成效率。当文件生成成功后,将Java虚拟机所存储的数据删除,节省了Java虚拟机的存储空间,以提高Java虚拟机存储空间的利用率。In this embodiment, by storing the original data (the second row of data) acquired from the database in the Java virtual machine, when the data related to the original data has an error during the process of generating the file, the The Java virtual machine obtains the original data without looking up the original data in the business system database, which improves the file generation efficiency. After the file is successfully generated, the data stored in the Java virtual machine is deleted, which saves the storage space of the Java virtual machine to improve the utilization of the Java virtual machine storage space.
此外,本申请实施例还提出一种文件生成装置,所述文件生成装置包括:In addition, the embodiment of the present application further provides a file generating apparatus, where the file generating apparatus includes:
获取模块,用于当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息;An obtaining module, configured to acquire configuration information of a preset type downloading framework when detecting a startup instruction of the business system;
生成模块,用于生成预设结构的第一行数据;Generating a module for generating a first line of data of the preset structure;
创建模块,用于根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;a creating module, configured to create a preset table according to the configuration information, and write the first row of data into the preset table;
所述生成模块还用于若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。The generating module is further configured to: if the first row of data meets the condition of the preset table, generate a file corresponding to the preset table according to the first row of data.
进一步地,所述生成模块包括:Further, the generating module includes:
获取单元,用于从数据库中获取第二行数据;An obtaining unit, configured to obtain second row data from a database;
确定单元,用于确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系;a determining unit, configured to determine a correspondence between the second row of data and a variable in a template file of the manifest download framework;
生成单元,用于基于所述第二行数据,根据所述对应关系生成map结构的第一行数据。And a generating unit, configured to generate first row data of the map structure according to the correspondence relationship based on the second row data.
进一步地,所述创建单元还用于根据所述配置信息创建Excel表格,并将map结构的第一行数据以流形式写入所述Excel表格中;Further, the creating unit is further configured to create an Excel table according to the configuration information, and write the first row data of the map structure into the Excel table in a stream form;
所述生成模块还用于若所述行数据满足所述Excel表格的条件,则生成与所述Excel表格对应Excel文件的sheet页头部和内容,并根据所述第一行数据的大小确定是否需要换页,以生成Excel文件。The generating module is further configured to: if the row data satisfies the condition of the Excel table, generate a sheet page header and content corresponding to the Excel file, and determine whether the data according to the size of the first row is Need to change pages to generate an Excel file.
进一步地,所述清单下载框架对应的模板文件包括头文件模板、内容头模板和内容体模板。Further, the template file corresponding to the manifest download framework includes a header file template, a content header template, and a content body template.
进一步地,所述获取模块包括:Further, the obtaining module includes:
加载单元,用于当侦测到业务系统的启动指令时,加载所述清单下载框架的JAR包;a loading unit, configured to load a JAR package of the list download framework when detecting a startup instruction of the business system;
获取单元,用于若所述JAR包加载成功,则在所述JAR包中获取所述清单下载框架的配置信息。And an obtaining unit, configured to acquire configuration information of the manifest download framework in the JAR package if the JAR package is successfully loaded.
进一步地,所述文件生成装置还包括:Further, the file generating apparatus further includes:
检测模块,用于检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。a detecting module, configured to detect whether a mandatory parameter field of the first row of data written in the preset table is empty, and detecting whether a number of columns corresponding to the first row of data is greater than a maximum of the configuration information The number of columns.
本申请文件生成装置具体实施方式与上述文件生成方法各实施例基本相同,在此不再赘述。The specific implementation of the file generating apparatus of the present application is substantially the same as the embodiment of the foregoing file generating method, and details are not described herein again.
此外,本申请实施例还提出一种计算机可读存储介质,所述计算机可读存储介质上存储有文件生成程序,所述文件生成程序被处理器执行时实现如下步骤:In addition, the embodiment of the present application further provides a computer readable storage medium, where the file readable storage medium is stored, and when the file generating program is executed by the processor, the following steps are implemented:
当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息,以及生成预设结构的第一行数据;When the startup command of the service system is detected, acquiring configuration information of the preset type download framework and generating the first row of data of the preset structure;
根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;Forming a preset table according to the configuration information, and writing the first row of data into the preset table;
若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。And if the first row data satisfies the condition of the preset table, generating a file corresponding to the preset table according to the first row data.
进一步地,所述生成预设结构的第一行数据的步骤包括:Further, the step of generating the first row of data of the preset structure includes:
从数据库中获取第二行数据;Get the second row of data from the database;
确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系;Determining a correspondence between the second row of data and a variable in a template file of the manifest download framework;
基于所述第二行数据,根据所述对应关系生成map结构的第一行数据。Based on the second row of data, the first row of data of the map structure is generated according to the correspondence.
进一步地,所述根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中的步骤包括:Further, the step of creating a preset table according to the configuration information, and writing the first row of data into the preset table includes:
根据所述配置信息创建Excel表格,并将map结构的第一行数据以流形式写入所述Excel表格中;Creating an Excel table according to the configuration information, and writing the first row data of the map structure into the Excel table in a stream form;
所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤包括:If the first row of data meets the condition of the preset table, the step of generating a file corresponding to the preset table according to the first row of data includes:
若所述行数据满足所述Excel表格的条件,则生成与所述Excel表格对应Excel文件的sheet页头部和内容,并根据所述第一行数据的大小确定是否需要换页,以生成Excel文件。If the row data satisfies the condition of the Excel table, generating a sheet page header and content corresponding to the Excel file, and determining whether a page change is required according to the size of the first row data to generate an Excel file.
进一步地,所述确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系的步骤之前,所述文件生成程序被处理器执行时实现如下步骤:Further, before the step of determining the correspondence between the second row data and the variables in the template file of the manifest download frame, the file generating program is executed by the processor to implement the following steps:
将所述第二行数据存储至Java虚拟机中;The second row of data is stored in a Java virtual machine;
所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之后,所述文件生成程序被处理器执行时实现如下步骤:If the first line of data satisfies the condition of the preset table, after the step of generating a file corresponding to the preset table according to the first line of data, when the file generating program is executed by the processor Implement the following steps:
删除所述Java虚拟机所存储的所述第二行数据。Deleting the second row of data stored by the Java virtual machine.
进一步地,所述清单下载框架对应的模板文件包括头文件模板、内容头模板和内容体模板。Further, the template file corresponding to the manifest download framework includes a header file template, a content header template, and a content body template.
进一步地,所述当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息的步骤包括:Further, when the startup command of the service system is detected, the step of acquiring configuration information of the preset type of download framework includes:
当侦测到业务系统的启动指令时,加载所述清单下载框架的JAR包;Loading a JAR package of the manifest download framework when a startup command of the business system is detected;
若所述JAR包加载成功,则在所述JAR包中获取所述清单下载框架的配置信息。If the JAR package is successfully loaded, the configuration information of the manifest download framework is obtained in the JAR package.
进一步地,所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之前,所述文件生成程序被处理器执行时实现如下步骤:Further, if the first row of data satisfies the condition of the preset table, the file generating program is processed before the step of generating a file corresponding to the preset table according to the first row of data The following steps are implemented when the device is executed:
检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;Detecting whether a mandatory parameter field of the first row of data written in the preset table is empty;
以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。And detecting whether the number of columns corresponding to the first row of data is greater than a maximum number of columns in the configuration information.
本申请计算机可读存储介质具体实施方式与上述文件生成方法各实施例基本相同,在此不再赘述。The specific embodiment of the computer readable storage medium of the present application is substantially the same as the embodiment of the foregoing file generating method, and details are not described herein again.
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。It is to be understood that the term "comprises", "comprising", or any other variants thereof, is intended to encompass a non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes those elements. It also includes other elements that are not explicitly listed, or elements that are inherent to such a process, method, article, or device. An element that is defined by the phrase "comprising a ..." does not exclude the presence of additional equivalent elements in the process, method, item, or device that comprises the element.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments of the present application are merely for the description, and do not represent the advantages and disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the foregoing embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be through hardware, but in many cases, the former is better. Implementation. Based on such understanding, the technical solution of the present application, which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk, The optical disc includes a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present application.
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above is only a preferred embodiment of the present application, and is not intended to limit the scope of the patent application, and the equivalent structure or equivalent process transformations made by the specification and the drawings of the present application, or directly or indirectly applied to other related technical fields. The same is included in the scope of patent protection of this application.

Claims (20)

  1. 一种文件生成方法,其特征在于,所述文件生成方法包括以下步骤: A file generating method, characterized in that the file generating method comprises the following steps:
    当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息,以及生成预设结构的第一行数据;When the startup command of the service system is detected, acquiring configuration information of the preset type download framework and generating the first row of data of the preset structure;
    根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;Forming a preset table according to the configuration information, and writing the first row of data into the preset table;
    若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。And if the first row data satisfies the condition of the preset table, generating a file corresponding to the preset table according to the first row data.
  2. 如权利要求1所述的文件生成方法,其特征在于,所述生成预设结构的第一行数据的步骤包括:The file generating method according to claim 1, wherein the step of generating the first row of data of the preset structure comprises:
    从数据库中获取第二行数据;Get the second row of data from the database;
    确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系;Determining a correspondence between the second row of data and a variable in a template file of the manifest download framework;
    基于所述第二行数据,根据所述对应关系生成map结构的第一行数据。Based on the second row of data, the first row of data of the map structure is generated according to the correspondence.
  3. 如权利要求2所述的文件生成方法,其特征在于,所述根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中的步骤包括:The file generating method according to claim 2, wherein the step of creating a preset table according to the configuration information and writing the first row of data into the preset table comprises:
    根据所述配置信息创建Excel表格,并将map结构的第一行数据以流形式写入所述Excel表格中;Creating an Excel table according to the configuration information, and writing the first row data of the map structure into the Excel table in a stream form;
    所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤包括:If the first row of data meets the condition of the preset table, the step of generating a file corresponding to the preset table according to the first row of data includes:
    若所述行数据满足所述Excel表格的条件,则生成与所述Excel表格对应Excel文件的sheet页头部和内容,并根据所述第一行数据的大小确定是否需要换页,以生成Excel文件。If the row data satisfies the condition of the Excel table, generating a sheet page header and content corresponding to the Excel file, and determining whether a page change is required according to the size of the first row data to generate an Excel file.
  4. 如权利要求2所述的文件生成方法,其特征在于,所述确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系的步骤之前,还包括:The method for generating a file according to claim 2, wherein the step of determining the correspondence between the second row of data and the variable in the template file of the list download frame further comprises:
    将所述第二行数据存储至Java虚拟机中;The second row of data is stored in a Java virtual machine;
    所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之后,还包括:After the step of generating the file corresponding to the preset table according to the first row of data, if the first row of data meets the condition of the preset table, the method further includes:
    删除所述Java虚拟机所存储的所述第二行数据。Deleting the second row of data stored by the Java virtual machine.
  5. 如权利要求2所述的文件生成方法,其特征在于,所述清单下载框架对应的模板文件包括头文件模板、内容头模板和内容体模板。The file generating method according to claim 2, wherein the template file corresponding to the list downloading frame comprises a header file template, a content header template, and a content body template.
  6. 如权利要求1所述的文件生成方法,其特征在于,所述当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息的步骤包括:The file generating method according to claim 1, wherein the step of acquiring the configuration information of the preset type of the download frame of the list when the startup command of the service system is detected includes:
    当侦测到业务系统的启动指令时,加载所述清单下载框架的JAR包;Loading a JAR package of the manifest download framework when a startup command of the business system is detected;
    若所述JAR包加载成功,则在所述JAR包中获取所述清单下载框架的配置信息。If the JAR package is successfully loaded, the configuration information of the manifest download framework is obtained in the JAR package.
  7. 如权利要求1所述的文件生成方法,其特征在于,所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之前,还包括:The file generating method according to claim 1, wherein if the first row of data satisfies a condition of the preset table, generating, corresponding to the preset table, according to the first row of data Before the steps of the file, it also includes:
    检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;Detecting whether a mandatory parameter field of the first row of data written in the preset table is empty;
    以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。And detecting whether the number of columns corresponding to the first row of data is greater than a maximum number of columns in the configuration information.
  8. 如权利要求2所述的文件生成方法,其特征在于,所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之前,还包括:The file generating method according to claim 2, wherein if the first row of data satisfies the condition of the preset table, generating, corresponding to the preset table, according to the first row of data Before the steps of the file, it also includes:
    检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;Detecting whether a mandatory parameter field of the first row of data written in the preset table is empty;
    以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。And detecting whether the number of columns corresponding to the first row of data is greater than a maximum number of columns in the configuration information.
  9. 如权利要求3所述的文件生成方法,其特征在于,所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之前,还包括:The file generating method according to claim 3, wherein if the first row of data satisfies the condition of the preset table, generating, corresponding to the preset table, according to the first row of data Before the steps of the file, it also includes:
    检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;Detecting whether a mandatory parameter field of the first row of data written in the preset table is empty;
    以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。And detecting whether the number of columns corresponding to the first row of data is greater than a maximum number of columns in the configuration information.
  10. 如权利要求4所述的文件生成方法,其特征在于,所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之前,还包括:The file generating method according to claim 4, wherein if the first row of data satisfies the condition of the preset table, generating, corresponding to the preset table, according to the first row of data Before the steps of the file, it also includes:
    检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;Detecting whether a mandatory parameter field of the first row of data written in the preset table is empty;
    以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。And detecting whether the number of columns corresponding to the first row of data is greater than a maximum number of columns in the configuration information.
  11. 如权利要求5所述的文件生成方法,其特征在于,所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之前,还包括:The file generating method according to claim 5, wherein if the first row of data satisfies the condition of the preset table, generating, corresponding to the preset table, according to the first row of data Before the steps of the file, it also includes:
    检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;Detecting whether a mandatory parameter field of the first row of data written in the preset table is empty;
    以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。And detecting whether the number of columns corresponding to the first row of data is greater than a maximum number of columns in the configuration information.
  12. 如权利要求6所述的文件生成方法,其特征在于,所述若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件的步骤之前,还包括:The file generating method according to claim 6, wherein if the first row of data satisfies the condition of the preset table, generating, corresponding to the preset table, according to the first row of data Before the steps of the file, it also includes:
    检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;Detecting whether a mandatory parameter field of the first row of data written in the preset table is empty;
    以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。And detecting whether the number of columns corresponding to the first row of data is greater than a maximum number of columns in the configuration information.
  13. 一种文件生成装置,其特征在于,所述文件生成装置包括:A file generating apparatus, wherein the file generating apparatus comprises:
    获取模块,用于当侦测到业务系统的启动指令时,获取预设类型的清单下载框架的配置信息;An obtaining module, configured to acquire configuration information of a preset type downloading framework when detecting a startup instruction of the business system;
    生成模块,用于生成预设结构的第一行数据;Generating a module for generating a first line of data of the preset structure;
    创建模块,用于根据所述配置信息创建预设表格,并将所述第一行数据写入所述预设表格中;a creating module, configured to create a preset table according to the configuration information, and write the first row of data into the preset table;
    所述生成模块还用于若所述第一行数据满足所述预设表格的条件,则根据所述第一行数据生成与所述预设表格对应的文件。The generating module is further configured to: if the first row of data meets the condition of the preset table, generate a file corresponding to the preset table according to the first row of data.
  14. 如权利要求13所述的文件生成装置,其特征在于,所述生成模块包括:The file generating apparatus according to claim 13, wherein said generating module comprises:
    获取单元,用于从数据库中获取第二行数据;An obtaining unit, configured to obtain second row data from a database;
    确定单元,用于确定所述第二行数据与所述清单下载框架的模板文件中变量的对应关系;a determining unit, configured to determine a correspondence between the second row of data and a variable in a template file of the manifest download framework;
    生成单元,用于基于所述第二行数据,根据所述对应关系生成map结构的第一行数据。And a generating unit, configured to generate first row data of the map structure according to the correspondence relationship based on the second row data.
  15. 如权利要求14所述的文件生成装置,其特征在于,所述创建单元还用于根据所述配置信息创建Excel表格,并将map结构的第一行数据以流形式写入所述Excel表格中;The file generating apparatus according to claim 14, wherein the creating unit is further configured to create an Excel table according to the configuration information, and write the first row data of the map structure into the Excel table in a stream form. ;
    所述生成模块还用于若所述行数据满足所述Excel表格的条件,则生成与所述Excel表格对应Excel文件的sheet页头部和内容,并根据所述第一行数据的大小确定是否需要换页,以生成Excel文件。The generating module is further configured to: if the row data satisfies the condition of the Excel table, generate a sheet page header and content corresponding to the Excel file, and determine whether the data according to the size of the first row is Need to change pages to generate an Excel file.
  16. 如权利要求14所述的文件生成装置,其特征在于,所述清单下载框架对应的模板文件包括头文件模板、内容头模板和内容体模板。The file generating apparatus according to claim 14, wherein the template file corresponding to the list downloading frame comprises a header file template, a content header template, and a content body template.
  17. 如权利要求13所述的文件生成装置,其特征在于,所述获取模块包括:The file generating apparatus according to claim 13, wherein the obtaining module comprises:
    加载单元,用于当侦测到业务系统的启动指令时,加载所述清单下载框架的JAR包;a loading unit, configured to load a JAR package of the list download framework when detecting a startup instruction of the business system;
    获取单元,用于若所述JAR包加载成功,则在所述JAR包中获取所述清单下载框架的配置信息。And an obtaining unit, configured to acquire configuration information of the manifest download framework in the JAR package if the JAR package is successfully loaded.
  18. 如权利要求13所述的文件生成装置,其特征在于,所述文件生成装置还包括:The file generating apparatus according to claim 13, wherein the file generating apparatus further comprises:
    检测模块,用于检测写入所述预设表格的所述第一行数据的必选参数字段是否为空;以及检测所述第一行数据对应的列数是否大于所述配置信息中的最大列数。a detecting module, configured to detect whether a mandatory parameter field of the first row of data written in the preset table is empty, and detecting whether a number of columns corresponding to the first row of data is greater than a maximum of the configuration information The number of columns.
  19. 一种文件生成设备,其特征在于,所述文件生成设备包括存储器、处理器和存储在所述存储器上并可在所述处理器上运行的文件生成程序,所述文件生成程序被所述处理器执行时实现如权利要求1所述的文件生成方法的步骤。A file generating device, comprising: a memory, a processor, and a file generating program stored on the memory and executable on the processor, the file generating program being processed The steps of the file generating method of claim 1 are implemented when executed.
  20. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有文件生成程序,所述文件生成程序被处理器执行时实现如权利要求1所述的文件生成方法的步骤。A computer readable storage medium, characterized in that the computer readable storage medium stores a file generation program, and the file generation program is executed by a processor to implement the steps of the file generation method according to claim 1.
PCT/CN2017/112009 2017-05-05 2017-11-21 Method, device and equipment for generating a file and computer readable storage medium WO2018201697A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710319543.3A CN107688456B (en) 2017-05-05 2017-05-05 File generation method, device and computer readable storage medium
CN201710319543.3 2017-05-05

Publications (1)

Publication Number Publication Date
WO2018201697A1 true WO2018201697A1 (en) 2018-11-08

Family

ID=61152394

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/112009 WO2018201697A1 (en) 2017-05-05 2017-11-21 Method, device and equipment for generating a file and computer readable storage medium

Country Status (2)

Country Link
CN (1) CN107688456B (en)
WO (1) WO2018201697A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110019970A (en) * 2018-06-15 2019-07-16 中国平安人寿保险股份有限公司 Inventory downloads template creation method, device, terminal and readable storage medium storing program for executing
CN111046643A (en) * 2019-11-23 2020-04-21 方正株式(武汉)科技开发有限公司 System and method for generating excel form by rapid customization, server and medium
CN112632165A (en) * 2020-12-22 2021-04-09 平安普惠企业管理有限公司 Page form export EXCEL method and device, computer equipment and storage medium
CN113312133B (en) * 2021-06-17 2022-06-24 浙江齐安信息科技有限公司 Operation method, system and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060095833A1 (en) * 2000-11-22 2006-05-04 Orchard Andrew C Method and apparatus for automatically producing spreadsheet-based models
CN103020089A (en) * 2011-09-27 2013-04-03 深圳市金蝶友商电子商务服务有限公司 Method and device for importing data in EXCEL file to database
CN103150298A (en) * 2013-03-13 2013-06-12 河海大学 Customizable complicated form generation method for river basin water diversion business based on Web
CN103744982A (en) * 2014-01-15 2014-04-23 北京神州普惠科技股份有限公司 Method for importing Excel data into database

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20070055696A (en) * 2005-11-28 2007-05-31 엘지노텔 주식회사 Initial data management apparatus and method in the element management system
CN101661460B (en) * 2009-09-18 2014-09-03 上海宝信软件股份有限公司 Method and device for generating management system report
CN103020162B (en) * 2012-11-26 2015-11-04 中国电力科学研究院 CC2000 model conversion imports the method for D5000 system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060095833A1 (en) * 2000-11-22 2006-05-04 Orchard Andrew C Method and apparatus for automatically producing spreadsheet-based models
CN103020089A (en) * 2011-09-27 2013-04-03 深圳市金蝶友商电子商务服务有限公司 Method and device for importing data in EXCEL file to database
CN103150298A (en) * 2013-03-13 2013-06-12 河海大学 Customizable complicated form generation method for river basin water diversion business based on Web
CN103744982A (en) * 2014-01-15 2014-04-23 北京神州普惠科技股份有限公司 Method for importing Excel data into database

Also Published As

Publication number Publication date
CN107688456B (en) 2020-04-10
CN107688456A (en) 2018-02-13

Similar Documents

Publication Publication Date Title
WO2019019378A1 (en) Service processing method and apparatus, adapter and computer-readable storage medium
WO2018201697A1 (en) Method, device and equipment for generating a file and computer readable storage medium
WO2015035777A1 (en) Software upgrade method and system for mobile terminal
WO2018120457A1 (en) Data processing method, apparatus, device, and computer readable storage medium
WO2019019374A1 (en) Method, apparatus, and system for controlling household appliance with intelligent voice device
WO2019019493A1 (en) Data sharing method and device, and computer readable storage medium
WO2019114262A1 (en) User interface loading method, smart television and computer-readable storage medium
WO2018120429A1 (en) Resource update method, terminal, computer readable storage medium and resource update device
WO2019080249A1 (en) Alarm processing method and apparatus, computer device, and storage medium
WO2015127859A1 (en) Sensitive text detecting method and apparatus
WO2019019376A1 (en) Service process management method, apparatus, and device, and computer readable storage medium
WO2018233367A1 (en) Case registration method and apparatus, terminal, and computer readable storage medium
WO2019061612A1 (en) Loan product promotion method and apparatus, and computer-readable storage medium
WO2018058919A1 (en) Identification information generating method, apparatus, device, and computer readable storage medium
WO2019019340A1 (en) Application program page opening method and apparatus, terminal and readable storage medium
WO2018227887A1 (en) Video advertisement delivery method, video advertisement generation method, device, server and readable storage medium
WO2019024336A1 (en) Data query method and device, and computer readable storage medium
WO2019000800A1 (en) Credential preparation method, apparatus, and device and computer readable storage medium
WO2015161778A1 (en) Webpage generating method and apparatus
WO2019037395A1 (en) Key management method, device and readable storage medium
WO2019019351A1 (en) User behaviour data processing method and apparatus, and computer readable storage medium
WO2018018827A1 (en) Data storage control method and data server
WO2018166236A1 (en) Claim settlement bill recognition method, apparatus and device, and computer-readable storage medium
WO2018166107A1 (en) Hybrid-based compatibility method, adapter, operating apparatus and system, and computer-readable storage medium
WO2017032122A1 (en) Method and apparatus for detecting digital television set

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17908544

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 18/02/2020)

122 Ep: pct application non-entry in european phase

Ref document number: 17908544

Country of ref document: EP

Kind code of ref document: A1