fixes bug#0012788
dev: thiago qua: Correção efetuada. git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@87605 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
76a75aa751
commit
ce4aec16cb
|
@ -16,7 +16,6 @@ import java.util.Date;
|
|||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -25,12 +24,11 @@ import com.rjconsultores.ventaboletos.relatorios.utilitarios.ArrayDataSource;
|
|||
import com.rjconsultores.ventaboletos.relatorios.utilitarios.Relatorio;
|
||||
import com.rjconsultores.ventaboletos.relatorios.utilitarios.RelatorioAcompanhamentoEquivalenteBean;
|
||||
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.DateUtil;
|
||||
import com.rjconsultores.ventaboletos.utilerias.LocaleUtil;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
||||
|
||||
import net.sf.jasperreports.engine.JRParameter;
|
||||
|
||||
/**
|
||||
* @author Bruno H. G. Gouvêa <bruno@rjconsultores.com.br>
|
||||
*
|
||||
|
@ -45,21 +43,19 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio {
|
|||
|
||||
MPE(1), RECEITA_KM(2), RECEITA_VIAGEM(3), IAP(4), PAXKM(5), ABSOLUTO(6), EQ(7);
|
||||
|
||||
public final int valor;
|
||||
public final Integer valor;
|
||||
|
||||
IndicadorRelatorio(int valorOpcao) {
|
||||
IndicadorRelatorio(Integer valorOpcao) {
|
||||
valor = valorOpcao;
|
||||
}
|
||||
|
||||
public static IndicadorRelatorio fromInt(Integer value) {
|
||||
if (value != null) {
|
||||
for (IndicadorRelatorio b : IndicadorRelatorio.values()) {
|
||||
if (value.equals(b.valor)) {
|
||||
return b;
|
||||
}
|
||||
for (IndicadorRelatorio b : IndicadorRelatorio.values()) {
|
||||
if (b.valor.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
throw new IllegalArgumentException("Indicador inexistente.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +69,74 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio {
|
|||
|
||||
this.setCustomDataSource(new ArrayDataSource(this) {
|
||||
|
||||
@Override
|
||||
public void initDados() throws Exception {
|
||||
|
||||
this.prepareQuery();
|
||||
|
||||
Date dataInicial = (Date) this.relatorio.getParametros().get("DATA_MES");
|
||||
|
||||
while (this.resultSet.next()) {
|
||||
|
||||
Integer indicador = (Integer) this.relatorio.getParametros().get("INDICADOR");
|
||||
Integer rolOperativoId = this.resultSet.getInt("ROLOPERATIVO_ID");
|
||||
Integer corridaId = this.resultSet.getInt("CORRIDA_ID");
|
||||
Integer assentos = this.resultSet.getInt("ASSENTOS");
|
||||
Integer rutaId = this.resultSet.getInt("RUTA_ID");
|
||||
|
||||
String horario = this.resultSet.getString("HORARIO");
|
||||
boolean isServicoExtra = isTipoServicoExtra(this.resultSet.getString("TIPO_SERVICO"));
|
||||
|
||||
Map<String, Object> row = new HashMap<String, Object>();
|
||||
BigDecimal totalMes = BigDecimal.ZERO;
|
||||
Integer totalDias = 0;
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(dataInicial);
|
||||
cal.set(Calendar.DATE, 1);
|
||||
|
||||
List<RelatorioAcompanhamentoEquivalenteBean> ls = getValorByIndicador(corridaId, rolOperativoId, indicador, assentos, dataInicial, rutaId, horario, isServicoExtra);
|
||||
|
||||
// Roda todos os dias do mes
|
||||
for (int dia = 1; dia <= cal.getActualMaximum(Calendar.DATE); dia++) {
|
||||
|
||||
BigDecimal valor = null;
|
||||
RelatorioAcompanhamentoEquivalenteBean equivalenteBean = buscarAcompanhamentoEquivalente(ls, DateUtil.inicioFecha(cal.getTime()));
|
||||
|
||||
if (equivalenteBean != null) {
|
||||
valor = equivalenteBean.getValor();
|
||||
}
|
||||
|
||||
if (valor != null) {
|
||||
totalMes = totalMes.add(valor);
|
||||
totalDias++;
|
||||
}
|
||||
|
||||
if (valor != null) {
|
||||
row.put("LINHA", this.resultSet.getString("SIGLA"));
|
||||
row.put("LOTACAO", this.resultSet.getInt("ASSENTOS"));
|
||||
row.put("SERVICO", this.resultSet.getString("TIPO_SERVICO"));
|
||||
row.put("CODIGO", this.resultSet.getInt("CORRIDA_ID"));
|
||||
row.put("HORARIO", this.resultSet.getString("HORARIO"));
|
||||
row.put("INTERESTADUAL", this.resultSet.getString("INTERESTADUAL"));
|
||||
row.put("GRUPO_LINHA", this.resultSet.getString("GRUPO_LINHA"));
|
||||
|
||||
row.put(String.valueOf(cal.get(Calendar.DATE)), valor);
|
||||
}
|
||||
|
||||
if (cal.get(Calendar.DATE) < cal.getActualMaximum(Calendar.DATE))
|
||||
cal.add(Calendar.DATE, 1);
|
||||
}
|
||||
|
||||
if (totalMes != null && !totalMes.equals(BigDecimal.ZERO) && totalDias > 0) {
|
||||
row.put("MEDIA", totalMes.divide(BigDecimal.valueOf(totalDias), 4, RoundingMode.HALF_UP));
|
||||
row.put("TOTAL", totalMes);
|
||||
this.dados.add(row);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void prepareQuery() throws SQLException {
|
||||
|
||||
CONSTANTE_GRATUIDADE_CRIANCA = buscarConstante("GRATUIDADE_CRIANCA");
|
||||
|
@ -115,79 +179,8 @@ public class RelatorioAcompanhamentoEquivalentes extends Relatorio {
|
|||
|
||||
}
|
||||
|
||||
private boolean verificaTipoServicoExtra(String tipoServico) {
|
||||
if (StringUtils.equalsIgnoreCase(tipoServico, "Extra")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initDados() throws Exception {
|
||||
|
||||
this.prepareQuery();
|
||||
|
||||
Date dataInicial = (Date) this.relatorio.getParametros().get("DATA_MES");
|
||||
|
||||
while (this.resultSet.next()) {
|
||||
|
||||
Integer indicador = (Integer) this.relatorio.getParametros().get("INDICADOR");
|
||||
Integer rolOperativoId = this.resultSet.getInt("ROLOPERATIVO_ID");
|
||||
Integer corridaId = this.resultSet.getInt("CORRIDA_ID");
|
||||
Integer assentos = this.resultSet.getInt("ASSENTOS");
|
||||
Integer rutaId = this.resultSet.getInt("RUTA_ID");
|
||||
|
||||
String horario = this.resultSet.getString("HORARIO");
|
||||
boolean isServicoExtra = verificaTipoServicoExtra(this.resultSet.getString("TIPO_SERVICO"));
|
||||
|
||||
Map<String, Object> row = new HashMap<String, Object>();
|
||||
BigDecimal totalMes = BigDecimal.ZERO;
|
||||
Integer totalDias = 0;
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(dataInicial);
|
||||
cal.set(Calendar.DATE, 1);
|
||||
|
||||
List<RelatorioAcompanhamentoEquivalenteBean> ls = getValorByIndicador(corridaId, rolOperativoId, indicador, assentos, dataInicial, rutaId, horario, isServicoExtra);
|
||||
|
||||
// Roda todos os dias do mes
|
||||
for (int dia = 1; dia <= cal.getActualMaximum(Calendar.DATE); dia++) {
|
||||
|
||||
BigDecimal valor = null;
|
||||
RelatorioAcompanhamentoEquivalenteBean equivalenteBean = buscarAcompanhamentoEquivalente(ls, cal.getTime());
|
||||
|
||||
if (equivalenteBean != null) {
|
||||
valor = equivalenteBean.getValor();
|
||||
}
|
||||
|
||||
if (valor != null) {
|
||||
totalMes = totalMes.add(valor);
|
||||
totalDias++;
|
||||
}
|
||||
|
||||
if (valor != null) {
|
||||
row.put("LINHA", this.resultSet.getString("SIGLA"));
|
||||
row.put("LOTACAO", this.resultSet.getInt("ASSENTOS"));
|
||||
row.put("SERVICO", this.resultSet.getString("TIPO_SERVICO"));
|
||||
row.put("CODIGO", this.resultSet.getInt("CORRIDA_ID"));
|
||||
row.put("HORARIO", this.resultSet.getString("HORARIO"));
|
||||
row.put("INTERESTADUAL", this.resultSet.getString("INTERESTADUAL"));
|
||||
row.put("GRUPO_LINHA", this.resultSet.getString("GRUPO_LINHA"));
|
||||
|
||||
row.put(String.valueOf(cal.get(Calendar.DATE)), valor);
|
||||
}
|
||||
|
||||
if (cal.get(Calendar.DATE) < cal.getActualMaximum(Calendar.DATE))
|
||||
cal.add(Calendar.DATE, 1);
|
||||
}
|
||||
|
||||
if (totalMes != null && !totalMes.equals(BigDecimal.ZERO) && totalDias > 0) {
|
||||
row.put("MEDIA", totalMes.divide(BigDecimal.valueOf(totalDias), 4, RoundingMode.HALF_UP));
|
||||
row.put("TOTAL", totalMes);
|
||||
this.dados.add(row);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isTipoServicoExtra(String tipoServico) {
|
||||
return StringUtils.equalsIgnoreCase(tipoServico, "Extra");
|
||||
}
|
||||
|
||||
protected List<RelatorioAcompanhamentoEquivalenteBean> getValorByIndicador(Integer corridaId,
|
||||
|
|
|
@ -62,10 +62,6 @@ public class RelatorioAcompanhamentoEquivalentesController extends MyGenericForw
|
|||
*/
|
||||
private void executarRelatorio() throws Exception {
|
||||
|
||||
// Messagebox.show(Labels.getLabel("MSG.Error"),
|
||||
// Labels.getLabel("relatorioAcompanhamentoEquivalentesController.window.title"),
|
||||
// Messagebox.OK, Messagebox.INFORMATION);
|
||||
|
||||
Relatorio relatorio;
|
||||
Map<String, Object> parametros = new HashMap<String, Object>();
|
||||
|
||||
|
|
Loading…
Reference in New Issue