Browse Source

Merge pull request #19 in PG/plugin-report-doc-demo from release/10.0 to persist/10.0

* commit '394c0dd1b9a35bc57eb2eec332506d1a8cddfc5c':
  DEC-10642 后台CAS登录后,token应放入request
  无JIRA任务  图表接口更新
  http://www.finedevelop.com:2016/browse/DEMO-2670 新增10.0从数据读取frm决策报表,编码格式改为utf-8
  http://www.finedevelop.com:2016/browse/DEMO-2670 新增10.0从数据库读取frm决策报表
  1.代码改为utf-8编码 2.去掉多余注释部分
  1.代码改为utf-8编码 2.去掉代码多余的注释部分
  frm表单导出api新增代码
persist/10.0
Lanlan 5 years ago
parent
commit
9a474478b3
  1. 2
      src/main/java/com/fr/FrFilter.java
  2. 58
      src/main/java/com/fr/demo/ReadfrmFromDatabase.java
  3. 76
      src/main/java/com/fr/io/ExportApi_frm.java
  4. 23
      src/main/java/com/fr/plugin/chart/IndependentChartProviderImpl.java
  5. 5
      src/main/java/com/fr/plugin/chart/IndependentChartUIProviderImpl.java

2
src/main/java/com/fr/FrFilter.java

@ -81,7 +81,7 @@ public class FrFilter implements Filter {
*/ */
private void login(HttpServletRequest req, HttpServletResponse res, HttpSession session, String username) throws Exception { private void login(HttpServletRequest req, HttpServletResponse res, HttpSession session, String username) throws Exception {
String token = LoginService.getInstance().login(req, res, username); String token = LoginService.getInstance().login(req, res, username);
session.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, token); req.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, token);
FineLoggerFactory.getLogger().info("fr FrFilter is over with username is ###" + username); FineLoggerFactory.getLogger().info("fr FrFilter is over with username is ###" + username);
} }

58
src/main/java/com/fr/demo/ReadfrmFromDatabase.java

@ -0,0 +1,58 @@
package com.fr.demo;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.web.weblet.Formlet;
import com.fr.form.main.Form;
import javax.servlet.http.HttpServletRequest;
import com.fr.log.FineLoggerFactory;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Map;
public class ReadfrmFromDatabase extends Formlet {
public Form createForm(HttpServletRequest reportletRequest) {
Form form= new Form();
String name = reportletRequest.getParameter("reportname").toString();
try {
// 定义数据连接(根据你实际数据库信息进行修改)
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/test";
String user = "root";
String pass = "123456";
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, pass);
// 从数据库中读模板
String sql = "select B from report where A = '" + name
+ "'";
Statement smt = conn.createStatement();
ResultSet rs = smt.executeQuery(sql);
while (rs.next()) {
Blob blob = rs.getBlob(1);
FineLoggerFactory.getLogger().info(blob.toString());
InputStream ins = blob.getBinaryStream();
form.readStream(ins);
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(ResourceIOUtils.getRealPath("assets"));
return form;
}
@Override
public void setParameterMap(Map<String, Object> arg0) {
// TODO Auto-generated method stub
}
}

76
src/main/java/com/fr/io/ExportApi_frm.java

@ -0,0 +1,76 @@
package com.fr.io;
import com.fr.base.operator.common.CommonOperator;
import com.fr.chart.activator.ChartBaseActivator;
import com.fr.cluster.engine.activator.standalone.StandaloneModeActivator;
import com.fr.config.activator.BaseDBActivator;
import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl;
import com.fr.form.export.FormToWBExecutor;
import com.fr.general.I18nResource;
import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.ImageExporter;
import com.fr.io.exporter.PDFExporter;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.main.impl.WorkBook;
import com.fr.main.workbook.ResultWorkBook;
import com.fr.module.Module;
import com.fr.module.tool.ActivatorToolBox;
import com.fr.report.ReportActivator;
import com.fr.report.RestrictionActivator;
import com.fr.report.module.ReportBaseActivator;
import com.fr.report.write.WriteActivator;
import com.fr.scheduler.SchedulerActivator;
import com.fr.stable.WriteActor;
import com.fr.store.StateServerActivator;
import com.fr.workspace.simple.SimpleWork;
import java.io.File;
import java.io.FileOutputStream;
public class ExportApi_frm {
public static void main(String[] args) {
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new StandaloneModeActivator(),
new StateServerActivator(),
new SchedulerActivator(),
new ReportBaseActivator(),
new RestrictionActivator(),
new ReportActivator(),
new WriteActivator(),
new ChartBaseActivator());
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl());
String envpath = "C:\\Users\\hipsh\\Desktop\\apache-tomcat-8.5.38-10.0\\webapps\\webroot\\WEB-INF\\";//工程路径
SimpleWork.checkIn(envpath);
I18nResource.getInstance();
module.start();
try {
java.util.Map parameterMap = new java.util.HashMap();
parameterMap.put("aa", "1");
ResultWorkBook re = FormToWBExecutor.executeForm("test.frm",parameterMap);
// 定义输出流
FileOutputStream outputStream;
// 将结果工作薄导出为Excel文件
outputStream = new FileOutputStream(new File("C:\\FTPServer\\1528.xlsx"));
StreamExcel2007Exporter ExcelExport1 = new StreamExcel2007Exporter();
ExcelExport1.export(outputStream,re);
// 将结果工作薄导出为PDF文件
outputStream = new FileOutputStream(new File("C:\\FTPServer\\PdfExport.pdf"));
PDFExporter PdfExport = new PDFExporter();
PdfExport.export(outputStream, re);
//将结果工作薄导出为Image文件
outputStream = new FileOutputStream(new File("C:\\FTPServer\\PngExport.png"));
ImageExporter ImageExport = new ImageExporter();
ImageExport.export(outputStream, re);
outputStream.close();
module.stop();
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}

23
src/main/java/com/fr/plugin/chart/IndependentChartProviderImpl.java

@ -1,9 +1,10 @@
package com.fr.plugin.chart; package com.fr.plugin.chart;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.fun.impl.AbstractIndependentChartProvider; import com.fr.chart.fun.impl.AbstractIndependentChartsProvider;
import com.fr.stable.StringUtils;
public class IndependentChartProviderImpl extends AbstractIndependentChartProvider { public class IndependentChartProviderImpl extends AbstractIndependentChartsProvider {
@Override @Override
public void init() { public void init() {
@ -15,12 +16,22 @@ public class IndependentChartProviderImpl extends AbstractIndependentChartProvid
} }
@Override @Override
public String getChartName() { public Chart[] getChartTypes() {
return ""; return null;
} }
@Override @Override
public Chart[] getChartTypes() { public String[] getRequiredJS() {
return null; return new String[0];
}
@Override
public String getWrapperName() {
return StringUtils.EMPTY;
}
@Override
public int currentAPILevel() {
return 0;
} }
} }

5
src/main/java/com/fr/plugin/chart/IndependentChartUIProviderImpl.java

@ -15,6 +15,11 @@ public class IndependentChartUIProviderImpl extends AbstractExtendedChartUIProvi
return null; return null;
} }
@Override
public String[] getDemoImagePath() {
return new String[0];
}
@Override @Override
public String getIconPath() { public String getIconPath() {
return ""; return "";

Loading…
Cancel
Save