Cambios menores

parent 1ef5f661
...@@ -27,7 +27,7 @@ public class UjapackApplication { ...@@ -27,7 +27,7 @@ public class UjapackApplication {
public static void main(String[] args){ public static void main(String[] args){
SpringApplication.run(UjapackApplication.class, args); SpringApplication.run(UjapackApplication.class, args);
HashMap<Integer,PuntodeControl> puntosdecontrol= new HashMap<>(); /* HashMap<Integer,PuntodeControl> puntosdecontrol= new HashMap<>();
int idPr=11; //Id para las provincias, se usa para darle un identificador a cada una de las oficinas. int idPr=11; //Id para las provincias, se usa para darle un identificador a cada una de las oficinas.
String fichero=""; String fichero="";
try(BufferedReader br=new BufferedReader(new FileReader("redujapackPr.json"))){ try(BufferedReader br=new BufferedReader(new FileReader("redujapackPr.json"))){
...@@ -72,10 +72,10 @@ public class UjapackApplication { ...@@ -72,10 +72,10 @@ public class UjapackApplication {
PuntodeControl pc=new PuntodeControl(nombre, localizacion,CentroLogistico,nombre); PuntodeControl pc=new PuntodeControl(nombre, localizacion,CentroLogistico,nombre);
pc.setConexiones(conexiones); pc.setConexiones(conexiones);
pc.setProvincias(provincias); pc.setProvincias(provincias);
puntosdecontrol.put(id,pc); /**Aqui es id y no idPr porque aqui se añaden especificamente los centros logisticos, no oficinas puntosdecontrol.put(id,pc); //Aqui es id y no idPr porque aqui se añaden especificamente los centros logisticos, no oficinas
por lo que se toma dicho id. */ // por lo que se toma dicho id.
} }*/
ServicioUjaPackImpl servi = new ServicioUjaPackImpl(); ServicioUjaPackImpl servi = new ServicioUjaPackImpl();
......
...@@ -80,7 +80,7 @@ public class Envio { ...@@ -80,7 +80,7 @@ public class Envio {
break; break;
} }
} }
}else{ }else if(!(e.direccionDestino.equals(e.direccionOrigen)) && cl.get(e.direccionDestino).getCentro()==cl.get(e.direccionOrigen).getCentro()){ //MODIFICAR hay que buscarlo con el id
for(int i=1; i<cl.size(); i++){ for(int i=1; i<cl.size(); i++){
if(cl.get(i).getProvincia().equals(e.getDireccionOrigen()) && a == false){ if(cl.get(i).getProvincia().equals(e.getDireccionOrigen()) && a == false){
listadoPuntos.add(cl.get(i)); listadoPuntos.add(cl.get(i));
...@@ -99,6 +99,7 @@ public class Envio { ...@@ -99,6 +99,7 @@ public class Envio {
} }
} }
} }
return listadoPuntos; return listadoPuntos;
} }
......
...@@ -13,7 +13,7 @@ import java.util.ArrayList; ...@@ -13,7 +13,7 @@ import java.util.ArrayList;
public class PuntodeControl { public class PuntodeControl {
private String nombre,provincia,centro; //Provincia es la localización donde está private String nombre,provincia,centro;
private int id; private int id;
private TipoPunto tipo; private TipoPunto tipo;
private ArrayList<String> provincias; private ArrayList<String> provincias;
......
...@@ -5,12 +5,15 @@ ...@@ -5,12 +5,15 @@
*/ */
package es.ujaen.dae.Ujapack.entidades; package es.ujaen.dae.Ujapack.entidades;
import es.ujaen.dae.beans.ServicioUjaPackImpl;
import es.ujaen.dae.entidades.Envio; import es.ujaen.dae.entidades.Envio;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import java.util.ArrayList;
import es.ujaen.dae.entidades.PuntodeControl;
import java.util.HashMap;
/** /**
* *
...@@ -26,6 +29,24 @@ public class EnvioTest { ...@@ -26,6 +29,24 @@ public class EnvioTest {
Assertions.assertNotNull(e.calcularImporte(e)); Assertions.assertNotNull(e.calcularImporte(e));
} }
@Test
public void testCalcularRuta(){
ServicioUjaPackImpl servicio = new ServicioUjaPackImpl();
Envio e=servicio.crearEnvio("Jose","Maria","Castellon","Islas Baleares",0.5f,20.4f,20.4f,20.4f);
//Envio e = new Envio("Jose","Maria","Castellon","Islas Baleares",0.5f,20.4f,20.4f,20.4f);
HashMap<Integer,PuntodeControl> puntosdecontrol= new HashMap<>();
ArrayList<PuntodeControl> j = new ArrayList<>();
j = e.calcularRuta(puntosdecontrol,e);
System.out.println(j.size());
/**
for(int i=0; i<j.size(); i++){
System.out.println(j.get(i));
}
float v = 0;
v = e.calcularImporte(e);
System.out.println(v);*/
Assertions.assertNotNull(j);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment