frederico 2017-08-31 13:31:30 +00:00
parent 5efce21efa
commit 82eb9ac37d
1 changed files with 220 additions and 218 deletions

View File

@ -62,7 +62,7 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
try {
pacotes = carregarDadosPacotes(fecInicial, fecFinal, fecVentaInicial, fecVentaFinal, fecAlteracaoInicial, fecAlteracaoFinal);
if(!pacotes.isEmpty()) {
if (!pacotes.isEmpty()) {
carregarDadosPagamento(pacotes, fecInicial, fecFinal, fecVentaInicial, fecVentaFinal, fecAlteracaoInicial, fecAlteracaoFinal);
carregarDadosServico(pacotes, fecInicial, fecFinal, fecVentaInicial, fecVentaFinal, fecAlteracaoInicial, fecAlteracaoFinal);
carregarDadosPassageiros(pacotes, fecInicial, fecFinal, fecVentaInicial, fecVentaFinal, fecAlteracaoInicial, fecAlteracaoFinal);
@ -71,7 +71,7 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
carregarDadosItemPacotes(pacotes, fecInicial, fecFinal, fecVentaInicial, fecVentaFinal, fecAlteracaoInicial, fecAlteracaoFinal);
}
} catch(Exception e) {
} catch (Exception e) {
log.error(e.getMessage(), e);
pacotes.clear();
}
@ -79,10 +79,10 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
return getPacotesFiltradosReserva(pacotes);
}
private List<PacoteVO> getPacotesFiltradosReserva(List<PacoteVO> pacotes){
private List<PacoteVO> getPacotesFiltradosReserva(List<PacoteVO> pacotes) {
List<PacoteVO> retorno = new ArrayList<PacoteVO>();
for(PacoteVO p : pacotes){
if(p.getFormaspagamento() != null && !p.getFormaspagamento().isEmpty()){
for (PacoteVO p : pacotes) {
if (p.getFormaspagamento() != null && !p.getFormaspagamento().isEmpty()) {
retorno.add(p);
}
}
@ -194,15 +194,15 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
query.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
adicionarFiltros(query, fecInicial, fecFinal, fecVentaInicial, fecVentaFinal, fecAlteracaoInicial, fecAlteracaoFinal);
HashMap<Long, List<HashMap<String, Object>>> resultGroupedByCajaDiversos = new HashMap<Long,List<HashMap<String,Object>>>();
HashMap<Long, List<HashMap<String, Object>>> resultGroupedByCajaDiversos = new HashMap<Long, List<HashMap<String, Object>>>();
for(HashMap<String, Object> h : (List<HashMap<String, Object>>) query.list()){
Long cajaDiversosId = (Long)h.get("CAJADIVERSOS_ID");
if(!resultGroupedByCajaDiversos.containsKey(cajaDiversosId)){
List<HashMap<String, Object>> list = new ArrayList<HashMap<String,Object>>();
for (HashMap<String, Object> h : (List<HashMap<String, Object>>) query.list()) {
Long cajaDiversosId = (Long) h.get("CAJADIVERSOS_ID");
if (!resultGroupedByCajaDiversos.containsKey(cajaDiversosId)) {
List<HashMap<String, Object>> list = new ArrayList<HashMap<String, Object>>();
list.add(h);
resultGroupedByCajaDiversos.put(cajaDiversosId, list);
}else{
} else {
resultGroupedByCajaDiversos.get(cajaDiversosId).add(h);
}
}
@ -212,23 +212,23 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
for (PacoteVO pacote : pacotes) {
int flag = -1;
for (PagamentoVO pagamento : pagamentos) {
if(pagamento.getVendapacoteId().equals(pacote.getVendapacoteId())) {
if (pagamento.getVendapacoteId().equals(pacote.getVendapacoteId())) {
flag = 0;
if(pacote.getFormaspagamento() == null) {
if (pacote.getFormaspagamento() == null) {
pacote.setFormaspagamento(new ArrayList<PagamentoVO>());
}
if(isPacoteReserva(pacote) && isPagamentoPacoteReserva(pagamento) ||
if (isPacoteReserva(pacote) && isPagamentoPacoteReserva(pagamento) ||
(isPagamentoPacoteReserva(pagamento) && pacote.getQtdePacoteFormaspago() == 1) ||
(!isPacoteReserva(pacote) && !isPagamentoPacoteReserva(pagamento))) {
pacote.getFormaspagamento().add(pagamento);
}
if(isPagamentoDeposito(pagamento)) {
if (isPagamentoDeposito(pagamento)) {
carregarDadosDeposito(pacote, pagamento);
}
} else if(flag == 0){
} else if (flag == 0) {
break;
}
@ -277,7 +277,9 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
count = 0;
for (HashMap<String, Object> s : secondResult) {
if (cajaDiversosId.equals(s.get("CAJADIVERSOS_ID"))) {
if (firstResult.get(cajaDiversosId).size() < count) {
firstResult.get(cajaDiversosId).get(count).putAll(s);
}
count++;
}
}
@ -355,6 +357,7 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
/**
* Adiciona os filtros na query
*
* @param query
* @param fecInicial
* @param fecFinal
@ -366,24 +369,24 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
private void adicionarFiltros(SQLQuery query, Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal, Date fecAlteracaoInicial, Date fecAlteracaoFinal) {
query.setParameter("situacaoPacote", SituacaoVendaPacote.RESERVA.getShortValue());
if(fecInicial != null) {
if (fecInicial != null) {
query.setParameter("fecInicial", fecInicial, DateType.INSTANCE);
}
if(fecFinal != null) {
if (fecFinal != null) {
query.setParameter("fecFinal", fecFinal, DateType.INSTANCE);
}
if(fecVentaInicial != null) {
if (fecVentaInicial != null) {
query.setParameter("fecVentaInicial", fecVentaInicial, TimestampType.INSTANCE);
}
if(fecVentaFinal != null) {
if (fecVentaFinal != null) {
query.setParameter("fecVentaFinal", fecVentaFinal, TimestampType.INSTANCE);
}
if(fecAlteracaoInicial != null) {
if (fecAlteracaoInicial != null) {
query.setParameter("fecAlteracaoInicial", fecAlteracaoInicial, TimestampType.INSTANCE);
}
if(fecAlteracaoFinal != null) {
if (fecAlteracaoFinal != null) {
query.setParameter("fecAlteracaoFinal", fecAlteracaoFinal, TimestampType.INSTANCE);
}
}
@ -392,24 +395,24 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
sQuery.append("AND VP.SITUACAO != :situacaoPacote ");
if(fecInicial != null) {
if (fecInicial != null) {
sQuery.append("AND VP.DATAPACOTE >= :fecInicial ");
}
if(fecFinal != null) {
if (fecFinal != null) {
sQuery.append("AND VP.DATAPACOTE <= :fecFinal ");
}
if(fecVentaInicial != null) {
if (fecVentaInicial != null) {
sQuery.append("AND VP.DATAVENDA >= :fecVentaInicial ");
}
if(fecVentaFinal != null) {
if (fecVentaFinal != null) {
sQuery.append("AND VP.DATAVENDA <= :fecVentaFinal ");
}
if(fecAlteracaoInicial != null) {
if (fecAlteracaoInicial != null) {
sQuery.append("AND VP.FECMODIF >= :fecAlteracaoInicial ");
}
if(fecAlteracaoFinal != null) {
if (fecAlteracaoFinal != null) {
sQuery.append("AND VP.FECMODIF <= :fecAlteracaoFinal ");
}
@ -427,7 +430,6 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
return TipoFormapago.RESERVA.equals(pagamento.getTipoFormapago());
}
@SuppressWarnings("unchecked")
private void carregarDadosServico(List<PacoteVO> pacotes, Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal, Date fecAlteracaoInicial, Date fecAlteracaoFinal) {
StringBuilder sQuery = new StringBuilder();
@ -455,7 +457,7 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
List<ServicoVO> servicos = query.list();
for (PacoteVO pacote : pacotes) {
for (ServicoVO servico : servicos) {
if(servico.getVendapacoteId().equals(pacote.getVendapacoteId())) {
if (servico.getVendapacoteId().equals(pacote.getVendapacoteId())) {
pacote.setServico(servico);
break;
}
@ -497,7 +499,7 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
List<ClientePacoteVO> clientesPacotes = query.list();
for (PacoteVO pacote : pacotes) {
for (ClientePacoteVO clientePacote : clientesPacotes) {
if(clientePacote.getVendapacoteId().equals(pacote.getVendapacoteId())) {
if (clientePacote.getVendapacoteId().equals(pacote.getVendapacoteId())) {
pacote.setClientePacote(clientePacote);
}
}
@ -533,8 +535,8 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
List<PassageiroVO> passageiros = query.list();
for (PacoteVO pacote : pacotes) {
for (PassageiroVO passageiro : passageiros) {
if(passageiro.getVendapacoteId().equals(pacote.getVendapacoteId())) {
if(pacote.getPax() == null) {
if (passageiro.getVendapacoteId().equals(pacote.getVendapacoteId())) {
if (pacote.getPax() == null) {
pacote.setPax(new ArrayList<PassageiroVO>());
}
pacote.getPax().add(passageiro);
@ -571,7 +573,7 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
List<EnderecoApanheVO> enderecosApanhe = query.list();
for (PacoteVO pacote : pacotes) {
for (EnderecoApanheVO enderecoApanhe : enderecosApanhe) {
if(enderecoApanhe.getVendapacoteId().equals(pacote.getVendapacoteId())) {
if (enderecoApanhe.getVendapacoteId().equals(pacote.getVendapacoteId())) {
pacote.setEnderecoApanhe(enderecoApanhe);
}
}
@ -601,8 +603,8 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
List<ItemAdicionalVO> itens = query.list();
for (PacoteVO pacote : pacotes) {
for (ItemAdicionalVO itemAdicional : itens) {
if(itemAdicional.getVendapacoteId().equals(pacote.getVendapacoteId())) {
if(pacote.getItens() == null) {
if (itemAdicional.getVendapacoteId().equals(pacote.getVendapacoteId())) {
if (pacote.getItens() == null) {
pacote.setItens(new ArrayList<ItemAdicionalVO>());
}
pacote.getItens().add(itemAdicional);
@ -632,7 +634,7 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
query.setParameter("formapagoId", pagamento.getFormapagoId());
List<DadosBancarioVO> dadosBancarios = query.list();
if(dadosBancarios != null && !dadosBancarios.isEmpty()) {
if (dadosBancarios != null && !dadosBancarios.isEmpty()) {
pagamento.setDadosBancarios(dadosBancarios);
}
}