Commit 71a1023d by Rafael Ortega Chica

Merge branch 'jose' into Rafael

parents 08a31b83 2d542074
......@@ -55,7 +55,7 @@ public class UjapackApplication {
JsonArray provinciasArr=centroJson.getAsJsonArray("provincias");
for(JsonElement prov : provinciasArr){
provincias.add(prov.getAsString());
PuntodeControl pc2 = new PuntodeControl(prov.getAsString(),prov.getAsString(),Oficina);
PuntodeControl pc2 = new PuntodeControl(prov.getAsString(),prov.getAsString(),Oficina,nombre);
puntosdecontrol.put(idPr,pc2);
pc2.setConexiones(conexiones);
idPr++;
......@@ -68,18 +68,18 @@ public class UjapackApplication {
}
PuntodeControl pc=new PuntodeControl(nombre, localizacion,CentroLogistico);
PuntodeControl pc=new PuntodeControl(nombre, localizacion,CentroLogistico,nombre);
pc.setConexiones(conexiones);
pc.setProvincias(provincias);
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. */
//System.out.println(pc.toString());
}
puntosdecontrol.forEach((k,v) -> System.out.println("Clave del punto de control: " + k + "Valor asociado: " + v));
//Prueba del metodo Calcular ruta y calcular importe
Envio e = new Envio("Jose","Maria","Almeria","Almeria",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);
ArrayList<PuntodeControl> j = new ArrayList<>();
j = e.calcularRuta(puntosdecontrol,e);
......@@ -91,6 +91,7 @@ public class UjapackApplication {
float v = 0;
v = e.calcularImporte(e);
System.out.println(v);
e.Pasos(e);
//Fin de prueba del metodo calcular ruta. Esto debe pasarse a un test propio
}
......
......@@ -46,12 +46,33 @@ public class Envio {
}
public void Pasos(Envio e){
if(e.getListadoPuntos().size() == 1){
e.setEstado('R');
System.out.println("El paquete esta en " + e.getEstado());
e.setEstado('E');
System.out.println("El paquete esta en " + e.getEstado());
}else{
if(e.getListadoPuntos().size() == 3){
e.setEstado('T');
for(int i=0; i<e.getListadoPuntos().size(); i++){
System.out.println("El paquete esta en " + e.getEstado() + " en la provincia " + e.getListadoPuntos().get(i).getProvincia());
}
e.setEstado('R');
System.out.println("El paquete esta en " + e.getEstado());
e.setEstado('E');
System.out.println("El paquete esta en " + e.getEstado());
}
}
}
//Hecho solamente el caso donde envias y recibes dentro de la misma provincia
public ArrayList<PuntodeControl> calcularRuta(HashMap<Integer,PuntodeControl> cl, Envio e){
boolean a=false;
boolean b=false;
boolean c=false;
if(e.getDireccionOrigen().equals(e.getDireccionDestino())){
for(int i=1; i<cl.size(); i++){
if(cl.get(i).getProvincia().equals(e.getDireccionDestino())){
......@@ -59,6 +80,24 @@ public class Envio {
break;
}
}
}else{
for(int i=1; i<cl.size(); i++){
if(cl.get(i).getProvincia().equals(e.getDireccionOrigen()) && a == false){
listadoPuntos.add(cl.get(i));
a=true;
for(int z=1; z<cl.size(); z++){
if(cl.get(i).getCentro().equals(cl.get(z).getCentro()) && c == false){
listadoPuntos.add(cl.get(z));
c=true;
}
}
}
if(cl.get(i).getProvincia().equals(e.getDireccionDestino()) && b == false){
listadoPuntos.add(cl.get(i));
b=true;
}
}
}
return listadoPuntos;
}
......
......@@ -13,7 +13,7 @@ import java.util.ArrayList;
public class PuntodeControl {
private String nombre,provincia; //Provincia es la localización donde está
private String nombre,provincia,centro; //Provincia es la localización donde está
private int id;
private TipoPunto tipo;
private ArrayList<String> provincias;
......@@ -21,13 +21,14 @@ public class PuntodeControl {
public PuntodeControl(String nombre, String provincia, TipoPunto t){ //AÑADIR EL ENUM AL CONSTRUCTOR DEL PUNTO DE CONTROL
public PuntodeControl(String nombre, String provincia, TipoPunto t, String centro){ //AÑADIR EL ENUM AL CONSTRUCTOR DEL PUNTO DE CONTROL
this.id = id;
this.nombre=nombre;
this.provincia=provincia;
tipo = t;
this.conexiones = new ArrayList<>();
this.provincias = new ArrayList<>();
this.provincias = new ArrayList<>();
this.centro=centro;
};
......@@ -107,5 +108,19 @@ public class PuntodeControl {
public String toString(){
return nombre;
}
/**
* @return the centro
*/
public String getCentro() {
return centro;
}
/**
* @param centro the centro to set
*/
public void setCentro(String centro) {
this.centro = centro;
}
}
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