14394: Melhoria performace Dispositivo Venda Embarcada
fixes bug#14394 dev:valdir qua:marcelo git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@93415 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
d7ee6afc6d
commit
204c0d0bd6
|
@ -4,7 +4,10 @@
|
||||||
*/
|
*/
|
||||||
package com.rjconsultores.ventaboletos.dao;
|
package com.rjconsultores.ventaboletos.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Boleto;
|
import com.rjconsultores.ventaboletos.entidad.Boleto;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.embarcada.PtoVtaUsuarioUltimaVendaDispositivoVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -13,5 +16,5 @@ import com.rjconsultores.ventaboletos.entidad.Boleto;
|
||||||
|
|
||||||
public interface BoletoDAO extends GenericDAO<Boleto, Long> {
|
public interface BoletoDAO extends GenericDAO<Boleto, Long> {
|
||||||
public Boleto buscarPeloImeiDoDispositivo(String imei);
|
public Boleto buscarPeloImeiDoDispositivo(String imei);
|
||||||
|
public List<PtoVtaUsuarioUltimaVendaDispositivoVO> buscarUltimaVendaDosDispositivosEmbarcada();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,23 @@
|
||||||
*/
|
*/
|
||||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.Criteria;
|
import org.hibernate.Criteria;
|
||||||
|
import org.hibernate.SQLQuery;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.criterion.Order;
|
import org.hibernate.criterion.Order;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
import org.hibernate.transform.AliasToBeanResultTransformer;
|
||||||
|
import org.hibernate.type.LongType;
|
||||||
|
import org.hibernate.type.StringType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.dao.BoletoDAO;
|
import com.rjconsultores.ventaboletos.dao.BoletoDAO;
|
||||||
import com.rjconsultores.ventaboletos.entidad.Boleto;
|
import com.rjconsultores.ventaboletos.entidad.Boleto;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.embarcada.PtoVtaUsuarioUltimaVendaDispositivoVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -27,6 +34,29 @@ public class BoletoHibernateDAO extends GenericHibernateDAO<Boleto, Long> implem
|
||||||
setSessionFactory(factory);
|
setSessionFactory(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<PtoVtaUsuarioUltimaVendaDispositivoVO> buscarUltimaVendaDosDispositivosEmbarcada(){
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("select p.puntoventa_id as puntoventaId, u.usuario_id as usuarioId, u.nombusuario as nombusuario, p.nombpuntoventa as nombpuntoventa, b.imei_dispositivo_embarcada as imei ");
|
||||||
|
sb.append("from ");
|
||||||
|
sb.append(" boleto b ");
|
||||||
|
sb.append(" left join usuario u on u.usuario_id = b.usuario_id ");
|
||||||
|
sb.append(" left join punto_venta p on p.puntoventa_id = b.puntoventa_id ");
|
||||||
|
sb.append("where ");
|
||||||
|
sb.append(" b.boleto_id in (select max(boleto_id) ");
|
||||||
|
sb.append("from boleto ");
|
||||||
|
sb.append("where imei_dispositivo_embarcada is not null ");
|
||||||
|
sb.append("group by imei_dispositivo_embarcada)");
|
||||||
|
|
||||||
|
|
||||||
|
SQLQuery qry = getSession().createSQLQuery(sb.toString())
|
||||||
|
.addScalar("puntoventaId", LongType.INSTANCE)
|
||||||
|
.addScalar("usuarioId", LongType.INSTANCE)
|
||||||
|
.addScalar("nombusuario", StringType.INSTANCE)
|
||||||
|
.addScalar("nombpuntoventa", StringType.INSTANCE)
|
||||||
|
.addScalar("imei", StringType.INSTANCE);
|
||||||
|
qry.setResultTransformer(new AliasToBeanResultTransformer(PtoVtaUsuarioUltimaVendaDispositivoVO.class));
|
||||||
|
return qry.list();
|
||||||
|
}
|
||||||
|
|
||||||
public Boleto buscarPeloImeiDoDispositivo(String imei) {
|
public Boleto buscarPeloImeiDoDispositivo(String imei) {
|
||||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.rjconsultores.ventaboletos.vo.embarcada;
|
||||||
|
|
||||||
|
public class PtoVtaUsuarioUltimaVendaDispositivoVO {
|
||||||
|
private Long puntoventaId;
|
||||||
|
private Long usuarioId;
|
||||||
|
private String nombusuario;
|
||||||
|
private String nombpuntoventa;
|
||||||
|
private String imei;
|
||||||
|
|
||||||
|
public PtoVtaUsuarioUltimaVendaDispositivoVO(){}
|
||||||
|
|
||||||
|
public PtoVtaUsuarioUltimaVendaDispositivoVO(Long puntoventaId, Long usuarioId, String nombusuario, String nombpuntoventa, String imei) {
|
||||||
|
super();
|
||||||
|
this.puntoventaId = puntoventaId;
|
||||||
|
this.usuarioId = usuarioId;
|
||||||
|
this.nombusuario = nombusuario;
|
||||||
|
this.nombpuntoventa = nombpuntoventa;
|
||||||
|
this.imei = imei;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getPuntoventaId() {
|
||||||
|
return puntoventaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPuntoventaId(Long puntoventaId) {
|
||||||
|
this.puntoventaId = puntoventaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUsuarioId() {
|
||||||
|
return usuarioId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsuarioId(Long usuarioId) {
|
||||||
|
this.usuarioId = usuarioId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNombusuario() {
|
||||||
|
return nombusuario;
|
||||||
|
}
|
||||||
|
public void setNombusuario(String nombusuario) {
|
||||||
|
this.nombusuario = nombusuario;
|
||||||
|
}
|
||||||
|
public String getNombpuntoventa() {
|
||||||
|
return nombpuntoventa;
|
||||||
|
}
|
||||||
|
public void setNombpuntoventa(String nombpuntoventa) {
|
||||||
|
this.nombpuntoventa = nombpuntoventa;
|
||||||
|
}
|
||||||
|
public String getImei() {
|
||||||
|
return imei;
|
||||||
|
}
|
||||||
|
public void setImei(String imei) {
|
||||||
|
this.imei = imei;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue