- merge restfull
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@33094 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
47754fbd9e
commit
698a169eb4
|
@ -0,0 +1,10 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.vo.caja.CajaVO;
|
||||
|
||||
public interface CajaDAO {
|
||||
public List<CajaVO> buscarCajaFecha(boolean yaCerrado, Date fechaDesde, Date fechaHasta);
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.transform.AliasToBeanResultTransformer;
|
||||
import org.hibernate.type.BigDecimalType;
|
||||
import org.hibernate.type.DateType;
|
||||
import org.hibernate.type.IntegerType;
|
||||
import org.hibernate.type.LongType;
|
||||
import org.hibernate.type.StringType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.CajaDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||
import com.rjconsultores.ventaboletos.vo.caja.CajaVO;
|
||||
|
||||
@Repository("cajaDAO")
|
||||
public class CajaHibernateDAO extends GenericHibernateDAO<Object, Long> implements CajaDAO {
|
||||
|
||||
@Autowired
|
||||
private SQLBuilder sqlBuilder;
|
||||
|
||||
@Autowired
|
||||
public CajaHibernateDAO(@Qualifier("sessionFactory") SessionFactory factory) {
|
||||
setSessionFactory(factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CajaVO> buscarCajaFecha(boolean yaCerrado, Date fechaDesde, Date fechaHasta) {
|
||||
String sqlBuscarCajaFecha = sqlBuilder.getSQLBuscarCajaFecha(yaCerrado, fechaDesde, fechaHasta);
|
||||
SQLQuery sql = getSession().createSQLQuery(sqlBuscarCajaFecha)
|
||||
.addScalar("cajaId", LongType.INSTANCE)
|
||||
.addScalar("numAsiento", StringType.INSTANCE)
|
||||
.addScalar("categoriaId", IntegerType.INSTANCE)
|
||||
.addScalar("numFolioSistema", StringType.INSTANCE)
|
||||
.addScalar("claseServicioId", IntegerType.INSTANCE)
|
||||
.addScalar("marcaId", IntegerType.INSTANCE)
|
||||
.addScalar("origenId", IntegerType.INSTANCE)
|
||||
.addScalar("destinoId", IntegerType.INSTANCE)
|
||||
.addScalar("corridaId", IntegerType.INSTANCE)
|
||||
.addScalar("fecCorrida", DateType.INSTANCE)
|
||||
.addScalar("nombPasajero", StringType.INSTANCE)
|
||||
.addScalar("precioBase", BigDecimalType.INSTANCE)
|
||||
.addScalar("precioPagado", BigDecimalType.INSTANCE)
|
||||
.addScalar("tipoVentaId", IntegerType.INSTANCE)
|
||||
.addScalar("numSeriePreimpresa", StringType.INSTANCE)
|
||||
.addScalar("numFolioPreImpreso", StringType.INSTANCE)
|
||||
.addScalar("fecHorViaje", DateType.INSTANCE)
|
||||
.addScalar("fecHorVenta", DateType.INSTANCE)
|
||||
.addScalar("puntoVentaId", IntegerType.INSTANCE)
|
||||
.addScalar("numKmViaje", BigDecimalType.INSTANCE)
|
||||
.addScalar("numOperacion", StringType.INSTANCE)
|
||||
.addScalar("motivoCancelacionId", IntegerType.INSTANCE)
|
||||
.addScalar("empresaPuntoVentaId", IntegerType.INSTANCE)
|
||||
.addScalar("empresaCorridaId", IntegerType.INSTANCE)
|
||||
.addScalar("turnoId", IntegerType.INSTANCE)
|
||||
.addScalar("importeTaxaEmbarque", BigDecimalType.INSTANCE)
|
||||
.addScalar("importePedagio", BigDecimalType.INSTANCE)
|
||||
.addScalar("importeOutros", BigDecimalType.INSTANCE)
|
||||
.addScalar("importeSeguro", BigDecimalType.INSTANCE)
|
||||
.addScalar("rutaId", IntegerType.INSTANCE)
|
||||
.addScalar("usuarioId", IntegerType.INSTANCE)
|
||||
.addScalar("numAutorizacion", StringType.INSTANCE)
|
||||
.addScalar("ordenSevicio", StringType.INSTANCE);
|
||||
|
||||
sql.setResultTransformer(new AliasToBeanResultTransformer(CajaVO.class));
|
||||
|
||||
return sql.list();
|
||||
}
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@ public class FnArredondamentoTarifa implements SQLFunction {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
public String render(List args, SessionFactoryImplementor arg1) throws QueryException {
|
||||
if (args.size() != 6) {
|
||||
throw new QueryException("Para o arredondamento de preço são necessário 6 parametros");
|
||||
|
@ -41,4 +41,9 @@ public class FnArredondamentoTarifa implements SQLFunction {
|
|||
throw new QueryException("Ainda não existe a traduação da função de arredondamento para o banco usado");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String render(Type arg0, List arg1, SessionFactoryImplementor arg2) throws QueryException {
|
||||
return render(arg1, arg2);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,10 @@
|
|||
package com.rjconsultores.ventaboletos.dao.sqlbuilder;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.vo.caja.CajaVO;
|
||||
|
||||
/**
|
||||
* Interface que indica quais são os SQL nativos da aplicação.
|
||||
*
|
||||
|
@ -37,4 +42,6 @@ public interface SQLBuilder {
|
|||
|
||||
public String getSQLActualizarCorridaTramoFecHusoFecVerano();
|
||||
|
||||
public String getSQLBuscarCajaFecha(boolean yaCerrado, Date fechaDesde, Date fechaHasta);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.rjconsultores.ventaboletos.dao.sqlbuilder.impl;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||
import com.rjconsultores.ventaboletos.dao.util.DBUtil;
|
||||
|
||||
|
@ -544,4 +547,61 @@ public class SQLBuilderOracle implements SQLBuilder {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLBuscarCajaFecha(boolean yaCerrado, Date fechaDesde, Date fechaHasta) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
sb.append(" select ");
|
||||
sb.append(" ");
|
||||
sb.append(" c.CAJA_ID as \"cajaId\", ");
|
||||
sb.append(" c.NUMASIENTO as \"numAsiento\", ");
|
||||
sb.append(" c.CATEGORIA_ID as \"categoriaId\", ");
|
||||
sb.append(" c.NUMFOLIOSISTEMA as \"numFolioSistema\", ");
|
||||
sb.append(" c.CLASESERVICIO_ID as \"claseServicioId\", ");
|
||||
sb.append(" c.MARCA_ID as \"marcaId\", ");
|
||||
sb.append(" c.ORIGEN_ID as \"origenId\", ");
|
||||
sb.append(" c.DESTINO_ID as \"destinoId\", ");
|
||||
sb.append(" c.CORRIDA_ID as \"corridaId\", ");
|
||||
sb.append(" c.FECCORRIDA as \"fecCorrida\", ");
|
||||
sb.append(" c.NOMBPASAJERO as \"nombPasajero\", ");
|
||||
sb.append(" c.PRECIOBASE as \"precioBase\", ");
|
||||
sb.append(" c.PRECIOPAGADO as \"precioPagado\", ");
|
||||
sb.append(" c.TIPOVENTA_ID as \"tipoVentaId\", ");
|
||||
sb.append(" c.NUMSERIEPREIMPRESA as \"numSeriePreimpresa\", ");
|
||||
sb.append(" c.NUMFOLIOPREIMPRESO as \"numFolioPreImpreso\", ");
|
||||
sb.append(" c.FECHORVIAJE as \"fecHorViaje\", ");
|
||||
sb.append(" c.FECHORVENTA as \"fecHorVenta\", ");
|
||||
sb.append(" c.PUNTOVENTA_ID as \"puntoVentaId\", ");
|
||||
sb.append(" c.NUMKMVIAJE as \"numKmViaje\", ");
|
||||
sb.append(" c.NUMOPERACION as \"numOperacion\", ");
|
||||
sb.append(" c.MOTIVOCANCELACION_ID as \"motivoCancelacionId\", ");
|
||||
sb.append(" c.EMPRESAPUNTOVENTA_ID as \"empresaPuntoVentaId\", ");
|
||||
sb.append(" c.EMPRESACORRIDA_ID as \"empresaCorridaId\", ");
|
||||
sb.append(" c.TURNO_ID as \"turnoId\", ");
|
||||
sb.append(" c.IMPORTETAXAEMBARQUE as \"importeTaxaEmbarque\", ");
|
||||
sb.append(" c.IMPORTEPEDAGIO as \"importePedagio\", ");
|
||||
sb.append(" c.IMPORTEOUTROS as \"importeOutros\", ");
|
||||
sb.append(" c.IMPORTESEGURO as \"importeSeguro\", ");
|
||||
sb.append(" co.ruta_id as \"rutaId\", ");
|
||||
sb.append(" c.usuario_id as \"usuarioId\", ");
|
||||
sb.append(" ct.numautorizacion as \"numAutorizacion\", ");
|
||||
sb.append(" (case when cfp.formapago_id = 11 then cdp.numdocumento else null end) as \"ordenSevicio\" ");
|
||||
sb.append(" ");
|
||||
sb.append(" from ");
|
||||
sb.append(" caja c ");
|
||||
sb.append(" left join corrida co on co.corrida_id = c.corrida_id and co.feccorrida = c.feccorrida ");
|
||||
sb.append(" left join caja_formapago cfp on cfp.caja_id = c.caja_id ");
|
||||
sb.append(" left join caja_det_pago cdp on cdp.cajaformapago_id = cfp.cajaformapago_id ");
|
||||
sb.append(" left join caja_tarjeta ct on ct.cajadetpago_id = cdp.cajadetpago_id ");
|
||||
sb.append(" ");
|
||||
sb.append(" where ");
|
||||
sb.append(" trunc(fechorventa) between to_date('").append(sdf.format(fechaDesde)).append("','yyyy-MM-dd') and ").append(" to_date('").append(sdf.format(fechaHasta)).append("','yyyy-MM-dd')");
|
||||
sb.append(" and c.feccorte ").append(yaCerrado ? " is not null" : " is null ");
|
||||
sb.append(" ");
|
||||
sb.append(" order by c.fechorventa,c.usuario_id,c.caja_id asc ");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
package com.rjconsultores.ventaboletos.vo.caja;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class CajaVO {
|
||||
private Long cajaId;
|
||||
private String numAsiento;
|
||||
private Integer categoriaId;
|
||||
private String numFolioSistema;
|
||||
private Integer claseServicioId;
|
||||
private Integer marcaId;
|
||||
private Integer origenId;
|
||||
private Integer destinoId;
|
||||
private Integer corridaId;
|
||||
private Date fecCorrida;
|
||||
private String nombPasajero;
|
||||
private BigDecimal precioBase;
|
||||
private BigDecimal precioPagado;
|
||||
private Integer tipoVentaId;
|
||||
private String numSeriePreimpresa;
|
||||
private String numFolioPreImpreso;
|
||||
private Date fecHorViaje;
|
||||
private Date fecHorVenta;
|
||||
private Integer puntoVentaId;
|
||||
private BigDecimal numKmViaje;
|
||||
private String numOperacion;
|
||||
private Integer motivoCancelacionId;
|
||||
private Integer empresaPuntoVentaId;
|
||||
private Integer empresaCorridaId;
|
||||
private Integer turnoId;
|
||||
private BigDecimal importeTaxaEmbarque;
|
||||
private BigDecimal importePedagio;
|
||||
private BigDecimal importeOutros;
|
||||
private BigDecimal importeSeguro;
|
||||
private Integer rutaId;
|
||||
private Integer usuarioId;
|
||||
private String numAutorizacion;
|
||||
private String ordenSevicio;
|
||||
public Long getCajaId() {
|
||||
return cajaId;
|
||||
}
|
||||
public void setCajaId(Long cajaId) {
|
||||
this.cajaId = cajaId;
|
||||
}
|
||||
public String getNumAsiento() {
|
||||
return numAsiento;
|
||||
}
|
||||
public void setNumAsiento(String numAsiento) {
|
||||
this.numAsiento = numAsiento;
|
||||
}
|
||||
public Integer getCategoriaId() {
|
||||
return categoriaId;
|
||||
}
|
||||
public void setCategoriaId(Integer categoriaId) {
|
||||
this.categoriaId = categoriaId;
|
||||
}
|
||||
public String getNumFolioSistema() {
|
||||
return numFolioSistema;
|
||||
}
|
||||
public void setNumFolioSistema(String numFolioSistema) {
|
||||
this.numFolioSistema = numFolioSistema;
|
||||
}
|
||||
public Integer getClaseServicioId() {
|
||||
return claseServicioId;
|
||||
}
|
||||
public void setClaseServicioId(Integer claseServicioId) {
|
||||
this.claseServicioId = claseServicioId;
|
||||
}
|
||||
public Integer getMarcaId() {
|
||||
return marcaId;
|
||||
}
|
||||
public void setMarcaId(Integer marcaId) {
|
||||
this.marcaId = marcaId;
|
||||
}
|
||||
public Integer getOrigenId() {
|
||||
return origenId;
|
||||
}
|
||||
public void setOrigenId(Integer origenId) {
|
||||
this.origenId = origenId;
|
||||
}
|
||||
public Integer getDestinoId() {
|
||||
return destinoId;
|
||||
}
|
||||
public void setDestinoId(Integer destinoId) {
|
||||
this.destinoId = destinoId;
|
||||
}
|
||||
public Integer getCorridaId() {
|
||||
return corridaId;
|
||||
}
|
||||
public void setCorridaId(Integer corridaId) {
|
||||
this.corridaId = corridaId;
|
||||
}
|
||||
public Date getFecCorrida() {
|
||||
return fecCorrida;
|
||||
}
|
||||
public void setFecCorrida(Date fecCorrida) {
|
||||
this.fecCorrida = fecCorrida;
|
||||
}
|
||||
public String getNombPasajero() {
|
||||
return nombPasajero;
|
||||
}
|
||||
public void setNombPasajero(String nombPasajero) {
|
||||
this.nombPasajero = nombPasajero;
|
||||
}
|
||||
public BigDecimal getPrecioBase() {
|
||||
return precioBase;
|
||||
}
|
||||
public void setPrecioBase(BigDecimal precioBase) {
|
||||
this.precioBase = precioBase;
|
||||
}
|
||||
public BigDecimal getPrecioPagado() {
|
||||
return precioPagado;
|
||||
}
|
||||
public void setPrecioPagado(BigDecimal precioPagado) {
|
||||
this.precioPagado = precioPagado;
|
||||
}
|
||||
public Integer getTipoVentaId() {
|
||||
return tipoVentaId;
|
||||
}
|
||||
public void setTipoVentaId(Integer tipoVentaId) {
|
||||
this.tipoVentaId = tipoVentaId;
|
||||
}
|
||||
public String getNumSeriePreimpresa() {
|
||||
return numSeriePreimpresa;
|
||||
}
|
||||
public void setNumSeriePreimpresa(String numSeriePreimpresa) {
|
||||
this.numSeriePreimpresa = numSeriePreimpresa;
|
||||
}
|
||||
public String getNumFolioPreImpreso() {
|
||||
return numFolioPreImpreso;
|
||||
}
|
||||
public void setNumFolioPreImpreso(String numFolioPreImpreso) {
|
||||
this.numFolioPreImpreso = numFolioPreImpreso;
|
||||
}
|
||||
public Date getFecHorViaje() {
|
||||
return fecHorViaje;
|
||||
}
|
||||
public void setFecHorViaje(Date fecHorViaje) {
|
||||
this.fecHorViaje = fecHorViaje;
|
||||
}
|
||||
public Date getFecHorVenta() {
|
||||
return fecHorVenta;
|
||||
}
|
||||
public void setFecHorVenta(Date fecHorVenta) {
|
||||
this.fecHorVenta = fecHorVenta;
|
||||
}
|
||||
public Integer getPuntoVentaId() {
|
||||
return puntoVentaId;
|
||||
}
|
||||
public void setPuntoVentaId(Integer puntoVentaId) {
|
||||
this.puntoVentaId = puntoVentaId;
|
||||
}
|
||||
public BigDecimal getNumKmViaje() {
|
||||
return numKmViaje;
|
||||
}
|
||||
public void setNumKmViaje(BigDecimal numKmViaje) {
|
||||
this.numKmViaje = numKmViaje;
|
||||
}
|
||||
public String getNumOperacion() {
|
||||
return numOperacion;
|
||||
}
|
||||
public void setNumOperacion(String numOperacion) {
|
||||
this.numOperacion = numOperacion;
|
||||
}
|
||||
public Integer getMotivoCancelacionId() {
|
||||
return motivoCancelacionId;
|
||||
}
|
||||
public void setMotivoCancelacionId(Integer motivoCancelacionId) {
|
||||
this.motivoCancelacionId = motivoCancelacionId;
|
||||
}
|
||||
public Integer getEmpresaPuntoVentaId() {
|
||||
return empresaPuntoVentaId;
|
||||
}
|
||||
public void setEmpresaPuntoVentaId(Integer empresaPuntoVentaId) {
|
||||
this.empresaPuntoVentaId = empresaPuntoVentaId;
|
||||
}
|
||||
public Integer getEmpresaCorridaId() {
|
||||
return empresaCorridaId;
|
||||
}
|
||||
public void setEmpresaCorridaId(Integer empresaCorridaId) {
|
||||
this.empresaCorridaId = empresaCorridaId;
|
||||
}
|
||||
public Integer getTurnoId() {
|
||||
return turnoId;
|
||||
}
|
||||
public void setTurnoId(Integer turnoId) {
|
||||
this.turnoId = turnoId;
|
||||
}
|
||||
public BigDecimal getImporteTaxaEmbarque() {
|
||||
return importeTaxaEmbarque;
|
||||
}
|
||||
public void setImporteTaxaEmbarque(BigDecimal importeTaxaEmbarque) {
|
||||
this.importeTaxaEmbarque = importeTaxaEmbarque;
|
||||
}
|
||||
public BigDecimal getImportePedagio() {
|
||||
return importePedagio;
|
||||
}
|
||||
public void setImportePedagio(BigDecimal importePedagio) {
|
||||
this.importePedagio = importePedagio;
|
||||
}
|
||||
public BigDecimal getImporteOutros() {
|
||||
return importeOutros;
|
||||
}
|
||||
public void setImporteOutros(BigDecimal importeOutros) {
|
||||
this.importeOutros = importeOutros;
|
||||
}
|
||||
public BigDecimal getImporteSeguro() {
|
||||
return importeSeguro;
|
||||
}
|
||||
public void setImporteSeguro(BigDecimal importeSeguro) {
|
||||
this.importeSeguro = importeSeguro;
|
||||
}
|
||||
public Integer getRutaId() {
|
||||
return rutaId;
|
||||
}
|
||||
public void setRutaId(Integer rutaId) {
|
||||
this.rutaId = rutaId;
|
||||
}
|
||||
public Integer getUsuarioId() {
|
||||
return usuarioId;
|
||||
}
|
||||
public void setUsuarioId(Integer usuarioId) {
|
||||
this.usuarioId = usuarioId;
|
||||
}
|
||||
public String getNumAutorizacion() {
|
||||
return numAutorizacion;
|
||||
}
|
||||
public void setNumAutorizacion(String numAutorizacion) {
|
||||
this.numAutorizacion = numAutorizacion;
|
||||
}
|
||||
public String getOrdenSevicio() {
|
||||
return ordenSevicio;
|
||||
}
|
||||
public void setOrdenSevicio(String ordenSevicio) {
|
||||
this.ordenSevicio = ordenSevicio;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.rjconsultores.ventaboletos.ws.rs;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
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.CajaDAO;
|
||||
import com.rjconsultores.ventaboletos.vo.caja.CajaVO;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
||||
|
||||
@Path("/cajas")
|
||||
public class CajaRS {
|
||||
|
||||
@GET
|
||||
@Produces({ MediaType.APPLICATION_XML })
|
||||
public List<CajaVO> buscarCaja(@QueryParam("yaCerrado") boolean yaCerrado, @QueryParam("fecDesde") String fecDesde, @QueryParam("fecHasta") String fecHasta) {
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
|
||||
|
||||
Date fecDesdeD = new Date();
|
||||
Date fecHastaD = new Date();
|
||||
|
||||
try {
|
||||
fecDesdeD = StringUtils.isBlank(fecDesde) ? new Date() : sdf.parse(fecDesde);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
try {
|
||||
fecHastaD = StringUtils.isBlank(fecHasta) ? new Date() : sdf.parse(fecHasta);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
CajaDAO cajaDAO = (CajaDAO) AppContext.getApplicationContext().getBean("cajaDAO");
|
||||
List<CajaVO> list = cajaDAO.buscarCajaFecha(yaCerrado, fecDesdeD, fecHastaD);
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue