Beispiel #1
0
        public static double CalculateCurrentShiftEff(DataGridView lgGrid)
        {
            List <OrderDataForEfficiencyStructure> currentShiftOrders = GetCurrentShiftLgOrders(lgGrid).OrderBy(o => o.rowIndex).ToList();

            if (currentShiftOrders.Count < 0)
            {
                return(-1);
            }
            List <Tuple <double, double> > ordersEffDurationList = new List <Tuple <double, double> >();


            foreach (var order in currentShiftOrders)
            {
                int changeOverTime = 5;
                if (order.rowIndex <= lgGrid.Rows.Count - 1)
                {
                    if (order.modelId != lgGrid.Rows[order.rowIndex + 1].Cells["ColumnModel"].Value.ToString())
                    {
                        changeOverTime = 25;
                    }
                }

                ordersEffDurationList.Add(new Tuple <double, double>(
                                              EfficiencyCalculation.CalculateEfficiency(order.start, order.end.AddMinutes(-changeOverTime), order.modelId, order.qty, false),
                                              (order.end - order.start).TotalHours));
            }

            return(EfficiencyCalculation.WeightedAverage(ordersEffDurationList) * 100);
        }
        public static double CalculateCurrentShiftEff(CurrentMstOrder currentMstOrder, DataGridView mstGrid)
        {
            List <OrderDataForEfficiencyStructure> currentShiftOrders = GetCurrentShiftMstOrders(mstGrid);

            List <Tuple <double, double> > ordersEffDurationList = new List <Tuple <double, double> >();

            if ((currentMstOrder.LastUpdateTime - currentMstOrder.DateStart).TotalHours > 0 & currentMstOrder.Nc10 != "")
            {
                ordersEffDurationList.Add(new Tuple <double, double>(EfficiencyCalculation.CalculateEfficiency(currentMstOrder.DateStart, currentMstOrder.LastUpdateTime, currentMstOrder.Nc10, currentMstOrder.MadeQty, true),
                                                                     (currentMstOrder.LastUpdateTime - currentMstOrder.DateStart).TotalHours));
            }

            foreach (var order in currentShiftOrders)
            {
                try
                {
                    ordersEffDurationList.Add(new Tuple <double, double>(
                                                  EfficiencyCalculation.CalculateEfficiency(order.start, order.end, order.modelId, order.qty, true),
                                                  (order.end - order.start).TotalHours));
                }
                catch { continue; }
            }
            if (ordersEffDurationList.Count > 0)
            {
                return(EfficiencyCalculation.WeightedAverage(ordersEffDurationList) * 100);
            }
            return(-1);
        }
Beispiel #3
0
        public static void FillOutListView(ListView lV, List <EfficiencyCalculation.OrderDataForEfficiencyStructure> ordersEff)
        {
            Dictionary <string, List <EfficiencyCalculation.OrderDataForEfficiencyStructure> > grouppedByDateShift = new Dictionary <string, List <EfficiencyCalculation.OrderDataForEfficiencyStructure> >();

            foreach (var orderEff in ordersEff.OrderByDescending(o => o.dateShiftOwner.fixedDate))
            {
                string dateShiftKey = $"{orderEff.dateShiftOwner.fixedDate.ToString("dd-MMM")} {orderEff.dateShiftOwner.shift}zm.";
                if (!grouppedByDateShift.ContainsKey(dateShiftKey))
                {
                    grouppedByDateShift.Add(dateShiftKey, new List <EfficiencyCalculation.OrderDataForEfficiencyStructure>());
                }
                grouppedByDateShift[dateShiftKey].Add(orderEff);
            }

            foreach (var shiftEntry in grouppedByDateShift)
            {
                List <Tuple <double, double> > effDurationList = new List <Tuple <double, double> >();
                foreach (var order in shiftEntry.Value)
                {
                    var eff = EfficiencyCalculation.CalculateEfficiency(order.start, order.end, order.modelId, order.qty, true);

                    effDurationList.Add(new Tuple <double, double>(eff, (order.end - order.start).TotalHours));
                }

                var weightedAvergae = Math.Round(EfficiencyCalculation.WeightedAverage(effDurationList) * 100, 0) + "%";

                var item = new ListViewItem(new[] { shiftEntry.Key, shiftEntry.Value.Select(o => o.qty).Sum().ToString(), weightedAvergae.ToString() });
                lV.Items.Add(item);
            }

            foreach (ColumnHeader column in lV.Columns)
            {
                column.Width = -2; //=autosize
            }
        }