Rev 646 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 646 | Rev 732 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | package br.com.ec.controller; |
1 | package br.com.ec.controller; |
| 2 | 2 | ||
| - | 3 | import java.io.IOException; |
|
| 3 | import java.io.Serializable; |
4 | import java.io.Serializable; |
| 4 | import java.util.ArrayList; |
5 | import java.util.ArrayList; |
| 5 | import java.util.Date; |
6 | import java.util.Date; |
| 6 | import java.util.List; |
7 | import java.util.List; |
| 7 | 8 | ||
| - | 9 | import javax.annotation.PostConstruct; |
|
| 8 | import javax.inject.Inject; |
10 | import javax.inject.Inject; |
| 9 | import javax.inject.Named; |
11 | import javax.inject.Named; |
| 10 | 12 | ||
| 11 | import org.primefaces.event.FileUploadEvent; |
- | |
| 12 | import org.primefaces.model.StreamedContent; |
- | |
| 13 | import org.primefaces.model.file.UploadedFile; |
13 | import org.primefaces.model.file.UploadedFile; |
| 14 | import org.springframework.context.annotation.Scope; |
14 | import org.springframework.context.annotation.Scope; |
| 15 | 15 | ||
| 16 | import br.com.ec.controller.consultademanda.AvaliacaoConsultaPorDemanda; |
16 | import br.com.ec.controller.consultademanda.AvaliacaoConsultaPorDemanda; |
| 17 | import br.com.ec.core.consulta.ParametrosConsulta; |
17 | import br.com.ec.core.consulta.ParametrosConsulta; |
| 18 | import br.com.ec.core.generic.GenericService; |
18 | import br.com.ec.core.generic.GenericService; |
| 19 | import br.com.ec.core.util.VerificadorUtil; |
19 | import br.com.ec.core.util.VerificadorUtil; |
| 20 | import br.com.ec.domain.dto.AvaliacaoDTO; |
20 | import br.com.ec.domain.dto.AvaliacaoDTO; |
| 21 | import br.com.ec.domain.dto.ValeTransporteDTO; |
- | |
| - | 21 | import br.com.ec.domain.dto.ParcelaDTO; |
|
| 22 | import br.com.ec.domain.dto.ValeTransporteDTO; |
22 | import br.com.ec.domain.dto.ValeTransporteDTO; |
| 23 | import br.com.ec.domain.dto.ValeTransporteFuncionarioDTO; |
23 | import br.com.ec.domain.dto.ValeTransporteFuncionarioDTO; |
| 24 | import br.com.ec.domain.dto.ValeTransporteFuncionarioExtraidoDTO; |
24 | import br.com.ec.domain.dto.ValeTransporteFuncionarioExtraidoDTO; |
| - | 25 | import br.com.ec.domain.dto.VigenciaDTO; |
|
| 25 | import br.com.ec.domain.model.Avaliacao; |
26 | import br.com.ec.domain.model.Avaliacao; |
| - | 27 | import br.com.ec.domain.model.tipos.TipoSituacoesVigencia; |
|
| - | 28 | import br.com.ec.domain.service.AvaliacaoService; |
|
| 26 | import br.com.ec.domain.service.ParcelaService; |
29 | import br.com.ec.domain.service.ParcelaService; |
| 27 | import br.com.ec.domain.service.ValeTransporteService; |
30 | import br.com.ec.domain.service.ValeTransporteService; |
| - | 31 | import br.com.ec.domain.service.VigenciaService; |
|
| 28 | import br.com.ec.web.exception.VerificadorLancamentoException; |
32 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 29 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
33 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
| 30 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandRelatorioStreamedContent; |
- | |
| 31 | import br.com.ec.web.generic.AbstractBean; |
34 | import br.com.ec.web.generic.AbstractBean; |
| 32 | import br.com.ec.web.message.LancadorMensagem; |
35 | import br.com.ec.web.message.LancadorMensagem; |
| 33 | import br.com.ec.web.util.TipoOperacao; |
36 | import br.com.ec.web.util.TipoOperacao; |
| 34 | 37 | ||
| 35 | @Named |
38 | @Named |
| Line 37... | Line 40... | ||
| 37 | public class ValeTransporteBean extends AbstractBean<Avaliacao> implements Serializable { |
40 | public class ValeTransporteBean extends AbstractBean<Avaliacao> implements Serializable { |
| 38 | 41 | ||
| 39 | private static final long serialVersionUID = 1L; |
42 | private static final long serialVersionUID = 1L; |
| 40 | 43 | ||
| 41 | private ValeTransporteDTO valeTransporteDTO; |
44 | private ValeTransporteDTO valeTransporteDTO; |
| - | 45 | private VigenciaDTO vigenciaSelecionada; |
|
| - | 46 | ||
| - | 47 | private ValeTransporteService valeTransporteService; |
|
| - | 48 | ||
| - | 49 | private VigenciaService vigenciaService; |
|
| - | 50 | private AvaliacaoService avaliacaoService; |
|
| 42 | 51 | ||
| 43 | private UploadedFile arquivoParaImportacao; |
52 | private UploadedFile arquivoParaImportacao; |
| 44 | private Date dataPagamento = new Date(); |
53 | private Date dataPagamento = new Date(); |
| 45 | 54 | ||
| 46 | private ValeTransporteService valeTransporteService; |
- | |
| 47 | private ParcelaService parcelaService; |
55 | private ParcelaService parcelaService; |
| 48 | 56 | ||
| 49 | private AvaliacaoConsultaPorDemanda lazy; |
57 | private AvaliacaoConsultaPorDemanda lazy; |
| 50 | private ParametrosConsulta<Avaliacao> parametrosConsultaAvaliacao; |
58 | private ParametrosConsulta<Avaliacao> parametrosConsultaAvaliacao; |
| 51 | 59 | ||
| 52 | @Inject |
60 | @Inject |
| 53 | public ValeTransporteBean(AvaliacaoConsultaPorDemanda lazy, ValeTransporteService valeTransporteService, ParcelaService parcelaService) { |
- | |
| - | 61 | public ValeTransporteBean(AvaliacaoConsultaPorDemanda lazy, ValeTransporteService valeTransporteService, |
|
| - | 62 | VigenciaService vigenciaService, AvaliacaoService avaliacaoService, ParcelaService parcelaService) { |
|
| 54 | this.lazy = lazy; |
63 | this.lazy = lazy; |
| 55 | this.valeTransporteService = valeTransporteService; |
64 | this.valeTransporteService = valeTransporteService; |
| - | 65 | this.vigenciaService= vigenciaService; |
|
| - | 66 | this.avaliacaoService = avaliacaoService; |
|
| 56 | this.parcelaService = parcelaService; |
67 | this.parcelaService = parcelaService; |
| 57 | }
|
68 | }
|
| 58 | 69 | ||
| 59 | @Override |
70 | @Override |
| 60 | public void preCarregamento() { |
71 | public void preCarregamento() { |
| 61 | parametrosConsultaAvaliacao = new ParametrosConsulta<Avaliacao>(); |
72 | parametrosConsultaAvaliacao = new ParametrosConsulta<Avaliacao>(); |
| 62 | parametrosConsultaAvaliacao.setEntidade(new Avaliacao()); |
73 | parametrosConsultaAvaliacao.setEntidade(new Avaliacao()); |
| 63 | prepararConsultaDemanda(); |
74 | prepararConsultaDemanda(); |
| 64 | limparEntidade(); |
75 | limparEntidade(); |
| - | 76 | }
|
|
| - | 77 | ||
| - | 78 | @PostConstruct |
|
| - | 79 | private void posCarregamento() { |
|
| - | 80 | if (VerificadorUtil.naoEstaNulo(getParametro("vigencia"))) { |
|
| - | 81 | setVigenciaSelecionada(vigenciaService.consultarVigencia(new Long(getParametro("vigencia").toString()))); |
|
| - | 82 | if (VerificadorUtil.naoEstaNulo(getVigenciaSelecionada())) { |
|
| - | 83 | detalharValeTransporte(); |
|
| - | 84 | }
|
|
| - | 85 | }
|
|
| - | 86 | }
|
|
| - | 87 | ||
| - | 88 | private void detalharValeTransporte() { |
|
| - | 89 | AvaliacaoDTO avaliacaoDTO = avaliacaoService.consultarAvaliacao(getVigenciaSelecionada().getSequencial()); |
|
| - | 90 | if (VerificadorUtil.naoEstaNulo(avaliacaoDTO)) { |
|
| - | 91 | setValeTransporteDTO(valeTransporteService.detalharValeTransporte(avaliacaoDTO)); |
|
| - | 92 | }
|
|
| 65 | }
|
93 | }
|
| 66 | 94 | ||
| 67 | @Override |
95 | @Override |
| 68 | public void limparEntidade() { |
96 | public void limparEntidade() { |
| 69 | setEntidade(new Avaliacao()); |
97 | setEntidade(new Avaliacao()); |
| Line 115... | Line 143... | ||
| 115 | public ValeTransporteDTO getValeTransporteDTO() { |
143 | public ValeTransporteDTO getValeTransporteDTO() { |
| 116 | return valeTransporteDTO; |
144 | return valeTransporteDTO; |
| 117 | }
|
145 | }
|
| 118 | public void setValeTransporteDTO(ValeTransporteDTO valeTransporteDTO) { |
146 | public void setValeTransporteDTO(ValeTransporteDTO valeTransporteDTO) { |
| 119 | this.valeTransporteDTO = valeTransporteDTO; |
147 | this.valeTransporteDTO = valeTransporteDTO; |
| - | 148 | }
|
|
| - | 149 | ||
| - | 150 | public VigenciaDTO getVigenciaSelecionada() { |
|
| - | 151 | return vigenciaSelecionada; |
|
| - | 152 | }
|
|
| - | 153 | public void setVigenciaSelecionada(VigenciaDTO vigenciaSelecionada) { |
|
| - | 154 | this.vigenciaSelecionada = vigenciaSelecionada; |
|
| 120 | }
|
155 | }
|
| 121 | 156 | ||
| 122 | public UploadedFile getArquivoParaImportacao() { |
157 | public UploadedFile getArquivoParaImportacao() { |
| 123 | return arquivoParaImportacao; |
158 | return arquivoParaImportacao; |
| 124 | }
|
159 | }
|
| Line 132... | Line 167... | ||
| 132 | public void setDataPagamento(Date dataPagamento) { |
167 | public void setDataPagamento(Date dataPagamento) { |
| 133 | this.dataPagamento = dataPagamento; |
168 | this.dataPagamento = dataPagamento; |
| 134 | }
|
169 | }
|
| 135 | 170 | ||
| 136 | public List<ValeTransporteFuncionarioExtraidoDTO> funcionariosExtraidosForaDaAvaliacao() { |
171 | public List<ValeTransporteFuncionarioExtraidoDTO> funcionariosExtraidosForaDaAvaliacao() { |
| - | 172 | Double valorTotalForaDaAvaliacao = new Double(0.0); |
|
| 137 | List<ValeTransporteFuncionarioExtraidoDTO> extraidosForaDaAvaliacao = new ArrayList<ValeTransporteFuncionarioExtraidoDTO>(); |
173 | List<ValeTransporteFuncionarioExtraidoDTO> extraidosForaDaAvaliacao = new ArrayList<ValeTransporteFuncionarioExtraidoDTO>(); |
| 138 | if (VerificadorUtil.naoEstaNuloOuVazio(getValeTransporteDTO().getFuncionariosExtraidos())) { |
174 | if (VerificadorUtil.naoEstaNuloOuVazio(getValeTransporteDTO().getFuncionariosExtraidos())) { |
| 139 | for (ValeTransporteFuncionarioExtraidoDTO extraido : getValeTransporteDTO().getFuncionariosExtraidos()) { |
175 | for (ValeTransporteFuncionarioExtraidoDTO extraido : getValeTransporteDTO().getFuncionariosExtraidos()) { |
| 140 | if (!extraido.getAdicionado()) { |
176 | if (!extraido.getAdicionado()) { |
| - | 177 | valorTotalForaDaAvaliacao += extraido.getValorVencimentos(); |
|
| 141 | extraidosForaDaAvaliacao.add(extraido); |
178 | extraidosForaDaAvaliacao.add(extraido); |
| 142 | }
|
179 | }
|
| 143 | }
|
180 | }
|
| 144 | }
|
181 | }
|
| 145 | return extraidosForaDaAvaliacao; |
182 | return extraidosForaDaAvaliacao; |
| - | 183 | }
|
|
| - | 184 | ||
| - | 185 | public Double valorTotalImportadoSemAusentes() { |
|
| - | 186 | Double valorTotalForaDaAvaliacao = new Double(0.0); |
|
| - | 187 | List<ValeTransporteFuncionarioExtraidoDTO> extraidosForaDaAvaliacao = new ArrayList<ValeTransporteFuncionarioExtraidoDTO>(); |
|
| - | 188 | if (VerificadorUtil.naoEstaNuloOuVazio(getValeTransporteDTO().getFuncionariosExtraidos())) { |
|
| - | 189 | for (ValeTransporteFuncionarioExtraidoDTO extraido : getValeTransporteDTO().getFuncionariosExtraidos()) { |
|
| - | 190 | if (!extraido.getAdicionado()) { |
|
| - | 191 | valorTotalForaDaAvaliacao += extraido.getValorVencimentos(); |
|
| - | 192 | extraidosForaDaAvaliacao.add(extraido); |
|
| - | 193 | }
|
|
| - | 194 | }
|
|
| - | 195 | return getValeTransporteDTO().getValorTotalImportado() - valorTotalForaDaAvaliacao; |
|
| - | 196 | }
|
|
| - | 197 | return valorTotalForaDaAvaliacao; |
|
| 146 | }
|
198 | }
|
| 147 | 199 | ||
| 148 | /**************************************************/
|
200 | /**************************************************/
|
| 149 | 201 | ||
| 150 | public void uploadArquivoEspacoCase() { |
- | |
| - | 202 | public void redirecionarGestaoMensal() { |
|
| 151 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
203 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 152 | public void execute() { |
204 | public void execute() { |
| 153 | setValeTransporteDTO(valeTransporteService.importarValeTransporte(getArquivoParaImportacao().getContent(), getValeTransporteDTO())); |
- | |
| 154 | LancadorMensagem.lancarSucesso("ARQUIVO IMPORTADO COM SUCESSO!"); |
- | |
| - | 205 | try { |
|
| - | 206 | LancadorMensagem.redirecionarTela("/sistema/gestao_mensal/gestao_mensal.xhtml"); |
|
| - | 207 | } catch (IOException e) { |
|
| - | 208 | e.printStackTrace(); |
|
| - | 209 | }
|
|
| 155 | }
|
210 | }
|
| 156 | }); |
211 | }); |
| 157 | }
|
212 | }
|
| 158 | 213 | ||
| 159 | public void uploadArquivoEspacoCase(final FileUploadEvent e) { |
- | |
| 160 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
- | |
| - | 214 | public void uploadArquivoFlash() { |
|
| - | 215 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| 161 | public void execute() { |
216 | public void execute() { |
| 162 | setValeTransporteDTO(valeTransporteService.importarValeTransporte(e.getFile().getContent(), getValeTransporteDTO())); |
- | |
| - | 217 | setValeTransporteDTO(valeTransporteService.importarValeTransporte(getArquivoParaImportacao().getContent(), getValeTransporteDTO())); |
|
| - | 218 | LancadorMensagem.lancarSucesso("ARQUIVO FLASH IMPORTADO COM SUCESSO!"); |
|
| 163 | }
|
219 | }
|
| 164 | }); |
220 | }); |
| 165 | }
|
- | |
| - | 221 | }
|
|
| 166 | 222 | ||
| 167 | public void atualizarValoresImportados() { |
223 | public void atualizarValoresImportados() { |
| 168 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
224 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 169 | public void execute() { |
225 | public void execute() { |
| 170 | for (ValeTransporteFuncionarioDTO valeTransporteFuncionario : getValeTransporteDTO().getFuncionarios()) { |
226 | for (ValeTransporteFuncionarioDTO valeTransporteFuncionario : getValeTransporteDTO().getFuncionarios()) { |
| Line 177... | Line 233... | ||
| 177 | LancadorMensagem.lancarSucesso("VALORES ATUALIZADOS COM SUCESSO"); |
233 | LancadorMensagem.lancarSucesso("VALORES ATUALIZADOS COM SUCESSO"); |
| 178 | }
|
234 | }
|
| 179 | }); |
235 | }); |
| 180 | }
|
236 | }
|
| 181 | 237 | ||
| 182 | public void efetuarPagamentos() { |
- | |
| - | 238 | public void atualizarCentrosDeCustos() { |
|
| 183 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
239 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 184 | public void execute() { |
240 | public void execute() { |
| 185 | for (ValeTransporteFuncionarioDTO valeTransporteFuncionario : getValeTransporteDTO().getFuncionarios()) { |
241 | for (ValeTransporteFuncionarioDTO valeTransporteFuncionario : getValeTransporteDTO().getFuncionarios()) { |
| 186 | if (!VerificadorUtil.isListaNulaOuVazia(valeTransporteFuncionario.getParcelas())) { |
242 | if (!VerificadorUtil.isListaNulaOuVazia(valeTransporteFuncionario.getParcelas())) { |
| 187 | if (valeTransporteFuncionario.getEfetuarPagamento()) { |
- | |
| 188 | parcelaService.efetuarPagamentoRecebimento(valeTransporteFuncionario.getParcelas().get(0), getDataPagamento()); |
- | |
| - | 243 | if (VerificadorUtil.naoEstaNulo(valeTransporteFuncionario.getParcelas().get(0))) { |
|
| - | 244 | ParcelaDTO parcela = valeTransporteFuncionario.getParcelas().get(0); |
|
| - | 245 | Long sequencialConta = parcela.getContaDTO().getSequencial(); |
|
| - | 246 | valeTransporteService.atualizarCentroDeCustos(sequencialConta, valeTransporteFuncionario.getAvaliacaoFuncionarioDTO().getSequencialDaLoja()); |
|
| 189 | }
|
247 | }
|
| 190 | }
|
248 | }
|
| 191 | }
|
249 | }
|
| - | 250 | detalharValeTransporte(); |
|
| - | 251 | setArquivoParaImportacao(null); |
|
| - | 252 | LancadorMensagem.lancarSucesso("CENTROS DE CUSTOS ATUALIZADOS COM SUCESSO"); |
|
| - | 253 | }
|
|
| - | 254 | }); |
|
| - | 255 | }
|
|
| - | 256 | ||
| - | 257 | public void efetuarPagamentos() { |
|
| - | 258 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 259 | public void execute() { |
|
| - | 260 | for (ValeTransporteFuncionarioDTO valeTransporteFuncionario : getValeTransporteDTO().getFuncionarios()) { |
|
| - | 261 | if (!VerificadorUtil.isListaNulaOuVazia(valeTransporteFuncionario.getParcelas())) { |
|
| - | 262 | parcelaService.efetuarPagamentoRecebimento(valeTransporteFuncionario.getParcelas().get(0), getDataPagamento()); |
|
| - | 263 | vigenciaService.alterarSituacaoFolha(getVigenciaSelecionada().getSequencial(), TipoSituacoesVigencia.EM_ANDAMENTO_A.getValor()); |
|
| - | 264 | }
|
|
| - | 265 | }
|
|
| - | 266 | detalharValeTransporte(); |
|
| 192 | setArquivoParaImportacao(null); |
267 | setArquivoParaImportacao(null); |
| 193 | setValeTransporteDTO(valeTransporteService.detalharValeTransporte(new AvaliacaoDTO(getEntidade().getSequencial(), getEntidade().getSequencialDaVigencia(), getEntidade().getDescricaoDaVigencia()))); |
- | |
| 194 | LancadorMensagem.lancarSucesso("PAGAMENTOS EFETUADOS COM SUCESSO"); |
268 | LancadorMensagem.lancarSucesso("PAGAMENTOS EFETUADOS COM SUCESSO"); |
| - | 269 | }
|
|
| - | 270 | }); |
|
| - | 271 | }
|
|
| - | 272 | ||
| - | 273 | public void finalizarValeTransporte() { |
|
| - | 274 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 275 | public void execute() { |
|
| - | 276 | vigenciaService.alterarSituacaoValeTransporte(getVigenciaSelecionada().getSequencial(), TipoSituacoesVigencia.FINALIZADO_F.getValor()); |
|
| - | 277 | setArquivoParaImportacao(null); |
|
| - | 278 | redirecionarGestaoMensal(); |
|
| - | 279 | LancadorMensagem.lancarSucesso("VALE TRANSPORTE FINALIZADA COM SUCESSO"); |
|
| 195 | }
|
280 | }
|
| 196 | }); |
281 | }); |
| 197 | }
|
282 | }
|
| 198 | 283 | ||
| 199 | }
|
284 | }
|