예제 #1
0
        public List <ReliabilitySummary> ConvertDictionaryToList(Dictionary <string, Dictionary <string, List <ReliabilitySummary> > > keyValuePairs, string ClientOrDept)
        {
            List <ReliabilitySummary> reliabilitySummaries = new List <ReliabilitySummary>();

            foreach (var ClientsGroup in keyValuePairs)
            {
                foreach (var DeptGroup in ClientsGroup.Value)
                {
                    if (DeptGroup.Key == "Total")
                    {
                        if (ClientOrDept == "client")
                        {
                            ReliabilitySummary reliability = new ReliabilitySummary();
                            reliability.Clients          = ClientsGroup.Key;
                            reliability.DepartmentCode   = "Total";
                            reliability.Orders           = DeptGroup.Value.Select(d => d.Orders).Sum();
                            reliability.OrdersOT         = DeptGroup.Value.Select(d => d.OrdersOT).Sum();
                            reliability.OrdesEarly       = DeptGroup.Value.Select(d => d.OrdesEarly).Sum();
                            reliability.OrdesLate        = DeptGroup.Value.Select(d => d.OrdesLate).Sum();
                            reliability.Reliability      = (reliability.OrdersOT + reliability.OrdesEarly) / reliability.Orders;
                            reliability.OTS              = DeptGroup.Value.Select(d => d.OTS).Average();
                            reliability.DeliveryQuantity = DeptGroup.Value.Select(d => d.DeliveryQuantity).Sum();
                            reliability.SOMO             = DeptGroup.Value.Select(d => d.SOMO).Average();
                            reliability.ReqOTS           = DeptGroup.Value.Select(d => d.ReqOTS).Average();
                            reliabilitySummaries.Add(reliability);
                        }
                        else if (ClientOrDept == "dept")
                        {
                            ReliabilitySummary reliability = new ReliabilitySummary();
                            reliability.Clients          = "Total";
                            reliability.DepartmentCode   = ClientsGroup.Key;
                            reliability.Orders           = DeptGroup.Value.Select(d => d.Orders).Sum();
                            reliability.OrdersOT         = DeptGroup.Value.Select(d => d.OrdersOT).Sum();
                            reliability.OrdesEarly       = DeptGroup.Value.Select(d => d.OrdesEarly).Sum();
                            reliability.OrdesLate        = DeptGroup.Value.Select(d => d.OrdesLate).Sum();
                            reliability.Reliability      = (reliability.OrdersOT + reliability.OrdesEarly) / reliability.Orders;
                            reliability.OTS              = DeptGroup.Value.Select(d => d.OTS).Average();
                            reliability.DeliveryQuantity = DeptGroup.Value.Select(d => d.DeliveryQuantity).Sum();
                            reliability.SOMO             = DeptGroup.Value.Select(d => d.SOMO).Average();
                            reliability.ReqOTS           = DeptGroup.Value.Select(d => d.ReqOTS).Average();
                            reliabilitySummaries.Add(reliability);
                        }
                    }
                    else
                    {
                        foreach (var item in DeptGroup.Value)
                        {
                            reliabilitySummaries.Add(item);
                        }
                    }
                }
            }
            return(reliabilitySummaries);
        }
예제 #2
0
        public Dictionary <string, Dictionary <string, List <ReliabilitySummary> > > SortbyDepartmentsRealitykeyValuePairs(List <RawReliability> listRawData)
        {
            Dictionary <string, Dictionary <string, List <ReliabilitySummary> > > keyValuePairs = new Dictionary <string, Dictionary <string, List <ReliabilitySummary> > >();

            var listGroupByClient = listRawData
                                    .GroupBy(u => u.DepartmentCode)
                                    .Select(grp => grp.ToList())
                                    .ToList();

            foreach (var ClientS in listGroupByClient)
            {
                var ListGroupByDept = ClientS
                                      .GroupBy(u => u.ClientsEnd)
                                      .Select(grp => grp.ToList())
                                      .ToList();
                Dictionary <string, List <ReliabilitySummary> > DeptReliability = new Dictionary <string, List <ReliabilitySummary> >();
                List <ReliabilitySummary> reliabilities      = new List <ReliabilitySummary>();
                List <ReliabilitySummary> reliabilitiesTotal = new List <ReliabilitySummary>();
                foreach (var dept in ListGroupByDept)
                {
                    ReliabilitySummary reliability = new ReliabilitySummary();
                    reliabilities              = new List <ReliabilitySummary>();
                    reliability.Clients        = dept[0].ClientsEnd;
                    reliability.DepartmentCode = dept[0].DepartmentCode;
                    int CountLate   = dept.Where(d => d.Evaluation == "Late").Count();
                    int CountOntime = dept.Where(d => d.Evaluation == "On-time").Count();
                    int CountEarly  = dept.Where(d => d.Evaluation == "Early").Count();
                    reliability.DeliveryQuantity = dept.Select(d => d.DeliveryQuantity).Sum();
                    reliability.OTS         = dept.Select(d => d.OTS).Average();
                    reliability.SOMO        = dept.Select(d => d.SOMO).Average();
                    reliability.ReqOTS      = dept.Select(d => d.ReqOTS).Average();
                    reliability.Orders      = CountLate + CountOntime + CountEarly;
                    reliability.OrdersOT    = CountOntime;
                    reliability.OrdesEarly  = CountEarly;
                    reliability.OrdesLate   = CountLate;
                    reliability.Reliability = (reliability.OrdesEarly + reliability.OrdersOT) / reliability.Orders;
                    reliabilities.Add(reliability);
                    reliabilitiesTotal.Add(reliability);
                    DeptReliability.Add(reliability.Clients, reliabilities);
                }
                DeptReliability.Add("Total", reliabilitiesTotal);
                keyValuePairs.Add(ClientS[0].DepartmentCode, DeptReliability);
            }
            return(keyValuePairs);
        }