fixed bug #7589
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@58388 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
24960f82cc
commit
7859fc79d6
|
@ -12,4 +12,7 @@ public interface OrgaoConcedenteDAO extends GenericDAO<OrgaoConcedente, Integer>
|
|||
|
||||
public List<Integer> obtenerTodosIds() ;
|
||||
|
||||
public List<OrgaoConcedente> obtenerTodosExceto(Integer... id);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.rjconsultores.ventaboletos.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
|
@ -38,8 +40,10 @@ public interface TarifaOficialDAO extends GenericDAO<TarifaOficial, Integer>{
|
|||
* @param calculaPegagio Boolean
|
||||
* @param calculaTarifa Boolean
|
||||
* @param calculaTaxaEmbarque Boolean
|
||||
* @param empresa Empresa
|
||||
* @param orgaoConcedente OrgaoConcedente
|
||||
*/
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro);
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Empresa empresa, OrgaoConcedente orgaoConcedente);
|
||||
|
||||
/**
|
||||
* See {@link TarifaOficialService#atualizarTaxaEmbarque(Integer, Integer)}
|
||||
|
|
|
@ -32,6 +32,16 @@ public class OrgaoConcedenteHibernateDAO extends GenericHibernateDAO<OrgaoConced
|
|||
return c.list();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<OrgaoConcedente> obtenerTodosExceto(Integer... id) {
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
c.addOrder(Order.asc("descOrgao"));
|
||||
c.add(Restrictions.not(Restrictions.in("orgaoConcedenteId", id)));
|
||||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<Integer> obtenerTodosIds() {
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.springframework.stereotype.Repository;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
|
@ -78,7 +80,7 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
query.executeUpdate();
|
||||
}
|
||||
|
||||
private void apagarTarifasInativas(VigenciaTarifa vigenciaTarifa){
|
||||
private void apagarTarifasInativas(VigenciaTarifa vigenciaTarifa, Empresa empresa, OrgaoConcedente orgao) {
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
sb.append("select ");
|
||||
sb.append(" tar.tarifaId ");
|
||||
|
@ -95,36 +97,61 @@ public class TarifaOficialHibernateDAO extends GenericHibernateDAO<TarifaOficial
|
|||
sb.append(" and tar.ruta=tao.ruta ");
|
||||
sb.append(" and tar.vigenciaTarifa.vigenciatarifaId = :vigenciaId ");
|
||||
|
||||
Query query = null;
|
||||
if (orgao != null) {
|
||||
sb.append(" and tar.orgaoConcedente = :orgao ");
|
||||
}
|
||||
if (empresa != null) {
|
||||
sb.append(" and tar.marca.empresa = :empresa ");
|
||||
}
|
||||
|
||||
query = getSession().createQuery("DELETE FROM TarifaTipoptovta WHERE tarifa.tarifaId in (" + sb.toString()+ ")");
|
||||
Query query = getSession().createQuery("DELETE FROM TarifaTipoptovta WHERE tarifa.tarifaId in (" + sb.toString()+ ")");
|
||||
query.setParameter("vigenciaId", vigenciaTarifa.getVigenciatarifaId());
|
||||
|
||||
if (orgao != null) {
|
||||
query.setParameter("orgao", orgao);
|
||||
}
|
||||
if (empresa != null) {
|
||||
query.setParameter("empresa", empresa);
|
||||
}
|
||||
|
||||
int qtd = query.executeUpdate();
|
||||
log.info("qtd TarifaTipoptovta apagada = " + qtd);
|
||||
|
||||
query = getSession().createQuery("DELETE FROM TarifaCategoria WHERE tarifa.tarifaId in (" + sb.toString()+ ")");
|
||||
query.setParameter("vigenciaId", vigenciaTarifa.getVigenciatarifaId());
|
||||
if (orgao != null) {
|
||||
query.setParameter("orgao", orgao);
|
||||
}
|
||||
if (empresa != null) {
|
||||
query.setParameter("empresa", empresa);
|
||||
}
|
||||
|
||||
qtd = query.executeUpdate();
|
||||
log.info("qtd TarifaCategoria apagada = " + qtd);
|
||||
|
||||
query = getSession().createQuery("DELETE FROM Tarifa WHERE activo = 0 and tarifaId in (" + sb.toString()+ ")");
|
||||
query.setParameter("vigenciaId", vigenciaTarifa.getVigenciatarifaId());
|
||||
if (orgao != null) {
|
||||
query.setParameter("orgao", orgao);
|
||||
}
|
||||
if (empresa != null) {
|
||||
query.setParameter("empresa", empresa);
|
||||
}
|
||||
|
||||
qtd = query.executeUpdate();
|
||||
log.info("qtd Tarifa apagada = " + qtd);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro) {
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Empresa empresa, OrgaoConcedente orgaoConcedente) {
|
||||
//Apago antes as tarifas que podem estar como activo =0
|
||||
apagarTarifasInativas(vigenciaTarifa);
|
||||
apagarTarifasInativas(vigenciaTarifa, empresa, orgaoConcedente);
|
||||
|
||||
// Insiro as tarifas que não existem
|
||||
SQLQuery querySQL = getSession().createSQLQuery(sqlBuilder.getSQLInserirTarifaPelaTarifaOficial(vigenciaTarifa.getVigenciatarifaId(), usuarioId));
|
||||
SQLQuery querySQL = getSession().createSQLQuery(sqlBuilder.getSQLInserirTarifaPelaTarifaOficial(vigenciaTarifa.getVigenciatarifaId(), usuarioId, empresa, orgaoConcedente));
|
||||
querySQL.executeUpdate();
|
||||
// Atualizo o preço e o componente dos preços que já existem
|
||||
querySQL = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTarifaPorTarifaOfical(vigenciaTarifa.getVigenciatarifaId(), usuarioId, calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro));
|
||||
querySQL = getSession().createSQLQuery(sqlBuilder.getSQLAtualizarTarifaPorTarifaOfical(vigenciaTarifa.getVigenciatarifaId(), usuarioId, calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, empresa, orgaoConcedente));
|
||||
querySQL.executeUpdate();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.rjconsultores.ventaboletos.dao.sqlbuilder;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import com.rjconsultores.ventaboletos.vo.caja.CajaVO;
|
||||
|
||||
/**
|
||||
|
@ -37,9 +39,9 @@ public interface SQLBuilder {
|
|||
|
||||
public String getSQLAtualizarSeguroPorTarifa(Integer rutaId, Integer usuarioId, Integer orgaoConcedenteId);
|
||||
|
||||
public String getSQLAtualizarTarifaPorTarifaOfical(Integer vigenciaTarifaId, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro);
|
||||
public String getSQLAtualizarTarifaPorTarifaOfical(Integer vigenciaTarifaId, Integer usuarioId, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Empresa empresa, OrgaoConcedente orgao);
|
||||
|
||||
public String getSQLInserirTarifaPelaTarifaOficial(Integer vigenciaTarifaId, Integer usuarioId);
|
||||
public String getSQLInserirTarifaPelaTarifaOficial(Integer vigenciaTarifaId, Integer usuarioId, Empresa empresa, OrgaoConcedente orgao);
|
||||
|
||||
public String getSQLActualizarCorridaFecHusoFecVerano();
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import java.util.List;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.sqlbuilder.SQLBuilder;
|
||||
import com.rjconsultores.ventaboletos.dao.util.DBUtil;
|
||||
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
||||
|
||||
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
public class SQLBuilderOracle implements SQLBuilder {
|
||||
private static final Integer HORAS_NO_DIA = Integer.valueOf(24);
|
||||
private static final Integer RED_PAGO_FORMAPAGO_ID = Integer.valueOf(95);
|
||||
|
@ -658,7 +658,7 @@ public class SQLBuilderOracle implements SQLBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAtualizarTarifaPorTarifaOfical(final Integer vigenciaTarifaId, final Integer usuarioId, final Boolean calculaPegagio, final Boolean calculaTarifa, final Boolean calculaTaxaEmbarque, final Boolean calculaSeguro) {
|
||||
public String getSQLAtualizarTarifaPorTarifaOfical(final Integer vigenciaTarifaId, final Integer usuarioId, final Boolean calculaPegagio, final Boolean calculaTarifa, final Boolean calculaTaxaEmbarque, final Boolean calculaSeguro, Empresa empresa, OrgaoConcedente orgao) {
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
sb.append("update ( ");
|
||||
sb.append(" ");
|
||||
|
@ -685,8 +685,15 @@ public class SQLBuilderOracle implements SQLBuilder {
|
|||
sb.append(" and tao.moneda_id = ta.moneda_id ");
|
||||
sb.append(" and tao.ruta_id = ta.ruta_id ");
|
||||
sb.append(" and tao.orgaoconcedente_id = ta.orgaoconcedente_id ");
|
||||
sb.append(" inner join marca m ON tao.marca_id = m.marca_id ");
|
||||
sb.append("where ");
|
||||
sb.append(" ta.vigenciatarifa_id = ").append(vigenciaTarifaId);
|
||||
if(orgao != null){
|
||||
sb.append(" and tao.orgaoconcedente_id = ").append(orgao.getOrgaoConcedenteId());
|
||||
}
|
||||
if(empresa != null){
|
||||
sb.append(" and m.empresa_id = ").append(empresa.getEmpresaId());
|
||||
}
|
||||
sb.append(" ) set ");
|
||||
if (calculaPegagio) {
|
||||
sb.append(" taimportepedagio = taoimportepedagio,");
|
||||
|
@ -708,7 +715,7 @@ public class SQLBuilderOracle implements SQLBuilder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getSQLInserirTarifaPelaTarifaOficial(final Integer vigenciaTarifaId, final Integer usuarioId) {
|
||||
public String getSQLInserirTarifaPelaTarifaOficial(final Integer vigenciaTarifaId, final Integer usuarioId, Empresa empresa, OrgaoConcedente orgao) {
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
sb.append(" insert ");
|
||||
sb.append(" into ");
|
||||
|
@ -742,14 +749,24 @@ public class SQLBuilderOracle implements SQLBuilder {
|
|||
sb.append(" tao.DESTINO_ID ");
|
||||
sb.append(" from ");
|
||||
sb.append(" TARIFA_OFICIAL tao, ");
|
||||
sb.append(" VIGENCIA_TARIFA v ");
|
||||
sb.append(" VIGENCIA_TARIFA v, ");
|
||||
sb.append(" MARCA m ");
|
||||
sb.append(" where ");
|
||||
sb.append(" tao.ACTIVO=1 ");
|
||||
sb.append(" m.MARCA_ID=tao.MARCA_ID ");
|
||||
sb.append(" and tao.ACTIVO=1 ");
|
||||
sb.append(" and v.VIGENCIATARIFA_ID=").append(vigenciaTarifaId).append(" ");
|
||||
|
||||
if(orgao != null){
|
||||
sb.append(" and tao.ORGAOCONCEDENTE_ID=").append(orgao.getOrgaoConcedenteId()).append(" ");
|
||||
}
|
||||
if(empresa != null){
|
||||
sb.append(" and m.EMPRESA_ID=").append(empresa.getEmpresaId()).append(" ");
|
||||
}
|
||||
|
||||
sb.append(" and not (exists (select ");
|
||||
sb.append(" tar.TARIFA_ID ");
|
||||
sb.append(" from ");
|
||||
sb.append(" TARIFA tar ");
|
||||
sb.append(" TARIFA tar ");
|
||||
sb.append(" where ");
|
||||
sb.append(" tar.ACTIVO=1 ");
|
||||
sb.append(" and tar.TRAMO_ID=tao.TRAMO_ID ");
|
||||
|
|
|
@ -11,6 +11,8 @@ public interface OrgaoConcedenteService {
|
|||
|
||||
public List<OrgaoConcedente> obtenerTodos();
|
||||
|
||||
public List<OrgaoConcedente> obtenerTodosExceto(Integer... id);
|
||||
|
||||
public OrgaoConcedente obtenerID(Integer id);
|
||||
|
||||
public OrgaoConcedente actualizacion(OrgaoConcedente entidad);
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
|
||||
import com.rjconsultores.ventaboletos.dao.TarifaOficialDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.OrgaoConcedente;
|
||||
import com.rjconsultores.ventaboletos.entidad.Ruta;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarifaOficial;
|
||||
import com.rjconsultores.ventaboletos.entidad.VigenciaTarifa;
|
||||
|
@ -69,7 +70,7 @@ public interface TarifaOficialService {
|
|||
*
|
||||
* @param vigenciaTarifa
|
||||
*/
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro);
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro, Empresa empresa, OrgaoConcedente orgaoConcedente);
|
||||
|
||||
/**
|
||||
* Atualiza a taxa de embarque da entidade TarifaOficial.<br/>
|
||||
|
|
|
@ -56,4 +56,9 @@ public class OrgaoConcedenteServiceImpl implements OrgaoConcedenteService {
|
|||
public List<OrgaoConcedente> buscar(String desc) {
|
||||
return orgaoConcedenteDAO.buscar(desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrgaoConcedente> obtenerTodosExceto(Integer... id) {
|
||||
return orgaoConcedenteDAO.obtenerTodosExceto(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,8 +50,9 @@ public class TarifaOficialServiceImpl implements TarifaOficialService {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro) {
|
||||
tarifaOficialDAO.copiarParaTarifa(vigenciaTarifa, UsuarioLogado.getUsuarioLogado().getUsuarioId(), calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro);
|
||||
public void copiarParaTarifa(VigenciaTarifa vigenciaTarifa, Boolean calculaPegagio, Boolean calculaTarifa, Boolean calculaTaxaEmbarque, Boolean calculaSeguro,Empresa empresa, OrgaoConcedente orgaoConcedente) {
|
||||
tarifaOficialDAO.copiarParaTarifa(vigenciaTarifa, UsuarioLogado.getUsuarioLogado().getUsuarioId(),
|
||||
calculaPegagio, calculaTarifa, calculaTaxaEmbarque, calculaSeguro, empresa, orgaoConcedente);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue