When software companies to develop projects, reporting has become an indispensable part. The ever-changing needs of customers reporting, research and development out of something customers are not satisfied, the secondary development or completely rewritten common occurrences. Reports section features complex, coupled with complex business logic, needs a little bit of change, we need to spend more time to adjust and improve, high development costs, it is difficult to maintain when personnel changes. Can not quickly adjust reporting capabilities, the entire development cycle becomes longer, severe cases can lead to delayed project delivery. Select can be dynamically adjusted, rapid formation of reporting tools demand reports can solve the fastest project reporting.
Fan Ying reporting tools can quickly create, generate reports, and can be a whole package, the whole project as a module, the internal project code calls using modular integration project, the project can also be integrated as a separate report system services.
When reporting system as a separate service, divided into surplus sail design and reporting tools to show the two parts, the design part is a separate line design, integrated depending on whether the actual needs of the designer. Designer is responsible for designing reports, designed template then show through the background distribution. The main show is to obtain an integrated part of the contents of the report show, and then integrated display.
Ying Fan reports as a separate system service, provides the following methods of integration:
A single sign-on
Skip through http request login screen, the login user to the corresponding interface display. DETAILED requests as follows: http: // IP: 8099 / EFReport / loginWithoutPage account = demo & password = 123?
Second, get the user to integrate SessionId
Get the user's SessionID, then use SessionId to get a good distribution of the report show page for the final presentation interface for project integration.
1. Get sessionid, the code are the following:
public String getAuth() throws Exception {
String sessionid = null;
1 // Create HttpClient
CloseableHttpClient client = HttpClients.createDefault();
// 2, package request parameters
List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>(2);
// "demo" is the actual user name
list.add(new BasicNameValuePair("command", "demo"));
// symmetric encryption, "123" is the account "demo" of the actual password, "123456789ABCDEFG" symmetric encryption KEY value. KEY value "123456789ABCDEFG" must be 16-bit, this needs to be consistent with the KEY webapps \ ROOT \ WEB-INF \ classes \ application.properties documents in the AES.KEY
list.add(new BasicNameValuePair("certificate", AES.encrypt("123", "123456789ABCDEFG")));
// 3, the conversion parameters
UrlEncodedFormEntity refe = new UrlEncodedFormEntity(list, "UTF-8");
4 // Create HttpPost
HttpPost post = new HttpPost("http:// IP:8099/EFReport/authentication");
post.setHeader("Accept", "text/plain;charset=UTF-8");
// 5, set the parameters
post.setEntity(refe);
// 6, execution request
CloseableHttpResponse resp = client.execute(post);
// 7, get physical
HttpEntity entity = resp.getEntity();
// 8, get back into the Entity Data
String result = EntityUtils.toString(entity, "UTF-8");
if ("OK".equals(result)) {
Header[] headers = resp.getHeaders("Set-Cookie");
String str = headers[0].getValue();
sessionid = str.substring(0, str.indexOf(";"));
}
// 9, closed
resp.close();
return sessionid;
}
2. sessionid acquired to obtain the current user can preview the report name.
// Get the first step sessionid
String global_session_id = getAuth();
Request following address: "http: // IP: 8099 / EFReport / r_menu; <% = global_session_id%>", returns JSON-formatted data.
The following figure shows the manner described above, the interface returns the data, the user reports menu tree JSON format.
3. By acquiring the sessionid, template name, parameters, gets the current user can preview the contents of the report. Request following address:
"http:// IP:8099/EFReport/r_report;<%=global_session_id%>?file=<%=URLEncoder.encode("日期参数",
"UTF-8")%>¶ms="
Template with the actual request parameters as follows:
"http:// IP:8099/EFReport/r_report;<%=global_session_id%>?file=<%=URLEncoder.encode("日期参数",
"UTF-8")%>¶ms=<%=URLEncoder.encode("param1=2016-1-10;param2=2018-05-01",
"UTF-8")%>"
The following figure shows by way of a request with parameters, return interface.
Third, skip directly integrated permission
Reporting Services to obtain the public key, access token by the algorithm, and then get the current user can preview the report obtained by the token, the template name, parameters.
1. Obtain the public key
Request at the following address: "http: // IP: 8099 / EFReport / thirdSys / getPublic"
2. Get token
Get the current computer time and GMT time, using the RSA algorithm, the token.
public String getToken() throws Exception {
// Get the current number of milliseconds
String data = String.valueOf(System.currentTimeMillis());
// and public key token by using the RSA algorithm to obtain the time, the red part of the public for access
String encryptData = RsaUtils.encrypt(data,RsaUtils.getPublicKey("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDmVtO9QRTBBVUzDzhtSU9aVjv46dlQUiMGZRt9uz0h/T1Ty6X2nF1on0EG7fUgg3yU+XepD/AQlZFzLtpuI7TPhA67CoecmhRhCdUHN4u6FOGhQjyNl9PPL1gYF4YwW94BX5HPKg1nOdpmkkB/pdJ5cpobjYD0R0xgelmG1nkRWQIDAQAB"));
return encryptData;
}
3. Get the regional reports
By token acquired template name, parameter acquisition reports the current user can preview.
The actual http request as follows:
http:// IP:8099/EFReport/report/checkSheet?file=<%=URLEncoder.encode("日期参数","UTF-8")%>¶ms=&token=<%=getToken()%>
Template with the actual request parameters as follows:
http:// IP:8099/EFReport/report/checkSheet?file=<%=URLEncoder.encode("日期参数","UTF-8")%>¶ms=<%=URLEncoder.encode("param1=2016-1-10;param2=2018-05-01","UTF-8")%>&token=<%=getToken()%>
The following figure shows by way of a request with parameters, return interface.
http:// IP:8099/EFReport/report/checkSheet?file=%E6%97%A5%E6%9C%9F%E5%8F%82%E6%95%B0¶ms=param1%3D2016-1-10%3Bparam2%3D2018-05-01&token=JyraKnXWLabFB/5FYL13wJVhWBjcyAPkgtDySdcZ3xJHqKm7lekK0rbDw7WZ3ISUTcvAIaD4PJX9ynaFX8RDThU8gWow12uiBgmiC49iv2dIByd7vHMR/ml2YChEXs5wc5pxL+1iWxcFlybgX8szjfV0lxlDsa3hwJiLReVbkys=
Fourth, the public template
1. Set the template public
The need to integrate the template, template management in the background, edit the template, if public property is set to "Yes."
2. Get the report area
Template name, parameters, obtain a report. http request as follows:
http://IP:8099/EFReport/report/checkSheet?file=<%=URLEncoder.encode("日期参数","UTF-8")%>¶ms=
Template with the actual request parameters as follows:
http:// IP:8099/EFReport/report/checkSheet?file=<%=URLEncoder.encode("日期参数","UTF-8")%>¶ms=<%=URLEncoder.encode("param1=2016-1-10;param2=2018-05-01","UTF-8")%>
The following figure shows by way of a request with parameters, return interface.
http:// IP:8099/EFReport/report/checkSheet?file=%E6%97%A5%E6%9C%9F%E5%8F%82%E6%95%B0¶ms=param1%3D2016-1-10%3Bparam2%3D2018-05-01
Surplus sail over several reporting tools provide an integrated manner, can quickly integrate content of the report in accordance with the actual needs of the project to address the reporting needs of the project.