fixes bug #7500
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@56988 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
058c6f75c2
commit
c7874595bd
|
@ -0,0 +1,92 @@
|
|||
package com.rjconsultores.ventaboletos.relatorios.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.rjconsultores.ventaboletos.relatorios.utilitarios.DataSource;
|
||||
import com.rjconsultores.ventaboletos.relatorios.utilitarios.ECFReducaoZVO;
|
||||
import com.rjconsultores.ventaboletos.relatorios.utilitarios.ItemECFVO;
|
||||
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UtiliteriasFiscal;
|
||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalReducaoZVO;
|
||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalVO;
|
||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ItemFiscalVO;
|
||||
|
||||
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
|
||||
|
||||
public class RelatorioECFReducaoZ extends Relatorio {
|
||||
|
||||
private List<ECFReducaoZVO> lsDadosRelatorio;
|
||||
|
||||
public RelatorioECFReducaoZ(final Map<String, Object> parametros, Connection conexao) throws Exception {
|
||||
super(parametros, conexao);
|
||||
|
||||
lsDadosRelatorio = new ArrayList<ECFReducaoZVO>();
|
||||
|
||||
this.setCustomDataSource(new DataSource(this) {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initDados() throws Exception {
|
||||
|
||||
List<ImportacionFiscalVO> ecfInvalidos = (List<ImportacionFiscalVO>) parametros.get("ecfInvalidos");
|
||||
List<ImportacionFiscalReducaoZVO> redZInvalido = (List<ImportacionFiscalReducaoZVO>) parametros.get("redZInvalido");
|
||||
|
||||
for (ImportacionFiscalReducaoZVO irz : redZInvalido) {
|
||||
ECFReducaoZVO zvo = new ECFReducaoZVO("REDUÇÃO Z", irz.getAliquota(), padronizaData(irz.getDatamov()),
|
||||
irz.getNumserie20(), null, padronizaValor(irz.getVendabrutadiaria()));
|
||||
lsDadosRelatorio.add(zvo);
|
||||
}
|
||||
|
||||
for (ImportacionFiscalVO ecf : ecfInvalidos) {
|
||||
ECFReducaoZVO ecfvo = new ECFReducaoZVO("ECF", null, padronizaData(ecf.getDataEmissao()), ecf.getNumImpressora(),
|
||||
ecf.getCoo(), UtiliteriasFiscal.arredondar(UtiliteriasFiscal.valorTotalItensECF(ecf)));
|
||||
|
||||
List<ItemECFVO> list = new ArrayList<ItemECFVO>();
|
||||
for (ItemFiscalVO ifi : ecf.getItensFiscais()) {
|
||||
list.add(new ItemECFVO(ifi.getNumItem(), ifi.getCodProduto(), padronizaValor(ifi.getValorItem())));
|
||||
}
|
||||
|
||||
ecfvo.setItens(list);
|
||||
lsDadosRelatorio.add(ecfvo);
|
||||
}
|
||||
|
||||
setLsDadosRelatorio(lsDadosRelatorio);
|
||||
|
||||
Collections.sort(lsDadosRelatorio, new Comparator<ECFReducaoZVO>() {
|
||||
@Override
|
||||
public int compare(ECFReducaoZVO b1, ECFReducaoZVO b2) {
|
||||
if (b1.getDatamov().equals(b2.getDatamov())) {
|
||||
return b1.getNumserie20().compareTo(b2.getNumserie20());
|
||||
} else {
|
||||
return b1.getDatamov().compareTo(b2.getDatamov());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private BigDecimal padronizaValor(BigDecimal valor) {
|
||||
return valor.divide(UtiliteriasFiscal.CEM);
|
||||
}
|
||||
|
||||
private String padronizaData(String data) {
|
||||
return DateUtil.changeFormatStringDate(data, "yyyyMMdd", "dd/MM/yyyy");
|
||||
}
|
||||
|
||||
public void setLsDadosRelatorio(List<ECFReducaoZVO> lsDadosRelatorio) {
|
||||
this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio));
|
||||
this.lsDadosRelatorio = lsDadosRelatorio;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processaParametros() throws Exception {
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
#geral
|
||||
msg.noData=Não foi possivel obter dados com os parâmetros informados.
|
|
@ -0,0 +1,2 @@
|
|||
#geral
|
||||
msg.noData=Não foi possivel obter dados com os parâmetros informados.
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="RelatorioAnaliticoVoucher" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0e8aff42-5ba8-48ac-9950-da8178561888">
|
||||
<property name="ireport.zoom" value="1.0"/>
|
||||
<property name="ireport.x" value="14"/>
|
||||
<property name="ireport.x" value="0"/>
|
||||
<property name="ireport.y" value="0"/>
|
||||
<parameter name="nombempresa" class="java.lang.String"/>
|
||||
<parameter name="competencia" class="java.lang.String"/>
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,202 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="RelatorioECFReducaoZ" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="33d0fe75-6cbc-46ff-9d9e-6e257391b1d8">
|
||||
<property name="ireport.zoom" value="1.0"/>
|
||||
<property name="ireport.x" value="0"/>
|
||||
<property name="ireport.y" value="0"/>
|
||||
<subDataset name="dsItens" uuid="780b6ae2-4f05-42ff-a3ca-f3fdcb446f89">
|
||||
<field name="numItem" class="java.lang.String"/>
|
||||
<field name="codProduto" class="java.lang.String"/>
|
||||
<field name="valorItem" class="java.math.BigDecimal"/>
|
||||
</subDataset>
|
||||
<parameter name="inicio" class="java.util.Date"/>
|
||||
<parameter name="fim" class="java.util.Date"/>
|
||||
<parameter name="empresa" class="java.lang.String"/>
|
||||
<field name="datamov" class="java.lang.String"/>
|
||||
<field name="numserie20" class="java.lang.String"/>
|
||||
<field name="coo" class="java.lang.String"/>
|
||||
<field name="valorTotal" class="java.math.BigDecimal"/>
|
||||
<field name="itens" class="java.util.List"/>
|
||||
<field name="tipo" class="java.lang.String"/>
|
||||
<field name="pendenciaRedZ" class="java.lang.String"/>
|
||||
<background>
|
||||
<band splitType="Stretch"/>
|
||||
</background>
|
||||
<title>
|
||||
<band height="66" splitType="Stretch">
|
||||
<textField pattern="dd/MM/yyyy HH:mm">
|
||||
<reportElement x="276" y="0" width="279" height="20" uuid="7c609e0b-e3d8-4bde-b3f3-2e245b88e566"/>
|
||||
<textElement textAlignment="Right" verticalAlignment="Middle">
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
|
||||
</textField>
|
||||
<staticText>
|
||||
<reportElement x="0" y="0" width="276" height="20" uuid="5cf84d9b-ccd2-43b7-b52f-8340c8d9a718"/>
|
||||
<textElement verticalAlignment="Middle">
|
||||
<font size="14" isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[ANALITICO DE PENDENCIAS]]></text>
|
||||
</staticText>
|
||||
<textField pattern="dd/MM/yyyy">
|
||||
<reportElement x="186" y="20" width="369" height="20" uuid="ed1eec37-acea-40b9-8a2b-fd4cc82f3c54"/>
|
||||
<textElement verticalAlignment="Middle"/>
|
||||
<textFieldExpression><![CDATA[$P{fim}]]></textFieldExpression>
|
||||
</textField>
|
||||
<staticText>
|
||||
<reportElement x="0" y="40" width="84" height="23" uuid="eaf57bd2-6e34-43a9-8bf4-2a325b059982"/>
|
||||
<textElement verticalAlignment="Middle">
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Empresa:]]></text>
|
||||
</staticText>
|
||||
<textField>
|
||||
<reportElement x="84" y="40" width="471" height="23" uuid="849b040c-719b-41b3-857f-ec1501d775de"/>
|
||||
<textElement verticalAlignment="Middle"/>
|
||||
<textFieldExpression><![CDATA[$P{empresa}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="158" y="20" width="28" height="20" uuid="c6ba87cc-89f1-407b-8e70-64a313494b3d"/>
|
||||
<textElement verticalAlignment="Middle">
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[" a "]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField pattern="dd/MM/yyyy">
|
||||
<reportElement x="80" y="20" width="78" height="20" uuid="da239a2a-35fe-4f17-83c3-a3bb1df689da"/>
|
||||
<textElement textAlignment="Left" verticalAlignment="Middle"/>
|
||||
<textFieldExpression><![CDATA[$P{inicio}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="0" y="20" width="80" height="20" uuid="c23507a8-46b7-4e58-9b9d-66d5a1422b62"/>
|
||||
<textElement verticalAlignment="Middle">
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA["Período: "]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</title>
|
||||
<pageHeader>
|
||||
<band splitType="Stretch"/>
|
||||
</pageHeader>
|
||||
<columnHeader>
|
||||
<band height="39" splitType="Stretch">
|
||||
<staticText>
|
||||
<reportElement x="91" y="0" width="67" height="20" uuid="faf81703-3b1c-4ed7-bf95-1a5ce6f87de0"/>
|
||||
<textElement>
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Data]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="158" y="0" width="131" height="20" uuid="2ebb8035-7fd0-4390-82b3-d9e780ab7858"/>
|
||||
<textElement>
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Impessora]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="289" y="0" width="59" height="20" uuid="12d992b9-9116-460d-91a4-c0ef82cc75bd"/>
|
||||
<textElement>
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Coo]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="348" y="0" width="65" height="20" uuid="7d37cc3c-e926-4c0e-909e-2ab054b3d8ed"/>
|
||||
<textElement>
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[valorTotal]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="0" y="0" width="91" height="20" uuid="7713d2b4-091d-4bd0-96b7-0472c420222d"/>
|
||||
<textElement>
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Tipo Pendencia]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="148" y="20" width="100" height="14" uuid="a6a65438-6427-4bff-aebc-be5a07d06a25"/>
|
||||
<textElement>
|
||||
<font size="9"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Cod. Produto]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="248" y="20" width="100" height="14" uuid="88b012fd-4940-4827-8fbc-67ff13ca4b3f"/>
|
||||
<textElement>
|
||||
<font size="9"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Valor Item]]></text>
|
||||
</staticText>
|
||||
<staticText>
|
||||
<reportElement x="413" y="0" width="142" height="20" uuid="da4dedcb-bce2-4b81-8b9b-3d0afb238d6b"/>
|
||||
<textElement>
|
||||
<font isBold="true"/>
|
||||
</textElement>
|
||||
<text><![CDATA[Pendencia Redução Z]]></text>
|
||||
</staticText>
|
||||
</band>
|
||||
</columnHeader>
|
||||
<detail>
|
||||
<band height="45" splitType="Stretch">
|
||||
<textField>
|
||||
<reportElement x="91" y="0" width="67" height="20" uuid="12f4a75d-daa7-4e97-8134-abb553e55e5a"/>
|
||||
<textFieldExpression><![CDATA[$F{datamov}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField>
|
||||
<reportElement x="158" y="0" width="131" height="20" uuid="9df39779-e1f2-4704-a591-30170a1f64a8"/>
|
||||
<textFieldExpression><![CDATA[$F{numserie20}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField isBlankWhenNull="true">
|
||||
<reportElement x="289" y="0" width="59" height="20" uuid="8da87c27-9fe5-4637-83b6-e370b7bfa2de"/>
|
||||
<textFieldExpression><![CDATA[$F{coo}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField pattern="###0.00;-###0.00">
|
||||
<reportElement x="348" y="0" width="65" height="20" uuid="698dfd69-5079-4c0d-8e8c-06f4f5afca72"/>
|
||||
<textFieldExpression><![CDATA[$F{valorTotal}]]></textFieldExpression>
|
||||
</textField>
|
||||
<componentElement>
|
||||
<reportElement x="148" y="20" width="219" height="23" isRemoveLineWhenBlank="true" uuid="e1254b4d-091a-4506-91ee-911420f7f41e"/>
|
||||
<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
|
||||
<datasetRun subDataset="dsItens" uuid="6168eeb6-e1f4-4b13-b7db-100d0666ff79">
|
||||
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{itens})]]></dataSourceExpression>
|
||||
</datasetRun>
|
||||
<jr:listContents height="23" width="219">
|
||||
<textField>
|
||||
<reportElement x="0" y="0" width="100" height="20" isRemoveLineWhenBlank="true" uuid="01605157-20e6-479e-b9a3-3ed2fe52e990"/>
|
||||
<textElement>
|
||||
<font size="9"/>
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{codProduto}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField pattern="###0.00;-###0.00">
|
||||
<reportElement x="100" y="0" width="100" height="20" isRemoveLineWhenBlank="true" uuid="47dbdc52-f4c0-418f-b38f-19c151e2cd3d"/>
|
||||
<textElement>
|
||||
<font size="9"/>
|
||||
</textElement>
|
||||
<textFieldExpression><![CDATA[$F{valorItem}]]></textFieldExpression>
|
||||
</textField>
|
||||
</jr:listContents>
|
||||
</jr:list>
|
||||
</componentElement>
|
||||
<textField>
|
||||
<reportElement x="0" y="0" width="91" height="20" uuid="6e9a0344-ab19-4f4d-8f2f-18736f6de87d"/>
|
||||
<textFieldExpression><![CDATA[$F{tipo}]]></textFieldExpression>
|
||||
</textField>
|
||||
<textField isBlankWhenNull="true">
|
||||
<reportElement x="413" y="0" width="142" height="20" uuid="d047645d-279f-4772-9927-492c87308c1d"/>
|
||||
<textFieldExpression><![CDATA[$F{pendenciaRedZ}]]></textFieldExpression>
|
||||
</textField>
|
||||
</band>
|
||||
</detail>
|
||||
<columnFooter>
|
||||
<band splitType="Stretch"/>
|
||||
</columnFooter>
|
||||
<pageFooter>
|
||||
<band splitType="Stretch"/>
|
||||
</pageFooter>
|
||||
<summary>
|
||||
<band splitType="Stretch"/>
|
||||
</summary>
|
||||
</jasperReport>
|
|
@ -0,0 +1,93 @@
|
|||
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.TipoPendencia;
|
||||
|
||||
public class ECFReducaoZVO {
|
||||
|
||||
private String tipo;
|
||||
private String pendenciaRedZ;
|
||||
private String datamov;
|
||||
private String numserie20;
|
||||
private String coo;
|
||||
private BigDecimal valorTotal;
|
||||
private List<ItemECFVO> itens;
|
||||
|
||||
public ECFReducaoZVO(String tipo, String pendenciaRedZ, String datamov, String numserie20, String coo, BigDecimal valorTotal) {
|
||||
super();
|
||||
this.tipo = tipo;
|
||||
this.datamov = datamov;
|
||||
this.numserie20 = numserie20;
|
||||
this.coo = coo;
|
||||
this.valorTotal = valorTotal;
|
||||
this.itens = new ArrayList<ItemECFVO>();
|
||||
|
||||
if (pendenciaRedZ == null) {
|
||||
this.pendenciaRedZ = null;
|
||||
} else if (pendenciaRedZ.equals(TipoPendencia.DIF_RED.toString())) {
|
||||
this.pendenciaRedZ = "Redução Z maior que ECF";
|
||||
} else if (pendenciaRedZ.equals(TipoPendencia.DIF_ECF.toString())) {
|
||||
this.pendenciaRedZ = "ECF maior que Redução Z";
|
||||
}
|
||||
}
|
||||
|
||||
public String getDatamov() {
|
||||
return datamov;
|
||||
}
|
||||
|
||||
public void setDatamov(String datamov) {
|
||||
this.datamov = datamov;
|
||||
}
|
||||
|
||||
public String getNumserie20() {
|
||||
return numserie20;
|
||||
}
|
||||
|
||||
public void setNumserie20(String numserie20) {
|
||||
this.numserie20 = numserie20;
|
||||
}
|
||||
|
||||
public String getCoo() {
|
||||
return coo;
|
||||
}
|
||||
|
||||
public void setCoo(String coo) {
|
||||
this.coo = coo;
|
||||
}
|
||||
|
||||
public BigDecimal getValorTotal() {
|
||||
return valorTotal;
|
||||
}
|
||||
|
||||
public void setValorTotal(BigDecimal valorTotal) {
|
||||
this.valorTotal = valorTotal;
|
||||
}
|
||||
|
||||
public List<ItemECFVO> getItens() {
|
||||
return itens;
|
||||
}
|
||||
|
||||
public void setItens(List<ItemECFVO> itens) {
|
||||
this.itens = itens;
|
||||
}
|
||||
|
||||
public String getTipo() {
|
||||
return tipo;
|
||||
}
|
||||
|
||||
public void setTipo(String tipo) {
|
||||
this.tipo = tipo;
|
||||
}
|
||||
|
||||
public String getPendenciaRedZ() {
|
||||
return pendenciaRedZ;
|
||||
}
|
||||
|
||||
public void setPendenciaRedZ(String pendenciaRedZ) {
|
||||
this.pendenciaRedZ = pendenciaRedZ;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.rjconsultores.ventaboletos.relatorios.utilitarios;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ItemECFVO {
|
||||
|
||||
private String numItem;
|
||||
private String codProduto;
|
||||
private BigDecimal valorItem;
|
||||
|
||||
public ItemECFVO(String numItem, String codProduto, BigDecimal valorItem) {
|
||||
super();
|
||||
this.numItem = numItem;
|
||||
this.codProduto = codProduto;
|
||||
this.valorItem = valorItem;
|
||||
}
|
||||
|
||||
public String getNumItem() {
|
||||
return numItem;
|
||||
}
|
||||
|
||||
public void setNumItem(String numItem) {
|
||||
this.numItem = numItem;
|
||||
}
|
||||
|
||||
public String getCodProduto() {
|
||||
return codProduto;
|
||||
}
|
||||
|
||||
public void setCodProduto(String codProduto) {
|
||||
this.codProduto = codProduto;
|
||||
}
|
||||
|
||||
public BigDecimal getValorItem() {
|
||||
return valorItem;
|
||||
}
|
||||
|
||||
public void setValorItem(BigDecimal valorItem) {
|
||||
this.valorItem = valorItem;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package com.rjconsultores.ventaboletos.web.gui.controladores.impressaofiscal;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Calendar;
|
||||
|
@ -12,10 +15,12 @@ import java.util.Map;
|
|||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.zkoss.util.media.AMedia;
|
||||
import org.zkoss.util.resource.Labels;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
@ -31,10 +36,14 @@ import org.zkoss.zul.Textbox;
|
|||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAnaliticoFinanceiro;
|
||||
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioAnaliticoVoucher;
|
||||
import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioECFReducaoZ;
|
||||
import com.rjconsultores.ventaboletos.relatorios.utilitarios.SaidaRelatorio;
|
||||
import com.rjconsultores.ventaboletos.service.EmpresaService;
|
||||
import com.rjconsultores.ventaboletos.service.FiscalService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.utilerias.ZipUtil;
|
||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalReducaoZVO;
|
||||
import com.rjconsultores.ventaboletos.vo.impressaofiscal.ImportacionFiscalVO;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MaskUtil;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||
|
@ -162,6 +171,7 @@ public class BusquedaImportacionFiscalController extends MyGenericForwardCompose
|
|||
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public void onClick$btnExeImportacionEcfRedZ(Event ev) throws InterruptedException {
|
||||
|
||||
Empresa empresa = null;
|
||||
|
@ -171,13 +181,42 @@ public class BusquedaImportacionFiscalController extends MyGenericForwardCompose
|
|||
}
|
||||
|
||||
try {
|
||||
List<File> txts = fiscalService.importacionFiscalECFValidaReducaoZ(datInicial.getValue(), datFinal.getValue(), empresa);
|
||||
HashMap<String, Object> retorno = fiscalService.importacionFiscalECFValidaReducaoZ(datInicial.getValue(), datFinal.getValue(), empresa);
|
||||
|
||||
Map<String, Object> parametros = new HashMap<String, Object>();
|
||||
parametros.put("ecfInvalidos", (List<ImportacionFiscalVO>) retorno.get("ecfInvalidos"));
|
||||
parametros.put("redZInvalido", (List<ImportacionFiscalReducaoZVO>) retorno.get("redZInvalido"));
|
||||
parametros.put("inicio", datInicial.getValue());
|
||||
parametros.put("fim", datFinal.getValue());
|
||||
parametros.put("empresa", empresa.getNombempresa());
|
||||
|
||||
RelatorioECFReducaoZ relatorio = new RelatorioECFReducaoZ(parametros, dataSourceRead.getConnection());
|
||||
final InputStream mediais = new ByteArrayInputStream(relatorio.getConteudo(SaidaRelatorio.PDF));
|
||||
AMedia conteudoRelatorioPDF = new AMedia("RelatorioECFReducaoZ" + ".pdf", "pdf", null, mediais);
|
||||
|
||||
List<File> txts = (List<File>) retorno.get("arquivos");
|
||||
txts.add(inpuStreamToFile(conteudoRelatorioPDF.getStreamData(), "RelatorioECFReducaoZ_0", ".pdf"));
|
||||
|
||||
downloadListaArquivos(txts);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
}
|
||||
}
|
||||
|
||||
private File inpuStreamToFile(InputStream in, String prefix, String suffix) {
|
||||
try {
|
||||
File tempFile = File.createTempFile(prefix, suffix);
|
||||
tempFile.deleteOnExit();
|
||||
FileOutputStream out = new FileOutputStream(tempFile);
|
||||
IOUtils.copy(in, out);
|
||||
return tempFile;
|
||||
} catch (IOException e) {
|
||||
log.error("", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onClick$btnExeImportacionManual(Event ev) throws InterruptedException {
|
||||
|
||||
Empresa empresa = null;
|
||||
|
@ -258,16 +297,16 @@ public class BusquedaImportacionFiscalController extends MyGenericForwardCompose
|
|||
}
|
||||
}
|
||||
|
||||
private void downloadListaArquivos(List<File> txts) throws Exception {
|
||||
private void downloadListaArquivos(List<File> files) throws Exception {
|
||||
|
||||
String extensao = ".zip";
|
||||
String contentType = "application/zip";
|
||||
File arquivoDownload = new File(System.getProperty("jboss.server.log.dir") + File.separator + "fiscal_" + DateUtil.getStringDate(Calendar.getInstance().getTime(), "yyyyMMddhhmm") + extensao);
|
||||
ZipUtil.compactarArquivos(arquivoDownload, txts);
|
||||
ZipUtil.compactarArquivos(arquivoDownload, files);
|
||||
InputStream isFile = new FileInputStream(arquivoDownload);
|
||||
String nomeArquivo = arquivoDownload.getName();
|
||||
|
||||
Filedownload.save(isFile, contentType, nomeArquivo + extensao);
|
||||
Filedownload.save(isFile, contentType, nomeArquivo);
|
||||
|
||||
if (arquivoDownload != null) {
|
||||
arquivoDownload.delete();
|
||||
|
@ -300,7 +339,7 @@ public class BusquedaImportacionFiscalController extends MyGenericForwardCompose
|
|||
nomeArquivo = arquivoTxt.getName();
|
||||
}
|
||||
|
||||
Filedownload.save(isFile, contentType, nomeArquivo + extensao);
|
||||
Filedownload.save(isFile, contentType, nomeArquivo);
|
||||
|
||||
if (arquivoTxt != null) {
|
||||
arquivoTxt.delete();
|
||||
|
|
Loading…
Reference in New Issue