From b3a612263201709ff094e1ac1e86afc0d04f8982 Mon Sep 17 00:00:00 2001 From: fabio Date: Tue, 31 Mar 2020 20:59:30 +0000 Subject: [PATCH] fixes bug#18849 dev: Gleimar qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@101041 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../ventaboletos/dao/TramoServicioDAO.java | 5 +++ .../hibernate/TramoServicioHibernateDAO.java | 42 ++++++++++++++++++- .../service/TramoRutaService.java | 2 + .../service/impl/RutaServiceImpl.java | 4 ++ .../service/impl/TramoRutaServiceImpl.java | 4 ++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/TramoServicioDAO.java b/src/com/rjconsultores/ventaboletos/dao/TramoServicioDAO.java index 9b0990169..b0abee51b 100644 --- a/src/com/rjconsultores/ventaboletos/dao/TramoServicioDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/TramoServicioDAO.java @@ -42,4 +42,9 @@ public interface TramoServicioDAO extends GenericDAO { * @return */ public boolean existenTiemposTramosEsquema(Integer esquemaCorridaId); + + /* + * Rotina que corrige inconsistencias nos tramos + */ + public void limparInconsistenciasTramo(); } diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/TramoServicioHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/TramoServicioHibernateDAO.java index 05e8e9a0c..02aca90b0 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/TramoServicioHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/TramoServicioHibernateDAO.java @@ -14,6 +14,8 @@ import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; +import org.zkoss.util.logging.Log; import com.rjconsultores.ventaboletos.dao.TramoServicioDAO; import com.rjconsultores.ventaboletos.entidad.ClaseServicio; @@ -26,6 +28,7 @@ import com.rjconsultores.ventaboletos.entidad.Via; * * @author Rafius */ +@SuppressWarnings("unchecked") @Repository("tramoServicioDAO") public class TramoServicioHibernateDAO extends GenericHibernateDAO implements TramoServicioDAO { @@ -46,7 +49,6 @@ public class TramoServicioHibernateDAO extends GenericHibernateDAO buscarPorTramo(Tramo tramo) { Criteria c = getSession().createCriteria(getPersistentClass()); c.add(Restrictions.eq("activo", Boolean.TRUE)); @@ -83,7 +85,6 @@ public class TramoServicioHibernateDAO extends GenericHibernateDAO list = c.list(); if (list.size() > 1){ @@ -122,4 +123,41 @@ public class TramoServicioHibernateDAO extends GenericHibernateDAO 1 ) "); + sql.append(" and activo =1 "); + Query query = getSession().createSQLQuery(sql.toString()); + int tramoServicoAtualizado = query.executeUpdate(); + log.info(" Rotina limparInconsistenciasTramo: "+tramoServicoAtualizado+" TramoServicio atualizados" ); + + sql = new StringBuilder(500); + sql.append("update "); + sql.append(" orgao_tramo set activo = 0 "); + sql.append("WHERE "); + sql.append(" rowid in ( select rid from ( "); + sql.append(" select rowid rid,row_number() "); + sql.append(" over (partition by CLASESERVICIO_ID,ORGAOCONCEDENTE_ID,TRAMO_ID order by rowid) rn "); + sql.append(" from orgao_tramo "); + sql.append(" where activo = 1) "); + sql.append(" where rn <> 1 ) "); + sql.append(" and activo =1 "); + + Query query2 = getSession().createSQLQuery(sql.toString()); + int orgaoTramoAtualizado = query2.executeUpdate(); + log.info(" Rotina limparInconsistenciasTramo: "+orgaoTramoAtualizado+" OrgaoTramo atualizados" ); + } + } diff --git a/src/com/rjconsultores/ventaboletos/service/TramoRutaService.java b/src/com/rjconsultores/ventaboletos/service/TramoRutaService.java index 103341bf8..83353dc28 100644 --- a/src/com/rjconsultores/ventaboletos/service/TramoRutaService.java +++ b/src/com/rjconsultores/ventaboletos/service/TramoRutaService.java @@ -58,4 +58,6 @@ public interface TramoRutaService { * @throws BusinessException */ public void generarTramosRutaExistente(RutaTramoVO rutaTramoVO, Ruta ruta) throws BusinessException; + + public void limparInconsistenciasTramo(); } diff --git a/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java index 43d1f9fd0..57bd3e17a 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/RutaServiceImpl.java @@ -35,6 +35,7 @@ import com.rjconsultores.ventaboletos.service.ParadaService; import com.rjconsultores.ventaboletos.service.RutaCombinacionService; import com.rjconsultores.ventaboletos.service.RutaSecuenciaService; import com.rjconsultores.ventaboletos.service.RutaService; +import com.rjconsultores.ventaboletos.service.TramoRutaService; import com.rjconsultores.ventaboletos.service.TramoService; import com.rjconsultores.ventaboletos.utilerias.RegistroConDependenciaException; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; @@ -61,6 +62,8 @@ public class RutaServiceImpl implements RutaService { private EsquemaCorridaDAO esquemaCorridaDAO; @Autowired private ParadaService paradaService; + @Autowired + private TramoRutaService tramoRutaService; private static Logger log = Logger.getLogger(RutaServiceImpl.class); @@ -249,6 +252,7 @@ public class RutaServiceImpl implements RutaService { private void generarSecuencias(Ruta ruta, List lsParadasSequencia) throws BusinessException { + tramoRutaService.limparInconsistenciasTramo(); if (lsParadasSequencia != null) { List lsRutaSecuencia = new ArrayList(); HashMap> rutaSecuenciaBackup = new HashMap>(); diff --git a/src/com/rjconsultores/ventaboletos/service/impl/TramoRutaServiceImpl.java b/src/com/rjconsultores/ventaboletos/service/impl/TramoRutaServiceImpl.java index 2ca472d95..31ab7145f 100644 --- a/src/com/rjconsultores/ventaboletos/service/impl/TramoRutaServiceImpl.java +++ b/src/com/rjconsultores/ventaboletos/service/impl/TramoRutaServiceImpl.java @@ -656,4 +656,8 @@ public class TramoRutaServiceImpl implements TramoRutaService { return kmTotal; } + + public void limparInconsistenciasTramo() { + tramoServicioDAO.limparInconsistenciasTramo(); + } }