Commit 7f080a63262e9d31de670fb8866ac9bbfda2b678
1 parent
3cd770af
Exists in
master
Implementação dos recursos de relatório
Showing
3 changed files
with
14 additions
and
7 deletions
Show diff stats
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/service/impl/JasperReportManagerImpl.java
@@ -5,6 +5,7 @@ import java.io.FileOutputStream; | @@ -5,6 +5,7 @@ import java.io.FileOutputStream; | ||
5 | import java.sql.Connection; | 5 | import java.sql.Connection; |
6 | import java.util.HashMap; | 6 | import java.util.HashMap; |
7 | import java.util.List; | 7 | import java.util.List; |
8 | +import java.util.Map; | ||
8 | 9 | ||
9 | import net.sf.jasperreports.engine.JRDataSource; | 10 | import net.sf.jasperreports.engine.JRDataSource; |
10 | import net.sf.jasperreports.engine.JRException; | 11 | import net.sf.jasperreports.engine.JRException; |
@@ -52,12 +53,15 @@ public class JasperReportManagerImpl extends ReportManagerImpl implements Jasper | @@ -52,12 +53,15 @@ public class JasperReportManagerImpl extends ReportManagerImpl implements Jasper | ||
52 | throw new EsiExecutionException(e1); | 53 | throw new EsiExecutionException(e1); |
53 | } | 54 | } |
54 | 55 | ||
56 | + Map<String, Object> params = this.buildParams(report, inputMap); | ||
57 | + params.put("SUBREPORT_DIR", servletContext.getRealPath(path)+"/"); | ||
58 | + | ||
55 | switch (report.getDataSource().getType()) { | 59 | switch (report.getDataSource().getType()) { |
56 | case CONNECTION: | 60 | case CONNECTION: |
57 | Connection connection = dataSourceService.connect(report.getDataSource().getConnection()); | 61 | Connection connection = dataSourceService.connect(report.getDataSource().getConnection()); |
58 | 62 | ||
59 | try { | 63 | try { |
60 | - print = JasperFillManager.fillReport(pathReportJasper, this.buildParams(report, inputMap), connection); | 64 | + print = JasperFillManager.fillReport(pathReportJasper, params, connection); |
61 | } catch (JRException e) { | 65 | } catch (JRException e) { |
62 | e.printStackTrace(); | 66 | e.printStackTrace(); |
63 | try { | 67 | try { |
@@ -71,7 +75,7 @@ public class JasperReportManagerImpl extends ReportManagerImpl implements Jasper | @@ -71,7 +75,7 @@ public class JasperReportManagerImpl extends ReportManagerImpl implements Jasper | ||
71 | 75 | ||
72 | default: | 76 | default: |
73 | try { | 77 | try { |
74 | - print = JasperFillManager.fillReport(pathReportJasper, this.buildParams(report, inputMap), this.buildDataSource(report, inputMap)); | 78 | + print = JasperFillManager.fillReport(pathReportJasper, params, this.buildDataSource(report, inputMap)); |
75 | } catch (JRException e) { | 79 | } catch (JRException e) { |
76 | throw new EsiExecutionException(e); | 80 | throw new EsiExecutionException(e); |
77 | } | 81 | } |
cit-esi-web/src/main/resources/reports/empregado.jrxml
@@ -4,8 +4,11 @@ | @@ -4,8 +4,11 @@ | ||
4 | <property name="ireport.x" value="0"/> | 4 | <property name="ireport.x" value="0"/> |
5 | <property name="ireport.y" value="0"/> | 5 | <property name="ireport.y" value="0"/> |
6 | <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> | 6 | <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> |
7 | - <defaultValueExpression><![CDATA["D:\\cit\\cit-grp-esi\\cit-esi-web\\src\\main\\resources\\reports\\"]]></defaultValueExpression> | 7 | + <defaultValueExpression><![CDATA[]]></defaultValueExpression> |
8 | </parameter> | 8 | </parameter> |
9 | + <queryString language="JSON"> | ||
10 | + <![CDATA[]]> | ||
11 | + </queryString> | ||
9 | <field name="id" class="java.lang.Integer"> | 12 | <field name="id" class="java.lang.Integer"> |
10 | <fieldDescription><![CDATA[id]]></fieldDescription> | 13 | <fieldDescription><![CDATA[id]]></fieldDescription> |
11 | </field> | 14 | </field> |
@@ -55,8 +58,8 @@ | @@ -55,8 +58,8 @@ | ||
55 | <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> | 58 | <textFieldExpression><![CDATA[$F{id}]]></textFieldExpression> |
56 | </textField> | 59 | </textField> |
57 | <subreport> | 60 | <subreport> |
58 | - <reportElement x="438" y="0" width="106" height="20" uuid="904cdc0b-98c8-40ac-af91-baaed29629f0"/> | ||
59 | - <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> | 61 | + <reportElement x="434" y="0" width="110" height="22" uuid="10ec63c0-9a3b-4c31-bb52-8e3a6296b10b"/> |
62 | + <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{telefones})]]></dataSourceExpression> | ||
60 | <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "empregado_telefone.jasper"]]></subreportExpression> | 63 | <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "empregado_telefone.jasper"]]></subreportExpression> |
61 | </subreport> | 64 | </subreport> |
62 | </band> | 65 | </band> |
cit-esi-web/src/main/resources/reports/empregado_telefone.jrxml
@@ -10,9 +10,9 @@ | @@ -10,9 +10,9 @@ | ||
10 | <band splitType="Stretch"/> | 10 | <band splitType="Stretch"/> |
11 | </background> | 11 | </background> |
12 | <detail> | 12 | <detail> |
13 | - <band height="42" splitType="Stretch"> | 13 | + <band height="23" splitType="Stretch"> |
14 | <textField> | 14 | <textField> |
15 | - <reportElement x="11" y="12" width="100" height="20" uuid="42865c6c-27a5-48de-9549-8c87e20aa594"/> | 15 | + <reportElement x="0" y="0" width="100" height="20" uuid="2b62387e-af3c-4c0c-81b8-e211519c1d4a"/> |
16 | <textFieldExpression><![CDATA[$F{numero}]]></textFieldExpression> | 16 | <textFieldExpression><![CDATA[$F{numero}]]></textFieldExpression> |
17 | </textField> | 17 | </textField> |
18 | </band> | 18 | </band> |