[关闭]
@caos 2015-09-02T08:14:47.000000Z 字数 4922 阅读 773

润乾报表电子签名教程

工作


在朔黄项目中的流程审批采用了自动电子签章生成的方法来根据具体的流程记录在润乾报表文件中动态生成用户保存的签章图片,并嵌入到报表中,报表使用了润乾4.5版本的设计器,用户的个人签章图片已经在数据库中存储在 shdcm_signature 表中为BOLB类型的二进制文件,根据此情况,我们一共有两种方式实现自动签章的效果:

SQL

  1. SELECT SS.PICTURE pic
  2. FROM SHDCM_SIGNATURE ss,
  3. (SELECT F.TRANSACT_PERSON_ID
  4. FROM DENO_FLOW_RECORD F, DENO_PAYMENT_RECORD p
  5. WHERE F.DENOMINATE_ID = p.id
  6. AND f.id = (SELECT MAX(f.id)
  7. FROM DENO_FLOW_RECORD F, DENO_PAYMENT_RECORD p
  8. WHERE F.DENOMINATE_ID = p.id
  9. AND F.RECORD_TYPE_ID = 2
  10. and P.YEAR_PERIOD = ?
  11. and p.SEASON_PERIOD = ?
  12. and p.CONTRACT_ID = ?
  13. AND F.TACHE LIKE '%起草申请单%'
  14. )
  15. )E
  16. WHERE SS.OWNER_ID = e.TRANSACT_PERSON_ID
  1. package com.itclub.deno.dianziqianzhang.supervisorPayment;
  2. import java.io.ByteArrayOutputStream;
  3. import java.io.InputStream;
  4. import java.sql.Blob;
  5. import java.sql.Connection;
  6. import java.sql.ResultSet;
  7. import java.sql.Statement;
  8. import java.util.ArrayList;
  9. import java.util.List;
  10. import com.runqian.report4.usermodel.CellGraphConfig;
  11. import com.runqian.report4.usermodel.Context;
  12. import com.runqian.report4.usermodel.ICellGraphGenerator;
  13. //工程付款申请流程 施工单位复审
  14. public class FuHe implements ICellGraphGenerator {
  15. /* 数据图层
  16. * (non-Javadoc)
  17. * @see com.runqian.report4.usermodel.ICellGraphGenerator#generate(com.runqian.report4.usermodel.Context, com.runqian.report4.usermodel.CellGraphConfig)
  18. */
  19. public byte[] generate(Context arg0, CellGraphConfig arg1) {
  20. Connection con1 = null;
  21. byte[] imagebyte=null;
  22. Long uuid=null;
  23. // 读取程序全局添加的数据源
  24. Context initCtx = arg0;//全局context
  25. //String defDsName="report"; //数据源名
  26. String defDsName = initCtx.getDefDataSourceName();
  27. java.util.Map paramMap = initCtx.getParamMap(false);
  28. System.out.println(paramMap);
  29. String contractId=(String)paramMap.get("contract_id");
  30. String year=(String)paramMap.get("year");
  31. String season=(String)paramMap.get("season");
  32. String seasonTime=(String)paramMap.get("season_time");
  33. List<Object> uuidList = getUuid(contractId,year,season,seasonTime,defDsName,arg0);
  34. if(uuidList!=null&&uuidList.size()>0){
  35. uuid = (Long) uuidList.get(0);
  36. }
  37. try {
  38. con1 = initCtx.getConnectionFactory(defDsName).getConnection();
  39. } catch (Exception e) {
  40. System.out.println( "[ConnectionManager] - 获取数据库连接失败" );
  41. e.printStackTrace();
  42. }
  43. ResultSet rs1=null;
  44. Statement stmt1=null;
  45. String sql1="select picture ,ID from shdcm_signature where owner_id="+uuid+" and owner_type=680 ORDER BY ID DESC"; //得到签字图片
  46. try {
  47. stmt1 = con1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  48. rs1=stmt1.executeQuery(sql1);
  49. System.out.println(rs1.getRow());
  50. if (rs1.next()) {
  51. // BLOB blob = (BLOB) rs1.getBlob("picture");
  52. Long id = rs1.getLong("id");
  53. System.out.println(id);
  54. Blob blob = rs1.getBlob("picture");
  55. System.out.println(blob);
  56. InputStream stream = blob.getBinaryStream();
  57. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  58. for(int b; (b=stream.read())>=0;){
  59. baos.write(b);
  60. }
  61. imagebyte = baos.toByteArray();
  62. System.out.println("获取二进制数据库完成");
  63. }
  64. else imagebyte =null; //如果状态位state=0 或者记录为空则返回null图片
  65. rs1.close();
  66. stmt1.close();
  67. con1.close();
  68. } catch (Exception e) {
  69. System.out.println(e.getMessage());
  70. }
  71. return imagebyte;
  72. }
  73. private List<Object> getUuid(String contractId, String year, String season, String seasonTime,String defDsName, Context arg0) {
  74. Connection con = null;
  75. Context initCtx = arg0;//全局context
  76. List<Object> uuidList = new ArrayList<Object>();
  77. try {
  78. con = initCtx.getConnectionFactory(defDsName).getConnection();
  79. } catch (Exception e) {
  80. System.out.println( "[ConnectionManager] - 获取数据库连接失败" );
  81. e.printStackTrace();
  82. }
  83. ResultSet rs=null;
  84. Statement stmt=null;
  85. String sql1="SELECT F.TRANSACT_PERSON_ID FROM DENO_FLOW_RECORD F WHERE F.ID = " +
  86. " (SELECT MAX(F.ID) FROM DENO_FLOW_RECORD F, DENO_PAYMENT_RECORD R WHERE F.DENOMINATE_ID = R.ID " +
  87. " AND F.RECORD_TYPE_ID = 2 AND R.CONTRACT_ID = "+contractId+" AND R.YEAR_PERIOD = "+year+
  88. " AND R.SEASON_PERIOD = "+season+" and R.CONTRACT_TYPE_ID = 717"+
  89. " and R.payment_season_time = "+seasonTime+" AND F.TACHE like '%监理单位复审%')";
  90. try {
  91. stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  92. rs=stmt.executeQuery(sql1);
  93. if (rs.next()) {
  94. Long uuid = rs.getLong(1);
  95. uuidList.add(uuid);
  96. }
  97. rs.close();
  98. stmt.close();
  99. con.close();
  100. } catch (Exception e) {
  101. e.printStackTrace();
  102. }
  103. return uuidList;
  104. }
  105. }

这两点都能够通过sql查询的方式获得用户的图片签章文件,不过两者同样使用流程任务的任务节点名称作为过滤条件查询对应的签章。

  1. /*施工付款单
  2. *总数据集
  3. */
  4. SELECT SS.PICTURE pic,
  5. e.transact_date "处理时间",
  6. e.transact_person_id,
  7. e.transact_opinion "审批意见",
  8. e.transact_unit_name
  9. FROM SHDCM_SIGNATURE ss,
  10. (SELECT F.TRANSACT_PERSON_ID,
  11. f.transact_date,
  12. f.transact_opinion,
  13. f.transact_unit_name
  14. FROM DENO_FLOW_RECORD F, DENO_PAYMENT_RECORD p
  15. WHERE F.DENOMINATE_ID = p.id
  16. AND f.id = (SELECT MAX(f.id)
  17. FROM DENO_FLOW_RECORD F, DENO_PAYMENT_RECORD p
  18. WHERE F.DENOMINATE_ID = p.id
  19. AND F.RECORD_TYPE_ID = 2
  20. and P.YEAR_PERIOD = ?
  21. and p.SEASON_PERIOD = ?
  22. and p.CONTRACT_ID = ?
  23. and p.payment_season_time = ?
  24. AND F.TACHE LIKE '%分公司领导_审批%'
  25. )
  26. )E
  27. WHERE SS.OWNER_ID = e.TRANSACT_PERSON_ID
  28. /*部门字段*/
  29. =if(fengognsilingdaoQZ.select(transact_unit_name)==null,'分公司领导审批',fengognsilingdaoQZ.select(transact_unit_name))
  30. /*审批意见*/
  31. =" "+fengognsilingdaoQZ.select(审批意见)
  32. /*签章*/
  33. =fengognsilingdaoQZ.select(pic)
  34. /*审批时间*/
  35. =year(fengognsilingdaoQZ.select(处理时间))+"年"+month(fengognsilingdaoQZ.select(处理时间))+"月"+day(fengognsilingdaoQZ.select(处理时间))+"日"
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注