Rev 467 | Rev 472 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 353 | espaco | 1 | package br.com.ec.controller; |
| 2 | |||
| 3 | import java.io.Serializable; |
||
| 468 | blopes | 4 | import java.util.List; |
| 353 | espaco | 5 | |
| 6 | import javax.inject.Inject; |
||
| 7 | import javax.inject.Named; |
||
| 8 | |||
| 414 | espaco | 9 | import org.primefaces.model.StreamedContent; |
| 353 | espaco | 10 | import org.springframework.context.annotation.Scope; |
| 11 | |||
| 12 | import br.com.ec.controller.consultademanda.NotaFiscalConsultaPorDemanda; |
||
| 13 | import br.com.ec.core.generic.GenericService; |
||
| 468 | blopes | 14 | import br.com.ec.domain.dto.CompraProdutoDTO; |
| 462 | blopes | 15 | import br.com.ec.domain.dto.NotaFiscalDTO; |
| 16 | import br.com.ec.domain.dto.NotaFiscalProdutoDTO; |
||
| 17 | import br.com.ec.domain.dto.NotaFiscalReferenciadaDTO; |
||
| 18 | import br.com.ec.domain.dto.ProdutoDTO; |
||
| 353 | espaco | 19 | import br.com.ec.domain.dto.consulta.ParametrosConsultaNotaFiscal; |
| 20 | import br.com.ec.domain.model.NotaFiscal; |
||
| 449 | blopes | 21 | import br.com.ec.domain.model.Pessoa; |
| 413 | espaco | 22 | import br.com.ec.domain.model.Venda; |
| 465 | blopes | 23 | import br.com.ec.domain.model.nfe.TipoModeloNotaFiscal; |
| 353 | espaco | 24 | import br.com.ec.domain.model.nfe.TipoNotaFiscal; |
| 468 | blopes | 25 | import br.com.ec.domain.service.CompraProdutoService; |
| 414 | espaco | 26 | import br.com.ec.domain.service.EmissorRelatorioService; |
| 462 | blopes | 27 | import br.com.ec.domain.service.NotaFiscalProdutoService; |
| 28 | import br.com.ec.domain.service.NotaFiscalReferenciadaService; |
||
| 353 | espaco | 29 | import br.com.ec.domain.service.NotaFiscalService; |
| 462 | blopes | 30 | import br.com.ec.domain.service.ProdutoService; |
| 353 | espaco | 31 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 32 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 446 | blopes | 33 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandRelatorioStreamedContent; |
| 353 | espaco | 34 | import br.com.ec.web.generic.AbstractBean; |
| 35 | import br.com.ec.web.message.LancadorMensagem; |
||
| 36 | import br.com.ec.web.util.TipoOperacao; |
||
| 37 | |||
| 38 | @Named |
||
| 39 | @Scope("view") |
||
| 40 | public class NotaFiscalBean extends AbstractBean<NotaFiscal> implements Serializable { |
||
| 41 | |||
| 42 | private static final long serialVersionUID = 1L; |
||
| 43 | |||
| 467 | blopes | 44 | private String statusSefaz = ""; |
| 353 | espaco | 45 | |
| 46 | private ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal; |
||
| 47 | private NotaFiscalConsultaPorDemanda lazy; |
||
| 48 | |||
| 49 | private Long sequencialVendaParaVinculo; |
||
| 446 | blopes | 50 | private StreamedContent danfeNfePreVisualizacao; |
| 414 | espaco | 51 | private StreamedContent danfeNfe; |
| 449 | blopes | 52 | |
| 462 | blopes | 53 | private String codigoProdutoParaVinculoNotaFiscal = ""; |
| 54 | private Integer quantidadeProdutoParaVinculoNotaFiscal = 0; |
||
| 55 | private ProdutoDTO produtoDTOParaVinculoNotaFiscal; |
||
| 468 | blopes | 56 | private CompraProdutoDTO compraProdutoDTOParaVinculoNotaFiscal; |
| 57 | private List<CompraProdutoDTO> listaCompraProdutoDTOParaVinculoNotaFiscal; |
||
| 462 | blopes | 58 | |
| 59 | private String chaveNotaFiscalParaReferenciaNotaFiscal = ""; |
||
| 60 | private NotaFiscalDTO notaFiscalDTOParaReferenciaNotaFiscal; |
||
| 61 | |||
| 467 | blopes | 62 | private NotaFiscalService notaFiscalService; |
| 63 | private NotaFiscalProdutoService notaFiscalProdutoService; |
||
| 64 | private NotaFiscalReferenciadaService notaFiscalReferenciadaService; |
||
| 65 | private ProdutoService produtoService; |
||
| 468 | blopes | 66 | private CompraProdutoService compraProdutoService; |
| 467 | blopes | 67 | private EmissorRelatorioService emissorRelatorioService; |
| 68 | |||
| 353 | espaco | 69 | @Inject |
| 462 | blopes | 70 | public NotaFiscalBean(NotaFiscalConsultaPorDemanda lazy, NotaFiscalService notaFiscalService, NotaFiscalProdutoService notaFiscalProdutoService, |
| 468 | blopes | 71 | NotaFiscalReferenciadaService notaFiscalReferenciadaService, ProdutoService produtoService, CompraProdutoService compraProdutoService, |
| 72 | EmissorRelatorioService emissorRelatorioService) { |
||
| 353 | espaco | 73 | this.lazy = lazy; |
| 74 | this.notaFiscalService = notaFiscalService; |
||
| 462 | blopes | 75 | this.notaFiscalProdutoService = notaFiscalProdutoService; |
| 76 | this.notaFiscalReferenciadaService = notaFiscalReferenciadaService; |
||
| 77 | this.produtoService = produtoService; |
||
| 468 | blopes | 78 | this.compraProdutoService = compraProdutoService; |
| 414 | espaco | 79 | this.emissorRelatorioService = emissorRelatorioService; |
| 353 | espaco | 80 | } |
| 81 | |||
| 82 | @Override |
||
| 83 | public void preCarregamento() { |
||
| 84 | parametrosConsultaNotaFiscal = new ParametrosConsultaNotaFiscal(); |
||
| 85 | prepararConsultaDemanda(); |
||
| 86 | limparEntidade(); |
||
| 467 | blopes | 87 | atualizarStatusSefaz(); |
| 353 | espaco | 88 | } |
| 89 | |||
| 90 | @Override |
||
| 91 | public void limparEntidade() { |
||
| 92 | setEntidade(new NotaFiscal()); |
||
| 93 | } |
||
| 94 | |||
| 95 | @Override |
||
| 96 | public GenericService<NotaFiscal> getService() { |
||
| 97 | return notaFiscalService; |
||
| 98 | } |
||
| 99 | |||
| 100 | @Override |
||
| 101 | public NotaFiscal getEntidade() { |
||
| 102 | return entidade; |
||
| 103 | } |
||
| 104 | |||
| 105 | @Override |
||
| 106 | public void preConsultar() { |
||
| 107 | setTipoOperacao(TipoOperacao.CONSULTAR); |
||
| 108 | } |
||
| 449 | blopes | 109 | |
| 110 | /* |
||
| 353 | espaco | 111 | @Override |
| 449 | blopes | 112 | public void preAlterar(NotaFiscal notaFiscal) { |
| 113 | NotaFiscal notaFiscalDetalhada = notaFiscalService.detalhar(notaFiscal.getSequencial()); |
||
| 114 | super.preAlterar(notaFiscalDetalhada); |
||
| 115 | } |
||
| 116 | */ |
||
| 117 | |||
| 118 | @Override |
||
| 353 | espaco | 119 | public NotaFiscal getId() { |
| 120 | return getEntidade(); |
||
| 121 | } |
||
| 122 | |||
| 123 | public ParametrosConsultaNotaFiscal getParametrosConsultaNotaFiscal() { |
||
| 124 | return parametrosConsultaNotaFiscal; |
||
| 125 | } |
||
| 126 | public void setParametrosConsultaNotaFiscal(ParametrosConsultaNotaFiscal parametrosConsultaNotaFiscal) { |
||
| 127 | this.parametrosConsultaNotaFiscal = parametrosConsultaNotaFiscal; |
||
| 128 | } |
||
| 129 | |||
| 130 | public NotaFiscalConsultaPorDemanda getLazy() { |
||
| 131 | return lazy; |
||
| 132 | } |
||
| 133 | public void setLazy(NotaFiscalConsultaPorDemanda lazy) { |
||
| 134 | this.lazy = lazy; |
||
| 135 | } |
||
| 136 | public void prepararConsultaDemanda() { |
||
| 137 | lazy.setarParametrosConsulta(getParametrosConsultaNotaFiscal()); |
||
| 138 | } |
||
| 139 | |||
| 140 | public TipoNotaFiscal[] getTiposNotaFiscal() { |
||
| 141 | return TipoNotaFiscal.values(); |
||
| 142 | } |
||
| 143 | |||
| 144 | public Long getSequencialVendaParaVinculo() { |
||
| 145 | return sequencialVendaParaVinculo; |
||
| 146 | } |
||
| 147 | public void setSequencialVendaParaVinculo(Long sequencialVendaParaVinculo) { |
||
| 148 | this.sequencialVendaParaVinculo = sequencialVendaParaVinculo; |
||
| 149 | } |
||
| 150 | |||
| 446 | blopes | 151 | public StreamedContent getDanfeNfePreVisualizacao() { |
| 152 | return danfeNfePreVisualizacao; |
||
| 153 | } |
||
| 154 | public void setDanfeNfePreVisualizacao(StreamedContent danfeNfePreVisualizacao) { |
||
| 155 | this.danfeNfePreVisualizacao = danfeNfePreVisualizacao; |
||
| 156 | } |
||
| 157 | |||
| 414 | espaco | 158 | public StreamedContent getDanfeNfe() { |
| 159 | return danfeNfe; |
||
| 160 | } |
||
| 161 | public void setDanfeNfe(StreamedContent danfeNfe) { |
||
| 162 | this.danfeNfe = danfeNfe; |
||
| 163 | } |
||
| 164 | |||
| 462 | blopes | 165 | public String getCodigoProdutoParaVinculoNotaFiscal() { |
| 166 | return codigoProdutoParaVinculoNotaFiscal; |
||
| 167 | } |
||
| 168 | public void setCodigoProdutoParaVinculoNotaFiscal(String codigoProdutoParaVinculoNotaFiscal) { |
||
| 169 | this.codigoProdutoParaVinculoNotaFiscal = codigoProdutoParaVinculoNotaFiscal; |
||
| 170 | } |
||
| 171 | |||
| 172 | public Integer getQuantidadeProdutoParaVinculoNotaFiscal() { |
||
| 173 | return quantidadeProdutoParaVinculoNotaFiscal; |
||
| 174 | } |
||
| 175 | public void setQuantidadeProdutoParaVinculoNotaFiscal(Integer quantidadeProdutoParaVinculoNotaFiscal) { |
||
| 176 | this.quantidadeProdutoParaVinculoNotaFiscal = quantidadeProdutoParaVinculoNotaFiscal; |
||
| 177 | } |
||
| 178 | |||
| 179 | public ProdutoDTO getProdutoDTOParaVinculoNotaFiscal() { |
||
| 180 | return produtoDTOParaVinculoNotaFiscal; |
||
| 181 | } |
||
| 182 | public void setProdutoDTOParaVinculoNotaFiscal(ProdutoDTO produtoDTOParaVinculoNotaFiscal) { |
||
| 183 | this.produtoDTOParaVinculoNotaFiscal = produtoDTOParaVinculoNotaFiscal; |
||
| 184 | } |
||
| 185 | |||
| 468 | blopes | 186 | public CompraProdutoDTO getCompraProdutoDTOParaVinculoNotaFiscal() { |
| 187 | return compraProdutoDTOParaVinculoNotaFiscal; |
||
| 188 | } |
||
| 189 | public void setCompraProdutoDTOParaVinculoNotaFiscal(CompraProdutoDTO compraProdutoDTOParaVinculoNotaFiscal) { |
||
| 190 | this.compraProdutoDTOParaVinculoNotaFiscal = compraProdutoDTOParaVinculoNotaFiscal; |
||
| 191 | } |
||
| 192 | |||
| 193 | public List<CompraProdutoDTO> getListaCompraProdutoDTOParaVinculoNotaFiscal() { |
||
| 194 | return listaCompraProdutoDTOParaVinculoNotaFiscal; |
||
| 195 | } |
||
| 196 | public void setListaCompraProdutoDTOParaVinculoNotaFiscal(List<CompraProdutoDTO> listaCompraProdutoDTOParaVinculoNotaFiscal) { |
||
| 197 | this.listaCompraProdutoDTOParaVinculoNotaFiscal = listaCompraProdutoDTOParaVinculoNotaFiscal; |
||
| 198 | } |
||
| 199 | |||
| 462 | blopes | 200 | public String getChaveNotaFiscalParaReferenciaNotaFiscal() { |
| 201 | return chaveNotaFiscalParaReferenciaNotaFiscal; |
||
| 202 | } |
||
| 203 | public void setChaveNotaFiscalParaReferenciaNotaFiscal(String chaveNotaFiscalParaReferenciaNotaFiscal) { |
||
| 204 | this.chaveNotaFiscalParaReferenciaNotaFiscal = chaveNotaFiscalParaReferenciaNotaFiscal; |
||
| 205 | } |
||
| 206 | |||
| 207 | public NotaFiscalDTO getNotaFiscalDTOParaReferenciaNotaFiscal() { |
||
| 208 | return notaFiscalDTOParaReferenciaNotaFiscal; |
||
| 209 | } |
||
| 210 | public void setNotaFiscalDTOParaReferenciaNotaFiscal(NotaFiscalDTO notaFiscalDTOParaReferenciaNotaFiscal) { |
||
| 211 | this.notaFiscalDTOParaReferenciaNotaFiscal = notaFiscalDTOParaReferenciaNotaFiscal; |
||
| 212 | } |
||
| 213 | |||
| 467 | blopes | 214 | public String getStatusSefaz() { |
| 215 | return statusSefaz; |
||
| 216 | } |
||
| 217 | public void setStatusSefaz(String statusSefaz) { |
||
| 218 | this.statusSefaz = statusSefaz; |
||
| 219 | } |
||
| 220 | |||
| 353 | espaco | 221 | /**************************************************/ |
| 222 | |||
| 467 | blopes | 223 | public void atualizarStatusSefaz() { |
| 224 | setStatusSefaz(notaFiscalService.retornarStatusSefaz()); |
||
| 225 | } |
||
| 226 | |||
| 353 | espaco | 227 | public void desvincularVenda() { |
| 228 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 229 | public void execute() { |
||
| 413 | espaco | 230 | notaFiscalService.desvincularVenda(getEntidade().getSequencial()); |
| 231 | getEntidade().setVenda(null); |
||
| 353 | espaco | 232 | LancadorMensagem.lancarSucesso("VENDA DESVINCULADA COM SUCESSO"); |
| 233 | } |
||
| 234 | }); |
||
| 235 | } |
||
| 236 | |||
| 237 | public void vincularVenda() { |
||
| 238 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 239 | public void execute() { |
||
| 413 | espaco | 240 | Venda vendaVinculada = notaFiscalService.vincularVenda(getEntidade().getSequencial(), getSequencialVendaParaVinculo()); |
| 241 | getEntidade().setVenda(vendaVinculada); |
||
| 353 | espaco | 242 | LancadorMensagem.lancarSucesso("VENDA VINCULADA COM SUCESSO"); |
| 243 | } |
||
| 244 | }); |
||
| 245 | } |
||
| 246 | |||
| 414 | espaco | 247 | public void emitirDanfeNfe(Long sequencialNotaFiscal) { |
| 447 | blopes | 248 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
| 414 | espaco | 249 | setDanfeNfe(notaFiscalService.gerarDanfeNfe(sequencialNotaFiscal)); |
| 446 | blopes | 250 | } |
| 251 | |||
| 252 | public void emitirDanfeNfePreVisualizacao(Long sequencialNotaFiscal) { |
||
| 253 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
||
| 254 | setDanfeNfe(notaFiscalService.gerarDanfeNfe(sequencialNotaFiscal)); |
||
| 414 | espaco | 255 | /* |
| 256 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 257 | @Override |
||
| 258 | public StreamedContent execute() { |
||
| 259 | return notaFiscalService.gerarDanfeNfe(getEntidade().getSequencial()); |
||
| 260 | } |
||
| 261 | }); |
||
| 262 | */ |
||
| 263 | } |
||
| 264 | |||
| 446 | blopes | 265 | public StreamedContent downloadNotaFiscal() { |
| 266 | return new VerificadorLancamentoException().verificarLancamentoException(new CommandRelatorioStreamedContent() { |
||
| 267 | @Override |
||
| 268 | public StreamedContent execute() { |
||
| 269 | return getDanfeNfe(); |
||
| 270 | } |
||
| 271 | }); |
||
| 272 | } |
||
| 273 | |||
| 425 | espaco | 274 | public void emitirDanfeNfeTeste() { |
| 275 | Long sequencialNotaFiscal = new Long(168722); |
||
| 446 | blopes | 276 | setDanfeNfePreVisualizacao(notaFiscalService.gerarDanfeNfePreVisualizacao(sequencialNotaFiscal)); |
| 425 | espaco | 277 | setDanfeNfe(notaFiscalService.gerarDanfeNfe(sequencialNotaFiscal)); |
| 278 | } |
||
| 279 | |||
| 449 | blopes | 280 | public void selecionarEmitente(final Pessoa pessoa) { |
| 281 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 282 | public void execute() { |
||
| 283 | getEntidade().setPessoaEmitente(pessoa); |
||
| 284 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 285 | } |
||
| 286 | }); |
||
| 287 | } |
||
| 288 | |||
| 289 | public void retirarEmitente() { |
||
| 290 | getEntidade().setPessoaEmitente(null); |
||
| 291 | } |
||
| 292 | |||
| 293 | public void selecionarDestinatario(final Pessoa pessoa) { |
||
| 294 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 295 | public void execute() { |
||
| 296 | getEntidade().setPessoaDestinatario(pessoa); |
||
| 297 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 298 | } |
||
| 299 | }); |
||
| 300 | } |
||
| 301 | |||
| 302 | public void retirarDestinatario() { |
||
| 303 | getEntidade().setPessoaDestinatario(null); |
||
| 304 | } |
||
| 305 | |||
| 465 | blopes | 306 | |
| 307 | /************************************/ |
||
| 308 | /** REMESSA **/ |
||
| 309 | /************************************/ |
||
| 310 | |||
| 311 | public void prepararNotaFiscalRemessa() { |
||
| 312 | preCadastrar(); |
||
| 313 | getEntidade().setTipoModeloNotaFiscal(TipoModeloNotaFiscal.MODELO_NFE_55.getValor()); |
||
| 314 | getEntidade().setTipoNotaFiscal(TipoNotaFiscal.NFE_REMESSA.getValor()); |
||
| 315 | } |
||
| 316 | |||
| 317 | public void emitirNotaFiscalRemessa() { |
||
| 318 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 319 | public void execute() { |
||
| 320 | notaFiscalService.emitirNotaFiscalRemessa(getEntidade()); |
||
| 321 | limparEntidade(); |
||
| 322 | LancadorMensagem.lancarSucesso("NOTA DE REMESSA EMITIDA COM SUCESSO"); |
||
| 323 | } |
||
| 324 | }); |
||
| 325 | } |
||
| 326 | |||
| 449 | blopes | 327 | public void consultarProdutosVinculados() { |
| 328 | getEntidade().setListaProdutosVinculadosDTO(notaFiscalService.consultarProdutosVinculados(getEntidade().getSequencial())); |
||
| 329 | } |
||
| 330 | |||
| 468 | blopes | 331 | public void selecionarCompraProdutoParaVinculoNotaFiscal(CompraProdutoDTO compraProdutoDTO) { |
| 332 | setCompraProdutoDTOParaVinculoNotaFiscal(compraProdutoDTO); |
||
| 333 | } |
||
| 334 | |||
| 335 | |||
| 336 | |||
| 337 | |||
| 462 | blopes | 338 | public void consultarNfReferenciadas() { |
| 339 | getEntidade().setListaNfeReferenciadasDTO(notaFiscalService.consultarNfReferenciadas(getEntidade().getSequencial())); |
||
| 340 | } |
||
| 341 | |||
| 342 | public void excluirVinculoNotaFiscalProduto(NotaFiscalProdutoDTO notaFiscalProdutoDTO) { |
||
| 343 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 344 | public void execute() { |
||
| 345 | notaFiscalProdutoService.excluirNotaFiscalProduto(notaFiscalProdutoDTO); |
||
| 346 | consultarProdutosVinculados(); |
||
| 347 | LancadorMensagem.lancarSucesso("VÍNCULO EXCLUÍDO COM SUCESSO"); |
||
| 348 | } |
||
| 349 | }); |
||
| 350 | } |
||
| 351 | |||
| 352 | public void consultarProdutoParaVinculoNotaFiscal() { |
||
| 353 | setProdutoDTOParaVinculoNotaFiscal(produtoService.consultarProdutoDTOPorCodigoOuCodigoEAN(getCodigoProdutoParaVinculoNotaFiscal())); |
||
| 468 | blopes | 354 | setListaCompraProdutoDTOParaVinculoNotaFiscal(produtoService.consultarComprasDoProduto(getProdutoDTOParaVinculoNotaFiscal().getSequencial())); |
| 462 | blopes | 355 | } |
| 356 | |||
| 357 | public void vinculoProdutoNaNotaFiscal() { |
||
| 358 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 359 | public void execute() { |
||
| 360 | notaFiscalProdutoService.vinculoProdutoNaNotaFiscal(getEntidade().getSequencial(), |
||
| 468 | blopes | 361 | getProdutoDTOParaVinculoNotaFiscal().getSequencial(), |
| 362 | getCompraProdutoDTOParaVinculoNotaFiscal().getSequencial(), |
||
| 462 | blopes | 363 | getQuantidadeProdutoParaVinculoNotaFiscal()); |
| 364 | setCodigoProdutoParaVinculoNotaFiscal(""); |
||
| 365 | setProdutoDTOParaVinculoNotaFiscal(null); |
||
| 468 | blopes | 366 | setCompraProdutoDTOParaVinculoNotaFiscal(null); |
| 462 | blopes | 367 | setQuantidadeProdutoParaVinculoNotaFiscal(0); |
| 368 | consultarProdutosVinculados(); |
||
| 369 | LancadorMensagem.lancarSucesso("PRODUTO VINCULADO COM SUCESSO"); |
||
| 370 | } |
||
| 371 | }); |
||
| 372 | } |
||
| 373 | |||
| 374 | public void consultarNotaFiscalParaReferenciarNotaFiscal() { |
||
| 375 | setNotaFiscalDTOParaReferenciaNotaFiscal(notaFiscalService.consultarPorChave(getChaveNotaFiscalParaReferenciaNotaFiscal())); |
||
| 376 | } |
||
| 377 | |||
| 378 | public void referenciarNotaFiscalNaNotaFiscal() { |
||
| 379 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 380 | public void execute() { |
||
| 381 | notaFiscalReferenciadaService.referenciarNotaFiscal(getEntidade().getSequencial(), getNotaFiscalDTOParaReferenciaNotaFiscal().getSequencialNotaFiscal()); |
||
| 382 | setChaveNotaFiscalParaReferenciaNotaFiscal(""); |
||
| 383 | setNotaFiscalDTOParaReferenciaNotaFiscal(null); |
||
| 384 | consultarNfReferenciadas(); |
||
| 385 | LancadorMensagem.lancarSucesso("NOTA FISCAL REFERENCIADA COM SUCESSO"); |
||
| 386 | } |
||
| 387 | }); |
||
| 388 | } |
||
| 389 | |||
| 390 | public void excluirNotaFiscalReferenciada(NotaFiscalReferenciadaDTO notaFiscalReferenciadaDTO) { |
||
| 391 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 392 | public void execute() { |
||
| 393 | notaFiscalReferenciadaService.excluirNotaFiscalReferenciada(notaFiscalReferenciadaDTO); |
||
| 394 | consultarNfReferenciadas(); |
||
| 395 | LancadorMensagem.lancarSucesso("REFERÊNCIA EXCLUÍDA COM SUCESSO"); |
||
| 396 | } |
||
| 397 | }); |
||
| 398 | } |
||
| 399 | |||
| 413 | espaco | 400 | /* |
| 401 | private StreamedContent chart; |
||
| 402 | public StreamedContent getChart() { |
||
| 403 | return chart; |
||
| 404 | } |
||
| 405 | private PieDataset createDataset() { |
||
| 406 | DefaultPieDataset dataset = new DefaultPieDataset(); |
||
| 407 | dataset.setValue("New York", new Double(45.0)); |
||
| 408 | dataset.setValue("London", new Double(15.0)); |
||
| 409 | dataset.setValue("Paris", new Double(25.2)); |
||
| 410 | dataset.setValue("Berlin", new Double(14.8)); |
||
| 411 | return dataset; |
||
| 412 | } |
||
| 413 | |||
| 414 | private StreamedContent escala; |
||
| 415 | public StreamedContent getEscala() { |
||
| 416 | return escala; |
||
| 417 | } |
||
| 418 | |||
| 419 | private StreamedContent escalaPdf; |
||
| 420 | public StreamedContent getEscalaPdf() { |
||
| 421 | return escalaPdf; |
||
| 422 | } |
||
| 423 | public String generateRandomIdForNotCaching() { |
||
| 424 | return java.util.UUID.randomUUID().toString(); |
||
| 425 | } |
||
| 426 | |||
| 427 | private void criarImagens() { |
||
| 428 | try { |
||
| 429 | InputStream arquivoPdf = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/imagens/escala-202310.pdf"); |
||
| 430 | byte[] bytePdf = ArquivoUtil.retornarBytesPassandoInputStream(arquivoPdf); |
||
| 431 | ByteArrayOutputStream osPdf = new ByteArrayOutputStream(); |
||
| 432 | PdfReader reader = new PdfReader(bytePdf); |
||
| 433 | escalaPdf = DefaultStreamedContent.builder() |
||
| 434 | .contentType("application/pdf") |
||
| 435 | .name("escala-202310.pdf") |
||
| 436 | .stream(() -> { |
||
| 437 | try { |
||
| 438 | return ArquivoUtil.gerarInputStreamDeArquivo(bytePdf); |
||
| 439 | } catch (IOException e1) { |
||
| 440 | e1.printStackTrace(); |
||
| 441 | } |
||
| 442 | return arquivoPdf; |
||
| 443 | }) |
||
| 444 | .build(); |
||
| 445 | |||
| 446 | |||
| 447 | InputStream arquivo = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/imagens/escala-202310.png"); |
||
| 448 | BufferedImage imagem = ImageIO.read(arquivo); |
||
| 449 | ByteArrayOutputStream os = new ByteArrayOutputStream(); |
||
| 450 | ImageIO.write(imagem, "png", os); |
||
| 451 | escala = DefaultStreamedContent.builder() |
||
| 452 | .contentType("image/png") |
||
| 453 | .stream(() -> new ByteArrayInputStream(os.toByteArray())) |
||
| 454 | .build(); |
||
| 455 | |||
| 456 | |||
| 457 | chart = DefaultStreamedContent.builder() |
||
| 458 | .contentType("image/png") |
||
| 459 | .stream(() -> { |
||
| 460 | try { |
||
| 461 | JFreeChart jfreechart = ChartFactory.createPieChart("Cities", createDataset(), true, true, false); |
||
| 462 | File chartFile = new File("dynamichart"); |
||
| 463 | ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 375, 300); |
||
| 464 | return new FileInputStream(chartFile); |
||
| 465 | } |
||
| 466 | catch (Exception e) { |
||
| 467 | e.printStackTrace(); |
||
| 468 | return null; |
||
| 469 | } |
||
| 470 | }) |
||
| 471 | .build(); |
||
| 472 | } catch (IOException e1) { |
||
| 473 | // TODO Auto-generated catch block |
||
| 474 | e1.printStackTrace(); |
||
| 475 | } |
||
| 476 | } |
||
| 477 | */ |
||
| 353 | espaco | 478 | } |