Compare commits

...

44 Commits

Author SHA1 Message Date
Roger.Chen-陈旺 066849fb6f Pull request #69: REPORT-113769 修改WebService程序数据集帮助文档中的示例代码 9 months ago
roger 4c97624bdc 修复代码问题 9 months ago
roger ee65b0dfe7 REPORT-113769 修改WebService程序数据集帮助文档中的示例代码 9 months ago
Bruce.Deng-邓铖臻 737e4c42e5 Pull request #63: REPORT-94658 【降本增效】后台导出demo优化 1 year ago
Bruce.Deng 0614d33511 REPORT-94658 【降本增效】后台导出demo优化 1 year ago
Bruce.Deng 504fd59217 REPORT-94658 【降本增效】后台导出demo优化 1 year ago
Bruce.Deng d7737090ec REPORT-94658 【降本增效】后台导出demo优化 1 year ago
Bruce.Deng-邓铖臻 65312af3b2 Pull request #60: REPORT-88257 导出API代码适配11.0 2 years ago
Bruce.Deng 3f7ff140f8 REPORT-88257 导出API代码适配11.0 2 years ago
Rosie.Xu f3f9a70b12 Pull request #59: https://work.fineres.com/browse/REPORT-65524 3 years ago
Rosie.Xu fb54bae1b0 https://work.fineres.com/browse/REPORT-65524 3 years ago
zack 347a9332b8 Pull request #57: REPORT-64392 这个任务再看下产品端报错侧有没有能优化的 3 years ago
zack 59aa0ad8be REPORT-64392 这个任务再看下产品端报错侧有没有能优化的 3 years ago
zack cddbf30e23 Pull request #56: REPORT-65408 引擎API>保存模板至数据库代码编译出错 3 years ago
zack 2d925ee7af REPORT-65380 引擎API>保存模板至数据库代码编译出错 3 years ago
zack 60609d03e9 Pull request #55: REPORT-65118 REPORT-64392 这个任务再看下产品端报错侧有没有能优化的 3 years ago
zack e79e8f895e 1 3 years ago
zack 8cb1a2e82e Merge branch 'release/10.0' of https://code.fineres.com/scm/~zack/plugin-report-doc-demo 3 years ago
zack bf88811291 REPORT-65118 REPORT-64392 这个任务再看下产品端报错侧有没有能优化的 3 years ago
zack b2d209136a Pull request #54: DEMO-20364 导出excel2003文档刊误 3 years ago
zack 5ea33e5068 DEMO-20364 导出excel2003文档刊误 3 years ago
ju|剧浩宇 00aa706b1f Pull request #53: 无jira任务 demo插件打包失败 3 years ago
zack 3478bd0ac6 无jira任务 demo插件打包失败 3 years ago
zack d51e4171ed Pull request #51: 无JIRA任务 本地编译发现这个文档插件里面的类编译不通过了,纠正下,这个类在文档里没有用到,无需测试 4 years ago
zack cbdac5146e 无JIRA任务 本地编译发现这个文档插件里面的类编译不通过了,纠正下,这个类在文档里没有用到,无需测试 4 years ago
pengda f1600566e0 Pull request #50: REPORT-50982 保存模板至数据库后,读取带参数面板的报表会报错空指针,不带参数面板报表可以读取成功 4 years ago
pengda 283f40f697 REPORT-50982 保存模板至数据库后,读取带参数面板的报表会报错空指针,不带参数面板报表可以读取成功 4 years ago
zack ff97ecf5fd Pull request #49: REPORT-50963 优化程序数据集上层设计(abstracttabledata) 4 years ago
zack 3f6541199b REPORT-50963 优化程序数据集上层设计(abstracttabledata) 4 years ago
zack 0cf74b4e96 Pull request #47: REPORT-50963 新demo里面获取连接的逻辑跟老demo一致 4 years ago
zack 471a43570c rt 4 years ago
zack bc90de3c16 REPORT-50963 新demo里面获取连接的逻辑跟老demo一致 4 years ago
zack 128cd31f3c Pull request #46: REPORT-50963 优化程序数据集上层设计(abstracttabledata),提交新demo 4 years ago
zack 8ec9a4a4ee 补一下简单程序数据集demo 4 years ago
zack cf6488f8cf REPORT-50963 优化程序数据集上层设计(abstracttabledata),提交新demo 4 years ago
Rosie.Xu edec0b6917 Pull request #44: 误删自定义函数,恢复 4 years ago
Rosie 1ab42424ac 误删自定义函数,恢复 4 years ago
zack fdab845093 Pull request #39: 无JIRA任务 修复一些demo编译问题,已经程序数据集逻辑不严谨问题(getColumnName可能报错NPE) 4 years ago
zack bff933481e 无JIRA任务 修复一些demo编译问题,已经程序数据集逻辑不严谨问题(getColumnName可能报错NPE) 4 years ago
ju|剧浩宇 23ff4263ea Pull request #38: 程序网络报表-https://help.fanruan.com/finereport/doc-view-685.html 4 years ago
Rosie cb4e9b9a7e 程序网络报表-https://help.fanruan.com/finereport/doc-view-685.html 4 years ago
Rosie 4d23fc467a 程序网络报表-https://help.fanruan.com/finereport/doc-view-685.html 4 years ago
Roxy 7266b28e75 Pull request #37: 删除非产品内置的自定义函数 java文件 已经和manto沟通 4 years ago
Roxy 08ec05022c 删除非产品内置的自定义函数 java文件 已经和manto沟通 4 years ago
  1. 4
      build.xml
  2. 25
      src/main/java/com/fr/data/ParamTableDataDemo.java
  3. 29
      src/main/java/com/fr/data/SimpleArrayTableDataDemo.java
  4. 100
      src/main/java/com/fr/data/SimpleParamTableDataDemo.java
  5. 91
      src/main/java/com/fr/data/WebServiceTableData.java
  6. 2
      src/main/java/com/fr/data/XMLDemoTableData.java
  7. 72
      src/main/java/com/fr/demo/NewReadFrmFromDatabase.java
  8. 4
      src/main/java/com/fr/demo/ReadFromDatabase.java
  9. 10
      src/main/java/com/fr/demo/ReadfrmFromDatabase.java
  10. 34
      src/main/java/com/fr/demo/SimpleReportletDemoFrm.java
  11. BIN
      src/main/java/com/fr/function/CellSum.class
  12. BIN
      src/main/java/com/fr/function/DateDiff.class
  13. BIN
      src/main/java/com/fr/function/FlagHtmlColor.class
  14. BIN
      src/main/java/com/fr/function/IRR.class
  15. BIN
      src/main/java/com/fr/function/ReportCheck.class
  16. 16
      src/main/java/com/fr/function/ReportCheck.java
  17. BIN
      src/main/java/com/fr/function/StringCat.class
  18. BIN
      src/main/java/com/fr/function/StringImage.class
  19. 45
      src/main/java/com/fr/function/SubSection.java
  20. BIN
      src/main/java/com/fr/function/Ubm.class
  21. 105
      src/main/java/com/fr/function/Widget2Image.java
  22. 57
      src/main/java/com/fr/io/ExportApi.java
  23. 30
      src/main/java/com/fr/io/ExportApi_frm.java
  24. 78
      src/main/java/com/fr/io/SaveReportToDatabase.java
  25. 2
      src/main/java/com/fr/output/OutputExcel.java
  26. 15
      src/main/java/com/fr/privilege/RSAUtil.java
  27. 77
      src/main/java/com/fr/test/gauthority.java
  28. 2
      src/test/main/java/com/fr/demo/ExportApiTest.java
  29. 2
      src/test/main/java/com/fr/demo/ModuleStartTest.java

4
build.xml

@ -84,8 +84,8 @@
<param name="resources_from" value="${basedir}"/> <param name="resources_from" value="${basedir}"/>
</antcall> </antcall>
<antcall target="compile_javas"> <antcall target="compile_javas">
<param name="source_jdk_version" value="1.6"/> <param name="source_jdk_version" value="1.8"/>
<param name="target_jdk_version" value="1.6"/> <param name="target_jdk_version" value="1.8"/>
<param name="compile_jdk_version" value="${jdk.home}"/> <param name="compile_jdk_version" value="${jdk.home}"/>
<param name="compile_files" value="${basedir}/src"/> <param name="compile_files" value="${basedir}/src"/>
</antcall> </antcall>

25
src/main/java/com/fr/data/ParamTableDataDemo.java

@ -2,11 +2,14 @@ package com.fr.data;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.file.DatasourceManager; import com.fr.file.DatasourceManager;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
@ -50,11 +53,13 @@ public class ParamTableDataDemo extends AbstractTableData {
*/ */
@Override @Override
public int getColumnCount() { public int getColumnCount() {
init();
return columnNum; return columnNum;
} }
@Override @Override
public String getColumnName(int columnIndex) { public String getColumnName(int columnIndex) {
init();
return columnNames[columnIndex]; return columnNames[columnIndex];
} }
@ -90,10 +95,11 @@ public class ParamTableDataDemo extends AbstractTableData {
// 保存得到的结果集 // 保存得到的结果集
valueList = new ArrayList(); valueList = new ArrayList();
// 下面开始建立数据库连接,按照刚才的SQL语句进行查询 // 下面开始建立数据库连接,按照刚才的SQL语句进行查询
// 根据连接名获取FR数据连接定义的数据连接,如果没有定义,也可以参考getConnection方法自己创建连接
com.fr.data.impl.Connection conn = DatasourceManager.getInstance().getConnection("FRDemo"); com.fr.data.impl.Connection conn = DatasourceManager.getInstance().getConnection("FRDemo");
Connection con = null;
try { try {
Connection con = conn.createConnection(); con = conn.createConnection();
Statement stmt = con.createStatement(); Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql); ResultSet rs = stmt.executeQuery(sql);
// 获得记录的详细信息,然后获得总列数 // 获得记录的详细信息,然后获得总列数
@ -116,7 +122,15 @@ public class ParamTableDataDemo extends AbstractTableData {
// 打印一共取到的数据行数量 // 打印一共取到的数据行数量
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
if (con != null) {
try {
con.close();
} catch (SQLException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
} }
} }
@ -131,14 +145,13 @@ public class ParamTableDataDemo extends AbstractTableData {
String url = "jdbc:sqlite:////Applications//FineReport10_325//webapps//webroot//help//FRDemo.db"; String url = "jdbc:sqlite:////Applications//FineReport10_325//webapps//webroot//help//FRDemo.db";
String username = ""; String username = "";
String password = ""; String password = "";
Connection con; Connection con = null;
try { try {
Class.forName(driverName); Class.forName(driverName);
con = DriverManager.getConnection(url, username, password); con = DriverManager.getConnection(url, username, password);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return null;
} }
return con; return con;
} }

29
src/main/java/com/fr/data/SimpleArrayTableDataDemo.java

@ -0,0 +1,29 @@
package com.fr.data;
import java.util.ArrayList;
import java.util.List;
public class SimpleArrayTableDataDemo extends SimpleTableData {
/**
* 初始化列头
* @return
*/
@Override
public String[] initColumnNames() {
return new String[]{"Name", "Score"};
}
/**
* 加载行列数据
* @return
*/
@Override
public List<Object[]> loadData() {
ArrayList<Object[]> valueList = new ArrayList();
valueList.add(new Object[]{"Alex", 15});
valueList.add(new Object[]{"Helly", 22});
valueList.add(new Object[]{"Bobby", 99});
return valueList;
}
}

100
src/main/java/com/fr/data/SimpleParamTableDataDemo.java

@ -0,0 +1,100 @@
package com.fr.data;
import com.fr.file.ConnectionConfig;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ParameterProvider;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
/**
* 带参数的程序数据集Demo 跟ParamTableDataDemo功能一样但实现更简单
*
* @author fanruan
*/
public class SimpleParamTableDataDemo extends SimpleTableData {
@Override
public String[] initColumnNames() {
String[] columnNames = new String[10];
for (int i = 0; i < 10; i++) {
columnNames[i] = "column#" + i;
}
return columnNames;
}
@Override
public List<Object[]> loadData() {
// 保存得到的数据库表名
String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString();
// 构造SQL语句,并打印出来
String sql = "select * from " + tableName;
FineLoggerFactory.getLogger().info("Query SQL of ParamTableDataDemo: \n" + sql);
// 保存得到的结果集
ArrayList<Object[]> valueList = new ArrayList();
// 下面开始建立数据库连接,按照刚才的SQL语句进行查询
// 根据连接名获取FR数据连接定义的数据连接,如果没有定义,也可以参考getConnection方法自己创建连接
com.fr.data.impl.Connection conn = ConnectionConfig.getInstance().getConnection("FRDemo");
Connection con = null;
try {
con = conn.createConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
// 获得记录的详细信息,然后获得总列数
ResultSetMetaData rsmd = rs.getMetaData();
int colNum = rsmd.getColumnCount();
// 用对象保存数据
Object[] objArray = null;
while (rs.next()) {
objArray = new Object[colNum];
for (int i = 0; i < colNum; i++) {
objArray[i] = rs.getObject(i + 1);
}
// 在valueList中加入这一行数据
valueList.add(objArray);
}
// 释放数据库资源
rs.close();
stmt.close();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
return valueList;
}
/**
* 获取数据库连接 driverName和 url 可以换成您需要的
*
* @return Connection
*/
private Connection getConnection() {
String driverName = "org.sqlite.JDBC";
String url = "jdbc:sqlite:////Applications//FineReport10_325//webapps//webroot//help//FRDemo.db";
String username = "";
String password = "";
Connection con = null;
try {
Class.forName(driverName);
con = DriverManager.getConnection(url, username, password);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return con;
}
}

91
src/main/java/com/fr/data/WebServiceTableData.java

@ -1,38 +1,87 @@
package com.fr.data; package com.fr.data;
import javax.xml.namespace.QName; import com.fr.general.data.TableDataException;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ParameterProvider;
import org.apache.axis.client.Call; import org.apache.axis.client.Call;
import org.apache.axis.client.Service; import org.apache.axis.client.Service;
import com.fr.data.AbstractTableData;
import com.fr.general.data.TableDataException;
public class WebServiceTableData extends AbstractTableData{ import javax.xml.namespace.QName;
private String[][] data; import java.util.ArrayList;
import java.util.List;
/**
* WebService程序数据集
*
* @author Roger
* @since 11.0
* Created on 2024/1/8
*/
public class WebServiceTableData extends SimpleTableData {
public WebServiceTableData() { private static final int COLUMN_COUNT = 10;
this.data = this.createData();
}
//获取列数 /**
public int getColumnCount() throws TableDataException { * 初始化列名数组
return data[0].length; *
* @return {col1,col2,col3...}
* @throws TableDataException
*/
@Override
public String[] initColumnNames() {
String[] columnNames = new String[COLUMN_COUNT];
for (int i = 0; i < COLUMN_COUNT; i++) {
columnNames[i] = "column#" + i;
} }
return columnNames;
//获取列的名称为数组中第一行的值
public String getColumnName(int columnIndex) throws TableDataException {
return data[0][columnIndex];
} }
//获取行数为数据的长度-1 /**
public int getRowCount() throws TableDataException { * 加载数据
return data.length - 1; *
* @return 行列数据
*/
@Override
public List<Object[]> loadData() {
String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString();
FineLoggerFactory.getLogger().info("Query SQL of ParamTableDataDemo: {}", tableName);
// 保存得到的结果集
ArrayList<Object[]> valueList = new ArrayList();
try {
// 调用 Web 服务获取数据
String[][] data = createData();
// 如果数据为空,直接返回空列表
if (data == null || data.length == 0) {
return valueList;
} }
//获取值 // 获得总列数
public Object getValueAt(int rowIndex, int columnIndex) { int colNum = data[0].length;
return data[rowIndex + 1][columnIndex];
// 用对象保存数据
Object[] objArray = null;
for (int rowIndex = 1; rowIndex < data.length; rowIndex++) {
objArray = new Object[colNum];
for (int i = 0; i < colNum; i++) {
objArray[i] = data[rowIndex][i];
}
// 在valueList中加入这一行数据
valueList.add(objArray);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return valueList;
} }
/**
* 调用 Web 服务获取数据
*
* @return
*/
public String[][] createData() { public String[][] createData() {
try { try {
String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws"; String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws";

2
src/main/java/com/fr/data/XMLDemoTableData.java

@ -77,6 +77,8 @@ public class XMLDemoTableData extends AbstractParameterTableData {
try { try {
in = new BufferedInputStream(new FileInputStream(new File(filePath))); in = new BufferedInputStream(new FileInputStream(new File(filePath)));
XMLEventReader reader = inputFactory.createXMLEventReader(in); XMLEventReader reader = inputFactory.createXMLEventReader(in);
deep=0;
flag=false;
readCol(reader,list); readCol(reader,list);
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {

72
src/main/java/com/fr/demo/NewReadFrmFromDatabase.java

@ -0,0 +1,72 @@
package com.fr.demo;
import com.fr.data.core.db.DBUtils;
import com.fr.form.main.Form;
import com.fr.log.FineLoggerFactory;
import com.fr.web.session.SessionLocalManager;
import com.fr.web.weblet.DBFormlet;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Map;
public class NewReadFrmFromDatabase extends DBFormlet {
@Override
public Form createForm(HttpServletRequest reportletRequest) {
String name = reportletRequest.getParameter("reportname");
return createForm(name);
}
@Override
public Form createForm(String reportName) {
Form form = new Form();
Connection connection = null;
try {
connection = getConnection();
// 从数据库中读模板
String sql = "select frm from report where frmname = '" + reportName
+ "'";
Statement smt = connection.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);
return form;
}
} catch (Exception e) {
throw SessionLocalManager.createLogPackedException(e);
}finally {
DBUtils.closeConnection(connection);
}
return form;
}
private static Connection getConnection() throws ClassNotFoundException, SQLException {
// 定义数据连接(根据你实际数据库信息进行修改)
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);
return conn;
}
@Override
public void setParameterMap(Map<String, Object> arg0) {
// TODO Auto-generated method stub
}
}

4
src/main/java/com/fr/demo/ReadFromDatabase.java

@ -5,6 +5,8 @@ import com.fr.main.impl.WorkBook;
import com.fr.web.core.Reportlet; import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest; import com.fr.web.request.ReportletRequest;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.web.session.SessionLocalManager;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Blob; import java.sql.Blob;
import java.sql.Connection; import java.sql.Connection;
@ -40,7 +42,7 @@ public class ReadFromDatabase extends Reportlet {
workbook.readStream(ins); workbook.readStream(ins);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw SessionLocalManager.createLogPackedException(e);
} }
return workbook; return workbook;
} }

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

@ -1,10 +1,12 @@
package com.fr.demo; package com.fr.demo;
import com.fr.form.main.Form;
import com.fr.io.utils.ResourceIOUtils; import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.web.session.SessionLocalManager;
import com.fr.web.weblet.Formlet; import com.fr.web.weblet.Formlet;
import com.fr.form.main.Form;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.fr.log.FineLoggerFactory;
import java.io.InputStream; import java.io.InputStream;
import java.sql.Blob; import java.sql.Blob;
import java.sql.Connection; import java.sql.Connection;
@ -31,7 +33,7 @@ public class ReadfrmFromDatabase extends Formlet {
Class.forName(driver); Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, pass); Connection conn = DriverManager.getConnection(url, user, pass);
// 从数据库中读模板 // 从数据库中读模板
String sql = "select B from report where A = '" + name String sql = "select frm from report where frmname = '" + name
+ "'"; + "'";
Statement smt = conn.createStatement(); Statement smt = conn.createStatement();
ResultSet rs = smt.executeQuery(sql); ResultSet rs = smt.executeQuery(sql);
@ -42,7 +44,7 @@ public class ReadfrmFromDatabase extends Formlet {
form.readStream(ins); form.readStream(ins);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); throw SessionLocalManager.createLogPackedException(e);
} }
System.out.println(ResourceIOUtils.getRealPath("assets")); System.out.println(ResourceIOUtils.getRealPath("assets"));
return form; return form;

34
src/main/java/com/fr/demo/SimpleReportletDemoFrm.java

@ -0,0 +1,34 @@
package com.fr.demo;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.fr.form.main.Form;
import com.fr.form.main.FormIO;
import com.fr.log.FineLoggerFactory;
import com.fr.web.weblet.Formlet;
public class SimpleReportletDemoFrm extends Formlet {
@Override
public void setParameterMap(Map arg0) {
// TODO Auto-generated method stub
}
@Override
protected Form createForm(HttpServletRequest request) throws Exception {
Form form = null;
//模板的相对路径
String tplPath = "//doc//frm//决策报表入门.frm";
this.setTplPath(tplPath);
try {
form = FormIO.readForm(tplPath);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return form;
}
}

BIN
src/main/java/com/fr/function/CellSum.class

Binary file not shown.

BIN
src/main/java/com/fr/function/DateDiff.class

Binary file not shown.

BIN
src/main/java/com/fr/function/FlagHtmlColor.class

Binary file not shown.

BIN
src/main/java/com/fr/function/IRR.class

Binary file not shown.

BIN
src/main/java/com/fr/function/ReportCheck.class

Binary file not shown.

16
src/main/java/com/fr/function/ReportCheck.java

@ -4,13 +4,9 @@ package com.fr.function;
import com.fr.base.ResultFormula; import com.fr.base.ResultFormula;
import com.fr.base.operator.common.CommonOperator; import com.fr.base.operator.common.CommonOperator;
import com.fr.chart.activator.ChartBaseActivator; 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.BaseDBActivator;
import com.fr.config.activator.ConfigurationActivator; import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl; import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.I18nResource;
import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.ResourceRepositoryActivator;
import com.fr.io.TemplateWorkBookIO; import com.fr.io.TemplateWorkBookIO;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
@ -23,8 +19,6 @@ import com.fr.report.RestrictionActivator;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.module.ReportBaseActivator; import com.fr.report.module.ReportBaseActivator;
import com.fr.report.report.ResultReport; import com.fr.report.report.ResultReport;
import com.fr.report.write.WriteActivator;
import com.fr.scheduler.SchedulerActivator;
import com.fr.script.AbstractFunction; import com.fr.script.AbstractFunction;
import com.fr.stable.WriteActor; import com.fr.stable.WriteActor;
import com.fr.store.StateServiceActivator; import com.fr.store.StateServiceActivator;
@ -46,23 +40,15 @@ public class ReportCheck extends AbstractFunction {
// 定义报表运行环境,用于执行报表 // 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(), new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(), new StateServiceActivator(),
new ChartBaseActivator(),
new SchedulerActivator(),
new ReportBaseActivator(), new ReportBaseActivator(),
new RestrictionActivator(), new RestrictionActivator(),
new ReportActivator(), new ReportActivator(),
new WriteActivator()); new ChartBaseActivator());
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl());
String envpath= "//Applications//FineReport10_325//webapps//webroot//WEB-INF"; //工程路径 String envpath= "//Applications//FineReport10_325//webapps//webroot//WEB-INF"; //工程路径
SimpleWork.checkIn(envpath); SimpleWork.checkIn(envpath);
I18nResource.getInstance();
module.start(); module.start();
try { try {
ResultWorkBook rworkbook = null; ResultWorkBook rworkbook = null;
// 读取模板 // 读取模板

BIN
src/main/java/com/fr/function/StringCat.class

Binary file not shown.

BIN
src/main/java/com/fr/function/StringImage.class

Binary file not shown.

45
src/main/java/com/fr/function/SubSection.java

@ -1,45 +0,0 @@
//SubSection函数-Oracle查询参数个数限制
package com.fr.function;
import com.fr.general.FArray;
import com.fr.script.AbstractFunction;
public class SubSection extends AbstractFunction {
public Object run(Object[] args) {
// 获取第一个对象,即取得传入的参数
Object para = args[0];
String parastr = para.toString();
// 由于是复选参数,因此要去掉前后的"("和")"
if (parastr.startsWith("(") && parastr.endsWith(")")) {
parastr = parastr.substring(1, parastr.length() - 1);
}
// 将字符串转为","分割的数组
String test[] = parastr.split(",");
int len = test.length;
int loopnum = len / 500;
if (len % 500 != 0) {
loopnum += 1;
}
;
// 返回的值是数组,需要定义成我们内部的类型FArray
FArray result = new FArray();
String str = "";
int k = 1;
for (int i = 0; i < loopnum; i++) {
for (int j = 500 * i; j < 500 * (i + 1) && j < len; j++) {
if (k != 500 && j != (len - 1)) {
str += test[j] + ",";
} else {
str += test[j];
}
k++;
}
// 每500个形成一组并在每组外部加上"("和")"
str = "(" + str + ")";
result.add(str);
str = "";
k = 1;
}
return result;
}
}

BIN
src/main/java/com/fr/function/Ubm.class

Binary file not shown.

105
src/main/java/com/fr/function/Widget2Image.java

@ -1,105 +0,0 @@
// 导出打印单选按钮及复选框
package com.fr.function;
import com.fr.base.AbstractPainter;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.Style;
import com.fr.general.FArray;
import com.fr.general.FRFont;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.StringUtils;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
public class Widget2Image extends AbstractFunction {
public Object run(Object[] args) {
if (args.length < 3)
return Primitive.NULL;
// 第一个参数:控件类型,不区分大小写
String type = args[0].toString().toLowerCase();
if (!("checkbox".equals(type) || "radiobutton".equals(type)))
return Primitive.ERROR_VALUE;
// 第二个参数:控件按钮个数
int num = Integer.parseInt(args[1].toString());
// 第三个参数:按钮组的值,哪些被选中
String selection = args[2].toString();
// 第四个参数:可选参数,按钮组对应的显示值数组
FArray textArray = new FArray();
if (args.length == 4 && args[3] instanceof FArray) {
textArray = (FArray) args[3];
}
return new WidgetPaint(type, num, selection, textArray);
}
public static class WidgetPaint extends AbstractPainter {
public static String CHECK_ON = "/com/fr/web/images/checkon.gif";
public static String CHECK_OFF = "/com/fr/web/images/checkoff.gif";
public static String RADIO_ON = "/com/fr/web/images/radioon.gif";
public static String RADIO_OFF = "/com/fr/web/images/radiooff.gif";
public static FRFont DEFUALT_FONT = FRFont.getInstance();
public static FontMetrics FontMetrics = GraphHelper
.getFontMetrics(DEFUALT_FONT);
private String type;
private int num;
private String selection;
private FArray textArray;
{
DEFUALT_FONT = DEFUALT_FONT.applyForeground(Color.BLACK);
}
public WidgetPaint(String type, int num, String selection,
FArray textArray) {
this.type = type;
this.num = num;
this.selection = selection;
this.textArray = textArray;
}
private String resolveText(int i) {
if (i < this.textArray.length()) {
return this.textArray.elementAt(i).toString();
}
return StringUtils.EMPTY;
}
public void paint(Graphics g, int width, int height, int resolution,
Style style) {
String OFF = CHECK_OFF;
String ON = CHECK_ON;
if ("radiobutton".equals(type)) {
OFF = RADIO_OFF;
ON = RADIO_ON;
}
Image[] checkOFFON = {BaseUtils.readImage(OFF),
BaseUtils.readImage(ON)};
int[] imgWidths = {checkOFFON[0].getWidth(null),
checkOFFON[1].getWidth(null)};
int[] imgHeights = {checkOFFON[0].getHeight(null),
checkOFFON[1].getHeight(null)};
Graphics2D g2d = (Graphics2D) g;
g2d.setFont(FRFont.getInstance());
g2d.setPaint(Color.BLACK);
int x = 2;
int y = (height - imgHeights[0]) / 2;
String select = selection;
for (int i = 0; i < num; i++) {
int bit = Integer.parseInt(select.substring(i, i + 1));
g2d.drawImage(checkOFFON[bit], x, y, imgWidths[bit],
imgHeights[bit], null);
x += imgWidths[bit] + 2;
String text = resolveText(i);
g2d.setBackground(Color.BLACK);
g2d.drawString(text, (float) x, (float) (y + FontMetrics
.getAscent()));
x += FontMetrics.stringWidth(text) + 2;
}
}
}
}

57
src/main/java/com/fr/io/ExportApi.java

@ -7,8 +7,6 @@ import com.fr.config.activator.BaseDBActivator;
import com.fr.config.activator.ConfigurationActivator; import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl; import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.I18nResource; import com.fr.general.I18nResource;
import com.fr.general.log.Log4jConfig;
import com.fr.general.log.parser.ExtraPatternParserManager;
import com.fr.health.activator.ModuleHealActivator; import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.exporter.CSVExporter; import com.fr.io.exporter.CSVExporter;
import com.fr.io.exporter.EmbeddedTableDataExporter; import com.fr.io.exporter.EmbeddedTableDataExporter;
@ -20,53 +18,52 @@ import com.fr.io.exporter.TextExporter;
import com.fr.io.exporter.WordExporter; import com.fr.io.exporter.WordExporter;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter; import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.module.ModuleRole;
import com.fr.module.tool.ActivatorToolBox; import com.fr.module.tool.ActivatorToolBox;
import com.fr.report.ReportActivator; import com.fr.report.ReportActivator;
import com.fr.report.RestrictionActivator; import com.fr.report.RestrictionActivator;
import com.fr.report.module.ReportBaseActivator; 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.stable.WriteActor;
import com.fr.stable.resource.ResourceLoader;
import com.fr.store.StateServiceActivator; import com.fr.store.StateServiceActivator;
import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.PropertyConfigurator;
import com.fr.workspace.simple.SimpleWork; import com.fr.workspace.simple.SimpleWork;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties;
public class ExportApi { public class ExportApi {
public static void main(String[] args) { public static void main(String[] args) {
/**
initLog4j(); * 以下这段if判断仅在main函数测试时使用
* 实际生产环境中一般使用web容器集成帆软后帆软服务会自动启动不再需要下面的if判断直接写导出的业务逻辑即可
* web集成注意事项
* 1集成环境需要依赖当前使用jdk对应版本的tools.jar一般从jdk中直接复制即可;
* 2帆软服务自动启动成功后使用的工作目录自动识别为集成应用下的WEB-INF目录所以需要把下面代码中envpath指向的工作目录拷贝到集成环境下web应用的WEB-INF目录
* 正式发布时需要拷贝生产环境的帆软WEB-INF如果有的话这样才能沿用原先帆软的配置及模板如果是集群环境会自动使用文件服务器的模板本地测试时envpath需要指向单机非集群的帆软工程
* 3可以访问集成环境的地址 ip:port/应用名/decision 如果能成功访问且不需要初始化配置则代表帆软服务启动成功
*/
if (!ModuleRole.Root.isPresent()) {
/**定义报表运行环境,用于执行报表*/ /**定义报表运行环境,用于执行报表*/
com.fr.module.Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), com.fr.module.Module module = ActivatorToolBox.simpleLink(
new BaseDBActivator(),
new ConfigurationActivator(), new ConfigurationActivator(),
new ResourceRepositoryActivator(), new ResourceRepositoryActivator(),
new StandaloneModeActivator(), new StandaloneModeActivator(),
new ModuleHealActivator(), new ModuleHealActivator(),
//2020.4.26jar包之前的版本,替换成StateServerActivator() //2020.4.26jar包之前的版本,替换成StateServerActivator()
new StateServiceActivator(), new StateServiceActivator(),
new SchedulerActivator(),
new ReportBaseActivator(), new ReportBaseActivator(),
new RestrictionActivator(), new RestrictionActivator(),
new ReportActivator(), new ReportActivator(),
new WriteActivator(),
new ChartBaseActivator()); new ChartBaseActivator());
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl());
//定义工程路径 //定义工程路径
String envpath = "D:\\javatools\\FineReport_10.0\\webapps\\webroot\\WEB-INF\\"; String envpath = "D:\\FineReport_11.0\\webapps\\webroot\\WEB-INF\\";
SimpleWork.checkIn(envpath); SimpleWork.checkIn(envpath);
I18nResource.getInstance(); I18nResource.getInstance();
module.start(); module.start();
}
/**输出模板*/ /**输出模板*/
try { try {
// 定义输出的模板路径,以reportlets为根目录 // 定义输出的模板路径,以reportlets为根目录
@ -91,6 +88,7 @@ public class ExportApi {
/**将结果工作薄导出为2003Excel文件*/ /**将结果工作薄导出为2003Excel文件*/
outputStream = new FileOutputStream(new java.io.File(outputUrl+"ExcelExport2003.xls")); outputStream = new FileOutputStream(new java.io.File(outputUrl+"ExcelExport2003.xls"));
ExcelExporter ExcelExport = new ExcelExporter(); ExcelExporter ExcelExport = new ExcelExporter();
ExcelExport.setVersion(true);
ExcelExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); ExcelExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
/**将结果工作薄导出为2007Excel文件*/ /**将结果工作薄导出为2007Excel文件*/
@ -129,32 +127,9 @@ public class ExportApi {
ImageExport.export(outputStream, workbook.execute(parameterMap, new WriteActor())); ImageExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
outputStream.close(); outputStream.close();
module.stop();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
private static void initLog4j() {
PropertyConfigurator.configure(loadLog4jPropertiesFromJar(Level.toLevel("INFO")));
} }
private static Properties loadLog4jPropertiesFromJar(Level level) {
Properties properties = new Properties();
System.setProperty("LOG_HOME", System.getProperty("user.dir"));
System.setProperty("LOG_ROOT_LEVEL", level.toString());
ExtraPatternParserManager.setSystemProperty();
try {
properties.load(ResourceLoader.getResourceAsStream("/com/fr/general/log/log4j.properties", Log4jConfig.class));
} catch (IOException ignore) {
//do nothing
} }
return properties;
}
} }

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

@ -13,13 +13,11 @@ import com.fr.io.exporter.ImageExporter;
import com.fr.io.exporter.PDFExporter; import com.fr.io.exporter.PDFExporter;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter; import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.main.workbook.ResultWorkBook; import com.fr.main.workbook.ResultWorkBook;
import com.fr.module.Module; import com.fr.module.ModuleRole;
import com.fr.module.tool.ActivatorToolBox; import com.fr.module.tool.ActivatorToolBox;
import com.fr.report.ReportActivator; import com.fr.report.ReportActivator;
import com.fr.report.RestrictionActivator; import com.fr.report.RestrictionActivator;
import com.fr.report.module.ReportBaseActivator; import com.fr.report.module.ReportBaseActivator;
import com.fr.report.write.WriteActivator;
import com.fr.scheduler.SchedulerActivator;
import com.fr.store.StateServiceActivator; import com.fr.store.StateServiceActivator;
import com.fr.workspace.simple.SimpleWork; import com.fr.workspace.simple.SimpleWork;
@ -27,25 +25,38 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
public class ExportApi_frm { public class ExportApi_frm {
public static void main(String[] args) { public static void main(String[] args) {
// 定义报表运行环境,用于执行报表 /**
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(), * 以下这段if判断仅在main函数测试时使用
* 实际生产环境中一般使用web容器集成帆软后帆软服务会自动启动不再需要下面的if判断直接写导出的业务逻辑即可
* web集成注意事项
* 1集成环境需要依赖当前使用jdk对应版本的tools.jar一般从jdk中直接复制即可;
* 2帆软服务自动启动成功后使用的工作目录自动识别为集成应用下的WEB-INF目录所以需要把下面代码中envpath指向的工作目录拷贝到集成环境下web应用的WEB-INF目录
* 正式发布时需要拷贝生产环境的帆软WEB-INF如果有的话这样才能沿用原先帆软的配置及模板如果是集群环境会自动使用文件服务器的模板本地测试时envpath需要指向单机非集群的帆软工程
* 3可以访问集成环境的地址 ip:port/应用名/decision 如果能成功访问且不需要初始化配置则代表帆软服务启动成功
*/
if (!ModuleRole.Root.isPresent()) {
/**定义报表运行环境,用于执行报表*/
com.fr.module.Module module = ActivatorToolBox.simpleLink(
new BaseDBActivator(),
new ConfigurationActivator(), new ConfigurationActivator(),
new ResourceRepositoryActivator(), new ResourceRepositoryActivator(),
new StandaloneModeActivator(), new StandaloneModeActivator(),
new ModuleHealActivator(), new ModuleHealActivator(),
//2020.4.26jar包之前的版本,替换成StateServerActivator()
new StateServiceActivator(), new StateServiceActivator(),
new SchedulerActivator(),
new ReportBaseActivator(), new ReportBaseActivator(),
new RestrictionActivator(), new RestrictionActivator(),
new ReportActivator(), new ReportActivator(),
new WriteActivator(),
new ChartBaseActivator()); new ChartBaseActivator());
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl());
String envpath = "C:\\Users\\hipsh\\Desktop\\apache-tomcat-8.5.38-10.0\\webapps\\webroot\\WEB-INF\\";//工程路径 //定义工程路径
String envpath = "D:\\FineReport_11.0\\webapps\\webroot\\WEB-INF\\";
SimpleWork.checkIn(envpath); SimpleWork.checkIn(envpath);
I18nResource.getInstance(); I18nResource.getInstance();
module.start(); module.start();
}
try { try {
java.util.Map parameterMap = new java.util.HashMap(); java.util.Map parameterMap = new java.util.HashMap();
@ -66,11 +77,8 @@ public class ExportApi_frm {
ImageExporter ImageExport = new ImageExporter(); ImageExporter ImageExport = new ImageExporter();
ImageExport.export(outputStream, re); ImageExport.export(outputStream, re);
outputStream.close(); outputStream.close();
module.stop();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
SimpleWork.checkOut();
} }
} }
} }

78
src/main/java/com/fr/io/SaveReportToDatabase.java

@ -1,78 +0,0 @@
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.general.I18nResource;
import com.fr.health.activator.ModuleHealActivator;
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.store.StateServiceActivator;
import com.fr.workspace.simple.SimpleWork;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class SaveReportToDatabase {
public static void main(String[] args) {
SaveReport();
}
private static void SaveReport() {
try {
// 连接数据库
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://review.finedevelop.com:3306/susie";
String user = "root";
String pass = "ilovejava";
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, pass);
PreparedStatement presmt = conn
.prepareStatement("insert into report values(?,?)");
// 读进需要保存入库的模板文件
// 首先需要定义执行所在的环境,这样才能正确读取数据库信息
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new ResourceRepositoryActivator(),
new StandaloneModeActivator(),
new ModuleHealActivator(),
new StateServiceActivator(),
new ChartBaseActivator(),
new SchedulerActivator(),
new ReportBaseActivator(),
new RestrictionActivator(),
new ReportActivator(),
new WriteActivator());
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl());
String envpath = "//Applications//FineReport10_325//webapps//webroot//WEB-INF";//工程路径
SimpleWork.checkIn(envpath);
I18nResource.getInstance();
module.start();
File cptfile = new File("//doc//Primary//Parameter//Parameter.cpt");
int lens = (int) cptfile.length();
InputStream ins = new FileInputStream(cptfile);
// 将模板保存入库
presmt.setString(1, "Parameter.cpt"); // 第一个字段存放模板相对路径
presmt.setBinaryStream(2, ins, lens); // 第二个字段存放模板文件的二进制流
presmt.execute();
conn.commit();
presmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

2
src/main/java/com/fr/output/OutputExcel.java

@ -9,9 +9,9 @@ import com.fr.stable.ArrayUtils;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Map; import java.util.Map;

15
src/main/java/com/fr/privilege/RSAUtil.java

@ -1,5 +1,8 @@
package com.fr.privilege; package com.fr.privilege;
import com.fr.third.org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -19,8 +22,6 @@ import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPrivateKeySpec; import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec; import java.security.spec.RSAPublicKeySpec;
import javax.crypto.Cipher;
/** /**
* RSA 工具类提供加密解密生成密钥对等方法 * RSA 工具类提供加密解密生成密钥对等方法
* 需要到http://www.bouncycastle.org下载bcprov-jdk14-123.jar。 * 需要到http://www.bouncycastle.org下载bcprov-jdk14-123.jar。
@ -36,7 +37,7 @@ public class RSAUtil {
public static KeyPair generateKeyPair() throws Exception { public static KeyPair generateKeyPair() throws Exception {
try { try {
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA", KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider()); new BouncyCastleProvider());
final int KEY_SIZE = 1024;// 没什么好说的了,这个值关系到块加密的大小,可以更改,但是不要太大,否则效率会低 final int KEY_SIZE = 1024;// 没什么好说的了,这个值关系到块加密的大小,可以更改,但是不要太大,否则效率会低
keyPairGen.initialize(KEY_SIZE, new SecureRandom()); keyPairGen.initialize(KEY_SIZE, new SecureRandom());
KeyPair keyPair = keyPairGen.generateKeyPair(); KeyPair keyPair = keyPairGen.generateKeyPair();
@ -79,7 +80,7 @@ public class RSAUtil {
KeyFactory keyFac = null; KeyFactory keyFac = null;
try { try {
keyFac = KeyFactory.getInstance("RSA", keyFac = KeyFactory.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider()); new BouncyCastleProvider());
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
throw new Exception(ex.getMessage()); throw new Exception(ex.getMessage());
} }
@ -106,7 +107,7 @@ public class RSAUtil {
KeyFactory keyFac = null; KeyFactory keyFac = null;
try { try {
keyFac = KeyFactory.getInstance("RSA", keyFac = KeyFactory.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider()); new BouncyCastleProvider());
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
throw new Exception(ex.getMessage()); throw new Exception(ex.getMessage());
} }
@ -133,7 +134,7 @@ public class RSAUtil {
public static byte[] encrypt(PublicKey pk, byte[] data) throws Exception { public static byte[] encrypt(PublicKey pk, byte[] data) throws Exception {
try { try {
Cipher cipher = Cipher.getInstance("RSA", Cipher cipher = Cipher.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider()); new BouncyCastleProvider());
cipher.init(Cipher.ENCRYPT_MODE, pk); cipher.init(Cipher.ENCRYPT_MODE, pk);
int blockSize = cipher.getBlockSize();// 获得加密块大小,如:加密前数据为128个byte,而key_size=1024 int blockSize = cipher.getBlockSize();// 获得加密块大小,如:加密前数据为128个byte,而key_size=1024
// 加密块大小为127 // 加密块大小为127
@ -177,7 +178,7 @@ public class RSAUtil {
public static byte[] decrypt(PrivateKey pk, byte[] raw) throws Exception { public static byte[] decrypt(PrivateKey pk, byte[] raw) throws Exception {
try { try {
Cipher cipher = Cipher.getInstance("RSA", Cipher cipher = Cipher.getInstance("RSA",
new org.bouncycastle.jce.provider.BouncyCastleProvider()); new BouncyCastleProvider());
cipher.init(cipher.DECRYPT_MODE, pk); cipher.init(cipher.DECRYPT_MODE, pk);
int blockSize = cipher.getBlockSize(); int blockSize = cipher.getBlockSize();
ByteArrayOutputStream bout = new ByteArrayOutputStream(64); ByteArrayOutputStream bout = new ByteArrayOutputStream(64);

77
src/main/java/com/fr/test/gauthority.java

@ -1,77 +0,0 @@
package com.fr.test;
import com.fr.base.FRContext;
import com.fr.base.Formula;
import com.fr.general.FArray;
import com.fr.json.JSONObject;
import com.fr.script.AbstractFunction;
import com.fr.script.Calculator;
import com.fr.stable.Primitive;
public class gauthority extends AbstractFunction {
public gauthority() {
}
public Object run(Object[] args) {
int[] newArgs = new int[args.length];
for (int i = 0; i < args.length; ++i) {
if (!(args[i] instanceof Integer) || (Integer) args[i] <= 0) {
return Primitive.ERROR_NAME;
}
newArgs[i] = (Integer) args[i];
}
FArray res = new FArray();
Calculator ca = this.getCalculator();
Formula f = new Formula("$fr_userposition");
try {
Object dp = ca.eval(f);
if (dp instanceof FArray) {
FArray fa = (FArray) dp;
for (int i = 0; i < fa.length(); ++i) {
JSONObject jo = (JSONObject) fa.elementAt(i);
String dName = jo.getString("jobTitle");
if (newArgs.length == 0) {
res.add(dName);
} else {
String[] dNames = dName.split(",");
res.add(this.buildRes(dNames, newArgs));
}
}
}
} catch (Exception var12) {
FRContext.getLogger().error(var12.getMessage(), var12);
}
return res;
}
private String buildRes(String[] dNames, int[] args) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < args.length; ++i) {
int index = args[i];
if (dNames.length >= index) {
sb.append(dNames[index - 1]).append(",");
}
}
return sb.substring(0, sb.length() > 0 ? sb.length() - 1 : 0);
}
public Type getType() {
return OTHER;
}
public String getCN() {
return "GETUSERDEPARTMENTS():返回角色部门\n示例:\nGETUSERDEPARTMENTS():返回角色所有部门,若多个部门则数组\nGETUSERDEPARTMENTS(3,2):返回角色该部门的第三层和第二层名字,\n若多个部门则返回数组,若没有第三层则只显示第二层";
}
public String getEN() {
return "";
}
}

2
src/test/main/java/com/fr/demo/ExportApiTest.java

@ -7,6 +7,8 @@ import com.fr.config.activator.BaseDBActivator;
import com.fr.config.activator.ConfigurationActivator; import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl; import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.I18nResource; import com.fr.general.I18nResource;
import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.ResourceRepositoryActivator;
import com.fr.io.TemplateWorkBookIO; import com.fr.io.TemplateWorkBookIO;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter; import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;

2
src/test/main/java/com/fr/demo/ModuleStartTest.java

@ -8,6 +8,8 @@ import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl; import com.fr.env.operator.CommonOperatorImpl;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.I18nResource; import com.fr.general.I18nResource;
import com.fr.health.activator.ModuleHealActivator;
import com.fr.io.ResourceRepositoryActivator;
import com.fr.io.TemplateWorkBookIO; import com.fr.io.TemplateWorkBookIO;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.log.LogHandler; import com.fr.log.LogHandler;

Loading…
Cancel
Save