Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Autowired
- private RelatorioService relatorioService;
- @GetMapping("/vendasEmitidas")
- public ModelAndView relatorioVendasEmitidas() {
- ModelAndView mv = new ModelAndView("relatorio/RelatorioVendasEmitidas");
- mv.addObject(new PeriodoRelatorio());
- return mv;
- }
- @GetMapping("/controleEntregas")
- public ModelAndView relatorioControleEntrega() {
- ModelAndView mv = new ModelAndView("relatorio/RelatorioControleEntrega");
- mv.addObject(new ControleEntregaCodigo());
- return mv;
- }
- @PostMapping(value ="/controleEntregas", params = "emitir")
- public ResponseEntity<byte[]> gerarControleEntrega(ControleEntregaCodigo controleEntregaCodigo) throws Exception {
- byte[] relatorio = relatorioService.gerarControleEntrega(controleEntregaCodigo);
- return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PDF_VALUE)
- .body(relatorio);
- }
- @GetMapping("/produtoPrecos")
- public ModelAndView relatorioProdutosPrecoVenda() {
- ModelAndView mv = new ModelAndView("relatorio/RelatorioProdutoPrecoVenda");
- mv.addObject(new PrecoRelatorio());
- return mv;
- }
- @PostMapping("/vendasEmitidas")
- public ResponseEntity<byte[]> gerarRelatorioVendasEmitidas(PeriodoRelatorio periodoRelatorio) throws Exception {
- byte[] relatorio = relatorioService.gerarRelatorioVendasEmitidas(periodoRelatorio);
- return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PDF_VALUE)
- .body(relatorio);
- }
- @PostMapping("/controleEntregas")
- public ResponseEntity<byte[]> emitirControleEntrega(ControleEntregaCodigo controleEntregaCodigo) throws Exception {
- byte[] relatorio = relatorioService.gerarControleEntrega(controleEntregaCodigo);
- return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PDF_VALUE)
- .body(relatorio);
- }
- @PostMapping("/produtoPrecos")
- public ResponseEntity<byte[]> gerarRelatorioProdutoPreco(PrecoRelatorio precoRelatorio) throws Exception {
- byte[] relatorio = relatorioService.gerarRelatorioProdutoPreco(precoRelatorio);
- return ResponseEntity.ok().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PDF_VALUE)
- .body(relatorio);
- }
- @Autowired
- private DataSource dataSource;
- // relatórido de venda por periodo
- public byte[] gerarRelatorioVendasEmitidas(PeriodoRelatorio periodoRelatorio) throws Exception {
- Date dataInicio = Date.from(LocalDateTime.of(periodoRelatorio.getDataInicio(), LocalTime.of(0, 0, 0))
- .atZone(ZoneId.systemDefault()).toInstant());
- Date dataFim = Date.from(LocalDateTime.of(periodoRelatorio.getDataFim(), LocalTime.of(23, 59, 59))
- .atZone(ZoneId.systemDefault()).toInstant());
- Map<String, Object> parametros = new HashMap<>();
- parametros.put("format", "pdf");
- parametros.put("data_inicio", dataInicio);
- parametros.put("data_fim", dataFim);
- InputStream inputStream = this.getClass().getResourceAsStream("/relatorios/relatorio_vendas_emitidas.jasper");
- Connection con = this.dataSource.getConnection();
- try {
- JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parametros, con);
- return JasperExportManager.exportReportToPdf(jasperPrint);
- } finally {
- con.close();
- }
- }
- // imprimir controle de entrega
- public byte[] gerarControleEntrega(ControleEntregaCodigo controleEntregaCodigo) throws Exception {
- Map<String, Object> parametros = new HashMap<>();
- parametros.put("format", "pdf");
- parametros.put("codigo", controleEntregaCodigo.getCodigo());
- InputStream inputStream = this.getClass().getResourceAsStream("/relatorios/relatorio_controle_entrega.jasper");
- Connection con = this.dataSource.getConnection();
- try {
- JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parametros, con);
- return JasperExportManager.exportReportToPdf(jasperPrint);
- } finally {
- con.close();
- }
- }
- // relatório de produtos por valor de venda
- public byte[] gerarRelatorioProdutoPreco(PrecoRelatorio precoRelatorio) throws Exception {
- Map<String, Object> parametros = new HashMap<>();
- parametros.put("format", "pdf");
- parametros.put("valor_inicial", precoRelatorio.getValorInicial());
- parametros.put("valor_final", precoRelatorio.getValorFinal());
- // System.out.println(" valor inicial: " +
- // precoRelatorio.getValorInicial()+ "valor final:
- // "+precoRelatorio.getValorFinal() );
- InputStream inputStream = this.getClass().getResourceAsStream("/relatorios/relatorio_produto_valor.jasper");
- Connection con = this.dataSource.getConnection();
- try {
- JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, parametros, con);
- return JasperExportManager.exportReportToPdf(jasperPrint);
- } finally {
- con.close();
- }
- }
- <a class="btn btn-link btn-xs js-tooltip " title="Imprimir"
- th:href="@{/relatorios/controleEntregas{codigo}(codigo=${venda.codigo})}"
- >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement