Fixes Bug #0009366
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@71604 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
715163ec89
commit
d54b17790d
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrador
|
||||
*/
|
||||
public interface FormaPagamentoAgenciaDAO extends GenericDAOInforme {
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.FormaPagamentoAgenciaDAO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrador
|
||||
*/
|
||||
@Repository("formaPagamentoAgenciaDAO")
|
||||
public class FormaPagamentoAgenciaDAOImpl implements FormaPagamentoAgenciaDAO {
|
||||
|
||||
private static final Logger log = Logger.getLogger(FormaPagamentoAgenciaDAOImpl.class);
|
||||
|
||||
private String getSql(Date dataInicio, Date dataFinal) {
|
||||
StringBuilder where = new StringBuilder();
|
||||
where.append(" WHERE 1 = 1 ");
|
||||
|
||||
if (dataInicio != null) {
|
||||
where.append(" AND c.fechorventa >= ? ");
|
||||
}
|
||||
|
||||
if (dataFinal != null) {
|
||||
where.append(" AND c.fechorventa <= ? ");
|
||||
}
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append(" select to_char(c.fechorventa, 'dd/mm/yyyy') as data, ");
|
||||
sql.append(" pv.PUNTOVENTA_ID as agencia, ");
|
||||
sql.append(" fp.DESCPAGO as forma_pagamento, ");
|
||||
sql.append(" sum(nvl(c.PRECIOPAGADO,0)) as tarifa, ");
|
||||
sql.append(" sum(nvl(c.IMPORTEPEDAGIO,0)) as pedagio, ");
|
||||
sql.append(" sum(nvl(c.IMPORTESEGURO,0)) as seguro, ");
|
||||
sql.append(" sum(nvl(c.IMPORTETAXAEMBARQUE,0)) as taxa, ");
|
||||
sql.append(" sum((c.PRECIOPAGADO + c.IMPORTEPEDAGIO + c.IMPORTESEGURO + c.IMPORTETAXAEMBARQUE)) as total, ");
|
||||
sql.append(" count(c.PRECIOPAGADO) as qtde ");
|
||||
sql.append(" from caja c ");
|
||||
sql.append(" join caja_formapago cfp on c.caja_id = cfp.caja_id ");
|
||||
sql.append(" join forma_pago fp on cfp.formapago_id = fp.formapago_id ");
|
||||
sql.append(" join punto_venta pv on pv.PUNTOVENTA_ID = c.PUNTOVENTA_ID ");
|
||||
sql.append(where);
|
||||
sql.append(" group by to_char(c.fechorventa, 'dd/mm/yyyy'), pv.PUNTOVENTA_ID, fp.DESCPAGO ");
|
||||
sql.append(" order by data, agencia, forma_pagamento");
|
||||
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
public ResultSet executarSQL(Connection conn, Map parameters) {
|
||||
Date dataInicio = (Date) parameters.get("dataInicio");
|
||||
Date dataFinal = (Date) parameters.get("dataFinal");
|
||||
String sql = getSql(dataInicio, dataFinal);
|
||||
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rset = null;
|
||||
|
||||
try {
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setDate(1, new java.sql.Date(dataInicio.getTime()));
|
||||
stmt.setDate(2, new java.sql.Date(dataFinal.getTime()));
|
||||
rset = stmt.executeQuery();
|
||||
} catch (Exception ex) {
|
||||
log.error(ex);
|
||||
}
|
||||
|
||||
return rset;
|
||||
}
|
||||
}
|
|
@ -20,6 +20,14 @@ public class ParadaSecuencia {
|
|||
private String kmReal = "";
|
||||
private String kmEntradaSaida = "";
|
||||
private String tempoReal = "";
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (parada != null) {
|
||||
return parada.toString();
|
||||
}
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
public ParadaSecuencia() {
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrador
|
||||
*/
|
||||
public interface FormaPagamentoAgenciaService extends GenericServiceInforme {
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.zkoss.util.media.AMedia;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.FormaPagamentoAgenciaDAO;
|
||||
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
||||
import com.rjconsultores.ventaboletos.service.FormaPagamentoAgenciaService;
|
||||
|
||||
import net.sf.jasperreports.engine.JRDataSource;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JRResultSetDataSource;
|
||||
import net.sf.jasperreports.engine.JasperRunManager;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrador
|
||||
*/
|
||||
@Service("formaPagamentoAgenciaService")
|
||||
public class FormaPagamentoAgenciaServiceImpl implements FormaPagamentoAgenciaService {
|
||||
|
||||
@Autowired
|
||||
private FormaPagamentoAgenciaDAO financeiroDAO;
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
private static final Logger log = Logger.getLogger(FormaPagamentoAgenciaServiceImpl.class);
|
||||
|
||||
public AMedia gerarInforme(InputStream informe, Map parameters) throws BusinessException {
|
||||
Connection conn = null;
|
||||
AMedia amedia = null;
|
||||
|
||||
try {
|
||||
conn = dataSource.getConnection();
|
||||
|
||||
ResultSet rs = financeiroDAO.executarSQL(conn, parameters);
|
||||
JRDataSource jrDataSource = new JRResultSetDataSource(rs);
|
||||
|
||||
Date dataInicio = (Date) parameters.get("dataInicio");
|
||||
Date dataFinal = (Date) parameters.get("dataFinal");
|
||||
Map<String, Object> args = new HashMap<String, Object>();
|
||||
args.put("dataInicio", dataInicio);
|
||||
args.put("dataFinal", dataFinal);
|
||||
final byte[] buf = JasperRunManager.runReportToPdf(informe, args, jrDataSource);
|
||||
|
||||
final InputStream mediais = new ByteArrayInputStream(buf);
|
||||
|
||||
amedia = new AMedia("financeiro.pdf", "pdf", null, mediais);
|
||||
} catch (JRException e) {
|
||||
log.error("Erro al generar reporte", e);
|
||||
throw new BusinessException("MSG.Error");
|
||||
} catch (SQLException e) {
|
||||
log.error("Error al obtener una conexcion en el datasource", e);
|
||||
throw new BusinessException("MSG.Error");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
log.error("Error al cerrar la conexion", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return amedia;
|
||||
}
|
||||
}
|
|
@ -466,7 +466,7 @@ public class TramoRutaServiceImpl implements TramoRutaService {
|
|||
for (ParadaSecuencia secuenciaDestino : secuenciasDestino) {
|
||||
|
||||
//O processo não é realizado na ordem inversa (em que a sequencia da origem é maior que a sequencia de seus destinos), considerando que esse é o processo inversa a ida ou a volta.
|
||||
if (secuencia.getOrigem().getSecuencia() > secuenciaDestino.getSecuencia()){
|
||||
if (secuencia.getOrigem().getSecuencia() >= secuenciaDestino.getSecuencia()){
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package com.rjconsultores.ventaboletos.vo.impressaofiscal;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class RelatorioFinanceiro {
|
||||
|
||||
private Date data;
|
||||
private String agencia;
|
||||
private String formaPagamento;
|
||||
private Double tarifa;
|
||||
private Double pedagio;
|
||||
private Double seguro;
|
||||
private Double taxas;
|
||||
private Double total;
|
||||
public Date getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(Date data) {
|
||||
this.data = data;
|
||||
}
|
||||
public String getAgencia() {
|
||||
return agencia;
|
||||
}
|
||||
public void setAgencia(String agencia) {
|
||||
this.agencia = agencia;
|
||||
}
|
||||
public String getFormaPagamento() {
|
||||
return formaPagamento;
|
||||
}
|
||||
public void setFormaPagamento(String formaPagamento) {
|
||||
this.formaPagamento = formaPagamento;
|
||||
}
|
||||
public Double getTarifa() {
|
||||
return tarifa;
|
||||
}
|
||||
public void setTarifa(Double tarifa) {
|
||||
this.tarifa = tarifa;
|
||||
}
|
||||
public Double getPedagio() {
|
||||
return pedagio;
|
||||
}
|
||||
public void setPedagio(Double pedagio) {
|
||||
this.pedagio = pedagio;
|
||||
}
|
||||
public Double getSeguro() {
|
||||
return seguro;
|
||||
}
|
||||
public void setSeguro(Double seguro) {
|
||||
this.seguro = seguro;
|
||||
}
|
||||
public Double getTaxas() {
|
||||
return taxas;
|
||||
}
|
||||
public void setTaxas(Double taxas) {
|
||||
this.taxas = taxas;
|
||||
}
|
||||
public Double getTotal() {
|
||||
return total;
|
||||
}
|
||||
public void setTotal(Double total) {
|
||||
this.total = total;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue