Commit 143e243471344e4c6cc4531c1222f100dde296a8
1 parent
2b165ae044
Exists in
master
espacio
Showing
1 changed file
with
1 additions
and
1 deletions
Show diff stats
src/js/service.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .factory( | 2 | .factory( |
3 | 'focaLogisticaPedidoRutaService', [ | 3 | 'focaLogisticaPedidoRutaService', [ |
4 | '$http', | 4 | '$http', |
5 | '$cookies', | 5 | '$cookies', |
6 | 'API_ENDPOINT', | 6 | 'API_ENDPOINT', |
7 | '$filter', | 7 | '$filter', |
8 | function($http, $cookies, API_ENDPOINT, $filter) { | 8 | function($http, $cookies, API_ENDPOINT, $filter) { |
9 | return { | 9 | return { |
10 | idUsuario: $cookies.get('idUsuario'), | 10 | idUsuario: $cookies.get('idUsuario'), |
11 | obtenerActividad: function(parametros) { | 11 | obtenerActividad: function(parametros) { |
12 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); | 12 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); |
13 | }, | 13 | }, |
14 | obtenerVehiculoById: function(idVehiculo) { | 14 | obtenerVehiculoById: function(idVehiculo) { |
15 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); | 15 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); |
16 | }, | 16 | }, |
17 | obtenerRemitoById: function(idRemito) { | 17 | obtenerRemitoById: function(idRemito) { |
18 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); | 18 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); |
19 | }, | 19 | }, |
20 | guardarCisternas: function(cisterna, idRemito) { | 20 | guardarCisternas: function(cisterna, idRemito) { |
21 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + | 21 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + |
22 | this.idUsuario + '/' + idRemito,cisterna); | 22 | this.idUsuario + '/' + idRemito,cisterna); |
23 | }, | 23 | }, |
24 | numeroHojaRuta: function() { | 24 | numeroHojaRuta: function() { |
25 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); | 25 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); |
26 | }, | 26 | }, |
27 | getRemitos: function(idVehiculo) { | 27 | getRemitos: function(idVehiculo) { |
28 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); | 28 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); |
29 | }, | 29 | }, |
30 | crearHojaRuta: function(hojaRuta) { | 30 | crearHojaRuta: function(hojaRuta) { |
31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); | 31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); |
32 | }, | 32 | }, |
33 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { | 33 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { |
34 | var idsRemitos = []; | 34 | var idsRemitos = []; |
35 | for (var i = 0; i < remitos.length; i++) { | 35 | for (var i = 0; i < remitos.length; i++) { |
36 | idsRemitos.push(remitos[i].id); | 36 | idsRemitos.push(remitos[i].id); |
37 | } | 37 | } |
38 | return $http.post(API_ENDPOINT.URL + '/vehiculo/desasociar-remitos', | 38 | return $http.post(API_ENDPOINT.URL + '/vehiculo/desasociar-remitos', |
39 | { | 39 | { |
40 | idsRemitos: idsRemitos, | 40 | idsRemitos: idsRemitos, |
41 | idVehiculo: idVehiculo, | 41 | idVehiculo: idVehiculo, |
42 | vehiculoSinRemitos: sinRemitos | 42 | vehiculoSinRemitos: sinRemitos |
43 | }); | 43 | }); |
44 | }, | 44 | }, |
45 | obtenerRemitosDeCarga: function(remitos) { | 45 | obtenerRemitosDeCarga: function(remitos) { |
46 | var remitosRes = []; | 46 | var remitosRes = []; |
47 | for(var i = 0; i < remitos.cisternas.length; i++) { | 47 | for(var i = 0; i < remitos.cisternas.length; i++) { |
48 | procesoCistena(remitos.cisternas[i], this.fecha.toISOString()); | 48 | procesoCistena(remitos.cisternas[i], this.fecha.toISOString()); |
49 | } | 49 | } |
50 | function procesoCistena(cisterna, fecha) { | 50 | function procesoCistena(cisterna, fecha) { |
51 | for(var j = 0; j < cisterna.cisternasCarga.length; j++) { | 51 | for(var j = 0; j < cisterna.cisternasCarga.length; j++) { |
52 | for (var k = 0; k < cisterna.cisternasCarga[j].cisternaMovimientos | 52 | for(var k = 0; k < cisterna.cisternasCarga[j].cisternaMovimientos |
53 | .length; k++) | 53 | .length; k++) |
54 | { | 54 | { |
55 | if(cisterna.cisternasCarga[j].fechaReparto.substring(0, 10) === | 55 | if(cisterna.cisternasCarga[j].fechaReparto.substring(0, 10) === |
56 | fecha.substring(0, 10)) | 56 | fecha.substring(0, 10)) |
57 | { | 57 | { |
58 | procesoMovimiento(cisterna.cisternasCarga[j] | 58 | procesoMovimiento(cisterna.cisternasCarga[j] |
59 | .cisternaMovimientos[k]); | 59 | .cisternaMovimientos[k]); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } | 62 | } |
63 | } | 63 | } |
64 | function procesoMovimiento(movimiento) { | 64 | function procesoMovimiento(movimiento) { |
65 | if(!movimiento.anulado && movimiento.remito && | 65 | if(!movimiento.anulado && movimiento.remito && |
66 | !movimiento.remito.idHojaRuta) { | 66 | !movimiento.remito.idHojaRuta) { |
67 | var remito = movimiento.remito; | 67 | var remito = movimiento.remito; |
68 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); | 68 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); |
69 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { | 69 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { |
70 | remitosRes.push(remito); | 70 | remitosRes.push(remito); |
71 | } | 71 | } |
72 | } | 72 | } |
73 | } | 73 | } |
74 | return remitosRes; | 74 | return remitosRes; |
75 | }, | 75 | }, |
76 | getVehiculosByIdUsuario: function() { | 76 | getVehiculosByIdUsuario: function() { |
77 | return $http.get(API_ENDPOINT.URL + '/vehiculo/usuario/' + this.idUsuario); | 77 | return $http.get(API_ENDPOINT.URL + '/vehiculo/usuario/' + this.idUsuario); |
78 | }, | 78 | }, |
79 | obtenerCisternasPorFecha: function(idVehiculo) { | 79 | obtenerCisternasPorFecha: function(idVehiculo) { |
80 | return $http.post(API_ENDPOINT.URL + '/cisterna/listar/fecha', | 80 | return $http.post(API_ENDPOINT.URL + '/cisterna/listar/fecha', |
81 | {idVehiculo: idVehiculo, fechaReparto: this.fecha}); | 81 | {idVehiculo: idVehiculo, fechaReparto: this.fecha}); |
82 | }, | 82 | }, |
83 | getUnidadesByFecha: function() { | 83 | getUnidadesByFecha: function() { |
84 | return $http.post(API_ENDPOINT.URL + '/vehiculo/listar/fecha', | 84 | return $http.post(API_ENDPOINT.URL + '/vehiculo/listar/fecha', |
85 | {fecha: this.fecha}); | 85 | {fecha: this.fecha}); |
86 | }, | 86 | }, |
87 | setFechaReparto: function(fechaReparto) { | 87 | setFechaReparto: function(fechaReparto) { |
88 | this.fecha = fechaReparto; | 88 | this.fecha = fechaReparto; |
89 | } | 89 | } |
90 | }; | 90 | }; |
91 | }]); | 91 | }]); |
92 | 92 |