fixes bug #8301
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@64584 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
a329a01314
commit
f4b8632e5e
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.SegVKM;
|
||||
|
@ -15,4 +16,8 @@ import com.rjconsultores.ventaboletos.entidad.SegVKM;
|
|||
public interface SegVKMDAO extends GenericDAO<SegVKM, Integer> {
|
||||
|
||||
public List<SegVKM> buscar(String segVKm);
|
||||
|
||||
public String seriePorEmpresa(Integer empresaId);
|
||||
|
||||
public BigDecimal buscarSeguroPorKm(Long km, String serie, Integer orgaoConcedenteId);
|
||||
}
|
||||
|
|
|
@ -131,7 +131,8 @@ public class ParadaHibernateDAO extends GenericHibernateDAO<Parada, Integer> imp
|
|||
String sql = "SELECT DISTINCT "
|
||||
+ "t.destino "
|
||||
+ "FROM Tramo t "
|
||||
+ "WHERE t.origem = :origem";
|
||||
+ "WHERE t.origem = :origem "
|
||||
+ "ORDER BY t.destino.descparada";
|
||||
|
||||
return getSession().createQuery(sql).setEntity("origem", origem).list();
|
||||
}
|
||||
|
|
|
@ -4,9 +4,12 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -14,6 +17,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.SegVKMDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.SegVKM;
|
||||
|
||||
/**
|
||||
|
@ -45,4 +49,63 @@ public class SegVKMHibernateDAO extends GenericHibernateDAO<SegVKM, Integer>
|
|||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
public BigDecimal buscarSeguroPorKm(Long km, String serie, Integer orgaoConcedenteId) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Query miQry = null;
|
||||
|
||||
sb = new StringBuilder();
|
||||
sb.append(" select seg.valor");
|
||||
sb.append(" from SegVKm seg");
|
||||
sb.append(" where seg.activo = 1 and seg.km >= :km and seg.serie in (" + serie + ") and seg.ORGAOCONCEDENTE_ID = :orgaoconcedenteId");
|
||||
sb.append(" order by seg.km");
|
||||
|
||||
miQry = getSession().createSQLQuery(sb.toString());
|
||||
miQry.setLong("km", km);
|
||||
miQry.setInteger("orgaoconcedenteId", orgaoConcedenteId);
|
||||
|
||||
miQry.setMaxResults(1);
|
||||
|
||||
List<BigDecimal> list = miQry.list();
|
||||
|
||||
if (list.isEmpty()) {
|
||||
sb = new StringBuilder();
|
||||
sb.append(" select seg.valor");
|
||||
sb.append(" from SegVKm seg");
|
||||
sb.append(" where seg.activo = 1 and seg.km >= :km and seg.serie in (" + serie + ") and seg.orgaoconcedenteId is null");
|
||||
sb.append(" order by seg.km");
|
||||
miQry = getSession().createQuery(sb.toString());
|
||||
|
||||
// miQry.setMaxResults(1);
|
||||
|
||||
miQry.setLong("km", km);
|
||||
list = miQry.list();
|
||||
}
|
||||
|
||||
return list.isEmpty() ? null : list.get(0);
|
||||
}
|
||||
|
||||
public String seriePorEmpresa(Integer empresaId) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(" select serie ");
|
||||
sb.append(" from SeguradoraEmpresa segEmp");
|
||||
sb.append(" where segEmp.activo = 1 and segEmp.empresa = :empresaId");
|
||||
|
||||
Query q = getSession().createQuery(sb.toString());
|
||||
q.setInteger("empresaId", empresaId);
|
||||
|
||||
List<String> res = q.list();
|
||||
String series = "";
|
||||
for (String serie : res) {
|
||||
series += "'" + serie + "',";
|
||||
}
|
||||
if (!series.isEmpty()) {
|
||||
series = series.substring(0, series.length() - 1);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(series)) {
|
||||
return "-1";
|
||||
}
|
||||
return series;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.SegVKM;
|
||||
|
@ -15,4 +16,8 @@ import com.rjconsultores.ventaboletos.entidad.SegVKM;
|
|||
public interface SegVKMService extends GenericService<SegVKM, Integer> {
|
||||
|
||||
public List<SegVKM> buscar(String serie);
|
||||
|
||||
public String seriePorEmpresa(Integer empresaId);
|
||||
|
||||
public BigDecimal buscarSeguroPorKm(Long km, String serie, Integer orgaoConcedenteId);
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.jboss.resteasy.client.core.SelfExpandingBufferredInputStream;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -63,5 +65,16 @@ public class SegVKMServiceImpl implements SegVKMService {
|
|||
|
||||
public List<SegVKM> buscar(String serie) {
|
||||
return segVKMDAO.buscar(serie);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String seriePorEmpresa(Integer empresaId) {
|
||||
return segVKMDAO.seriePorEmpresa(empresaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal buscarSeguroPorKm(Long km, String serie, Integer orgaoConcedenteId) {
|
||||
return segVKMDAO.buscarSeguroPorKm(km, serie, orgaoConcedenteId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue