fixes bug #8353
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@65055 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
aa51e6902e
commit
300e9de79e
|
@ -142,9 +142,15 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
||||||
|
|
||||||
// pra cada ruta obter as combinacoes de tramos, cada tramo com sua lista de casetaPeaje
|
// pra cada ruta obter as combinacoes de tramos, cada tramo com sua lista de casetaPeaje
|
||||||
public int[] gerarSQLInserirPeajes(List<Ruta> lsRuta, OrgaoConcedente orgao, boolean usaICMS) {
|
public int[] gerarSQLInserirPeajes(List<Ruta> lsRuta, OrgaoConcedente orgao, boolean usaICMS) {
|
||||||
|
boolean isOrgaoNull = orgao == null;
|
||||||
|
List<String> updates = new ArrayList<String>();
|
||||||
List<PeajeVO> peajes = new ArrayList<PeajeVO>();
|
List<PeajeVO> peajes = new ArrayList<PeajeVO>();
|
||||||
orgao = orgaoConcedenteService.obtenerID(orgao.getOrgaoConcedenteId());
|
List<ClasseIndicePeaje> classeIndicePeajes = new ArrayList<ClasseIndicePeaje>();
|
||||||
List<ClasseIndicePeaje> classeIndicePeajes = orgao.getClassesIndicePeaje();
|
if(orgao != null){
|
||||||
|
orgao = orgaoConcedenteService.obtenerID(orgao.getOrgaoConcedenteId());
|
||||||
|
classeIndicePeajes = orgao.getClassesIndicePeaje();
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("****** INICIO DO PROCESSO DE CALCULO DE PEDAGIO ******");
|
log.debug("****** INICIO DO PROCESSO DE CALCULO DE PEDAGIO ******");
|
||||||
log.debug("****** QTD DE LINHAS = "+lsRuta.size()+"******");
|
log.debug("****** QTD DE LINHAS = "+lsRuta.size()+"******");
|
||||||
int z = 0;
|
int z = 0;
|
||||||
|
@ -154,6 +160,14 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
||||||
|
|
||||||
List<Object> lsObj = buscarCasetasPeajeWithinTramo(ruta);
|
List<Object> lsObj = buscarCasetasPeajeWithinTramo(ruta);
|
||||||
log.debug("****** QTD COMBINAÇÕES DE TRECHOS x QTD PEDAGIOS POR TRECHO: "+lsObj.size()+" ******");
|
log.debug("****** QTD COMBINAÇÕES DE TRECHOS x QTD PEDAGIOS POR TRECHO: "+lsObj.size()+" ******");
|
||||||
|
if(isOrgaoNull){
|
||||||
|
orgao = orgaoConcedenteService.obtenerID(ruta.getOrgaoConcedente().getOrgaoConcedenteId());
|
||||||
|
classeIndicePeajes = orgao.getClassesIndicePeaje();
|
||||||
|
String update = " update peaje set activo = 0 where ruta_id ="+ruta.getRutaId();
|
||||||
|
updates.add(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (null != lsObj) {
|
if (null != lsObj) {
|
||||||
for (Object arrObj : lsObj) {
|
for (Object arrObj : lsObj) {
|
||||||
BigDecimal bigKm = new BigDecimal(((Object[]) arrObj)[11].toString()) ;
|
BigDecimal bigKm = new BigDecimal(((Object[]) arrObj)[11].toString()) ;
|
||||||
|
@ -163,16 +177,27 @@ public class CalcularPeajeHibernateDAO extends GenericHibernateDAO<String, Strin
|
||||||
log.debug("****** FIM LINHA : "+ruta.toString()+" . INSTRUCOES DE INSERT NO BANCO PRONTAS ******");
|
log.debug("****** FIM LINHA : "+ruta.toString()+" . INSTRUCOES DE INSERT NO BANCO PRONTAS ******");
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder updateSql = new StringBuilder()
|
StringBuilder updateSql = new StringBuilder();
|
||||||
.append("update peaje set activo = 0 ")
|
if(isOrgaoNull == false){
|
||||||
.append("where orgaoconcedente_id = ")
|
updateSql = new StringBuilder()
|
||||||
.append(orgao.getOrgaoConcedenteId());
|
.append("update peaje set activo = 0 ")
|
||||||
|
.append("where orgaoconcedente_id = ")
|
||||||
|
.append(orgao.getOrgaoConcedenteId());
|
||||||
|
}
|
||||||
|
|
||||||
int[] result = {};
|
int[] result = {};
|
||||||
Connection con = getSession().connection();
|
Connection con = getSession().connection();
|
||||||
try {
|
try {
|
||||||
Statement stmt = con.createStatement();
|
Statement stmt = con.createStatement();
|
||||||
con.setAutoCommit(false);
|
con.setAutoCommit(false);
|
||||||
stmt.addBatch(updateSql.toString());
|
if(!isOrgaoNull){
|
||||||
|
stmt.addBatch(updateSql.toString());
|
||||||
|
}else{
|
||||||
|
for(String up : updates){
|
||||||
|
stmt.addBatch(up);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0 ; i < peajes.size(); i++){
|
for(int i = 0 ; i < peajes.size(); i++){
|
||||||
stmt.addBatch(peajes.get(i).toInsertQuery());
|
stmt.addBatch(peajes.get(i).toInsertQuery());
|
||||||
stmt.addBatch(peajes.get(i).toUpdateExcepcionPeajeQuery());
|
stmt.addBatch(peajes.get(i).toUpdateExcepcionPeajeQuery());
|
||||||
|
|
|
@ -68,7 +68,11 @@ public class RutaHibernateDAO extends GenericHibernateDAO<Ruta, Integer> impleme
|
||||||
|
|
||||||
c.addOrder(Order.asc("descruta"));
|
c.addOrder(Order.asc("descruta"));
|
||||||
|
|
||||||
return c.list();
|
List<Ruta> l =c.list();
|
||||||
|
for(Ruta r : l){
|
||||||
|
r.getLsRutaEmpresa();
|
||||||
|
}
|
||||||
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Ruta> buscarPorClaseServicio(ClaseServicio claseServicio) {
|
public List<Ruta> buscarPorClaseServicio(ClaseServicio claseServicio) {
|
||||||
|
|
Loading…
Reference in New Issue