Rev 434 | Rev 553 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 434 | Rev 439 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | package br.com.ec.controller; |
1 | package br.com.ec.controller; |
| 2 | 2 | ||
| 3 | import java.io.Serializable; |
3 | import java.io.Serializable; |
| 4 | import java.util.Date; |
4 | import java.util.Date; |
| 5 | 5 | ||
| - | 6 | import javax.faces.context.FacesContext; |
|
| 6 | import javax.inject.Inject; |
7 | import javax.inject.Inject; |
| 7 | import javax.inject.Named; |
8 | import javax.inject.Named; |
| - | 9 | import javax.servlet.ServletContext; |
|
| 8 | 10 | ||
| 9 | import org.primefaces.event.FileUploadEvent; |
11 | import org.primefaces.event.FileUploadEvent; |
| 10 | import org.primefaces.model.StreamedContent; |
12 | import org.primefaces.model.StreamedContent; |
| 11 | import org.primefaces.model.file.UploadedFile; |
13 | import org.primefaces.model.file.UploadedFile; |
| 12 | import org.springframework.context.annotation.Scope; |
14 | import org.springframework.context.annotation.Scope; |
| Line 18... | Line 20... | ||
| 18 | import br.com.ec.domain.dto.AvaliacaoDTO; |
20 | import br.com.ec.domain.dto.AvaliacaoDTO; |
| 19 | import br.com.ec.domain.dto.FolhaPagamentoDTO; |
21 | import br.com.ec.domain.dto.FolhaPagamentoDTO; |
| 20 | import br.com.ec.domain.dto.FolhaPagamentoFuncionarioDTO; |
22 | import br.com.ec.domain.dto.FolhaPagamentoFuncionarioDTO; |
| 21 | import br.com.ec.domain.model.Avaliacao; |
23 | import br.com.ec.domain.model.Avaliacao; |
| 22 | import br.com.ec.domain.service.FolhaPagamentoService; |
24 | import br.com.ec.domain.service.FolhaPagamentoService; |
| - | 25 | import br.com.ec.domain.service.ParcelaService; |
|
| 23 | import br.com.ec.web.exception.VerificadorLancamentoException; |
26 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 24 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
27 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
| 25 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandRelatorioStreamedContent; |
28 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandRelatorioStreamedContent; |
| 26 | import br.com.ec.web.generic.AbstractBean; |
29 | import br.com.ec.web.generic.AbstractBean; |
| 27 | import br.com.ec.web.message.LancadorMensagem; |
30 | import br.com.ec.web.message.LancadorMensagem; |
| Line 38... | Line 41... | ||
| 38 | private UploadedFile arquivoParaImportacao; |
41 | private UploadedFile arquivoParaImportacao; |
| 39 | private String tituloEmail = "CONTRACHEQUE"; |
42 | private String tituloEmail = "CONTRACHEQUE"; |
| 40 | private Date dataPagamento = new Date(); |
43 | private Date dataPagamento = new Date(); |
| 41 | 44 | ||
| 42 | private FolhaPagamentoService folhaPagamentoService; |
45 | private FolhaPagamentoService folhaPagamentoService; |
| - | 46 | private ParcelaService parcelaService; |
|
| 43 | 47 | ||
| 44 | private AvaliacaoConsultaPorDemanda lazy; |
48 | private AvaliacaoConsultaPorDemanda lazy; |
| 45 | private ParametrosConsulta<Avaliacao> parametrosConsultaAvaliacao; |
49 | private ParametrosConsulta<Avaliacao> parametrosConsultaAvaliacao; |
| 46 | 50 | ||
| 47 | @Inject |
51 | @Inject |
| 48 | public FolhaPagamentoBean(AvaliacaoConsultaPorDemanda lazy, FolhaPagamentoService folhaPagamentoService) { |
- | |
| - | 52 | public FolhaPagamentoBean(AvaliacaoConsultaPorDemanda lazy, FolhaPagamentoService folhaPagamentoService, ParcelaService parcelaService) { |
|
| 49 | this.lazy = lazy; |
53 | this.lazy = lazy; |
| 50 | this.folhaPagamentoService = folhaPagamentoService; |
54 | this.folhaPagamentoService = folhaPagamentoService; |
| - | 55 | this.parcelaService = parcelaService; |
|
| 51 | }
|
56 | }
|
| 52 | 57 | ||
| 53 | @Override |
58 | @Override |
| 54 | public void preCarregamento() { |
59 | public void preCarregamento() { |
| 55 | parametrosConsultaAvaliacao = new ParametrosConsulta<Avaliacao>(); |
60 | parametrosConsultaAvaliacao = new ParametrosConsulta<Avaliacao>(); |
| Line 138... | Line 143... | ||
| 138 | 143 | ||
| 139 | public void uploadArquivoEspacoCase() { |
144 | public void uploadArquivoEspacoCase() { |
| 140 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
145 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 141 | public void execute() { |
146 | public void execute() { |
| 142 | setFolhaPagamentoDTO(folhaPagamentoService.importarFolhaPagamento(getArquivoParaImportacao().getContent(), getFolhaPagamentoDTO())); |
147 | setFolhaPagamentoDTO(folhaPagamentoService.importarFolhaPagamento(getArquivoParaImportacao().getContent(), getFolhaPagamentoDTO())); |
| - | 148 | setTituloEmail(getTituloEmail() + " " + getFolhaPagamentoDTO().getAvaliacaoDTO().getVigenciaDTO().getDescricao()); |
|
| 143 | LancadorMensagem.lancarSucesso("ARQUIVO IMPORTADO COM SUCESSO!"); |
149 | LancadorMensagem.lancarSucesso("ARQUIVO IMPORTADO COM SUCESSO!"); |
| 144 | }
|
150 | }
|
| 145 | }); |
151 | }); |
| 146 | }
|
152 | }
|
| 147 | 153 | ||
| Line 170... | Line 176... | ||
| 170 | public void atualizarValoresImportados() { |
176 | public void atualizarValoresImportados() { |
| 171 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
177 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 172 | public void execute() { |
178 | public void execute() { |
| 173 | for (FolhaPagamentoFuncionarioDTO folhaPagamentoFuncionario : getFolhaPagamentoDTO().getFuncionarios()) { |
179 | for (FolhaPagamentoFuncionarioDTO folhaPagamentoFuncionario : getFolhaPagamentoDTO().getFuncionarios()) { |
| 174 | if (VerificadorUtil.naoEstaNulo(folhaPagamentoFuncionario.getValorSalarioImportado()) && |
180 | if (VerificadorUtil.naoEstaNulo(folhaPagamentoFuncionario.getValorSalarioImportado()) && |
| 175 | VerificadorUtil.naoEstaNulo(folhaPagamentoFuncionario.getParcelaSalario())) { |
- | |
| 176 | folhaPagamentoFuncionario.getParcelaSalario().setValor(folhaPagamentoFuncionario.getValorSalarioImportado()); |
- | |
| 177 | folhaPagamentoService.atualizarValorParcela(folhaPagamentoFuncionario.getParcelaSalario()); |
- | |
| - | 181 | !VerificadorUtil.isListaNulaOuVazia(folhaPagamentoFuncionario.getParcelas())) { |
|
| - | 182 | folhaPagamentoFuncionario.getParcelas().get(0).setValor(folhaPagamentoFuncionario.getValorSalarioImportado()); |
|
| - | 183 | folhaPagamentoService.atualizarValorParcela(folhaPagamentoFuncionario.getParcelas().get(0)); |
|
| 178 | }
|
184 | }
|
| 179 | }
|
185 | }
|
| 180 | LancadorMensagem.lancarSucesso("VALORES ATUALIZADOS COM SUCESSO"); |
186 | LancadorMensagem.lancarSucesso("VALORES ATUALIZADOS COM SUCESSO"); |
| 181 | }
|
187 | }
|
| 182 | }); |
188 | }); |
| 183 | }
|
189 | }
|
| 184 | 190 | ||
| 185 | public void efetuarPagamentos() { |
191 | public void efetuarPagamentos() { |
| 186 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
192 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
| 187 | public void execute() { |
193 | public void execute() { |
| - | 194 | for (FolhaPagamentoFuncionarioDTO folhaPagamentoFuncionario : getFolhaPagamentoDTO().getFuncionarios()) { |
|
| - | 195 | if (!VerificadorUtil.isListaNulaOuVazia(folhaPagamentoFuncionario.getParcelas())) { |
|
| - | 196 | parcelaService.efetuarPagamentoRecebimento(folhaPagamentoFuncionario.getParcelas().get(0), getDataPagamento()); |
|
| - | 197 | }
|
|
| - | 198 | }
|
|
| - | 199 | setArquivoParaImportacao(null); |
|
| 188 | LancadorMensagem.lancarSucesso("PAGAMENTOS EFETUADOS COM SUCESSO"); |
200 | LancadorMensagem.lancarSucesso("PAGAMENTOS EFETUADOS COM SUCESSO"); |
| 189 | }
|
201 | }
|
| 190 | }); |
202 | }); |
| 191 | }
|
203 | }
|
| 192 | 204 | ||
| 193 | public StreamedContent downloadRecibos() throws Exception { |
205 | public StreamedContent downloadRecibos() throws Exception { |
| 194 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
206 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
| 195 | @Override |
207 | @Override |
| 196 | public StreamedContent execute() { |
208 | public StreamedContent execute() { |
| 197 | return null; |
- | |
| 198 | // return arquivoService.gerarRecibos(arquivoDTO, ((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()));
|
- | |
| - | 209 | return folhaPagamentoService.downloadRecibos(getFolhaPagamentoDTO()); |
|
| - | 210 | }
|
|
| - | 211 | }); |
|
| - | 212 | }
|
|
| - | 213 | ||
| - | 214 | public void enviarRecibos() throws Exception { |
|
| - | 215 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
|
| - | 216 | public void execute() { |
|
| - | 217 | folhaPagamentoService.enviarRecibosPorEmail(getFolhaPagamentoDTO(), getTituloEmail()); |
|
| - | 218 | LancadorMensagem.lancarSucesso("RECIBOS ENVIADOS COM SUCESSO!"); |
|
| 199 | }
|
219 | }
|
| 200 | }); |
220 | }); |
| 201 | }
|
221 | }
|
| 202 | 222 | ||
| 203 | public StreamedContent enviarRecibos() throws Exception { |
- | |
| - | 223 | public StreamedContent downloadArquivoFolhaBanco(String codigoBanco) throws Exception { |
|
| 204 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
224 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
| 205 | @Override |
225 | @Override |
| 206 | public StreamedContent execute() { |
226 | public StreamedContent execute() { |
| 207 | return null; |
- | |
| 208 | // return arquivoService.gerarRecibos(arquivoDTO, ((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()));
|
- | |
| - | 227 | return folhaPagamentoService.downloadArquivoFolhaBanco(getFolhaPagamentoDTO(), codigoBanco); |
|
| 209 | }
|
228 | }
|
| 210 | }); |
229 | }); |
| 211 | }
|
230 | }
|
| 212 | 231 | ||
| 213 | }
|
232 | }
|