Beispiel #1
0
        private OrdenProduccionModel OrdenProduccionPorNumero(string numero)
        {
            var model = new OrdenProduccionModel();

            OrdenProduccion ordenProduccion;

            using (var service = new ProduccionServiceClient())
            {
                ordenProduccion = service.ObetenerOrdenProduccionPorNumero(numero);
            }

            if (ordenProduccion == null)
            {
                throw new Exception("El número (" + numero + ") de Orden de Producción no existe.");
            }

            model.Id                  = ordenProduccion.Id;
            model.Numero              = ordenProduccion.Numero;
            model.CantidadOrdenVenta  = ordenProduccion.OrdenVenta.Cantidad;
            model.DescripcionProducto = ordenProduccion.OrdenVenta.Producto.Descripcion;
            model.FechaEntrega        = ordenProduccion.OrdenVenta.FechaEntrega;
            model.NumeroOrdenVenta    = ordenProduccion.Numero;
            model.StockMinimoProducto = ordenProduccion.OrdenVenta.Producto.StockMinimo;
            model.StockProducto       = ordenProduccion.OrdenVenta.Producto.Stock;
            model.CantidadProducto    = ordenProduccion.OrdenVenta.Cantidad + ordenProduccion.OrdenVenta.Producto.StockMinimo - ordenProduccion.OrdenVenta.Producto.Stock;

            foreach (var item in ordenProduccion.Materiales)
            {
                model.Materiales.Add(new OrdenProduccionMaterialModel
                {
                    IdMaterial          = item.Material.Id,
                    DescripcionMaterial = item.Material.Descripcion,
                    Stock       = item.Material.Stock,
                    StockMinimo = item.Material.StockMinimo,
                    Requerido   = item.Requerido,
                    Reservado   = item.Material.Reservado,
                    Comprar     = item.Comprar
                });
            }

            foreach (var item in ordenProduccion.Secuencia)
            {
                model.Secuencia.Add(new OrdenProduccionSecuenciaModel
                {
                    IdMaquina          = item.Maquina.Id,
                    Secuencia          = item.Secuencia,
                    DescripcionMaquina = item.Maquina.Descripcion,
                    PorcentajeFalla    = item.Maquina.PorcentajeFalla,
                    Tiempo             = item.Maquina.Tiempo,
                    FechaInicio        = item.FechaInicio,
                    FechaFin           = item.FechaFin
                });
            }
            return(model);
        }
Beispiel #2
0
        public ActionResult CrearOrdenProduccion(string numero)
        {
            var model = new OrdenProduccionModel();

            try
            {
                OrdenVenta ordenVenta;
                using (var service = new ProduccionServiceClient())
                {
                    ordenVenta = service.ObtenerOrdenVentaPorNumero(numero);
                }

                if (ordenVenta == null)
                {
                    throw new Exception("El número (" + numero + ") de Orden de Venta no existe.");
                }

                model.IdOrdenVenta        = ordenVenta.Id;
                model.CantidadOrdenVenta  = ordenVenta.Cantidad;
                model.IdProducto          = ordenVenta.Producto.Id;
                model.DescripcionProducto = ordenVenta.Producto.Descripcion;
                model.FechaEntrega        = ordenVenta.FechaEntrega;
                model.NumeroOrdenVenta    = ordenVenta.Numero;
                model.StockMinimoProducto = ordenVenta.Producto.StockMinimo;
                model.StockProducto       = ordenVenta.Producto.Stock;
                model.CantidadProducto    = model.CantidadOrdenVenta + model.StockMinimoProducto - model.StockProducto;

                List <Material> materiales = null;
                using (var service = new ProduccionServiceClient())
                {
                    materiales = service.ListarMaterialesPorProducto(ordenVenta.Producto.Id);
                }

                foreach (var material in materiales)
                {
                    var materialRequerido = new OrdenProduccionMaterialModel
                    {
                        DescripcionMaterial = material.Descripcion,
                        IdMaterial          = material.Id,
                        Stock       = material.Stock,
                        StockMinimo = material.StockMinimo,
                        Requerido   = material.Cantidad, //Cantidad necesaria para un Producto
                        Reservado   = material.Reservado
                    };

                    model.Materiales.Add(materialRequerido);
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return(View("OrdenProduccion", model));
        }
Beispiel #3
0
        public ActionResult VerOrdenProduccion(string numero)
        {
            var model = new OrdenProduccionModel();

            try
            {
                model = OrdenProduccionPorNumero(numero);
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return(View("OrdenProduccion", model));
        }
Beispiel #4
0
        public JsonResult GuardarOrdenProduccion(OrdenProduccionModel model)
        {
            var response = new JsonResponse();

            try
            {
                var ordenProduccion = new OrdenProduccion
                {
                    TomarStock               = model.TomarStock,
                    CantidadProducto         = model.CantidadProducto,
                    CantidadProductoDigitado = model.CantidadProductoDigitado,
                    Estado     = Constantes.EstadoOrdenPoduccion.PendienteAprobar,
                    OrdenVenta = new OrdenVenta
                    {
                        Id       = model.IdOrdenVenta,
                        Producto = new Producto
                        {
                            Id          = model.IdProducto,
                            Stock       = model.StockProducto,
                            StockMinimo = model.StockMinimoProducto
                        },
                        Cantidad = model.CantidadOrdenVenta
                    },
                    Materiales = new List <OrdenProduccionMaterial>(),
                    Secuencia  = new List <OrdenProduccionSecuencia>()
                };

                foreach (var material in model.Materiales)
                {
                    ordenProduccion.Materiales.Add(new OrdenProduccionMaterial
                    {
                        Comprar   = material.Comprar,
                        Requerido = material.Requerido,
                        Material  = new Material
                        {
                            Id          = material.IdMaterial,
                            Stock       = material.Stock,
                            StockMinimo = material.StockMinimo
                        }
                    });
                }

                foreach (var secuencia in model.Secuencia)
                {
                    var fechaInicio = Utils.ConvertDate(secuencia.FechaInicioStr, "dd/MM/yyyy HH:mm");
                    var fechaFin    = Utils.ConvertDate(secuencia.FechaFinStr, "dd/MM/yyyy HH:mm");

                    ordenProduccion.Secuencia.Add(new OrdenProduccionSecuencia
                    {
                        Secuencia = secuencia.Secuencia,
                        Maquina   = new Maquina {
                            Id = secuencia.IdMaquina
                        },
                        FechaInicio = fechaInicio.Value,
                        FechaFin    = fechaFin.Value
                    });
                }

                var idOrdenProduccion = 0;
                using (var service = new ProduccionServiceClient())
                {
                    idOrdenProduccion = service.RegistrarOrdenProduccion(ordenProduccion);
                }

                response.Data    = idOrdenProduccion;
                response.Success = true;
                response.Message = "Ok";
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;

                LogError(ex);
            }
            return(Json(response));
        }
Beispiel #5
0
        public ActionResult EjecucionOrdenProduccion(string numero)
        {
            var model = new OrdenProduccionModel();

            try
            {
                OrdenProduccion ordenProduccion;
                using (var service = new ProduccionServiceClient())
                {
                    ordenProduccion = service.ObetenerOrdenProduccionPorNumero(numero);
                }

                if (ordenProduccion == null)
                {
                    throw new Exception("El número (" + numero + ") de Orden de Producción no existe.");
                }

                model.Id               = ordenProduccion.Id;
                model.Numero           = ordenProduccion.Numero;
                model.FechaEntrega     = ordenProduccion.OrdenVenta.FechaEntrega;
                model.NumeroOrdenVenta = ordenProduccion.Numero;
                model.Estado           = ordenProduccion.Estado;
                model.CantidadProducto = ordenProduccion.CantidadProducto;

                foreach (var item in ordenProduccion.Materiales)
                {
                    model.Materiales.Add(new OrdenProduccionMaterialModel
                    {
                        IdMaterial          = item.Material.Id,
                        DescripcionMaterial = item.Material.Descripcion,
                        Stock       = item.Material.Stock,
                        StockMinimo = item.Material.StockMinimo,
                        Requerido   = item.Requerido,
                        Reservado   = item.Material.Reservado,
                        Comprar     = item.Comprar
                    });
                }

                foreach (var item in ordenProduccion.Secuencia)
                {
                    model.Secuencia.Add(new OrdenProduccionSecuenciaModel
                    {
                        IdMaquina          = item.Maquina.Id,
                        Secuencia          = item.Secuencia,
                        DescripcionMaquina = item.Maquina.Descripcion,
                        PorcentajeFalla    = item.Maquina.PorcentajeFalla,
                        Tiempo             = item.Maquina.Tiempo,
                        FechaInicio        = item.FechaInicio,
                        FechaFin           = item.FechaFin,
                        Estado             = item.Estado,
                        PLC      = item.Maquina.PLD,
                        Ciclo    = item.Maquina.Ciclo,
                        Longitud = item.Maquina.Longitud,
                        Espesor  = item.Maquina.Espesor
                    });
                }

                OrdenProduccionActual = model;
            }
            catch (Exception ex)
            {
                LogError(ex);
            }
            return(View(model));
        }