diff --git a/pom.xml b/pom.xml index 3eafba0aa..cdefb5bb6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 br.com.rjconsultores ventaboletosadm - 1.55.11 + 1.56.0 war diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgencia.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgencia.java index 0fd033790..6a1e13412 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgencia.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgencia.java @@ -192,6 +192,7 @@ public class RelatorioBilhetesVendidosEstoqueAgencia extends Relatorio { sql.append(" em.nombEmpresa, AIT.DESCTIPO "); sql.append(" )TB "); sql.append(" ORDER BY to_number(TB.FOLIO) "); + System.out.println(sql.toString()); return sql.toString(); diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout.java new file mode 100644 index 000000000..d5c04309f --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout.java @@ -0,0 +1,291 @@ +/** + * + */ +package com.rjconsultores.ventaboletos.relatorios.impl; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioBilhetesVendidosEstoqueAgenciaBean; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; + +import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; + +/** + * @author Wallace + * + */ +public class RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout extends Relatorio { + private List lsDadosRelatorio; + + public RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout(Map parametros, Connection conexao) throws Exception { + super(parametros, conexao); + + this.setCustomDataSource(new ArrayDataSource(this) { + @SuppressWarnings("unused") + @Override + public void initDados() throws Exception { + + Connection conexao = this.relatorio.getConexao(); + Map parametros = this.relatorio.getParametros(); + String pnutoVentasIds = (String) parametros.get("NUMPUNTOVENTA"); + Integer empresa = (Integer) parametros.get("EMPRESA_ID"); + Date datainicial = (Date) parametros.get("DATA_INICIAL"); + Date dataFinal = (Date) parametros.get("DATA_FINAL"); + Integer aidfTipoId = (Integer) parametros.get("AIDFTIPO_ID"); + + NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql(pnutoVentasIds, aidfTipoId)); + + stmt.setInt("EMPRESA_ID", empresa); + stmt.setString("dataInicio", DateUtil.getStringDate(datainicial, "dd/MM/yyyy") + " 00:00:00"); + stmt.setString("dataFinal", DateUtil.getStringDate(dataFinal, "dd/MM/yyyy") + " 23:59:59"); + if(aidfTipoId != null) { + stmt.setInt("aidfTipo",aidfTipoId); + } + + ResultSet rset = stmt.executeQuery(); + List lsTemp = new ArrayList<>(); + List lsRelatorioBilhetesVendidosEstoqueAgenciaBean = new ArrayList<>(); + List lsRelatorioBilhetesVendidosEstoqueAgenciaBeanGeradoSequencia = new ArrayList<>(); + while (rset.next()) { + + Map dataResult = new HashMap(); + + RelatorioBilhetesVendidosEstoqueAgenciaBean bean = new RelatorioBilhetesVendidosEstoqueAgenciaBean(); + bean.setAidfId(rset.getInt("aidfId")); + bean.setNombpuntoventa(rset.getString("descpuntoVenta")); + bean.setSerie(rset.getString("serie")); + bean.setFechorVenta(DateUtil.getDateFromString(rset.getString("dataVenda"), "ddMMyyyy")); + bean.setChave(rset.getString("chave")); + bean.setFolio(rset.getString("folio")); + bean.setNomeEmpresa(rset.getString("nomeEmpresa")); + bean.setTipoEvento(rset.getString("tipoAidf")); + bean.setValorContabil((BigDecimal)rset.getObject("valorContabil")); + bean.setOrigem(rset.getString("origem")); + bean.setDestino(rset.getString("destino")); + bean.setEstado(rset.getString("estado")); + lsRelatorioBilhetesVendidosEstoqueAgenciaBean.add(bean); + + this.dados.add(dataResult); + + } + + this.resultSet = rset; + setLsDadosRelatorio(lsRelatorioBilhetesVendidosEstoqueAgenciaBean); + } + }); + } + + public void setLsDadosRelatorio(List lsDadosRelatorio) { + this.setCollectionDataSource(new JRBeanCollectionDataSource(lsDadosRelatorio)); + this.lsDadosRelatorio = lsDadosRelatorio; + } + + public List getLsDadosRelatorio() { + return lsDadosRelatorio; + } + + private String sql(String puntoVentasId, Integer aidfTipoId) { + + StringBuilder sql = new StringBuilder(); + sql.append(" SELECT TB.aidfId AS aidfId, "); + sql.append(" TB.descpuntoVenta AS descpuntoVenta, "); + sql.append(" TB.SERIE AS serie, "); + sql.append(" TB.puntoventaId, "); + sql.append(" TB.dataVenda AS dataVenda, "); + sql.append(" TB.chave AS chave, "); + sql.append(" TB.nomeEmpresa AS nomeEmpresa, "); + sql.append(" TB.folio AS folio, "); + sql.append(" TB.tipoAidf AS tipoAidf, "); + sql.append(" tb.VALOR AS valorContabil, "); + sql.append(" tb.origen as origem, "); + sql.append(" tb.destino as destino, "); + sql.append(" tb.estado as estado "); + sql.append(" FROM "); + sql.append(" (SELECT DAB.AIDF_ID AS aidfId, "); + sql.append(" pv.nombpuntoventa AS descpuntoVenta, "); + sql.append(" c.numseriepreimpresa AS SERIE, "); + sql.append(" c.puntoventa_id AS puntoventaId, "); + sql.append(" to_char(c.fechorventa, 'ddMMyyyy') AS dataVenda,"); + sql.append(" DAB.AIDF_ID || c.numseriepreimpresa || c.puntoventa_id || to_char(c.fechorventa, 'ddMMyyyy') AS chave, "); + sql.append(" em.nombEmpresa AS nomeEmpresa, "); + sql.append(" c.numfoliopreimpreso AS folio, "); + sql.append(" AIT.DESCTIPO tipoAidf,"); + sql.append(" COALESCE(COALESCE(c.PRECIOPAGADO, 0) + COALESCE(c.IMPORTETAXAEMBARQUE, 0) + COALESCE(c.IMPORTESEGURO, 0) + COALESCE(c.IMPORTEPEDAGIO, 0) + COALESCE(c.IMPORTEOUTROS, 0), 0) AS VALOR, "); + sql.append(" po.descparada AS origen, "); + sql.append(" pd.descparada AS destino, est.nombestado as estado "); + sql.append(" FROM caja c, "); + sql.append(" PUNTO_VENTA PV, "); + sql.append(" EMPRESA EM, "); + sql.append(" parada po, "); + sql.append(" ciudad co, "); + sql.append(" parada pd, "); + sql.append(" ciudad cd, "); + sql.append(" estado est, "); + sql.append(" AIDF_TIPO AIT, "); + sql.append(" AIDF AI, "); + sql.append(" ABASTO_BOLETO AB "); + sql.append(" LEFT JOIN DET_ABASTO_BOLETO DAB ON (AB.ABASTOBOLETO_ID = DAB.ABASTOBOLETO_ID) "); + sql.append(" WHERE fechorventa BETWEEN TO_DATE(:dataInicio,'dd/mm/yyyy hh24:mi:ss') AND TO_DATE(:dataFinal,'dd/mm/yyyy hh24:mi:ss') "); + sql.append(" AND TO_NUMBER(c.NUMFOLIOPREIMPRESO) BETWEEN TO_NUMBER(DAB.NUMFOLIOINICIAL) AND TO_NUMBER(DAB.NUMFOLIOFINAL) "); + sql.append(" AND c.PUNTOVENTA_ID = AB.PUNTOVENTA_ID "); + if (puntoVentasId != null && !puntoVentasId.equals("-1")) { + sql.append(" AND c.PUNTOVENTA_ID in (" + puntoVentasId + ") "); + } + sql.append(" AND EM.EMPRESA_ID = AB.EMPRESA_ID "); + sql.append(" AND c.PUNTOVENTA_ID = PV.PUNTOVENTA_ID "); + sql.append(" AND DAB.AIDF_ID = AI.AIDF_ID "); + sql.append(" AND AIT.AIDFTIPO_ID = AI.AIDFTIPO_ID "); + sql.append(" AND EM.EMPRESA_ID =:EMPRESA_ID "); + sql.append(" AND po.parada_id = c.origen_id "); + sql.append(" AND co.ciudad_id = po.ciudad_id "); + sql.append(" AND pd.parada_id = c.destino_id "); + sql.append(" AND cd.ciudad_id = pd.ciudad_id "); + sql.append(" AND est.estado_id = co.estado_id "); + sql.append(" and c.INDSTATUSBOLETO = 'V' AND c.MOTIVOCANCELACION_ID IS NULL "); + sql.append(" AND EM.EMPRESA_ID =:EMPRESA_ID "); + sql.append(" GROUP BY DAB.AIDF_ID, "); + sql.append(" c.numseriepreimpresa, "); + sql.append(" c.numfoliopreimpreso, "); + sql.append(" c.puntoventa_id, "); + sql.append(" to_char(c.fechorventa, 'ddMMyyyy'), "); + sql.append(" pv.nombpuntoventa, "); + sql.append(" em.nombEmpresa, "); + sql.append(" AIT.DESCTIPO, "); + sql.append(" c.preciopagado, "); + sql.append(" c.IMPORTETAXAEMBARQUE, "); + sql.append(" c.IMPORTESEGURO, "); + sql.append(" c.importepedagio, "); + sql.append(" c.IMPORTEOUTROS, "); + sql.append(" po.descparada, "); + sql.append(" pd.descparada, est.nombestado "); + sql.append(" UNION ALL SELECT DAB.AIDF_ID AS aidfId, "); + sql.append(" pv.nombpuntoventa AS descpuntoVenta, "); + sql.append(" c.numseriepreimpresa AS SERIE, "); + sql.append(" c.puntoventa_id AS puntoventaId, "); + sql.append(" to_char(c.FECHORVTA, 'ddMMyyyy') AS dataVenda, "); + sql.append(" DAB.AIDF_ID || c.numseriepreimpresa || c.puntoventa_id || to_char(c.FECHORVTA, 'ddMMyyyy') AS chave, "); + sql.append(" em.nombEmpresa AS nomeEmpresa, "); + sql.append(" c.numfoliopreimpreso AS folio,"); + sql.append(" AIT.DESCTIPO tipoAidf, "); + sql.append(" c.PRECIO, "); + sql.append(" ' ' AS origen, "); + sql.append(" ' ' AS desgtino, "); + sql.append(" ' ' AS estado "); + sql.append(" FROM caja_diversos c, "); + sql.append(" PUNTO_VENTA PV, "); + sql.append(" EMPRESA EM, "); + sql.append(" AIDF AI, "); + sql.append(" AIDF_TIPO AIT, "); + sql.append(" ABASTO_BOLETO AB "); + sql.append(" LEFT JOIN DET_ABASTO_BOLETO DAB ON (AB.ABASTOBOLETO_ID = DAB.ABASTOBOLETO_ID) "); + sql.append(" WHERE FECHORVTA BETWEEN TO_DATE(:dataInicio,'dd/mm/yyyy hh24:mi:ss') AND TO_DATE(:dataFinal,'dd/mm/yyyy hh24:mi:ss') "); + sql.append(" AND TO_NUMBER(c.NUMFOLIOPREIMPRESO) BETWEEN TO_NUMBER(DAB.NUMFOLIOINICIAL) AND TO_NUMBER(DAB.NUMFOLIOFINAL) "); + sql.append(" AND c.PUNTOVENTA_ID = AB.PUNTOVENTA_ID "); + if (puntoVentasId != null && !puntoVentasId.equals("-1")) { + sql.append(" AND c.PUNTOVENTA_ID in (" + puntoVentasId + ") "); + } + sql.append(" AND EM.EMPRESA_ID = AB.EMPRESA_ID "); + sql.append(" AND c.PUNTOVENTA_ID = PV.PUNTOVENTA_ID "); + sql.append(" AND DAB.AIDF_ID = AI.AIDF_ID "); + sql.append(aidfTipoId != null ? " AND (AI.AIDFTIPO_ID =:aidfTipo AND AIT.AIDFTIPO_ID = AI.AIDFTIPO_ID) " : " AND AIT.AIDFTIPO_ID = AI.AIDFTIPO_ID "); + sql.append(" AND EM.EMPRESA_ID =:EMPRESA_ID "); + sql.append(" GROUP BY DAB.AIDF_ID, "); + sql.append(" c.numseriepreimpresa, "); + sql.append(" c.numfoliopreimpreso, "); + sql.append(" c.puntoventa_id, "); + sql.append(" to_char(c.FECHORVTA, 'ddMMyyyy'), "); + sql.append(" pv.nombpuntoventa, "); + sql.append(" em.nombEmpresa, "); + sql.append(" AIT.DESCTIPO, "); + sql.append(" c.PRECIO)TB "); + sql.append(" ORDER BY to_number(TB.FOLIO) "); + + return sql.toString(); + + + } + + private List agruparSequenciasBilhetes(List lista) { + + + int[] bilhetesInt = new int[lista.size()]; + int i = 0; + + for (RelatorioBilhetesVendidosEstoqueAgenciaBean relatorioBilhetesVendidosEstoqueAgenciaBean : lista) { + bilhetesInt[i] = Integer.parseInt(relatorioBilhetesVendidosEstoqueAgenciaBean.getFolio()); + i++; + } + Arrays.sort(bilhetesInt); + List listaAgrupada = new ArrayList<>(); + + RelatorioBilhetesVendidosEstoqueAgenciaBean bean = lista.get(0); + + bilhetesInt = reajustarPosicaoArray(bilhetesInt.length, bilhetesInt, bilhetesInt[0], 1); + int inicio = bilhetesInt[0]; + int fim = bilhetesInt.length == 1 ? bilhetesInt[0] : bilhetesInt[1]; + BigDecimal valorContabil = BigDecimal.ZERO; + for (int j = 2; j < bilhetesInt.length; ++j) { + if (fim + 1 == bilhetesInt[j]) { + fim++; + } else { + listaAgrupada.add(gerarAgrupamento(inicio, fim, new RelatorioBilhetesVendidosEstoqueAgenciaBean(bean))); + inicio = bilhetesInt[j]; + fim = bilhetesInt[j]; + } + } + + listaAgrupada.add(gerarAgrupamento(inicio, fim, bean)); + + return listaAgrupada; + } + + + private RelatorioBilhetesVendidosEstoqueAgenciaBean gerarAgrupamento(int inicio, int fim, RelatorioBilhetesVendidosEstoqueAgenciaBean bean) { + + RelatorioBilhetesVendidosEstoqueAgenciaBean object = new RelatorioBilhetesVendidosEstoqueAgenciaBean(bean); + + + if (inicio != fim) { + object.setQuantidade((fim-inicio+1)); + object.setFolioInicial(inicio); + object.setFolioFinal(fim); + + } else { + object.setQuantidade(1); + object.setFolioInicial(inicio); + object.setFolioFinal(inicio); + } + return object; + } + private int[] reajustarPosicaoArray(int numero, int arr[],int x, int posicao) + { + int novoArray[] = new int[numero + 1]; + + for (int i = 0; i < numero + 1; i++) { + if (i < posicao - 1) + novoArray[i] = arr[i]; + else if (i == posicao - 1) + novoArray[i] = x; + else + novoArray[i] = arr[i - 1]; + } + return novoArray; + } + + @Override + protected void processaParametros() throws Exception { + + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioEstoque.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioEstoque.java index 6fcd8c33d..bbdc50fc7 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioEstoque.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioEstoque.java @@ -35,6 +35,7 @@ public class RelatorioEstoque extends Relatorio { Date dtInicio = (Date) parametros.get("DATA_INICIO"); Date dtFim = (Date) parametros.get("DATA_FIM"); Integer aidfTipoId = (Integer) parametros.get("AIDFTIPO_ID"); + Integer aidfId = (Integer) parametros.get("AIDF_ID"); if (parametros.get("EMPRESA_ID") != null) { empresaId = Integer.valueOf(parametros.get("EMPRESA_ID").toString()); @@ -42,7 +43,7 @@ public class RelatorioEstoque extends Relatorio { if (parametros.get("NUMPUNTOVENTA") != null) { puntoVentaId = String.valueOf(parametros.get("NUMPUNTOVENTA")); } - String sql = retornarItensConsultaPorPuloFolio(puntoVentaId,empresaId, dtInicio, dtFim, aidfTipoId); + String sql = retornarItensConsultaPorPuloFolio(puntoVentaId,empresaId, dtInicio, dtFim, aidfTipoId, aidfId); NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql); if(dtInicio != null && dtFim != null) { stmt.setString("dataInicio", DateUtil.getStringDate(dtInicio, "dd/MM/yyyy") + " 00:00:00"); @@ -53,6 +54,9 @@ public class RelatorioEstoque extends Relatorio { if(aidfTipoId != null) { stmt.setInt("aidfTipo",aidfTipoId); } + if(aidfId != null) { + stmt.setInt("aidfId",aidfId); + } lsDadosRelatorio = new ArrayList(); ResultSet rset = null; @@ -81,7 +85,7 @@ public class RelatorioEstoque extends Relatorio { this.resultSet = rset; - String sqlretornEstoque = sQLretornarEstoque(puntoVentaId, dtInicio, dtFim,empresaId, aidfTipoId); + String sqlretornEstoque = sQLretornarEstoque(puntoVentaId, dtInicio, dtFim,empresaId, aidfTipoId, aidfId); NamedParameterStatement stmt2 = new NamedParameterStatement(conexao, sqlretornEstoque); @@ -94,6 +98,9 @@ public class RelatorioEstoque extends Relatorio { if(aidfTipoId != null) { stmt2.setInt("aidfTipo",aidfTipoId); } + if(aidfId != null) { + stmt2.setInt("aidfId",aidfId); + } ResultSet rset2 = null; rset2 = stmt2.executeQuery(); @@ -143,6 +150,7 @@ public class RelatorioEstoque extends Relatorio { for (ItemReporteControleEstoqueBoletos itemEstoque : lsEstoque) { if(!lsTempRetornoAux.contains(itemEstoque)) { + itemEstoque.setQuantidade(calcularQuantidade(itemEstoque.getFolioInicial(), itemEstoque.getFolioFinal())); lsTempRetornoAux.add(itemEstoque); } } @@ -172,7 +180,7 @@ public class RelatorioEstoque extends Relatorio { - private String retornarItensConsultaPorPuloFolio(String puntoVentaId, Integer empresaId, Date dataInicio, Date dataFim, Integer aidfTipo) { + private String retornarItensConsultaPorPuloFolio(String puntoVentaId, Integer empresaId, Date dataInicio, Date dataFim, Integer aidfTipo, Integer aidfId) { StringBuilder sb = new StringBuilder(); @@ -246,7 +254,7 @@ public class RelatorioEstoque extends Relatorio { sb.append(" AND A.ARTICULO_ID = AB.ARTICULO_ID "); sb.append(" AND EM.EMPRESA_ID = AB.EMPRESA_ID "); sb.append(" AND M.EMPRESA_ID = EM.EMPRESA_ID "); - sb.append(" AND M.ACTIVO = 1 AND DAB.AIDF_ID = AI.AIDF_ID "); + sb.append(" AND M.ACTIVO = 1 "); sb.append(" AND CJ.USUARIO_ID = U.USUARIO_ID "); sb.append(" AND (CJ.INDREIMPRESION = 0 "); sb.append(" OR (CJ.INDREIMPRESION = 1 "); @@ -255,6 +263,7 @@ public class RelatorioEstoque extends Relatorio { sb.append(" AND DAB.ACTIVO = 1 "); sb.append(" AND AB.activo =1 AND AI.activo = 1 and est.estado_id = ai.ESTADO_ID "); sb.append(aidfTipo != null ? " AND (AI.AIDFTIPO_ID =:aidfTipo AND AIT.AIDFTIPO_ID = AI.AIDFTIPO_ID) " : " AND AIT.AIDFTIPO_ID = AI.AIDFTIPO_ID "); + sb.append(aidfId != null ? " AND (AI.AIDF_ID =:aidfId AND DAB.AIDF_ID = AI.AIDF_ID) " : " AND DAB.AIDF_ID = AI.AIDF_ID "); sb.append(" GROUP BY DAB.AIDF_ID, "); sb.append(" DAB.NUMSERIEPREIMPRESA, "); sb.append(" CJ.NUMFOLIOPREIMPRESO, "); @@ -326,12 +335,13 @@ public class RelatorioEstoque extends Relatorio { sb.append(" AND A.ARTICULO_ID = AB.ARTICULO_ID "); sb.append(" AND EM.EMPRESA_ID = AB.EMPRESA_ID "); sb.append(" AND M.EMPRESA_ID = EM.EMPRESA_ID "); - sb.append(" AND M.ACTIVO = 1 AND DAB.AIDF_ID = AI.AIDF_ID "); + sb.append(" AND M.ACTIVO = 1 "); sb.append(" AND CJ.USUARIO_ID = U.USUARIO_ID "); sb.append(" AND CJ.PUNTOVENTA_ID = PV.PUNTOVENTA_ID "); sb.append(" AND DAB.ACTIVO = 1 "); sb.append(" AND AB.activo =1 AND AI.activo = 1 and est.estado_id = ai.ESTADO_ID "); sb.append(aidfTipo != null ? " AND (AI.AIDFTIPO_ID =:aidfTipo AND AIT.AIDFTIPO_ID = AI.AIDFTIPO_ID) " : " AND AIT.AIDFTIPO_ID = AI.AIDFTIPO_ID "); + sb.append(aidfId != null ? " AND (AI.AIDF_ID =:aidfId AND DAB.AIDF_ID = AI.AIDF_ID) " : " AND DAB.AIDF_ID = AI.AIDF_ID "); sb.append(" GROUP BY DAB.AIDF_ID, "); sb.append(" DAB.NUMSERIEPREIMPRESA, "); sb.append(" CJ.NUMFOLIOPREIMPRESO, "); @@ -351,11 +361,13 @@ public class RelatorioEstoque extends Relatorio { sb.append(" ORDER BY TB.aidfId, "); sb.append(" TB.serie, "); sb.append(" TB.folioCaja "); + System.out.println(sb.toString()); + return sb.toString(); } - private String sQLretornarEstoque(String puntoVentaId, Date dataInicio, Date dataFim, Integer empresaId, Integer aidfTipo) { + private String sQLretornarEstoque(String puntoVentaId, Date dataInicio, Date dataFim, Integer empresaId, Integer aidfTipo, Integer aidfId) { StringBuilder queryString = new StringBuilder("SELECT DISTINCT to_date(to_char(ai.fecvencimiento, 'dd/MM/yyyy'), 'dd/MM/yyyy') as fecVencimento, to_date(to_char(AI.fecadquisicion, 'dd/MM/yyyy'), 'dd/MM/yyyy') as fechorAquisicion, ") .append("dab.NUMSERIEPREIMPRESA as serie, ") @@ -413,7 +425,8 @@ public class RelatorioEstoque extends Relatorio { .append("AND dab.ACTIVO = 1 ") .append(" and dab.NUMFOLIOFINAL < 2147483647 ") .append(" AND DAB.AIDF_ID = AI.AIDF_ID and ai.activo = 1 ") - .append(aidfTipo != null ? " AND AI.AIDFTIPO_ID = :aidfTipo " : " "); + .append(aidfTipo != null ? " AND AI.AIDFTIPO_ID = :aidfTipo " : " ") + .append(aidfId != null ? " AND AI.AIDF_ID = :aidfId " : " "); @@ -471,7 +484,8 @@ public class RelatorioEstoque extends Relatorio { ItemReporteStockBoletos.setFolioInicial(String.valueOf(a[i - length])); ItemReporteStockBoletos.setFolioAtual(String.valueOf(a[i - length])); - ItemReporteStockBoletos.setFolioFinal(String.valueOf(a[i - length])); + ItemReporteStockBoletos.setFolioFinal(String.valueOf(a[i - length])); + ItemReporteStockBoletos.setQuantidade(calcularQuantidade(ItemReporteStockBoletos.getFolioInicial(), ItemReporteStockBoletos.getFolioFinal())); list.add(ItemReporteStockBoletos); } } @@ -479,7 +493,8 @@ public class RelatorioEstoque extends Relatorio { ItemReporteStockBoletos.setFolioInicial(String.valueOf(a[i - length])); ItemReporteStockBoletos.setFolioAtual(String.valueOf(a[i - length])); - ItemReporteStockBoletos.setFolioFinal(String.valueOf(a[i - 1])); + ItemReporteStockBoletos.setFolioFinal(String.valueOf(a[i - 1])); + ItemReporteStockBoletos.setQuantidade(calcularQuantidade(ItemReporteStockBoletos.getFolioInicial(), ItemReporteStockBoletos.getFolioFinal())); list.add(ItemReporteStockBoletos); } length = 1; @@ -492,6 +507,14 @@ public class RelatorioEstoque extends Relatorio { return list; } + private Integer calcularQuantidade(String folioInicial, String folioFinal) { + + Integer folioInicialInt = Integer.valueOf(folioInicial); + Integer folioFinalInt = Integer.valueOf(folioFinal); + return folioInicialInt == folioFinalInt ? 1 : (folioFinalInt - folioInicialInt); + + } + private int[] recuperarOsFaltantes(List listEstoque) { int arrayTemp[] = null; ItemReporteControleEstoqueBoletos item = new ItemReporteControleEstoqueBoletos(); diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout_es.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout_es.properties new file mode 100644 index 000000000..6128dbef4 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout_es.properties @@ -0,0 +1,20 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. + +#Labels cabeçalho +cabecalho.relatorio=Relatório: +cabecalho.periodo=Período: +cabecalho.periodoA=à +cabecalho.dataHora=Data/Hora: +cabecalho.impressorPor=Impressor por: +cabecalho.pagina=Página +cabecalho.de=de +cabecalho.filtros=Filtros: + +#Labels header +label.aidf=AIDF +label.empresa=Empresa +label.agencia=Agencia +label.serie=Serie +label.bilhete=Bilhetes +label.numeracao=Numeração diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout_pt_BR.properties b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout_pt_BR.properties new file mode 100644 index 000000000..6128dbef4 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/internacionalizacao/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout_pt_BR.properties @@ -0,0 +1,20 @@ +#geral +msg.noData=Não foi possivel obter dados com os parâmetros informados. + +#Labels cabeçalho +cabecalho.relatorio=Relatório: +cabecalho.periodo=Período: +cabecalho.periodoA=à +cabecalho.dataHora=Data/Hora: +cabecalho.impressorPor=Impressor por: +cabecalho.pagina=Página +cabecalho.de=de +cabecalho.filtros=Filtros: + +#Labels header +label.aidf=AIDF +label.empresa=Empresa +label.agencia=Agencia +label.serie=Serie +label.bilhete=Bilhetes +label.numeracao=Numeração diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout.jasper new file mode 100644 index 000000000..538f59b74 Binary files /dev/null and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout.jrxml new file mode 100644 index 000000000..5022f1d4f --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout.jrxml @@ -0,0 +1,264 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioEstoque.jasper b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioEstoque.jasper index 9ee375011..5a7fcefac 100644 Binary files a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioEstoque.jasper and b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioEstoque.jasper differ diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioEstoque.jrxml b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioEstoque.jrxml index 0d3a83fcb..db3af0ce5 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioEstoque.jrxml +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/templates/RelatorioEstoque.jrxml @@ -1,8 +1,8 @@ - - - + + + @@ -24,6 +24,7 @@ + @@ -111,7 +112,7 @@ - + @@ -146,7 +147,7 @@ - + @@ -173,6 +174,13 @@ + + + + + + + @@ -193,7 +201,7 @@ - + @@ -230,7 +238,7 @@ - + @@ -257,6 +265,14 @@ + + + + + + + + diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/ItemReporteControleEstoqueBoletos.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/ItemReporteControleEstoqueBoletos.java index c5f758c1e..f61a7f4c0 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/ItemReporteControleEstoqueBoletos.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/ItemReporteControleEstoqueBoletos.java @@ -32,6 +32,7 @@ public class ItemReporteControleEstoqueBoletos { private Integer numfoliopreimpreso; private String ID; private String tipoAidf; + private Integer quantidade; public Integer getEstacionId() { @@ -191,6 +192,13 @@ public class ItemReporteControleEstoqueBoletos { public void setTipoAidf(String tipoAidf) { this.tipoAidf = tipoAidf; } + + public Integer getQuantidade() { + return quantidade; + } + public void setQuantidade(Integer quantidade) { + this.quantidade = quantidade; + } @Override public int hashCode() { final int prime = 31; diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioBilhetesVendidosEstoqueAgenciaBean.java b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioBilhetesVendidosEstoqueAgenciaBean.java index 50ef35b41..f68accf92 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioBilhetesVendidosEstoqueAgenciaBean.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/utilitarios/RelatorioBilhetesVendidosEstoqueAgenciaBean.java @@ -1,5 +1,6 @@ package com.rjconsultores.ventaboletos.relatorios.utilitarios; +import java.math.BigDecimal; import java.util.Date; public class RelatorioBilhetesVendidosEstoqueAgenciaBean { @@ -16,6 +17,10 @@ public class RelatorioBilhetesVendidosEstoqueAgenciaBean { private String range; private String chave; private String folio; + private String origem; + private String destino; + private BigDecimal valorContabil; + private String estado; public RelatorioBilhetesVendidosEstoqueAgenciaBean(RelatorioBilhetesVendidosEstoqueAgenciaBean bean) { @@ -107,5 +112,37 @@ public class RelatorioBilhetesVendidosEstoqueAgenciaBean { public void setFolio(String folio) { this.folio = folio; } + + public String getOrigem() { + return origem; + } + + public void setOrigem(String origem) { + this.origem = origem; + } + + public String getDestino() { + return destino; + } + + public void setDestino(String destino) { + this.destino = destino; + } + + public BigDecimal getValorContabil() { + return valorContabil; + } + + public void setValorContabil(BigDecimal valorContabil) { + this.valorContabil = valorContabil; + } + + public String getEstado() { + return estado; + } + + public void setEstado(String estado) { + this.estado = estado; + } } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAidfDetalhadoController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAidfDetalhadoController.java index 2536e9801..5745bcaa2 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAidfDetalhadoController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioAidfDetalhadoController.java @@ -2,6 +2,8 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.relatorios; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -19,16 +21,20 @@ import org.zkoss.zul.Bandbox; import org.zkoss.zul.Combobox; import org.zkoss.zul.Comboitem; import org.zkoss.zul.Datebox; +import org.zkoss.zul.Intbox; import org.zkoss.zul.Paging; import org.zkoss.zul.Textbox; +import com.rjconsultores.ventaboletos.entidad.Aidf; import com.rjconsultores.ventaboletos.entidad.AidfTipo; import com.rjconsultores.ventaboletos.entidad.Empresa; import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioEstoque; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; +import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioBilhetesVendidosEstoqueAgenciaBean; import com.rjconsultores.ventaboletos.service.AidfService; import com.rjconsultores.ventaboletos.service.EmpresaService; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.MyComboboxEstandar; import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; @@ -55,6 +61,9 @@ public class RelatorioAidfDetalhadoController extends MyGenericForwardComposer { private Textbox txtFimForm; private List lsAidfTipo; private Combobox cmbAidfTipo; + private Intbox aidfIdIntBox; + + @Autowired private transient PagedListWrapper plwPuntoVenta; @@ -81,6 +90,7 @@ public class RelatorioAidfDetalhadoController extends MyGenericForwardComposer { puntoVentaList.setItemRenderer(new RenderRelatorioVendasBilheteiro()); puntoVentaSelList.setItemRenderer(new RenderRelatorioVendasBilheteiroSelecionados()); lsAidfTipo = aidfService.obtenerTodosAdifTipo(); + } /** @@ -138,6 +148,15 @@ public class RelatorioAidfDetalhadoController extends MyGenericForwardComposer { } else { filtro.append(" Todas; "); } + + + if (aidfIdIntBox.getValue() != null) { + Integer aidfId = aidfIdIntBox.getValue(); + parametros.put("AIDF_ID", aidfId ); + filtro.append(aidfId + ";"); + } else { + filtro.append(" Todas; "); + } parametros.put("FILTROS", filtro.toString()); relatorio = new RelatorioEstoque(parametros, dataSourceRead.getConnection()); @@ -302,6 +321,7 @@ public class RelatorioAidfDetalhadoController extends MyGenericForwardComposer { public void setLsAidfTipo(List lsAidfTipo) { this.lsAidfTipo = lsAidfTipo; - } - + } + + } diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosEstoqueAgenciaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosEstoqueAgenciaController.java index c185a1e2f..84a1ec6bf 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosEstoqueAgenciaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/relatorios/RelatorioBilhetesVendidosEstoqueAgenciaController.java @@ -31,6 +31,7 @@ import com.rjconsultores.ventaboletos.entidad.PuntoVenta; import com.rjconsultores.ventaboletos.enums.IndStatusBoleto; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBilhetesVendidos; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBilhetesVendidosEstoqueAgencia; +import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout; import com.rjconsultores.ventaboletos.relatorios.impl.RelatorioBilhetesVendidosNovoLayout; import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio; import com.rjconsultores.ventaboletos.service.AidfService; @@ -135,7 +136,7 @@ public class RelatorioBilhetesVendidosEstoqueAgenciaController extends MyGeneric executarRelatorio(false); } - public void onClick$btnExecutarRelatorioNovoLayout(Event ev) throws Exception { + public void onClick$btnExecutarRelatorioConsumoDetalhado(Event ev) throws Exception { executarRelatorio(true); } @@ -200,13 +201,17 @@ public class RelatorioBilhetesVendidosEstoqueAgenciaController extends MyGeneric filtro.append(" Todas; "); } - relatorio = new RelatorioBilhetesVendidosEstoqueAgencia(parametros, dataSourceRead.getConnection()); + if(novoLayout) { + relatorio = new RelatorioBilhetesVendidosEstoqueAgenciaNovoLayout(parametros, dataSourceRead.getConnection()); + }else{ + relatorio = new RelatorioBilhetesVendidosEstoqueAgencia(parametros, dataSourceRead.getConnection()); + } parametros.put("FILTROS", filtro.toString()); Map args = new HashMap(); args.put("relatorio", relatorio); - openWindow("/component/reportView.zul", Labels.getLabel("relatorioBilhetesVendidosController.window.title"), args, MODAL); + openWindow("/component/reportView.zul", Labels.getLabel("relatorioBilhetesVendidosEstoqueAgenciaController.window.title"), args, MODAL); } public List getLsAidfTipo() { diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index 9c853bd15..ab5ab3fd8 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -1104,6 +1104,7 @@ relatorioAidfDetalhadoController.lbFormInicial.value = Form. Inicial relatorioAidfDetalhadoController.lbFormFinal.value = Form. Final relatorioAidfDetalhadoController.msg.agencia.obrigatorio = Uma Agência deve ser selecionada relatorioAidfDetalhadoController.aidfTipo.label=Tipo Aidf +relatorioAidfDetalhadoController.aidf.label=Aidf #Relatório de Vendas PTA relatorioVendasPTAController.window.title = Reporte de Ventas PTA diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 42be94bd3..60e365f78 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -1217,7 +1217,6 @@ relatorioAidfController.lbEmpresa.value = Empresa relatorioAidfController.lbSerie.value = Série #Relatorio Aidf Detalhado -relatorioAidfDetalhadoController.window.title = Relatório Estoque relatorioAidfDetalhadoController.datainicial.value = Data Inicial Aquisição relatorioAidfDetalhadoController.dataFinal.value = Data Final Aquisição relatorioAidfDetalhadoController.lbEmpresa.value = Empresa @@ -1226,6 +1225,9 @@ relatorioAidfDetalhadoController.lbFormInicial.value = Form. Inicial relatorioAidfDetalhadoController.lbFormFinal.value = Form. Final relatorioAidfDetalhadoController.msg.agencia.obrigatorio = Uma Agência deve ser selecionada relatorioAidfDetalhadoController.aidfTipo.label=Tipo Aidf +relatorioAidfDetalhadoController.aidf.label=Aidf ID +relatorioAidfDetalhadoController.window.title = Relatório Saldo de Estoque +relatorioBilhetesVendidosEstoqueAgenciaController.consumoEstoqueDetalhado.label = Consumo Estoque - Detalhado #Relatorio Movimentacao Estoque relatorioMovimentacaoEstoqueController.window.title = Relatório Movimentação de Estoque diff --git a/web/gui/relatorios/filtroRelatorioAidfDetalhado.zul b/web/gui/relatorios/filtroRelatorioAidfDetalhado.zul index d352b94d2..26743ab04 100644 --- a/web/gui/relatorios/filtroRelatorioAidfDetalhado.zul +++ b/web/gui/relatorios/filtroRelatorioAidfDetalhado.zul @@ -7,7 +7,7 @@ + height="340px" width="738px" border="normal"> @@ -89,6 +89,11 @@ + + +