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;
|
||||
|
@ -31,6 +32,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";
|
||||
|
||||
@Autowired
|
||||
|
@ -43,6 +46,10 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
|
||||
@Override
|
||||
public List<ImportacionManualFiscalVO> buscaDatosFiscaisECFManual(Date inicio, Date fim, Integer empresaId) throws SQLException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rset = null;
|
||||
|
||||
try {
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("select r4.numserie20 as numImpressora, ");
|
||||
|
@ -143,7 +150,7 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
|
||||
List<ImportacionManualFiscalVO> listManuais = new ArrayList<ImportacionManualFiscalVO>();
|
||||
|
||||
PreparedStatement stmt = getConexao().prepareStatement(sql.toString());
|
||||
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()));
|
||||
|
@ -152,7 +159,7 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
stmt.setInt(3, empresaId);
|
||||
}
|
||||
|
||||
ResultSet rset = stmt.executeQuery();
|
||||
rset = stmt.executeQuery();
|
||||
while (rset.next()) {
|
||||
|
||||
ImportacionManualFiscalVO item = new ImportacionManualFiscalVO();
|
||||
|
@ -192,14 +199,22 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
listManuais.add(item);
|
||||
}
|
||||
|
||||
if (!getConexao().isClosed())
|
||||
getConexao().close();
|
||||
|
||||
return listManuais;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(e.getMessage(), e);
|
||||
throw new SQLException(e);
|
||||
} finally {
|
||||
fecharconexao();
|
||||
}
|
||||
}
|
||||
|
||||
@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, ");
|
||||
|
@ -266,14 +281,14 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
|
||||
List<ImportacionFiscalReducaoZVO> listRedZ = new ArrayList<ImportacionFiscalReducaoZVO>();
|
||||
|
||||
PreparedStatement stmt = getConexao().prepareStatement(sql.toString());
|
||||
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();
|
||||
rset = stmt.executeQuery();
|
||||
while (rset.next()) {
|
||||
|
||||
ImportacionFiscalReducaoZVO item = new ImportacionFiscalReducaoZVO();
|
||||
|
@ -297,10 +312,14 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
listRedZ.add(item);
|
||||
}
|
||||
|
||||
if (!getConexao().isClosed())
|
||||
getConexao().close();
|
||||
|
||||
return listRedZ;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(e.getMessage(), e);
|
||||
throw new SQLException(e);
|
||||
} finally {
|
||||
fecharconexao();
|
||||
}
|
||||
}
|
||||
|
||||
public String sqlFiscaisECFCancelados() {
|
||||
|
@ -470,9 +489,13 @@ 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 = getConexao().prepareStatement(sql);
|
||||
stmt.setFetchSize(100);
|
||||
stmt.setString(1, DateUtil.getStringDate(inicio, DATE_FORMAT_FISCAL));
|
||||
stmt.setString(2, DateUtil.getStringDate(fim, DATE_FORMAT_FISCAL));
|
||||
|
@ -485,7 +508,7 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
ImportacionFiscalVO fiscal = null;
|
||||
String codProduto = null;
|
||||
|
||||
ResultSet rset = stmt.executeQuery();
|
||||
rset = stmt.executeQuery();
|
||||
while (rset.next()) {
|
||||
|
||||
ItemFiscalVO item = new ItemFiscalVO();
|
||||
|
@ -545,10 +568,14 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
list.add(fiscal);
|
||||
}
|
||||
|
||||
if (!getConexao().isClosed())
|
||||
getConexao().close();
|
||||
|
||||
return list;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(e.getMessage(), e);
|
||||
throw new SQLException(e);
|
||||
} finally {
|
||||
fecharconexao();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validaValorExiste(BigDecimal valor) {
|
||||
|
@ -747,6 +774,10 @@ 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, ")
|
||||
|
@ -760,12 +791,12 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
.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 = 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();
|
||||
rset = stmt.executeQuery();
|
||||
List<ImportacionNaoFiscalVO> importacionNaoFiscalVOs = new ArrayList<ImportacionNaoFiscalVO>();
|
||||
while (rset.next()) {
|
||||
ImportacionNaoFiscalVO importacionNaoFiscal = new ImportacionNaoFiscalVO();
|
||||
|
@ -777,14 +808,28 @@ public class FiscalHibernateDAO extends GenericHibernateDAO<String, String> impl
|
|||
importacionNaoFiscalVOs.add(importacionNaoFiscal);
|
||||
}
|
||||
|
||||
if (!getConexao().isClosed())
|
||||
getConexao().close();
|
||||
|
||||
return importacionNaoFiscalVOs;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.info(e.getMessage(), e);
|
||||
throw new SQLException(e);
|
||||
} finally {
|
||||
fecharconexao();
|
||||
}
|
||||
}
|
||||
|
||||
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