wilian 2017-01-10 19:51:47 +00:00
parent ffbc705c2d
commit cc4b2f10b9
9 changed files with 204 additions and 22 deletions

View File

@ -7,6 +7,6 @@ import com.rjconsultores.ventaboletos.vo.busquedapacotes.PacoteVO;
public interface BusquedaDatosTicketDAO {
public List<PacoteVO> buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal);
public List<PacoteVO> buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal, Date fecAlteracaoInicial, Date fecAlteracaoFinal);
}

View File

@ -0,0 +1,7 @@
package com.rjconsultores.ventaboletos.dao;
import com.rjconsultores.ventaboletos.entidad.VendaPacote;
public interface VendaPacoteDAO extends GenericDAO<VendaPacote, Long> {
}

View File

@ -48,12 +48,12 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
}
@Override
public List<PacoteVO> buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal) {
public List<PacoteVO> buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal, Date fecAlteracaoInicial, Date fecAlteracaoFinal) {
vendapacoteIds = null;
List<PacoteVO> pacotes = new ArrayList<PacoteVO>();
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<Pacote,
return pacotes;
}
private List<PacoteVO> carregarDadosPacotes(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal) {
private List<PacoteVO> 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<Pacote,
.append("LEFT JOIN PUNTO_VENTA PV ON PV.PUNTOVENTA_ID = VP.PUNTOVENTA_ID ")
.append("LEFT JOIN TARIFA_VENDA_PACOTE TVP ON TVP.VENDAPACOTE_ID = VP.VENDAPACOTE_ID ")
.append("LEFT JOIN BOLETO B ON B.BOLETO_ID = TVP.BOLETO_ID ")
.append("WHERE (B.BOLETO_ID IS NULL OR B.INDSTATUSBOLETO = 'V') ")
.append("AND VP.DATAPACOTE BETWEEN :fecInicial AND :fecFinal ");
.append("WHERE (B.BOLETO_ID IS NULL OR B.INDSTATUSBOLETO = 'V') ");
if(fecInicial != null) {
sQuery.append("AND VP.DATAPACOTE >= :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<Pacote,
sQuery.append("AND VP.DATAVENDA <= :fecVentaFinal ");
}
if(fecAlteracaoInicial != null) {
sQuery.append("AND VP.FECMODIF >= :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<Pacote,
.addScalar("TOTALPEDAGIO", BigDecimalType.INSTANCE)
.addScalar("TOTALOUTROS", BigDecimalType.INSTANCE)
.addScalar("TOTALSEGURO", BigDecimalType.INSTANCE)
.addScalar("QTDEPACOTEFORMAPAGO", IntegerType.INSTANCE);
.addScalar("QTDEPACOTEFORMAPAGO", IntegerType.INSTANCE)
.addScalar("FECMODIF", TimestampType.INSTANCE)
.addScalar("DATACANCELAMENTO", TimestampType.INSTANCE);
query.setResultTransformer(new DatosTicketResultTransformer());
query.setParameter("fecInicial", fecInicial, DateType.INSTANCE)
.setParameter("fecFinal", fecFinal, DateType.INSTANCE);
if(fecInicial != null) {
query.setParameter("fecInicial", fecInicial, DateType.INSTANCE);
}
if(fecFinal != null) {
query.setParameter("fecFinal", fecFinal, DateType.INSTANCE);
}
if(fecVentaInicial != null) {
query.setParameter("fecVentaInicial", fecVentaInicial, TimestampType.INSTANCE);
@ -135,6 +155,13 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
query.setParameter("fecVentaFinal", fecVentaFinal, TimestampType.INSTANCE);
}
if(fecAlteracaoInicial != null) {
query.setParameter("fecAlteracaoInicial", fecAlteracaoInicial, TimestampType.INSTANCE);
}
if(fecAlteracaoFinal != null) {
query.setParameter("fecAlteracaoFinal", fecAlteracaoFinal, TimestampType.INSTANCE);
}
return query.list();
}

View File

@ -0,0 +1,45 @@
package com.rjconsultores.ventaboletos.dao.hibernate;
import java.util.Date;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.rjconsultores.ventaboletos.dao.VendaPacoteDAO;
import com.rjconsultores.ventaboletos.entidad.VendaPacote;
@Repository("vendaPacoteDAO")
public class VendaPacoteHibernateDAO extends GenericHibernateDAO<VendaPacote, Long> implements VendaPacoteDAO {
@Autowired
public VendaPacoteHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
setSessionFactory(factory);
}
@Override
@SuppressWarnings("unchecked")
public List<VendaPacote> 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);
}
}

View File

@ -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;
}
}

View File

@ -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<EnderecoApanhe> 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<EnderecoApanhe> buscar(Date datapacote, String numoperacion) {
return enderecoApanheDAO.buscar(datapacote, numoperacion);
}
private void atualizarVendaPacote(VendaPacote vendaPacote) {
vendaPacoteDAO.actualizacion(vendaPacoteDAO.obtenerID(vendaPacote.getVendapacoteId()));
}
}

View File

@ -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;
}
}

View File

@ -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("&nbsp;", " ").replaceAll("\\<.*?\\>", " ")).replaceAll("\\s+", " "));

View File

@ -23,20 +23,37 @@ public class BusquedaDatosTicketsRS {
@GET
@Path("/busquedadatostickets")
@Produces({ MediaType.APPLICATION_XML })
public List<PacoteVO> busquedaDatosTickets(@QueryParam("fecinicial") String fechaIniParam, @QueryParam("fecfinal") String fechaFinParam, @QueryParam("fecventainicial") String fechaVentaIniParam, @QueryParam("fecventafinal") String fechaVentaFinParam) throws ParseException{
public List<PacoteVO> 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<PacoteVO> pacotes = pacoteDao.buscaDatosTickets(fecInicial, fecFinal, fecVentaInicial, fecVentaFinal);
List<PacoteVO> 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;
}
}