Conclusão mantis 6968
fixes bug 6968 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@51660 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
922c950e36
commit
afd5006d20
|
@ -16,4 +16,6 @@ public interface ClasseServicoDAO extends GenericDAO<ClaseServicio, Integer> {
|
|||
public List<ClaseServicio> buscarPorNome(String nomeClaseServicio);
|
||||
|
||||
public List<ClaseServicio> buscarTodosExceto(Integer ... idClase);
|
||||
|
||||
public List<ClaseServicio> buscarPorEmpresasDoUsuario (String idEmpresasUsuario);
|
||||
}
|
|
@ -4,17 +4,22 @@
|
|||
*/
|
||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.ClasseServicoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.transform.AliasToBeanResultTransformer;
|
||||
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.ClasseServicoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrador
|
||||
|
@ -35,6 +40,24 @@ public class ClasseServicoHibernateDAO extends GenericHibernateDAO<ClaseServicio
|
|||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ClaseServicio> buscarPorEmpresasDoUsuario (String empresasUsuario) {
|
||||
|
||||
String consulta = ""
|
||||
+ " SELECT DISTINCT CS.DESCCLASE AS descclase "
|
||||
+ " FROM MARCA_CLASESERVICIO MC "
|
||||
+ " JOIN CLASE_SERVICIO CS ON CS.CLASESERVICIO_ID = MC.CLASESERVICIO_ID "
|
||||
+ " JOIN MARCA M ON M.MARCA_ID = MC.MARCA_ID "
|
||||
+ " WHERE M.EMPRESA_ID IN (:empresas)";
|
||||
|
||||
SQLQuery query = getSession().createSQLQuery(consulta);
|
||||
query.setParameterList("empresas", empresasUsuario.split(","));
|
||||
query.setResultTransformer(new AliasToBeanResultTransformer(getPersistentClass()));
|
||||
query.addScalar("descclase", StringType.INSTANCE);
|
||||
List<ClaseServicio> result = (List<ClaseServicio>) query.list();
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<ClaseServicio> buscarPorNome(String nomeClaseServicio) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
|
|
|
@ -210,4 +210,4 @@ public class ClaseServicio implements Serializable {
|
|||
public void setEquivalenciaElektraId(String equivalenciaElektraId) {
|
||||
this.equivalenciaElektraId = equivalenciaElektraId;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -16,4 +18,6 @@ public interface ClaseServicioService extends GenericService<ClaseServicio, Inte
|
|||
public List<ClaseServicio> buscarPorNome(String nomeClaseServicio);
|
||||
|
||||
public List<ClaseServicio> buscarTodosExceto(Integer ... idClase);
|
||||
|
||||
public List<ClaseServicio> buscarPorEmpresasDoUsuario (List<Empresa> empresasUsuario);
|
||||
}
|
||||
|
|
|
@ -6,10 +6,13 @@ package com.rjconsultores.ventaboletos.service.impl;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.ClasseServicoDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.ClaseServicio;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.service.ClaseServicioService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -62,7 +65,28 @@ public class ClaseServicioServiceImpl implements ClaseServicioService {
|
|||
public List<ClaseServicio> buscarPorNome(String nomeClaseServicio) {
|
||||
return claseServicoDAO.buscarPorNome(nomeClaseServicio);
|
||||
}
|
||||
|
||||
public List<ClaseServicio> buscarTodosExceto(Integer ... idClase){
|
||||
return claseServicoDAO.buscarTodosExceto(idClase);
|
||||
}
|
||||
|
||||
public List<ClaseServicio> buscarPorEmpresasDoUsuario (List<Empresa> empresasUsuario) {
|
||||
|
||||
if(empresasUsuario == null || empresasUsuario.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder idEmpresasBuilder = new StringBuilder();
|
||||
String idEmpresas = "";
|
||||
|
||||
for (Empresa empresa : empresasUsuario) {
|
||||
idEmpresasBuilder.append(empresa.getEmpresaId().toString()).append(",");
|
||||
}
|
||||
|
||||
idEmpresasBuilder = idEmpresasBuilder.deleteCharAt(idEmpresasBuilder.length() -1);
|
||||
idEmpresas = idEmpresasBuilder.toString();
|
||||
|
||||
List<ClaseServicio> result = (List<ClaseServicio>) claseServicoDAO.buscarPorEmpresasDoUsuario(idEmpresas);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue