B6 - SISDAP Relatório ANTT (fixed bug #5247)
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@35644 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
1d7ada35f5
commit
bc1a9c19d8
|
@ -2,18 +2,22 @@ package com.rjconsultores.ventaboletos.dao.hibernate;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.transform.AliasToBeanResultTransformer;
|
||||
import org.hibernate.type.IntegerType;
|
||||
import org.hibernate.type.StringType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.SisdapDAO;
|
||||
import com.rjconsultores.ventaboletos.relatorios.MovimentoLinha;
|
||||
import com.rjconsultores.ventaboletos.relatorios.MovimentoSecoes;
|
||||
|
||||
@Repository("sisdapDAO")
|
||||
public class SisdapHibernateDAO extends HibernateDaoSupport implements SisdapDAO {
|
||||
|
@ -30,196 +34,296 @@ public class SisdapHibernateDAO extends HibernateDaoSupport implements SisdapDAO
|
|||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("select e.codantt, ");
|
||||
sb.append(" r.prefixo, ");
|
||||
sb.append(" nvl(case subviagens.sentido ");
|
||||
sb.append(" when 1 then count(subviagens.ruta) ");
|
||||
sb.append(" end, 0) viagens_ida, ");
|
||||
sb.append(" nvl(case subviagens.sentido ");
|
||||
sb.append(" when 0 then count(subviagens.ruta) ");
|
||||
sb.append(" end, 0) viagens_volta, ");
|
||||
sb.append(" nvl(case subviagens.sentido ");
|
||||
sb.append(" when 1 then ( da.cantasientos * count(subviagens.ruta) ) ");
|
||||
sb.append(" end, 0) lugares_ida, ");
|
||||
sb.append(" nvl(case subviagens.sentido ");
|
||||
sb.append(" when 0 then ( da.cantasientos * count(subviagens.ruta) ) ");
|
||||
sb.append(" end, 0) lugares_volta, ");
|
||||
sb.append(" r.ruta_id, ");
|
||||
sb.append(" e.empresa_id ");
|
||||
sb.append("from corrida c ");
|
||||
sb.append("SELECT DISTINCT e.codantt antt, ");
|
||||
sb.append(" r.prefixo prefixo, ");
|
||||
sb.append(" TO_CHAR(c.feccorrida, 'MM') mes, ");
|
||||
sb.append(" TO_CHAR(c.feccorrida, 'yyyy') ano, ");
|
||||
sb.append(" NVL(CASE subviagens.sentido ");
|
||||
sb.append(" WHEN 1 THEN Count(subviagens.ruta) ");
|
||||
sb.append(" END, 0) viagensIda, ");
|
||||
sb.append(" NVL(CASE subviagens.sentido ");
|
||||
sb.append(" WHEN 0 THEN Count(subviagens.ruta) ");
|
||||
sb.append(" END, 0) viagensVolta, ");
|
||||
sb.append(" NVL(CASE subviagens.sentido ");
|
||||
sb.append(" WHEN 1 THEN ( da.cantasientos * Count(subviagens.ruta) ) ");
|
||||
sb.append(" END, 0) lugaresIda, ");
|
||||
sb.append(" NVL(CASE subviagens.sentido ");
|
||||
sb.append(" WHEN 0 THEN ( da.cantasientos * Count(subviagens.ruta) ) ");
|
||||
sb.append(" END, 0) lugaresVolta ");
|
||||
sb.append("FROM corrida c ");
|
||||
sb.append(" inner join ruta r ");
|
||||
sb.append(" on r.ruta_id = c.ruta_id ");
|
||||
sb.append(" ON r.ruta_id = c.ruta_id ");
|
||||
sb.append(" inner join empresa e ");
|
||||
sb.append(" on e.empresa_id = c.empresacorrida_id ");
|
||||
sb.append(" ON e.empresa_id = c.empresacorrida_id ");
|
||||
sb.append(" left join rol_operativo ro ");
|
||||
sb.append(" on c.roloperativo_id = ro.roloperativo_id ");
|
||||
sb.append(" ON c.roloperativo_id = ro.roloperativo_id ");
|
||||
sb.append(" left join diagrama_autobus da ");
|
||||
sb.append(" on da.diagramaautobus_id = ro.diagramaautobus_id, ");
|
||||
sb.append(" (select ru.ruta_id as ruta, ");
|
||||
sb.append(" bo.corrida_id as corrida, ");
|
||||
sb.append(" bo.feccorrida as feccorrida, ");
|
||||
sb.append(" bo.empresacorrida_id as empresacorrida, ");
|
||||
sb.append(" ru.indsentidoida as sentido ");
|
||||
sb.append(" from boleto bo ");
|
||||
sb.append(" left join ruta ru ");
|
||||
sb.append(" on ru.ruta_id = bo.ruta_id ");
|
||||
sb.append(" where bo.numasiento is not null ");
|
||||
sb.append(" and bo.motivocancelacion_id is null ");
|
||||
sb.append(" and bo.feccorrida between to_date(:fecInicio, 'DD/MM/YYYY') and ");
|
||||
sb.append(" to_date(:fecFinal, 'DD/MM/YYYY') ");
|
||||
sb.append(" group by ru.ruta_id, ");
|
||||
sb.append(" bo.corrida_id, ");
|
||||
sb.append(" bo.feccorrida, ");
|
||||
sb.append(" bo.empresacorrida_id, ");
|
||||
sb.append(" ru.indsentidoida) subviagens ");
|
||||
sb.append("where e.empresa_id = :empresa_id ");
|
||||
sb.append(" and subviagens.ruta = r.ruta_id ");
|
||||
sb.append(" and subviagens.corrida = c.corrida_id ");
|
||||
sb.append(" and subviagens.feccorrida = c.feccorrida ");
|
||||
sb.append(" and subviagens.empresacorrida = e.empresa_id ");
|
||||
sb.append(" and e.codantt is not null ");
|
||||
sb.append(" and c.feccorrida between to_date(:fecInicio, 'DD/MM/YYYY') and ");
|
||||
sb.append(" to_date(:fecFinal, 'DD/MM/YYYY') ");
|
||||
sb.append("group by e.codantt, ");
|
||||
sb.append(" ON da.diagramaautobus_id = ro.diagramaautobus_id ");
|
||||
sb.append(" left join (SELECT DISTINCT ru.prefixo ruta, ");
|
||||
sb.append(" bo.corrida_id corrida, ");
|
||||
sb.append(" bo.feccorrida feccorrida, ");
|
||||
sb.append(" bo.empresacorrida_id empresacorrida, ");
|
||||
sb.append(" ru.indsentidoida sentido ");
|
||||
sb.append(" FROM boleto bo ");
|
||||
sb.append(" left join ruta ru ");
|
||||
sb.append(" ON ru.ruta_id = bo.ruta_id ");
|
||||
sb.append(" WHERE bo.numasiento IS NOT NULL ");
|
||||
sb.append(" AND bo.motivocancelacion_id IS NULL ");
|
||||
sb.append(" AND bo.feccorrida BETWEEN To_date(:fecInicio, 'DD/MM/YYYY') AND ");
|
||||
sb.append(" To_date(:fecFinal, 'DD/MM/YYYY') ");
|
||||
sb.append(" GROUP BY ru.prefixo, ");
|
||||
sb.append(" bo.corrida_id, ");
|
||||
sb.append(" bo.feccorrida, ");
|
||||
sb.append(" bo.empresacorrida_id, ");
|
||||
sb.append(" ru.indsentidoida) subviagens ");
|
||||
sb.append(" ON ( subviagens.ruta = r.prefixo ");
|
||||
sb.append(" AND subviagens.corrida = c.corrida_id ");
|
||||
sb.append(" AND subviagens.feccorrida = c.feccorrida ");
|
||||
sb.append(" AND subviagens.empresacorrida = e.empresa_id ) ");
|
||||
sb.append("WHERE e.empresa_id = :empresaId ");
|
||||
sb.append(" AND r.orgaoconcedente_id = 3 ");
|
||||
sb.append(" AND e.codantt IS NOT NULL ");
|
||||
sb.append(" AND c.feccorrida BETWEEN To_date(:fecInicio, 'DD/MM/YYYY') AND ");
|
||||
sb.append(" To_date(:fecFinal, 'DD/MM/YYYY') ");
|
||||
sb.append("GROUP BY e.codantt, ");
|
||||
sb.append(" r.prefixo, ");
|
||||
sb.append(" da.cantasientos, ");
|
||||
sb.append(" r.ruta_id, ");
|
||||
sb.append(" e.empresa_id, ");
|
||||
sb.append(" subviagens.sentido ");
|
||||
sb.append("order by r.ruta_id ");
|
||||
sb.append(" subviagens.sentido, ");
|
||||
sb.append(" To_char(c.feccorrida, 'MM'), ");
|
||||
sb.append(" To_char(c.feccorrida, 'yyyy') ");
|
||||
sb.append("ORDER BY mes, ");
|
||||
sb.append(" ano, ");
|
||||
sb.append(" e.codantt, ");
|
||||
sb.append(" r.prefixo, ");
|
||||
sb.append(" viagensida, ");
|
||||
sb.append(" viagensvolta ");
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString())
|
||||
.setParameter("fecInicio", sdf.format(fecInicio))
|
||||
.setParameter("fecFinal", sdf.format(fecFinal))
|
||||
.setParameter("empresa_id", empresaId);
|
||||
List<Object[]> result = query.list();
|
||||
.addScalar("antt", StringType.INSTANCE)
|
||||
.addScalar("prefixo", StringType.INSTANCE)
|
||||
.addScalar("mes", IntegerType.INSTANCE)
|
||||
.addScalar("ano", IntegerType.INSTANCE)
|
||||
.addScalar("viagensIda", IntegerType.INSTANCE)
|
||||
.addScalar("viagensVolta", IntegerType.INSTANCE)
|
||||
.addScalar("lugaresIda", IntegerType.INSTANCE)
|
||||
.addScalar("lugaresVolta", IntegerType.INSTANCE);
|
||||
query.setResultTransformer(new AliasToBeanResultTransformer(MovimentoLinha.class));
|
||||
|
||||
query.setParameter("fecInicio", sdf.format(fecInicio));
|
||||
query.setParameter("fecFinal", sdf.format(fecFinal));
|
||||
query.setParameter("empresaId", empresaId);
|
||||
|
||||
List<MovimentoLinha> list = query.list();
|
||||
|
||||
movimentoLinhas.add("empresa;prefixo;mes;ano;viagem_ida;viagem_volta;lugar_ida;lugar_volta");
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(fecInicio);
|
||||
int month = cal.get(Calendar.MONTH) + 1; // o mês na classe Calendar é zero based
|
||||
int year = cal.get(Calendar.YEAR);
|
||||
List<MovimentoLinha> result = new ArrayList<MovimentoLinha>();
|
||||
|
||||
for (Object[] row : result) {
|
||||
movimentoLinhas.add(row[0].toString() + ";"
|
||||
+ row[1].toString() + ";" +
|
||||
+month + ";"
|
||||
+ year + ";"
|
||||
+ row[2].toString() + ";"
|
||||
+ row[3].toString() + ";"
|
||||
+ row[4].toString() + ";"
|
||||
+ row[5].toString());
|
||||
for (MovimentoLinha movimentoLinha : list) {
|
||||
boolean insert = agrupaMovimentoLinhas(result, movimentoLinha);
|
||||
if (insert)
|
||||
result.add(movimentoLinha);
|
||||
}
|
||||
|
||||
for (MovimentoLinha movimentoLinha : result) {
|
||||
movimentoLinhas.add(movimentoLinha.toString());
|
||||
}
|
||||
|
||||
return movimentoLinhas;
|
||||
}
|
||||
|
||||
private boolean agrupaMovimentoLinhas(List<MovimentoLinha> resul, MovimentoLinha movimentoLinha) {
|
||||
|
||||
if (resul.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
for (MovimentoLinha ml : resul) {
|
||||
if (ml.getPrefixo().equals(movimentoLinha.getPrefixo()) && ml.getMes().equals(movimentoLinha.getMes())
|
||||
&& ml.getAno().equals(movimentoLinha.getAno())) {
|
||||
|
||||
if (movimentoLinha.getViagensVolta() > 0) {
|
||||
ml.setLugaresVolta(movimentoLinha.getLugaresVolta());
|
||||
ml.setViagensVolta(movimentoLinha.getViagensVolta());
|
||||
}
|
||||
|
||||
if (movimentoLinha.getViagensIda() > 0) {
|
||||
ml.setLugaresIda(movimentoLinha.getLugaresIda());
|
||||
ml.setViagensIda(movimentoLinha.getViagensIda());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMovimentoSecoes(Date fecInicio, Date fecFinal, Integer empresaId) {
|
||||
List<String> movimentoSecoes = new ArrayList<String>();
|
||||
List<String> movimentosSecoes = new ArrayList<String>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("select distinct e.codantt, ");
|
||||
sb.append(" r.ruta_id, ");
|
||||
sb.append(" r.prefixo, ");
|
||||
sb.append(" po.codantt as local_origem, ");
|
||||
sb.append(" pd.codantt as local_destino, ");
|
||||
sb.append(" nvl(case r.indsentidoida ");
|
||||
sb.append(" when 1 then count(*) ");
|
||||
sb.append(" end, 0) passageiros_ida, ");
|
||||
sb.append(" nvl(case r.indsentidoida ");
|
||||
sb.append(" when 0 then count(*) ");
|
||||
sb.append(" end, 0) passageiros_volta, ");
|
||||
sb.append(" nvl(case ");
|
||||
sb.append(" when r.indsentidoida = 1 ");
|
||||
sb.append(" and b.categoria_id in (select categoria_id ");
|
||||
sb.append(" from categoria ");
|
||||
sb.append(" where grupocategoria_id in ( 1, 2 )) then count(*) ");
|
||||
sb.append(" end, 0) gratuidade_passe_livre_ida, ");
|
||||
sb.append(" nvl(case ");
|
||||
sb.append(" when r.indsentidoida = 0 ");
|
||||
sb.append(" and b.categoria_id in (select categoria_id ");
|
||||
sb.append(" from categoria ");
|
||||
sb.append(" where grupocategoria_id in ( 1, 2 )) then count(*) ");
|
||||
sb.append(" end, 0) gratuidade_passe_livre_volta, ");
|
||||
sb.append(" nvl(case ");
|
||||
sb.append(" when r.indsentidoida = 1 ");
|
||||
sb.append(" and b.categoria_id in (select categoria_id ");
|
||||
sb.append(" from categoria ");
|
||||
sb.append(" where grupocategoria_id = 1) then count(*) ");
|
||||
sb.append(" end, 0) gratuidade_idoso_ida, ");
|
||||
sb.append(" nvl(case ");
|
||||
sb.append(" when r.indsentidoida = 0 ");
|
||||
sb.append(" and b.categoria_id in (select categoria_id ");
|
||||
sb.append(" from categoria ");
|
||||
sb.append(" where grupocategoria_id = 1) then count(*) ");
|
||||
sb.append(" end, 0) gratuidade_idoso_volta, ");
|
||||
sb.append(" nvl(case ");
|
||||
sb.append(" when r.indsentidoida = 1 ");
|
||||
sb.append(" and b.categoria_id in (select categoria_id ");
|
||||
sb.append(" from categoria ");
|
||||
sb.append(" where grupocategoria_id = 3) then count(*) ");
|
||||
sb.append(" end, 0) desconto_idoso_ida, ");
|
||||
sb.append(" nvl(case ");
|
||||
sb.append(" when r.indsentidoida = 0 ");
|
||||
sb.append(" and b.categoria_id in (select categoria_id ");
|
||||
sb.append(" from categoria ");
|
||||
sb.append(" where grupocategoria_id = 3) then count(*) ");
|
||||
sb.append(" end, 0) desconto_idoso_volta ");
|
||||
sb.append("from boleto b ");
|
||||
sb.append(" join ruta r ");
|
||||
sb.append(" on r.ruta_id = b.ruta_id ");
|
||||
sb.append(" join parada po ");
|
||||
sb.append(" on po.parada_id = b.origen_id ");
|
||||
sb.append(" join parada pd ");
|
||||
sb.append(" on pd.parada_id = b.destino_id ");
|
||||
sb.append(" join empresa e ");
|
||||
sb.append(" on e.empresa_id = b.empresacorrida_id ");
|
||||
sb.append("where b.numasiento is not null ");
|
||||
sb.append(" and b.motivocancelacion_id is null ");
|
||||
sb.append(" and e.codantt is not null ");
|
||||
sb.append(" and e.empresa_id = :empresa_id ");
|
||||
sb.append(" and b.feccorrida between to_date(:fecInicio, 'DD/MM/YYYY') and to_date(:fecFinal, 'DD/MM/YYYY') ");
|
||||
sb.append("group by e.codantt, ");
|
||||
sb.append(" r.ruta_id, ");
|
||||
sb.append("SELECT DISTINCT e.codantt antt, ");
|
||||
sb.append(" r.prefixo prefixo, ");
|
||||
sb.append(" To_char(c.feccorrida, 'MM') mes, ");
|
||||
sb.append(" To_char(c.feccorrida, 'yyyy') ano, ");
|
||||
sb.append(" CASE r.indsentidoida ");
|
||||
sb.append(" WHEN 1 THEN po.codantt ");
|
||||
sb.append(" ELSE pd.codantt ");
|
||||
sb.append(" END localOrigem, ");
|
||||
sb.append(" CASE r.indsentidoida ");
|
||||
sb.append(" WHEN 1 THEN pd.codantt ");
|
||||
sb.append(" ELSE po.codantt ");
|
||||
sb.append(" END localDestino, ");
|
||||
sb.append(" Nvl(CASE r.indsentidoida ");
|
||||
sb.append(" WHEN 1 THEN Count(*) ");
|
||||
sb.append(" END, 0) passageirosIda, ");
|
||||
sb.append(" Nvl(CASE r.indsentidoida ");
|
||||
sb.append(" WHEN 0 THEN Count(*) ");
|
||||
sb.append(" END, 0) passageirosVolta, ");
|
||||
sb.append(" Nvl(CASE ");
|
||||
sb.append(" WHEN r.indsentidoida = 1 ");
|
||||
sb.append(" AND b.categoria_id IN (SELECT categoria_id ");
|
||||
sb.append(" FROM categoria ");
|
||||
sb.append(" WHERE grupocategoria_id IN ( 1, 2 )) THEN Count(* ");
|
||||
sb.append(" ) ");
|
||||
sb.append(" END, 0) gratuidadePasseLivreIda, ");
|
||||
sb.append(" Nvl(CASE ");
|
||||
sb.append(" WHEN r.indsentidoida = 0 ");
|
||||
sb.append(" AND b.categoria_id IN (SELECT categoria_id ");
|
||||
sb.append(" FROM categoria ");
|
||||
sb.append(" WHERE grupocategoria_id IN ( 1, 2 )) THEN Count(* ");
|
||||
sb.append(" ) ");
|
||||
sb.append(" END, 0) gratuidadePasseLivreVolta, ");
|
||||
sb.append(" Nvl(CASE ");
|
||||
sb.append(" WHEN r.indsentidoida = 1 ");
|
||||
sb.append(" AND b.categoria_id IN (SELECT categoria_id ");
|
||||
sb.append(" FROM categoria ");
|
||||
sb.append(" WHERE grupocategoria_id = 1) THEN Count(*) ");
|
||||
sb.append(" END, 0) gratuidadeIdosoIda, ");
|
||||
sb.append(" Nvl(CASE ");
|
||||
sb.append(" WHEN r.indsentidoida = 0 ");
|
||||
sb.append(" AND b.categoria_id IN (SELECT categoria_id ");
|
||||
sb.append(" FROM categoria ");
|
||||
sb.append(" WHERE grupocategoria_id = 1) THEN Count(*) ");
|
||||
sb.append(" END, 0) gratuidadeIdosoVolta, ");
|
||||
sb.append(" Nvl(CASE ");
|
||||
sb.append(" WHEN r.indsentidoida = 1 ");
|
||||
sb.append(" AND b.categoria_id IN (SELECT categoria_id ");
|
||||
sb.append(" FROM categoria ");
|
||||
sb.append(" WHERE grupocategoria_id = 3) THEN Count(*) ");
|
||||
sb.append(" END, 0) descontoIdosoIda, ");
|
||||
sb.append(" Nvl(CASE ");
|
||||
sb.append(" WHEN r.indsentidoida = 0 ");
|
||||
sb.append(" AND b.categoria_id IN (SELECT categoria_id ");
|
||||
sb.append(" FROM categoria ");
|
||||
sb.append(" WHERE grupocategoria_id = 3) THEN Count(*) ");
|
||||
sb.append(" END, 0) descontoIdosoVolta ");
|
||||
sb.append("FROM corrida c ");
|
||||
sb.append(" left join boleto b ");
|
||||
sb.append(" ON c.corrida_id = b.corrida_id ");
|
||||
sb.append(" AND c.feccorrida = b.feccorrida ");
|
||||
sb.append(" left join ruta r ");
|
||||
sb.append(" ON r.ruta_id = c.ruta_id ");
|
||||
sb.append(" left join parada po ");
|
||||
sb.append(" ON po.parada_id = b.origen_id ");
|
||||
sb.append(" left join parada pd ");
|
||||
sb.append(" ON pd.parada_id = b.destino_id ");
|
||||
sb.append(" left join empresa e ");
|
||||
sb.append(" ON e.empresa_id = b.empresacorrida_id ");
|
||||
sb.append("WHERE r.orgaoconcedente_id = 3 ");
|
||||
sb.append(" AND b.numasiento IS NOT NULL ");
|
||||
sb.append(" AND b.motivocancelacion_id IS NULL ");
|
||||
sb.append(" AND e.codantt IS NOT NULL ");
|
||||
sb.append(" AND e.empresa_id = :empresaId ");
|
||||
sb.append(" AND c.feccorrida BETWEEN To_date(:fecInicio, 'DD/MM/YYYY') AND ");
|
||||
sb.append(" To_date(:fecFinal, 'DD/MM/YYYY') ");
|
||||
sb.append("GROUP BY e.codantt, ");
|
||||
sb.append(" r.prefixo, ");
|
||||
sb.append(" To_char(c.feccorrida, 'MM'), ");
|
||||
sb.append(" To_char(c.feccorrida, 'yyyy'), ");
|
||||
sb.append(" po.codantt, ");
|
||||
sb.append(" pd.codantt, ");
|
||||
sb.append(" r.indsentidoida, ");
|
||||
sb.append(" b.categoria_id ");
|
||||
sb.append("ORDER BY mes, ");
|
||||
sb.append(" ano, ");
|
||||
sb.append(" e.codantt, ");
|
||||
sb.append(" r.prefixo, ");
|
||||
sb.append(" localOrigem, ");
|
||||
sb.append(" localDestino ");
|
||||
|
||||
Query query = getSession().createSQLQuery(sb.toString())
|
||||
.setParameter("fecInicio", sdf.format(fecInicio))
|
||||
.setParameter("fecFinal", sdf.format(fecFinal))
|
||||
.setParameter("empresa_id", empresaId);
|
||||
List<Object[]> result = query.list();
|
||||
.addScalar("antt", StringType.INSTANCE)
|
||||
.addScalar("prefixo", StringType.INSTANCE)
|
||||
.addScalar("mes", IntegerType.INSTANCE)
|
||||
.addScalar("ano", IntegerType.INSTANCE)
|
||||
.addScalar("localOrigem", StringType.INSTANCE)
|
||||
.addScalar("localDestino", StringType.INSTANCE)
|
||||
.addScalar("passageirosIda", IntegerType.INSTANCE)
|
||||
.addScalar("passageirosVolta", IntegerType.INSTANCE)
|
||||
.addScalar("gratuidadePasseLivreIda", IntegerType.INSTANCE)
|
||||
.addScalar("gratuidadePasseLivreVolta", IntegerType.INSTANCE)
|
||||
.addScalar("gratuidadeIdosoIda", IntegerType.INSTANCE)
|
||||
.addScalar("gratuidadeIdosoVolta", IntegerType.INSTANCE)
|
||||
.addScalar("descontoIdosoIda", IntegerType.INSTANCE)
|
||||
.addScalar("descontoIdosoVolta", IntegerType.INSTANCE);
|
||||
|
||||
movimentoSecoes.add("empresa;prefixo;local_origem;local_destino;mes;ano;passageiro_ida;passageiro_volta;gratuidade_ida" +
|
||||
query.setResultTransformer(new AliasToBeanResultTransformer(MovimentoSecoes.class));
|
||||
|
||||
query.setParameter("fecInicio", sdf.format(fecInicio));
|
||||
query.setParameter("fecFinal", sdf.format(fecFinal));
|
||||
query.setParameter("empresaId", empresaId);
|
||||
|
||||
List<MovimentoSecoes> list = query.list();
|
||||
|
||||
movimentosSecoes.add("empresa;prefixo;local_origem;local_destino;mes;ano;passageiro_ida;passageiro_volta;gratuidade_ida" +
|
||||
";gratuidade_volta;idoso_ida;idoso_volta;desconto_ida;desconto_volta ");
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(fecInicio);
|
||||
int month = cal.get(Calendar.MONTH) + 1; // o mês na classe Calendar é zero based
|
||||
int year = cal.get(Calendar.YEAR);
|
||||
List<MovimentoSecoes> result = new ArrayList<MovimentoSecoes>();
|
||||
|
||||
for (Object[] row : result) {
|
||||
movimentoSecoes.add(row[0].toString() + ";"
|
||||
+ row[1].toString() + ";"
|
||||
+ row[2].toString() + ";"
|
||||
+ row[3].toString() + ";"
|
||||
+ month + ";"
|
||||
+ year + ";"
|
||||
+ row[4].toString() + ";"
|
||||
+ row[5].toString() + ";"
|
||||
+ row[6].toString() + ";"
|
||||
+ row[7].toString() + ";"
|
||||
+ row[8].toString() + ";"
|
||||
+ row[9].toString() + ";"
|
||||
+ row[10].toString() + ";"
|
||||
+ row[11].toString());
|
||||
for (MovimentoSecoes ms : list) {
|
||||
boolean insert = agrupaMovimentoSecoes(result, ms);
|
||||
if (insert)
|
||||
result.add(ms);
|
||||
}
|
||||
|
||||
for (MovimentoSecoes ms : result) {
|
||||
movimentosSecoes.add(ms.toString());
|
||||
}
|
||||
|
||||
return movimentoSecoes;
|
||||
return movimentosSecoes;
|
||||
}
|
||||
|
||||
private boolean agrupaMovimentoSecoes(List<MovimentoSecoes> resul, MovimentoSecoes movimentoSecao) {
|
||||
|
||||
if (resul.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
for (MovimentoSecoes ms : resul) {
|
||||
if (ms.getPrefixo().equals(movimentoSecao.getPrefixo()) && ms.getMes().equals(movimentoSecao.getMes())
|
||||
&& ms.getAno().equals(movimentoSecao.getAno()) && ms.getLocalOrigem().equals(movimentoSecao.getLocalOrigem())
|
||||
&& ms.getLocalDestino().equals(movimentoSecao.getLocalDestino())) {
|
||||
|
||||
ms.setDescontoIdosoIda(ms.getDescontoIdosoIda() + movimentoSecao.getDescontoIdosoIda());
|
||||
ms.setDescontoIdosoVolta(ms.getDescontoIdosoVolta() + movimentoSecao.getDescontoIdosoVolta());
|
||||
|
||||
ms.setGratuidadeIdosoIda(ms.getGratuidadeIdosoIda() + movimentoSecao.getGratuidadeIdosoIda());
|
||||
ms.setGratuidadeIdosoVolta(ms.getGratuidadeIdosoVolta() + movimentoSecao.getGratuidadeIdosoVolta());
|
||||
|
||||
ms.setGratuidadePasseLivreIda(ms.getGratuidadePasseLivreIda() + movimentoSecao.getGratuidadePasseLivreIda());
|
||||
ms.setGratuidadePasseLivreVolta(ms.getGratuidadePasseLivreVolta() + movimentoSecao.getGratuidadePasseLivreVolta());
|
||||
|
||||
ms.setPassageirosIda(ms.getPassageirosIda() + movimentoSecao.getPassageirosIda());
|
||||
ms.setPassageirosVolta(ms.getPassageirosVolta() + movimentoSecao.getPassageirosVolta());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package com.rjconsultores.ventaboletos.relatorios;
|
||||
|
||||
public class MovimentoLinha {
|
||||
private String antt;
|
||||
private String prefixo;
|
||||
private Integer mes;
|
||||
private Integer ano;
|
||||
private Integer viagensIda;
|
||||
private Integer viagensVolta;
|
||||
private Integer lugaresIda;
|
||||
private Integer lugaresVolta;
|
||||
|
||||
public String getAntt() {
|
||||
return antt;
|
||||
}
|
||||
|
||||
public void setAntt(String antt) {
|
||||
this.antt = antt;
|
||||
}
|
||||
|
||||
public String getPrefixo() {
|
||||
return prefixo;
|
||||
}
|
||||
|
||||
public void setPrefixo(String prefixo) {
|
||||
this.prefixo = prefixo;
|
||||
}
|
||||
|
||||
public Integer getMes() {
|
||||
return mes;
|
||||
}
|
||||
|
||||
public void setMes(Integer mes) {
|
||||
this.mes = mes;
|
||||
}
|
||||
|
||||
public Integer getAno() {
|
||||
return ano;
|
||||
}
|
||||
|
||||
public void setAno(Integer ano) {
|
||||
this.ano = ano;
|
||||
}
|
||||
|
||||
public Integer getViagensIda() {
|
||||
return viagensIda;
|
||||
}
|
||||
|
||||
public void setViagensIda(Integer viagensIda) {
|
||||
this.viagensIda = viagensIda;
|
||||
}
|
||||
|
||||
public Integer getViagensVolta() {
|
||||
return viagensVolta;
|
||||
}
|
||||
|
||||
public void setViagensVolta(Integer viagensVolta) {
|
||||
this.viagensVolta = viagensVolta;
|
||||
}
|
||||
|
||||
public Integer getLugaresIda() {
|
||||
return lugaresIda;
|
||||
}
|
||||
|
||||
public void setLugaresIda(Integer lugaresIda) {
|
||||
this.lugaresIda = lugaresIda;
|
||||
}
|
||||
|
||||
public Integer getLugaresVolta() {
|
||||
return lugaresVolta;
|
||||
}
|
||||
|
||||
public void setLugaresVolta(Integer lugaresVolta) {
|
||||
this.lugaresVolta = lugaresVolta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return antt + ";" + prefixo + ";" + mes + ";" + ano + ";" + viagensIda + ";" + viagensVolta + ";" + lugaresIda + ";" + lugaresVolta;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package com.rjconsultores.ventaboletos.relatorios;
|
||||
|
||||
public class MovimentoSecoes {
|
||||
|
||||
private String antt;
|
||||
private String prefixo;
|
||||
private Integer mes;
|
||||
private Integer ano;
|
||||
private String localOrigem;
|
||||
private String localDestino;
|
||||
private Integer passageirosIda;
|
||||
private Integer passageirosVolta;
|
||||
private Integer gratuidadePasseLivreIda;
|
||||
private Integer gratuidadePasseLivreVolta;
|
||||
private Integer gratuidadeIdosoIda;
|
||||
private Integer gratuidadeIdosoVolta;
|
||||
private Integer descontoIdosoIda;
|
||||
private Integer descontoIdosoVolta;
|
||||
|
||||
public String getAntt() {
|
||||
return antt;
|
||||
}
|
||||
|
||||
public void setAntt(String antt) {
|
||||
this.antt = antt;
|
||||
}
|
||||
|
||||
public String getPrefixo() {
|
||||
return prefixo;
|
||||
}
|
||||
|
||||
public void setPrefixo(String prefixo) {
|
||||
this.prefixo = prefixo;
|
||||
}
|
||||
|
||||
public Integer getMes() {
|
||||
return mes;
|
||||
}
|
||||
|
||||
public void setMes(Integer mes) {
|
||||
this.mes = mes;
|
||||
}
|
||||
|
||||
public Integer getAno() {
|
||||
return ano;
|
||||
}
|
||||
|
||||
public void setAno(Integer ano) {
|
||||
this.ano = ano;
|
||||
}
|
||||
|
||||
public String getLocalOrigem() {
|
||||
return localOrigem;
|
||||
}
|
||||
|
||||
public void setLocalOrige(String localOrige) {
|
||||
this.localOrigem = localOrige;
|
||||
}
|
||||
|
||||
public String getLocalDestino() {
|
||||
return localDestino;
|
||||
}
|
||||
|
||||
public void setLocalDestino(String localDestino) {
|
||||
this.localDestino = localDestino;
|
||||
}
|
||||
|
||||
public Integer getPassageirosIda() {
|
||||
return passageirosIda;
|
||||
}
|
||||
|
||||
public void setPassageirosIda(Integer passageirosIda) {
|
||||
this.passageirosIda = passageirosIda;
|
||||
}
|
||||
|
||||
public Integer getPassageirosVolta() {
|
||||
return passageirosVolta;
|
||||
}
|
||||
|
||||
public void setPassageirosVolta(Integer passageirosVolta) {
|
||||
this.passageirosVolta = passageirosVolta;
|
||||
}
|
||||
|
||||
public Integer getGratuidadePasseLivreIda() {
|
||||
return gratuidadePasseLivreIda;
|
||||
}
|
||||
|
||||
public void setGratuidadePasseLivreIda(Integer gratuidadePasseLivreIda) {
|
||||
this.gratuidadePasseLivreIda = gratuidadePasseLivreIda;
|
||||
}
|
||||
|
||||
public Integer getGratuidadePasseLivreVolta() {
|
||||
return gratuidadePasseLivreVolta;
|
||||
}
|
||||
|
||||
public void setGratuidadePasseLivreVolta(Integer gratuidadePasseLivreVolta) {
|
||||
this.gratuidadePasseLivreVolta = gratuidadePasseLivreVolta;
|
||||
}
|
||||
|
||||
public Integer getGratuidadeIdosoIda() {
|
||||
return gratuidadeIdosoIda;
|
||||
}
|
||||
|
||||
public void setGratuidadeIdosoIda(Integer gratuidadeIdosoIda) {
|
||||
this.gratuidadeIdosoIda = gratuidadeIdosoIda;
|
||||
}
|
||||
|
||||
public Integer getGratuidadeIdosoVolta() {
|
||||
return gratuidadeIdosoVolta;
|
||||
}
|
||||
|
||||
public void setGratuidadeIdosoVolta(Integer gratuidadeIdosoVolta) {
|
||||
this.gratuidadeIdosoVolta = gratuidadeIdosoVolta;
|
||||
}
|
||||
|
||||
public Integer getDescontoIdosoIda() {
|
||||
return descontoIdosoIda;
|
||||
}
|
||||
|
||||
public void setDescontoIdosoIda(Integer descontoIdosoIda) {
|
||||
this.descontoIdosoIda = descontoIdosoIda;
|
||||
}
|
||||
|
||||
public Integer getDescontoIdosoVolta() {
|
||||
return descontoIdosoVolta;
|
||||
}
|
||||
|
||||
public void setDescontoIdosoVolta(Integer descontoIdosoVolta) {
|
||||
this.descontoIdosoVolta = descontoIdosoVolta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return antt + ";" + prefixo + ";" + mes + ";" + ano + ";" + localOrigem + ";" + localDestino + ";" + passageirosIda + ";" + passageirosVolta + ";" + gratuidadePasseLivreIda + ";" + gratuidadePasseLivreVolta + ";" + gratuidadeIdosoIda + ";" + gratuidadeIdosoVolta + ";" + descontoIdosoIda + ";" + descontoIdosoVolta;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,9 +3,9 @@ package com.rjconsultores.ventaboletos.service;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
|
||||
public interface SisdapService {
|
||||
|
||||
public List<String> getMovimentoLinhas(Date fecInicio, Date fecFinal, Integer empresaId);
|
||||
|
||||
public List<String> getMovimentoSecoes(Date fecInicio, Date fecFinal, Integer empresaId);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue