116 lines
3.3 KiB
Java
116 lines
3.3 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.Date;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import com.rjconsultores.ventaboletos.dao.CiudadDAO;
|
|
import com.rjconsultores.ventaboletos.dao.EmpresaDAO;
|
|
import com.rjconsultores.ventaboletos.dao.EstadoDAO;
|
|
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
|
import com.rjconsultores.ventaboletos.entidad.Estado;
|
|
import com.rjconsultores.ventaboletos.entidad.Pais;
|
|
import com.rjconsultores.ventaboletos.service.EstadoService;
|
|
import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException;
|
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
|
|
|
/**
|
|
*
|
|
* @author MCosso
|
|
*/
|
|
@Service("estadoService")
|
|
public class EstadoServiceImpl implements EstadoService {
|
|
|
|
@Autowired
|
|
private EstadoDAO estadoDAO;
|
|
@Autowired
|
|
private CiudadDAO ciudadDAO;
|
|
@Autowired
|
|
private EmpresaDAO empresaDAO;
|
|
|
|
public List<Estado> obtenerTodos() {
|
|
return estadoDAO.obtenerTodos();
|
|
}
|
|
|
|
public Estado obtenerID(Integer id) {
|
|
return estadoDAO.obtenerID(id);
|
|
}
|
|
|
|
@Transactional
|
|
public Estado suscribir(Estado entidad) {
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.TRUE);
|
|
|
|
entidad = estadoDAO.suscribir(entidad);
|
|
|
|
gerarSeqNumFolioSistema(entidad);
|
|
|
|
return entidad;
|
|
}
|
|
|
|
@Transactional
|
|
public Estado actualizacion(Estado entidad) {
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.TRUE);
|
|
|
|
return estadoDAO.actualizacion(entidad);
|
|
}
|
|
|
|
@Transactional
|
|
public void borrar(Estado entidad) throws RegistroConDependenciaException {
|
|
|
|
if (ciudadDAO.count("estado", entidad) > 0l) {
|
|
throw new RegistroConDependenciaException();
|
|
}
|
|
|
|
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
|
entidad.setFecmodif(Calendar.getInstance().getTime());
|
|
entidad.setActivo(Boolean.FALSE);
|
|
|
|
estadoDAO.actualizacion(entidad);
|
|
}
|
|
|
|
public List<Estado> buscar(String nombestado, Pais pais) {
|
|
return estadoDAO.buscar(nombestado, pais);
|
|
}
|
|
|
|
public List<Estado> buscarNotInEmpresaImposto(Empresa empresa) {
|
|
return estadoDAO.buscarNotInEmpresaImposto(empresa);
|
|
|
|
}
|
|
|
|
@Override
|
|
public List<Estado> buscarCveEstado(String cveEstado) {
|
|
return estadoDAO.buscarCveEstado(cveEstado);
|
|
}
|
|
|
|
private void gerarSeqNumFolioSistema(Estado estado) {
|
|
List<Empresa> lsEmpresas = empresaDAO.obtenerTodos();
|
|
for (Empresa empresa : lsEmpresas) {
|
|
empresaDAO.gerarSeqNumFolioSistema(empresa.getEmpresaId(), estado.getCveestado());
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Map<String, Integer> getConfiguracoesFusoVeraoParada(Integer paradaId, Date data) {
|
|
return estadoDAO.getConfiguracoesFusoVeraoParada(paradaId, data);
|
|
}
|
|
|
|
@Override
|
|
public Map<String, Integer> getConfiguracoesFusoVeraoPuntoventa(Integer puntoventaId, Date data) {
|
|
return estadoDAO.getConfiguracoesFusoVeraoPuntoventa(puntoventaId, data);
|
|
}
|
|
|
|
}
|