Exemplo n.º 1
0
        //Get all model daily replenishment report from DB
        public static List <ModelZoneMap> GetDailyReportByModelsAndLocation()
        {
            var query = (from model in db.ModelZoneMaps
                         orderby model.Model descending
                         select model);
            var updateModelZone1 = new List <ModelZoneMap>();

            foreach (ModelZoneMap i in query)
            {
                var inventoryQty = (from inventory in db.InventoryIns
                                    where inventory.ModelNo.Equals(i.Model)
                                    group inventory by inventory.Location into g
                                    let count = g.Count()
                                                orderby count descending
                                                select new { Location = g.Key, Count = count }
                                    );

                var daily = new FGDailyReplenishment();
                foreach (var inventory in inventoryQty)
                {
                    if (LocationHelper.MapZoneCode(inventory.Location) != 1)
                    {
                        continue;
                    }

                    daily.ModelNo     = i.Model;
                    daily.Description = i.FG;
                    daily.Location    = inventory.Location;
                    daily.Qty         = inventory.Count;

                    break;
                }

                if (daily.Location != null)
                {
                    i.Zone1Code = daily.Location;
                    updateModelZone1.Add(i);
                }
            }



            return(updateModelZone1);
        }
Exemplo n.º 2
0
        //Get all model Zone2fifo qty from DB
        public static List <FGDailyReplenishment> GetAllModelsZoneQty(int zoneCode)
        {
            var query = (from model in db.ModelZoneMaps
                         orderby model.Model descending
                         select model);
            var updateModelZone1 = new List <ModelZoneMap>();

            var result = new List <FGDailyReplenishment>();

            Dictionary <string, int> duplicatedModel = new Dictionary <string, int>();
            Dictionary <string, int> hashtable       = new Dictionary <string, int>();

            foreach (ModelZoneMap i in query)
            {
                if (duplicatedModel.ContainsKey(i.Model))
                {
                    continue;
                }
                else
                {
                    duplicatedModel.Add(i.Model, 1);
                }

                var inventoryQty = (from inventory in db.InventoryIns
                                    where inventory.ModelNo.Equals(i.Model)
                                    group inventory by new { inventory.SN, inventory.Location }
                                    into g
                                    orderby g.FirstOrDefault().SN
                                    let item = (from ig in g orderby ig.SN select ig).FirstOrDefault()
                                               select item)
                ;



                foreach (var inventory in inventoryQty)
                {
                    if (LocationHelper.MapZoneCode(inventory.Location) != zoneCode)
                    {
                        continue;
                    }


                    var daily = new FGDailyReplenishment();
                    daily.ModelNo     = i.Model;
                    daily.Description = i.FG;
                    daily.Location    = inventory.Location;
                    daily.Qty        += 1;



                    if (daily.Location != null)
                    {
                        if (!hashtable.ContainsKey(daily.ModelNo + daily.Location))
                        {
                            hashtable.Add(daily.ModelNo + daily.Location, daily.Qty);
                        }
                        else
                        {
                            daily.Qty = (int)hashtable[daily.ModelNo + daily.Location] + (int)daily.Qty;
                            hashtable[daily.ModelNo + daily.Location] = daily.Qty;
                        }
                    }
                }
            }

            Dictionary <string, string> duplicated = new Dictionary <string, string>();

            foreach (KeyValuePair <string, int> entry in hashtable)
            {
                var daily = new FGDailyReplenishment();
                var key   = (string)entry.Key;
                if (duplicated.ContainsKey(key.Substring(0, 6)))
                {
                    continue;
                }
                duplicated.Add(key.Substring(0, 6), key.Substring(6));
                daily.ModelNo  = key.Substring(0, 6);
                daily.Location = key.Substring(6);
                daily.Qty      = (int)entry.Value;
                result.Add(daily);
            }


            return(result);
        }