AJ-Report Beginners (Introductory Tutorial)

Hits: 0

Article directory

foreword

This AJ-Reprot needs to be used in the project to generate dynamic large-screen reports. I have also studied it in the past two days. I think it is a very good open source project, so I organize it for sharing.

Not much to say, beginners understand beginners best

Introduction

Online experience: https://report.anji-plus.com/index.html

Experience account:guest

password:guest

The official documentation says this:

  • AJ-Report is a completely open-source BI platform with cool big-screen display, which can control business dynamics anytime and anywhere, so that every decision is supported by data.
  • Multi-data source support, built-in mysql, elasticsearch, kudu and other drivers, support for custom data sets to save data interface development, currently supports 20 kinds of large-screen components/charts, no development, according to the design draft can also make large Screen.
  • Three steps to easily complete the large screen design: configure the data source —-> write SQL to configure the data set —-> drag and drop to configure the large screen —-> save and publish.

According to my explanation, you can use this open source project, configure data on it, write SQL (data set), and then you can directly design reports, dynamically preview reports, and support exporting.

Above, I will directly copy what is introduced in the official document. I also provide the document address below. It is recommended to look at the official document first. It is already very detailed~~

Official website and [source code] download address

gitee download: https://gitee.com/anji-plus/report/releases

Official document: http://192.168.98.2:14000/

Preparation

1. Download

According to the abovegitee downloadLink to download and it’s done

  1. aj-report-xxxx.zipThis is the release version, after the windows download, change the configuration to directly run the .bat file to start
  2. Source code (zip)Download this if you want to see the source code or start it under Windows
  3. Source code (tar.gz)Download this if you want to run it directly under linux

I won’t do a demonstration on linux, I’ll just download the first two and play

Unzip after downloading the distribution and source code

2. Database preparation

First of all, you must have a database, right? If you don’t have a database, I will also provide a local mysql data for everyone to learn (congratulations if you have, you can skip this step)

Link: Baidu network disk address
Extraction code: 5lxo

This installation step will not go into details, it is basically a fool-like installation

Distribution configuration and startup

If you are a developer, it doesn’t matter whether you can start the distribution or not. Anyway, you have to use the source code for learning. It will allow you to understand AJ-Report better and faster. Why do I add this here, because some Workers of big data may not need to look at the source code, play with this distribution and get familiar with it.

Double click to enter this directory

1. Modify [bootstrap] .yml

First of all, you need to go to the configuration file directory confto modify bootstrap.ymlthe configuration of the file (it is recommended to look at the configuration file by yourself, many of the configurations of the developers are conscientiously commented)

The place to be modified here is the configuration of the database, change it to your own, save it

  • The aj_report library is a library that stores the underlying basic information. It will be automatically created when flyway is started. If you modify the library here, an error will occur.
  • Please confirm whether your Mysql supports remote connection and whether the login user has DDL authority

2. Modify start.bat

Then modify the start.bat in the bindirectory and open the editor in the form of text

Delete this rem comment and add your own jdk configuration

How to check the configuration of JDK?

This PC -> Right mouse button select “Properties” -> Advanced System Settings -> Advanced – Environment Variables -> System Variables – java_home

So here I am
changing it rem set JAVA_HOME=D:\App\Java\jdk1.8.0_172
toset JAVA_HOME=C:\Program Files\Java\jdk1.8.0_172

3. Launch and Access

Double- binclick the start.batfile in the directory to start directly

And you can see that after startup, and two databases aj_reportwill be added directly to your databaseaj_report_init

After startup, you can directly access it locally. As for the functions here, you can understand it with a little more. The release version will not explain it in detail~~

Address: http://localhost:9095

Account: admin
Password:123456

Source configuration and startup

1. IDEA import project

After importing it looks like this

where report-coreis the back-end code and report-uiis the front-end code

2. Backend startup

This project is built with springboot, so you can directly run the startup class, but the premise is that you need to configure the bootstrap.ymlfile

You can change the database of these three bootstrap files to the database you use

For example, my local database is changed like this:

datasource:
    url: jdbc:mysql://localhost:3306/aj_report?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false
    username: root
    password: root

Run the startup class:

Started successfully:

And you can see that after startup, and two databases aj_reportwill be added directly to your databaseaj_report_init

2. Front-end startup

The front-end enablement needs to be used node. If you haven’t downloaded node, I also provide the node I’m currently using, and the installation is also a fool-like installation, so I won’t go into details.

Link: Baidu network disk address
Extraction code: knw5

Front-end startup, whether you use webstorm, visual studio code or other front-end tools, it’s almost the same, I’m not so troublesome here, and I also use IDEA to start.

click belowTerminal

Enter the following three commands in turn:
cd report-ui: The first entry should be under report-Vxxx, cd into report-ui
npm install: Install the dependencies required by the
npm run devfront-end: run the front-end

Seeing this means that your front end has also been successfully started.

Access address: http://localhost:9528

Account: admin
Password:123456

The pit I stepped on

The above installation and startup are all routine. Generally, it can be done by looking at the official documents. The key is the problems encountered after use, but there are no official documents. The following I will sort out the problems I encountered when using and the way it is handled.

1. Driver problems other than mysql

In report design, we can configure different data sources

Different data sources have different driver classes. For example, the driver class of mysql is the driver class of com.mysql.cj.jdbc.Drivermssqlserver . There are no dependencies of some driver classes com.microsoft.sqlserver.jdbc.SQLServerDriverin the back-end .pomfiles . We need to add them ourselves, or run the data in the data. sql will report an error, for example, I have a database type of mssqlserver

I will add a new dataset here, using the mssqlserver database

<!-- The driver class corresponding to mssqlserver--> 
        < dependency > 
            < groupId > com.microsoft.sqlserver </ groupId > 
            < artifactId > mssql-jdbc </ artifactId > 
            < version > 8.2.2.jre8 </ version > 
        < / dependency >

maven, restart the project.

2. Request timeout problem

[3. Null pointer exception] caused by null value[]

The back end is:java.lang.NullPointerException: null

The code is as follows (example):

// If fieldLabel is null , set it to " " 
if (fieldLabel== null ) {
    fieldLabel = " ";
}
String replace = v.replace("#{".concat(dataSet.getSetCode()).concat(".").concat(dataSet.getFieldLabel()).concat("}"), fieldLabel);

Restart the backend to solve it.

4. The table field length is not enough

This is also a relatively common problem. The solution is very simple, just find the corresponding table expansion field.

5. Failed to export file

This is the reason why you use the export function without configuring the path, change the path you have on your computer

Summarize

The above is what I learned from learning AJ-Ropert in the past two days and the problems I solved.

You may also like...

Leave a Reply

Your email address will not be published.