Subversion Repositories Integrator Subversion

Rev

Rev 369 | Rev 414 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 369 Rev 413
Line 9... Line 9...
9
9
10
import br.com.ec.controller.consultademanda.NotaFiscalConsultaPorDemanda;
10
import br.com.ec.controller.consultademanda.NotaFiscalConsultaPorDemanda;
11
import br.com.ec.core.generic.GenericService;
11
import br.com.ec.core.generic.GenericService;
12
import br.com.ec.domain.dto.consulta.ParametrosConsultaNotaFiscal;
12
import br.com.ec.domain.dto.consulta.ParametrosConsultaNotaFiscal;
13
import br.com.ec.domain.model.NotaFiscal;
13
import br.com.ec.domain.model.NotaFiscal;
14
import br.com.ec.domain.model.Papel;
-
 
-
 
14
import br.com.ec.domain.model.Venda;
15
import br.com.ec.domain.model.nfe.TipoNotaFiscal;
15
import br.com.ec.domain.model.nfe.TipoNotaFiscal;
16
import br.com.ec.domain.service.NotaFiscalService;
16
import br.com.ec.domain.service.NotaFiscalService;
17
import br.com.ec.web.exception.VerificadorLancamentoException;
17
import br.com.ec.web.exception.VerificadorLancamentoException;
18
import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean;
18
import br.com.ec.web.exception.VerificadorLancamentoException.CommandBean;
19
import br.com.ec.web.generic.AbstractBean;
19
import br.com.ec.web.generic.AbstractBean;
20
import br.com.ec.web.message.LancadorMensagem;
20
import br.com.ec.web.message.LancadorMensagem;
21
import br.com.ec.web.util.TipoOperacao;
21
import br.com.ec.web.util.TipoOperacao;
22
import br.com.swconsultoria.nfe.Nfe;
-
 
23
import br.com.swconsultoria.nfe.dom.ConfiguracoesNfe;
-
 
24
import br.com.swconsultoria.nfe.dom.enuns.*;
-
 
25
import br.com.swconsultoria.nfe.exception.NfeException;
-
 
26
import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TEnvEvento;
-
 
27
import br.com.swconsultoria.nfe.schema.envEventoCancNFe.TRetEnvEvento;
-
 
28
import br.com.swconsultoria.nfe.schema.retConsCad.TRetConsCad;
-
 
29
import br.com.swconsultoria.nfe.schema.retdistdfeint.RetDistDFeInt;
-
 
30
import br.com.swconsultoria.nfe.schema_4.enviNFe.TEnviNFe;
-
 
31
import br.com.swconsultoria.nfe.schema_4.enviNFe.TRetEnviNFe;
-
 
32
import br.com.swconsultoria.nfe.schema_4.inutNFe.TInutNFe;
-
 
33
import br.com.swconsultoria.nfe.schema_4.inutNFe.TRetInutNFe;
-
 
34
import br.com.swconsultoria.nfe.schema_4.retConsReciNFe.TRetConsReciNFe;
-
 
35
import br.com.swconsultoria.nfe.schema_4.retConsSitNFe.TRetConsSitNFe;
-
 
36
import br.com.swconsultoria.nfe.schema_4.retConsStatServ.TRetConsStatServ;
-
 
37
import br.com.swconsultoria.nfe.util.ConfiguracoesUtil;
-
 
38
22
39
@Named
23
@Named
40
@Scope("view")
24
@Scope("view")
41
public class NotaFiscalBean extends AbstractBean<NotaFiscal> implements Serializable {
25
public class NotaFiscalBean extends AbstractBean<NotaFiscal> implements Serializable {
42
26
Line 118... Line 102...
118
        /**************************************************/
102
        /**************************************************/
119
       
103
       
120
        public void desvincularVenda() {
104
        public void desvincularVenda() {
121
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
105
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
122
                        public void execute() {
106
                        public void execute() {
123
//                              pessoaPapelService.adicionarPapel(getEntidade().getPessoa(), new Papel(getPessoaPapelDTO().getCodigoPapel()));
-
 
124
//                              getEntidadeDTO().setPapeisDTO(pessoaPapelService.consultarPapeisDaPessoa(getPessoaPapelDTO().getSequencialPessoa()));
-
 
-
 
107
                                notaFiscalService.desvincularVenda(getEntidade().getSequencial());
-
 
108
                                getEntidade().setVenda(null);
125
                                LancadorMensagem.lancarSucesso("VENDA DESVINCULADA COM SUCESSO");
109
                                LancadorMensagem.lancarSucesso("VENDA DESVINCULADA COM SUCESSO");
126
                        }
110
                        }
127
                });
111
                });
128
        }
112
        }
129
       
113
       
130
        public void vincularVenda() {
114
        public void vincularVenda() {
131
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
115
                new VerificadorLancamentoException().tratarIhRelancarExcecaoSemLimparEntidade(new CommandBean() {
132
                        public void execute() {
116
                        public void execute() {
133
//                              pessoaPapelService.adicionarPapel(getEntidade().getPessoa(), new Papel(getPessoaPapelDTO().getCodigoPapel()));
-
 
134
//                              getEntidadeDTO().setPapeisDTO(pessoaPapelService.consultarPapeisDaPessoa(getPessoaPapelDTO().getSequencialPessoa()));
-
 
-
 
117
                                Venda vendaVinculada = notaFiscalService.vincularVenda(getEntidade().getSequencial(), getSequencialVendaParaVinculo());
-
 
118
                                getEntidade().setVenda(vendaVinculada);
135
                                LancadorMensagem.lancarSucesso("VENDA VINCULADA COM SUCESSO");
119
                                LancadorMensagem.lancarSucesso("VENDA VINCULADA COM SUCESSO");
136
                        }
120
                        }
137
                });
121
                });
138
        }
122
        }
139
       
123
       
-
 
124
        /*
-
 
125
         private StreamedContent chart;
-
 
126
         public StreamedContent getChart() {
-
 
127
                 return chart;
-
 
128
         }
-
 
129
         private PieDataset createDataset() {
-
 
130
                 DefaultPieDataset dataset = new DefaultPieDataset();
-
 
131
                 dataset.setValue("New York", new Double(45.0));
-
 
132
                 dataset.setValue("London", new Double(15.0));
-
 
133
                 dataset.setValue("Paris", new Double(25.2));
-
 
134
                 dataset.setValue("Berlin", new Double(14.8));
-
 
135
                 return dataset;
-
 
136
         }
-
 
137
       
-
 
138
         private StreamedContent escala;
-
 
139
         public StreamedContent getEscala() {
-
 
140
                 return escala;
-
 
141
         }
-
 
142
         
-
 
143
         private StreamedContent escalaPdf;
-
 
144
         public StreamedContent getEscalaPdf() {
-
 
145
                 return escalaPdf;
-
 
146
         }
-
 
147
         public String generateRandomIdForNotCaching() {
-
 
148
                 return java.util.UUID.randomUUID().toString();
-
 
149
         }
-
 
150
       
-
 
151
         private void criarImagens() {
-
 
152
                 try {
-
 
153
                         InputStream arquivoPdf = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/imagens/escala-202310.pdf");
-
 
154
                         byte[] bytePdf = ArquivoUtil.retornarBytesPassandoInputStream(arquivoPdf);
-
 
155
                         ByteArrayOutputStream osPdf = new ByteArrayOutputStream();
-
 
156
                         PdfReader reader = new PdfReader(bytePdf);
-
 
157
                         escalaPdf = DefaultStreamedContent.builder()
-
 
158
                            .contentType("application/pdf")
-
 
159
                            .name("escala-202310.pdf")
-
 
160
                            .stream(() -> {
-
 
161
                                                try {
-
 
162
                                                        return ArquivoUtil.gerarInputStreamDeArquivo(bytePdf);
-
 
163
                                                } catch (IOException e1) {
-
 
164
                                                        e1.printStackTrace();
-
 
165
                                                }
-
 
166
                                                return arquivoPdf;
-
 
167
                                        })
-
 
168
                            .build();
-
 
169
                         
-
 
170
                         
-
 
171
                         InputStream arquivo = FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/imagens/escala-202310.png");
-
 
172
                         BufferedImage imagem = ImageIO.read(arquivo);
-
 
173
                         ByteArrayOutputStream os = new ByteArrayOutputStream();
-
 
174
             ImageIO.write(imagem, "png", os);
-
 
175
                         escala = DefaultStreamedContent.builder()
-
 
176
                            .contentType("image/png")
-
 
177
                            .stream(() -> new ByteArrayInputStream(os.toByteArray()))
-
 
178
                            .build();
-
 
179
                       
-
 
180
                         
-
 
181
                        chart = DefaultStreamedContent.builder()
-
 
182
                            .contentType("image/png")
-
 
183
                            .stream(() -> {
-
 
184
                                try {
-
 
185
                                    JFreeChart jfreechart = ChartFactory.createPieChart("Cities", createDataset(), true, true, false);
-
 
186
                                    File chartFile = new File("dynamichart");
-
 
187
                                    ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 375, 300);
-
 
188
                                    return new FileInputStream(chartFile);
-
 
189
                                }
-
 
190
                                catch (Exception e) {
-
 
191
                                    e.printStackTrace();
-
 
192
                                    return null;
-
 
193
                                }
-
 
194
                            })
-
 
195
                            .build();
-
 
196
                 } catch (IOException e1) {
-
 
197
                                // TODO Auto-generated catch block
-
 
198
                                e1.printStackTrace();
-
 
199
                        }
-
 
200
        }
-
 
201
        */
140
}
202
}