Rev 412 | Rev 553 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 325 | espaco | 1 | package br.com.ec.controller; |
| 2 | |||
| 412 | espaco | 3 | import java.io.IOException; |
| 325 | espaco | 4 | import java.io.Serializable; |
| 353 | espaco | 5 | import java.util.ArrayList; |
| 355 | espaco | 6 | import java.util.Date; |
| 325 | espaco | 7 | import java.util.List; |
| 8 | |||
| 9 | import javax.inject.Inject; |
||
| 10 | import javax.inject.Named; |
||
| 11 | |||
| 12 | import org.springframework.context.annotation.Scope; |
||
| 13 | |||
| 14 | import br.com.ec.core.generic.GenericService; |
||
| 353 | espaco | 15 | import br.com.ec.core.util.DataUtils; |
| 325 | espaco | 16 | import br.com.ec.core.util.VerificadorUtil; |
| 353 | espaco | 17 | import br.com.ec.domain.dto.AtestadoFuncionarioDTO; |
| 412 | espaco | 18 | import br.com.ec.domain.dto.BancoHorasDTO; |
| 325 | espaco | 19 | import br.com.ec.domain.dto.EnderecoDTO; |
| 353 | espaco | 20 | import br.com.ec.domain.dto.ExameFuncionarioDTO; |
| 325 | espaco | 21 | import br.com.ec.domain.dto.FuncionarioDTO; |
| 353 | espaco | 22 | import br.com.ec.domain.dto.FuncionarioEscalaDTO; |
| 409 | espaco | 23 | import br.com.ec.domain.dto.FuncionarioEventoDTO; |
| 353 | espaco | 24 | import br.com.ec.domain.dto.FuncionarioFeriasDTO; |
| 25 | import br.com.ec.domain.dto.LojaDTO; |
||
| 26 | import br.com.ec.domain.dto.PessoaDTO; |
||
| 325 | espaco | 27 | import br.com.ec.domain.dto.PessoaPapelDTO; |
| 353 | espaco | 28 | import br.com.ec.domain.dto.PontoDTO; |
| 325 | espaco | 29 | import br.com.ec.domain.dto.UsuarioDTO; |
| 30 | import br.com.ec.domain.dto.UsuarioLojaDTO; |
||
| 31 | import br.com.ec.domain.dto.UsuarioPerfilDTO; |
||
| 355 | espaco | 32 | import br.com.ec.domain.dto.VigenciaDTO; |
| 412 | espaco | 33 | import br.com.ec.domain.model.BancoHoras; |
| 325 | espaco | 34 | import br.com.ec.domain.model.Endereco; |
| 35 | import br.com.ec.domain.model.Funcionario; |
||
| 411 | espaco | 36 | import br.com.ec.domain.model.FuncionarioEvento; |
| 353 | espaco | 37 | import br.com.ec.domain.model.FuncionarioFerias; |
| 325 | espaco | 38 | import br.com.ec.domain.model.Papel; |
| 353 | espaco | 39 | import br.com.ec.domain.model.Ponto; |
| 325 | espaco | 40 | import br.com.ec.domain.model.Usuario; |
| 409 | espaco | 41 | import br.com.ec.domain.model.tipos.TipoFuncionarioEvento; |
| 326 | espaco | 42 | import br.com.ec.domain.service.AvaliacaoFuncionarioService; |
| 412 | espaco | 43 | import br.com.ec.domain.service.BancoHorasService; |
| 325 | espaco | 44 | import br.com.ec.domain.service.EnderecoService; |
| 409 | espaco | 45 | import br.com.ec.domain.service.FuncionarioEventoService; |
| 353 | espaco | 46 | import br.com.ec.domain.service.FuncionarioFeriasService; |
| 325 | espaco | 47 | import br.com.ec.domain.service.FuncionarioService; |
| 48 | import br.com.ec.domain.service.PapelService; |
||
| 49 | import br.com.ec.domain.service.PessoaPapelService; |
||
| 50 | import br.com.ec.domain.service.PessoaService; |
||
| 353 | espaco | 51 | import br.com.ec.domain.service.PontoService; |
| 325 | espaco | 52 | import br.com.ec.domain.service.UsuarioLojaService; |
| 53 | import br.com.ec.domain.service.UsuarioPerfilService; |
||
| 54 | import br.com.ec.domain.service.UsuarioService; |
||
| 55 | import br.com.ec.domain.service.VendedorService; |
||
| 56 | import br.com.ec.web.exception.VerificadorLancamentoException; |
||
| 57 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 58 | import br.com.ec.web.generic.AbstractBean; |
||
| 59 | import br.com.ec.web.message.LancadorMensagem; |
||
| 60 | import br.com.ec.web.util.TipoOperacao; |
||
| 61 | |||
| 62 | @Named |
||
| 63 | @Scope("view") |
||
| 64 | public class FuncionarioBean extends AbstractBean<Funcionario> implements Serializable { |
||
| 65 | |||
| 66 | private static final long serialVersionUID = 1L; |
||
| 67 | |||
| 68 | private FuncionarioService funcionarioService; |
||
| 69 | private UsuarioService usuarioService; |
||
| 70 | private PessoaService pessoaService; |
||
| 71 | private PapelService papelService; |
||
| 72 | private PessoaPapelService pessoaPapelService; |
||
| 73 | private EnderecoService enderecoService; |
||
| 74 | private UsuarioPerfilService usuarioPerfilService; |
||
| 75 | private UsuarioLojaService usuarioLojaService; |
||
| 76 | private VendedorService vendedorService; |
||
| 326 | espaco | 77 | private AvaliacaoFuncionarioService avaliacaoFuncionarioService; |
| 353 | espaco | 78 | private FuncionarioFeriasService funcionarioFeriasService; |
| 409 | espaco | 79 | private FuncionarioEventoService funcionarioEventoService; |
| 412 | espaco | 80 | private BancoHorasService bancoHorasService; |
| 353 | espaco | 81 | private PontoService pontoService; |
| 325 | espaco | 82 | |
| 83 | private FuncionarioDTO entidadeParaConsulta; |
||
| 84 | private List<FuncionarioDTO> funcionarios; |
||
| 85 | |||
| 86 | private FuncionarioDTO entidadeDTO; |
||
| 87 | private PessoaPapelDTO pessoaPapelDTO; |
||
| 88 | private Endereco endereco; |
||
| 89 | private Usuario usuario; |
||
| 90 | private UsuarioPerfilDTO usuarioPerfilDTO; |
||
| 91 | private UsuarioLojaDTO usuarioLojaDTO; |
||
| 353 | espaco | 92 | private FuncionarioFeriasDTO funcionarioFeriasDTO; |
| 409 | espaco | 93 | private FuncionarioEventoDTO funcionarioEventoDTO; |
| 94 | private FuncionarioEscalaDTO funcionarioEscalaDTO; |
||
| 412 | espaco | 95 | private BancoHorasDTO bancoHorasDTO; |
| 325 | espaco | 96 | |
| 97 | @Inject |
||
| 98 | public FuncionarioBean(FuncionarioService funcionarioService, UsuarioService usuarioService, PessoaService pessoaService, |
||
| 99 | PapelService papelService, PessoaPapelService pessoaPapelService, EnderecoService enderecoService, |
||
| 326 | espaco | 100 | UsuarioPerfilService usuarioPerfilService, UsuarioLojaService usuarioLojaService, VendedorService vendedorService, |
| 353 | espaco | 101 | AvaliacaoFuncionarioService avaliacaoFuncionarioService, FuncionarioFeriasService funcionarioFeriasService, |
| 412 | espaco | 102 | FuncionarioEventoService funcionarioEventoService, BancoHorasService bancoHorasService, PontoService pontoService) { |
| 325 | espaco | 103 | this.funcionarioService = funcionarioService; |
| 104 | this.usuarioService = usuarioService; |
||
| 105 | this.pessoaService = pessoaService; |
||
| 106 | this.papelService = papelService; |
||
| 107 | this.pessoaPapelService = pessoaPapelService; |
||
| 108 | this.enderecoService = enderecoService; |
||
| 109 | this.usuarioPerfilService = usuarioPerfilService; |
||
| 110 | this.usuarioLojaService = usuarioLojaService; |
||
| 111 | this.vendedorService = vendedorService; |
||
| 326 | espaco | 112 | this.avaliacaoFuncionarioService = avaliacaoFuncionarioService; |
| 353 | espaco | 113 | this.funcionarioFeriasService = funcionarioFeriasService; |
| 409 | espaco | 114 | this.funcionarioEventoService = funcionarioEventoService; |
| 412 | espaco | 115 | this.bancoHorasService = bancoHorasService; |
| 353 | espaco | 116 | this.pontoService = pontoService; |
| 325 | espaco | 117 | } |
| 118 | |||
| 119 | @Override |
||
| 120 | public void preCarregamento() { |
||
| 121 | limparEntidade(); |
||
| 122 | consultarFuncionarios(); |
||
| 123 | } |
||
| 124 | |||
| 125 | @Override |
||
| 126 | public void limparEntidade() { |
||
| 127 | setEntidade(new Funcionario()); |
||
| 430 | espaco | 128 | FuncionarioDTO funcionarioParaConsulta = new FuncionarioDTO(); |
| 129 | funcionarioParaConsulta.setPessoaDTO(new PessoaDTO()); |
||
| 130 | setEntidadeParaConsulta(funcionarioParaConsulta); |
||
| 325 | espaco | 131 | setEntidadeDTO(null); |
| 132 | consultarFuncionarios(); |
||
| 133 | } |
||
| 134 | |||
| 135 | @Override |
||
| 136 | public GenericService<Funcionario> getService() { |
||
| 137 | return funcionarioService; |
||
| 138 | } |
||
| 139 | |||
| 140 | @Override |
||
| 141 | public Funcionario getEntidade() { |
||
| 142 | return entidade; |
||
| 143 | } |
||
| 144 | |||
| 145 | @Override |
||
| 146 | public void preConsultar() { |
||
| 147 | setTipoOperacao(TipoOperacao.CONSULTAR); |
||
| 148 | } |
||
| 149 | |||
| 150 | @Override |
||
| 151 | public Funcionario getId() { |
||
| 152 | return getEntidade(); |
||
| 153 | } |
||
| 154 | |||
| 155 | /*************************************************/ |
||
| 156 | |||
| 157 | public FuncionarioDTO getEntidadeParaConsulta() { |
||
| 158 | return entidadeParaConsulta; |
||
| 159 | } |
||
| 160 | public void setEntidadeParaConsulta(FuncionarioDTO entidadeParaConsulta) { |
||
| 161 | this.entidadeParaConsulta = entidadeParaConsulta; |
||
| 162 | } |
||
| 163 | |||
| 164 | public List<FuncionarioDTO> getFuncionarios() { |
||
| 165 | return funcionarios; |
||
| 166 | } |
||
| 167 | public void setFuncionarios(List<FuncionarioDTO> funcionarios) { |
||
| 168 | this.funcionarios = funcionarios; |
||
| 169 | } |
||
| 170 | |||
| 171 | public FuncionarioDTO getEntidadeDTO() { |
||
| 172 | return entidadeDTO; |
||
| 173 | } |
||
| 174 | public void setEntidadeDTO(FuncionarioDTO entidadeDTO) { |
||
| 175 | this.entidadeDTO = entidadeDTO; |
||
| 176 | } |
||
| 177 | |||
| 178 | public PessoaPapelDTO getPessoaPapelDTO() { |
||
| 179 | return pessoaPapelDTO; |
||
| 180 | } |
||
| 181 | public void setPessoaPapelDTO(PessoaPapelDTO pessoaPapelDTO) { |
||
| 182 | this.pessoaPapelDTO = pessoaPapelDTO; |
||
| 183 | } |
||
| 184 | |||
| 185 | public Endereco getEndereco() { |
||
| 186 | return endereco; |
||
| 187 | } |
||
| 188 | public void setEndereco(Endereco endereco) { |
||
| 189 | this.endereco = endereco; |
||
| 190 | } |
||
| 191 | |||
| 192 | public Usuario getUsuario() { |
||
| 193 | return usuario; |
||
| 194 | } |
||
| 195 | public void setUsuario(Usuario usuario) { |
||
| 196 | this.usuario = usuario; |
||
| 197 | } |
||
| 198 | |||
| 199 | public UsuarioPerfilDTO getUsuarioPerfilDTO() { |
||
| 200 | return usuarioPerfilDTO; |
||
| 201 | } |
||
| 202 | public void setUsuarioPerfilDTO(UsuarioPerfilDTO usuarioPerfilDTO) { |
||
| 203 | this.usuarioPerfilDTO = usuarioPerfilDTO; |
||
| 204 | } |
||
| 205 | |||
| 206 | public UsuarioLojaDTO getUsuarioLojaDTO() { |
||
| 207 | return usuarioLojaDTO; |
||
| 208 | } |
||
| 209 | public void setUsuarioLojaDTO(UsuarioLojaDTO usuarioLojaDTO) { |
||
| 210 | this.usuarioLojaDTO = usuarioLojaDTO; |
||
| 211 | } |
||
| 212 | |||
| 353 | espaco | 213 | public FuncionarioFeriasDTO getFuncionarioFeriasDTO() { |
| 214 | return funcionarioFeriasDTO; |
||
| 215 | } |
||
| 216 | public void setFuncionarioFeriasDTO(FuncionarioFeriasDTO funcionarioFeriasDTO) { |
||
| 217 | this.funcionarioFeriasDTO = funcionarioFeriasDTO; |
||
| 218 | } |
||
| 219 | |||
| 409 | espaco | 220 | public FuncionarioEventoDTO getFuncionarioEventoDTO() { |
| 221 | return funcionarioEventoDTO; |
||
| 222 | } |
||
| 223 | public void setFuncionarioEventoDTO(FuncionarioEventoDTO funcionarioEventoDTO) { |
||
| 224 | this.funcionarioEventoDTO = funcionarioEventoDTO; |
||
| 225 | } |
||
| 226 | |||
| 227 | public FuncionarioEscalaDTO getFuncionarioEscalaDTO() { |
||
| 228 | return funcionarioEscalaDTO; |
||
| 229 | } |
||
| 230 | public void setFuncionarioEscalaDTO(FuncionarioEscalaDTO funcionarioEscalaDTO) { |
||
| 231 | this.funcionarioEscalaDTO = funcionarioEscalaDTO; |
||
| 232 | } |
||
| 233 | |||
| 412 | espaco | 234 | public BancoHorasDTO getBancoHorasDTO() { |
| 235 | return bancoHorasDTO; |
||
| 236 | } |
||
| 237 | public void setBancoHorasDTO(BancoHorasDTO bancoHorasDTO) { |
||
| 238 | this.bancoHorasDTO = bancoHorasDTO; |
||
| 239 | } |
||
| 409 | espaco | 240 | |
| 325 | espaco | 241 | /*************************************************/ |
| 242 | |||
| 243 | public void prepararDetalhar(FuncionarioDTO funcionarioDTO) { |
||
| 244 | super.preDetalhar(funcionarioService.consultarPorId(new Funcionario(funcionarioDTO.getSequencialFuncionario()))); |
||
| 245 | } |
||
| 246 | |||
| 247 | public void prepararAlterar(FuncionarioDTO funcionarioDTO) { |
||
| 248 | super.preAlterar(funcionarioService.consultarPorId(new Funcionario(funcionarioDTO.getSequencialFuncionario()))); |
||
| 249 | } |
||
| 250 | |||
| 251 | public void consultarFuncionarios() { |
||
| 252 | setFuncionarios(funcionarioService.consultarFuncionarios(getEntidadeParaConsulta())); |
||
| 253 | } |
||
| 254 | |||
| 255 | public void prepararAlterarCompleto(FuncionarioDTO funcionarioDTO) { |
||
| 256 | super.preAlterar(funcionarioService.consultarPorId(new Funcionario(funcionarioDTO.getSequencialFuncionario()))); |
||
| 430 | espaco | 257 | UsuarioDTO usuarioDTO = usuarioService.consultarPorPessoa(funcionarioDTO.getSequencialPessoaDoFuncionario()); |
| 258 | setEntidadeDTO(new FuncionarioDTO(getEntidade().getSequencial(), null, null)); |
||
| 325 | espaco | 259 | if (VerificadorUtil.naoEstaNulo(usuarioDTO)) { |
| 260 | getEntidadeDTO().setUsuarioDTO(usuarioDTO); |
||
| 261 | getEntidadeDTO().getUsuarioDTO().setPerfis(usuarioPerfilService.consultarPerfisDoUsuario(usuarioDTO.getSequencial())); |
||
| 262 | getEntidadeDTO().getUsuarioDTO().setLojas(usuarioLojaService.consultarLojasDoUsuario(usuarioDTO.getSequencial())); |
||
| 263 | } |
||
| 264 | getEntidadeDTO().setPapeisDTO(pessoaPapelService.consultarPapeisDaPessoa(getEntidade().getSequencialDaPessoa())); |
||
| 265 | getEntidadeDTO().setEnderecosDTO(enderecoService.consultarEnderecosDaPessoa(getEntidade().getSequencialDaPessoa())); |
||
| 266 | getEntidadeDTO().setVendedorDTO(vendedorService.consultarVendedorPorPessoa(getEntidade().getSequencialDaPessoa())); |
||
| 267 | limparPapel(); |
||
| 268 | } |
||
| 269 | |||
| 270 | public void alterarCompleto() { |
||
| 271 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 272 | public void execute() { |
||
| 273 | pessoaService.alterar(getEntidade().getPessoa()); |
||
| 353 | espaco | 274 | if (VerificadorUtil.naoEstaNulo(getEntidadeDTO().getUsuarioDTO())) { |
| 275 | usuarioService.alterar(getEntidadeDTO().getUsuarioDTO()); |
||
| 276 | } |
||
| 326 | espaco | 277 | vendedorService.alterar(getEntidadeDTO().getVendedorDTO()); |
| 325 | espaco | 278 | alterar(getEntidade()); |
| 279 | } |
||
| 280 | }); |
||
| 281 | } |
||
| 282 | |||
| 283 | public void limparPapel() { |
||
| 284 | PessoaPapelDTO pessoaPapelDTO = new PessoaPapelDTO(); |
||
| 285 | pessoaPapelDTO.setSequencialPessoa(getEntidade().getPessoa().getSequencial()); |
||
| 286 | setPessoaPapelDTO(pessoaPapelDTO); |
||
| 287 | } |
||
| 288 | |||
| 289 | public void adicionarPapel() { |
||
| 290 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 291 | public void execute() { |
||
| 292 | pessoaPapelService.adicionarPapel(getEntidade().getPessoa(), new Papel(getPessoaPapelDTO().getCodigoPapel())); |
||
| 293 | getEntidadeDTO().setPapeisDTO(pessoaPapelService.consultarPapeisDaPessoa(getPessoaPapelDTO().getSequencialPessoa())); |
||
| 294 | LancadorMensagem.lancarSucesso("PAPEL ADICIONADO COM SUCESSO"); |
||
| 295 | } |
||
| 296 | }); |
||
| 297 | } |
||
| 298 | |||
| 299 | public void removerPapel(PessoaPapelDTO pessoaPapelDTO) { |
||
| 300 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 301 | public void execute() { |
||
| 302 | pessoaPapelService.removerPapel(pessoaPapelDTO.getSequencialPessoa(), pessoaPapelDTO.getCodigoPapel()); |
||
| 303 | getEntidadeDTO().setPapeisDTO(pessoaPapelService.consultarPapeisDaPessoa(pessoaPapelDTO.getSequencialPessoa())); |
||
| 304 | LancadorMensagem.lancarSucesso("PAPEL REMOVIDO COM SUCESSO"); |
||
| 305 | } |
||
| 306 | }); |
||
| 307 | } |
||
| 308 | |||
| 309 | public void limparEndereco() { |
||
| 310 | Endereco endereco = new Endereco(); |
||
| 311 | endereco.setPessoa(getEntidade().getPessoa()); |
||
| 312 | endereco.setAtivo(true); |
||
| 313 | setEndereco(endereco); |
||
| 314 | } |
||
| 315 | |||
| 316 | public void prepararAlterarEndereco(EnderecoDTO enderecoDTO) { |
||
| 317 | setEndereco(enderecoService.consultarPorId(new Endereco(enderecoDTO.getSequencial()))); |
||
| 318 | } |
||
| 319 | |||
| 320 | public void adicionarEndereco() { |
||
| 321 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 322 | public void execute() { |
||
| 323 | enderecoService.alterar(getEndereco()); |
||
| 324 | getEntidadeDTO().setEnderecosDTO(enderecoService.consultarEnderecosDaPessoa(getEntidade().getSequencialDaPessoa())); |
||
| 325 | LancadorMensagem.lancarSucesso("ENDEREÇO SALVO COM SUCESSO"); |
||
| 326 | } |
||
| 327 | }); |
||
| 328 | } |
||
| 329 | |||
| 330 | public void removerEndereco(EnderecoDTO enderecoDTO) { |
||
| 331 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 332 | public void execute() { |
||
| 333 | enderecoService.removerEndereco(enderecoDTO.getSequencial()); |
||
| 334 | getEntidadeDTO().setEnderecosDTO(enderecoService.consultarEnderecosDaPessoa(getEntidade().getSequencialDaPessoa())); |
||
| 335 | LancadorMensagem.lancarSucesso("ENDEREÇO REMOVIDO COM SUCESSO"); |
||
| 336 | } |
||
| 337 | }); |
||
| 338 | } |
||
| 339 | |||
| 340 | public void limparUsuarioPerfil() { |
||
| 341 | UsuarioPerfilDTO usuarioPerfilDTO = new UsuarioPerfilDTO(); |
||
| 342 | usuarioPerfilDTO.setSequencialUsuario(getEntidadeDTO().getUsuarioDTO().getSequencial()); |
||
| 343 | setUsuarioPerfilDTO(usuarioPerfilDTO); |
||
| 344 | } |
||
| 345 | |||
| 346 | public void adicionarUsuarioPerfil() { |
||
| 347 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 348 | public void execute() { |
||
| 349 | usuarioPerfilService.adicionarPerfil(getUsuarioPerfilDTO().getSequencialUsuario(), getUsuarioPerfilDTO().getCodigoPerfil()); |
||
| 350 | getEntidadeDTO().getUsuarioDTO().setPerfis(usuarioPerfilService.consultarPerfisDoUsuario(getUsuarioPerfilDTO().getSequencialUsuario())); |
||
| 351 | LancadorMensagem.lancarSucesso("PERFIL ADICIONADO COM SUCESSO"); |
||
| 352 | } |
||
| 353 | }); |
||
| 354 | } |
||
| 355 | |||
| 356 | public void removerUsuarioPerfil(UsuarioPerfilDTO usuarioPerfilDTO) { |
||
| 357 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 358 | public void execute() { |
||
| 359 | usuarioPerfilService.removerPerfil(usuarioPerfilDTO.getSequencial()); |
||
| 360 | getEntidadeDTO().getUsuarioDTO().setPerfis(usuarioPerfilService.consultarPerfisDoUsuario(usuarioPerfilDTO.getSequencialUsuario())); |
||
| 361 | LancadorMensagem.lancarSucesso("PERFIL REMOVIDO COM SUCESSO"); |
||
| 362 | } |
||
| 363 | }); |
||
| 364 | } |
||
| 365 | |||
| 366 | public void limparUsuarioLoja() { |
||
| 367 | UsuarioLojaDTO usuarioLojaDTO = new UsuarioLojaDTO(); |
||
| 368 | usuarioLojaDTO.setSequencialUsuario(getEntidadeDTO().getUsuarioDTO().getSequencial()); |
||
| 369 | setUsuarioLojaDTO(usuarioLojaDTO); |
||
| 370 | } |
||
| 371 | |||
| 372 | public void adicionarUsuarioLoja() { |
||
| 373 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 374 | public void execute() { |
||
| 375 | usuarioLojaService.adicionarLoja(getUsuarioLojaDTO().getSequencialUsuario(), getUsuarioLojaDTO().getSequencialLoja()); |
||
| 376 | getEntidadeDTO().getUsuarioDTO().setLojas(usuarioLojaService.consultarLojasDoUsuario(getUsuarioLojaDTO().getSequencialUsuario())); |
||
| 377 | LancadorMensagem.lancarSucesso("LOJA ADICIONADA COM SUCESSO"); |
||
| 378 | } |
||
| 379 | }); |
||
| 380 | } |
||
| 381 | |||
| 382 | public void removerUsuarioLoja(UsuarioLojaDTO usuarioLojaDTO) { |
||
| 383 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 384 | public void execute() { |
||
| 385 | usuarioLojaService.removerLoja(usuarioLojaDTO.getSequencialUsuario(), usuarioLojaDTO.getSequencialLoja()); |
||
| 386 | getEntidadeDTO().getUsuarioDTO().setLojas(usuarioLojaService.consultarLojasDoUsuario(usuarioLojaDTO.getSequencialUsuario())); |
||
| 387 | LancadorMensagem.lancarSucesso("LOJA REMOVIDA COM SUCESSO"); |
||
| 388 | } |
||
| 389 | }); |
||
| 390 | } |
||
| 391 | |||
| 353 | espaco | 392 | public void consultarFerias() { |
| 393 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 394 | public void execute() { |
||
| 395 | getEntidadeDTO().setFeriasDTO(funcionarioFeriasService.consultarFerias(getEntidadeDTO().getSequencialFuncionario())); |
||
| 396 | } |
||
| 397 | }); |
||
| 398 | } |
||
| 399 | |||
| 400 | public void selecionarFerias(FuncionarioFeriasDTO funcionarioFeriasDTO) { |
||
| 401 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 402 | public void execute() { |
||
| 403 | setFuncionarioFeriasDTO(funcionarioFeriasDTO); |
||
| 404 | } |
||
| 405 | }); |
||
| 406 | } |
||
| 407 | |||
| 408 | public void prepararFerias() { |
||
| 409 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 410 | public void execute() { |
||
| 411 | FuncionarioFeriasDTO funcionarioFeriasDTO = new FuncionarioFeriasDTO(); |
||
| 412 | funcionarioFeriasDTO.setFuncionarioDTO(getEntidadeDTO()); |
||
| 413 | setFuncionarioFeriasDTO(funcionarioFeriasDTO); |
||
| 414 | } |
||
| 415 | }); |
||
| 416 | } |
||
| 417 | |||
| 418 | public void atualizarFerias() { |
||
| 419 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 420 | public void execute() { |
||
| 421 | funcionarioFeriasService.alterarProvisao(getFuncionarioFeriasDTO()); |
||
| 422 | consultarFerias(); |
||
| 423 | LancadorMensagem.lancarSucesso("FÉRIAS ATUALIZADA COM SUCESSO!"); |
||
| 424 | } |
||
| 425 | }); |
||
| 426 | } |
||
| 427 | |||
| 428 | public void removerFerias(FuncionarioFeriasDTO funcionarioFeriasDTO) { |
||
| 429 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 430 | public void execute() { |
||
| 431 | FuncionarioFerias funcionarioFerias = new FuncionarioFerias(); |
||
| 432 | funcionarioFerias.setSequencial(funcionarioFeriasDTO.getSequencialFuncionarioFerias()); |
||
| 433 | funcionarioFeriasService.excluir(funcionarioFerias); |
||
| 434 | consultarFerias(); |
||
| 435 | LancadorMensagem.lancarSucesso("FÉRIAS REMOVIDA COM SUCESSO"); |
||
| 436 | } |
||
| 437 | }); |
||
| 438 | } |
||
| 439 | |||
| 326 | espaco | 440 | public void consultarAvaliacoes() { |
| 441 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 442 | public void execute() { |
||
| 443 | getEntidadeDTO().setAvaliacoesDTO(avaliacaoFuncionarioService.consultarAvaliacoesFuncionario(getEntidadeDTO().getSequencialFuncionario())); |
||
| 444 | } |
||
| 445 | }); |
||
| 325 | espaco | 446 | } |
| 447 | |||
| 412 | espaco | 448 | public void prepararEvento() { |
| 409 | espaco | 449 | FuncionarioEventoDTO funcionarioEventoDTO = new FuncionarioEventoDTO(); |
| 450 | funcionarioEventoDTO.setFuncionarioDTO(getEntidadeDTO()); |
||
| 451 | setFuncionarioEventoDTO(funcionarioEventoDTO); |
||
| 452 | } |
||
| 453 | |||
| 454 | public void adicionarEvento(UsuarioDTO usuarioLogado) { |
||
| 455 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 456 | public void execute() { |
||
| 457 | getFuncionarioEventoDTO().setUsuarioDTOCadastro(usuarioLogado); |
||
| 458 | funcionarioEventoService.cadastrar(getFuncionarioEventoDTO()); |
||
| 459 | consultarEscala(); |
||
| 460 | LancadorMensagem.lancarSucesso("EVENTO ADICIONADO COM SUCESSO"); |
||
| 461 | } |
||
| 462 | }); |
||
| 463 | } |
||
| 464 | |||
| 465 | public void removerEvento(FuncionarioEventoDTO funcionarioEventoDTO) { |
||
| 466 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 467 | public void execute() { |
||
| 411 | espaco | 468 | funcionarioEventoService.excluir(new FuncionarioEvento(funcionarioEventoDTO)); |
| 409 | espaco | 469 | getFuncionarioEscalaDTO().getEventosDTO().remove(funcionarioEventoDTO); |
| 470 | consultarEscala(); |
||
| 471 | LancadorMensagem.lancarSucesso("EVENTO REMOVIDO COM SUCESSO"); |
||
| 472 | } |
||
| 473 | }); |
||
| 474 | } |
||
| 475 | |||
| 412 | espaco | 476 | public void prepararParaAlterarEvento(FuncionarioEventoDTO funcionarioEventoDTO) { |
| 477 | setFuncionarioEventoDTO(funcionarioEventoDTO); |
||
| 478 | } |
||
| 479 | |||
| 409 | espaco | 480 | public void confirmarEvento(UsuarioDTO usuarioLogado, FuncionarioEventoDTO funcionarioEventoDTO) { |
| 481 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 482 | public void execute() { |
||
| 483 | funcionarioEventoDTO.setUsuarioDTOAuditor(usuarioLogado); |
||
| 412 | espaco | 484 | funcionarioEventoService.alterar(new FuncionarioEvento(funcionarioEventoDTO)); |
| 485 | consultarEscala(); |
||
| 409 | espaco | 486 | LancadorMensagem.lancarSucesso("EVENTO CONFIRMADO COM SUCESSO"); |
| 487 | } |
||
| 488 | }); |
||
| 489 | } |
||
| 490 | |||
| 412 | espaco | 491 | public void alterarEvento() { |
| 492 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 493 | public void execute() { |
||
| 494 | FuncionarioEvento funcionarioEvento = funcionarioEventoService.consultarPorId(new FuncionarioEvento(getFuncionarioEventoDTO())); |
||
| 495 | funcionarioEvento.atualizarDados(getFuncionarioEventoDTO()); |
||
| 496 | funcionarioEventoService.alterar(funcionarioEvento); |
||
| 497 | consultarEscala(); |
||
| 498 | LancadorMensagem.lancarSucesso("EVENTO ALTERADO COM SUCESSO"); |
||
| 499 | } |
||
| 500 | }); |
||
| 501 | } |
||
| 502 | |||
| 409 | espaco | 503 | public void consultarEventos(FuncionarioEscalaDTO escalaDTOSelecionada) { |
| 504 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 505 | public void execute() { |
||
| 506 | setFuncionarioEscalaDTO(escalaDTOSelecionada); |
||
| 507 | } |
||
| 508 | }); |
||
| 509 | } |
||
| 510 | |||
| 412 | espaco | 511 | public void adicionarBancoHoras() { |
| 512 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 513 | public void execute() { |
||
| 514 | bancoHorasService.cadastrar(getBancoHorasDTO()); |
||
| 515 | consultarBancoHoras(); |
||
| 516 | LancadorMensagem.lancarSucesso("BANCO DE HORAS ADICIONADO COM SUCESSO"); |
||
| 517 | } |
||
| 518 | }); |
||
| 519 | } |
||
| 520 | |||
| 521 | public void removerBancoHoras(BancoHorasDTO bancoHorasDTO) { |
||
| 522 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 523 | public void execute() { |
||
| 524 | bancoHorasService.excluir(new BancoHoras(bancoHorasDTO)); |
||
| 525 | getEntidadeDTO().getListaBancoHorasDTO().remove(bancoHorasDTO); |
||
| 526 | consultarBancoHoras(); |
||
| 527 | LancadorMensagem.lancarSucesso("BANCO DE HORAS REMOVIDO COM SUCESSO"); |
||
| 528 | } |
||
| 529 | }); |
||
| 530 | } |
||
| 531 | |||
| 532 | public void prepararBancoHoras() { |
||
| 533 | BancoHorasDTO bancoHorasDTO = new BancoHorasDTO(); |
||
| 534 | bancoHorasDTO.setFuncionarioDTO(getEntidadeDTO()); |
||
| 535 | setBancoHorasDTO(bancoHorasDTO); |
||
| 536 | } |
||
| 537 | |||
| 538 | public void prepararParaAlterarBancoHoras(BancoHorasDTO bancoHorasDTO) { |
||
| 539 | setBancoHorasDTO(bancoHorasDTO); |
||
| 540 | } |
||
| 541 | |||
| 542 | public void alterarBancoHoras() { |
||
| 543 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 544 | public void execute() { |
||
| 545 | BancoHoras bancoHoras = bancoHorasService.consultarPorId(new BancoHoras(getBancoHorasDTO())); |
||
| 546 | bancoHoras.atualizarDados(getBancoHorasDTO()); |
||
| 547 | bancoHorasService.alterar(bancoHoras); |
||
| 548 | consultarBancoHoras(); |
||
| 549 | LancadorMensagem.lancarSucesso("BANCO DE HORAS ALTERADO COM SUCESSO"); |
||
| 550 | } |
||
| 551 | }); |
||
| 552 | } |
||
| 553 | |||
| 554 | public void consultarBancoHoras() { |
||
| 555 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 556 | public void execute() { |
||
| 557 | getEntidadeDTO().setListaBancoHorasDTO(bancoHorasService.consultarBancoHorasFuncionario(getEntidadeDTO().getSequencialFuncionario())); |
||
| 558 | } |
||
| 559 | }); |
||
| 560 | } |
||
| 561 | |||
| 562 | public void consultarBancoHorasDoUsuario(UsuarioDTO usuarioDTO) { |
||
| 563 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 564 | public void execute() { |
||
| 565 | Usuario usuario = usuarioService.consultarPorId(new Usuario(usuarioDTO.getSequencial())); |
||
| 566 | Funcionario funcionario = funcionarioService.consultarFuncionarioPelaPessoa(usuario.getSequencialDaPessoa()); |
||
| 567 | FuncionarioDTO funcionarioDTO = new FuncionarioDTO(); |
||
| 568 | funcionarioDTO.setListaBancoHorasDTO(bancoHorasService.consultarBancoHorasFuncionario(funcionario.getSequencial())); |
||
| 569 | funcionarioDTO.setListaBancoHorasDTOAnoVigente(bancoHorasService.consultarBancoHorasFuncionarioAnoVigente(funcionario.getSequencial())); |
||
| 570 | setEntidadeDTO(funcionarioDTO); |
||
| 571 | } |
||
| 572 | }); |
||
| 573 | } |
||
| 574 | |||
| 353 | espaco | 575 | // TODO: IMPLEMENTAÇÃO PENDENTE |
| 576 | public void consultarExames() { |
||
| 577 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 578 | public void execute() { |
||
| 579 | List<ExameFuncionarioDTO> examesDTO = new ArrayList<ExameFuncionarioDTO>(); |
||
| 580 | ExameFuncionarioDTO exameDTO = new ExameFuncionarioDTO(); |
||
| 581 | exameDTO.setDataPrevista(DataUtils.converterStringParaData("01/05/2021")); |
||
| 582 | exameDTO.setTipoExame("P"); |
||
| 583 | examesDTO.add(exameDTO); |
||
| 584 | |||
| 585 | exameDTO = new ExameFuncionarioDTO(); |
||
| 586 | exameDTO.setDataPrevista(DataUtils.converterStringParaData("01/05/2020")); |
||
| 587 | exameDTO.setDataRealizada(DataUtils.converterStringParaData("01/05/2020")); |
||
| 588 | exameDTO.setTipoExame("P"); |
||
| 589 | examesDTO.add(exameDTO); |
||
| 590 | |||
| 591 | exameDTO = new ExameFuncionarioDTO(); |
||
| 592 | exameDTO.setDataRealizada(DataUtils.converterStringParaData("01/05/2019")); |
||
| 593 | exameDTO.setTipoExame("A"); |
||
| 594 | examesDTO.add(exameDTO); |
||
| 595 | |||
| 596 | getEntidadeDTO().setExamesDTO(examesDTO); |
||
| 597 | } |
||
| 598 | }); |
||
| 599 | } |
||
| 600 | |||
| 601 | // TODO: IMPLEMENTAÇÃO PENDENTE |
||
| 602 | public void consultarAtestados() { |
||
| 603 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 604 | public void execute() { |
||
| 605 | List<AtestadoFuncionarioDTO> atestadosDTO = new ArrayList<AtestadoFuncionarioDTO>(); |
||
| 606 | AtestadoFuncionarioDTO atestadoDTO = new AtestadoFuncionarioDTO(); |
||
| 607 | atestadoDTO.setDataAtestado(DataUtils.converterStringParaData("01/11/2020")); |
||
| 608 | atestadoDTO.setQuantidadeDias(new Long(15)); |
||
| 609 | atestadoDTO.setCodigoCid("Y71"); |
||
| 610 | atestadoDTO.setObservacao("COVID"); |
||
| 611 | atestadosDTO.add(atestadoDTO); |
||
| 612 | |||
| 613 | atestadoDTO = new AtestadoFuncionarioDTO(); |
||
| 614 | atestadoDTO.setDataAtestado(DataUtils.converterStringParaData("01/09/2020")); |
||
| 615 | atestadoDTO.setQuantidadeDias(new Long(3)); |
||
| 616 | atestadoDTO.setCodigoCid("Y59"); |
||
| 617 | atestadoDTO.setObservacao(""); |
||
| 618 | atestadosDTO.add(atestadoDTO); |
||
| 619 | |||
| 620 | getEntidadeDTO().setAtestadosDTO(atestadosDTO); |
||
| 621 | } |
||
| 622 | }); |
||
| 623 | } |
||
| 624 | |||
| 625 | // TODO: IMPLEMENTAÇÃO PENDENTE |
||
| 626 | public void consultarPontoEletronico() { |
||
| 627 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 628 | public void execute() { |
||
| 629 | List<PontoDTO> pontosDTO = new ArrayList<PontoDTO>(); |
||
| 630 | PontoDTO pontoDTO = new PontoDTO(); |
||
| 631 | LojaDTO lojaDTO = new LojaDTO(); |
||
| 632 | lojaDTO.setDescricao("QUIOSQUE BIG GRUTA"); |
||
| 633 | pontoDTO.setLojaDTO(lojaDTO); |
||
| 634 | |||
| 635 | PessoaDTO pessoaDTO = new PessoaDTO(); |
||
| 430 | espaco | 636 | pessoaDTO.setNome(getEntidadeDTO().getNomeDaPessoa()); |
| 353 | espaco | 637 | pontoDTO.setPessoaDTO(pessoaDTO); |
| 638 | |||
| 639 | pontoDTO.setDataPonto(DataUtils.converterStringParaData("13/08/2021")); |
||
| 640 | pontoDTO.setDataHoraPontoInicio(DataUtils.converterStringParaDataComHorario("13/08/2021 16:00:00")); |
||
| 641 | pontoDTO.setDataHoraPontoFim(DataUtils.converterStringParaDataComHorario("13/08/2021 16:00:00")); |
||
| 642 | pontoDTO.setDataHoraIntervaloInicio(DataUtils.converterStringParaDataComHorario("13/08/2021 16:00:00")); |
||
| 643 | pontoDTO.setDataHoraIntervaloFim(DataUtils.converterStringParaDataComHorario("13/08/2021 16:00:00")); |
||
| 644 | pontoDTO.setObservacao(""); |
||
| 645 | pontosDTO.add(pontoDTO); |
||
| 646 | |||
| 647 | getEntidadeDTO().setPontosDTO(pontosDTO); |
||
| 648 | } |
||
| 649 | }); |
||
| 650 | } |
||
| 651 | |||
| 355 | espaco | 652 | /* |
| 653 | public String retornarTipoOcorrenciaEscala(Date dataPonto, List<Ponto> pontos) { |
||
| 654 | String tipoOcorrenciaEscala = TipoOcorrenciaEscala.SEM_PONTO.getValor(); |
||
| 655 | for (Ponto ponto : pontos) { |
||
| 656 | if (DataUtils.datasIguais(ponto.getDataPonto(), dataPonto)) { |
||
| 657 | if (ponto.getPontoCompleto()) { |
||
| 658 | return TipoOcorrenciaEscala.PONTO_COMPLETO.getValor(); |
||
| 659 | } else { |
||
| 660 | return TipoOcorrenciaEscala.PONTO_INCOMPLETO.getValor(); |
||
| 661 | } |
||
| 662 | } |
||
| 663 | } |
||
| 664 | return tipoOcorrenciaEscala; |
||
| 665 | } |
||
| 666 | */ |
||
| 667 | |||
| 353 | espaco | 668 | // TODO: IMPLEMENTAÇÃO PENDENTE |
| 669 | public void consultarEscala() { |
||
| 670 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 671 | public void execute() { |
||
| 355 | espaco | 672 | VigenciaDTO vigenciaSelecionada = getEntidadeDTO().getVigenciaEscalaDTO(); |
| 673 | Date dataPonto = vigenciaSelecionada.getDataInicio(); |
||
| 674 | Date dataInicio = vigenciaSelecionada.getDataInicio(); |
||
| 675 | Date dataFim = vigenciaSelecionada.getDataFim(); |
||
| 676 | List<FuncionarioEscalaDTO> escalasDTO = new ArrayList<FuncionarioEscalaDTO>(); |
||
| 677 | FuncionarioEscalaDTO escalaDTO = null; |
||
| 412 | espaco | 678 | List<Ponto> pontos = pontoService.consultarPontosEletronicos(getEntidadeDTO().getVigenciaEscalaDTO(), getEntidade().getSequencialDaPessoa()); |
| 679 | List<FuncionarioEventoDTO> eventos = funcionarioEventoService.consultarEventos(getEntidadeDTO().getVigenciaEscalaDTO(), getEntidade().getSequencial()); |
||
| 355 | espaco | 680 | while (DataUtils.dataEstaEntrePeriodos(dataPonto, dataInicio, dataFim) || |
| 681 | DataUtils.datasIguais(dataPonto, dataInicio) || |
||
| 682 | DataUtils.datasIguais(dataPonto, dataFim)) { |
||
| 683 | escalaDTO = new FuncionarioEscalaDTO(); |
||
| 684 | escalaDTO.atualizarDadosEscala(dataPonto, pontos); |
||
| 409 | espaco | 685 | escalaDTO.atualizarDadosEventos(dataPonto, eventos); |
| 355 | espaco | 686 | escalasDTO.add(escalaDTO); |
| 687 | dataPonto = DataUtils.acrescentarDias(dataPonto, 1); |
||
| 353 | espaco | 688 | } |
| 355 | espaco | 689 | getEntidadeDTO().setListaFuncionarioEscalaDTO(escalasDTO); |
| 353 | espaco | 690 | } |
| 691 | }); |
||
| 692 | } |
||
| 693 | |||
| 325 | espaco | 694 | } |