Compare commits

..

138 Commits

Author SHA1 Message Date
roger e159509541 REPORT-113769 程序数据集代码问题:修改WebService程序数据集帮助文档中的示例代码 10 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
zack ebdca952ab Pull request #35: REPORT-42908 调用sap接口帆软上没执行 4 years ago
zack ae0260ea55 REPORT-42908 调用sap接口帆软上没执行 4 years ago
Bruce.Deng 4c83348f58 Pull request #34: REPORT-39385 导出API,日志报错,文件无法输出 4 years ago
Bruce.Deng ff72249144 REPORT-39385 导出API,日志报错,文件无法输出 4 years ago
susie 30b311bc87 Pull request #33: 下拉树控件自定义函数 TREENODEFINDER(param1,param2) Java脚本-Zack提供 4 years ago
Rosie a6372ce1d7 自定义函数设置下拉树默认值-https://help.finereport.com/doc-view-3637.html 4 years ago
Bruce.Deng ef6abc7d72 Pull request #32: 无jira任务,解决冲突 4 years ago
Bruce.Deng 10bcae59cb Merge remote-tracking branch 'origin/release/10.0' into release/10.0 4 years ago
Bruce.Deng 872fdb18a9 无jira任务,解决冲突 4 years ago
Bruce.Deng ec33b8c9b6 Pull request #30: 无jira任务,解决冲突 4 years ago
Bruce.Deng 19c77eb3ca Merge remote-tracking branch 'origin/release/10.0' into release/10.0 4 years ago
Bruce.Deng 7453e18699 无jira任务,解决冲突 4 years ago
Bruce.Deng 35d5088d7b Pull request #28: REPORT-35537 调用导出api,控制台报错NPE:fine module health clinic is null 4 years ago
Bruce.Deng 81ff64e704 无jira任务,模块启动加上ModuleHealActivator避免NPE 4 years ago
Bruce.Deng dbfa72c8c6 REPORT-35537 调用导出api,控制台报错NPE:fine module health clinic is null 4 years ago
susie fb782a47e3 Pull request #26: DEC-13978 定时调度上传附件0kb 修改帮助文档DEMO 4 years ago
Cloud.Liu f060679c86 DEC-13978 定时调度上传附件Okb 修改帮助文档DEMO 4 years ago
Cloud.Liu 28dbfb3466 Pull request #24: DEMO-4947 帮助文档 CAS Filter 用户登录日志级别ERROR改INFO 5 years ago
Cloud.Liu 857af4e194 DEMO-4947 帮助文档 CAS Filter 用户登录日志级别ERROR改INFO 5 years ago
susie b6a7536cb0 Merge pull request #22 in PG/plugin-report-doc-demo from ~HARRISON/plugin-report-doc-demo:release/10.0 to release/10.0 5 years ago
Harrison 7210221021 DEMO-3230 Release10 module无法引用 5 years ago
zack 724bb47e92 Merge pull request #20 in PG/plugin-report-doc-demo from ~ZACK/plugin-report-doc-demo:release/10.0 to release/10.0 5 years ago
zack 79b18ff09e 无JIRA任务 适配新10.0代码 5 years ago
Cloud.Liu 394c0dd1b9 Merge pull request #18 in PG/plugin-report-doc-demo from ~CLOUD.LIU/plugin-report-doc-demo:release/10.0 to release/10.0 5 years ago
Cloud.Liu 0fee1eaab2 DEC-10642 后台CAS登录后,token应放入request 5 years ago
zack 4312da4d33 Merge pull request #17 in PG/plugin-report-doc-demo from ~ZACK/plugin-report-doc-demo:release/10.0 to release/10.0 5 years ago
zack 2bf2dd090c 无JIRA任务 图表接口更新 5 years ago
Leo.Tsai c027a144ad Merge pull request #16 in PG/plugin-report-doc-demo from ~LEO.TSAI/plugin-report-doc-demo-leo:release/10.0 to release/10.0 5 years ago
Leo.Cai 397bfa1d66 http://www.finedevelop.com:2016/browse/DEMO-2670 5 years ago
Leo.Cai 745b53362c http://www.finedevelop.com:2016/browse/DEMO-2670 5 years ago
Leo.Tsai 911c0c8041 Merge pull request #14 in PG/plugin-report-doc-demo from ~LEO.TSAI/plugin-report-doc-demo-leo:release/10.0 to release/10.0 5 years ago
Leo.Cai fb25c44e62 1.代码改为utf-8编码 5 years ago
Leo.Cai ade1863442 1.代码改为utf-8编码 5 years ago
Leo.Cai fdaf3bb08e frm表单导出api新增代码 5 years ago
zack 3df1638ac1 Merge pull request #11 in PG/plugin-report-doc-demo from ~ZACK/plugin-report-doc-demo:release/10.0 to release/10.0 5 years ago
zack fd21d7c3bb REPORT-21133 导出excel数据不对 5 years ago
zack 2e7bc0820e Merge pull request #9 in PG/plugin-report-doc-demo from ~ZACK/plugin-report-doc-demo:release/10.0 to release/10.0 5 years ago
zack a57cdb8e44 无JIRA任务 文档demo单元测试 5 years ago
zack 76811bfa84 Merge pull request #7 in PG/plugin-report-doc-demo from ~ZACK/plugin-report-doc-demo:release/10.0 to release/10.0 5 years ago
zack 0277ceb6f1 DEMO-2528 有几个包遗漏了 5 years ago
zack c2a96733e3 DEMO-2528 demo编译失败 5 years ago
richie 23f67b82bd 删除 6 years ago
richie 79772de12b Merge pull request #6 in PG/plugin-report-doc-demo from ~ZACK/plugin-report-doc-demo:release/10.0 to release/10.0 6 years ago
zack 99a1e18f71 误传jar包了 6 years ago
zack 4cef0ea288 无JIRA任务 将文档示例代码上传doc插件 6 years ago
zack 1505058f42 Merge pull request #5 in PG/plugin-report-doc-demo from ~ZACK/plugin-report-doc-demo:release/10.0 to release/10.0 6 years ago
zack e5ffbcb32b REPORT-15312 开放API整理任务 补充一些新增的api 修正之前有问题的api 6 years ago
zack 981fb9a86e Merge branch 'release/10.0' of https://cloud.finedevelop.com/scm/~zack/plugin-report-doc-demo 6 years ago
zack 64bb5c2570 Merge pull request #4 in PG/plugin-report-doc-demo from ~ZACK/plugin-report-doc-demo:release/10.0 to release/10.0 6 years ago
zack 4ccc1aa068 REPORT-15174 为了解决UNDEF-1709的问题,需要帮助文档所使用的代码,每天都要能保证编译通过.修改有问题的api ,加上所有插件的默认实现 6 years ago
zack ebabb7f783 REPORT-15174 为了解决UNDEF-1709的问题,需要帮助文档所使用的代码,每天都要能保证编译通过, 公开api和插件接口挪到插件目录 6 years ago
zack eca6f1bc68 Merge branch 'release/10.0' of https://cloud.finedevelop.com/scm/~zack/plugin-report-doc-demo 6 years ago
richie 83494a8876 文件列表 6 years ago
richie b1e79777c9 redis支持脚本转换值 6 years ago
richie 824336db27 先判断文件是否存在 6 years ago
richie 5c8494b98f 提供两个新的插件 6 years ago
richie 69edb7daf5 增加功能点记录 6 years ago
richie 7ea154f0f7 filter接口修改 6 years ago
richie 1fd1ece237 增加繁体中文支持 6 years ago
richie 0db3415469 初始化 6 years ago
richie b18c413633 10.0开发配置 6 years ago
richie 583434ab01 redis国际化 6 years ago
richie ecafaacb3d plugin.xml错误 6 years ago
richie 5a01f0c5c2 功能配置 6 years ago
richie 08b86af993 修改版本要求 6 years ago
richie a08f37a35d 单元格公式问题 6 years ago
richie 55ce7b22af 增加授权插件的编写示例 6 years ago
richie d373cde1d2 增加授权插件的编写示例 6 years ago
richie 1f11299d04 增加资源文件的存放示例 6 years ago
richie 65715f0a47 调试 6 years ago
richie 8b53267f50 优化 6 years ago
richie 5f9d9e440b 优化 6 years ago
richie d2b98dc286 优化 6 years ago
richie 13ff659951 优化 6 years ago
richie 873aaa3553 插件开发配置 6 years ago
richie 1f17678f58 插件开发配置 6 years ago
richie 6fff5a3474 2.0,不依赖 6 years ago
richie 357e421ba3 tomcat依赖8.5.32版本 6 years ago
richie a3cf8f0275 tomcat依赖8.5.32版本 6 years ago
richie c9c9288422 重新组织结构 6 years ago
yaoh.wu 363ca91c46 Merge pull request #3 in PG/plugin-report-doc_demo from ~YAOH.WU/plugin-report-doc_demo:release/10.0 to release/10.0 6 years ago
yaoh.wu 09633c645c REPORT-10287 source language level 1.6 6 years ago
yaoh.wu 7478ed077a Merge pull request #2 in PG/plugin-report-doc_demo from ~YAOH.WU/plugin-report-doc_demo:release/10.0 to release/10.0 6 years ago
yaoh.wu 9c50c8a6f9 REPORT-10287 文档demo 兼容 6 years ago
richie e21d1c254b 重新组织结构 6 years ago
richie c7b3eb9b03 重新组织结构 6 years ago
richie 763032df10 重新组织结构 6 years ago
richie 522200e773 插件打包 6 years ago
richie d626676bb7 插件打包 6 years ago
richie 736ae24ad4 10.0开发工程 6 years ago
richie be7702e112 10.0开发工程 6 years ago
richie 13016ed41b 10.0开发工程 6 years ago
richie abc5a0c09d 10.0开发工程 6 years ago
richie ea5ba3f181 10.0开发工程 6 years ago
yaoh.wu b40abd1c9f update dependencies 6 years ago
yaoh.wu 0251597f7b REPORT-9210 文档demo代码适配10 6 years ago
  1. 6
      .gitignore
  2. 27
      README.md
  3. 4
      build.xml
  4. BIN
      lib/cas-client-core-3.2.1.jar
  5. BIN
      lib/json-lib-2.1-jdk15.jar
  6. BIN
      lib/org.apache.oltu.oauth2.client-1.0.1.jar
  7. BIN
      lib/swexpl.jar
  8. 15
      plugin.xml
  9. 212
      pom.xml
  10. 26
      readme.md
  11. 58
      src/com/fr/data/WebServiceTableData.java
  12. 49
      src/com/fr/demo/SaveReportToDatabase.java
  13. 19
      src/com/fr/function/StringCat.java
  14. 73
      src/com/fr/function/StringImage.java
  15. 45
      src/com/fr/function/SubSection.java
  16. 105
      src/com/fr/function/Widget2Image.java
  17. 25
      src/com/fr/io/ExcelToCpt.java
  18. 43
      src/com/fr/io/ExcuteDemo.java
  19. 93
      src/com/fr/io/ExportApi.java
  20. 70
      src/com/fr/io/ExportBatch.java
  21. 90
      src/com/fr/io/ExportExcel.java
  22. 57
      src/com/fr/io/ExportReports.java
  23. 35
      src/com/fr/io/JavaPrint.java
  24. 57
      src/com/fr/io/SetParameterWindow.java
  25. 49
      src/com/fr/io/SimpleDemo.java
  26. 76
      src/com/fr/output/FTPUpload.java
  27. 100
      src/com/fr/output/OutputExcel.java
  28. 77
      src/com/fr/test/gauthority.java
  29. 11
      src/main/java/SimpleService.java
  30. 8
      src/main/java/TestWS2TDClient.java
  31. 111
      src/main/java/com/fr/FrFilter.java
  32. 60
      src/main/java/com/fr/FrLoginFilter.java
  33. 228
      src/main/java/com/fr/HttpUtil.java
  34. 111
      src/main/java/com/fr/SSLConnectionClient.java
  35. 0
      src/main/java/com/fr/StartFRDesigner.java
  36. 58
      src/main/java/com/fr/Test2.java
  37. 3
      src/main/java/com/fr/data/ArrayTableDataDemo.java
  38. 0
      src/main/java/com/fr/data/Commit3.java
  39. 0
      src/main/java/com/fr/data/CustomTableData.java
  40. 31
      src/main/java/com/fr/data/DataModelDemo.java
  41. 0
      src/main/java/com/fr/data/DemoSubmitJob1.java
  42. 0
      src/main/java/com/fr/data/DemoSubmitJob2.java
  43. 0
      src/main/java/com/fr/data/DemoTotalSubmitJob.java
  44. 0
      src/main/java/com/fr/data/GetXmlData.java
  45. 5
      src/main/java/com/fr/data/GetXmlDate.java
  46. 4
      src/main/java/com/fr/data/MobileTableWsdlDataDemo.java
  47. 6
      src/main/java/com/fr/data/MobileWsdlTableDataDemo.java
  48. 6
      src/main/java/com/fr/data/MobileWsdlTableDataDemo1.java
  49. 0
      src/main/java/com/fr/data/MobileWsdlTableDataDemo2.java
  50. 6
      src/main/java/com/fr/data/MobileWsdlTableDataDemoPara.java
  51. 16
      src/main/java/com/fr/data/ParamSAPDataTest.java
  52. 30
      src/main/java/com/fr/data/ParamTableDataDemo.java
  53. 29
      src/main/java/com/fr/data/SimpleArrayTableDataDemo.java
  54. 100
      src/main/java/com/fr/data/SimpleParamTableDataDemo.java
  55. 86
      src/main/java/com/fr/data/WebServiceTableData.java
  56. 10
      src/main/java/com/fr/data/WebServiceWsdlTableDataDemo2.java
  57. 0
      src/main/java/com/fr/data/XMLColumnNameType4Demo.java
  58. 84
      src/main/java/com/fr/data/XMLDemoTableData.java
  59. 25
      src/main/java/com/fr/data/XMLParseDemoDataModel.java
  60. 65
      src/main/java/com/fr/data/XMLRead.java
  61. 0
      src/main/java/com/fr/data/impl/Commit1.java
  62. 0
      src/main/java/com/fr/data/impl/Commit3.java
  63. 50
      src/main/java/com/fr/data/session.java
  64. 19
      src/main/java/com/fr/decision/privilege/encrpt/Base64PasswordValidator.java
  65. 14
      src/main/java/com/fr/decision/privilege/encrpt/CustomSHA256PasswordValidator.java
  66. 6
      src/main/java/com/fr/demo/ChangeRowAndCol.java
  67. 7
      src/main/java/com/fr/demo/CreateReportletDemo.java
  68. 14
      src/main/java/com/fr/demo/NewDateDemo.java
  69. 72
      src/main/java/com/fr/demo/NewReadFrmFromDatabase.java
  70. 20
      src/main/java/com/fr/demo/ReadFromDatabase.java
  71. 60
      src/main/java/com/fr/demo/ReadfrmFromDatabase.java
  72. 85
      src/main/java/com/fr/demo/SaveReportToDatabase.java
  73. 11
      src/main/java/com/fr/demo/SetCellElementStyle.java
  74. 12
      src/main/java/com/fr/demo/SimpleReportletDemo.java
  75. 34
      src/main/java/com/fr/demo/SimpleReportletDemoFrm.java
  76. 10
      src/main/java/com/fr/demo/TotalVerifyJobDemo.java
  77. 20
      src/main/java/com/fr/demo/URLParameterDemo.java
  78. 21
      src/main/java/com/fr/demo/VerifyJobDemo.java
  79. 73
      src/main/java/com/fr/demo/VerifyJobDemo2.java
  80. 0
      src/main/java/com/fr/function/BinaryImage.java
  81. BIN
      src/main/java/com/fr/function/CellSum.class
  82. 1
      src/main/java/com/fr/function/CellSum.java
  83. 9
      src/main/java/com/fr/function/ConnectSAPServer.java
  84. BIN
      src/main/java/com/fr/function/DateDiff.class
  85. 67
      src/main/java/com/fr/function/DateDiff.java
  86. BIN
      src/main/java/com/fr/function/FlagHtmlColor.class
  87. 67
      src/main/java/com/fr/function/FlagHtmlColor.java
  88. 23
      src/main/java/com/fr/function/GETIP.java
  89. BIN
      src/main/java/com/fr/function/IRR.class
  90. 152
      src/main/java/com/fr/function/IRR.java
  91. 10
      src/main/java/com/fr/function/JFreeToChart.java
  92. 0
      src/main/java/com/fr/function/Lunar.java
  93. 0
      src/main/java/com/fr/function/ParamSAPDataTest.java
  94. BIN
      src/main/java/com/fr/function/ReportCheck.class
  95. 36
      src/main/java/com/fr/function/ReportCheck.java
  96. 48
      src/main/java/com/fr/function/SolarToLunar.java
  97. BIN
      src/main/java/com/fr/function/StringCat.class
  98. 15
      src/main/java/com/fr/function/StringCat.java
  99. BIN
      src/main/java/com/fr/function/StringImage.class
  100. 59
      src/main/java/com/fr/function/StringImage.java
  101. Some files were not shown because too many files have changed in this diff Show More

6
.gitignore vendored

@ -1 +1,7 @@
*.iml
.idea/
/target/
/download/
/webroot/
.DS_Store
lib/report/*.jar

27
README.md

@ -1,3 +1,26 @@
# 文档demo代码插件
# 工程配置指南
## 只是为了验证文档demo代码是否能够编译,插件本身无任何作用。
## 安装maven
用于构建开发工程,文档参考:http://wiki.jikexueyuan.com/project/maven/environment-setup.html
## 安装ant
用于构建插件安装包,文档参考:http://wiki.jikexueyuan.com/project/ant/environment-setup.html
## 配置开发工程
直接使用IntelliJ IDEA打开这个目录即可。
如果需要复制jar包到webroot/WEB-INF/lib下,可以执行命令:```mvn install```
## 启动设计器
如果希望正常的进行插件开发,使用```com.fr.learn.Leaner```启动设计器。
如果希望进行设计器调试,则使用```com.fr.learn.Leaner4Debug```启动设计器。
## 修改依赖的jar版本
只需要更改pom.xml中的common-version属性即可。
|common-version|含义|
|--------------|----|
|10.0-RELEASE-SNAPSHOT|10.0的测试版本快照|
|10.0-SNAPSHOT|10.0的正式版本快照|
|10.0|10.0的正式版本|

4
build.xml

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

BIN
lib/cas-client-core-3.2.1.jar

Binary file not shown.

BIN
lib/json-lib-2.1-jdk15.jar

Binary file not shown.

BIN
lib/org.apache.oltu.oauth2.client-1.0.1.jar

Binary file not shown.

BIN
lib/swexpl.jar

Binary file not shown.

15
plugin.xml

@ -1,15 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugin>
<id>com.fr.plugin.doc.demo</id>
<name><![CDATA[9.0 文档demo代码集成]]></name>
<id>com.fr.plugin.doc.demo.v10</id>
<name><![CDATA[文档demo代码集成]]></name>
<active>yes</active>
<hidden>no</hidden>
<version>1.1.0</version>
<env-version>~9.0</env-version>
<jartime>2018-01-25</jartime>
<version>1.1.1</version>
<env-version>10.0~</env-version>
<jartime>2018-08-02</jartime>
<vendor>finereport</vendor>
<description><![CDATA[集成帮助文档中的demo代码]]></description>
<change-notes><![CDATA[发布。]]></change-notes>
<change-notes><![CDATA[
[2018-01-25] 发布。<br>
[2018-08-02] 插件适配10
]]></change-notes>
<extra-core>
</extra-core>

212
pom.xml

@ -0,0 +1,212 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.fr.plugin</groupId>
<artifactId>starter</artifactId>
<version>10.0</version>
<packaging>pom</packaging>
<properties>
<common-version>10.0-RELEASE-SNAPSHOT</common-version>
<web-inf-bucket>${project.basedir}/webroot/WEB-INF</web-inf-bucket>
</properties>
<dependencies>
<!-- core包 -->
<dependency>
<groupId>com.fr.third</groupId>
<artifactId>fine-third</artifactId>
<version>${common-version}</version>
</dependency>
<dependency>
<groupId>com.fr.activator</groupId>
<artifactId>fine-activator</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.core</groupId>
<artifactId>fine-core</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.webui</groupId>
<artifactId>fine-webui</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<!-- 数据源包 -->
<dependency>
<groupId>com.fr.datasource</groupId>
<artifactId>fine-datasource</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<!-- 决策平台包 -->
<dependency>
<groupId>com.fr.decision</groupId>
<artifactId>fine-decision</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.decision</groupId>
<artifactId>fine-decision-report</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<!-- 定时调度包 -->
<dependency>
<groupId>com.fr.schedule</groupId>
<artifactId>fine-schedule</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.schedule</groupId>
<artifactId>fine-schedule-report</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<!-- 智能日志包 -->
<dependency>
<groupId>com.fr.intelligence</groupId>
<artifactId>fine-swift</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fr.intelligence</groupId>
<artifactId>fine-accumulator</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<!-- 报表引擎包 -->
<dependency>
<groupId>com.fr.report</groupId>
<artifactId>fine-report-engine</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<!-- 设计器包 -->
<dependency>
<groupId>com.fr.report</groupId>
<artifactId>fine-report-designer</artifactId>
<version>${common-version}</version>
<scope>compile</scope>
</dependency>
<!-- 远程设计用包 -->
<dependency>
<groupId>io.socket</groupId>
<artifactId>socket.io-client</artifactId>
<version>0.7.0</version>
<scope>compile</scope>
</dependency>
<!-- AOP用包 -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.9</version>
<scope>compile</scope>
</dependency>
<!-- 设计器调试用包 -->
<dependency>
<groupId>org.swingexplorer</groupId>
<artifactId>swexpl</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.swingexplorer</groupId>
<artifactId>swag</artifactId>
<version>1.0</version>
</dependency>
<!-- tomcat包 -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>8.5.32</version>
</dependency>
<!-- mysql驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.44</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.5.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<outputDirectory>${web-inf-bucket}/classes</outputDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<!--不生成target/generated-sources/annotations-->
<proc>none</proc>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.basedir}/webroot/WEB-INF/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>fanruan</id>
<name>fanruan</name>
<url>http://mvn.finedevelop.com/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>fanruan</id>
<name>fanruan</name>
<url>http://mvn.finedevelop.com/repository/maven-public/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>

26
readme.md

@ -0,0 +1,26 @@
# 工程配置指南
## 安装maven
用于构建开发工程,文档参考:http://wiki.jikexueyuan.com/project/maven/environment-setup.html
## 安装ant
用于构建插件安装包,文档参考:http://wiki.jikexueyuan.com/project/ant/environment-setup.html
## 配置开发工程
直接使用IntelliJ IDEA打开这个目录即可。
如果需要复制jar包到webroot/WEB-INF/lib下,可以执行命令:```mvn install```
## 启动设计器
如果希望正常的进行插件开发,使用```com.fr.learn.Leaner```启动设计器。
如果希望进行设计器调试,则使用```com.fr.learn.Leaner4Debug```启动设计器。
## 修改依赖的jar版本
只需要更改pom.xml中的common-version属性即可。
|common-version|含义|
|--------------|----|
|10.0-RELEASE-SNAPSHOT|10.0的测试版本快照|
|10.0-SNAPSHOT|10.0的正式版本快照|
|10.0|10.0的正式版本|

58
src/com/fr/data/WebServiceTableData.java

@ -1,58 +0,0 @@
package com.fr.data;
import com.fr.general.data.TableDataException;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;
public class WebServiceTableData extends AbstractTableData {
private String[][] data;
public WebServiceTableData() {
this.data = this.getData();
}
//获取列数
@Override
public int getColumnCount() throws TableDataException {
return data[0].length;
}
//获取列的名称为数组中第一行的值
@Override
public String getColumnName(int columnIndex) throws TableDataException {
return data[0][columnIndex];
}
//获取行数为数据的长度-1
@Override
public int getRowCount() throws TableDataException {
return data.length - 1;
}
//获取值
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return data[rowIndex + 1][columnIndex];
}
public String[][] getData() {
try {
String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://localhost:8080/axis/TestWS2TDClient.jws",
"getTD"));
return (String[][]) call.invoke(new Object[]{});
} catch (Exception e) {
e.printStackTrace();
}
return new String[][]{};
}
}

49
src/com/fr/demo/SaveReportToDatabase.java

@ -1,49 +0,0 @@
package com.fr.demo;
import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
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 envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
// 连接数据库
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://112.124.109.239:3306/yourdatabase";
String user = "yourusername";
String pass = "yourpassword";
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, pass); //注意表名是否区分大小写
conn.setAutoCommit(false);
PreparedStatement presmt = conn
.prepareStatement("INSERT INTO report VALUES(?,?)");
// 读进需要保存入库的模板文件
File cptfile = new File(envpath
+ "\\reportlets\\GettingStarted.cpt");
int lens = (int) cptfile.length();
InputStream ins = new FileInputStream(cptfile);
// 将模板保存入库
presmt.setString(1, "GettingStarted.cpt"); // 第一个字段存放模板相对路径
presmt.setBinaryStream(2, ins, lens); // 第二个字段存放模板文件的二进制流
presmt.execute();
conn.commit();
presmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

19
src/com/fr/function/StringCat.java

@ -1,19 +0,0 @@
package com.fr.function;
import com.fr.script.AbstractFunction;
public class StringCat extends AbstractFunction {
public StringCat() {
}
public Object run(Object[] args) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < args.length; ++i) {
Object para = args[i];
result.append(para.toString());
}
return result.toString();
}
}

73
src/com/fr/function/StringImage.java

@ -1,73 +0,0 @@
//图片在下文字在上
package com.fr.function;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.script.AbstractFunction;
import com.fr.stable.CoreGraphHelper;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class StringImage extends AbstractFunction {
public Object run(Object[] args) {
Image result = null;
int p = 0;
Object[] ob = new Object[2];
for (int i = 0; (i < args.length && p <= 1); i++) {
if (args[i] == null) {
continue;
}
ob[p] = args[i];
p++;
}
try {
result = initStringImage(ob[0], ob[1]);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
public Image initStringImage(Object nameOb, Object imageOb)
throws IOException {
String name = (String) nameOb;
Image image = null;
if (imageOb instanceof Image)
image = (Image) imageOb;
else
;
Image stringImage = null;
BufferedImage splashBuffedImage = CoreGraphHelper.toBufferedImage(image);
stringImage = splashBuffedImage;
Graphics2D splashG2d = splashBuffedImage.createGraphics();
double centerX = 25;
double centerY = 25;
GraphHelper.drawString(splashG2d, name, centerX, centerY);
//
String FilePath = "Test.png";
File f = new File(FilePath);
ImageIO.write(splashBuffedImage, "png", f);
//
return splashBuffedImage;
}
public static void main(String arg[]) throws IOException {
StringImage tt = new StringImage();
Image image = BaseUtils.readImage("D:\\1.jpg");
String name = "12314124";
Image aa = tt.initStringImage(name, image);
JFrame jf = new JFrame();
JPanel jp = new JPanel();
}
}

45
src/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;
}
}

105
src/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;
}
}
}
}

25
src/com/fr/io/ExcelToCpt.java

@ -1,25 +0,0 @@
package com.fr.io;
import com.fr.general.ModuleContext;
import com.fr.io.importer.ExcelReportImporter;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import com.fr.report.module.EngineModule;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
public class ExcelToCpt {
public static void main(String[] args) throws Exception {
File excelFile = new File("D:\\API.xls");
FileInputStream a = new FileInputStream(excelFile);
ModuleContext.startModule(EngineModule.class.getName());
TemplateWorkBook tpl = new ExcelReportImporter().generateWorkBookByStream(a);
OutputStream outputStream = new FileOutputStream(new File("D:\\abc.cpt"));
((WorkBook) tpl).export(outputStream);
outputStream.close();
ModuleContext.stopModules();
}
}

43
src/com/fr/io/ExcuteDemo.java

@ -1,43 +0,0 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.ExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.main.workbook.ResultWorkBook;
import com.fr.report.module.EngineModule;
import com.fr.stable.WriteActor;
import java.io.File;
import java.io.FileOutputStream;
public class ExcuteDemo {
public static void main(String[] args) {
try {
// 首先需要定义执行所在的环境,这样才能正确读取数据库信息
String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
ModuleContext.startModule(EngineModule.class.getName());
// 读取模板
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), "\\doc\\Primary\\Parameter\\Parameter.cpt");
/*
* 生成参数map注入参数与对应的值用于执行报表 该模板中只有一个参数地区给其赋值华北
* 若参数在发送请求时传过来可以通过req.getParameter(name)获得
* 获得的参数put进map中paraMap.put(paraname,paravalue)
*/
java.util.Map paraMap = new java.util.HashMap();
paraMap.put("地区", "华北");
// 使用paraMap执行生成结果
ResultWorkBook result = workbook.execute(paraMap, new WriteActor());
// 使用结果如导出至excel
FileOutputStream outputStream = new FileOutputStream(new File(
"D:\\Parameter.xls"));
ExcelExporter excelExporter = new ExcelExporter();
excelExporter.export(outputStream, result);
} catch (Exception e) {
e.printStackTrace();
}
}
}

93
src/com/fr/io/ExportApi.java

@ -1,93 +0,0 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.CSVExporter;
import com.fr.io.exporter.EmbeddedTableDataExporter;
import com.fr.io.exporter.ExcelExporter;
import com.fr.io.exporter.ImageExporter;
import com.fr.io.exporter.PDFExporter;
import com.fr.io.exporter.SVGExporter;
import com.fr.io.exporter.TextExporter;
import com.fr.io.exporter.WordExporter;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.main.impl.WorkBook;
import com.fr.main.workbook.ResultWorkBook;
import com.fr.report.module.EngineModule;
import com.fr.stable.WriteActor;
import java.io.File;
import java.io.FileOutputStream;
public class ExportApi {
public static void main(String[] args) {
// 定义报表运行环境,才能执行报表
String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
ModuleContext.startModule(EngineModule.class.getName());
ResultWorkBook rworkbook = null;
try {
// 未执行模板工作薄
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(FRContext.getCurrentEnv(),
"\\doc\\Primary\\Parameter\\Parameter.cpt");
// 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集
Parameter[] parameters = workbook.getParameters();
parameters[0].setValue("华东");
// 定义parametermap用于执行报表,将执行后的结果工作薄保存为rworkBook
java.util.Map parameterMap = new java.util.HashMap();
for (int i = 0; i < parameters.length; i++) {
parameterMap.put(parameters[i].getName(), parameters[i]
.getValue());
}
// 定义输出流
FileOutputStream outputStream;
// 将未执行模板工作薄导出为内置数据集模板
outputStream = new FileOutputStream(new File("D:\\EmbExport.cpt"));
EmbeddedTableDataExporter templateExporter = new EmbeddedTableDataExporter();
templateExporter.export(outputStream, workbook);
// 将模板工作薄导出模板文件,在导出前您可以编辑导入的模板工作薄,可参考报表调用章节
outputStream = new FileOutputStream(new File("D:\\TmpExport.cpt"));
((WorkBook) workbook).export(outputStream);
// 将结果工作薄导出为2003Excel文件
outputStream = new FileOutputStream(new File("D:\\ExcelExport.xls"));
ExcelExporter ExcelExport = new ExcelExporter();
ExcelExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
// 将结果工作薄导出为Excel文件
outputStream = new FileOutputStream(new File("D:\\ExcelExport.xlsx"));
StreamExcel2007Exporter ExcelExport1 = new StreamExcel2007Exporter();
ExcelExport1.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
// 将结果工作薄导出为Word文件
outputStream = new FileOutputStream(new File("D:\\WordExport.doc"));
WordExporter WordExport = new WordExporter();
WordExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
// 将结果工作薄导出为Pdf文件
outputStream = new FileOutputStream(new File("D:\\PdfExport.pdf"));
PDFExporter PdfExport = new PDFExporter();
PdfExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
// 将结果工作薄导出为Txt文件(txt文件本身不支持表格、图表等,被导出模板一般为明细表)
outputStream = new FileOutputStream(new File("D:\\TxtExport.txt"));
TextExporter TxtExport = new TextExporter();
TxtExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
// 将结果工作薄导出为Csv文件
outputStream = new FileOutputStream(new File("D:\\CsvExport.csv"));
CSVExporter CsvExport = new CSVExporter();
CsvExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
//将结果工作薄导出为SVG文件
outputStream = new FileOutputStream(new File("D:\\SvgExport.svg"));
SVGExporter SvgExport = new SVGExporter();
SvgExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
//将结果工作薄导出为image文件
outputStream = new FileOutputStream(new File("D:\\PngExport.png"));
ImageExporter ImageExport = new ImageExporter();
ImageExport.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
outputStream.close();
ModuleContext.stopModules();
} catch (Exception e) {
e.printStackTrace();
}
}
}

70
src/com/fr/io/ExportBatch.java

@ -1,70 +0,0 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.ExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.main.workbook.ResultWorkBook;
import com.fr.report.module.EngineModule;
import com.fr.stable.StableUtils;
import com.fr.stable.WriteActor;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.Arrays;
public class ExportBatch {
public static void main(String[] args) {
try {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
String envpath = "D:\\FineReport_7.1\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
ModuleContext.startModule(EngineModule.class.getName());
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(),
"doc\\Primary\\DetailReport\\Details.cpt");
// <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>txt<EFBFBD>ļ<EFBFBD>
File parafile = new File(envpath + "\\para.txt");
FileInputStream fileinputstream;
fileinputstream = new FileInputStream(parafile);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileinputstream));
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>map<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
java.util.Map paramap = new java.util.HashMap();
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>txt<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>txt<EFBFBD>ļ<EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽΪ para1,para2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>para1=<EFBFBD><EFBFBD><EFBFBD>ա<EFBFBD>para2=<EFBFBD><EFBFBD><EFBFBD>𣬸<EFBFBD><EFBFBD>ݲ<EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>excel excel<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
String lineText = bufferedReader.readLine();
lineText = lineText.trim();
String[] paraname = StableUtils.splitString(lineText, ",");
System.out.println(Arrays.toString(paraname));
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>ִ<EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int number = 0;
while ((lineText = bufferedReader.readLine()) != null) {
lineText = lineText.trim();
String[] paravalue = StableUtils.splitString(lineText, ",");
for (int j = 0; j < paravalue.length; j++) {
paramap.put(paraname[j], paravalue[j]);
}
ResultWorkBook result = workbook.execute(paramap, new WriteActor());
OutputStream outputstream = new FileOutputStream(new File("E:\\ExportEg" + number + ".xls"));
ExcelExporter excelexporter = new ExcelExporter();
excelexporter.export(outputstream, result);
// <EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>²<EFBFBD><EFBFBD><EFBFBD>map<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´μ<EFBFBD><EFBFBD><EFBFBD>
paramap.clear();
number++;
outputstream.close();
}
ModuleContext.stopModules();
} catch (Exception e) {
e.printStackTrace();
}
}
}

90
src/com/fr/io/ExportExcel.java

@ -1,90 +0,0 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.ExcelExporter;
import com.fr.io.exporter.LargeDataPageExcelExporter;
import com.fr.io.exporter.PageExcel2007Exporter;
import com.fr.io.exporter.PageExcelExporter;
import com.fr.io.exporter.PageToSheetExcel2007Exporter;
import com.fr.io.exporter.PageToSheetExcelExporter;
import com.fr.io.exporter.excel.stream.StreamExcel2007Exporter;
import com.fr.main.impl.WorkBook;
import com.fr.main.workbook.ResultWorkBook;
import com.fr.report.core.ReportUtils;
import com.fr.report.module.EngineModule;
import com.fr.stable.WriteActor;
import java.io.File;
import java.io.FileOutputStream;
public class ExportExcel {
public static void main(String[] args) {
// 定义报表运行环境,才能执行报表
String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
ModuleContext.startModule(EngineModule.class.getName());
ResultWorkBook rworkbook = null;
try {
// 未执行模板工作薄
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(FRContext.getCurrentEnv(),
"\\doc\\Primary\\Parameter\\Parameter.cpt");
// 获取报表参数并设置值,导出内置数据集时数据集会根据参数值查询出结果从而转为内置数据集
Parameter[] parameters = workbook.getParameters();
parameters[0].setValue("华东");
// 定义parametermap用于执行报表,将执行后的结果工作薄保存为rworkBook
java.util.Map parameterMap = new java.util.HashMap();
for (int i = 0; i < parameters.length; i++) {
parameterMap.put(parameters[i].getName(), parameters[i]
.getValue());
}
// 定义输出流
FileOutputStream outputStream;
//原样导出excel2003
outputStream = new FileOutputStream(new File("E:\\ExcelExport.xls"));
ExcelExporter excel = new ExcelExporter();
excel.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
//原样导出excel2007
outputStream = new FileOutputStream(new File("E:\\ExcelExport.xlsx"));
StreamExcel2007Exporter excel1 = new StreamExcel2007Exporter();
excel.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
//分页导出excel2003
outputStream = new FileOutputStream(new File("E:\\PageExcelExport.xls"));
PageExcelExporter page = new PageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(workbook.execute(parameterMap, new WriteActor())));
page.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
//分页导出excel2007
outputStream = new FileOutputStream(new File("E:\\PageExcelExport.xlsx"));
PageExcel2007Exporter page1 = new PageExcel2007Exporter(ReportUtils.getPaperSettingListFromWorkBook(rworkbook));
page1.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
//分页分sheet导出excel2003
outputStream = new FileOutputStream(new File("E:\\PageSheetExcelExport.xls"));
PageToSheetExcelExporter sheet = new PageToSheetExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(workbook.execute(parameterMap, new WriteActor())));
sheet.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
//分页分sheet导出excel2007
outputStream = new FileOutputStream(new File("E:\\PageSheetExcelExport.xlsx"));
PageToSheetExcel2007Exporter sheet1 = new PageToSheetExcel2007Exporter(ReportUtils.getPaperSettingListFromWorkBook(rworkbook));
sheet1.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
//大数据量导出
outputStream = new FileOutputStream(new File("E:\\LargeExcelExport.zip"));
LargeDataPageExcelExporter large = new LargeDataPageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(workbook.execute(parameterMap, new WriteActor())), true);
//导出2007版outputStream = new FileOutputStream(new File("E:\\LargeExcelExport.xlsx")); excel LargeDataPageExcel2007Exporter large = new LargeDataPageExcel2007Exporter(ReportUtils.getPaperSettingListFromWorkBook(rworkbook), true);
large.export(outputStream, workbook.execute(parameterMap, new WriteActor()));
outputStream.close();
ModuleContext.stopModules();
} catch (Exception e) {
e.printStackTrace();
}
}
}

57
src/com/fr/io/ExportReports.java

@ -1,57 +0,0 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.PageExcelExporter;
import com.fr.main.TemplateWorkBook;
import com.fr.main.workbook.PageWorkBook;
import com.fr.report.core.ReportUtils;
import com.fr.report.module.EngineModule;
import com.fr.report.report.PageReport;
import com.fr.stable.PageActor;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
public class ExportReports {
public static void main(String[] args) {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
String envpath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
ModuleContext.startModule(EngineModule.class.getName());
// <EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>
try {
// δִ<EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(),
"Gettingstarted.cpt");
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪChina<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>rworkbook
Parameter[] parameters = workbook.getParameters();
java.util.Map parameterMap = new java.util.HashMap();
for (int i = 0; i < parameters.length; i++) {
parameterMap.put(parameters[i].getName(), "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
PageWorkBook rworkbook = (PageWorkBook) workbook.execute(parameterMap, new PageActor());
rworkbook.setReportName(0, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
// <EFBFBD><EFBFBD><EFBFBD>parametermap<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ResultReport
parameterMap.clear();
for (int i = 0; i < parameters.length; i++) {
parameterMap.put(parameters[i].getName(), "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
PageWorkBook rworkbook2 = (PageWorkBook) workbook.execute(parameterMap, new PageActor());
PageReport rreport2 = rworkbook2.getPageReport(0);
rworkbook.addReport("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", rreport2);
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪExcel<EFBFBD>ļ<EFBFBD>
OutputStream outputStream = new FileOutputStream(new File("D:\\ExcelExport1.xls"));
PageExcelExporter excelExport = new PageExcelExporter(ReportUtils.getPaperSettingListFromWorkBook(rworkbook));
excelExport.export(outputStream, rworkbook);
outputStream.close();
ModuleContext.stopModules();
} catch (Exception e) {
e.printStackTrace();
}
}
}

35
src/com/fr/io/JavaPrint.java

@ -1,35 +0,0 @@
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.main.TemplateWorkBook;
import com.fr.print.PrintUtils;
import java.util.HashMap;
public class JavaPrint {
public static void main(String[] args) {
// 定义报表运行环境,才能执行报表
String envPath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
try {
TemplateWorkBook workbook = TemplateWorkBookIO.readTemplateWorkBook(FRContext.getCurrentEnv(), "GettingStarted.cpt");
// 参数传值
Parameter[] parameters = workbook.getParameters();
HashMap<String, String> paraMap = new HashMap<String, String>();
paraMap.put(parameters[0].getName(), "华北");
// java中调用报表打印方法
boolean a = PrintUtils.printWorkBook("GettingStarted.cpt", paraMap, true);
if (a == false) {
System.out.println("失败啦!返回" + a);
} else {
System.out.println("成功!返回" + a);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

57
src/com/fr/io/SetParameterWindow.java

@ -1,57 +0,0 @@
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>API
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.background.ColorBackground;
import com.fr.dav.LocalEnv;
import com.fr.general.Background;
import com.fr.general.ModuleContext;
import com.fr.io.exporter.EmbeddedTableDataExporter;
import com.fr.main.impl.WorkBook;
import com.fr.main.parameter.ReportParameterAttr;
import com.fr.report.module.EngineModule;
import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
public class SetParameterWindow {
public static void main(String[] args) {
try {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
String envPath = "D:\\FineReport\\develop\\code\\build\\package\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
ModuleContext.startModule(EngineModule.class.getName());
// <EFBFBD><EFBFBD>ȡģ<EFBFBD><EFBFBD><EFBFBD>ΪWorkBook<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(FRContext.getCurrentEnv(),
"\\doc\\Primary\\Parameter\\Parameter.cpt");
// <EFBFBD><EFBFBD>ȡWorkBook<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ReportParameterAttr
ReportParameterAttr paraAttr = workbook.getReportParameterAttr();
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD>
* 0 : <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* 1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* 2 <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
paraAttr.setAlign(1);
/*
* <EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ColorBackground <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* GradientBackground <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ImageBackground <EFBFBD><EFBFBD>ͼƬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* PatternBackground <EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* TextureBackground <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
Background background = ColorBackground.getInstance(new Color(0, 255, 255));
paraAttr.setBackground(background);
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ս<EFBFBD><EFBFBD>
workbook.setReportParameterAttr(paraAttr);
FileOutputStream outputStream = new FileOutputStream(new File(
"D:\\newParameter.cpt"));
EmbeddedTableDataExporter templateExporter = new EmbeddedTableDataExporter();
templateExporter.export(outputStream, workbook);
} catch (Exception e) {
e.printStackTrace();
}
}
}

49
src/com/fr/io/SimpleDemo.java

@ -1,49 +0,0 @@
//<EFBFBD><EFBFBD>ȡ<EFBFBD>޸ı<EFBFBD><EFBFBD><EFBFBD>
package com.fr.io;
import com.fr.base.FRContext;
import com.fr.base.Style;
import com.fr.dav.LocalEnv;
import com.fr.general.FRFont;
import com.fr.general.ModuleContext;
import com.fr.main.impl.WorkBook;
import com.fr.report.cell.CellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.module.EngineModule;
import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
public class SimpleDemo {
public static void main(String[] args) {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD>
String envPath = "D:\\FineReport_7.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
ModuleContext.startModule(EngineModule.class.getName());
try {
// <EFBFBD><EFBFBD>ȡģ<EFBFBD><EFBFBD>
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(FRContext.getCurrentEnv(),
"\\doc\\Primary\\Parameter\\Parameter.cpt");
// <EFBFBD><EFBFBD><EFBFBD>WorkBook<EFBFBD>е<EFBFBD>WorkSheet<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>A1<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ɫΪ<EFBFBD><EFBFBD>ɫ
TemplateElementCase report = (TemplateElementCase) workbook
.getReport(0);
// getCellElement(int column, int
// row),column<EFBFBD><EFBFBD>row<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>A1<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>0<EFBFBD>е<EFBFBD>0<EFBFBD><EFBFBD>
CellElement cellA1 = report.getCellElement(0, 0);
FRFont frFont = FRFont.getInstance();
frFont = frFont.applyForeground(Color.red);
Style style = Style.getInstance();
style = style.deriveFRFont(frFont);
cellA1.setStyle(style);
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>
FileOutputStream outputStream = new FileOutputStream(new File(
"D:\\newParameter1.cpt"));
((WorkBook) workbook).export(outputStream);
} catch (Exception e) {
e.printStackTrace();
}
}
}

76
src/com/fr/output/FTPUpload.java

@ -1,76 +0,0 @@
package com.fr.output;
import com.fr.data.dao.CompatiableIDFCMapper;
import com.fr.data.dao.ObjectTableMapper;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.schedule.output.AbstractOutputFileAction;
import com.fr.schedule.output.FTPTransmission;
import com.fr.schedule.output.OutputFileAction;
import com.fr.schedule.output.ftp.DefaultFTPTransmit;
import java.io.File;
public class FTPUpload extends AbstractOutputFileAction {
@Override
public ObjectTableMapper objectTableMapper2Register() {
return null;
}
@Override
public long getId() {
return 0;
}
@Override
public File[] getFilesToDealWith(File[] files) {
return files;
}
@Override
public void doFileAction(File[] files) {
FTPTransmission ftp = new FTPTransmission();
ftp.setServerAddress("env.finedevelop.com");
ftp.setPort(58321);
ftp.setSavePath("connie");
ftp.setUsername("fr");
ftp.setPassword("ilovejava");
try {
new DefaultFTPTransmit().transmit(files, ftp.getServerAddress(), ftp.getPort(), ftp.getUsername(), ftp.getPassword(), ftp.getSavePath());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public CompatiableIDFCMapper getExtraOutputFileActionForeignKey() {
return null;
}
@Override
public boolean isEmailNotification() {
// TODO Auto-generated method stub
return false;
}
@Override
public OutputFileAction analyzeJSON(JSONObject arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public JSONObject createJSONConfig() throws JSONException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getJsonTag() {
// TODO Auto-generated method stub
return null;
}
}

100
src/com/fr/output/OutputExcel.java

@ -1,100 +0,0 @@
package com.fr.output;
import com.fr.data.dao.CompatiableIDFCMapper;
import com.fr.data.dao.ObjectTableMapper;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.schedule.output.AbstractOutputFileAction;
import com.fr.schedule.output.OutputFileAction;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public class OutputExcel extends AbstractOutputFileAction {
@Override
public File[] getFilesToDealWith(File[] files) {
return files;
}
@Override
public void doFileAction(File[] files) {
// OutputStream out=new BufferedOutputStream(new FileOutputStream(new File(files.)));;
System.out.println(files[0].getName());
for (int i = 0; i < files.length; i++) {
String name = files[i].getName();
String path = "D:/" + name;
BufferedInputStream in = null;
OutputStream out = null;
try {
out = new BufferedOutputStream(new FileOutputStream(new File(path)));
in = new BufferedInputStream(new FileInputStream(files[i]));
byte[] ba = new byte[in.available()];
in.read(ba);
out.write(ba);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
@Override
public ObjectTableMapper objectTableMapper2Register() {
return null;
}
@Override
public CompatiableIDFCMapper getExtraOutputFileActionForeignKey() {
return null;
}
@Override
public long getId() {
return 0;
}
@Override
public boolean isEmailNotification() {
// TODO Auto-generated method stub
return false;
}
@Override
public OutputFileAction analyzeJSON(JSONObject arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public JSONObject createJSONConfig() throws JSONException {
// TODO Auto-generated method stub
return null;
}
@Override
public String getJsonTag() {
// TODO Auto-generated method stub
return null;
}
}

77
src/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 "";
}
}

11
src/main/java/SimpleService.java

@ -0,0 +1,11 @@
public class SimpleService
{
public String getGreeting(String name)
{
return "你好 " + name;
}
public int getPrice()
{
return new java.util.Random().nextInt(1000);
}
}

8
src/main/java/TestWS2TDClient.java

@ -0,0 +1,8 @@
public class TestWS2TDClient {
public String[][] getTD() {
String[][] a = { { "城市", "销售员", "销售额" }, { "江苏", "Anna", "230" }, { "江苏", "Alex", "190" },
{ "江苏", "Jack", "320" }, { "江苏", "Apple", "210" }, { "浙江", "Faye", "150" }, { "浙江", "Sammi", "280" } };
return a;
}
}

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

@ -0,0 +1,111 @@
package com.fr;
import com.fr.data.NetworkHelper;
import com.fr.decision.mobile.terminal.TerminalHandler;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.decision.webservice.v10.login.LoginService;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.security.JwtUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.web.Device;
import org.jasig.cas.client.validation.Assertion;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
/**
* Created by Zed on 2018/9/11.
*/
public class FrFilter implements Filter {
public FrFilter() {
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
FineLoggerFactory.getLogger().info("fr cas login");
HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse res = (HttpServletResponse) servletResponse;
HttpSession session = req.getSession(true);
FineLoggerFactory.getLogger().info("URL:" + req.getRequestURI());
String username;
//获取cas传递过来的username
Object object = req.getSession().getAttribute("_const_cas_assertion_");
if (object != null) {
Assertion assertion = (Assertion) object;
username = assertion.getPrincipal().getName();
} else {
username = (String) session.getAttribute("edu.yale.its.tp.cas.client.filter.user");
}
try {
//用户名为空,登录请求有问题,直接报错
if (StringUtils.isNotEmpty(username)) {
FineLoggerFactory.getLogger().info("username:" + username);
//获取请求携带的token
Object oldToken = session.getAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME);
//token不存在,或者token过期了,走后台登录方法
if (oldToken == null || !checkTokenValid(req, (String) oldToken, username)) {
login(req, res, session, username);
filterChain.doFilter(req, res);
} else {
//放行
filterChain.doFilter(req, res);
FineLoggerFactory.getLogger().info("no need");
}
} else {
throw new Exception("username is empty");
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
* 后台登录方法
*/
private void login(HttpServletRequest req, HttpServletResponse res, HttpSession session, String username) throws Exception {
String token = LoginService.getInstance().login(req, res, username);
req.setAttribute(DecisionServiceConstants.FINE_AUTH_TOKEN_NAME, token);
FineLoggerFactory.getLogger().info("fr FrFilter is over with username is ###" + username);
}
/**
* 校验token是否有效
*/
private boolean checkTokenValid(HttpServletRequest req, String token, String currentUserName) {
try {
//当前登录用户和token对应的用户名不同,需要重新生成token
if (!ComparatorUtils.equals(currentUserName, JwtUtils.parseJWT(token).getSubject())) {
FineLoggerFactory.getLogger().info("username changed:" + currentUserName);
return false;
}
Device device = NetworkHelper.getDevice(req);
LoginService.getInstance().loginStatusValid(token, TerminalHandler.getTerminal(req, device));
return true;
} catch (Exception ignore) {
}
return false;
}
@Override
public void destroy() {
}
}

60
src/main/java/com/fr/FrLoginFilter.java

@ -0,0 +1,60 @@
package com.fr;
import com.fr.decision.authority.data.User;
import com.fr.decision.webservice.exception.user.UserNotExistException;
import com.fr.decision.webservice.v10.login.LoginService;
import com.fr.decision.webservice.v10.login.TokenResource;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.web.utils.WebUtils;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class FrLoginFilter implements Filter {
public FrLoginFilter() {
}
public void init(FilterConfig filterConfig) throws ServletException {
}
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest)servletRequest;
HttpServletResponse res = (HttpServletResponse)servletResponse;
String username = WebUtils.getHTTPRequestParameter(req, "username");
try {
if (StringUtils.isNotEmpty(username)) {
FineLoggerFactory.getLogger().error("username:" + username);
User user = UserService.getInstance().getUserByUserName(username);
if (user == null) {
throw new UserNotExistException();
}
String oldToken = TokenResource.COOKIE.getToken(req);
if (oldToken == null) {
String token = LoginService.getInstance().login(req, res, username);
req.setAttribute("fine_auth_token", token);
filterChain.doFilter(req, res);
} else {
filterChain.doFilter(req, res);
}
} else {
filterChain.doFilter(req, res);
}
} catch (Exception var10) {
FineLoggerFactory.getLogger().error(var10.getMessage(), var10);
}
}
public void destroy() {
}
}

228
src/main/java/com/fr/HttpUtil.java

@ -0,0 +1,228 @@
package com.fr;
import java.security.*;
import javax.net.ssl.*;
import com.fr.third.org.hsqldb.lib.*;
import java.net.*;
import java.io.*;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;
public class HttpUtil
{
private static final String DEFAULT_CHARSET = "UTF-8";
private static final String METHOD_POST = "POST";
private static final String METHOD_GET = "GET";
private static final int CONNECTTIMEOUT = 5000;
private static final int READTIMEOUT = 5000;
private static class DefaultTrustManager implements X509TrustManager {
@Override
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
private static HttpURLConnection getConnection(final URL url, final String method, final String ctype) throws IOException {
HttpURLConnection conn = null;
if ("https".equals(url.getProtocol())) {
SSLContext ctx = null;
try {
ctx = SSLContext.getInstance("TLS");
ctx.init(new KeyManager[0], new TrustManager[] { new DefaultTrustManager() }, new SecureRandom());
}
catch (Exception e) {
throw new IOException(e);
}
final HttpsURLConnection connHttps = (HttpsURLConnection)url.openConnection();
connHttps.setSSLSocketFactory(ctx.getSocketFactory());
connHttps.setHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
});
conn = connHttps;
}
else {
conn = (HttpURLConnection)url.openConnection();
}
conn.setRequestMethod(method);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("User-Agent", "quantangle- apiclient-java");
conn.setRequestProperty("Content-Type", ctype);
conn.setRequestProperty("Connection", "Keep-Alive");
return conn;
}
public static String doGet(final String url, final Map<String, String> params) throws IOException {
return doGet(url, params, "UTF-8");
}
public static String doGet(String url, final Map<String, String> params, final String charset) throws IOException {
if (StringUtil.isEmpty(url) || params == null) {
return null;
}
String response = "";
url = url + "?" + buildQuery(params, charset);
HttpURLConnection conn = null;
final String ctype = "application/x-www-form- urlencoded;charset=" + charset;
conn = getConnection(new URL(url), "GET", ctype);
response = getResponseAsString(conn);
return response;
}
public static String doPost(final String url, final Map<String, String> params) throws IOException {
return doPost(url, params, 5000, 5000);
}
public static String doPost(final String url, final Map<String, String> params, final int connectTimeOut, final int readTimeOut) throws IOException {
return doPost(url, params, "UTF-8", connectTimeOut, readTimeOut);
}
public static String doPost(final String url, final Map<String, String> params, final String charset, final int connectTimeOut, final int readTimeOut) throws IOException {
HttpURLConnection conn = null;
String response = "";
final String ctype = "application/x-www-form- urlencoded;charset=" + charset;
conn = getConnection(new URL(url), "POST", ctype);
conn.setConnectTimeout(connectTimeOut);
conn.setReadTimeout(readTimeOut);
conn.getOutputStream().write(buildQuery(params, charset).getBytes(charset));
response = getResponseAsString(conn);
return response;
}
public static String buildQuery(final Map<String, String> params, final String charset) {
if (params == null || params.isEmpty()) {
return null;
}
final StringBuilder sb = new StringBuilder();
boolean first = true;
for (final Map.Entry<String, String> entry : params.entrySet()) {
if (first) {
first = false;
}
else {
sb.append("&");
}
final String key = entry.getKey();
final String value = entry.getValue();
if (!StringUtil.isEmpty(key) && !StringUtil.isEmpty(value)) {
try {
sb.append(key).append("=").append(URLEncoder.encode(value, charset));
}
catch (UnsupportedEncodingException ex) {}
}
}
return sb.toString();
}
public static Map<String, String> splitQuery(final String query, final String charset) {
final Map<String, String> ret = new HashMap<String, String>();
if (!StringUtil.isEmpty(query)) {
final String[] split2;
final String[] splits = split2 = query.split("\\&");
for (final String split : split2) {
final String[] keyAndValue = split.split("\\=");
boolean flag = true;
for (int i = 0, len = keyAndValue.length; i < len; ++i) {
if (StringUtil.isEmpty(keyAndValue[i])) {
flag = false;
break;
}
}
if (flag && keyAndValue.length == 2) {
try {
ret.put(keyAndValue[0], URLDecoder.decode(keyAndValue[1], charset));
}
catch (UnsupportedEncodingException ex) {}
}
}
}
return ret;
}
private static byte[] getTextEntry(final String fieldName, final String fieldValue, final String charset) throws IOException {
final StringBuilder entry = new StringBuilder();
entry.append("Content-Disposition:form-data;name=\"");
entry.append(fieldName);
entry.append("\"\r\nContent-Type:text/plain\r\n\r\n");
entry.append(fieldValue);
return entry.toString().getBytes(charset);
}
private static byte[] getFileEntry(final String fieldName, final String fileName, final String mimeType, final String charset) throws IOException {
final StringBuilder entry = new StringBuilder();
entry.append("Content-Disposition:form-data;name=\"");
entry.append(fieldName);
entry.append("\";filename=\"");
entry.append(fileName);
entry.append("\"\r\nContent-Type:");
entry.append(mimeType);
entry.append("\r\n\r\n");
return entry.toString().getBytes(charset);
}
private static String getResponseAsString(final HttpURLConnection conn) throws IOException {
final String charset = getResponseCharset(conn.getContentType());
final InputStream es = conn.getErrorStream();
if (es == null) {
return getStreamAsString(conn.getInputStream(), charset);
}
final String msg = getStreamAsString(es, charset);
if (StringUtil.isEmpty(msg)) {
throw new IOException("{\"" + conn.getResponseCode() + "\":\"" + conn.getResponseMessage() + "\"}");
}
throw new IOException(msg);
}
private static String getStreamAsString(final InputStream input, final String charset) throws IOException {
final StringBuilder sb = new StringBuilder();
BufferedReader bf = null;
try {
bf = new BufferedReader(new InputStreamReader(input, charset));
String str;
while ((str = bf.readLine()) != null) {
sb.append(str);
}
return sb.toString();
}
finally {
if (bf != null) {
bf.close();
bf = null;
}
}
}
private static String getResponseCharset(final String ctype) {
String charset = "UTF-8";
if (!StringUtil.isEmpty(ctype)) {
final String[] split;
final String[] params = split = ctype.split("\\;");
for (String param : split) {
param = param.trim();
if (param.startsWith("charset")) {
final String[] pair = param.split("\\=");
if (pair.length == 2) {
charset = pair[1].trim();
}
}
}
}
return charset;
}
}

111
src/main/java/com/fr/SSLConnectionClient.java

@ -0,0 +1,111 @@
package com.fr;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URL;
import java.net.URLConnection;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.oltu.oauth2.client.HttpClient;
import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
import org.apache.oltu.oauth2.client.response.OAuthClientResponse;
import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory;
import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
import org.apache.oltu.oauth2.common.utils.OAuthUtils;
public class SSLConnectionClient implements HttpClient {
public SSLConnectionClient() {
}
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers, String requestMethod, Class<T> responseClass) throws OAuthSystemException, OAuthProblemException {
String responseBody = null;
URLConnection c = null;
boolean var7 = false;
int responseCode;
try {
URL url = new URL(request.getLocationUri());
c = url.openConnection();
responseCode = -1;
if (c instanceof HttpsURLConnection) {
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) c;
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init((KeyManager[]) null, new TrustManager[]{new TrustAnyTrustManager()}, new SecureRandom());
httpsURLConnection.setSSLSocketFactory(sslContext.getSocketFactory());
httpsURLConnection.setHostnameVerifier(new TrustAnyHostnameVerifier());
if (headers != null && !headers.isEmpty()) {
Iterator var11 = headers.entrySet().iterator();
while (var11.hasNext()) {
Entry<String, String> header = (Entry) var11.next();
httpsURLConnection.addRequestProperty((String) header.getKey(), (String) header.getValue());
}
}
if (!OAuthUtils.isEmpty(requestMethod)) {
httpsURLConnection.setRequestMethod(requestMethod);
if (requestMethod.equals("POST")) {
httpsURLConnection.setDoOutput(true);
OutputStream ost = httpsURLConnection.getOutputStream();
PrintWriter pw = new PrintWriter(ost);
pw.print(request.getBody());
pw.flush();
pw.close();
}
} else {
httpsURLConnection.setRequestMethod("GET");
}
httpsURLConnection.connect();
responseCode = httpsURLConnection.getResponseCode();
InputStream inputStream;
if (responseCode == 400) {
inputStream = httpsURLConnection.getErrorStream();
} else {
inputStream = httpsURLConnection.getInputStream();
}
responseBody = OAuthUtils.saveStreamAsString(inputStream);
}
} catch (Exception var13) {
throw new OAuthSystemException(var13);
}
return OAuthClientResponseFactory.createCustomResponse(responseBody, c.getContentType(), responseCode, responseClass);
}
public void shutdown() {
}
static class TrustAnyTrustManager implements X509TrustManager {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
}
static class TrustAnyHostnameVerifier implements HostnameVerifier {
public boolean verify(String hostname, SSLSession session) {
return true;
}
}
}

0
src/com/fr/StartFRDesigner.java → src/main/java/com/fr/StartFRDesigner.java

58
src/main/java/com/fr/Test2.java

@ -0,0 +1,58 @@
import com.fr.cert.token.JwtBuilder;
import com.fr.cert.token.Jwts;
import com.fr.cert.token.SignatureAlgorithm;
import sun.misc.BASE64Encoder;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.Date;
public class Test2 {
public static void main(String[] args) {
//数字签名有效时长
long validTime = 30 * 60 * 1000;
//数字签名内容,以访问资源的相对路径作为内容
String path = "GettingStarted.cpt";
//数字签名用的HS256的密钥
String key = createSecret();
//生成fine_digital_signature
String fine_digital_signature = createJwt("", "", path, validTime, key);
//输出密钥
System.out.println(key);
//输出fine_digital_signature
System.out.println(fine_digital_signature);
}
private static String createJwt(String issuer, String id, String subject, long validTime, String key) {
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
Date currentTime = new Date();
Date expirationTime = new Date(currentTime.getTime() + validTime);
JwtBuilder builder = Jwts.builder()
.setIssuer(issuer)
.setSubject(subject)
.setIssuedAt(currentTime)
.setExpiration(expirationTime)
.setId(id)
.signWith(signatureAlgorithm, key);
return builder.compact();
}
private static String createSecret() {
try {
//secret可以自定义的
String secret = "2222222";
String message = "";
Mac sha256Hmac = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
sha256Hmac.init(secret_key);
BASE64Encoder encoder = new BASE64Encoder();
String hash = encoder.encode(sha256Hmac.doFinal(message.getBytes()));
return hash;
} catch (Exception e) {
System.out.println(e.getMessage());
}
return "";
}
}

3
src/com/fr/data/ArrayTableDataDemo.java → src/main/java/com/fr/data/ArrayTableDataDemo.java

@ -1,8 +1,5 @@
package com.fr.data;
/**
* @author fanruan
*/
public class ArrayTableDataDemo extends AbstractTableData {
/**
* 定义程序数据集的列名与数据保存位置

0
src/com/fr/data/Commit3.java → src/main/java/com/fr/data/Commit3.java

0
src/com/fr/data/CustomTableData.java → src/main/java/com/fr/data/CustomTableData.java

31
src/com/fr/data/DataModelDemo.java → src/main/java/com/fr/data/DataModelDemo.java

@ -1,50 +1,29 @@
package com.fr.data;
import examples.ejb.ejb20.basic.beanManaged.Account;
import examples.ejb.ejb20.basic.beanManaged.AccountHome;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
/**
* @author fanruan
*/
import javax.naming.*;
import java.util.*;
import examples.ejb.ejb20.basic.beanManaged.*;
public class DataModelDemo extends AbstractTableData {
private String[] columnNames;
private ArrayList valueList = null;
public DataModelDemo() {
String[] columnNames = {"Name", "Score"};
String[] columnNames = { "Name", "Score" };
this.columnNames = columnNames;
}
// 实现其他四个方法
@Override
public int getColumnCount() {
return columnNames.length;
}
@Override
public String getColumnName(int columnIndex) {
return columnNames[columnIndex];
}
@Override
public int getRowCount() {
init();
return valueList.size();
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
init();
return ((Object[]) valueList.get(rowIndex))[columnIndex];
}
// 准备数据
public void init() {
// 确保只被执行一次
@ -72,7 +51,7 @@ public class DataModelDemo extends AbstractTableData {
Account bigAccount = (Account) iter.next();
objArray = new Object[2];
objArray[0] = bigAccount.getPrimaryKey();
objArray[1] = bigAccount.balance();
objArray[1] = new Double(bigAccount.balance());
// 在valueList中加入这一行数据
valueList.add(objArray);
}

0
src/com/fr/data/DemoSubmitJob1.java → src/main/java/com/fr/data/DemoSubmitJob1.java

0
src/com/fr/data/DemoSubmitJob2.java → src/main/java/com/fr/data/DemoSubmitJob2.java

0
src/com/fr/data/DemoTotalSubmitJob.java → src/main/java/com/fr/data/DemoTotalSubmitJob.java

0
src/com/fr/data/GetXmlData.java → src/main/java/com/fr/data/GetXmlData.java

5
src/com/fr/data/GetXmlDate.java → src/main/java/com/fr/data/GetXmlDate.java

@ -1,11 +1,10 @@
package com.fr.data;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLableReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLableReader;
public class GetXmlDate {
// 定义返回值数组

4
src/com/fr/data/MobileTableWsdlDataDemo.java → src/main/java/com/fr/data/MobileTableWsdlDataDemo.java

@ -20,7 +20,7 @@ public class MobileTableWsdlDataDemo extends AbstractTableData {
private String[][] data;
public MobileTableWsdlDataDemo() {
this.data = this.getData();
this.data = this.getMobileTableWsdlData();
}
@Override
@ -82,7 +82,7 @@ public class MobileTableWsdlDataDemo extends AbstractTableData {
}
public String[][] getData() {
public String[][] getMobileTableWsdlData() {
try {
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
EndpointReference targetEPR = new EndpointReference(url);

6
src/com/fr/data/MobileWsdlTableDataDemo.java → src/main/java/com/fr/data/MobileWsdlTableDataDemo.java

@ -23,7 +23,7 @@ public class MobileWsdlTableDataDemo extends AbstractTableData {
private String[][] data;
public MobileWsdlTableDataDemo() {
this.data = this.getData();
this.data = this.getMobileWsdlTableData();
}
public int getColumnCount() throws TableDataException {
@ -78,7 +78,7 @@ public class MobileWsdlTableDataDemo extends AbstractTableData {
}
public String[][] getData() {
public String[][] getMobileWsdlTableData() {
try {
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
EndpointReference targetEPR = new EndpointReference(url);
@ -102,8 +102,6 @@ public class MobileWsdlTableDataDemo extends AbstractTableData {
OMElement result1 = sender.sendReceive(method);
String[][] result = getResults(result1);
return result;
} catch (org.apache.axis2.AxisFault e) {
e.printStackTrace();
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}

6
src/com/fr/data/MobileWsdlTableDataDemo1.java → src/main/java/com/fr/data/MobileWsdlTableDataDemo1.java

@ -17,7 +17,7 @@ public class MobileWsdlTableDataDemo1 extends AbstractTableData {
private String[][] data;
public MobileWsdlTableDataDemo1() {
this.data = this.getData();
this.data = this.getMobileWsdlTableData();
}
public int getColumnCount() throws TableDataException {
@ -72,7 +72,7 @@ public class MobileWsdlTableDataDemo1 extends AbstractTableData {
}
public String[][] getData() {
public String[][] getMobileWsdlTableData() {
try {
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
EndpointReference targetEPR = new EndpointReference(url);
@ -98,8 +98,6 @@ public class MobileWsdlTableDataDemo1 extends AbstractTableData {
return result;
} catch (org.apache.axis2.AxisFault e) {
e.printStackTrace();
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}
return new String[][]{{}};
}

0
src/com/fr/data/MobileWsdlTableDataDemo2.java → src/main/java/com/fr/data/MobileWsdlTableDataDemo2.java

6
src/com/fr/data/MobileWsdlTableDataDemoPara.java → src/main/java/com/fr/data/MobileWsdlTableDataDemoPara.java

@ -18,7 +18,7 @@ public class MobileWsdlTableDataDemoPara extends AbstractTableData {
private String[][] data;
public MobileWsdlTableDataDemoPara() {
this.data = this.getData();
this.data = this.getMobileWsdlTableData();
}
public int getColumnCount() throws TableDataException {
@ -69,7 +69,7 @@ public class MobileWsdlTableDataDemoPara extends AbstractTableData {
}
public String[][] getData() {
public String[][] getMobileWsdlTableData() {
try {
FRLogger.getLogger().error("进入了");
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
@ -99,8 +99,6 @@ public class MobileWsdlTableDataDemoPara extends AbstractTableData {
OMElement result1 = sender.sendReceive(method);
String[][] result = getResults(result1);
return result;
} catch (org.apache.axis2.AxisFault e) {
e.printStackTrace();
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}

16
src/com/fr/data/ParamSAPDataTest.java → src/main/java/com/fr/data/ParamSAPDataTest.java

@ -2,12 +2,16 @@ package com.fr.data;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.config.holder.impl.xml.XmlColConf;
import com.fr.function.ConnectSAPServer;
import com.fr.stable.ParameterProvider;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoTable;
import java.util.ArrayList;
public class ParamSAPDataTest extends AbstractTableData {
private String[] columnNames = null;
@ -18,8 +22,10 @@ public class ParamSAPDataTest extends AbstractTableData {
private static JCoDestination jCoDestination;
public ParamSAPDataTest() {
this.parameters = new Parameter[]{new Parameter("LIFNR"),
new Parameter("NAME1")};
ArrayList<ParameterProvider> arrayList = new ArrayList<>();
arrayList.add(new Parameter("LIFNR"));
arrayList.add(new Parameter("NAME1"));
this.parameters = new XmlColConf<>(arrayList, ParameterProvider.class);
this.columnNames = new String[this.columnNum];
this.columnNames[0] = "供应商编码";
@ -69,8 +75,10 @@ public class ParamSAPDataTest extends AbstractTableData {
if (function == null)
throw new RuntimeException(
"Function not found in SAP.");
function.getImportParameterList().setValue("LIFNR", "%" + this.parameters[0].getValue().toString().toUpperCase().trim() + "%");
function.getImportParameterList().setValue("NAME1", "%" + this.parameters[1].getValue().toString().toUpperCase().trim() + "%");
function.getImportParameterList().setValue("LIFNR", "%" +
((ParameterProvider) (parameters.get().toArray()[0])).getValue().toString().toUpperCase().trim() + "%");
function.getImportParameterList().setValue("NAME1", "%" + ((ParameterProvider) (parameters.get().toArray()[1]))
.getValue().toString().toUpperCase().trim() + "%");
function.execute(jCoDestination);
JCoTable returnTable = function.getTableParameterList().getTable(
"ZLFA1S3");

30
src/com/fr/data/ParamTableDataDemo.java → src/main/java/com/fr/data/ParamTableDataDemo.java

@ -2,11 +2,14 @@ package com.fr.data;
import com.fr.base.FRContext;
import com.fr.file.DatasourceManager;
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;
@ -50,11 +53,13 @@ public class ParamTableDataDemo extends AbstractTableData {
*/
@Override
public int getColumnCount() {
init();
return columnNum;
}
@Override
public String getColumnName(int columnIndex) {
init();
return columnNames[columnIndex];
}
@ -82,8 +87,7 @@ public class ParamTableDataDemo extends AbstractTableData {
return;
}
// 保存得到的数据库表名
String tableName = parameters[0].getValue().toString();
String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString();
// 构造SQL语句,并打印出来
String sql = "select * from " + tableName;
@ -91,10 +95,11 @@ public class ParamTableDataDemo extends AbstractTableData {
// 保存得到的结果集
valueList = new ArrayList();
// 下面开始建立数据库连接,按照刚才的SQL语句进行查询
// 根据连接名获取FR数据连接定义的数据连接,如果没有定义,也可以参考getConnection方法自己创建连接
com.fr.data.impl.Connection conn = DatasourceManager.getInstance().getConnection("FRDemo");
Connection con = null;
try {
Connection con = conn.createConnection();
con = conn.createConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
// 获得记录的详细信息,然后获得总列数
@ -117,7 +122,15 @@ public class ParamTableDataDemo extends AbstractTableData {
// 打印一共取到的数据行数量
} 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);
}
}
}
}
@ -129,17 +142,16 @@ public class ParamTableDataDemo extends AbstractTableData {
public Connection getConnection() {
String driverName = "org.sqlite.JDBC";
String url = "jdbc:sqlite://E:\\8.0-master\\env\\WebReport\\FRDemo.db";
String url = "jdbc:sqlite:////Applications//FineReport10_325//webapps//webroot//help//FRDemo.db";
String username = "";
String password = "";
Connection con;
Connection con = null;
try {
Class.forName(driverName);
con = DriverManager.getConnection(url, username, password);
} catch (Exception e) {
e.printStackTrace();
return null;
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
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;
}
}

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

@ -0,0 +1,86 @@
package com.fr.data;
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.Service;
import javax.xml.namespace.QName;
import java.util.ArrayList;
import java.util.List;
public class WebServiceTableData extends SimpleTableData {
/**
* 初始化列名数组
*
* @return {col1,col2,col3...}
* @throws TableDataException
*/
@Override
public String[] initColumnNames() {
String[] columnNames = new String[10];
for (int i = 0; i < 10; i++) {
columnNames[i] = "column#" + i;
}
return columnNames;
}
/**
* 加载数据
*
* @return 行列数据
*/
@Override
public List<Object[]> loadData() {
String tableName = ((ParameterProvider) (parameters.get().toArray())[0]).getValue().toString();
FineLoggerFactory.getLogger().info("Query SQL of ParamTableDataDemo: \n" + tableName);
// 保存得到的结果集
ArrayList<Object[]> valueList = new ArrayList();
try {
// 调用 Web 服务获取数据
String[][] data = createData();
// 如果数据为空,直接返回空列表
if (data == null || data.length == 0) {
return valueList;
}
// 获得总列数
int colNum = data[0].length;
// 用对象保存数据
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;
}
public String[][] createData() {
try {
String endpoint = "http://localhost:8080/axis/TestWS2TDClient.jws";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName(new QName("http://localhost:8080/axis/TestWS2TDClient.jws",
"getTD"));
String[][] ret = (String[][])call.invoke(new Object[] {});
return ret;
} catch (Exception e) {
e.printStackTrace();
}
return new String[][] {};
}
}

10
src/com/fr/data/WebServiceWsdlTableDataDemo2.java → src/main/java/com/fr/data/WebServiceWsdlTableDataDemo2.java

@ -11,7 +11,7 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData {
private String[][] data;
public WebServiceWsdlTableDataDemo2() {
this.data = this.getData();
this.data = this.getWebServiceWsdlTableData();
}
public int getColumnCount() throws TableDataException {
@ -33,7 +33,7 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData {
return data[rowIndex + 1][columnIndex];
}
public String[][] getData() {
public String[][] getWebServiceWsdlTableData() {
try {
String url = "http://www.webxml.com.cn/WebServices/MobileCodeWS.asmx?wsdl";
MobileCodeWSStub stub = new MobileCodeWSStub(url);
@ -55,8 +55,6 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData {
}
}
return result;
} catch (org.apache.axis2.AxisFault e) {
e.printStackTrace();
} catch (java.rmi.RemoteException e) {
e.printStackTrace();
}
@ -64,8 +62,8 @@ public class WebServiceWsdlTableDataDemo2 extends AbstractTableData {
}
public static void main(String[] args) {
for (int i = 0; i < new WebServiceWsdlTableDataDemo2().getData().length; i++) {
System.out.println(new WebServiceWsdlTableDataDemo2().getData()[i]);
for (int i = 0; i < new WebServiceWsdlTableDataDemo2().getWebServiceWsdlTableData().length; i++) {
System.out.println(new WebServiceWsdlTableDataDemo2().getWebServiceWsdlTableData()[i]);
}
}
}

0
src/com/fr/data/XMLColumnNameType4Demo.java → src/main/java/com/fr/data/XMLColumnNameType4Demo.java

84
src/com/fr/data/XMLDemoTableData.java → src/main/java/com/fr/data/XMLDemoTableData.java

@ -1,27 +1,26 @@
package com.fr.data;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.*;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import com.fr.base.Parameter;
import com.fr.general.data.DataModel;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.XMLEvent;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import com.fr.config.holder.impl.xml.XmlColConf;
/**
* XMLDemoTableData
* <p>
*
* 这是一个按参数来解析不同地址XML文件的demo
* <p>
*
* AbstractParameterTableData 包装了有参数数据集的基本实现
*/
public class XMLDemoTableData extends AbstractParameterTableData {
@ -29,8 +28,9 @@ public class XMLDemoTableData extends AbstractParameterTableData {
// 构造函数
public XMLDemoTableData() {
// 定义需要的参数,这里定义一个参数,参数名为filename,给其一个默认值"Northwind.xml"
this.parameters = new Parameter[1];
this.parameters[0] = new Parameter("filename", "Northwind");
Parameter[] parameters = new Parameter[1];
parameters[0] = new Parameter("filename", "Northwind");
setParameters(parameters);
}
/**
@ -49,17 +49,18 @@ public class XMLDemoTableData extends AbstractParameterTableData {
if (params[i] == null) continue;
if ("filename".equals(params[i].getName())) {
filename = (String) params[i].getValue();
filename = (String)params[i].getValue();
}
}
String filePath;
if (StringUtils.isBlank(filename)) {
filePath = "D://DefaultFile.xml";
filePath = "/Users/susie/Downloads/DefaultFile.xml";
} else {
filePath = "D://" + filename + ".xml";
filePath = "/Users/susie/Downloads/" + filename + ".xml";
}
// 定义需要解析的数据列,机器
// XMLColumnNameType4Demo[] columns = new XMLColumnNameType4Demo[7];
// columns[0] = new XMLColumnNameType4Demo("CustomerID", XMLParseDemoDataModel.COLUMN_TYPE_STRING);
@ -70,19 +71,21 @@ public class XMLDemoTableData extends AbstractParameterTableData {
// columns[5] = new XMLColumnNameType4Demo("City", XMLParseDemoDataModel.COLUMN_TYPE_STRING);
// columns[6] = new XMLColumnNameType4Demo("Phone", XMLParseDemoDataModel.COLUMN_TYPE_STRING);
List list = new ArrayList();
List list=new ArrayList();
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
InputStream in;
try {
in = new BufferedInputStream(new FileInputStream(new File(filePath)));
XMLEventReader reader = inputFactory.createXMLEventReader(in);
readCol(reader, list);
deep=0;
flag=false;
readCol(reader,list);
in.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
XMLColumnNameType4Demo[] columns = (XMLColumnNameType4Demo[]) list.toArray(new XMLColumnNameType4Demo[0]);
XMLColumnNameType4Demo[] columns=(XMLColumnNameType4Demo[])list.toArray(new XMLColumnNameType4Demo[0]);
// 定义解析的数据在xml文件结构中的位置
@ -114,12 +117,10 @@ public class XMLDemoTableData extends AbstractParameterTableData {
// 构造一个实际去取值的执行对象
return new XMLParseDemoDataModel(filePath, xpath, columns);
}
private int deep = 0;
private static final int COL_DEEP = 3;
private boolean flag = false;
private void readCol(XMLEventReader reader, List list)
private int deep=0;
private static final int COL_DEEP=3;
private boolean flag=false;
private void readCol(XMLEventReader reader,List list)
throws XMLStreamException {
while (reader.hasNext()) {
XMLEvent event = reader.nextEvent();
@ -127,20 +128,20 @@ public class XMLDemoTableData extends AbstractParameterTableData {
//deep是控制层数的,只把xml中对应的层的加入到列名中
deep++;
//表示已经进入到了列名那一层
if (deep == COL_DEEP) {
flag = true;
if(deep==COL_DEEP){
flag=true;
}
//如果在高层,并且已经进入到了col层,则退出
if (deep < COL_DEEP && flag) {
if(deep<COL_DEEP&&flag){
return;
}
if (deep != COL_DEEP) {
if(deep!=COL_DEEP){
continue;
}
// println("name: " + event.asStartElement().getName());
XMLColumnNameType4Demo column = new XMLColumnNameType4Demo(event.asStartElement().getName().toString(), XMLParseDemoDataModel.COLUMN_TYPE_STRING);
XMLColumnNameType4Demo column=new XMLColumnNameType4Demo(event.asStartElement().getName().toString(), XMLParseDemoDataModel.COLUMN_TYPE_STRING);
list.add(column);
readCol(reader, list);
readCol(reader,list);
} else if (event.isCharacters()) {
//对数据值不做处理
} else if (event.isEndElement()) {
@ -158,14 +159,14 @@ public class XMLDemoTableData extends AbstractParameterTableData {
//deep是控制层数的,只把xml中对应的层的加入到列名中
deep++;
//表示已经进入到了列名那一层
if (deep == COL_DEEP) {
flag = true;
if(deep==COL_DEEP){
flag=true;
}
//如果在高层,并且已经进入到了col层,则退出
if (deep < COL_DEEP && flag) {
if(deep<COL_DEEP&&flag){
return;
}
if (deep != COL_DEEP) {
if(deep!=COL_DEEP){
continue;
}
System.out.println("name: " + event.asStartElement().getName());
@ -178,17 +179,16 @@ public class XMLDemoTableData extends AbstractParameterTableData {
}
}
}
public static void main(String[] args) {
public static void main(String[] args){
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
// in = new FileReader(new File(filePath));
// XMLEventReader reader = inputFactory.createXMLEventReader(in);
// readCol(reader,list);
BufferedInputStream in;
try {
in = new BufferedInputStream(new FileInputStream(new File("D:/tmp/f.xml")));
byte[] ba = new byte[3];
in.read(ba, 0, 3);
in = new BufferedInputStream(new FileInputStream(new File("/Users/susie/Downloads/f.xml")));
byte[] ba=new byte[3];
in.read(ba,0,3);
// System.out.println(in)
XMLEventReader reader = inputFactory.createXMLEventReader(in);
new XMLDemoTableData().readCol0(reader);

25
src/com/fr/data/XMLParseDemoDataModel.java → src/main/java/com/fr/data/XMLParseDemoDataModel.java

@ -1,23 +1,22 @@
package com.fr.data;
import com.fr.base.FRContext;
import com.fr.general.ComparatorUtils;
import com.fr.general.data.TableDataException;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import com.fr.base.FRContext;
import com.fr.general.ComparatorUtils;
import com.fr.general.data.TableDataException;
/**
* XMLParseDemoDataModel
* <p>
*
* DataModel是获取数据的接口
* <p>
*
* 这里通过init方法一次性取数后构造一个二维表对象来实现DataModel的各个取数方法
*/
public class XMLParseDemoDataModel extends AbstractDataModel {
@ -98,9 +97,7 @@ public class XMLParseDemoDataModel extends AbstractDataModel {
/** ************************************************** */
/** ************以下为解析XML文件的方法**************** */
/**
* *************************************************
*/
/** ************************************************** */
// 一次性将数据取出来
protected void init() throws TableDataException {

65
src/com/fr/data/XMLRead.java → src/main/java/com/fr/data/XMLRead.java

@ -1,44 +1,33 @@
package com.fr.data;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.io.StringBufferInputStream;
/**
* @author fanruan
*/
public class XMLRead extends AbstractTableData {
/**
* 列名数组保存程序数据集所有列名
*/
private String[] columnNames = {"id", "name", "MemoryFreeSize",
"MemoryTotalSize", "MemoryUsage"};
/**
* 保存表数据
*/
// 列名数组,保存程序数据集所有列名
private String[] columnNames = { "id", "name", "MemoryFreeSize",
"MemoryTotalSize", "MemoryUsage" };
// 保存表数据
private ArrayList valueList = null;
@Override
public int getColumnCount() {
return 5;
}
@Override
public String getColumnName(int columnIndex) {
return columnNames[columnIndex];
}
@Override
public int getRowCount() {
init();
return valueList.size();
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
init();
return ((Object[]) valueList.get(rowIndex))[columnIndex];
@ -50,29 +39,28 @@ public class XMLRead extends AbstractTableData {
return;
}
valueList = new ArrayList();
String sql = "SELECT * FROM xmltest";
String[] name = {"MemoryFreeSize", "MemoryTotalSize", "MemoryUsage"};
Connection conn = this.getConnection();
String sql = "select * from xmltest";
String[] name = { "MemoryFreeSize", "MemoryTotalSize", "MemoryUsage" };
Connection conn = this.getConncetion();
try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
// 用对象保存数据
Object[] objArray;
Object[] objArray = null;
while (rs.next()) {
objArray = new Object[5];
String[] xmlData;
String[] xmldata = null;
objArray[0] = rs.getObject(1);
objArray[1] = rs.getObject(2);
InputStream in;
String str = "中文stream";
in = new ByteArrayInputStream(str.getBytes("UTF-8"));
GetXmlData getXMLData = new GetXmlData();
InputStream in = new StringBufferInputStream("<demo>"
+ rs.getObject(3).toString() + "</demo>");
GetXmlDate getxmldata = new GetXmlDate();
// 对xml流进行解析,返回的为name对应的value值数组
xmlData = getXMLData.readerXMLSource(in, name);
xmldata = getxmldata.readerXMLSource(in, name);
// 将解析后的值存于最终结果ArrayList中
objArray[2] = xmlData[0];
objArray[3] = xmlData[1];
objArray[4] = xmlData[2];
objArray[2] = xmldata[0];
objArray[3] = xmldata[1];
objArray[4] = xmldata[2];
valueList.add(objArray);
}
// 释放数据源
@ -84,12 +72,12 @@ public class XMLRead extends AbstractTableData {
}
}
private Connection getConnection() {
String driverName = "oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@env.finedevelop.com:55702:fr";
String username = "system";
String password = "123";
Connection con;
public Connection getConncetion() {
String driverName = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://review.finedevelop.com:3306/susie";
String username = "root";
String password = "ilovejava";
Connection con = null;
try {
Class.forName(driverName);
@ -102,12 +90,7 @@ public class XMLRead extends AbstractTableData {
}
/**
* 释放一些资源因为可能会有重复调用所以需释放valueList将上次查询的结果释放掉
*
* @throws Exception e
*/
@Override
// 释放一些资源,因为可能会有重复调用,所以需释放valueList,将上次查询的结果释放掉
public void release() throws Exception {
super.release();
this.valueList = null;

0
src/com/fr/data/impl/Commit1.java → src/main/java/com/fr/data/impl/Commit1.java

0
src/com/fr/data/impl/Commit3.java → src/main/java/com/fr/data/impl/Commit3.java

50
src/main/java/com/fr/data/session.java

@ -0,0 +1,50 @@
package com.fr.data;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.String;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.fr.stable.CodeUtils;
public class session extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html; charset=gb2312");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
String urlid=request.getParameter("id"); //获取url通过ajax传递的值
HttpSession session=request.getSession(true);
if(urlid==""||urlid==null){
out.print("<form action=\"");
out.print("session\" ");
out.println("method=POST>");
out.println("set session:<input type=text name=sessionvalue>");
out.println("<input type=submit name=bbb value=tijiao>");
out.println("</form>");
if(request.getParameter("sessionvalue")!=null&&request.getParameter("sessionvalue")!=""){
session.setAttribute("sessionname", request.getParameter("sessionvalue"));
}
}
else{
urlid = CodeUtils.decodeText(urlid);
session.setAttribute("sessionname",urlid); //将值赋值给sessionname这个session中
out.println("<script language='javascript'>window.close();</script>");
}
out.println("</body>");
out.println("</html>");
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
}

19
src/main/java/com/fr/decision/privilege/encrpt/Base64PasswordValidator.java

@ -0,0 +1,19 @@
package com.fr.decision.privilege.encrpt;;
import com.fr.base.Base64;
import com.fr.base.ServerConfig;
import com.fr.decision.privilege.encrpt.AbstractPasswordValidator;
import com.fr.log.FineLoggerFactory;
import java.io.UnsupportedEncodingException;
public class Base64PasswordValidator extends AbstractPasswordValidator {
public Base64PasswordValidator() {
}
public String encode(String originText) {
try {
return Base64.encode(originText.getBytes(ServerConfig.getInstance().getServerCharset()));
} catch (UnsupportedEncodingException var3) {
FineLoggerFactory.getLogger().debug(var3.getMessage());
return "";
}
}
}

14
src/main/java/com/fr/decision/privilege/encrpt/CustomSHA256PasswordValidator.java

@ -0,0 +1,14 @@
package com.fr.decision.privilege.encrpt;
import com.fr.security.SecurityToolbox;
public class CustomSHA256PasswordValidator extends AbstractPasswordValidator {
public CustomSHA256PasswordValidator() {
}
@Override
public String encode(String originUserName, String originPassword) { //把 用户名+密码 加密成 SHA256字符
String unionPwd = originUserName + originPassword;
return SecurityToolbox.sha256(unionPwd);
}
}

6
src/com/fr/demo/ChangeRowAndCol.java → src/main/java/com/fr/demo/ChangeRowAndCol.java

@ -1,8 +1,6 @@
//遍历单元格
package com.fr.demo;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.io.TemplateWorkBookIO;
import com.fr.main.TemplateWorkBook;
import com.fr.report.cell.TemplateCellElement;
@ -18,13 +16,11 @@ public class ChangeRowAndCol extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletrequest) {
// 定义最终需要返回的WorkBook对象
TemplateWorkBook workbook = null;
Env oldEnv = FRContext.getCurrentEnv();
WorkSheet newworksheet = new WorkSheet();
String change = "0";
try {
// 读取模板保存为WorkBook对象
workbook = TemplateWorkBookIO.readTemplateWorkBook(oldEnv,
"\\doc\\Primary\\GroupReport\\Group.cpt");
workbook = TemplateWorkBookIO.readTemplateWorkBook("//doc//Primary//GroupReport//Group.cpt");
// 读取请求中的参数判断是否需要切换行列显示,0表示不切换,1表示切换
if (reportletrequest.getParameter("change") != null) {
change = reportletrequest.getParameter("change").toString();

7
src/com/fr/demo/CreateReportletDemo.java → src/main/java/com/fr/demo/CreateReportletDemo.java

@ -11,12 +11,13 @@ import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.unit.OLDPIX;
import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest;
import java.awt.Color;
import java.util.Map;
public class CreateReportletDemo extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest arg0) {
public class CreateReportletDemo extends Reportlet
{
public TemplateWorkBook createReport(ReportletRequest arg0)
{
//创建一个WorkBook工作薄,在工作薄中插入一个WorkSheet
WorkBook workbook = new WorkBook();
WorkSheet sheet1 = new WorkSheet();

14
src/com/fr/demo/NewDateDemo.java → src/main/java/com/fr/demo/NewDateDemo.java

@ -1,8 +1,6 @@
//<EFBFBD><EFBFBD>̬<EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//动态修改数据
package com.fr.demo;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.data.ArrayTableDataDemo;
import com.fr.general.ModuleContext;
import com.fr.io.TemplateWorkBookIO;
@ -16,13 +14,13 @@ import java.util.Map;
public class NewDateDemo extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletrequest) {
TemplateWorkBook workbook = null;
Env oldEnv = FRContext.getCurrentEnv();
ModuleContext.startModule(EngineModule.class.getName());
try {
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>workbook<EFBFBD><EFBFBD><EFBFBD>󣬽<EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>Ϊworkbook<EFBFBD><EFBFBD><EFBFBD>󲢷<EFBFBD><EFBFBD><EFBFBD>
workbook = TemplateWorkBookIO.readTemplateWorkBook(oldEnv, "1.cpt");
ArrayTableDataDemo a = new ArrayTableDataDemo(); // <EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
workbook.putTableData("ds2", a); // <EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD>µ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>
//创建workbook对象,将模板保存为workbook对象并返回
workbook = TemplateWorkBookIO.readTemplateWorkBook("1.cpt");
ArrayTableDataDemo a = new ArrayTableDataDemo(); //调用定义的程序数据集连接
workbook.putTableData("ds2", a); //给模板赋新的数据集
} catch (Exception e) {
e.getStackTrace();
}

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
}
}

20
src/com/fr/demo/ReadFromDatabase.java → src/main/java/com/fr/demo/ReadFromDatabase.java

@ -1,11 +1,11 @@
package com.fr.demo;
import com.fr.base.FRContext;
import com.fr.dav.LocalEnv;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest;
import com.fr.log.FineLoggerFactory;
import com.fr.web.session.SessionLocalManager;
import java.io.InputStream;
import java.sql.Blob;
@ -16,20 +16,18 @@ import java.sql.Statement;
import java.util.Map;
public class ReadFromDatabase extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletRequest) {
// 定义报表运行环境,才能执行报表
String envpath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envpath));
WorkBook workbook = new WorkBook();
String name = reportletRequest.getParameter("cptname").toString();
try {
// 定义数据连接
// 定义数据连接(根据你实际数据库信息进行修改)
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://112.124.109.239:3306/yourdatebase";
String user = "yourusername";
String pass = "yourpassword";
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);
// 从数据库中读模板
@ -39,12 +37,12 @@ public class ReadFromDatabase extends Reportlet {
ResultSet rs = smt.executeQuery(sql);
while (rs.next()) {
Blob blob = rs.getBlob(1); // 取第一列的值,即cpt列
FRContext.getLogger().info(blob.toString());
FineLoggerFactory.getLogger().info(blob.toString());
InputStream ins = blob.getBinaryStream();
workbook.readStream(ins);
}
} catch (Exception e) {
e.printStackTrace();
throw SessionLocalManager.createLogPackedException(e);
}
return workbook;
}

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

@ -0,0 +1,60 @@
package com.fr.demo;
import com.fr.form.main.Form;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.web.session.SessionLocalManager;
import com.fr.web.weblet.Formlet;
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.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 frm from report where frmname = '" + 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) {
throw SessionLocalManager.createLogPackedException(e);
}
System.out.println(ResourceIOUtils.getRealPath("assets"));
return form;
}
@Override
public void setParameterMap(Map<String, Object> arg0) {
// TODO Auto-generated method stub
}
}

85
src/main/java/com/fr/demo/SaveReportToDatabase.java

@ -0,0 +1,85 @@
package com.fr.demo;
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.io.ResourceRepositoryActivator;
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 {
// 定义报表运行环境,用于执行报表
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();
// 连接数据库
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); //注意表名是否区分大小写
conn.setAutoCommit(false);
PreparedStatement presmt = conn
.prepareStatement("INSERT INTO report VALUES(?,?)");
// 读进需要保存入库的模板文件
File cptfile = new File(envpath
+ "//reportlets//GettingStarted.cpt");
int lens = (int) cptfile.length();
InputStream ins = new FileInputStream(cptfile);
// 将模板保存入库
presmt.setString(1, "GettingStarted.cpt"); // 第一个字段存放模板相对路径
presmt.setBinaryStream(2, ins, lens); // 第二个字段存放模板文件的二进制流
presmt.execute();
conn.commit();
presmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
SimpleWork.checkOut();
}
}
}

11
src/com/fr/demo/SetCellElementStyle.java → src/main/java/com/fr/demo/SetCellElementStyle.java

@ -1,11 +1,12 @@
//单元格格式设置
package com.fr.demo;
import java.awt.Color;
import java.awt.Font;
import java.util.Map;
import com.fr.base.Style;
import com.fr.base.background.ColorBackground;
import com.fr.general.FRFont;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.worksheet.WorkSheet;
@ -13,10 +14,8 @@ import com.fr.stable.Constants;
import com.fr.stable.unit.OLDPIX;
import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest;
import java.awt.Color;
import java.awt.Font;
import java.util.Map;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
public class SetCellElementStyle extends Reportlet {

12
src/com/fr/demo/SimpleReportletDemo.java → src/main/java/com/fr/demo/SimpleReportletDemo.java

@ -1,25 +1,21 @@
//程序网络报表
package com.fr.demo;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.io.TemplateWorkBookIO;
import com.fr.main.TemplateWorkBook;
import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest;
import java.util.Map;
public class SimpleReportletDemo extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletrequest) {
// 新建一个WorkBook对象,用于保存最终返回的报表
Env oldEnv = FRContext.getCurrentEnv();
//新建一个WorkBook对象,用于保存最终返回的报表
TemplateWorkBook WorkBook = null;
try {
// 读取模板,将模板保存为workbook对象并返回
WorkBook = TemplateWorkBookIO.readTemplateWorkBook(oldEnv,
"\\doc\\Primary\\Parameter\\Parameter.cpt");
//读取模板,将模板保存为workbook对象并返回
WorkBook = TemplateWorkBookIO.readTemplateWorkBook("//doc//Primary//Parameter//Parameter.cpt");
} catch (Exception e) {
e.getStackTrace();
}

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;
}
}

10
src/com/fr/demo/TotalVerifyJobDemo.java → src/main/java/com/fr/demo/TotalVerifyJobDemo.java

@ -6,7 +6,7 @@ import com.fr.data.TotalVerifyJob;
import com.fr.data.Verifier;
import com.fr.script.Calculator;
public class TotalVerifyJobDemo extends TotalVerifyJob {
public class TotalVerifyJobDemo extends TotalVerifyJob{
/*
* type : 必须要定义此私有变量变量名可改表示校验状态
* 0 表示校验成功默认校验状态位为0
@ -28,7 +28,7 @@ public class TotalVerifyJobDemo extends TotalVerifyJob {
minnum = (JobValue) data.getValueAt(i, 1);
min = Integer.parseInt(Utils.objectToString(minnum.getValue()));
if (sale < min) { //校验判断
if(sale < min){ //校验判断
type = 1;
}
}
@ -37,9 +37,9 @@ public class TotalVerifyJobDemo extends TotalVerifyJob {
public String getMessage() {
// 根据校验状态是成功还是失败,设置对应的返回信息
if (type == 0) {
return "恭喜你,校验成功";
} else {
if(type == 0){
return "恭喜你,校验成功";//这个值并没有用,成功的时候不会显示这里的内容,还是显示我们默认的
}else{
return "销量值不能小于最小基数";
}
}

20
src/com/fr/demo/URLParameterDemo.java → src/main/java/com/fr/demo/URLParameterDemo.java

@ -1,36 +1,28 @@
// 程序网络报表中获取request中的值
package com.fr.demo;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.dav.LocalEnv;
import com.fr.general.ModuleContext;
import com.fr.io.TemplateWorkBookIO;
import java.util.Map;
import com.fr.main.TemplateWorkBook;
import com.fr.report.module.EngineModule;
import com.fr.web.core.Reportlet;
import com.fr.web.request.ReportletRequest;
import java.util.Map;
import com.fr.io.TemplateWorkBookIO;
import com.fr.base.Parameter;
@SuppressWarnings("unused")
public class URLParameterDemo extends Reportlet {
public TemplateWorkBook createReport(ReportletRequest reportletRequest) {
String envPath = "D:\\FineReport_8.0\\WebReport\\WEB-INF";
FRContext.setCurrentEnv(new LocalEnv(envPath));
ModuleContext.startModule(EngineModule.class.getName());
// 获取外部传来的参数
TemplateWorkBook wbTpl = null;
String countryValue = reportletRequest.getParameter("地区").toString();
try {
wbTpl = TemplateWorkBookIO.readTemplateWorkBook(
FRContext.getCurrentEnv(), "\\doc\\Primary\\Parameter\\Parameter.cpt");
"//doc//Primary//Parameter//Parameter.cpt");
// 提取报表参数组,由于原模板只有country一个参数,因此直接取index为0的参数,并将外部传入的值赋给该参数
Parameter[] ps = wbTpl.getParameters();
ps[0].setValue(countryValue);
// 原模板定义有参数界面,参数已经从外部获得,去掉参数页面
// 若您想保留参数界面,则将模板设置为不延迟报表展示,再传入参数后直接根据参数值显示结果,否则还需要再次点击查询按钮
// 如果想要参数面板,把下面wbTpl.getReportParameterAttr().setParameterUI(null); 这句去掉就行
wbTpl.getReportParameterAttr().setParameterUI(null);
} catch (Exception e) {
e.printStackTrace();

21
src/com/fr/demo/VerifyJobDemo.java → src/main/java/com/fr/demo/VerifyJobDemo.java

@ -6,7 +6,7 @@ import com.fr.data.JobValue;
import com.fr.data.Verifier;
import com.fr.script.Calculator;
public class VerifyJobDemo extends DefinedVerifyJob {
public class VerifyJobDemo extends DefinedVerifyJob{
/*
* 必须要定义此私有变量,变量名可改表示校验状态
* 0 表示校验成功默认校验状态位为0
@ -26,20 +26,20 @@ public class VerifyJobDemo extends DefinedVerifyJob {
* 校验规则为销量需要大于等于最小基数salenum >= minnum
* 校验不通过,提示销量值不能小于最小基数
*/
if (salenum != null) {
if(salenum != null){
int sale = 0;
if (salenum.getValue() instanceof Integer) { //将单元格值转为整型以便用于比较
sale = (Integer) salenum.getValue();
if(salenum.getValue() instanceof Integer){ //将单元格值转为整型以便用于比较
sale = (Integer)salenum.getValue();
} else {
}else {
sale = Integer.parseInt(Utils.objectToString(salenum.getValue()));
}
if (sale < minnum) { //校验判断
if(sale < minnum){ //校验判断
type = 1;
}
} else {
}else {
type = 1;
}
@ -47,14 +47,13 @@ public class VerifyJobDemo extends DefinedVerifyJob {
public String getMessage() {
// 根据校验状态是成功还是失败,设置对应的返回信息
if (type == 0) {
return "恭喜你,校验成功";
} else {
if(type == 0){
return "恭喜你,校验成功";//这个值并没有用,成功的时候不会显示这里的内容,还是显示我们默认的
}else{
return "销量值不能小于最小基数";
}
}
public Verifier.Status getType() {
// 返回校验状态
return Verifier.Status.parse(type);

73
src/main/java/com/fr/demo/VerifyJobDemo2.java

@ -0,0 +1,73 @@
package com.fr.demo;
import com.fr.base.FRContext;
import com.fr.base.Utils;
import com.fr.cache.Attachment;
import com.fr.data.DefinedVerifyJob;
import com.fr.data.JobValue;
import com.fr.data.Verifier;
import com.fr.general.FArray;
import com.fr.script.Calculator;
import com.fr.log.FineLoggerFactory;
public class VerifyJobDemo2 extends DefinedVerifyJob{
/*
* 必须要定义此私有变量,变量名可改表示校验状态
* 0 表示校验成功默认校验状态位为0
* 1 表示校验失败
*/
private int type = 0;
/**
* 当模板自定义事件增加的属性 名称与下面变量有对应时则会自动赋值于此对应变量
*/
private JobValue file; // JobValue对应单元格
private JobValue yesOrno;
// private int minnum; // 如果是非单元格,则对应具体类型值
public void doJob(Calculator calculator) throws Exception {
/*
* 如这边提供一个简单的判断来模拟执行过程
* 校验规则为yesOrno等于1 并且 file 上传了附件yesOrno == 1 && file 上传附件
* 校验不通过,提示请上传附件
*/
//这个是fr打印日志的接口,如果是设计器下的话 会在日志里看到对应的日志信息打印出来
FRContext.getLogger().error("##### start verigy####");
int yn = 0;
if(yesOrno.getValue() instanceof Integer){ //将单元格值转为整型以便用于比较
yn = Integer.parseInt(yesOrno.getValue().toString());
}else {
yn = Integer.parseInt(Utils.objectToString(yesOrno.getValue()));
}
FineLoggerFactory.getLogger().error("##### yn = "+yn +"####");
if (yn == 1) {
//判断file是否有上传文件
if (file.getValue() instanceof FArray && ((FArray) file.getValue()).length() > 0
&& ((FArray) file.getValue()).elementAt(0) instanceof Attachment) {
type = 0;
} else {
type = 1;
}
} else {
type = 1;
}
}
public String getMessage() {
// 根据校验状态是成功还是失败,设置校验失败的返回信息
if(type == 1){
return "请上传附件";
}
return "";
}
public Verifier.Status getType() {
// 返回校验状态
return Verifier.Status.parse(type);
}
public void doFinish(Calculator arg0) throws Exception {
// TODO Auto-generated method stub
}
}

0
src/com/fr/function/BinaryImage.java → src/main/java/com/fr/function/BinaryImage.java

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

Binary file not shown.

1
src/com/fr/function/CellSum.java → src/main/java/com/fr/function/CellSum.java

@ -1,4 +1,3 @@
// 自定义函数中获取公式所在单元格
package com.fr.function;
import com.fr.base.Utils;

9
src/com/fr/function/ConnectSAPServer.java → src/main/java/com/fr/function/ConnectSAPServer.java

@ -1,17 +1,16 @@
package com.fr.function;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Properties;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.ext.DestinationDataProvider;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Properties;
public class ConnectSAPServer {
static String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
static {
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST,

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

Binary file not shown.

67
src/main/java/com/fr/function/DateDiff.java

@ -0,0 +1,67 @@
package com.fr.function;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DateDiff extends AbstractFunction
{
private static final long serialVersionUID = -2863679010825725885L;
public String format = null;
private Long dif = Long.valueOf(0L);
public Object run(Object[] paramArrayOfObject)
{
try
{
Long localLong1 = Long.valueOf(((Date)paramArrayOfObject[0]).getTime());
Long localLong2 = Long.valueOf(((Date)paramArrayOfObject[1]).getTime());
this.dif = Long.valueOf(localLong2.longValue() - localLong1.longValue());
this.format = ((String)paramArrayOfObject[2]);
replace("((?i)y)", Long.valueOf(31536000000L));
replace("((?i)q)", Long.valueOf(7776000000L));
replace("M", Long.valueOf(2592000000L));
replace("((?i)w)", Long.valueOf(604800000L));
replace("((?i)d)", Long.valueOf(86400000L));
replace("((?i)h)", Long.valueOf(3600000L));
replace("m", Long.valueOf(60000L));
replace("((?i)s)", Long.valueOf(1000L));
try
{
return Long.valueOf(Long.parseLong(this.format));
}
catch (Exception localException2)
{
return this.format;
}
}
catch (Exception localException1)
{
}
return Primitive.ERROR_VALUE;
}
public void replace(String paramString, Long paramLong)
{
Pattern localPattern = Pattern.compile(paramString + "\\{\\d*?\\}");
Matcher localMatcher = localPattern.matcher(this.format);
int i = (int)(this.dif.longValue() / paramLong.longValue());
int j = 1;
while (localMatcher.find())
{
String str1 = localMatcher.group();
str1 = str1.replaceAll(paramString + "\\{", "");
str1 = str1.replaceAll("\\}", "");
int k = Integer.parseInt(str1);
String str2 = String.format("%0" + k + "d", new Object[] { Integer.valueOf(i) });
if (j != 0)
{
j = 0;
this.dif = Long.valueOf(this.dif.longValue() - i * paramLong.longValue());
}
this.format = this.format.replaceFirst(paramString + "\\{\\d*?\\}", str2);
}
}
}

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

Binary file not shown.

67
src/main/java/com/fr/function/FlagHtmlColor.java

@ -0,0 +1,67 @@
package com.fr.function;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
public class FlagHtmlColor extends AbstractFunction {
public Object run(Object[] args) {
String txt="";
String color="";
String flag="";
if(null==args||args.length==0){
return Primitive.ERROR_NAME;
}else if(args.length==1){
txt=args[0].toString();
color="red";
flag="N";
}else if(args.length==2){
txt=args[0].toString();
color=args[1].toString();
flag="N";
}else{
txt=args[0].toString();
color=args[1].toString();
flag=args[2].toString();
}
String result=getHtmlStr(txt, color, flag);
return result;
}
public String getHtmlStr(String txt,String color,String flag){
String starthtml="<font color='"+color+"'>";
String endhtml="</font>";
StringBuffer sb=new StringBuffer();
int len=txt.length();
if("N".equalsIgnoreCase(flag)){//数字
for(int i=0;i<len;i++){
char c=txt.charAt(i);
if(c>='0'&&c<='9'){
String str=starthtml+c+endhtml;
sb.append(str);
}else{
sb.append(c);
}
}
}else if("C".equalsIgnoreCase(flag)){//字母
for(int i=0;i<len;i++){
char c=txt.charAt(i);
if((c>='a'&&c<='z')||(c>='A'&&c<='Z')){
String str=starthtml+c+endhtml;
sb.append(str);
}else{
sb.append(c);
}
}
} else if("Z".equalsIgnoreCase(flag)){//中文
for(int i=0;i<len;i++){
char c=txt.charAt(i);
if(c >= 0x4E00 && c <= 0x9FA5){
String str=starthtml+c+endhtml;
sb.append(str);
}else{
sb.append(c);
}
}
}else{
return txt;
}
return sb.toString();
}
}

23
src/main/java/com/fr/function/GETIP.java

@ -0,0 +1,23 @@
package com.fr.function;
import com.fr.script.AbstractFunction;
import java.net.InetAddress;
public class GETIP extends AbstractFunction {
@Override
public Object run(Object[] objects) {
try {
InetAddress ia = InetAddress.getLocalHost();
return ia.getHostAddress();
} catch (Exception e) {
return e.getMessage();
}
}
public static InetAddress getInetAddress() {
return null;
}
}

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

Binary file not shown.

152
src/main/java/com/fr/function/IRR.java

@ -0,0 +1,152 @@
package com.fr.function;
import java.math.BigDecimal;
import com.fr.general.FArray;
import com.fr.general.GeneralUtils;
import com.fr.script.AbstractFunction;
public class IRR extends AbstractFunction {
private static final long serialVersionUID = 7634415917398642321L;
private static final String ERROR_VALUE = "#NUM!";
@Override
public Object run(Object[] args) {
try{
if(1 == args.length){
return run( transArr( (FArray) args[0] ) );
}else if(2 == args.length){
return run( transArr( (FArray) args[0] ), trans( args[1] ) );
}
}catch(Exception e){
System.out.println(e);
}
return ERROR_VALUE;
}
/**
* 将其他类型的数字转换为大数保证精度
* @param ele
* @return
*/
private static BigDecimal trans(Object ele){
try{
String val = GeneralUtils.objectToString(ele);
return new BigDecimal(val);
}catch(Exception e){
}
return (BigDecimal) ele;
}
/**
* 将数组转换为大数数组
* @param in
* @return
*/
private static FArray<BigDecimal> transArr(FArray in){
FArray<BigDecimal> rt = new FArray<BigDecimal>();
for(int i=0;i<in.length();i++){
Object ele = in.elementAt(i);
rt.add(trans(ele));
}
return rt;
}
private static BigDecimal run(FArray<BigDecimal> cashflow){
return run( cashflow, new BigDecimal(0.1d) );
}
private static BigDecimal run(FArray<BigDecimal> cashflow,BigDecimal guess){
BigDecimal maxrate = initRateMax(cashflow,guess);
BigDecimal minrate = initRateMin(cashflow,guess);
for( int i=0; i<Init_Max_Loop; i++ ){
BigDecimal testrate = minrate.add(maxrate).divide( new BigDecimal(2d) );
BigDecimal npv = NPV( cashflow, testrate );
if( npv.abs().compareTo(Accuracy) == LESS ){
guess = testrate;
break;
}else if( npv.compareTo(ZERO) == LESS ){
minrate = testrate;
}else{
maxrate = testrate;
}
}
//保留16位小数(足够精度)
return guess.setScale(16,BigDecimal.ROUND_HALF_UP);
}
//最小精度
private static final BigDecimal Accuracy = new BigDecimal(0.00000001d);
//最大循环次数,excel用的是20次,不过精度只到小数点后两位,而且不一定一定能算出值,为了尽可能保证算出结果,我增加到100次,
private static final int Init_Max_Loop = 100;
private static final BigDecimal ZERO = new BigDecimal(0);
private static final BigDecimal ONE = new BigDecimal(1);
private static final BigDecimal Z005 = new BigDecimal(0.005d);
private static final BigDecimal Z2 = new BigDecimal(0.2d);
private static final int GREATER = 1;
private static final int LESS = -1;
/**
* 生成一个使NPV为负数的R作为内部收益率下限值
* @param cashflow
* @param guess
* @return
*/
private static BigDecimal initRateMin(FArray<BigDecimal> cashflow,BigDecimal guess){
for( int i=0; i<Init_Max_Loop; i++ ){
BigDecimal npv = NPV( cashflow, guess );
if( npv.compareTo(ZERO) == LESS ){
return guess;
}
BigDecimal step = guess.abs().multiply( Z2 );
guess = guess.add( step.compareTo( Z005 ) == LESS ? Z005 : step );
}
return guess;
}
/**
* 生成一个使NPV为正数的R作为内部收益率的上限制
* @param cashflow
* @param guess
* @return
*/
private static BigDecimal initRateMax(FArray<BigDecimal> cashflow,BigDecimal guess){
for( int i=0; i<Init_Max_Loop; i++ ){
BigDecimal npv = NPV( cashflow, guess );
if( npv.compareTo(ZERO) == GREATER ){
return guess;
}
BigDecimal step = guess.abs().multiply( Z2 );
guess = guess.subtract( step.compareTo( Z005 ) == LESS ? Z005 : step );
}
return guess;
}
/**
* 算NPV
* @param cashflow
* @param rate
* @return
*/
private static BigDecimal NPV(FArray<BigDecimal> cashflow,BigDecimal rate){
BigDecimal npv = ZERO;
BigDecimal rpowj = ONE;//(1+r)^0
BigDecimal radd1 = rate.add(ONE);//1+r
for( int j=0; j<cashflow.length(); j++ ){
BigDecimal valuej = cashflow.elementAt(j);
npv = npv.add( valuej.divide( rpowj, 10, BigDecimal.ROUND_HALF_DOWN ) );// vj / (1+r)^j
rpowj = rpowj.multiply(radd1); // (1+r)^j
//npv += cashflow.elementAt(j) / Math.pow( 1+rate, j );
}
return npv;
}
}

10
src/com/fr/function/JFreeToChart.java → src/main/java/com/fr/function/JFreeToChart.java

@ -1,7 +1,9 @@
// 引入JFreeChart图表
package com.fr.function;
import com.fr.script.AbstractFunction;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.text.NumberFormat;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
@ -18,9 +20,7 @@ import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.util.SortOrder;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.text.NumberFormat;
import com.fr.script.AbstractFunction;
public class JFreeToChart extends AbstractFunction {
private String x, y;
@ -52,7 +52,7 @@ public class JFreeToChart extends AbstractFunction {
.createCategoryDataset("Languages", defaultkeyedvalues);
CategoryDataset categorydataset1 = DatasetUtilities
.createCategoryDataset("Cumulative", keyedvalues);
return (new CategoryDataset[]{categorydataset, categorydataset1});
return (new CategoryDataset[] { categorydataset, categorydataset1 });
}

0
src/com/fr/function/Lunar.java → src/main/java/com/fr/function/Lunar.java

0
src/com/fr/function/ParamSAPDataTest.java → src/main/java/com/fr/function/ParamSAPDataTest.java

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

Binary file not shown.

36
src/com/fr/function/ReportCheck.java → src/main/java/com/fr/function/ReportCheck.java

@ -1,18 +1,28 @@
// 自定义函数实现表间校验
package com.fr.function;
import com.fr.base.Env;
import com.fr.base.FRContext;
import com.fr.base.ResultFormula;
import com.fr.base.operator.common.CommonOperator;
import com.fr.chart.activator.ChartBaseActivator;
import com.fr.config.activator.BaseDBActivator;
import com.fr.config.activator.ConfigurationActivator;
import com.fr.env.operator.CommonOperatorImpl;
import com.fr.io.TemplateWorkBookIO;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
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.cell.CellElement;
import com.fr.report.module.ReportBaseActivator;
import com.fr.report.report.ResultReport;
import com.fr.script.AbstractFunction;
import com.fr.stable.WriteActor;
import com.fr.store.StateServiceActivator;
import com.fr.workspace.simple.SimpleWork;
import com.fr.write.cal.WB;
import java.util.HashMap;
@ -27,13 +37,23 @@ public class ReportCheck extends AbstractFunction {
int rownumber = Integer.parseInt(args[3].toString()); // 所取单元格所在行
// 定义返回的值
Object returnValue = null;
// 定义报表运行环境,才能运行读取的报表
Env oldEnv = FRContext.getCurrentEnv();
// 定义报表运行环境,用于执行报表
Module module = ActivatorToolBox.simpleLink(new BaseDBActivator(),
new ConfigurationActivator(),
new StateServiceActivator(),
new ReportBaseActivator(),
new RestrictionActivator(),
new ReportActivator(),
new ChartBaseActivator());
SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl());
String envpath= "//Applications//FineReport10_325//webapps//webroot//WEB-INF"; //工程路径
SimpleWork.checkIn(envpath);
module.start();
try {
ResultWorkBook rworkbook = null;
// 读取模板
WorkBook workbook = (WorkBook) TemplateWorkBookIO
.readTemplateWorkBook(oldEnv, cptname);
WorkBook workbook = (WorkBook)TemplateWorkBookIO
.readTemplateWorkBook(cptname);
// 获取需要传递给报表的参数名与参数值,格式如[{"name":para1name,"value":para1value},{"name":para2name,"value":para2value},......]
JSONArray parasArray = new JSONArray(args[1].toString());
// 需要判断是否是5秒内执行过的
@ -70,8 +90,8 @@ public class ReportCheck extends AbstractFunction {
ResultReport report = rworkbook.getResultReport(0);
CellElement cellElement = ((WB) report).getCellElement(colnumber, rownumber);
returnValue = cellElement.getValue().toString();
if (cellElement.getValue() instanceof ResultFormula) {
returnValue = ((ResultFormula) cellElement.getValue()).getResult().toString();
if(cellElement.getValue() instanceof ResultFormula) {
returnValue = ((ResultFormula)cellElement.getValue()).getResult().toString();
}
} catch (Exception e) {
e.printStackTrace();

48
src/com/fr/function/SolarToLunar.java → src/main/java/com/fr/function/SolarToLunar.java

@ -1,12 +1,12 @@
//自定义函数把阳历转换成阴历
package com.fr.function;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
public class SolarToLunar {
final private static long[] lunarInfo = new long[]{0x04bd8, 0x04ae0,
final private static long[] lunarInfo = new long[] { 0x04bd8, 0x04ae0,
0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, 0x09ad0,
0x055d2, 0x04ae0, 0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540,
0x0d6a0, 0x0ada2, 0x095b0, 0x14977, 0x04970, 0x0a4b0, 0x0b4b5,
@ -28,43 +28,43 @@ public class SolarToLunar {
0x0ea65, 0x0d530, 0x05aa0, 0x076a3, 0x096d0, 0x04bd7, 0x04ad0,
0x0a4d0, 0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, 0x0b5a0, 0x056d0,
0x055b2, 0x049b0, 0x0a577, 0x0a4b0, 0x0aa50, 0x1b255, 0x06d20,
0x0ada0};
0x0ada0 };
final private static int[] year20 = new int[]{1, 4, 1, 2, 1, 2, 1, 1, 2,
1, 2, 1};
final private static int[] year20 = new int[] { 1, 4, 1, 2, 1, 2, 1, 1, 2,
1, 2, 1 };
final private static int[] year19 = new int[]{0, 3, 0, 1, 0, 1, 0, 0, 1,
0, 1, 0};
final private static int[] year19 = new int[] { 0, 3, 0, 1, 0, 1, 0, 0, 1,
0, 1, 0 };
final private static int[] year2000 = new int[]{0, 3, 1, 2, 1, 2, 1, 1,
2, 1, 2, 1};
final private static int[] year2000 = new int[] { 0, 3, 1, 2, 1, 2, 1, 1,
2, 1, 2, 1 };
public final static String[] nStr1 = new String[]{"", "正", "二", "三", "四",
"五", "六", "七", "八", "九", "十", "十一", "十二"};
public final static String[] nStr1 = new String[] { "", "正", "二", "三", "四",
"五", "六", "七", "八", "九", "十", "十一", "十二" };
private final static String[] Gan = new String[]{"甲", "乙", "丙", "丁", "戊",
"己", "庚", "辛", "壬", "癸"};
private final static String[] Gan = new String[] { "甲", "乙", "丙", "丁", "戊",
"己", "庚", "辛", "壬", "癸" };
private final static String[] Zhi = new String[]{"子", "丑", "寅", "卯", "辰",
"巳", "午", "未", "申", "酉", "戌", "亥"};
private final static String[] Zhi = new String[] { "子", "丑", "寅", "卯", "辰",
"巳", "午", "未", "申", "酉", "戌", "亥" };
private final static String[] Animals = new String[]{"鼠", "牛", "虎", "兔",
"龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"};
private final static String[] Animals = new String[] { "鼠", "牛", "虎", "兔",
"龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" };
private final static String[] solarTerm = new String[]{"小寒", "大寒", "立春",
private final static String[] solarTerm = new String[] { "小寒", "大寒", "立春",
"雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑",
"立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"};
"立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至" };
private final static String[] sFtv = new String[]{"0101*元旦", "0214 情人节",
private final static String[] sFtv = new String[] { "0101*元旦", "0214 情人节",
"0308 妇女节", "0312 植树节", "0315 消费者权益日", "0401 愚人节", "0501 劳动节",
"0504 青年节", "0512 护士节", "0601 儿童节", "0701 建党节", "0801 建军节",
"0808 父亲节", "0909 毛泽东逝世纪念", "0910 教师节", "0928 孔子诞辰", "1001*国庆节",
"1006 老人节", "1024 联合国日", "1112 孙中山诞辰", "1220 澳门回归", "1225 圣诞节",
"1226 毛泽东诞辰"};
"1226 毛泽东诞辰" };
private final static String[] lFtv = new String[]{"0101*农历春节",
private final static String[] lFtv = new String[] { "0101*农历春节",
"0115 元宵节", "0505 端午节", "0707 七夕情人节", "0815 中秋节", "0909 重阳节",
"1208 腊八节", "1224 小年", "0100*除夕"};
"1208 腊八节", "1224 小年", "0100*除夕" };
/**
* 传回农历 y年的总天数

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

Binary file not shown.

15
src/main/java/com/fr/function/StringCat.java

@ -0,0 +1,15 @@
package com.fr.function;
import com.fr.script.AbstractFunction;
public class StringCat extends AbstractFunction {
public Object run(Object[] args) {
String result = "";
Object para;
for (int i = 0; i < args.length; i++) {
para = args[i];
result += para.toString();
}
return result;
}
}

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

Binary file not shown.

59
src/main/java/com/fr/function/StringImage.java

@ -0,0 +1,59 @@
//图片在下文字在上
package com.fr.function;
import com.fr.base.GraphHelper;
import com.fr.data.core.db.BinaryObject;
import com.fr.log.FineLoggerFactory;
import com.fr.script.AbstractFunction;
import com.fr.stable.CoreGraphHelper;
import javax.imageio.ImageIO;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
/**
* 图片在下文字在上
*/
public class StringImage extends AbstractFunction {
@Override
public Object run(Object[] args) {
Image result = null;
int p = 0;
Object[] ob = new Object[2];
for (int i = 0; (i < args.length && p <= 1); i++) {
if (args[i] == null) {
continue;
}
ob[p] = args[i];
p++;
}
if (ob[1] instanceof BinaryObject) {
BinaryObject binaryObject = (BinaryObject) ob[1];
try {
result = initStringImage((String) ob[0], ImageIO.read(binaryObject.getInputStream()));
} catch (IOException e) {
e.printStackTrace();
}
} else if (ob[1] instanceof Image) {
result = initStringImage((String) ob[0], (Image) ob[1]);
} else {
FineLoggerFactory.getLogger().warn("Unsupported type of " + ob[1].getClass());
}
return result;
}
private Image initStringImage(String name, Image image) {
BufferedImage splashBuffedImage = CoreGraphHelper.toBufferedImage(image);
Graphics2D splashG2d = splashBuffedImage.createGraphics();
double centerX = 25;
double centerY = 25;
GraphHelper.drawString(splashG2d, name, centerX, centerY);
return splashBuffedImage;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save