Subversion Repositories Integrator Subversion

Rev

Rev 195 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 195 Rev 580
Line 10... Line 10...
10
import br.com.ec.core.generic.AbstractService;
10
import br.com.ec.core.generic.AbstractService;
11
import br.com.ec.core.generic.GenericRepository;
11
import br.com.ec.core.generic.GenericRepository;
12
import br.com.ec.core.util.DataUtils;
12
import br.com.ec.core.util.DataUtils;
13
import br.com.ec.core.util.VerificadorUtil;
13
import br.com.ec.core.util.VerificadorUtil;
14
import br.com.ec.core.validador.Validador;
14
import br.com.ec.core.validador.Validador;
-
 
15
import br.com.ec.domain.model.AberturaLoja;
15
import br.com.ec.domain.model.Loja;
16
import br.com.ec.domain.model.Loja;
16
import br.com.ec.domain.model.Ponto;
17
import br.com.ec.domain.model.Ponto;
17
import br.com.ec.domain.model.Usuario;
18
import br.com.ec.domain.model.Usuario;
-
 
19
import br.com.ec.domain.service.aberturaloja.AberturaLojaService;
18
import br.com.ec.domain.service.loja.LojaService;
20
import br.com.ec.domain.service.loja.LojaService;
19
import br.com.ec.domain.service.ponto.PontoService;
21
import br.com.ec.domain.service.ponto.PontoService;
20
import br.com.ec.domain.service.usuario.UsuarioService;
22
import br.com.ec.domain.service.usuario.UsuarioService;
21
import br.com.ec.infrastructure.repository.PontoRepository;
23
import br.com.ec.infrastructure.repository.PontoRepository;
22
24
23
@Service
25
@Service
24
public class PontoServiceImpl extends AbstractService<Ponto> implements PontoService {
26
public class PontoServiceImpl extends AbstractService<Ponto> implements PontoService {
25
       
27
       
26
        private UsuarioService usuarioService;
28
        private UsuarioService usuarioService;
27
        private LojaService lojaService;
29
        private LojaService lojaService;
-
 
30
        private AberturaLojaService aberturaLojaService;
28
       
31
       
29
        private PontoRepository pontoRepository;
32
        private PontoRepository pontoRepository;
30
33
31
        @Autowired
34
        @Autowired
32
        public PontoServiceImpl(Validador validador, PontoRepository pontoRepository, UsuarioService usuarioService, LojaService lojaService) {
-
 
-
 
35
        public PontoServiceImpl(Validador validador, UsuarioService usuarioService, AberturaLojaService aberturaLojaService,
-
 
36
                        LojaService lojaService, PontoRepository pontoRepository) {
33
                super(validador);
37
                super(validador);
34
                this.pontoRepository = pontoRepository;
-
 
35
                this.usuarioService = usuarioService;
38
                this.usuarioService = usuarioService;
36
                this.lojaService = lojaService;
39
                this.lojaService = lojaService;
-
 
40
                this.aberturaLojaService = aberturaLojaService;
-
 
41
                this.pontoRepository = pontoRepository;
37
        }
42
        }
38
43
39
        @Override
44
        @Override
40
        protected GenericRepository<Ponto> getRepository() {
45
        protected GenericRepository<Ponto> getRepository() {
41
                return pontoRepository;
46
                return pontoRepository;
Line 47... Line 52...
47
                ponto.setDataPonto(DataUtils.getDataAtual());
52
                ponto.setDataPonto(DataUtils.getDataAtual());
48
                if (VerificadorUtil.naoEstaNulo(lojaSequencial)) {
53
                if (VerificadorUtil.naoEstaNulo(lojaSequencial)) {
49
                        Loja loja = new Loja();
54
                        Loja loja = new Loja();
50
                        loja.setSequencial(lojaSequencial);
55
                        loja.setSequencial(lojaSequencial);
51
                        ponto.setLoja(lojaService.consultarPorId(loja));
56
                        ponto.setLoja(lojaService.consultarPorId(loja));
-
 
57
                       
-
 
58
                        AberturaLoja aberturaLoja = aberturaLojaService.consultarAberturaLoja(dataAtual, loja);
-
 
59
                        if (VerificadorUtil.estaNulo(aberturaLoja)) {
-
 
60
                                throw new NegocioException("ABERTURA DE LOJA PENDENTE");
-
 
61
                        }
52
                }
62
                }
53
                if (VerificadorUtil.estaNulo(ponto.getLoja())) {
63
                if (VerificadorUtil.estaNulo(ponto.getLoja())) {
54
                        throw new NegocioException("LOJA NÃO IDENTIFICADA");
64
                        throw new NegocioException("LOJA NÃO IDENTIFICADA");
55
                }
65
                }
-
 
66
               
56
               
67
               
57
                Usuario usuarioConsultado = usuarioService.consultarUsuarioPorSenha(senhaUsuario);
68
                Usuario usuarioConsultado = usuarioService.consultarUsuarioPorSenha(senhaUsuario);
58
                if (VerificadorUtil.estaNulo(usuarioConsultado)) {
69
                if (VerificadorUtil.estaNulo(usuarioConsultado)) {
59
                        throw new NegocioException("USUÁRIO NÃO IDENTIFICADO");
70
                        throw new NegocioException("USUÁRIO NÃO IDENTIFICADO");
60
                }
71
                }