fixes bug #7413
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@55774 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
91ec5021a1
commit
9d216b6437
|
@ -11,6 +11,7 @@ import java.util.List;
|
|||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -30,6 +31,8 @@ import com.rjconsultores.ventaboletos.vo.impressaofiscal.SituacaoTributaria;
|
|||
|
||||
@Repository("fiscalDAO")
|
||||
public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> implements FiscalDAO {
|
||||
|
||||
private static Logger log = Logger.getLogger(FiscalHibernateDAO.class);
|
||||
|
||||
public static final String DATE_FORMAT_FISCAL = "yyyyMMdd";
|
||||
|
||||
|
@ -43,264 +46,280 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
|
||||
@Override
|
||||
public List<ImportacionManualFiscalVO> buscaDatosFiscaisECFManual(Date inicio, Date fim, Integer empresaId) throws SQLException {
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("select r4.numserie20 as numImpressora, ");
|
||||
sql.append(" coalesce(r4.coo, b.numfoliopreimpreso) as coo, ");
|
||||
sql.append(" b.boleto_id as boletoId, ");
|
||||
sql.append(" b.marca_id as empresaId, ");
|
||||
sql.append(" e.nombempresa as empresa, ");
|
||||
sql.append(" to_char(b.fechorventa, 'yyyyMMdd') as dataEmissao, ");
|
||||
sql.append(" b.preciopagado as valorTotal, ");
|
||||
sql.append(" co.codibge as origenId, ");
|
||||
sql.append(" eo.cveestado as origenUf, ");
|
||||
sql.append(" cd.codibge as destinoId, ");
|
||||
sql.append(" ed.cveestado as destinoUf, ");
|
||||
sql.append(" r5.totparcial as repTributado, ");
|
||||
sql.append(" b.preciopagado as valorItem, ");
|
||||
sql.append(" r5.tipopassagem as tipoPassagem, ");
|
||||
sql.append(" r5.numitem as numItem, ");
|
||||
sql.append(" r5.codproduto as codProduto, ");
|
||||
sql.append(" b.numseriepreimpresa as serie, ");
|
||||
sql.append(" eio.icms as icms, ");
|
||||
sql.append(" eio.porctributo as porctributo, ");
|
||||
sql.append(" eo.estado_id as estadoIdOrigen, ");
|
||||
sql.append(" ed.estado_id as estadoIdDestino, ");
|
||||
sql.append(" subserie as subSerie, ");
|
||||
sql.append(" docfiscal as aidf, ");
|
||||
sql.append(" fi.numserie as numpdv,");
|
||||
sql.append(" fi.modelo as modeloImpressora,");
|
||||
sql.append(" r4.usuario_id as numCaixa,");
|
||||
sql.append(" case b.importetaxaembarque when 0 then null else b.importetaxaembarque ");
|
||||
sql.append(" end as importetaxaembarque, ");
|
||||
sql.append(" case b.importepedagio when 0 then null else b.importepedagio ");
|
||||
sql.append(" end as importepedagio, ");
|
||||
sql.append(" case b.importeoutros when 0 then null else b.importeoutros ");
|
||||
sql.append(" end as importeoutros, ");
|
||||
sql.append(" case b.importeseguro when 0 then null else b.importeseguro ");
|
||||
sql.append(" end as importeseguro, ");
|
||||
sql.append(" case when b.indstatusboleto = 'V' or b.motivocancelacion_id is null THEN 'N' ELSE 'C' END status, ");
|
||||
sql.append(" cs.descclase as claseServicio ");
|
||||
sql.append("from boleto b ");
|
||||
sql.append(" left join fiscal_r4 r4 on b.boleto_id = r4.boleto_id ");
|
||||
sql.append(" left outer join fiscal_r5 r5 on r4.numserie20 = r5.numserie20 ");
|
||||
sql.append(" and r4.coo = r5.coo ");
|
||||
sql.append(" left outer join fiscal_impressora fi on fi.numserie20 = r4.numserie20 ");
|
||||
sql.append(" inner join empresa e on e.empresa_id = b.marca_id ");
|
||||
sql.append(" left join alias_servico ase ON ase.origen_id = b.origen_id ");
|
||||
sql.append(" and ase.destino_id = b.destino_id and ase.ruta_id = b.ruta_id and ase.activo = 1 and ase.corrida_id is null ");
|
||||
sql.append(" left join parada o on coalesce(ase.aliasorigen_id, b.origen_id) = o.parada_id ");
|
||||
sql.append(" left join ciudad co on o.ciudad_id = co.ciudad_id ");
|
||||
sql.append(" left join estado eo on co.estado_id = eo.estado_id ");
|
||||
sql.append(" left join empresa_imposto eio on eo.estado_id = eio.estado_id ");
|
||||
sql.append(" and eio.activo = 1 ");
|
||||
sql.append(" and b.marca_id = eio.empresa_id ");
|
||||
sql.append(" left join parada d on coalesce(ase.aliasdestino_id, b.destino_id) = d.parada_id ");
|
||||
sql.append(" left join ciudad cd on d.ciudad_id = cd.ciudad_id ");
|
||||
sql.append(" left join estado ed on cd.estado_id = ed.estado_id ");
|
||||
sql.append(" left join aidf a on a.serie = b.numseriepreimpresa ");
|
||||
sql.append(" and eo.estado_id = a.estado_id ");
|
||||
sql.append(" and a.empresa_id = e.empresa_id ");
|
||||
sql.append(" inner join clase_servicio cs ON cs.claseservicio_id = b.claseservicio_id ");
|
||||
sql.append("WHERE b.fechorventa BETWEEN ? AND ? ");
|
||||
sql.append(" AND b.marca_id = ? ");
|
||||
sql.append(" AND b.tipoventa_id = 3 ");
|
||||
sql.append(" AND (b.preciopagado > 0 OR b.importetaxaembarque > 0 OR b.importepedagio > 0) ");
|
||||
sql.append("GROUP BY r4.numserie20, ");
|
||||
sql.append(" COALESCE(r4.coo, b.numfoliopreimpreso), ");
|
||||
sql.append(" b.boleto_id, ");
|
||||
sql.append(" b.marca_id, ");
|
||||
sql.append(" e.nombempresa, ");
|
||||
sql.append(" TO_CHAR(b.fechorventa, 'yyyyMMdd'), ");
|
||||
sql.append(" b.preciopagado, ");
|
||||
sql.append(" co.codibge, ");
|
||||
sql.append(" cd.codibge, ");
|
||||
sql.append(" r5.totparcial, ");
|
||||
sql.append(" b.preciopagado, ");
|
||||
sql.append(" r5.tipopassagem, ");
|
||||
sql.append(" r5.numitem, ");
|
||||
sql.append(" r5.codproduto, ");
|
||||
sql.append(" b.numseriepreimpresa, ");
|
||||
sql.append(" eio.icms, ");
|
||||
sql.append(" eio.porctributo, ");
|
||||
sql.append(" eo.estado_id, ");
|
||||
sql.append(" ed.estado_id, ");
|
||||
sql.append(" subserie, ");
|
||||
sql.append(" docfiscal, ");
|
||||
sql.append(" b.importetaxaembarque, ");
|
||||
sql.append(" b.importepedagio, ");
|
||||
sql.append(" b.importeoutros, ");
|
||||
sql.append(" b.importeseguro, ");
|
||||
sql.append(" fi.numserie, ");
|
||||
sql.append(" fi.modelo, ");
|
||||
sql.append(" r4.usuario_id, ");
|
||||
sql.append(" eo.cveestado, ");
|
||||
sql.append(" ed.cveestado, ");
|
||||
sql.append(" b.motivocancelacion_id, ");
|
||||
sql.append(" b.indstatusboleto, ");
|
||||
sql.append(" cs.descclase ");
|
||||
sql.append("ORDER BY dataEmissao, coo, modeloImpressora ");
|
||||
|
||||
List<ImportacionManualFiscalVO> listManuais = new ArrayList<ImportacionManualFiscalVO>();
|
||||
|
||||
PreparedStatement stmt = getConexao().prepareStatement(sql.toString());
|
||||
stmt.setFetchSize(100);
|
||||
stmt.setTimestamp(1, new java.sql.Timestamp(inicio.getTime()));
|
||||
stmt.setTimestamp(2, new java.sql.Timestamp(fim.getTime()));
|
||||
|
||||
if (empresaId != null) {
|
||||
stmt.setInt(3, empresaId);
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rset = null;
|
||||
|
||||
try {
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("select r4.numserie20 as numImpressora, ");
|
||||
sql.append(" coalesce(r4.coo, b.numfoliopreimpreso) as coo, ");
|
||||
sql.append(" b.boleto_id as boletoId, ");
|
||||
sql.append(" b.marca_id as empresaId, ");
|
||||
sql.append(" e.nombempresa as empresa, ");
|
||||
sql.append(" to_char(b.fechorventa, 'yyyyMMdd') as dataEmissao, ");
|
||||
sql.append(" b.preciopagado as valorTotal, ");
|
||||
sql.append(" co.codibge as origenId, ");
|
||||
sql.append(" eo.cveestado as origenUf, ");
|
||||
sql.append(" cd.codibge as destinoId, ");
|
||||
sql.append(" ed.cveestado as destinoUf, ");
|
||||
sql.append(" r5.totparcial as repTributado, ");
|
||||
sql.append(" b.preciopagado as valorItem, ");
|
||||
sql.append(" r5.tipopassagem as tipoPassagem, ");
|
||||
sql.append(" r5.numitem as numItem, ");
|
||||
sql.append(" r5.codproduto as codProduto, ");
|
||||
sql.append(" b.numseriepreimpresa as serie, ");
|
||||
sql.append(" eio.icms as icms, ");
|
||||
sql.append(" eio.porctributo as porctributo, ");
|
||||
sql.append(" eo.estado_id as estadoIdOrigen, ");
|
||||
sql.append(" ed.estado_id as estadoIdDestino, ");
|
||||
sql.append(" subserie as subSerie, ");
|
||||
sql.append(" docfiscal as aidf, ");
|
||||
sql.append(" fi.numserie as numpdv,");
|
||||
sql.append(" fi.modelo as modeloImpressora,");
|
||||
sql.append(" r4.usuario_id as numCaixa,");
|
||||
sql.append(" case b.importetaxaembarque when 0 then null else b.importetaxaembarque ");
|
||||
sql.append(" end as importetaxaembarque, ");
|
||||
sql.append(" case b.importepedagio when 0 then null else b.importepedagio ");
|
||||
sql.append(" end as importepedagio, ");
|
||||
sql.append(" case b.importeoutros when 0 then null else b.importeoutros ");
|
||||
sql.append(" end as importeoutros, ");
|
||||
sql.append(" case b.importeseguro when 0 then null else b.importeseguro ");
|
||||
sql.append(" end as importeseguro, ");
|
||||
sql.append(" case when b.indstatusboleto = 'V' or b.motivocancelacion_id is null THEN 'N' ELSE 'C' END status, ");
|
||||
sql.append(" cs.descclase as claseServicio ");
|
||||
sql.append("from boleto b ");
|
||||
sql.append(" left join fiscal_r4 r4 on b.boleto_id = r4.boleto_id ");
|
||||
sql.append(" left outer join fiscal_r5 r5 on r4.numserie20 = r5.numserie20 ");
|
||||
sql.append(" and r4.coo = r5.coo ");
|
||||
sql.append(" left outer join fiscal_impressora fi on fi.numserie20 = r4.numserie20 ");
|
||||
sql.append(" inner join empresa e on e.empresa_id = b.marca_id ");
|
||||
sql.append(" left join alias_servico ase ON ase.origen_id = b.origen_id ");
|
||||
sql.append(" and ase.destino_id = b.destino_id and ase.ruta_id = b.ruta_id and ase.activo = 1 and ase.corrida_id is null ");
|
||||
sql.append(" left join parada o on coalesce(ase.aliasorigen_id, b.origen_id) = o.parada_id ");
|
||||
sql.append(" left join ciudad co on o.ciudad_id = co.ciudad_id ");
|
||||
sql.append(" left join estado eo on co.estado_id = eo.estado_id ");
|
||||
sql.append(" left join empresa_imposto eio on eo.estado_id = eio.estado_id ");
|
||||
sql.append(" and eio.activo = 1 ");
|
||||
sql.append(" and b.marca_id = eio.empresa_id ");
|
||||
sql.append(" left join parada d on coalesce(ase.aliasdestino_id, b.destino_id) = d.parada_id ");
|
||||
sql.append(" left join ciudad cd on d.ciudad_id = cd.ciudad_id ");
|
||||
sql.append(" left join estado ed on cd.estado_id = ed.estado_id ");
|
||||
sql.append(" left join aidf a on a.serie = b.numseriepreimpresa ");
|
||||
sql.append(" and eo.estado_id = a.estado_id ");
|
||||
sql.append(" and a.empresa_id = e.empresa_id ");
|
||||
sql.append(" inner join clase_servicio cs ON cs.claseservicio_id = b.claseservicio_id ");
|
||||
sql.append("WHERE b.fechorventa BETWEEN ? AND ? ");
|
||||
sql.append(" AND b.marca_id = ? ");
|
||||
sql.append(" AND b.tipoventa_id = 3 ");
|
||||
sql.append(" AND (b.preciopagado > 0 OR b.importetaxaembarque > 0 OR b.importepedagio > 0) ");
|
||||
sql.append("GROUP BY r4.numserie20, ");
|
||||
sql.append(" COALESCE(r4.coo, b.numfoliopreimpreso), ");
|
||||
sql.append(" b.boleto_id, ");
|
||||
sql.append(" b.marca_id, ");
|
||||
sql.append(" e.nombempresa, ");
|
||||
sql.append(" TO_CHAR(b.fechorventa, 'yyyyMMdd'), ");
|
||||
sql.append(" b.preciopagado, ");
|
||||
sql.append(" co.codibge, ");
|
||||
sql.append(" cd.codibge, ");
|
||||
sql.append(" r5.totparcial, ");
|
||||
sql.append(" b.preciopagado, ");
|
||||
sql.append(" r5.tipopassagem, ");
|
||||
sql.append(" r5.numitem, ");
|
||||
sql.append(" r5.codproduto, ");
|
||||
sql.append(" b.numseriepreimpresa, ");
|
||||
sql.append(" eio.icms, ");
|
||||
sql.append(" eio.porctributo, ");
|
||||
sql.append(" eo.estado_id, ");
|
||||
sql.append(" ed.estado_id, ");
|
||||
sql.append(" subserie, ");
|
||||
sql.append(" docfiscal, ");
|
||||
sql.append(" b.importetaxaembarque, ");
|
||||
sql.append(" b.importepedagio, ");
|
||||
sql.append(" b.importeoutros, ");
|
||||
sql.append(" b.importeseguro, ");
|
||||
sql.append(" fi.numserie, ");
|
||||
sql.append(" fi.modelo, ");
|
||||
sql.append(" r4.usuario_id, ");
|
||||
sql.append(" eo.cveestado, ");
|
||||
sql.append(" ed.cveestado, ");
|
||||
sql.append(" b.motivocancelacion_id, ");
|
||||
sql.append(" b.indstatusboleto, ");
|
||||
sql.append(" cs.descclase ");
|
||||
sql.append("ORDER BY dataEmissao, coo, modeloImpressora ");
|
||||
|
||||
List<ImportacionManualFiscalVO> listManuais = new ArrayList<ImportacionManualFiscalVO>();
|
||||
|
||||
stmt = getConexao().prepareStatement(sql.toString());
|
||||
stmt.setFetchSize(100);
|
||||
stmt.setTimestamp(1, new java.sql.Timestamp(inicio.getTime()));
|
||||
stmt.setTimestamp(2, new java.sql.Timestamp(fim.getTime()));
|
||||
|
||||
if (empresaId != null) {
|
||||
stmt.setInt(3, empresaId);
|
||||
}
|
||||
|
||||
rset = stmt.executeQuery();
|
||||
while (rset.next()) {
|
||||
|
||||
ImportacionManualFiscalVO item = new ImportacionManualFiscalVO();
|
||||
|
||||
item.setNumImpressora(rset.getString("numImpressora"));
|
||||
item.setCoo(rset.getString("coo"));
|
||||
item.setBoletoId(rset.getLong("boletoId"));
|
||||
item.setEmpresaId(rset.getInt("empresaId"));
|
||||
item.setDataEmissao(rset.getString("dataEmissao"));
|
||||
item.setValorTotal(rset.getBigDecimal("valorTotal"));
|
||||
item.setNumItem(rset.getString("numItem"));
|
||||
item.setCodProduto(rset.getString("codProduto"));
|
||||
item.setNumpdv(rset.getString("numpdv"));
|
||||
item.setRepTributado(rset.getString("repTributado"));
|
||||
item.setTipoPassagem(rset.getString("tipoPassagem"));
|
||||
item.setValorItem(rset.getBigDecimal("valorItem"));
|
||||
item.setOrigenId(rset.getInt("origenId"));
|
||||
item.setOrigenUf(rset.getString("origenUf"));
|
||||
item.setDestinoId(rset.getInt("destinoId"));
|
||||
item.setDestinoUf(rset.getString("destinoUf"));
|
||||
item.setModeloImpressora(rset.getString("modeloImpressora"));
|
||||
item.setNumCaixa(rset.getString("numCaixa"));
|
||||
item.setStatus(rset.getString("status"));
|
||||
item.setSerie(rset.getString("serie"));
|
||||
item.setIcms(rset.getBigDecimal("icms"));
|
||||
item.setPorctributo(rset.getBigDecimal("porctributo"));
|
||||
item.setEstadoIdOrigen(rset.getInt("estadoIdOrigen"));
|
||||
item.setEstadoIdDestino(rset.getInt("estadoIdDestino"));
|
||||
item.setImportetaxaembarque(rset.getBigDecimal("importetaxaembarque"));
|
||||
item.setImportepedagio(rset.getBigDecimal("importepedagio"));
|
||||
item.setImporteoutros(rset.getBigDecimal("importeoutros"));
|
||||
item.setImporteseguro(rset.getBigDecimal("importeseguro"));
|
||||
item.setSubSerie(rset.getString("subSerie"));
|
||||
item.setAidf(rset.getString("aidf"));
|
||||
item.setClaseServicio(rset.getString("claseServicio"));
|
||||
|
||||
listManuais.add(item);
|
||||
}
|
||||
|
||||
return listManuais;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(e.getMessage(), e);
|
||||
throw new SQLException(e);
|
||||
} finally {
|
||||
fecharconexao();
|
||||
}
|
||||
|
||||
ResultSet rset = stmt.executeQuery();
|
||||
while (rset.next()) {
|
||||
|
||||
ImportacionManualFiscalVO item = new ImportacionManualFiscalVO();
|
||||
|
||||
item.setNumImpressora(rset.getString("numImpressora"));
|
||||
item.setCoo(rset.getString("coo"));
|
||||
item.setBoletoId(rset.getLong("boletoId"));
|
||||
item.setEmpresaId(rset.getInt("empresaId"));
|
||||
item.setDataEmissao(rset.getString("dataEmissao"));
|
||||
item.setValorTotal(rset.getBigDecimal("valorTotal"));
|
||||
item.setNumItem(rset.getString("numItem"));
|
||||
item.setCodProduto(rset.getString("codProduto"));
|
||||
item.setNumpdv(rset.getString("numpdv"));
|
||||
item.setRepTributado(rset.getString("repTributado"));
|
||||
item.setTipoPassagem(rset.getString("tipoPassagem"));
|
||||
item.setValorItem(rset.getBigDecimal("valorItem"));
|
||||
item.setOrigenId(rset.getInt("origenId"));
|
||||
item.setOrigenUf(rset.getString("origenUf"));
|
||||
item.setDestinoId(rset.getInt("destinoId"));
|
||||
item.setDestinoUf(rset.getString("destinoUf"));
|
||||
item.setModeloImpressora(rset.getString("modeloImpressora"));
|
||||
item.setNumCaixa(rset.getString("numCaixa"));
|
||||
item.setStatus(rset.getString("status"));
|
||||
item.setSerie(rset.getString("serie"));
|
||||
item.setIcms(rset.getBigDecimal("icms"));
|
||||
item.setPorctributo(rset.getBigDecimal("porctributo"));
|
||||
item.setEstadoIdOrigen(rset.getInt("estadoIdOrigen"));
|
||||
item.setEstadoIdDestino(rset.getInt("estadoIdDestino"));
|
||||
item.setImportetaxaembarque(rset.getBigDecimal("importetaxaembarque"));
|
||||
item.setImportepedagio(rset.getBigDecimal("importepedagio"));
|
||||
item.setImporteoutros(rset.getBigDecimal("importeoutros"));
|
||||
item.setImporteseguro(rset.getBigDecimal("importeseguro"));
|
||||
item.setSubSerie(rset.getString("subSerie"));
|
||||
item.setAidf(rset.getString("aidf"));
|
||||
item.setClaseServicio(rset.getString("claseServicio"));
|
||||
|
||||
listManuais.add(item);
|
||||
}
|
||||
|
||||
if (!getConexao().isClosed())
|
||||
getConexao().close();
|
||||
|
||||
return listManuais;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImportacionFiscalReducaoZVO> buscaDatosFiscaisReducaoZ(Date inicio, Date fim, Integer empresaId) throws SQLException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rset = null;
|
||||
|
||||
try {
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT r2.datamov AS datamov, ");
|
||||
sql.append(" r2.numreducoes AS numreducoes, ");
|
||||
sql.append(" r2.crz AS crz, ");
|
||||
sql.append(" r2.numserie20 AS numserie20, ");
|
||||
sql.append(" r2.coo AS coo, ");
|
||||
sql.append(" r2.cooinicial AS cooinicial, ");
|
||||
sql.append(" r2.coofinal AS coofinal, ");
|
||||
sql.append(" r2.vendabrutadiaria AS vendabrutadiaria, ");
|
||||
sql.append(" r2.datareducao AS datareducao, ");
|
||||
sql.append(" r2.horareducao AS horareducao, ");
|
||||
sql.append(" r3.totparcial AS aliquota, ");
|
||||
sql.append(" r3.valoracumulado AS imposto, ");
|
||||
sql.append(" ifi.numserie AS numpdv, ");
|
||||
sql.append(" e.cnpj AS cnpj, ");
|
||||
sql.append(" r2.totgeral AS gtFinal, ");
|
||||
sql.append(" anterior.totgeral AS gtInicial ");
|
||||
sql.append("FROM fiscal_r2 r2 ");
|
||||
sql.append(" inner join fiscal_impressora ifi ");
|
||||
sql.append(" ON ifi.numserie20 = r2.numserie20 ");
|
||||
sql.append(" inner join fiscal_r3 r3 ");
|
||||
sql.append(" ON r3.crz = r2.crz ");
|
||||
sql.append(" AND r2.numserie20 = r3.numserie20 ");
|
||||
sql.append(" AND r3.datamov = r2.datamov ");
|
||||
sql.append(" AND r3.fiscalimpressora_id = ifi.fiscalimpressora_id ");
|
||||
sql.append(" inner join fiscal_t2 t2 ");
|
||||
sql.append(" ON ifi.fiscalimpressora_id = t2.fiscalimpressora_id ");
|
||||
sql.append(" inner join empresa e ON TRANSLATE(t2.cnpj, ' / - . ', ' ') ");
|
||||
sql.append(" in (TRANSLATE(e.cnpj, ' / - . ', ' '), ");
|
||||
sql.append(" (select TRANSLATE(cnpj, ' / - . ', ' ') from inscricao_estadual where empresa_id = ? )),");
|
||||
sql.append(" (SELECT numserie20, crz, totgeral ");
|
||||
sql.append(" FROM fiscal_r2) anterior ");
|
||||
sql.append("WHERE r2.datamov BETWEEN ? AND ? ");
|
||||
sql.append(" AND r2.activo = 1 ");
|
||||
sql.append(" AND e.empresa_id = ? ");
|
||||
sql.append(" AND r3.totparcial not in (");
|
||||
sql.append("'" + SituacaoTributaria.CANCELADO.getValue() + "'").append(", ");
|
||||
sql.append("'" + SituacaoTributaria.DESCRITIVO.getValue() + "'").append(", ");
|
||||
sql.append("'" + SituacaoTributaria.OPCIONAL.getValue() + "'").append(")");
|
||||
sql.append(" AND anterior.numserie20 = r2.numserie20 ");
|
||||
sql.append(" AND anterior.crz = r2.crz - 1 ");
|
||||
sql.append("GROUP BY r2.datamov, ");
|
||||
sql.append(" r2.numreducoes, ");
|
||||
sql.append(" r2.crz, ");
|
||||
sql.append(" r2.numserie20, ");
|
||||
sql.append(" r2.coo, ");
|
||||
sql.append(" r2.cooinicial, ");
|
||||
sql.append(" r2.coofinal, ");
|
||||
sql.append(" r2.vendabrutadiaria, ");
|
||||
sql.append(" r2.datareducao, ");
|
||||
sql.append(" r2.horareducao, ");
|
||||
sql.append(" r3.totparcial, ");
|
||||
sql.append(" r3.valoracumulado, ");
|
||||
sql.append(" ifi.numserie, ");
|
||||
sql.append(" e.cnpj, ");
|
||||
sql.append(" r2.totgeral, ");
|
||||
sql.append(" anterior.totgeral ");
|
||||
sql.append("ORDER BY r2.datamov, ");
|
||||
sql.append(" numserie20, ");
|
||||
sql.append(" crz, ");
|
||||
sql.append(" r2.numreducoes, ");
|
||||
sql.append(" r3.totparcial");
|
||||
|
||||
List<ImportacionFiscalReducaoZVO> listRedZ = new ArrayList<ImportacionFiscalReducaoZVO>();
|
||||
|
||||
PreparedStatement stmt = getConexao().prepareStatement(sql.toString());
|
||||
stmt.setFetchSize(100);
|
||||
stmt.setInt(1, empresaId);
|
||||
stmt.setString(2, DateUtil.getStringDate(inicio, DATE_FORMAT_FISCAL));
|
||||
stmt.setString(3, DateUtil.getStringDate(fim, DATE_FORMAT_FISCAL));
|
||||
stmt.setInt(4, empresaId);
|
||||
|
||||
ResultSet rset = stmt.executeQuery();
|
||||
while (rset.next()) {
|
||||
|
||||
ImportacionFiscalReducaoZVO item = new ImportacionFiscalReducaoZVO();
|
||||
item.setDatamov(rset.getString("datamov"));
|
||||
item.setNumreducoes(rset.getString("numreducoes"));
|
||||
item.setCrz(rset.getString("crz"));
|
||||
item.setNumserie20(rset.getString("numserie20"));
|
||||
item.setCoo(rset.getString("coo"));
|
||||
item.setCooinicial(rset.getString("cooinicial"));
|
||||
item.setCoofinal(rset.getString("coofinal"));
|
||||
item.setVendabrutadiaria(rset.getBigDecimal("vendabrutadiaria"));
|
||||
item.setDatareducao(rset.getString("datareducao"));
|
||||
item.setHorareducao(rset.getString("horareducao"));
|
||||
item.setAliquota(rset.getString("aliquota"));
|
||||
item.setImposto(rset.getBigDecimal("imposto"));
|
||||
item.setNumpdv(rset.getString("numpdv"));
|
||||
item.setCnpj(rset.getString("cnpj"));
|
||||
item.setGtFinal(rset.getBigDecimal("gtFinal"));
|
||||
item.setGtInicial(rset.getBigDecimal("gtInicial"));
|
||||
|
||||
listRedZ.add(item);
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT r2.datamov AS datamov, ");
|
||||
sql.append(" r2.numreducoes AS numreducoes, ");
|
||||
sql.append(" r2.crz AS crz, ");
|
||||
sql.append(" r2.numserie20 AS numserie20, ");
|
||||
sql.append(" r2.coo AS coo, ");
|
||||
sql.append(" r2.cooinicial AS cooinicial, ");
|
||||
sql.append(" r2.coofinal AS coofinal, ");
|
||||
sql.append(" r2.vendabrutadiaria AS vendabrutadiaria, ");
|
||||
sql.append(" r2.datareducao AS datareducao, ");
|
||||
sql.append(" r2.horareducao AS horareducao, ");
|
||||
sql.append(" r3.totparcial AS aliquota, ");
|
||||
sql.append(" r3.valoracumulado AS imposto, ");
|
||||
sql.append(" ifi.numserie AS numpdv, ");
|
||||
sql.append(" e.cnpj AS cnpj, ");
|
||||
sql.append(" r2.totgeral AS gtFinal, ");
|
||||
sql.append(" anterior.totgeral AS gtInicial ");
|
||||
sql.append("FROM fiscal_r2 r2 ");
|
||||
sql.append(" inner join fiscal_impressora ifi ");
|
||||
sql.append(" ON ifi.numserie20 = r2.numserie20 ");
|
||||
sql.append(" inner join fiscal_r3 r3 ");
|
||||
sql.append(" ON r3.crz = r2.crz ");
|
||||
sql.append(" AND r2.numserie20 = r3.numserie20 ");
|
||||
sql.append(" AND r3.datamov = r2.datamov ");
|
||||
sql.append(" AND r3.fiscalimpressora_id = ifi.fiscalimpressora_id ");
|
||||
sql.append(" inner join fiscal_t2 t2 ");
|
||||
sql.append(" ON ifi.fiscalimpressora_id = t2.fiscalimpressora_id ");
|
||||
sql.append(" inner join empresa e ON TRANSLATE(t2.cnpj, ' / - . ', ' ') ");
|
||||
sql.append(" in (TRANSLATE(e.cnpj, ' / - . ', ' '), ");
|
||||
sql.append(" (select TRANSLATE(cnpj, ' / - . ', ' ') from inscricao_estadual where empresa_id = ? )),");
|
||||
sql.append(" (SELECT numserie20, crz, totgeral ");
|
||||
sql.append(" FROM fiscal_r2) anterior ");
|
||||
sql.append("WHERE r2.datamov BETWEEN ? AND ? ");
|
||||
sql.append(" AND r2.activo = 1 ");
|
||||
sql.append(" AND e.empresa_id = ? ");
|
||||
sql.append(" AND r3.totparcial not in (");
|
||||
sql.append("'" + SituacaoTributaria.CANCELADO.getValue() + "'").append(", ");
|
||||
sql.append("'" + SituacaoTributaria.DESCRITIVO.getValue() + "'").append(", ");
|
||||
sql.append("'" + SituacaoTributaria.OPCIONAL.getValue() + "'").append(")");
|
||||
sql.append(" AND anterior.numserie20 = r2.numserie20 ");
|
||||
sql.append(" AND anterior.crz = r2.crz - 1 ");
|
||||
sql.append("GROUP BY r2.datamov, ");
|
||||
sql.append(" r2.numreducoes, ");
|
||||
sql.append(" r2.crz, ");
|
||||
sql.append(" r2.numserie20, ");
|
||||
sql.append(" r2.coo, ");
|
||||
sql.append(" r2.cooinicial, ");
|
||||
sql.append(" r2.coofinal, ");
|
||||
sql.append(" r2.vendabrutadiaria, ");
|
||||
sql.append(" r2.datareducao, ");
|
||||
sql.append(" r2.horareducao, ");
|
||||
sql.append(" r3.totparcial, ");
|
||||
sql.append(" r3.valoracumulado, ");
|
||||
sql.append(" ifi.numserie, ");
|
||||
sql.append(" e.cnpj, ");
|
||||
sql.append(" r2.totgeral, ");
|
||||
sql.append(" anterior.totgeral ");
|
||||
sql.append("ORDER BY r2.datamov, ");
|
||||
sql.append(" numserie20, ");
|
||||
sql.append(" crz, ");
|
||||
sql.append(" r2.numreducoes, ");
|
||||
sql.append(" r3.totparcial");
|
||||
|
||||
List<ImportacionFiscalReducaoZVO> listRedZ = new ArrayList<ImportacionFiscalReducaoZVO>();
|
||||
|
||||
stmt = getConexao().prepareStatement(sql.toString());
|
||||
stmt.setFetchSize(100);
|
||||
stmt.setInt(1, empresaId);
|
||||
stmt.setString(2, DateUtil.getStringDate(inicio, DATE_FORMAT_FISCAL));
|
||||
stmt.setString(3, DateUtil.getStringDate(fim, DATE_FORMAT_FISCAL));
|
||||
stmt.setInt(4, empresaId);
|
||||
|
||||
rset = stmt.executeQuery();
|
||||
while (rset.next()) {
|
||||
|
||||
ImportacionFiscalReducaoZVO item = new ImportacionFiscalReducaoZVO();
|
||||
item.setDatamov(rset.getString("datamov"));
|
||||
item.setNumreducoes(rset.getString("numreducoes"));
|
||||
item.setCrz(rset.getString("crz"));
|
||||
item.setNumserie20(rset.getString("numserie20"));
|
||||
item.setCoo(rset.getString("coo"));
|
||||
item.setCooinicial(rset.getString("cooinicial"));
|
||||
item.setCoofinal(rset.getString("coofinal"));
|
||||
item.setVendabrutadiaria(rset.getBigDecimal("vendabrutadiaria"));
|
||||
item.setDatareducao(rset.getString("datareducao"));
|
||||
item.setHorareducao(rset.getString("horareducao"));
|
||||
item.setAliquota(rset.getString("aliquota"));
|
||||
item.setImposto(rset.getBigDecimal("imposto"));
|
||||
item.setNumpdv(rset.getString("numpdv"));
|
||||
item.setCnpj(rset.getString("cnpj"));
|
||||
item.setGtFinal(rset.getBigDecimal("gtFinal"));
|
||||
item.setGtInicial(rset.getBigDecimal("gtInicial"));
|
||||
|
||||
listRedZ.add(item);
|
||||
}
|
||||
|
||||
return listRedZ;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(e.getMessage(), e);
|
||||
throw new SQLException(e);
|
||||
} finally {
|
||||
fecharconexao();
|
||||
}
|
||||
|
||||
if (!getConexao().isClosed())
|
||||
getConexao().close();
|
||||
|
||||
return listRedZ;
|
||||
}
|
||||
|
||||
public String sqlFiscaisECFCancelados() {
|
||||
|
@ -470,85 +489,93 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
|
||||
@Override
|
||||
public List<ImportacionFiscalVO> buscaDatosFiscaisECF(Date inicio, Date fim, Integer empresaId, boolean isCancelados) throws SQLException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rset = null;
|
||||
|
||||
try {
|
||||
|
||||
String sql = isCancelados ? sqlFiscaisECFCancelados() : sqlFiscaisECF();
|
||||
PreparedStatement stmt = getConexao().prepareStatement(sql);
|
||||
stmt.setFetchSize(100);
|
||||
stmt.setString(1, DateUtil.getStringDate(inicio, DATE_FORMAT_FISCAL));
|
||||
stmt.setString(2, DateUtil.getStringDate(fim, DATE_FORMAT_FISCAL));
|
||||
|
||||
if (empresaId != null) {
|
||||
stmt.setInt(3, empresaId);
|
||||
}
|
||||
|
||||
List<ImportacionFiscalVO> list = new ArrayList<ImportacionFiscalVO>();
|
||||
ImportacionFiscalVO fiscal = null;
|
||||
String codProduto = null;
|
||||
|
||||
ResultSet rset = stmt.executeQuery();
|
||||
while (rset.next()) {
|
||||
|
||||
ItemFiscalVO item = new ItemFiscalVO();
|
||||
item.setNumImpressora(rset.getString("numImpressora"));
|
||||
item.setCoo(rset.getString("coo"));
|
||||
item.setBoletoId(rset.getLong("boletoId"));
|
||||
item.setEmpresaId(rset.getInt("empresaId"));
|
||||
item.setDataEmissao(rset.getString("dataEmissao"));
|
||||
item.setCnpjCliente(rset.getString("cnpjCliente"));
|
||||
item.setCnpjImpressora(rset.getString("cnpjImpressora"));
|
||||
item.setOrigenId(rset.getInt("origenId"));
|
||||
item.setOrigenUf(rset.getString("origenUf"));
|
||||
item.setDestinoId(rset.getInt("destinoId"));
|
||||
item.setDestinoUf(rset.getString("destinoUf"));
|
||||
item.setNumpdv(rset.getString("numpdv"));
|
||||
item.setNumItem(rset.getString("numItem"));
|
||||
item.setCodProduto(rset.getString("codProduto"));
|
||||
item.setRepTributado(rset.getString("repTributado"));
|
||||
item.setTipoPassagem(rset.getString("tipoPassagem"));
|
||||
item.setModeloImpressora(rset.getString("modeloImpressora"));
|
||||
item.setNumCaixa(rset.getString("numCaixa"));
|
||||
item.setStatus(rset.getString("status"));
|
||||
item.setClaseServicio(rset.getString("claseServicio"));
|
||||
|
||||
if (isCancelados) {
|
||||
item.setMotivocancelacion(rset.getInt("motivocancelacion"));
|
||||
item.setValorMulta(rset.getBigDecimal("valorMulta"));
|
||||
String sql = isCancelados ? sqlFiscaisECFCancelados() : sqlFiscaisECF();
|
||||
stmt = getConexao().prepareStatement(sql);
|
||||
stmt.setFetchSize(100);
|
||||
stmt.setString(1, DateUtil.getStringDate(inicio, DATE_FORMAT_FISCAL));
|
||||
stmt.setString(2, DateUtil.getStringDate(fim, DATE_FORMAT_FISCAL));
|
||||
|
||||
if (empresaId != null) {
|
||||
stmt.setInt(3, empresaId);
|
||||
}
|
||||
|
||||
// TODO: Estes atributos foram criados, por motivo de divergencia no valorTotal com o valor unitario na tabela FISCAL_R5
|
||||
item.setValorTarifa(rset.getBigDecimal("importetarifa"));
|
||||
item.setValorPedagio(rset.getBigDecimal("importepedagio"));
|
||||
item.setValorEmbarque(rset.getBigDecimal("importetaxaembarque"));
|
||||
item.setValorSeguro(rset.getBigDecimal("importeseguro"));
|
||||
|
||||
ImportacionFiscalVO novoFiscal = item;
|
||||
|
||||
codProduto = item.getCodProduto();
|
||||
codProduto = codProduto.toString().replace("-", "").replace("TA", "").replace("TX", "").replace("PE", "").replace("SE", "");
|
||||
|
||||
if (fiscal == null) {
|
||||
fiscal = item;
|
||||
} else if (!novoFiscal.equals(fiscal)) {
|
||||
|
||||
List<ImportacionFiscalVO> list = new ArrayList<ImportacionFiscalVO>();
|
||||
ImportacionFiscalVO fiscal = null;
|
||||
String codProduto = null;
|
||||
|
||||
rset = stmt.executeQuery();
|
||||
while (rset.next()) {
|
||||
|
||||
ItemFiscalVO item = new ItemFiscalVO();
|
||||
item.setNumImpressora(rset.getString("numImpressora"));
|
||||
item.setCoo(rset.getString("coo"));
|
||||
item.setBoletoId(rset.getLong("boletoId"));
|
||||
item.setEmpresaId(rset.getInt("empresaId"));
|
||||
item.setDataEmissao(rset.getString("dataEmissao"));
|
||||
item.setCnpjCliente(rset.getString("cnpjCliente"));
|
||||
item.setCnpjImpressora(rset.getString("cnpjImpressora"));
|
||||
item.setOrigenId(rset.getInt("origenId"));
|
||||
item.setOrigenUf(rset.getString("origenUf"));
|
||||
item.setDestinoId(rset.getInt("destinoId"));
|
||||
item.setDestinoUf(rset.getString("destinoUf"));
|
||||
item.setNumpdv(rset.getString("numpdv"));
|
||||
item.setNumItem(rset.getString("numItem"));
|
||||
item.setCodProduto(rset.getString("codProduto"));
|
||||
item.setRepTributado(rset.getString("repTributado"));
|
||||
item.setTipoPassagem(rset.getString("tipoPassagem"));
|
||||
item.setModeloImpressora(rset.getString("modeloImpressora"));
|
||||
item.setNumCaixa(rset.getString("numCaixa"));
|
||||
item.setStatus(rset.getString("status"));
|
||||
item.setClaseServicio(rset.getString("claseServicio"));
|
||||
|
||||
if (isCancelados) {
|
||||
item.setMotivocancelacion(rset.getInt("motivocancelacion"));
|
||||
item.setValorMulta(rset.getBigDecimal("valorMulta"));
|
||||
}
|
||||
|
||||
// TODO: Estes atributos foram criados, por motivo de divergencia no valorTotal com o valor unitario na tabela FISCAL_R5
|
||||
item.setValorTarifa(rset.getBigDecimal("importetarifa"));
|
||||
item.setValorPedagio(rset.getBigDecimal("importepedagio"));
|
||||
item.setValorEmbarque(rset.getBigDecimal("importetaxaembarque"));
|
||||
item.setValorSeguro(rset.getBigDecimal("importeseguro"));
|
||||
|
||||
ImportacionFiscalVO novoFiscal = item;
|
||||
|
||||
codProduto = item.getCodProduto();
|
||||
codProduto = codProduto.toString().replace("-", "").replace("TA", "").replace("TX", "").replace("PE", "").replace("SE", "");
|
||||
|
||||
if (fiscal == null) {
|
||||
fiscal = item;
|
||||
} else if (!novoFiscal.equals(fiscal)) {
|
||||
List<ItemFiscalVO> itensFiscais = validaItensFiscais(fiscal, codProduto);
|
||||
fiscal.setItensFiscais(itensFiscais);
|
||||
list.add(fiscal);
|
||||
fiscal = item;
|
||||
}
|
||||
|
||||
fiscal.getItensFiscais().add(item);
|
||||
|
||||
}
|
||||
|
||||
if (fiscal != null) {
|
||||
List<ItemFiscalVO> itensFiscais = validaItensFiscais(fiscal, codProduto);
|
||||
fiscal.setItensFiscais(itensFiscais);
|
||||
list.add(fiscal);
|
||||
fiscal = item;
|
||||
}
|
||||
|
||||
fiscal.getItensFiscais().add(item);
|
||||
|
||||
|
||||
return list;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(e.getMessage(), e);
|
||||
throw new SQLException(e);
|
||||
} finally {
|
||||
fecharconexao();
|
||||
}
|
||||
|
||||
if (fiscal != null) {
|
||||
List<ItemFiscalVO> itensFiscais = validaItensFiscais(fiscal, codProduto);
|
||||
fiscal.setItensFiscais(itensFiscais);
|
||||
list.add(fiscal);
|
||||
}
|
||||
|
||||
if (!getConexao().isClosed())
|
||||
getConexao().close();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private boolean validaValorExiste(BigDecimal valor) {
|
||||
|
@ -747,44 +774,62 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
|
||||
@Override
|
||||
public List<ImportacionNaoFiscalVO> buscaDatosNaoFiscais(Date inicio, Date fim, Integer empresaId) throws SQLException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rset = null;
|
||||
|
||||
try {
|
||||
|
||||
StringBuilder sQuery = new StringBuilder();
|
||||
sQuery.append("SELECT TEE.TIPOEVENTOEXTRA_ID AS TIPOEVENTOEXTRAID, TEE.DESCTIPOEVENTO AS DESCTIPOEVENTO, ")
|
||||
.append(" TRUNC(CD.FECHORVTA) AS FECHORVTA, SUM(CD.PRECIO) AS TOTAL ")
|
||||
.append("FROM TIPO_EVENTO_EXTRA TEE ")
|
||||
.append("LEFT JOIN EVENTO_EXTRA EE ON TEE.TIPOEVENTOEXTRA_ID = EE.TIPOEVENTOEXTRA_ID ")
|
||||
.append("LEFT JOIN CAJA_DIVERSOS CD ON EE.EVENTOEXTRA_ID = CD.EVENTOEXTRA_ID ")
|
||||
.append("WHERE TEE.ACTIVO = 1 ")
|
||||
.append("AND EE.EMPRESA_ID = ? ")
|
||||
.append("AND TRUNC(CD.FECHORVTA) BETWEEN ? AND ? ")
|
||||
.append("GROUP BY TEE.TIPOEVENTOEXTRA_ID, TEE.DESCTIPOEVENTO, TRUNC(CD.FECHORVTA) ")
|
||||
.append("ORDER BY TRUNC(CD.FECHORVTA), TEE.DESCTIPOEVENTO ");
|
||||
|
||||
PreparedStatement stmt = getConexao().prepareStatement(sQuery.toString());
|
||||
stmt.setInt(1, empresaId);
|
||||
stmt.setDate(2, new java.sql.Date(inicio.getTime()));
|
||||
stmt.setDate(3, new java.sql.Date(fim.getTime()));
|
||||
|
||||
ResultSet rset = stmt.executeQuery();
|
||||
List<ImportacionNaoFiscalVO> importacionNaoFiscalVOs = new ArrayList<ImportacionNaoFiscalVO>();
|
||||
while (rset.next()) {
|
||||
ImportacionNaoFiscalVO importacionNaoFiscal = new ImportacionNaoFiscalVO();
|
||||
importacionNaoFiscal.setTipoeventoextraId(rset.getInt("TIPOEVENTOEXTRAID"));
|
||||
importacionNaoFiscal.setDesctipoevento(rset.getString("DESCTIPOEVENTO"));
|
||||
importacionNaoFiscal.setFechorvta(rset.getDate("FECHORVTA"));
|
||||
importacionNaoFiscal.setTotal(rset.getBigDecimal("TOTAL"));
|
||||
|
||||
importacionNaoFiscalVOs.add(importacionNaoFiscal);
|
||||
StringBuilder sQuery = new StringBuilder();
|
||||
sQuery.append("SELECT TEE.TIPOEVENTOEXTRA_ID AS TIPOEVENTOEXTRAID, TEE.DESCTIPOEVENTO AS DESCTIPOEVENTO, ")
|
||||
.append(" TRUNC(CD.FECHORVTA) AS FECHORVTA, SUM(CD.PRECIO) AS TOTAL ")
|
||||
.append("FROM TIPO_EVENTO_EXTRA TEE ")
|
||||
.append("LEFT JOIN EVENTO_EXTRA EE ON TEE.TIPOEVENTOEXTRA_ID = EE.TIPOEVENTOEXTRA_ID ")
|
||||
.append("LEFT JOIN CAJA_DIVERSOS CD ON EE.EVENTOEXTRA_ID = CD.EVENTOEXTRA_ID ")
|
||||
.append("WHERE TEE.ACTIVO = 1 ")
|
||||
.append("AND EE.EMPRESA_ID = ? ")
|
||||
.append("AND TRUNC(CD.FECHORVTA) BETWEEN ? AND ? ")
|
||||
.append("GROUP BY TEE.TIPOEVENTOEXTRA_ID, TEE.DESCTIPOEVENTO, TRUNC(CD.FECHORVTA) ")
|
||||
.append("ORDER BY TRUNC(CD.FECHORVTA), TEE.DESCTIPOEVENTO ");
|
||||
|
||||
stmt = getConexao().prepareStatement(sQuery.toString());
|
||||
stmt.setInt(1, empresaId);
|
||||
stmt.setDate(2, new java.sql.Date(inicio.getTime()));
|
||||
stmt.setDate(3, new java.sql.Date(fim.getTime()));
|
||||
|
||||
rset = stmt.executeQuery();
|
||||
List<ImportacionNaoFiscalVO> importacionNaoFiscalVOs = new ArrayList<ImportacionNaoFiscalVO>();
|
||||
while (rset.next()) {
|
||||
ImportacionNaoFiscalVO importacionNaoFiscal = new ImportacionNaoFiscalVO();
|
||||
importacionNaoFiscal.setTipoeventoextraId(rset.getInt("TIPOEVENTOEXTRAID"));
|
||||
importacionNaoFiscal.setDesctipoevento(rset.getString("DESCTIPOEVENTO"));
|
||||
importacionNaoFiscal.setFechorvta(rset.getDate("FECHORVTA"));
|
||||
importacionNaoFiscal.setTotal(rset.getBigDecimal("TOTAL"));
|
||||
|
||||
importacionNaoFiscalVOs.add(importacionNaoFiscal);
|
||||
}
|
||||
|
||||
return importacionNaoFiscalVOs;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(e.getMessage(), e);
|
||||
throw new SQLException(e);
|
||||
} finally {
|
||||
fecharconexao();
|
||||
}
|
||||
|
||||
if (!getConexao().isClosed())
|
||||
getConexao().close();
|
||||
|
||||
return importacionNaoFiscalVOs;
|
||||
}
|
||||
|
||||
public Connection getConexao() throws SQLException {
|
||||
return dataSourceRead.getConnection();
|
||||
}
|
||||
|
||||
private void fecharconexao() {
|
||||
try {
|
||||
if (getConexao() != null && !getConexao().isClosed()) {
|
||||
getConexao().close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Erro ao fechar a conexion", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue