bug #6321
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@44212 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
0591b87fea
commit
8a1f62a08d
|
@ -5,6 +5,8 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -33,18 +35,28 @@ public class RelatorioAgenciasNaoImportadas extends Relatorio {
|
|||
String fecInicio = parametros.get("fecInicio").toString() + " 00:00:00";
|
||||
String fecFinal = parametros.get("fecFinal").toString() + " 23:59:59";
|
||||
|
||||
String sql = getSQL();
|
||||
String empresas = getEmpresas(conexao);
|
||||
String sql = getSQL(empresas);
|
||||
|
||||
PreparedStatement stmt = conexao.prepareStatement(sql);
|
||||
ResultSet rs = null;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
|
||||
|
||||
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(sdf.parse(fecInicio));
|
||||
c.add(Calendar.DAY_OF_MONTH, 1);
|
||||
Date di = c.getTime();
|
||||
|
||||
c.setTime(sdf.parse(fecFinal));
|
||||
c.add(Calendar.DAY_OF_MONTH, 1);
|
||||
Date df = c.getTime();
|
||||
|
||||
stmt.setTimestamp(1, new java.sql.Timestamp(sdf.parse(fecInicio).getTime()));
|
||||
stmt.setTimestamp(2, new java.sql.Timestamp(sdf.parse(fecFinal).getTime()));
|
||||
stmt.setTimestamp(3, new java.sql.Timestamp(sdf.parse(fecInicio).getTime()));
|
||||
stmt.setTimestamp(4, new java.sql.Timestamp(sdf.parse(fecFinal).getTime()));
|
||||
stmt.setTimestamp(5, new java.sql.Timestamp(sdf.parse(fecInicio).getTime()));
|
||||
stmt.setTimestamp(6, new java.sql.Timestamp(sdf.parse(fecFinal).getTime()));
|
||||
stmt.setTimestamp(5, new java.sql.Timestamp(di.getTime()));
|
||||
stmt.setTimestamp(6, new java.sql.Timestamp(df.getTime()));
|
||||
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
|
@ -81,8 +93,24 @@ public class RelatorioAgenciasNaoImportadas extends Relatorio {
|
|||
protected void processaParametros() throws Exception {
|
||||
}
|
||||
|
||||
private String getSQL() {
|
||||
private String getEmpresas(Connection conexao){
|
||||
String sql = "select valorconstante from constante where nombconstante = 'EMPRESAS_INTEGRACAO'";
|
||||
try{
|
||||
PreparedStatement stmt = conexao.prepareStatement(sql);
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
if (rs.next()){
|
||||
return rs.getString(1);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
} catch (Exception e){
|
||||
System.out.println(e.toString());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
private String getSQL(String empresas) {
|
||||
|
||||
// Custo da query: 47
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append(" select distinct pu.numpuntoventa, pu.nombpuntoventa, t.fecha from ");
|
||||
sql.append(" punto_venta pu ");
|
||||
|
@ -93,9 +121,12 @@ public class RelatorioAgenciasNaoImportadas extends Relatorio {
|
|||
sql.append(" from ");
|
||||
sql.append(" punto_venta p ");
|
||||
sql.append(" inner join caja c on c.puntoventa_id = p.puntoventa_id ");
|
||||
sql.append(" inner join marca m on c.marca_id = m.marca_id ");
|
||||
sql.append(" where ");
|
||||
sql.append(" c.fecintegracion is null ");
|
||||
sql.append(" and c.FECHORVENTA between ? AND ? ");
|
||||
sql.append(" and c.activo = 1 ");
|
||||
sql.append(" and m.empresa_id in (" + empresas + ") ");
|
||||
sql.append(" union all ");
|
||||
sql.append(" select ");
|
||||
sql.append(" p.puntoventa_id puntoventa_id, ");
|
||||
|
@ -103,9 +134,12 @@ public class RelatorioAgenciasNaoImportadas extends Relatorio {
|
|||
sql.append(" from ");
|
||||
sql.append(" punto_venta p ");
|
||||
sql.append(" inner join caja_diversos cd on cd.puntoventa_id = p.puntoventa_id ");
|
||||
sql.append(" left join evento_extra ev on ev.eventoextra_id = cd.eventoextra_id ");
|
||||
sql.append(" where ");
|
||||
sql.append(" cd.fecintegracion is null ");
|
||||
sql.append(" and cd.FECHORVTA between ? AND ? ");
|
||||
sql.append(" and cd.activo = 1 ");
|
||||
sql.append(" and ev.empresa_id in (" + empresas + ") ");
|
||||
sql.append(" union all ");
|
||||
sql.append(" select ");
|
||||
sql.append(" p.puntoventa_id puntoventa_id, ");
|
||||
|
@ -117,6 +151,8 @@ public class RelatorioAgenciasNaoImportadas extends Relatorio {
|
|||
sql.append(" where ");
|
||||
sql.append(" fb.fecintegracion is null ");
|
||||
sql.append(" and fb.fecdocumento between ? AND ? ");
|
||||
sql.append(" and fb.activo = 1 ");
|
||||
sql.append(" and fc.empresa_id in (" + empresas + ") ");
|
||||
sql.append(" ) t on t.puntoventa_id = pu.puntoventa_id ");
|
||||
sql.append(" order by ");
|
||||
sql.append(" t.fecha, pu.nombpuntoventa ");
|
||||
|
|
|
@ -122,7 +122,6 @@ import com.rjconsultores.ventaboletos.web.utilerias.render.RenderParadaPtoVtaChe
|
|||
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtoVtaSeguro;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaCatInd;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderPtovtaComissao;
|
||||
import com.rjconsultores.ws.totvs.dao.DAO;
|
||||
import com.rjconsultores.ws.totvs.service.TotvsService;
|
||||
import com.rjconsultores.ws.utileria.RetornoTotvs.TipoRetorno;
|
||||
|
||||
|
|
Loading…
Reference in New Issue