leonardo 2015-09-21 14:41:44 +00:00
parent c5d2330393
commit 787df6d0cd
1 changed files with 5 additions and 58 deletions

View File

@ -42,21 +42,8 @@ public class RelatorioAgenciasNaoImportadas extends Relatorio {
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(di.getTime()));
stmt.setTimestamp(6, new java.sql.Timestamp(df.getTime()));
rs = stmt.executeQuery();
@ -112,51 +99,11 @@ public class RelatorioAgenciasNaoImportadas extends Relatorio {
// Custo da query: 40
StringBuilder sql = new StringBuilder();
sql.append(" select distinct pu.numpuntoventa, pu.nombpuntoventa, t.fecha from ");
sql.append(" punto_venta pu ");
sql.append(" inner join ( ");
sql.append(" select ");
sql.append(" p.puntoventa_id puntoventa_id, ");
sql.append(" TRUNC(c.fechorventa ) fecha ");
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(" and (c.motivocancelacion_id is null or c.motivocancelacion_id <> 35) ");
sql.append(" union all ");
sql.append(" select ");
sql.append(" p.puntoventa_id puntoventa_id, ");
sql.append(" TRUNC(cd.fechorvta ) fecha ");
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, ");
sql.append(" TRUNC(fb.fecdocumento ) fecha ");
sql.append(" from ");
sql.append(" punto_venta p ");
sql.append(" inner join fechamento_cntcorrente fc on fc.puntoventa_id = p.puntoventa_id ");
sql.append(" inner join fechamento_boleto fb on fb.FECHAMENTOCNTCORRENTE_ID = fc.FECHAMENTOCNTCORRENTE_ID ");
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 ");
sql.append(" select distinct p.numpuntoventa, p.nombpuntoventa, t.feccorte ");
sql.append(" from punto_venta p ");
sql.append(" inner join titulo_integracion t on t.puntoventa_id = p.puntoventa_id ");
sql.append(" where t.feccorte between ? AND ? and t.fecintegracion is null ");
sql.append(" order by t.feccorte, p.nombpuntoventa ");
return sql.toString();
}