forked from demo/example
Compare commits
44 Commits
release/10
...
release/10
Author | SHA1 | Date |
---|---|---|
Roger.Chen-陈旺 | 066849fb6f | 9 months ago |
roger | 4c97624bdc | 9 months ago |
roger | ee65b0dfe7 | 9 months ago |
Bruce.Deng-邓铖臻 | 737e4c42e5 | 1 year ago |
Bruce.Deng | 0614d33511 | 1 year ago |
Bruce.Deng | 504fd59217 | 1 year ago |
Bruce.Deng | d7737090ec | 1 year ago |
Bruce.Deng-邓铖臻 | 65312af3b2 | 2 years ago |
Bruce.Deng | 3f7ff140f8 | 2 years ago |
Rosie.Xu | f3f9a70b12 | 3 years ago |
Rosie.Xu | fb54bae1b0 | 3 years ago |
zack | 347a9332b8 | 3 years ago |
zack | 59aa0ad8be | 3 years ago |
zack | cddbf30e23 | 3 years ago |
zack | 2d925ee7af | 3 years ago |
zack | 60609d03e9 | 3 years ago |
zack | e79e8f895e | 3 years ago |
zack | 8cb1a2e82e | 3 years ago |
zack | bf88811291 | 3 years ago |
zack | b2d209136a | 3 years ago |
zack | 5ea33e5068 | 3 years ago |
ju|剧浩宇 | 00aa706b1f | 3 years ago |
zack | 3478bd0ac6 | 3 years ago |
zack | d51e4171ed | 4 years ago |
zack | cbdac5146e | 4 years ago |
pengda | f1600566e0 | 4 years ago |
pengda | 283f40f697 | 4 years ago |
zack | ff97ecf5fd | 4 years ago |
zack | 3f6541199b | 4 years ago |
zack | 0cf74b4e96 | 4 years ago |
zack | 471a43570c | 4 years ago |
zack | bc90de3c16 | 4 years ago |
zack | 128cd31f3c | 4 years ago |
zack | 8ec9a4a4ee | 4 years ago |
zack | cf6488f8cf | 4 years ago |
Rosie.Xu | edec0b6917 | 4 years ago |
Rosie | 1ab42424ac | 4 years ago |
zack | fdab845093 | 4 years ago |
zack | bff933481e | 4 years ago |
ju|剧浩宇 | 23ff4263ea | 4 years ago |
Rosie | cb4e9b9a7e | 4 years ago |
Rosie | 4d23fc467a | 4 years ago |
Roxy | 7266b28e75 | 4 years ago |
Roxy | 08ec05022c | 4 years ago |
29 changed files with 419 additions and 447 deletions
@ -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; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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
|
||||
|
||||
} |
||||
} |
@ -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; |
||||
} |
||||
|
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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; |
||||
} |
||||
} |
Binary file not shown.
@ -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; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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 ""; |
||||
} |
||||
} |
Loading…
Reference in new issue