Rev 470 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.controller.managedbean; |
| 2 | |||
| 3 | import java.io.IOException; |
||
| 4 | import java.io.Serializable; |
||
| 5 | import java.util.ArrayList; |
||
| 6 | import java.util.Arrays; |
||
| 7 | import java.util.List; |
||
| 8 | |||
| 9 | import javax.faces.context.FacesContext; |
||
| 10 | import javax.inject.Inject; |
||
| 11 | import javax.inject.Named; |
||
| 12 | |||
| 13 | import org.primefaces.context.RequestContext; |
||
| 14 | import org.springframework.context.annotation.Scope; |
||
| 15 | |||
| 16 | import br.com.ec.controller.managedbean.consultademanda.NotaFiscalConsultaPorDemanda; |
||
| 195 | espaco | 17 | import br.com.ec.core.generic.GenericService; |
| 18 | import br.com.ec.core.util.DataUtils; |
||
| 19 | import br.com.ec.core.util.VerificadorUtil; |
||
| 106 | espaco | 20 | import br.com.ec.domain.dto.ParametrosConsultaNotaFiscalDTO; |
| 21 | import br.com.ec.domain.dto.ParametrosConsultaProdutoDTO; |
||
| 22 | import br.com.ec.domain.dto.nfce.NotaFiscalRemessaDTO; |
||
| 23 | import br.com.ec.domain.model.Fornecedor; |
||
| 24 | import br.com.ec.domain.model.Loja; |
||
| 25 | import br.com.ec.domain.model.NotaFiscal; |
||
| 26 | import br.com.ec.domain.model.NotaFiscalProduto; |
||
| 27 | import br.com.ec.domain.model.Pessoa; |
||
| 28 | import br.com.ec.domain.model.Produto; |
||
| 29 | import br.com.ec.domain.model.ProdutoLoja; |
||
| 30 | import br.com.ec.domain.model.tipos.TipoRelatorio; |
||
| 170 | espaco | 31 | import br.com.ec.domain.model.tipos.nfe.TipoModeloNotaFiscal; |
| 32 | import br.com.ec.domain.model.tipos.nfe.TipoNotaFiscal; |
||
| 246 | espaco | 33 | import br.com.ec.domain.service.emissor.notafiscal.EmissorDiretoNotaFiscalService; |
| 106 | espaco | 34 | import br.com.ec.domain.service.emissor.notafiscal.EmissorNotaFiscalEletronicaService; |
| 35 | import br.com.ec.domain.service.notafiscal.NotaFiscalProdutoService; |
||
| 36 | import br.com.ec.domain.service.notafiscal.NotaFiscalService; |
||
| 37 | import br.com.ec.domain.service.pessoa.PessoaService; |
||
| 38 | import br.com.ec.domain.service.produto.ProdutoService; |
||
| 39 | import br.com.ec.domain.service.produtodaloja.ProdutoLojaService; |
||
| 195 | espaco | 40 | import br.com.ec.web.exception.VerificadorLancamentoException; |
| 41 | import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean; |
||
| 42 | import br.com.ec.web.generic.AbstractBean; |
||
| 43 | import br.com.ec.web.message.LancadorMensagem; |
||
| 246 | espaco | 44 | import br.com.swconsultoria.nfe.dom.enuns.DocumentoEnum; |
| 106 | espaco | 45 | |
| 46 | @Named |
||
| 47 | @Scope("view") |
||
| 48 | public class NotaFiscalBean extends AbstractBean<NotaFiscal> implements Serializable { |
||
| 49 | |||
| 50 | private static final long serialVersionUID = 1L; |
||
| 51 | |||
| 52 | private NotaFiscalService notaFiscalService; |
||
| 53 | private ProdutoService produtoService; |
||
| 54 | private NotaFiscalProdutoService notaFiscalProdutoService; |
||
| 55 | private EmissorNotaFiscalEletronicaService emissorNotaFiscalEletronicaService; |
||
| 246 | espaco | 56 | private EmissorDiretoNotaFiscalService emissorDiretoNotaFiscalService; |
| 106 | espaco | 57 | private PessoaService pessoaService; |
| 58 | private ProdutoLojaService produtoLojaService; |
||
| 59 | |||
| 60 | private String codigoProdutoRemessa; |
||
| 61 | private Produto produtoSelecionado; |
||
| 62 | private Integer quantidadeProdutoSelecionado; |
||
| 63 | private NotaFiscalRemessaDTO notaFiscalRemessa; |
||
| 64 | |||
| 65 | private Fornecedor fornecedorParaRemessa; |
||
| 66 | private Loja lojaParaRemessa; |
||
| 67 | |||
| 68 | private NotaFiscalConsultaPorDemanda lazy; |
||
| 69 | |||
| 70 | @Inject |
||
| 71 | public NotaFiscalBean(NotaFiscalService notaFiscalService, ProdutoService produtoService, NotaFiscalProdutoService notaFiscalProdutoService, |
||
| 246 | espaco | 72 | EmissorNotaFiscalEletronicaService emissorNotaFiscalEletronicaService, EmissorDiretoNotaFiscalService emissorDiretoNotaFiscalService, |
| 73 | PessoaService pessoaService, NotaFiscalConsultaPorDemanda lazy, |
||
| 106 | espaco | 74 | ProdutoLojaService produtoLojaService) { |
| 75 | this.notaFiscalService = notaFiscalService; |
||
| 76 | this.produtoService = produtoService; |
||
| 77 | this.notaFiscalProdutoService = notaFiscalProdutoService; |
||
| 78 | this.emissorNotaFiscalEletronicaService = emissorNotaFiscalEletronicaService; |
||
| 246 | espaco | 79 | this.emissorDiretoNotaFiscalService = emissorDiretoNotaFiscalService; |
| 106 | espaco | 80 | this.pessoaService = pessoaService; |
| 81 | this.lazy = lazy; |
||
| 82 | this.produtoLojaService = produtoLojaService; |
||
| 83 | } |
||
| 84 | |||
| 85 | @Override |
||
| 86 | public void preCarregamento() { |
||
| 87 | entidade = new NotaFiscal(); |
||
| 88 | parametrosConsulta = new ParametrosConsultaNotaFiscalDTO(); |
||
| 89 | parametrosConsulta.setEntidade(entidade); |
||
| 90 | } |
||
| 91 | |||
| 92 | @Override |
||
| 93 | public void limparEntidade() { |
||
| 94 | setEntidade(new NotaFiscal()); |
||
| 95 | } |
||
| 96 | |||
| 97 | @Override |
||
| 98 | public GenericService<NotaFiscal> getService() { |
||
| 99 | return notaFiscalService; |
||
| 100 | } |
||
| 101 | |||
| 102 | @Override |
||
| 103 | public NotaFiscal getEntidade() { |
||
| 104 | return entidade; |
||
| 105 | } |
||
| 106 | |||
| 107 | @Override |
||
| 108 | public NotaFiscal getId() { |
||
| 109 | return getEntidade(); |
||
| 110 | } |
||
| 111 | |||
| 112 | public String getCodigoProdutoRemessa() { |
||
| 113 | return codigoProdutoRemessa; |
||
| 114 | } |
||
| 115 | public void setCodigoProdutoRemessa(String codigoProdutoRemessa) { |
||
| 116 | this.codigoProdutoRemessa = codigoProdutoRemessa; |
||
| 117 | } |
||
| 118 | |||
| 119 | public Produto getProdutoSelecionado() { |
||
| 120 | return produtoSelecionado; |
||
| 121 | } |
||
| 122 | public void setProdutoSelecionado(Produto produtoSelecionado) { |
||
| 123 | this.produtoSelecionado = produtoSelecionado; |
||
| 124 | } |
||
| 125 | |||
| 126 | public Integer getQuantidadeProdutoSelecionado() { |
||
| 127 | return quantidadeProdutoSelecionado; |
||
| 128 | } |
||
| 129 | public void setQuantidadeProdutoSelecionado(Integer quantidadeProdutoSelecionado) { |
||
| 130 | this.quantidadeProdutoSelecionado = quantidadeProdutoSelecionado; |
||
| 131 | } |
||
| 132 | |||
| 133 | public NotaFiscalRemessaDTO getNotaFiscalRemessa() { |
||
| 134 | return notaFiscalRemessa; |
||
| 135 | } |
||
| 136 | public void setNotaFiscalRemessa(NotaFiscalRemessaDTO notaFiscalRemessa) { |
||
| 137 | this.notaFiscalRemessa = notaFiscalRemessa; |
||
| 138 | } |
||
| 139 | |||
| 140 | public Fornecedor getFornecedorParaRemessa() { |
||
| 141 | return fornecedorParaRemessa; |
||
| 142 | } |
||
| 143 | public void setFornecedorParaRemessa(Fornecedor fornecedorParaRemessa) { |
||
| 144 | this.fornecedorParaRemessa = fornecedorParaRemessa; |
||
| 145 | } |
||
| 146 | |||
| 147 | public Loja getLojaParaRemessa() { |
||
| 148 | return lojaParaRemessa; |
||
| 149 | } |
||
| 150 | public void setLojaParaRemessa(Loja lojaParaRemessa) { |
||
| 151 | this.lojaParaRemessa = lojaParaRemessa; |
||
| 152 | } |
||
| 153 | |||
| 154 | public NotaFiscalConsultaPorDemanda getLazy() { |
||
| 155 | prepararConsultaDemanda(); |
||
| 156 | return lazy; |
||
| 157 | } |
||
| 158 | public void setLazy(NotaFiscalConsultaPorDemanda lazy) { |
||
| 159 | this.lazy = lazy; |
||
| 160 | } |
||
| 161 | public void prepararConsultaDemanda() { |
||
| 162 | lazy.setarParametrosConsulta(getParametrosConsulta()); |
||
| 163 | } |
||
| 164 | |||
| 165 | public TipoNotaFiscal[] getTiposNotaFiscal() { |
||
| 166 | return TipoNotaFiscal.values(); |
||
| 167 | } |
||
| 168 | |||
| 169 | public void prepararParaCadastrarNFeRemessa() { |
||
| 170 | setNotaFiscalRemessa(new NotaFiscalRemessaDTO()); |
||
| 171 | preRealizar(); |
||
| 172 | } |
||
| 173 | |||
| 174 | /***************************************************************/ |
||
| 175 | |||
| 176 | @Override |
||
| 177 | public void cadastrar(final NotaFiscal notaFiscal) { |
||
| 178 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 179 | public void execute() { |
||
| 180 | notaFiscal.setDataHoraEmissao(DataUtils.getDataAtual()); |
||
| 170 | espaco | 181 | notaFiscal.setTipoNotaFiscal(TipoNotaFiscal.NFCE_SAIDA.getValor()); |
| 106 | espaco | 182 | notaFiscal.setTipoModeloNotaFiscal(TipoModeloNotaFiscal.MODELO_NFCE_65.getValor()); |
| 183 | getService().cadastrar(notaFiscal); |
||
| 184 | limparEntidade(); |
||
| 185 | LancadorMensagem.lancarSucesso(getMensagens().get(IDENTIFICADOR_MENSAGEM_CADASTRADO_COM_SUCESSO)); |
||
| 186 | } |
||
| 187 | }); |
||
| 188 | } |
||
| 189 | |||
| 190 | @Override |
||
| 191 | public void excluir(final NotaFiscal notaFiscal) { |
||
| 192 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 193 | public void execute() { |
||
| 194 | getService().excluir(notaFiscal); |
||
| 195 | limparEntidade(); |
||
| 196 | LancadorMensagem.lancarSucesso(getMensagens().get(IDENTIFICADOR_MENSAGEM_EXCLUIDO_COM_SUCESSO)); |
||
| 197 | } |
||
| 198 | }); |
||
| 199 | } |
||
| 200 | |||
| 201 | public void cancelarNotaFiscal(final NotaFiscal notaFiscal) { |
||
| 202 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 203 | public void execute() { |
||
| 204 | LancadorMensagem.lancarSucesso("OPERAÇÃO NÃO IMPLEMENTADA"); |
||
| 205 | // notaFiscalService.cancelarNFCe(notaFiscal); |
||
| 206 | // LancadorMensagem.lancarSucesso("NOTA FISCAL CANCELADA COM SUCESSO"); |
||
| 207 | } |
||
| 208 | }); |
||
| 209 | } |
||
| 210 | |||
| 211 | public void detalharNotaFiscal(NotaFiscal notaFiscal) { |
||
| 212 | setEntidade(notaFiscalService.detalhar(notaFiscal)); |
||
| 213 | getEntidade().setListaNFRemessaProdutos(notaFiscalProdutoService.consultarProdutosDaNotaFiscal(getEntidade())); |
||
| 214 | } |
||
| 215 | |||
| 216 | public void iniciarNfeRemessa() { |
||
| 217 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 218 | public void execute() { |
||
| 219 | NotaFiscal notaFiscal = new NotaFiscal(); |
||
| 220 | notaFiscal.setTipoModeloNotaFiscal(TipoModeloNotaFiscal.MODELO_NFE_55.getValor()); |
||
| 545 | blopes | 221 | notaFiscal.setTipoNotaFiscal(TipoNotaFiscal.NFE_REMESSA_SAIDA.getValor()); |
| 222 | notaFiscal.setSerie(TipoNotaFiscal.NFE_REMESSA_SAIDA.getSerie()); |
||
| 106 | espaco | 223 | notaFiscal.setDataHoraEmissao(DataUtils.getDataAtual()); |
| 170 | espaco | 224 | notaFiscal.setPessoaEmitente(getNotaFiscalRemessa().getLojaEmitente().getPessoaJuridica()); |
| 225 | notaFiscal.setPessoaDestinatario(getNotaFiscalRemessa().getLojaDestino().getPessoaJuridica()); |
||
| 106 | espaco | 226 | notaFiscalService.alterar(notaFiscal); |
| 227 | getNotaFiscalRemessa().preencherDadosNotaFiscal(notaFiscal); |
||
| 170 | espaco | 228 | getNotaFiscalRemessa().setPessoaEmitente(getNotaFiscalRemessa().getLojaEmitente().getPessoaJuridica()); |
| 229 | getNotaFiscalRemessa().setPessoaDestinatario(getNotaFiscalRemessa().getLojaDestino().getPessoaJuridica()); |
||
| 106 | espaco | 230 | setCodigoProdutoRemessa(null); |
| 231 | LancadorMensagem.lancarSucesso("REMESSA INICIADA COM SUCESSO"); |
||
| 232 | } |
||
| 233 | }); |
||
| 234 | } |
||
| 235 | |||
| 236 | public void consultarNfeRemessa(final NotaFiscal nf) { |
||
| 237 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 238 | public void execute() { |
||
| 239 | preRealizar(); |
||
| 240 | setEntidade(notaFiscalService.detalhar(nf)); |
||
| 241 | getEntidade().setListaNFRemessaProdutos(notaFiscalProdutoService.consultarProdutosDaNotaFiscal(getEntidade())); |
||
| 242 | setNotaFiscalRemessa(new NotaFiscalRemessaDTO()); |
||
| 243 | getNotaFiscalRemessa().preencherDadosNotaFiscal(getEntidade()); |
||
| 244 | } |
||
| 245 | }); |
||
| 246 | } |
||
| 247 | |||
| 248 | public void escolherProduto() { |
||
| 249 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 250 | public void execute() { |
||
| 251 | Produto produtoConsultado = produtoService.consultarProdutoPorCodigoOuCodigoEAN(getCodigoProdutoRemessa()); |
||
| 252 | if (VerificadorUtil.estaNulo(produtoConsultado)) { |
||
| 253 | LancadorMensagem.lancarErro("Produto não encontrado!"); |
||
| 254 | } else { |
||
| 255 | setProdutoSelecionado(produtoConsultado); |
||
| 256 | setQuantidadeProdutoSelecionado(1); |
||
| 257 | RequestContext.getCurrentInstance().addCallbackParam("confirmado", true); |
||
| 258 | } |
||
| 259 | } |
||
| 260 | }); |
||
| 261 | } |
||
| 262 | |||
| 263 | public void escolherProduto(Produto produto) { |
||
| 264 | setProdutoSelecionado(produto); |
||
| 265 | setQuantidadeProdutoSelecionado(1); |
||
| 266 | } |
||
| 267 | |||
| 268 | public void adicionarProduto() { |
||
| 269 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 270 | public void execute() { |
||
| 271 | NotaFiscalProduto notaFiscalRemessaProduto = new NotaFiscalProduto(); |
||
| 470 | blopes | 272 | // notaFiscalRemessaProduto.setProduto(getProdutoSelecionado()); |
| 106 | espaco | 273 | notaFiscalRemessaProduto.setQuantidade(getQuantidadeProdutoSelecionado()); |
| 274 | notaFiscalRemessaProduto.setNotaFiscal(notaFiscalService.consultarPorId(getNotaFiscalRemessa().getNotaFiscal())); |
||
| 275 | notaFiscalProdutoService.cadastrar(notaFiscalRemessaProduto); |
||
| 276 | // verificarParametros(notaFiscalRemessaProduto); |
||
| 277 | consultarNfeRemessa(getNotaFiscalRemessa().getNotaFiscal()); |
||
| 278 | setCodigoProdutoRemessa(null); |
||
| 279 | LancadorMensagem.lancarSucesso("Produto adicionado, código: " + getProdutoSelecionado().getCodigoProdutoPadrao()); |
||
| 280 | } |
||
| 281 | }); |
||
| 282 | } |
||
| 283 | |||
| 284 | public void removerProduto(final NotaFiscalProduto notaFiscalProduto) { |
||
| 285 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 286 | public void execute() { |
||
| 287 | notaFiscalProdutoService.excluir(notaFiscalProduto); |
||
| 288 | consultarNfeRemessa(notaFiscalProduto.getNotaFiscal()); |
||
| 289 | LancadorMensagem.lancarSucesso("Produto removido com sucesso"); |
||
| 290 | } |
||
| 291 | }); |
||
| 292 | } |
||
| 293 | |||
| 294 | public void emitirNfeRemessa() { |
||
| 295 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 296 | public void execute() { |
||
| 297 | NotaFiscal notaFiscal = notaFiscalService.detalhar(getEntidade()); |
||
| 170 | espaco | 298 | notaFiscal.setPessoaEmitente(pessoaService.detalharPessoa(notaFiscal.getPessoaEmitente())); |
| 299 | notaFiscal.setPessoaDestinatario(pessoaService.detalharPessoa(notaFiscal.getPessoaDestinatario())); |
||
| 106 | espaco | 300 | notaFiscal.setListaNFRemessaProdutos(notaFiscalProdutoService.consultarProdutosDaNotaFiscal(getEntidade())); |
| 301 | emissorNotaFiscalEletronicaService.enviarNotaFiscalEletronicaRemessa(notaFiscal); |
||
| 302 | LancadorMensagem.lancarSucesso("NOTA FISCAL DE REMESSA: EMITIDA COM SUCESSO"); |
||
| 303 | } |
||
| 304 | }); |
||
| 305 | } |
||
| 306 | |||
| 170 | espaco | 307 | // TODO: MÉTODO PROVISÓRIO |
| 308 | public void emitirNfeDevolucao() { |
||
| 309 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 310 | public void execute() { |
||
| 246 | espaco | 311 | emissorDiretoNotaFiscalService.emitirNotaFiscalDireto(TipoModeloNotaFiscal.MODELO_NFE_55.getValor(), DocumentoEnum.NFE); |
| 170 | espaco | 312 | LancadorMensagem.lancarSucesso("NOTA FISCAL: EMITIDA COM SUCESSO"); |
| 313 | } |
||
| 314 | }); |
||
| 315 | } |
||
| 316 | |||
| 317 | public void selecionarEmitente(final Pessoa pessoa) { |
||
| 318 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 319 | public void execute() { |
||
| 320 | getEntidade().setPessoaEmitente(pessoa); |
||
| 321 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 322 | } |
||
| 323 | }); |
||
| 324 | } |
||
| 325 | |||
| 326 | public void retirarEmitente() { |
||
| 327 | getEntidade().setPessoaEmitente(null); |
||
| 328 | } |
||
| 329 | |||
| 330 | public void selecionarDestinatario(final Pessoa pessoa) { |
||
| 331 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 332 | public void execute() { |
||
| 333 | getEntidade().setPessoaDestinatario(pessoa); |
||
| 334 | adicionandoParametroArgsConfirmandoAcao(true); |
||
| 335 | } |
||
| 336 | }); |
||
| 337 | } |
||
| 338 | |||
| 339 | public void retirarDestinatario() { |
||
| 340 | getEntidade().setPessoaDestinatario(null); |
||
| 341 | } |
||
| 342 | |||
| 106 | espaco | 343 | /* |
| 344 | private void verificarParametros(TransferenciaProduto transferenciaProduto) { |
||
| 345 | if (VerificadorUtil.estaNulo(transferenciaProduto.getQuantidadeTransferir()) || transferenciaProduto.getQuantidadeTransferir().equals(0)) { |
||
| 346 | throw new NegocioException("Obrigatório informar a quantidade para transferência."); |
||
| 347 | } |
||
| 348 | verificarSeProdutoJaFoiAdicionado(transferenciaProduto.getSequencialDoProduto()); |
||
| 349 | } |
||
| 350 | |||
| 351 | protected void verificarSeProdutoJaFoiAdicionado(Long sequencialProduto) { |
||
| 352 | if (getEntidade().verificarSeProdutoJaConstaNaLista(sequencialProduto)) { |
||
| 353 | throw new NegocioException("Produto já foi adicionando anteriormente!"); |
||
| 354 | } |
||
| 355 | } |
||
| 356 | */ |
||
| 357 | |||
| 358 | // MÉTODO PARCIAL |
||
| 359 | public void adicionarEstoqueProdutos() { |
||
| 360 | // FORNECEDORES: "MULTILASER" 29, "VIVONA25" 25, "JBL HARMAN" 38, "HUSKY" 40, "BHX ENERGY" 37, "KINGO" 30, "GBMAX" 70, |
||
| 361 | // "GIFFY" 32, "RCELL" 34, "TTNT" 60, "YASIN" 68, "DL COMERCIO" 71 |
||
| 362 | /*1;"LOJA POÇO" |
||
| 363 | 2;"QUIOSQUE EXTRA" |
||
| 364 | 3;"QUIOSQUE HIPER" |
||
| 365 | 4;"LOJA VIVO" |
||
| 366 | 5;"QUIOSQUE PÁTIO" |
||
| 367 | 6;"LOJA MATRIZ" |
||
| 368 | 7;"FARMÁCIA" |
||
| 369 | 8;"LOJA MACEIÓ" |
||
| 370 | 9;"ESTOQUE" |
||
| 371 | 13;"QUIOSQUE ANTARES"*/ |
||
| 372 | |||
| 373 | // FORNECEDORES APTOS |
||
| 374 | // List<Integer> sequenciaisFornecedor = new ArrayList<>(Arrays.asList(29, 25, 38, 40, 37, 30, 70, 32, 34, 60, 68, 71)); |
||
| 375 | // List<Integer> sequenciaisFornecedor = new ArrayList<>(Arrays.asList(38)); |
||
| 376 | new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() { |
||
| 377 | public void execute() { |
||
| 378 | ParametrosConsultaProdutoDTO parametrosConsultaProduto = new ParametrosConsultaProdutoDTO(); |
||
| 379 | parametrosConsultaProduto.setTipoRelatorioProduto(TipoRelatorio.PRODUTOS_COM_ESTOQUE.getValor()); |
||
| 380 | if (VerificadorUtil.naoEstaNulo(getLojaParaRemessa())) { |
||
| 381 | parametrosConsultaProduto.setLojaSelecionada(getLojaParaRemessa().getSequencial()); |
||
| 382 | } else { |
||
| 383 | LancadorMensagem.lancarErro("Selecione a loja do estoque"); |
||
| 384 | } |
||
| 385 | if (VerificadorUtil.naoEstaNulo(getFornecedorParaRemessa())) { |
||
| 386 | parametrosConsultaProduto.setFornecedor(getFornecedorParaRemessa()); |
||
| 387 | } else { |
||
| 388 | LancadorMensagem.lancarErro("Selecione o fornecedor"); |
||
| 389 | } |
||
| 390 | |||
| 391 | List<Produto> produtosAptos = produtoService.consultarProdutoPorParametros(parametrosConsultaProduto); |
||
| 392 | for (Produto produto : produtosAptos) { |
||
| 393 | ProdutoLoja produtoLoja = null; |
||
| 394 | if (VerificadorUtil.naoEstaNulo(getLojaParaRemessa())) { |
||
| 395 | produtoLoja = produtoLojaService.consultarProdutoLoja(produto, getLojaParaRemessa()); |
||
| 396 | } |
||
| 397 | NotaFiscalProduto notaFiscalProduto = new NotaFiscalProduto(); |
||
| 470 | blopes | 398 | // notaFiscalProduto.setProduto(produto); |
| 106 | espaco | 399 | notaFiscalProduto.setQuantidade(produtoLoja.getQuantidadeEstoque()); |
| 400 | notaFiscalProduto.setNotaFiscal(getEntidade()); |
||
| 401 | notaFiscalProdutoService.cadastrar(notaFiscalProduto); |
||
| 402 | } |
||
| 403 | consultarNfeRemessa(getEntidade()); |
||
| 404 | } |
||
| 405 | }); |
||
| 406 | } |
||
| 407 | |||
| 408 | public void retirarEstoqueProdutos() { |
||
| 409 | for (NotaFiscalProduto notaFiscalProduto : getEntidade().getListaNFRemessaProdutos()) { |
||
| 410 | notaFiscalProdutoService.excluir(notaFiscalProduto); |
||
| 411 | } |
||
| 412 | consultarNfeRemessa(getEntidade()); |
||
| 413 | } |
||
| 414 | |||
| 415 | public void abrirLinkCaminhoQrcode() { |
||
| 416 | try { |
||
| 417 | FacesContext.getCurrentInstance().getExternalContext().redirect(getEntidade().getCaminhoQrcode()); |
||
| 418 | } catch (IOException e) { |
||
| 419 | e.printStackTrace(); |
||
| 420 | } |
||
| 421 | } |
||
| 422 | |||
| 423 | public static void main(String[] args) { |
||
| 424 | List<Integer> sequenciaisFornecedor = new ArrayList<>(Arrays.asList(29, 25, 38, 40, 37, 30, 70, 32, 34, 60, 68, 71)); |
||
| 425 | for (Integer sequencialFornecedor : sequenciaisFornecedor) { |
||
| 426 | System.out.println(sequencialFornecedor); |
||
| 427 | } |
||
| 428 | } |
||
| 429 | |||
| 430 | } |