diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java index 2556afbe6..d9d389783 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioDemandasDetalhadoNovoLayout.java @@ -12,12 +12,24 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.zkoss.util.resource.Labels; +import org.zkoss.zul.Messagebox; + +import com.rjconsultores.ventaboletos.dao.ConstanteDAO; +import com.rjconsultores.ventaboletos.entidad.Constante; import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource; import com.rjconsultores.ventaboletos.utilerias.DateUtil; import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; +import bsh.StringUtil; + public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { - public RelatorioDemandasDetalhadoNovoLayout(Map parametros, Connection conexao) throws Exception { + public final String VENDA_EM_PE = "00"; + + public RelatorioDemandasDetalhadoNovoLayout(Map parametros, Connection conexao, final Boolean filtrarCrianca, final Boolean filtrarEmPe, final ConstanteDAO constanteDao) throws Exception { super(parametros, conexao); this.setCustomDataSource(new ArrayDataSource(this) { @Override @@ -60,12 +72,10 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { sql.append(" da.cantasientos as capacidade, "); sql.append(" count(bo.boleto_id) as ocupacao, "); sql.append(" ts.descservicio as tipo_servico, "); - sql.append(" ( select ctr1.PLATAFORMA from corrida_tramo ctr1 where ctr1.activo =1 and ctr1.corrida_id = co.corrida_id AND ctr1.numsecuencia = 1 AND ctr1.feccorrida = co.feccorrida AND ctr1.fechorsalida = co.FECHORSALIDA AND rownum <2 ) AS plataforma, "); sql.append(" e.nombempresa as empresa, "); sql.append(" r.INDSENTIDOIDA AS sentido "); sql.append("from boleto bo "); sql.append(" join corrida co on co.corrida_id = bo.corrida_id and co.feccorrida = bo.feccorrida "); - sql.append(" join corrida_tramo ct on ct.corrida_id = bo.corrida_id and bo.feccorrida = ct.feccorrida and ct.origen_id = bo.origen_id "); sql.append(" join ruta r on co.ruta_id = r.ruta_id "); sql.append(" left join empresa e on e.empresa_id = bo.empresacorrida_id "); sql.append(" join parada ori on ori.parada_id = co.origen_id "); @@ -74,15 +84,30 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { sql.append(" join rol_operativo ro on ro.roloperativo_id = co.roloperativo_id "); sql.append(" join diagrama_autobus da on ro.diagramaautobus_id = da.diagramaautobus_id "); sql.append(" join tipo_servicio ts on ts.tiposervicio_id = co.tiposervicio_id "); - sql.append("where ct.activo = 1 "); - sql.append(" and bo.motivocancelacion_id is null and bo.numasiento is not null and bo.indstatusoperacion = 'F' "); + sql.append(" where bo.motivocancelacion_id is null and bo.numasiento is not null and bo.indstatusoperacion = 'F' "); if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { sql.append(" and co.fechorsalida >= :DATA_INICIAL and co.fechorsalida <= :DATA_FINAL "); } - sql.append(" and co.activo = 1 and bo.activo = 1 and ct.activo = 1 and r.activo = 1 and e.activo = 1 and ori.activo = 1 and "); + sql.append(" and co.activo = 1 and bo.activo = 1 and r.activo = 1 and e.activo = 1 and ori.activo = 1 and "); sql.append(" des.activo = 1 and cs.activo = 1 and ro.activo = 1 and da.activo = 1 and ts.activo = 1 "); + if (filtrarCrianca){ + Constante idGratuidadeCrianca = constanteDao.buscarPorNomeConstante("CRIANÇA GRATUIDADE"); + if (idGratuidadeCrianca != null && StringUtils.isNotBlank(idGratuidadeCrianca.getValorconstante())){ + sql.append(" and bo.categoria_id != "+ idGratuidadeCrianca.getValorconstante() +" "); + } else { + Messagebox.show( + Labels.getLabel("relatorioDemandasController.ConstanteGratuidadeError"), + Labels.getLabel("relatorioDemandasController.window.title"), + Messagebox.OK, Messagebox.ERROR); + } + } + + if (filtrarEmPe){ + sql.append(" and bo.numasiento != '"+VENDA_EM_PE+"' "); + } + sql.append((parametros.get("RUTA_ID") != null) ? " and r.ruta_id = :RUTA_ID " : ""); sql.append((parametros.get("EMPRESA_ID") != null) ? " and e.empresa_id = :EMPRESA_ID " : ""); sql.append((parametros.get("PARADA_ID") != null) ? " and bo.origen_id = :PARADA_ID " : ""); @@ -106,11 +131,11 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { sql.append(" ) "); } - sql.append("group by co.feccorrida, co.fechorsalida, r.descruta, r.numruta, co.corrida_id, ct.plataforma, "); + sql.append("group by co.feccorrida, co.fechorsalida, r.descruta, r.numruta, co.corrida_id, "); sql.append(" case when ((ori.indvisibleinternet is null or ori.indvisibleinternet = 1) "); sql.append(" and (des.indvisibleinternet is null or des.indvisibleinternet = 1)) then 'SIM' else 'NÃO' end, "); sql.append(" ori.descparada, des.descparada, cs.descclase, "); - sql.append(" da.cantasientos, ts.descservicio, ct.plataforma, e.nombempresa, r.INDSENTIDOIDA "); + sql.append(" da.cantasientos, ts.descservicio, e.nombempresa, r.INDSENTIDOIDA "); sql.append("order by data, horario, servico, linha, origem, destino "); sql.append(" ), nao_vendidos as ( "); @@ -136,14 +161,9 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { sql.append(" da.cantasientos AS capacidade, "); sql.append(" 0 AS ocupacao, "); sql.append(" ts.descservicio AS tipo_servico, "); - sql.append(" ( select ctr1.PLATAFORMA from corrida_tramo ctr1 where ctr1.activo =1 and ctr1.corrida_id = co.corrida_id AND ctr1.numsecuencia = 1 AND ctr1.feccorrida = co.feccorrida AND ctr1.fechorsalida = co.FECHORSALIDA AND rownum <2 ) AS plataforma, "); sql.append(" e.nombempresa AS empresa, "); sql.append(" r.INDSENTIDOIDA AS sentido "); sql.append(" FROM corrida co "); - sql.append(" JOIN corrida_tramo ct "); - sql.append(" ON ct.corrida_id = co.corrida_id "); - sql.append(" AND co.feccorrida = ct.feccorrida "); - sql.append(" AND ct.origen_id = co.origen_id "); sql.append(" JOIN ruta r "); sql.append(" ON co.ruta_id = r.ruta_id "); sql.append(" LEFT JOIN empresa e "); @@ -160,8 +180,7 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { sql.append(" ON ro.diagramaautobus_id = da.diagramaautobus_id "); sql.append(" JOIN tipo_servicio ts "); sql.append(" ON ts.tiposervicio_id = co.tiposervicio_id "); - sql.append(" WHERE ct.activo = 1 "); - sql.append(" and co.activo = 1 "); + sql.append(" WHERE co.activo = 1 "); if (parametros.get("HORA_INICIAL") == null && parametros.get("HORA_FINAL") == null) { sql.append(" and co.FECHORSALIDA >= :DATA_INICIAL and co.FECHORSALIDA <= :DATA_FINAL "); } @@ -174,7 +193,7 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { sql.append(" and (co.CORRIDA_ID, co.feccorrida) not in (select servico, data_corrida from vendidos ) "); - sql.append(" and co.activo = 1 and ct.activo = 1 and r.activo = 1 and e.activo = 1 and ori.activo = 1 and des.activo = 1 and "); + sql.append(" and co.activo = 1 and r.activo = 1 and e.activo = 1 and ori.activo = 1 and des.activo = 1 and "); sql.append(" cs.activo = 1 and ro.activo = 1 and da.activo = 1 and ts.activo = 1 "); if (parametros.get("HORA_INICIAL") != null && parametros.get("HORA_FINAL") != null) { @@ -195,10 +214,10 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { } sql.append(" )select "); - sql.append(" DATA_CORRIDA, DATA, LINHA, CODLINHA, SERVICO, INTERNET, HORARIO, ORIGEM, DESTINO, CLASSE, CAPACIDADE, SUM(OCUPACAO) OCUPACAO, TIPO_SERVICO, PLATAFORMA, EMPRESA, SENTIDO "); + sql.append(" DATA_CORRIDA, DATA, LINHA, CODLINHA, SERVICO, INTERNET, HORARIO, ORIGEM, DESTINO, CLASSE, CAPACIDADE, SUM(OCUPACAO) OCUPACAO, TIPO_SERVICO, EMPRESA, SENTIDO "); sql.append(" from ( "); sql.append(" select * from vendidos v union select * from nao_vendidos ) "); - sql.append(" GROUP BY DATA_CORRIDA, DATA, LINHA, CODLINHA, SERVICO, INTERNET, HORARIO, ORIGEM, DESTINO, CLASSE, CAPACIDADE, TIPO_SERVICO, PLATAFORMA, EMPRESA, SENTIDO "); + sql.append(" GROUP BY DATA_CORRIDA, DATA, LINHA, CODLINHA, SERVICO, INTERNET, HORARIO, ORIGEM, DESTINO, CLASSE, CAPACIDADE, TIPO_SERVICO, EMPRESA, SENTIDO "); sql.append(" order by data, horario, servico, linha, origem, destino "); @@ -233,7 +252,6 @@ public class RelatorioDemandasDetalhadoNovoLayout extends RelatorioDemandas { dataResult.put("CLASSE", rset.getString("CLASSE")); dataResult.put("CAPACIDADE", rset.getInt("CAPACIDADE")); dataResult.put("TIPO_SERVICO", rset.getString("TIPO_SERVICO")); - dataResult.put("PLATAFORMA", rset.getString("PLATAFORMA")); dataResult.put("OCUPACAO", rset.getInt("OCUPACAO")); dataResult.put("EMPRESA", rset.getString("EMPRESA")); dataResult.put("CODLINHA", rset.getString("CODLINHA")); diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jasper index 3fba3d55c..65f7c9da4 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jrxml index 3c143535d..d9c70b5f4 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioDemandasDetalhadoNovoLayout.jrxml @@ -1,7 +1,7 @@ - +