예제 #1
0
        public override Boolean Equals(object obj)
        {
            if ((obj == null) || (obj.GetType() != this.GetType()))
            {
                return(false);
            }
            PickMethod castObj = (PickMethod)obj;

            return((castObj != null) &&
                   (this.MethodID == castObj.MethodID));
        }
예제 #2
0
       //Obtiene el Stock de un producto, Ubicacion, cantodad segun un metodo (ZONE, LIFO, FIFO) 
       public String GetStrProductStock(ProductStock productStock, PickMethod pickMethod)
       {
           //Query sobre label entity de tipo producto y activa, sacando la unidad base
           //Order tue query over  ZONE, FIFO, LIFO , FEFO segun el PickingMethod

           string result = "";

           //Label label = new Label
           //{
           //    Product = product,
           //    Bin = bin
           //};

           IList<ProductStock> list = Factory.DaoLabel().GetStock(productStock, pickMethod, 20);

           if (list == null || list.Count == 0)
               return "";

           foreach (ProductStock ps in list)
               result += ps.Bin.BinCode + "(" + ps.Stock.ToString() + "), ";

           return result;
       }
예제 #3
0
        public Dictionary<int,object[]> GetDocumentSuggestedBins(Document document, Location location, PickMethod pickMethod, short binDirection)
        {
            string result = "";
            string firstBin = "";
            IList<ProductStock> list = Factory.DaoLabel().GetDocumentSuggestedBins(document, location, pickMethod);
            IList<Bin> resultBin = new List<Bin>();
            Dictionary<int, object[]> resultDictionary = new Dictionary<int, object[]>();


            foreach (Product product in list.Select(p => p.Product).Distinct())
            {

                if (list == null || list.Count == 0)
                {
                    if (!resultDictionary.ContainsKey(product.ProductID))
                        resultDictionary.Add(product.ProductID, new object[] { "NO STOCK", WmsSetupValues.MaxBinRank, firstBin });
                }

                IList<ZoneBinRelation> listBin = GetAssignedBinsList(product, location);


                foreach (ProductStock ps in list.Where(f=>f.Product.ProductID == product.ProductID).OrderBy(f => f.Bin.Rank))
                {

                    if (binDirection == BinType.In_Out)
                    {
                        result += ps.Bin.BinCode + " (";

                        if (ps.PackStock + ps.Stock > 0)
                            result += (ps.PackStock + ps.Stock).ToString();

                        result += ")\n";

                        resultBin.Add(ps.Bin);

                        if (string.IsNullOrEmpty(firstBin))
                            firstBin = ps.Bin.BinCode;
                    }
                    else
                    {

                        if (listBin != null && listBin.Any(f => f.Bin.BinID == ps.Bin.BinID && f.BinType != binDirection))
                            continue;

                        if (binDirection == BinType.Exclude_Out && ps.BinType == BinType.Out_Only)
                            continue;

                        if (binDirection == BinType.Exclude_In && ps.BinType == BinType.In_Only)
                            continue;


                        result += ps.Bin.BinCode + " (";

                        if (ps.PackStock + ps.Stock > 0)
                            result += (ps.PackStock + ps.Stock).ToString();

                        result += ")\n";

                        resultBin.Add(ps.Bin);

                        if (string.IsNullOrEmpty(firstBin))
                            firstBin = ps.Bin.BinCode;
                    }

                    if (!resultDictionary.ContainsKey(product.ProductID))
                        resultDictionary.Add(product.ProductID, new object[] { result, resultBin[0].Rank, firstBin });
                }
               
            }

            return resultDictionary;
        }
예제 #4
0
        public object[] GetSuggestedBins(Product product, Location location, PickMethod pickMethod, short binDirection)
        {
            string result1 = "", result2 = "";
            string firstBin = "";
            string oldestBin = "";
            IList<ProductStock> list = Factory.DaoLabel().GetSuggestedBins(product, location, pickMethod);
            IList<Bin> resultBin = new List<Bin>();


            if (list == null || list.Count == 0)
                return new object[] { "NO STOCK", WmsSetupValues.MaxBinRank, firstBin, oldestBin };

            
            //Bin con mercancia mas vieja.
            try
            {
                ProductStock oldest = list.Where(f => f.MinDate != null).OrderBy(f => f.MinDate).First();
                oldestBin += oldest.Bin.BinCode + " (";
                oldestBin += (oldest.PackStock + oldest.Stock).ToString() + ")\n";
            }
            catch { }


            IList<ZoneBinRelation> listBin = GetAssignedBinsList(product, location);


            foreach (ProductStock ps in list.OrderBy(f => f.Bin.Rank))
            {

                if (binDirection == BinType.In_Out)
                {
                    result1 += ps.Bin.BinCode + " (";

                    if (ps.PackStock + ps.Stock > 0)
                        result1 += (ps.PackStock + ps.Stock).ToString();

                    result1 += ")\n";

                    resultBin.Add(ps.Bin);

                    if (string.IsNullOrEmpty(firstBin))
                        firstBin = ps.Bin.BinCode;
                }
                else
                {

                    if (listBin != null && listBin.Any(f => f.Bin.BinID == ps.Bin.BinID && f.BinType != binDirection))
                        continue;

                    if (binDirection == BinType.Exclude_Out && ps.BinType == BinType.Out_Only)
                        continue;

                    if (binDirection == BinType.Exclude_In && ps.BinType == BinType.In_Only)
                        continue;


                    //Si el bin esta en la lista de Zonas Se va para el Result 1
                    if (ps.PackStock + ps.Stock > 0)
                        if (listBin.Any(f => f.Bin.BinID == ps.Bin.BinID))
                        {
                            result1 += ps.Bin.BinCode + " (";
                            result1 += (ps.PackStock + ps.Stock).ToString();
                            result1 += ")\n";

                            if (string.IsNullOrEmpty(firstBin))
                                firstBin = ps.Bin.BinCode;
                        }
                        else //Si no se va para el result 2
                        {
                            result2 += ps.Bin.BinCode + " (";
                            result2 += (ps.PackStock + ps.Stock).ToString();
                            result2 += ")\n";
                        }

                    //Al final sumo result 1 y 2.

                    resultBin.Add(ps.Bin);
                }
            }

            if (string.IsNullOrEmpty(firstBin) && resultBin[0] != null)
                firstBin = resultBin[0].BinCode;

            int resRank = (resultBin[0] != null) ? resultBin[0].Rank : 0;

            return new object[] { result1 + result2, resRank, firstBin, oldestBin };
        }
예제 #5
0
        public object[] GetFirstSuggestedBin(Product product, Location location, PickMethod pickMethod, short binDirection)
        {
            string result = "";
            IList<ProductStock> list = Factory.DaoLabel().GetSuggestedBins(product, location, pickMethod);
            IList<Bin> resultBin = new List<Bin>();


            if (list == null || list.Count == 0)
                return new object[] { "NO STOCK", WmsSetupValues.MaxBinRank };


            IList<ZoneBinRelation> listBin = GetAssignedBinsList(product, location);


            foreach (ProductStock ps in list.OrderBy(f => f.Bin.Rank))
            {

                if (binDirection == BinType.In_Out)
                {
                    result += ps.Bin.BinCode + " (";

                    if (ps.PackStock + ps.Stock > 0)
                        result += (ps.PackStock + ps.Stock).ToString();

                    result += ")\n";

                    resultBin.Add(ps.Bin);

                    return new object[] { result, resultBin[0].Rank };
                }
                else
                {
                    if (listBin != null && listBin.Any(f => f.Bin.BinID == ps.Bin.BinID && f.BinType != binDirection))
                        continue;

                    result += ps.Bin.BinCode + " (";

                    if (ps.PackStock + ps.Stock > 0)
                        result += (ps.PackStock + ps.Stock).ToString();

                    result += ")\n";

                    resultBin.Add(ps.Bin);

                    return new object[] { result, resultBin[0].Rank };
                }

            }

            return new object[] { "NO STOCK", WmsSetupValues.MaxBinRank };
            
        }
예제 #6
0
 public String GetStrProductStock(ProductStock productStock, PickMethod pickMethod)
 { return LabelMngr.GetStrProductStock(productStock, pickMethod); }
예제 #7
0
 public IList<ProductStock> GetProductStock(ProductStock productStock, PickMethod pickMethod)
 { return Factory.DaoLabel().GetStock(productStock, pickMethod, 20); }
예제 #8
0
 public object[] GetSuggestedBins(Product product, Location location, PickMethod pickMethod,  short binDirection)
 {
     return BasicMngr.GetSuggestedBins(product, location, pickMethod, binDirection);
 }
예제 #9
0
 public IList<ProductStock> GetStock(ProductStock data, PickMethod pickMethod, int records)
 {
     return Factory.DaoLabel().GetStock(data, pickMethod, records);
 }
예제 #10
0
 public void UpdatePickMethod(PickMethod data) { Factory.DaoPickMethod().Update(data); }
예제 #11
0
 public void DeletePickMethod(PickMethod data) { Factory.DaoPickMethod().Delete(data); }
예제 #12
0
 public PickMethod SavePickMethod(PickMethod data) { return Factory.DaoPickMethod().Save(data); }
예제 #13
0
 public IList<PickMethod> GetPickMethod(PickMethod data) { return Factory.DaoPickMethod().Select(data); }
예제 #14
0
        public IList<ProductStock> GetSuggestedBins(Product product, Location location, PickMethod pickMethod)
        {

            string initQuery = "SELECT l.ProductID, p.BaseUnitID, l.BinID, SUM(l.SingleQuantity * u.BaseAmount) AS Stock,  SUM(l.PackQuantity*u.BaseAmount) as PackStock, l.MaxDate, l.MinDate, b.Rank "
             + " FROM vwStockSummary AS l INNER JOIN Master.Unit u ON u.UnitID = l.UnitID INNER JOIN Master.Product p ON p.ProductID = l.ProductID INNER JOIN Master.Bin b ON b.BinID = l.BinID "
            + " Where l.NodeID = :nid And l.StatusID = :sid AND ISNULL(b.LevelCode,'') != 'NOUSE' ";


            StringBuilder sql = new StringBuilder(initQuery);
            Parms = new List<Object[]>();


            Parms.Add(new Object[] { "nid", NodeType.Stored });
            Parms.Add(new Object[] { "sid", EntityStatus.Active });

            if (product != null && product.ProductID != 0)
            {
                sql.Append(" and l.ProductID = :id1 ");
                Parms.Add(new Object[] { "id1", product.ProductID });
            }

            if (location != null && location.LocationID != 0)
            {
                sql.Append(" and l.LocationID = :id2 ");
                Parms.Add(new Object[] { "id2", location.LocationID });
            }

            sql.Append(" GROUP by   l.ProductID, p.BaseUnitID, l.BinID, l.MaxDate, l.MinDate, b.Rank");
            sql.Append(" HAVING SUM(l.SingleQuantity * u.BaseAmount) > 0 OR SUM(l.PackQuantity * u.BaseAmount) > 0 ");


            if (pickMethod == null || pickMethod.MethodID == PickingMethod.FIFO)
                sql.Append(" order by  l.MinDate");

            else if (pickMethod.MethodID == PickingMethod.LIFO)
                sql.Append(" order by  l.MaxDate DESC");

            else if (pickMethod.MethodID == PickingMethod.ZONE)
                sql.Append(" order by b.Rank"); //l.BinID

            //else if (pickMethod == PickingMethod.FEFO)
            //sql.Append(" order by  ExpirationDate DESC");


            IQuery query = Factory.Session.CreateSQLQuery(sql.ToString());
            SetParameters(query);

            query.SetMaxResults(WmsSetupValues.DefaultBinsToShow);

            IList<ProductStock> ret = GetProductStockObject(query.List<Object[]>(), Factory);

            if (!Factory.IsTransactional)
                Factory.Commit();

            return ret;

        }
예제 #15
0
        /// <summary>
        /// Retorna una lista de objetos que contienen las ubicaciones de producto en bodega, 
        /// producto,cantidad en unidad base
        /// </summary>
        /// <param name="data"></param>
        /// <param name="records">Numero de registros a devolver</param>
        /// <returns></returns>
        public IList<ProductStock> GetStock(ProductStock data, PickMethod pickMethod, int records)
        {
            //Sale solo product, y del nodo stored
            string initQuery = "select p.ProductID, p.BaseUnitID, b.BinID, SUM(CASE WHEN l.Printed = 0 THEN l.CurrQty*u.BaseAmount ELSE 0 END) AS Stock,"
            + " SUM(CASE WHEN l.Printed = 1 THEN l.CurrQty*u.BaseAmount ELSE 0 END) as PackStock, Max(l.CreationDate) as MaxDate, Min(l.CreationDate) as MinDate " +
                " from Trace.Label l inner join Master.Product p on l.ProductID = p.ProductID " +
                " Inner Join Master.Unit u On l.UnitID = u.UnitID Inner Join Master.Bin b On l.BinID = b.BinID " +
                " where l.CurrQty > 0 AND (l.LabelTypeID = :lt1 OR l.LabelTypeID = :lsn1)  AND l.NodeID = :nd1 AND l.StatusID = :st1 ";

            StringBuilder sql = new StringBuilder(initQuery);
            Parms = new List<Object[]>();

            Parms.Add(new Object[] { "lt1", LabelType.ProductLabel });
            Parms.Add(new Object[] { "lsn1", LabelType.UniqueTrackLabel });
            Parms.Add(new Object[] { "nd1", NodeType.Stored });
            Parms.Add(new Object[] { "st1", EntityStatus.Active });


            if (data.Product != null && data.Product.ProductID != 0)
            {
                sql.Append(" and p.ProductID = :id1 ");
                Parms.Add(new Object[] { "id1", data.Product.ProductID });
            }


            if (data.Bin != null)
            {
                if (data.Bin.BinID != 0)
                {
                    sql.Append(" and b.BinID = :id8 ");
                    Parms.Add(new Object[] { "id8", data.Bin.BinID });
                }

                if (!string.IsNullOrEmpty(data.Bin.BinCode))
                {
                    sql.Append(" and b.BinCode = :idz2 ");
                    Parms.Add(new Object[] { "idz2", data.Bin.BinCode });
                }

                if (data.Bin.Location != null && data.Bin.Location.LocationID != 0)
                {
                    sql.Append(" and b.LocationID = :id10 ");
                    Parms.Add(new Object[] { "id10", data.Bin.Location.LocationID });
                }

            }


            sql = new StringBuilder(sql.ToString());
            sql.Append(" group by  p.ProductID, p.BaseUnitID, b.BinID ");


            //Order By Picking Method

            if (pickMethod == null || pickMethod.MethodID == PickingMethod.FIFO)
                sql.Append(" order by  MinDate");

            else if (pickMethod.MethodID == PickingMethod.LIFO)
                sql.Append(" order by  MaxDate DESC");

            //else if (pickMethod.MethodID == PickingMethod.ZONE)
            //sql.Append(" order by  b.ZoneID, b.Rank");

            //else if (pickMethod == PickingMethod.FEFO)
            //    sql.Append(" order by  ExpirationDate DESC");




            IQuery query = Factory.Session.CreateSQLQuery(sql.ToString());
            SetParameters(query);

            query.SetMaxResults(records);

            IList<ProductStock> ret = GetProductStockObject(query.List<Object[]>(), Factory);

            if (!Factory.IsTransactional)
                Factory.Commit();

            return ret;

        }
예제 #16
0
        public IList<ProductStock> GetDocumentSuggestedBins(Document document, Location location, PickMethod pickMethod)
        {
            string initQuery = "SELECT l.ProductID, l.UnitID, l.BinID, l.SingleQuantity AS Stock,  l.PackQuantity as PackStock, l.MaxDate, l.MinDate "
             + "FROM vwStockSummary AS l INNER JOIN Trace.DocumentLine dl ON dl.ProductID = l.ProductID "+
             " Where (l.SingleQuantity > 0 Or l.PackQuantity > 0) And l.NodeID = :nid And l.StatusID = :sid ";


            StringBuilder sql = new StringBuilder(initQuery);
            Parms = new List<Object[]>();


            Parms.Add(new Object[] { "nid", NodeType.Stored });
            Parms.Add(new Object[] { "sid", EntityStatus.Active });

            if (document != null && document.DocID != 0)
            {
                sql.Append(" and dl.DocID = :id1 ");
                Parms.Add(new Object[] { "id1", document.DocID });
            }

            if (location != null && location.LocationID != 0)
            {
                sql.Append(" and l.LocationID = :id2 ");
                Parms.Add(new Object[] { "id2", location.LocationID });
            }




            if (pickMethod == null || pickMethod.MethodID == PickingMethod.FIFO)
                sql.Append(" order by  l.MinDate");

            else if (pickMethod.MethodID == PickingMethod.LIFO)
                sql.Append(" order by  l.MaxDate DESC");

            else if (pickMethod.MethodID == PickingMethod.ZONE)
                sql.Append(" order by  l.BinID");

            //else if (pickMethod == PickingMethod.FEFO)
            //sql.Append(" order by  ExpirationDate DESC");


            IQuery query = Factory.Session.CreateSQLQuery(sql.ToString());
            SetParameters(query);

            query.SetMaxResults(WmsSetupValues.DefaultBinsToShow);

            IList<ProductStock> ret = GetProductStockObject(query.List<Object[]>(), Factory);

            if (!Factory.IsTransactional)
                Factory.Commit();

            return ret;
        }