wilian 2016-01-19 18:16:02 +00:00
parent 377f7c1515
commit 86262b15bd
4 changed files with 37 additions and 16 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);
public List<PacoteVO> buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal);
}

View File

@ -48,18 +48,20 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
}
@Override
public List<PacoteVO> buscaDatosTickets(Date fecInicial, Date fecFinal) {
public List<PacoteVO> buscaDatosTickets(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal) {
vendapacoteIds = null;
List<PacoteVO> pacotes = new ArrayList<PacoteVO>();
try {
pacotes = carregarDadosPacotes(fecInicial, fecFinal);
pacotes = carregarDadosPacotes(fecInicial, fecFinal, fecVentaInicial, fecVentaFinal);
if(!pacotes.isEmpty()) {
carregarDadosPagamento(pacotes);
carregarDadosServico(pacotes);
carregarDadosPassageiros(pacotes);
carregarDadosCliente(pacotes);
carregarDadosEnderecoApanhe(pacotes);
carregarDadosItemPacotes(pacotes);
}
} catch(Exception e) {
log.error(e.getMessage(), e);
@ -70,7 +72,7 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
}
@SuppressWarnings("unchecked")
private List<PacoteVO> carregarDadosPacotes(Date fecInicial, Date fecFinal) {
private List<PacoteVO> carregarDadosPacotes(Date fecInicial, Date fecFinal, Date fecVentaInicial, Date fecVentaFinal) {
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, ")
@ -88,14 +90,22 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
.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("GROUP BY VP.VENDAPACOTE_ID, VP.DATAPACOTE, VP.DATAVENDA, VP.SUBTOTAL, VP.TOTAL, ")
.append("AND VP.DATAPACOTE BETWEEN :fecInicial AND :fecFinal ");
if(fecVentaInicial != null) {
sQuery.append("AND VP.DATAVENDA >= :fecVentaInicial ");
}
if(fecVentaFinal != null) {
sQuery.append("AND VP.DATAVENDA <= :fecVentaFinal ");
}
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 ");
SQLQuery query = getSession().createSQLQuery(sQuery.toString())
.addScalar("VENDAPACOTE_ID", LongType.INSTANCE)
.addScalar("DATAPACOTE", DateType.INSTANCE)
.addScalar("DATAVENDA", DateType.INSTANCE)
.addScalar("DATAVENDA", TimestampType.INSTANCE)
.addScalar("SUBTOTAL", BigDecimalType.INSTANCE)
.addScalar("TOTAL", BigDecimalType.INSTANCE)
.addScalar("DESCONTO", BigDecimalType.INSTANCE)
@ -119,6 +129,13 @@ public class BusquedaDatosTicketHibernateDAO extends GenericHibernateDAO<Pacote,
query.setParameter("fecInicial", fecInicial, DateType.INSTANCE)
.setParameter("fecFinal", fecFinal, DateType.INSTANCE);
if(fecVentaInicial != null) {
query.setParameter("fecVentaInicial", fecVentaInicial, TimestampType.INSTANCE);
}
if(fecVentaFinal != null) {
query.setParameter("fecVentaFinal", fecVentaFinal, TimestampType.INSTANCE);
}
return query.list();
}

View File

@ -37,7 +37,7 @@ public class VendaPacote implements Serializable {
@Column(name = "VENDAPACOTE_ID")
private Long vendapacoteId;
@Temporal(TemporalType.DATE)
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "DATAVENDA")
private Date datavenda;

View File

@ -11,6 +11,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.apache.commons.lang.StringUtils;
import com.rjconsultores.ventaboletos.dao.BusquedaDatosTicketDAO;
import com.rjconsultores.ventaboletos.vo.busquedapacotes.PacoteVO;
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
@ -21,15 +23,17 @@ public class BusquedaDatosTicketsRS {
@GET
@Path("/busquedadatostickets")
@Produces({ MediaType.APPLICATION_XML })
public List<PacoteVO> busquedaDatosTickets(@QueryParam("fecinicial") String fechaIniParam, @QueryParam("fecfinal") String fechaFinParam) throws ParseException{
public List<PacoteVO> busquedaDatosTickets(@QueryParam("fecinicial") String fechaIniParam, @QueryParam("fecfinal") String fechaFinParam, @QueryParam("fecventainicial") String fechaVentaIniParam, @QueryParam("fecventafinal") String fechaVentaFinParam) throws ParseException{
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Date fecInicial = sdf.parse(fechaIniParam);
Date fecFinal = sdf.parse(fechaFinParam);
Date fecVentaInicial = StringUtils.isNotBlank(fechaVentaIniParam) ? sdf.parse(fechaVentaIniParam) : null;
Date fecVentaFinal = StringUtils.isNotBlank(fechaVentaFinParam) ? sdf.parse(fechaVentaFinParam) : null;
BusquedaDatosTicketDAO pacoteDao = (BusquedaDatosTicketDAO)AppContext.getApplicationContext().getBean("busquedaDatosTicketDAO");
List<PacoteVO> pacotes = pacoteDao.buscaDatosTickets(fecInicial, fecFinal);
List<PacoteVO> pacotes = pacoteDao.buscaDatosTickets(fecInicial, fecFinal, fecVentaInicial, fecVentaFinal);
return pacotes;
}