diff --git a/src/com/rjconsultores/ventaboletos/dao/BusquedaDatosTicketDAO.java b/src/com/rjconsultores/ventaboletos/dao/BusquedaDatosTicketDAO.java index 066d347cf..0df494203 100644 --- a/src/com/rjconsultores/ventaboletos/dao/BusquedaDatosTicketDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/BusquedaDatosTicketDAO.java @@ -7,6 +7,6 @@ import com.rjconsultores.ventaboletos.vo.busquedapacotes.PacoteVO; public interface BusquedaDatosTicketDAO { - public List buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal); + public List buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal, Date fecAlteracaoInicial, Date fecAlteracaoFinal); } diff --git a/src/com/rjconsultores/ventaboletos/dao/VendaPacoteDAO.java b/src/com/rjconsultores/ventaboletos/dao/VendaPacoteDAO.java new file mode 100644 index 000000000..a2517f29c --- /dev/null +++ b/src/com/rjconsultores/ventaboletos/dao/VendaPacoteDAO.java @@ -0,0 +1,7 @@ +package com.rjconsultores.ventaboletos.dao; + +import com.rjconsultores.ventaboletos.entidad.VendaPacote; + +public interface VendaPacoteDAO extends GenericDAO { + +} diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/BusquedaDatosTicketHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/BusquedaDatosTicketHibernateDAO.java index 593d78a22..8ae5baae8 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/BusquedaDatosTicketHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/BusquedaDatosTicketHibernateDAO.java @@ -48,12 +48,12 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal) { + public List buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal, Date fecAlteracaoInicial, Date fecAlteracaoFinal) { vendapacoteIds = null; List pacotes = new ArrayList(); try { - pacotes = carregarDadosPacotes(fecInicial, fecFinal, fecVentaInicial, fecVentaFinal); + pacotes = carregarDadosPacotes(fecInicial, fecFinal, fecVentaInicial, fecVentaFinal, fecAlteracaoInicial, fecAlteracaoFinal); if(!pacotes.isEmpty()) { carregarDadosPagamento(pacotes); carregarDadosServico(pacotes); @@ -71,10 +71,10 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO carregarDadosPacotes(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal) { + private List carregarDadosPacotes(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal, Date fecAlteracaoInicial, Date fecAlteracaoFinal) { StringBuilder sQuery = new StringBuilder(); sQuery.append("SELECT VP.VENDAPACOTE_ID, VP.DATAPACOTE, VP.DATAVENDA, VP.SUBTOTAL, VP.TOTAL, VP.DESCONTO, VP.NUMOPERACION, P.PACOTE_ID, ") - .append("P.NOMPACOTE, P.DESCPACOTE, E.NOMBEMPRESA, VP.SITUACAO, PV.NOMBPUNTOVENTA, VP.USUARIO_ID, ") + .append("P.NOMPACOTE, P.DESCPACOTE, E.NOMBEMPRESA, VP.SITUACAO, PV.NOMBPUNTOVENTA, VP.USUARIO_ID, VP.FECMODIF, VP.DATACANCELAMENTO, ") .append("COUNT(TVP.TARIFAVENDAPACOTE_ID) AS QTDEPASSAGEIRO, ") .append("SUM(B.PRECIOPAGADO) AS TOTALTARIFA, ") .append("SUM(B.IMPORTETAXAEMBARQUE) AS TOTALTAXAEMBARQUE, ") @@ -88,8 +88,14 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO= :fecInicial "); + } + if(fecFinal != null) { + sQuery.append("AND VP.DATAPACOTE <= :fecFinal "); + } if(fecVentaInicial != null) { sQuery.append("AND VP.DATAVENDA >= :fecVentaInicial "); @@ -98,8 +104,15 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO= :fecAlteracaoInicial "); + } + if(fecAlteracaoFinal != null) { + sQuery.append("AND VP.FECMODIF <= :fecAlteracaoFinal "); + } + sQuery.append("GROUP BY VP.VENDAPACOTE_ID, VP.DATAPACOTE, VP.DATAVENDA, VP.SUBTOTAL, VP.TOTAL, ") - .append("VP.DESCONTO, VP.NUMOPERACION, P.PACOTE_ID, P.NOMPACOTE, P.DESCPACOTE, E.NOMBEMPRESA, VP.SITUACAO, PV.NOMBPUNTOVENTA, VP.USUARIO_ID "); + .append("VP.DESCONTO, VP.NUMOPERACION, P.PACOTE_ID, P.NOMPACOTE, P.DESCPACOTE, E.NOMBEMPRESA, VP.SITUACAO, PV.NOMBPUNTOVENTA, VP.USUARIO_ID, VP.FECMODIF, VP.DATACANCELAMENTO "); SQLQuery query = getSession().createSQLQuery(sQuery.toString()) .addScalar("VENDAPACOTE_ID", LongType.INSTANCE) @@ -122,11 +135,18 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO implements VendaPacoteDAO { + + @Autowired + public VendaPacoteHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) { + setSessionFactory(factory); + } + + @Override + @SuppressWarnings("unchecked") + public List obtenerTodos() { + Criteria c = getSession().createCriteria(getPersistentClass()); + return c.list(); + } + + @Override + @Transactional + public VendaPacote suscribir(VendaPacote entidad) { + entidad.setFecmodif(new Date()); + return super.suscribir(entidad); + } + + @Override + @Transactional + public VendaPacote actualizacion(VendaPacote entidad) { + entidad.setFecmodif(new Date()); + return super.actualizacion(entidad); + } + +} diff --git a/src/com/rjconsultores/ventaboletos/entidad/VendaPacote.java b/src/com/rjconsultores/ventaboletos/entidad/VendaPacote.java index 6b4fbb180..37dd8b1c9 100644 --- a/src/com/rjconsultores/ventaboletos/entidad/VendaPacote.java +++ b/src/com/rjconsultores/ventaboletos/entidad/VendaPacote.java @@ -59,7 +59,7 @@ public class VendaPacote implements Serializable { @Column(name = "INDCANCELADO") private Boolean indcancelado; - @Temporal(TemporalType.DATE) + @Temporal(TemporalType.TIMESTAMP) @Column(name = "DATACANCELAMENTO") private Date datacancelamento; @@ -94,6 +94,10 @@ public class VendaPacote implements Serializable { @Column(name = "USUARIO_CONFIRMACAO_RESERVA_ID") private Long usuarioConfirmacaoReserva; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "FECMODIF") + private Date fecmodif; public Long getVendapacoteId() { return vendapacoteId; @@ -199,4 +203,52 @@ public class VendaPacote implements Serializable { this.usuario = usuario; } + public Date getFecmodif() { + return fecmodif; + } + + public void setFecmodif(Date fecmodif) { + this.fecmodif = fecmodif; + } + + public ClientePacote getClientePacote() { + return clientePacote; + } + + public void setClientePacote(ClientePacote clientePacote) { + this.clientePacote = clientePacote; + } + + public Integer getMotivoCancelVendaPacoteId() { + return motivoCancelVendaPacoteId; + } + + public void setMotivoCancelVendaPacoteId(Integer motivoCancelVendaPacoteId) { + this.motivoCancelVendaPacoteId = motivoCancelVendaPacoteId; + } + + public SituacaoVendaPacote getSituacao() { + return situacao; + } + + public void setSituacao(SituacaoVendaPacote situacao) { + this.situacao = situacao; + } + + public Date getDataConfirmacaoReserva() { + return dataConfirmacaoReserva; + } + + public void setDataConfirmacaoReserva(Date dataConfirmacaoReserva) { + this.dataConfirmacaoReserva = dataConfirmacaoReserva; + } + + public Long getUsuarioConfirmacaoReserva() { + return usuarioConfirmacaoReserva; + } + + public void setUsuarioConfirmacaoReserva(Long usuarioConfirmacaoReserva) { + this.usuarioConfirmacaoReserva = usuarioConfirmacaoReserva; + } + } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/EnderecoApanheServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/EnderecoApanheServiceImpl.java index cc7221e40..a28c05971 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/EnderecoApanheServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/EnderecoApanheServiceImpl.java @@ -9,7 +9,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.rjconsultores.ventaboletos.dao.EnderecoApanheDAO; +import com.rjconsultores.ventaboletos.dao.VendaPacoteDAO; import com.rjconsultores.ventaboletos.entidad.EnderecoApanhe; +import com.rjconsultores.ventaboletos.entidad.VendaPacote; import com.rjconsultores.ventaboletos.service.EnderecoApanheService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -18,6 +20,9 @@ public class EnderecoApanheServiceImpl implements EnderecoApanheService { @Autowired private EnderecoApanheDAO enderecoApanheDAO; + + @Autowired + private VendaPacoteDAO vendaPacoteDAO; public List obtenerTodos() { return enderecoApanheDAO.obtenerTodos(); @@ -32,15 +37,19 @@ public class EnderecoApanheServiceImpl implements EnderecoApanheService { entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE); - + + atualizarVendaPacote(entidad.getVendaPacote()); + return enderecoApanheDAO.suscribir(entidad); } - @Transactional + @Transactional public EnderecoApanhe actualizacion(EnderecoApanhe entidad) { entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId()); entidad.setFecmodif(Calendar.getInstance().getTime()); entidad.setActivo(Boolean.TRUE); + + atualizarVendaPacote(entidad.getVendaPacote()); return enderecoApanheDAO.actualizacion(entidad); } @@ -57,4 +66,9 @@ public class EnderecoApanheServiceImpl implements EnderecoApanheService { public List buscar(Date datapacote, String numoperacion) { return enderecoApanheDAO.buscar(datapacote, numoperacion); } + + private void atualizarVendaPacote(VendaPacote vendaPacote) { + vendaPacoteDAO.actualizacion(vendaPacoteDAO.obtenerID(vendaPacote.getVendapacoteId())); + } + } diff --git a/src/com/rjconsultores/ventaboletos/vo/busquedapacotes/PacoteVO.java b/src/com/rjconsultores/ventaboletos/vo/busquedapacotes/PacoteVO.java index 1b1371b9f..73e5c4647 100644 --- a/src/com/rjconsultores/ventaboletos/vo/busquedapacotes/PacoteVO.java +++ b/src/com/rjconsultores/ventaboletos/vo/busquedapacotes/PacoteVO.java @@ -12,14 +12,16 @@ import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlType; @XmlRootElement(name = "pacote") -@XmlType(propOrder = { "numoperacao", "datavenda", "datapacote", "nompacote", "pacoteId", "descpacote", "usuariovenda", "status", "pontoVenda", "empresa", "quantidade", - "totalTarifa", "totalSeguro", "totalOutros", "totalPedagio", "totalTaxaEmbarque", "valorsubtotal", "valortotal", "valordesconto", - "formaspagamento", "servico", "pax", "enderecoApanhe", "clientePacote", "itens" }) +@XmlType(propOrder = { "numoperacao", "datavenda", "datapacote", "dataalteracao", "datacancelamento", "nompacote", "pacoteId", "descpacote", "usuariovenda", + "status", "pontoVenda", "empresa", "quantidade", "totalTarifa", "totalSeguro", "totalOutros", "totalPedagio", "totalTaxaEmbarque", + "valorsubtotal", "valortotal", "valordesconto", "formaspagamento", "servico", "pax", "enderecoApanhe", "clientePacote", "itens" }) public class PacoteVO { private Long vendapacoteId; private Date datapacote; private Date datavenda; + private Date datacancelamento; + private Date dataalteracao; private Long pacoteId; private String nompacote; private String descpacote; @@ -274,4 +276,20 @@ public class PacoteVO { this.pacoteId = pacoteId; } + public Date getDatacancelamento() { + return datacancelamento; + } + + public void setDatacancelamento(Date datacancelamento) { + this.datacancelamento = datacancelamento; + } + + public Date getDataalteracao() { + return dataalteracao; + } + + public void setDataalteracao(Date dataalteracao) { + this.dataalteracao = dataalteracao; + } + } diff --git a/src/com/rjconsultores/ventaboletos/vo/busquedapacotes/transformer/DatosTicketResultTransformer.java b/src/com/rjconsultores/ventaboletos/vo/busquedapacotes/transformer/DatosTicketResultTransformer.java index e39e92a09..4c88fddee 100644 --- a/src/com/rjconsultores/ventaboletos/vo/busquedapacotes/transformer/DatosTicketResultTransformer.java +++ b/src/com/rjconsultores/ventaboletos/vo/busquedapacotes/transformer/DatosTicketResultTransformer.java @@ -83,6 +83,8 @@ public class DatosTicketResultTransformer implements ResultTransformer { pacote.setValortotal((BigDecimal) tupleMap.get("TOTAL")); pacote.setValordesconto((BigDecimal) tupleMap.get("DESCONTO")); pacote.setQtdePacoteFormaspago((Integer) tupleMap.get("QTDEPACOTEFORMAPAGO")); + pacote.setDataalteracao((Date) tupleMap.get("FECMODIF")); + pacote.setDatacancelamento((Date) tupleMap.get("DATACANCELAMENTO")); if(StringUtils.isNotBlank(pacote.getDescpacote())){ pacote.setDescpacote(StringEscapeUtils.unescapeHtml(pacote.getDescpacote().replaceAll(" ", " ").replaceAll("\\<.*?\\>", " ")).replaceAll("\\s+", " ")); diff --git a/src/com/rjconsultores/ventaboletos/ws/rs/BusquedaDatosTicketsRS.java b/src/com/rjconsultores/ventaboletos/ws/rs/BusquedaDatosTicketsRS.java index f797e0263..563756d18 100644 --- a/src/com/rjconsultores/ventaboletos/ws/rs/BusquedaDatosTicketsRS.java +++ b/src/com/rjconsultores/ventaboletos/ws/rs/BusquedaDatosTicketsRS.java @@ -23,20 +23,37 @@ public class BusquedaDatosTicketsRS { @GET @Path("/busquedadatostickets") @Produces({ MediaType.APPLICATION_XML }) - public List busquedaDatosTickets(@QueryParam("fecinicial") String fechaIniParam, @QueryParam("fecfinal") String fechaFinParam, @QueryParam("fecventainicial") String fechaVentaIniParam, @QueryParam("fecventafinal") String fechaVentaFinParam) throws ParseException{ + public List busquedaDatosTickets(@QueryParam("fecinicial") String fechaIniParam, @QueryParam("fecfinal") String fechaFinParam, + @QueryParam("fecventainicial") String fechaVentaIniParam, @QueryParam("fecventafinal") String fechaVentaFinParam, + @QueryParam("fecalteracaoinicial") String fechaAlteracaoIniParam, @QueryParam("fecalteracaofinal") String fechaAlteracaoFinParam) throws ParseException{ SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); - Date fecInicial = sdf.parse(fechaIniParam); - Date fecFinal = sdf.parse(fechaFinParam); + Date fecInicial = StringUtils.isNotBlank(fechaIniParam) ? sdf.parse(fechaIniParam) : null; + Date fecFinal = StringUtils.isNotBlank(fechaFinParam) ? sdf.parse(fechaFinParam) : null; Date fecVentaInicial = StringUtils.isNotBlank(fechaVentaIniParam) ? sdf.parse(fechaVentaIniParam) : null; Date fecVentaFinal = StringUtils.isNotBlank(fechaVentaFinParam) ? sdf.parse(fechaVentaFinParam) : null; + Date fecAlteracaoInicial = StringUtils.isNotBlank(fechaAlteracaoIniParam) ? sdf.parse(fechaAlteracaoIniParam) : null; + Date fecAlteracaoFinal = StringUtils.isNotBlank(fechaAlteracaoFinParam) ? sdf.parse(fechaAlteracaoFinParam) : null; - BusquedaDatosTicketDAO pacoteDao = (BusquedaDatosTicketDAO)AppContext.getApplicationContext().getBean("busquedaDatosTicketDAO"); - List pacotes = pacoteDao.buscaDatosTickets(fecInicial, fecFinal, fecVentaInicial, fecVentaFinal); + List pacotes = null; + + if(isParametrosInformado(fecInicial, fecFinal, fecVentaInicial, fecVentaFinal, fecAlteracaoInicial, fecAlteracaoFinal)) { + BusquedaDatosTicketDAO pacoteDao = (BusquedaDatosTicketDAO)AppContext.getApplicationContext().getBean("busquedaDatosTicketDAO"); + pacotes = pacoteDao.buscaDatosTickets(fecInicial, fecFinal, fecVentaInicial, fecVentaFinal, fecAlteracaoInicial, fecAlteracaoFinal); + } return pacotes; } + + private boolean isParametrosInformado(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal, Date fecAlteracaoInicial, Date fecAlteracaoFinal) { + return fecInicial != null || + fecFinal != null || + fecVentaInicial != null || + fecVentaFinal != null || + fecAlteracaoInicial != null || + fecAlteracaoFinal != null; + } }