Open source a set of original text processing tools: java + bat script to realize automatic batch processing of statement tools

Original / Zhu Jiqian

This tool was developed by the author in early 2018. After two years, I accidentally thought of this gadget, so I decided to open source it. If someone needs to make a tool similar to Java batch processing to sort out documents, you can refer to the logical idea of the tool.

The tool runs on the windos system and runs in the form of bat script and jar package. At that time, the background of developing the tool is that it needs to regularly process a large number of statement TXT text information and integrate it into an excel document for accountants to obtain. Before the tool, the accountants in the project team need to manually open a large number of TXT text every day, copy the required information from each TXT document, and then copy the obtained information into an excel document of the current day. This process takes nearly an hour, and the operation is repeated. For this reason, this gadget was developed at that time for accountants to use. The effect is that it saves a lot of sorting time: Accountants only need to put the statement TXT received by mail every day under the specified directory, click start to start the script, and then they can complete the batch processing automatically with one click.

This tool was effective in the working environment at that time, but it needs secondary development and modification if it is changed to another field or environment. The logic of the overall implementation of the tool is not complex. The author only provides a small idea to solve the repeated work of documents for reference and learning. After all, the essence of solving problems lies not in tools, but in ideas.

Next, we will conclude the automatic processing tool around the business and specific implementation.

The overall structure is as follows:

@L_ 404_ 0@

1. Statement: batch put statements of the same type into the statement folder. They are similar, that is, the format is almost the same, but the data is different, as shown below:

2. Statement set processing result: the data obtained by batch processing will be uniformly written into an automatically generated excel document, which is stored under the "statement set processing result" directory;

3.Auto. Jar: a jar package developed by the Java language, which reads the TXT text data through a loop, intercepts its name, corresponding deposit and available funds from the data in the specified field of the read text, and then writes it into the automatically generated excel document.

4.CopyName. Bat: bat script to batch write the txt file name in this directory to "statement batch name set. TXT";

CopyName. Bat is as follows:

5.Start. Bat: bat script. The main implementation is to copy copyname Bat and "statement batch name collection. TXT" are copied to the "statement" directory, and then copyname. TXT is executed Bat, and all the files under the directory will be saved Txt suffix, write it to "statement batch name collection. TXT", and then start auto Jar package. The jar will go to the "statement batch name collection. TXT" to obtain the names of TXT documents in the directory, and then read the corresponding TXT documents according to these names.

Start. The main codes of bat are as follows:

To sum up, business personnel only need to put the statements into the "statement" directory:

Click start Bat is started, and the following specified data can be obtained uniformly:

Next, let's share the logical implementation of Java:

Code structure

Maven is used for jar dependency, mainly including data, exportexcelbase, exportexcelclient and putexcel.

1. Introduce dependency

2. Set the export basic class and set it according to the excel display data to be generated. In the author's case, only three fields of "combination name", "deposit occupied amount" and "available funds" need to be displayed, so only name, margin and avafunds need to be set to accept the obtained values;

3. Set excel table generation class

4. Set excel export class based on data

5. Batch read TXT text and intercept the specified data class

Most of the above codes were written around 2018. Now read them again. The code style is very immature. I didn't make major changes because I wanted to keep the original appearance of these codes, just like keeping the memory of the meeting just after graduation. The overall implementation logic is not complicated, but the simplest things that can solve problems are worth sharing. On this basis, it can be further improved and expanded to bring convenience to business personnel who need it.

This is my first open source gadget. I take this as an incentive to learn more deeply in the future, and share what I have learned and gained. In my opinion, what you input is not necessarily your own, but what you output must be your own.

This is one of the reasons why I like output.

Finally, attach the first GitHub source code link: https://github.com/z924931408/auto-put-tool

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>