Ejemplo n.º 1
0
        /// <summary>
        /// 由批次号获取厨房信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="batchId"></param>
        /// <returns></returns>
        public List <KitchenInfo> GetInfoByBatchNo(string batchNo)
        {
            List <KitchenInfo> resultList = new List <KitchenInfo>();
            var outType     = typeof(KitchenInfo);
            var outProInfos = outType.GetProperties();
            var outNames    = outProInfos.Select(a => a.Name);
            //取餐具类型
            //var otherProductType = CommonRules.OtherProductTypeDicValue;

            var result = (from kitchen in context.KitchenMakes
                          join batch in context.OrderBatchs on kitchen.BatchNo equals batch.BatchNo
                          join kitchenDetail in context.KitchenMakeDetails on kitchen.Id equals kitchenDetail.KitchenMakeId
                          join subProduct in context.SubProducts on kitchenDetail.SubProductId equals subProduct.Id
                          join order in context.Orders on kitchen.OrderNo equals order.No
                          join orderDetail in context.OrderDetails on kitchenDetail.SubProductId equals orderDetail.SubProductId
                          join product in context.Products on orderDetail.ProductId equals product.Id
                          where kitchen.IsDeleted != 1 &&
                          kitchenDetail.IsDeleted != 1 &&
                          subProduct.IsDeleted != 1 &&
                          order.IsDeleted != 1 &&
                          orderDetail.IsDeleted != 1 &&
                          batch.IsDeleted != 1 &&
                          product.IsDeleted != 1 &&
                          kitchen.BatchNo.Equals(batchNo) &&
                          orderDetail.OrderNo.Equals(kitchen.OrderNo) &&
                          batch.Status == BatchReviewStatus.ReviewPass
                          select new KitchenInfo
            {
                BatchNo = kitchen.BatchNo,                                                                                       //批次号
                OrderNo = order.No,                                                                                              //订单号
                BatchRequiredTime = batch.RequiredTime,                                                                          //要求完成时间
                OrderRequiredTime = order.RequiredTime,                                                                          //订单要求送达时间
                ProductName = product.Name,                                                                                      //蛋糕名称
                Size = subProduct.Size,                                                                                          //磅数
                SizeTitle = "",
                Num = orderDetail.Num,                                                                                           //数量
                OrderStatus = kitchen.Status,                                                                                    //订单状态
                KitStatus = (OrderBatchMakeStatus)(batch.MakeStatus == null ? OrderBatchMakeStatus.NotStart : batch.MakeStatus), //批次状态
                ProductStatus = kitchenDetail.Status,                                                                            //产品状态
                ProductId = product.Id,                                                                                          //产品ID
                SubProductId = subProduct.Id,                                                                                    //子产品ID
                KitchenMakeDetailId = kitchenDetail.Id                                                                           //厨房明细ID
            }).ToList();

            foreach (var item in result)
            {
                item.SizeTitle = new FCake.Bll.ProductService().GetSizeTitleBuySubProductId(item.SubProductId);
                KitchenInfo outItem  = new KitchenInfo();
                var         type     = item.GetType();
                var         proInfos = type.GetProperties();
                foreach (var x in proInfos.Where(p => outNames.Contains(p.Name)))
                {
                    var p = outProInfos.SingleOrDefault(a => a.Name.Equals(x.Name));
                    p.SetValue(outItem, x.GetValue(item, null), null);
                }
                resultList.Add(outItem);
            }

            return(resultList);
        }
Ejemplo n.º 2
0
 public void setKitchenCard()
 {
     if (KitchenInfoActive)
     {
         KitchenInfo.SetActive(false);
         KitchenInfoActive = false;
     }
 }
Ejemplo n.º 3
0
 public void setKitchenInfo()
 {
     if (!KitchenInfoActive)
     {
         KitchenInfo.SetActive(true);
         KitchenInfoActive = true;
     }
 }
        public async Task <KitchenInfo> GetTodaysRevenue(int day, int month, int year)
        {
            var today  = new DateTime(year, month, day, 0, 0, 0, 1);
            var orders = await _db.Orders.Include(o => o.Drinks).ThenInclude(d => d.Drink)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Special)
                         .Include(o => o.Pizzas).ThenInclude(p => p.Toppings).ThenInclude(t => t.Topping).Where(a => a.CollectionDate.Date == today.Date).ToListAsync();

            var income = orders.Sum(a => a.GetTotalPrice());

            var kitchenInfo = new KitchenInfo();

            kitchenInfo.TotalIncome = income;
            var pizzaDict     = new Dictionary <string, int>();
            var PizzaSpecials = orders.SelectMany(a => a.Pizzas.Where(b => b.IsSide)).ToList();

            foreach (var p in PizzaSpecials)
            {
                if (pizzaDict.ContainsKey(p.Special.Name))
                {
                    var val = pizzaDict[p.Special.Name];
                    pizzaDict[p.Special.Name] = (val + 1);
                }
                else
                {
                    pizzaDict.Add(p.Special.Name, 1);
                }
            }

            var glutenFree = orders.SelectMany(a => a.Pizzas.Where(a => a.GlutenFree)).Count();
            var eightInch  = orders.SelectMany(a => a.Pizzas.Where(a => a.Size == 8 && !a.IsSide)).Count();
            var TwelveInch = orders.SelectMany(a => a.Pizzas.Where(a => a.Size == 12 && !a.GlutenFree)).Count();

            kitchenInfo.GlutenFree  = glutenFree;
            kitchenInfo.EightInch   = eightInch;
            kitchenInfo.TwelveInch  = TwelveInch;
            kitchenInfo.TodaysSales = pizzaDict;
            kitchenInfo.TotalPizzas = orders.SelectMany(a => a.Pizzas.Where(b => !b.IsSide)).Count();

            var drinkDict = new Dictionary <string, int>();
            var drinks    = orders.SelectMany(a => a.Drinks).ToList();

            foreach (var d in drinks)
            {
                if (drinkDict.ContainsKey(d.Drink.DrinkName))
                {
                    var val = drinkDict[d.Drink.DrinkName];
                    drinkDict[d.Drink.DrinkName] = (val + 1);
                }
                else
                {
                    drinkDict.Add(d.Drink.DrinkName, 1);
                }
            }
            kitchenInfo.Drinks = drinkDict;
            return(kitchenInfo);
        }