117 lines
3.6 KiB
Java
117 lines
3.6 KiB
Java
/*
|
|
* To change this template, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
package com.rjconsultores.ventaboletos.service.impl;
|
|
|
|
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;
|
|
|
|
import com.rjconsultores.ventaboletos.dao.EmpresaDAO;
|
|
import com.rjconsultores.ventaboletos.dao.EsquemaCorridaDAO;
|
|
import com.rjconsultores.ventaboletos.dao.RutaEmpresaDAO;
|
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
|
import com.rjconsultores.ventaboletos.entidad.InscricaoEstadual;
|
|
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
|
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
|
import com.rjconsultores.ventaboletos.service.EmpresaService;
|
|
import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
|
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
|
|
|
/**
|
|
*
|
|
* @author Administrador
|
|
*/
|
|
@Service("empresaService")
|
|
public class EmpresaServiceImpl implements EmpresaService {
|
|
|
|
@Autowired
|
|
private EmpresaDAO empresaDAO;
|
|
|
|
@Autowired
|
|
private RutaEmpresaDAO rutaEmpresaDAO;
|
|
|
|
@Autowired
|
|
private EsquemaCorridaDAO esquemaCorridaDAO;
|
|
|
|
public List<Empresa> obtenerTodos() {
|
|
return empresaDAO.obtenerTodos();
|
|
}
|
|
|
|
public Empresa obtenerID(Integer id) {
|
|
return empresaDAO.obtenerID(id);
|
|
}
|
|
|
|
@Transactional
|
|
public Empresa suscribirActualizacion(Empresa entidad) throws BusinessException {
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.TRUE);
|
|
|
|
if (entidad.getEmpresaId() == null) {
|
|
return empresaDAO.suscribir(entidad);
|
|
} else {
|
|
return empresaDAO.actualizacion(entidad);
|
|
}
|
|
}
|
|
|
|
@Transactional
|
|
public void borrar(Empresa entidad) throws RegistroConDependenciaException {
|
|
if ((rutaEmpresaDAO.obtenerPorEmpresa(entidad).size() > 0) ||
|
|
(esquemaCorridaDAO.buscarPorEmpresaCorrida(entidad).size() > 0)){
|
|
throw new RegistroConDependenciaException();
|
|
}
|
|
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.FALSE);
|
|
|
|
empresaDAO.actualizacion(entidad);
|
|
}
|
|
|
|
|
|
public List<Empresa> buscar(String nombempresa, Boolean indExterna, Short indTipo) {
|
|
return empresaDAO.buscar(nombempresa, indExterna, indTipo);
|
|
}
|
|
|
|
public List<Empresa> buscarTodosExceto(List<Empresa> empresa,Integer... idEmpresa) {
|
|
return empresaDAO.buscarTodosExceto( empresa, idEmpresa);
|
|
}
|
|
|
|
public List<Empresa> obtenerIndExternoFalse() {
|
|
return empresaDAO.obtenerIndExternoFalse();
|
|
}
|
|
|
|
public List<Empresa> obtenerIndTipo2() {
|
|
return empresaDAO.obtenerIndTipo2();
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see com.rjconsultores.ventaboletos.service.EmpresaService#buscarNotInPuntoVtaComissao(com.rjconsultores.ventaboletos.entidad.PuntoVenta)
|
|
*/
|
|
@Override
|
|
public List<Empresa> buscarNotInPuntoVtaComissao(PuntoVenta puntoVenta) {
|
|
return empresaDAO.buscarNotInPuntoVtaComissao(puntoVenta);
|
|
|
|
}
|
|
|
|
@Override
|
|
public List<InscricaoEstadual> buscaInscricoesEstaduais(Empresa empresa) {
|
|
return empresaDAO.buscaInscricoesEstaduais(empresa);
|
|
}
|
|
|
|
@Override
|
|
public void actualizaInscEstadual(InscricaoEstadual inscricaoEstadual) {
|
|
empresaDAO.actualizaInscEstadual(inscricaoEstadual);
|
|
}
|
|
|
|
@Override
|
|
public List<Empresa> buscaLike(String nombempresa){
|
|
return empresaDAO.buscaLike(nombempresa);
|
|
}
|
|
}
|