git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@20579 d1611594-4594-4d17-8e1d-87c2c4800839
parent
b15423bdff
commit
2e6cb7746f
|
@ -1,14 +1,29 @@
|
|||
package com.rjconsultores.ventaboletos.dao;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
import com.rjconsultores.ventaboletos.service.TarifaOficialService;
|
||||
|
||||
|
||||
public interface TarifaOficialDAO {
|
||||
/**
|
||||
* See {@link TarifaOficialService#gerarTarifaANTT(Ruta)}
|
||||
* See {@link TarifaOficialService#gerarTarifaANTT(Integer)}
|
||||
* @param ruta
|
||||
* @return TODO
|
||||
*/
|
||||
public Integer gerarTarifaANTT(Ruta ruta);
|
||||
public Integer gerarTarifaANTT(Integer ruta);
|
||||
|
||||
/**
|
||||
* See {@link TarifaOficialService#atualizarTarifaANTT(Integer)}
|
||||
* @param rutaId
|
||||
* @param usuarioId TODO
|
||||
* @return TODO
|
||||
*/
|
||||
public Integer atualizarTarifaANTT(Integer rutaId, Integer usuarioId);
|
||||
|
||||
/**
|
||||
* * See {@link TarifaOficialService#copiarParaTarifa(VigenciaTarifa)}
|
||||
* @param vigenciaTarifa
|
||||
* @param usuarioId TODO
|
||||
*/
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.rjconsultores.ventaboletos.dao.hibernate;
|
||||
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
@ -7,8 +8,8 @@ import org.springframework.stereotype.Repository;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
|
||||
@Repository("tarifaOficialDAO")
|
||||
public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial, Integer> implements TarifaOficialDAO {
|
||||
|
@ -22,8 +23,8 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer gerarTarifaANTT(Ruta ruta) {
|
||||
Integer rutaId = (ruta == null)?null:ruta.getRutaId();
|
||||
public Integer gerarTarifaANTT(Integer rutaId) {
|
||||
|
||||
|
||||
String sql = sqlBuilder.getSQLTarifaOficial1(rutaId);
|
||||
|
||||
|
@ -32,4 +33,84 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
return qtd;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public Integer atualizarTarifaANTT(Integer rutaId, Integer usuarioId) {
|
||||
|
||||
String sql = sqlBuilder.getSQLTarifaOficial2(rutaId,usuarioId);
|
||||
|
||||
int qtd = getSession().createSQLQuery(sql).executeUpdate();
|
||||
|
||||
return qtd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("INSERT ");
|
||||
sb.append("INTO ");
|
||||
sb.append(" Tarifa ");
|
||||
sb.append(" ( ");
|
||||
sb.append(" precio, ");
|
||||
sb.append(" precioredabierto, ");
|
||||
sb.append(" tramo, ");
|
||||
sb.append(" marca, ");
|
||||
sb.append(" claseServicio, ");
|
||||
sb.append(" preciooriginal, ");
|
||||
sb.append(" moneda, ");
|
||||
sb.append(" vigenciaTarifa, ");
|
||||
sb.append(" statustarifa, ");
|
||||
sb.append(" activo, ");
|
||||
sb.append(" fecmodif, ");
|
||||
sb.append(" usuarioId, ");
|
||||
sb.append(" importetaxaembarque, ");
|
||||
sb.append(" importepedagio, ");
|
||||
sb.append(" importeoutros, ");
|
||||
sb.append(" importeseguro, ");
|
||||
sb.append(" orgaoConcedente, ");
|
||||
sb.append(" ruta, ");
|
||||
sb.append(" origen, ");
|
||||
sb.append(" destino ");
|
||||
sb.append(" ) ");
|
||||
sb.append("SELECT ");
|
||||
sb.append(" ");
|
||||
sb.append(" to.precio, ");
|
||||
sb.append(" to.precioredabierto, ");
|
||||
sb.append(" to.tramo, ");
|
||||
sb.append(" to.marca, ");
|
||||
sb.append(" to.claseServicio, ");
|
||||
sb.append(" to.preciooriginal, ");
|
||||
sb.append(" to.moneda, ");
|
||||
sb.append(" vt, ");
|
||||
sb.append(" to.statustarifa, ");
|
||||
sb.append(" to.activo, ");
|
||||
sb.append(" current_timestamp(), ");
|
||||
sb.append(" ").append(usuarioId).append(", ");
|
||||
sb.append(" to.importetaxaembarque, ");
|
||||
sb.append(" to.importepedagio, ");
|
||||
sb.append(" to.importeoutros, ");
|
||||
sb.append(" to.importeseguro, ");
|
||||
sb.append(" to.orgaoConcedente, ");
|
||||
sb.append(" to.ruta, ");
|
||||
sb.append(" to.origen, ");
|
||||
sb.append(" to.destino ");
|
||||
sb.append("FROM ");
|
||||
sb.append(" TarifaOficial to, ");
|
||||
sb.append(" VigenciaTarifa vt ");
|
||||
sb.append("WHERE ");
|
||||
sb.append(" to.activo =1 ");
|
||||
sb.append(" and vt.vigenciatarifaId = :vigenciaId ");
|
||||
|
||||
|
||||
Query query = getSession().createQuery("DELETE FROM Tarifa t where t.vigenciaTarifa = :vigencia");
|
||||
query.setParameter("vigencia",vigenciaTarifa);
|
||||
query.executeUpdate();
|
||||
|
||||
query = getSession().createQuery(sb.toString());
|
||||
query.setParameter("vigenciaId",vigenciaTarifa.getVigenciatarifaId());
|
||||
|
||||
query.executeUpdate();
|
||||
|
||||
}
|
||||
}
|
|
@ -16,4 +16,6 @@ public interface SQLBuilder {
|
|||
|
||||
public String getSQLTarifaOficial1(Integer codRuta);
|
||||
|
||||
public String getSQLTarifaOficial2(Integer rutaId, Integer usuarioId);
|
||||
|
||||
}
|
||||
|
|
|
@ -93,4 +93,56 @@ public class SQLBuilderOracle implements SQLBuilder {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTarifaOficial2(Integer rutaId, Integer usuarioId) {
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
|
||||
sb.append("UPDATE TARIFA_OFICIAL SET PRECIO = ");
|
||||
sb.append("( ");
|
||||
sb.append("select ");
|
||||
sb.append(" ");
|
||||
sb.append(" ROUND( ");
|
||||
sb.append(" coalesce(ct1.coeficiente,0) * coalesce(tc.kmcoeficiente1,0) + ");
|
||||
sb.append(" coalesce(ct2.coeficiente,0) * coalesce(tc.kmcoeficiente2,0) + ");
|
||||
sb.append(" coalesce(ct3.coeficiente,0) * coalesce(tc.kmcoeficiente3,0),2) + 200 ");
|
||||
sb.append(" ");
|
||||
sb.append("from ");
|
||||
sb.append(" ruta_combinacion rc ");
|
||||
sb.append(" inner join ruta r on r.ruta_id = rc.ruta_id ");
|
||||
sb.append(" inner join orgao_tramo tc on tc.tramo_id = rc.tramo_id ");
|
||||
sb.append(" inner join orgao_concedente oc on oc.orgaoconcedente_id = tc.orgaoconcedente_id and oc.orgaoconcedente_id =r.orgaoconcedente_id ");
|
||||
sb.append(" inner join coeficiente_tarifa ct1 on ct1.coeficientetarifa_id = tc.coeficientetarifa1_id ");
|
||||
sb.append(" left join coeficiente_tarifa ct2 on ct2.coeficientetarifa_id = tc.coeficientetarifa2_id ");
|
||||
sb.append(" left join coeficiente_tarifa ct3 on ct3.coeficientetarifa_id = tc.coeficientetarifa3_id ");
|
||||
sb.append(" inner join tramo t on t.tramo_id = rc.tramo_id ");
|
||||
sb.append(" inner join parada po on po.parada_id = t.origen_id ");
|
||||
sb.append(" inner join parada pd on pd.parada_id = t.destino_id ");
|
||||
sb.append(" inner join MARCA_CLASESERVICIO mc on mc.CLASESERVICIO_ID = r.CLASESERVICIO_ID, ");
|
||||
sb.append(" moneda m ");
|
||||
sb.append(" ");
|
||||
sb.append("where ");
|
||||
sb.append(" rc.activo = 1 ");
|
||||
sb.append(" and r.activo = 1 ");
|
||||
sb.append(" and m.moneda_id = 1 ");
|
||||
sb.append(" and oc.orgaoconcedente_id = 3 ");
|
||||
sb.append(" and t.tramo_id = TARIFA_OFICIAL.tramo_id ");
|
||||
sb.append(" and mc.marca_id = TARIFA_OFICIAL.marca_id ");
|
||||
sb.append(" and r.CLASESERVICIO_ID = TARIFA_OFICIAL.CLASESERVICIO_ID ");
|
||||
sb.append(" and m.moneda_id = TARIFA_OFICIAL.moneda_id ");
|
||||
sb.append(" and oc.orgaoconcedente_id = TARIFA_OFICIAL.orgaoconcedente_id ");
|
||||
sb.append(" and r.ruta_id = TARIFA_OFICIAL.ruta_id ");
|
||||
sb.append(") ");
|
||||
sb.append(" ");
|
||||
sb.append(", usuario_id = ").append(usuarioId).append(",fecmodif = sysdate ");
|
||||
sb.append(" ");
|
||||
sb.append("where ");
|
||||
sb.append(" activo = 1 ");
|
||||
if (rutaId != null){
|
||||
sb.append(" ruta_id = ").append(rutaId);
|
||||
}
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -8,4 +8,9 @@ public class SQLBuilderSQLServer implements SQLBuilder {
|
|||
public String getSQLTarifaOficial1(Integer codRuta) {
|
||||
throw new RuntimeException("SQL getSQLTarifaOficial1 não implementado");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTarifaOficial2(Integer rutaId, Integer usuarioId) {
|
||||
throw new RuntimeException("SQL getSQLTarifaOficial2 não implementado");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,6 +41,14 @@ public class Tarifa implements Serializable {
|
|||
private Integer tarifaId;
|
||||
@Column(name = "PRECIO")
|
||||
private BigDecimal precio;
|
||||
@Column(name = "IMPORTETAXAEMBARQUE")
|
||||
private BigDecimal importetaxaembarque;
|
||||
@Column(name = "IMPORTEPEDAGIO")
|
||||
private BigDecimal importepedagio;
|
||||
@Column(name = "IMPORTEOUTROS")
|
||||
private BigDecimal importeoutros;
|
||||
@Column(name = "IMPORTESEGURO")
|
||||
private BigDecimal importeseguro;
|
||||
@Column(name = "PRECIOORIGINAL")
|
||||
private BigDecimal preciooriginal;
|
||||
@Column(name = "STATUSTARIFA")
|
||||
|
@ -293,4 +301,36 @@ public class Tarifa implements Serializable {
|
|||
public String toString() {
|
||||
return "com.rjconsultores.ventaboletos.entidad.Tarifa[tarifaId=" + tarifaId + "]";
|
||||
}
|
||||
|
||||
public BigDecimal getImportetaxaembarque() {
|
||||
return importetaxaembarque;
|
||||
}
|
||||
|
||||
public void setImportetaxaembarque(BigDecimal importetaxaembarque) {
|
||||
this.importetaxaembarque = importetaxaembarque;
|
||||
}
|
||||
|
||||
public BigDecimal getImportepedagio() {
|
||||
return importepedagio;
|
||||
}
|
||||
|
||||
public void setImportepedagio(BigDecimal importepedagio) {
|
||||
this.importepedagio = importepedagio;
|
||||
}
|
||||
|
||||
public BigDecimal getImporteoutros() {
|
||||
return importeoutros;
|
||||
}
|
||||
|
||||
public void setImporteoutros(BigDecimal importeoutros) {
|
||||
this.importeoutros = importeoutros;
|
||||
}
|
||||
|
||||
public BigDecimal getImporteseguro() {
|
||||
return importeseguro;
|
||||
}
|
||||
|
||||
public void setImporteseguro(BigDecimal importeseguro) {
|
||||
this.importeseguro = importeseguro;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,14 @@ public class TarifaOficial implements Serializable {
|
|||
private BigDecimal precio;
|
||||
@Column(name = "PRECIOORIGINAL")
|
||||
private BigDecimal preciooriginal;
|
||||
@Column(name = "IMPORTETAXAEMBARQUE")
|
||||
private BigDecimal importetaxaembarque;
|
||||
@Column(name = "IMPORTEPEDAGIO")
|
||||
private BigDecimal importepedagio;
|
||||
@Column(name = "IMPORTEOUTROS")
|
||||
private BigDecimal importeoutros;
|
||||
@Column(name = "IMPORTESEGURO")
|
||||
private BigDecimal importeseguro;
|
||||
@Column(name = "STATUSTARIFA")
|
||||
private String statustarifa;
|
||||
@Column(name = "ACTIVO")
|
||||
|
@ -245,4 +253,44 @@ public class TarifaOficial implements Serializable {
|
|||
public String toString() {
|
||||
return "com.rjconsultores.ventaboletos.entidad.TarifaOficial[tarifaOficialId=" + tarifaOficialId + "]";
|
||||
}
|
||||
|
||||
|
||||
public BigDecimal getImportetaxaembarque() {
|
||||
return importetaxaembarque;
|
||||
}
|
||||
|
||||
|
||||
public void setImportetaxaembarque(BigDecimal importetaxaembarque) {
|
||||
this.importetaxaembarque = importetaxaembarque;
|
||||
}
|
||||
|
||||
|
||||
public BigDecimal getImportepedagio() {
|
||||
return importepedagio;
|
||||
}
|
||||
|
||||
|
||||
public void setImportepedagio(BigDecimal importepedagio) {
|
||||
this.importepedagio = importepedagio;
|
||||
}
|
||||
|
||||
|
||||
public BigDecimal getImporteoutros() {
|
||||
return importeoutros;
|
||||
}
|
||||
|
||||
|
||||
public void setImporteoutros(BigDecimal importeoutros) {
|
||||
this.importeoutros = importeoutros;
|
||||
}
|
||||
|
||||
|
||||
public BigDecimal getImporteseguro() {
|
||||
return importeseguro;
|
||||
}
|
||||
|
||||
|
||||
public void setImporteseguro(BigDecimal importeseguro) {
|
||||
this.importeseguro = importeseguro;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,15 @@ import java.util.List;
|
|||
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
|
||||
public interface OrgaoConcedenteService extends GenericService<OrgaoConcedente, Integer> {
|
||||
public interface OrgaoConcedenteService {
|
||||
|
||||
public List<OrgaoConcedente> buscar(String desc);
|
||||
|
||||
|
||||
public List<OrgaoConcedente> obtenerTodos();
|
||||
|
||||
public OrgaoConcedente obtenerID(Integer id);
|
||||
|
||||
public OrgaoConcedente actualizacion(OrgaoConcedente entidad);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.rjconsultores.ventaboletos.service;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
|
||||
|
||||
public interface TarifaOficialService {
|
||||
|
||||
|
@ -12,10 +13,10 @@ public interface TarifaOficialService {
|
|||
*
|
||||
* Obs.: Essa operção apenas gera tarifas que ainda não estão geradas<br/>
|
||||
*
|
||||
* @param ruta
|
||||
* @param rutaId
|
||||
* @return A quantidade de registros afetadas
|
||||
*/
|
||||
public Integer gerarTarifaANTT(Ruta ruta);
|
||||
public Integer gerarTarifaANTT(Integer rutaId);
|
||||
|
||||
/**
|
||||
* Atualiza as tarifas de acordo o cálculo da ANTT<br/>
|
||||
|
@ -23,8 +24,15 @@ public interface TarifaOficialService {
|
|||
* Se o parametro ruta não for informado, será atualizado as tarifas para
|
||||
* todas as rutas da ANTT.<br/>
|
||||
*
|
||||
* @param ruta
|
||||
* @param rutaId
|
||||
* @return TODO
|
||||
*/
|
||||
public void atualizarTarifaANTT(Ruta ruta);
|
||||
public Integer atualizarTarifaANTT(Integer rutaId);
|
||||
|
||||
/**
|
||||
* Copia a tarifa oficial para a tabela de tarifa de acordo com a vigencia especificada
|
||||
* @param vigenciaTarifa
|
||||
*/
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa);
|
||||
|
||||
}
|
||||
|
|
|
@ -5,8 +5,9 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
import com.rjconsultores.ventaboletos.service.TarifaOficialService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
@Service("tarifaOficialService")
|
||||
public class TarifaOficialServiceImpl implements TarifaOficialService {
|
||||
|
@ -16,14 +17,20 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer gerarTarifaANTT(Ruta ruta) {
|
||||
return tarifaOficialDAO.gerarTarifaANTT(ruta);
|
||||
public Integer gerarTarifaANTT(Integer rutaId) {
|
||||
return tarifaOficialDAO.gerarTarifaANTT(rutaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void atualizarTarifaANTT(Ruta ruta) {
|
||||
// TODO Auto-generated method stub
|
||||
@Transactional
|
||||
public Integer atualizarTarifaANTT(Integer rutaId) {
|
||||
return tarifaOficialDAO.atualizarTarifaANTT(rutaId,UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa) {
|
||||
tarifaOficialDAO.copiarParaTarifa(vigenciaTarifa, UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue