wilian 2016-10-10 17:36:31 +00:00
parent d46eb28e7d
commit 5eb39c958b
7 changed files with 68 additions and 7 deletions

View File

@ -25,6 +25,9 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
private static Logger log = Logger.getLogger(RelatorioVendasPacotesBoletos.class);
public static final Integer VENDIDOS = 1;
public static final Integer CANCELADOS = 0;
private SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
private List<RelatorioVendasPacotesBoletosBean> lsDadosRelatorio;
@ -38,6 +41,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
private Integer destinoId;
private Integer usuarioId;
private Integer tipoTarifaPacoteId;
private Integer situacaoBilheteId;
public RelatorioVendasPacotesBoletos(Map<String, Object> parametros, Connection conexao, final String... nomeSubReporte) throws Exception {
super(parametros, conexao);
@ -57,11 +61,17 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
destinoId = parametros.get("destinoId") != null && !parametros.get("destinoId").equals("null") ? Integer.valueOf(parametros.get("destinoId").toString()) : null;
usuarioId = parametros.get("usuarioId") != null && !parametros.get("usuarioId").equals("null") ? Integer.valueOf(parametros.get("usuarioId").toString()) : null;
tipoTarifaPacoteId = parametros.get("tipoTarifaPacoteId") != null && !parametros.get("tipoTarifaPacoteId").equals("null") ? Integer.valueOf(parametros.get("tipoTarifaPacoteId").toString()) : null;
situacaoBilheteId = parametros.get("situacaoBilheteId") != null && !parametros.get("situacaoBilheteId").equals("null") ? Integer.valueOf(parametros.get("situacaoBilheteId").toString()) : null;
Connection conexao = this.relatorio.getConexao();
processarVendasPacote(conexao);
processarVendasAvulsas(conexao);
processarVendasAvulsasCancelados(conexao);
if(situacaoBilheteId == null || !CANCELADOS.equals(situacaoBilheteId)) {
processarVendasAvulsas(conexao);
}
if(situacaoBilheteId == null || CANCELADOS.equals(situacaoBilheteId)) {
processarVendasAvulsasCancelados(conexao);
}
processarVendasPacoteTotais();
setNomeSubReporte(nomeSubReporte);
@ -76,7 +86,7 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
NamedParameterStatement stmt = null;
try {
stmt = carregarNamedParameterStatementVendasPacotes(conexao, false);
stmt = carregarNamedParameterStatementVendasPacotes(conexao);
rset = stmt.executeQuery();
if(lsDadosRelatorio == null) {
@ -162,8 +172,8 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
return relatorioVendasPacotesBoletosBean;
}
private NamedParameterStatement carregarNamedParameterStatementVendasPacotes(Connection conexao, boolean cancelados) throws SQLException {
String sql = getSqlVendasPacotes(cancelados);
private NamedParameterStatement carregarNamedParameterStatementVendasPacotes(Connection conexao) throws SQLException {
String sql = getSqlVendasPacotes();
log.info(sql);
NamedParameterStatement stmt = new NamedParameterStatement(conexao, sql);
@ -195,11 +205,14 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
if(tipoTarifaPacoteId != null && tipoTarifaPacoteId > 0) {
stmt.setInt("tipoTarifaPacoteId", tipoTarifaPacoteId);
}
if(situacaoBilheteId != null) {
stmt.setInt("situacaoPacote",SituacaoVendaPacote.CANCELADO.getShortValue());
}
return stmt;
}
protected String getSqlVendasPacotes(boolean cancelado) {
protected String getSqlVendasPacotes() {
StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT DES.CVEPARADA AS CVEDESTINO, ORI.CVEPARADA AS CVEORIGEM, ORI.DESCPARADA AS ORIGEM, DES.DESCPARADA AS DESTINO, R.NUMRUTA, R.DESCRUTA, PC.NOMCONVENIO, TTP.DESCTIPOTARIFA, VP.SITUACAO, ")
@ -255,6 +268,17 @@ public class RelatorioVendasPacotesBoletos extends Relatorio {
sQuery.append("AND TTP.TIPOTARIFAPACOTE_ID = :tipoTarifaPacoteId ");
}
if(situacaoBilheteId != null) {
}
if(situacaoBilheteId != null && !CANCELADOS.equals(situacaoBilheteId)) {
sQuery.append("AND VP.SITUACAO <> :situacaoPacote ");
}
if(situacaoBilheteId != null && CANCELADOS.equals(situacaoBilheteId)) {
sQuery.append("AND VP.SITUACAO = :situacaoPacote ");
}
sQuery.append("GROUP BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, R.NUMRUTA, R.DESCRUTA, PC.NOMCONVENIO, TTP.DESCTIPOTARIFA, VP.SITUACAO, 'PACOTE' ")
.append("ORDER BY DES.CVEPARADA, ORI.CVEPARADA, ORI.DESCPARADA, DES.DESCPARADA, R.NUMRUTA, R.DESCRUTA, PC.NOMCONVENIO, TTP.DESCTIPOTARIFA, VP.SITUACAO, 'PACOTE' ");

View File

@ -16,6 +16,7 @@ cabecalho.origem=Origem:
cabecalho.destino=Destino:
cabecalho.usuario=Usuário:
cabecalho.tipoTarifaPacote=Tipo Tarifa:
cabecalho.situacaoBilhete=Situação:
label.empresa=Empresa:
label.trecho=Trecho:
label.cancelados = - CANCELADOS

View File

@ -16,6 +16,7 @@ cabecalho.origem=Origem:
cabecalho.destino=Destino:
cabecalho.usuario=Usuário:
cabecalho.tipoTarifaPacote=Tipo Tarifa:
cabecalho.situacaoBilhete=Situação:
label.empresa=Empresa:
label.trecho=Trecho:
label.cancelados=- CANCELADOS

View File

@ -17,6 +17,7 @@
<parameter name="tipoTarifaPacote" class="java.lang.String"/>
<parameter name="periodoPacote" class="java.lang.String"/>
<parameter name="periodoVenda" class="java.lang.String"/>
<parameter name="situacaoBilhete" class="java.lang.String"/>
<queryString>
<![CDATA[]]>
</queryString>
@ -27,7 +28,7 @@
<band splitType="Stretch"/>
</background>
<title>
<band height="142" splitType="Stretch">
<band height="160" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="620" height="20" uuid="43b2c28d-4760-4890-b00d-25e931e79c74"/>
<textElement markup="none">
@ -84,6 +85,13 @@
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.periodoPacote} + " " + $P{periodoPacote}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="140" width="802" height="20" uuid="10191622-490c-4eb8-800c-efe85abed02b"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.situacaoBilhete} + " " + $P{situacaoBilhete}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>

View File

@ -20,6 +20,7 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.ComboitemRenderer;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Radio;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Parada;
@ -67,6 +68,9 @@ public class RelatorioVendasPacotesBoletosController extends MyGenericForwardCom
private MyComboboxParada cmbParadaDestino;
private MyComboboxParadaCve cmbParadaDestinoCve;
private MyComboboxUsuario cmbUsuario;
private Radio rTodos;
private Radio rVendidos;
private Radio rCancelados;
public List<Empresa> getLsEmpresa() {
return lsEmpresa;
@ -189,6 +193,15 @@ public class RelatorioVendasPacotesBoletosController extends MyGenericForwardCom
parametros.put("tipoTarifaPacote", tipoTarifaPacote.getDesctipotarifa());
}
parametros.put("situacaoBilhete", "Todos");
if(rVendidos.isChecked()) {
parametros.put("situacaoBilhete", "Vendidos");
parametros.put("situacaoBilheteId", RelatorioVendasPacotesBoletos.VENDIDOS);
} else if(rCancelados.isChecked()) {
parametros.put("situacaoBilhete", "Cancelados");
parametros.put("situacaoBilheteId", RelatorioVendasPacotesBoletos.CANCELADOS);
}
Relatorio relatorio = gerarRelatorioVendaPacotesBoletos(parametros);
Map<String, Object> args = new HashMap<String, Object>();

View File

@ -92,6 +92,20 @@
format="dd/MM/yyyy" lenient="false"
maxlength="10" />
</row>
<row spans="1,3">
<label
value="${c:l('relatorioVendasPacotesBoletosController.lbSituacaoBilhete.value')}" />
<radiogroup>
<radio id="rTodos"
label="${c:l('relatorioVendasPacotesBoletosController.lbSituacaoBilheteTodos.value')}"
checked="true"/>
<radio id="rVendidos"
label="${c:l('relatorioVendasPacotesBoletosController.lbSituacaoBilheteVendidos.value')}"/>
<radio id="rCancelados"
label="${c:l('relatorioVendasPacotesBoletosController.lbSituacaoBilheteCancelados.value')}"/>
</radiogroup>
</row>
</rows>
</grid>
<toolbar>