예제 #1
0
 public IList<Record> GetInRange(IndexType type, DateTimeIntervals intervalType, IndexBarInfo barInfo, int startIndex, int count)
 {
     switch (type)
     {
         case IndexType.None:
             break;
         case IndexType.OEE:
             switch (barInfo.Level)
             {
                 case 0:
                     return GetOEEByDateTime(intervalType, startIndex, count);
                 case 1:
                     return GetOEEByMachines(barInfo, startIndex, count);
             }
             break;
         case IndexType.Performance:
             if (barInfo.Level == 0)
             {
                 return GetPerformanceByDateTime(intervalType, startIndex, count);
             }
             switch (barInfo.Filter)
             {
                 case IndexFilter.ByProduct:
                     return GetPerformanceByProducts(barInfo, startIndex, count);
                 case IndexFilter.ByStation:
                     return GetPerformanceByStations(barInfo, startIndex, count);
                 case IndexFilter.ByActivity:
                     return GetPerformanceByActivities(barInfo, startIndex, count);
                 case IndexFilter.ByOperator:
                     return GetPerformanceByOperators(barInfo, startIndex, count);
                 default:
                     return new List<Record>();
             }
         case IndexType.InternalPPM:
             switch (barInfo.Level)
             {
                 case 0:
                     return GetPPMByDateTime(intervalType, startIndex, count);
             }
             break;
         case IndexType.RemainingCapacity:
             switch (barInfo.Level)
             {
                 case 0:
                     return GetCapacityByDateTime(intervalType, startIndex, count);
             }
             break;
         default:
             throw new ArgumentOutOfRangeException("type");
     }
     return new List<Record>();
 }
예제 #2
0
        private IList<Record> GetPerformanceByActivities(IndexBarInfo indexInfo, int startIndex, int count)
        {
            IList<Record> records = new List<Record>();
            using (var context = new SoheilEdmContext())
            {
                var processRepository = new Repository<Process>(context);
                var processReportRepository = new Repository<ProcessReport>(context);
                var taskReportRepository = new Repository<TaskReport>(context);
                var processOperatortRepository = new Repository<ProcessOperator>(context);
                var operatorRepository = new Repository<Operator>(context);
                var ssaRepositoryRepository = new Repository<StateStationActivity>(context);
                var activityRepository = new Repository<Activity>(context);
                var stateStationRepository = new Repository<StateStation>(context);
                var stationRepository = new Repository<Station>(context);
                var stateRepository = new Repository<State>(context);
                var fpcRepository = new Repository<FPC>(context);
                var productRepository = new Repository<Product>(context);

                var processList = processRepository.GetAll();
                var processReportList = processReportRepository.GetAll();
                var taskReportList = taskReportRepository.GetAll();
                var processOperatortList = processOperatortRepository.GetAll();
                var operatorList = indexInfo.OperatorId > 0 ? operatorRepository.Find(item => item.Id == indexInfo.OperatorId) : operatorRepository.GetAll();
                var ssaList = ssaRepositoryRepository.GetAll();
                var activityList = activityRepository.GetAll();
                var stateStationList = stateStationRepository.GetAll();
                var stationList = indexInfo.StationId > 0 ? stationRepository.Find(item => item.Id == indexInfo.StationId) : stationRepository.GetAll();
                var stateList = stateRepository.GetAll();
                var fpcList = fpcRepository.GetAll();
                var productList = indexInfo.ProductId > 0 ? productRepository.Find(item => item.Id == indexInfo.ProductId) : productRepository.GetAll();

                var indexList = activityList.Skip(startIndex).Take(count).Select((p, index) => new { interval = index, p.Id, p.Code, p.Name });

                var activityQuery = from process in processList
                                   from processReport in processReportList.Where(ssapr => ssapr.Process != null && process != null && ssapr.Process.Id == process.Id).DefaultIfEmpty()
                                   from taskReport in taskReportList.Where(tr =>  tr.ReportStartDateTime >= indexInfo.StartDate && tr.ReportEndDateTime < indexInfo.EndDate).DefaultIfEmpty()
                                   from ssActivity in ssaList.Where(ssa => process != null && process.StateStationActivity != null && ssa.Id == process.StateStationActivity.Id).DefaultIfEmpty()
                                   from pOpr in processOperatortList.Where(po => po.Process != null && process != null && po.Process.Id == process.Id).DefaultIfEmpty()
                                   from opr in operatorList.Where(o => pOpr != null && pOpr.Operator != null && pOpr.Operator.Id == o.Id).DefaultIfEmpty()
                                   from stateStation in stateStationList.Where(ss => ssActivity != null && ssActivity.StateStation != null && ss.Id == ssActivity.StateStation.Id).DefaultIfEmpty()
                                   from station in stationList.Where(s => stateStation != null && stateStation.Station != null && s.Id == stateStation.Station.Id).DefaultIfEmpty()
                                   from state in stateList.Where(s => stateStation != null && stateStation.State != null && s.Id == stateStation.State.Id).DefaultIfEmpty()
                                   from fpc in fpcList.Where(f => state != null && state.FPC != null && f.Id == state.FPC.Id).DefaultIfEmpty()
                                   from product in productList.Where(p => fpc != null && fpc.Product != null && p.Id == fpc.Product.Id).DefaultIfEmpty()
                                   let producedG1 = processReport == null ? 0 : processReport.ProducedG1
                                   let targetCount = process == null ? 0 : process.TargetCount
                                   let aId = ssActivity == null ? -1 : (ssActivity.Activity == null ? -1 : ssActivity.Activity.Id)
                                   let prId = processReport == null ? -1 : processReport.Id
                                   let trId = taskReport == null ? -1 : taskReport.Id
                                   select new { pId = aId, prId, trId, producedG1, targetCount };

                var query = from index in indexList
                            from activity in activityQuery.Where(a => a.pId == index.Id).DefaultIfEmpty()
                            group activity by new { index.Id, index.interval, index.Code, index.Name } into g
                            let sumPg = g.Sum(item => item == null ? 0 : item.producedG1)
                            let sumTc = g.Sum(item => item == null ? 0 : item.targetCount)
                            select new { g.Key, value = sumTc == 0 ? 0 : sumPg / sumTc };

                for (int i = startIndex; i < count; i++)
                {
                    var newRecord = new Record { Header = i.ToString(CultureInfo.InvariantCulture) };
                    foreach (var line in query)
                    {
                        if (line.Key.interval + startIndex == i)
                        {
                            newRecord.Value = line.value;
                            newRecord.Value = 50; //???
                            newRecord.StartDate = indexInfo.StartDate;
                            newRecord.EndDate = indexInfo.EndDate;
                            newRecord.Header = line.Key.Name;
                        }
                    }
                    records.Add(newRecord);
                }
            }
            return records;
        }
예제 #3
0
        private IList<Record> GetOEEByMachines(IndexBarInfo indexInfo, int startIndex, int count)
        {
            IList<Record> records = new List<Record>();

            using (var context = new SoheilEdmContext())
            {
                var machineRepository = new Repository<Machine>(context);
                var selectedMachineRepository = new Repository<SelectedMachine>(context);
                var ssamRepository = new Repository<StateStationActivityMachine>(context);
                var ssaRepository = new Repository<StateStationActivity>(context);
                var processRepository = new Repository<Process>(context);
                var processReportRepository = new Repository<ProcessReport>(context);
                var taskReportRepository = new Repository<TaskReport>(context);

                var machineList = machineRepository.GetAll();
                var selectedMachineList = selectedMachineRepository.GetAll();
                var ssamList = ssamRepository.GetAll();
                var ssaList = ssaRepository.GetAll();
                var processList = processRepository.GetAll();
                var processReportList = processReportRepository.GetAll();
                var taskReportList = taskReportRepository.GetAll();

                var indexList = machineList.Skip(startIndex).Take(count).Select((m, index) => new { interval = index, m.Id, m.Code, m.Name });

                var pQuery = from ssamachine in ssamList
                            from selmachine in selectedMachineList.Where(sm => ssamachine != null && sm.StateStationActivityMachine != null && sm.StateStationActivityMachine.Id == ssamachine.Id).DefaultIfEmpty()
                            from process in processList.Where(p => selmachine != null && selmachine.Process != null && p.Id == selmachine.Process.Id).DefaultIfEmpty()
                            from ssActivity in ssaList.Where(ssa=> process!=null && process.StateStationActivity!=null && process.StateStationActivity.Id == ssa.Id).DefaultIfEmpty()
                            let mId = ssamachine == null ? -1 : (ssamachine.Machine == null? -1 : ssamachine.Machine.Id)
                            let pId = process == null ? -1 : process.Id
                            let cycleTime = ssActivity == null ? 0 : ssActivity.CycleTime
                            let targetCount = process == null ? 0 : process.TargetCount
                            select new { pId, mId, targetCount, cycleTime };

                var prQuery = from process in pQuery
                              from processReport in processReportList.Where(pr => process != null && pr.Process != null && pr.Process.Id == process.pId).DefaultIfEmpty()
                              from taskReport in taskReportList.Where(tr=>  tr.ReportStartDateTime >= indexInfo.StartDate && tr.ReportEndDateTime < indexInfo.EndDate).DefaultIfEmpty()
                              let mId = process == null ? -1 : process.mId
                              let producedG1 = processReport == null ? 0 : processReport.ProducedG1
                              let cycleTime = process == null ? 0 : process.cycleTime
                              let targetCount = process == null ? 0 : process.targetCount
                              select new { mId, fValue = cycleTime * producedG1, bValue = cycleTime * targetCount };

                var query = from machine in indexList
                             from pr in prQuery.Where(p => p.mId == machine.Id).DefaultIfEmpty()
                             group pr by new { machine.interval, machine.Id, machine.Code, machine.Name } into g
                             let sumf = g.Sum(item => item == null ? 0 : item.fValue)
                             let sumb = g.Sum(item => item == null ? 0 : item.bValue)
                             select new {g.Key.interval, mId = g.Key.Id, mCode = g.Key.Code, mName = g.Key.Name, value = sumb == 0 ? 0 : sumf / sumb };

                for (int i = startIndex; i < count; i++)
                {
                    var newRecord = new Record();
                    foreach (var line in query)
                    {
                        if (line.interval + startIndex == i)
                        {
                            newRecord.Value = line.value;
                            newRecord.StartDate = indexInfo.StartDate;
                            newRecord.EndDate = indexInfo.EndDate;
                            newRecord.Header = line.mName;
                        }
                    }
                    records.Add(newRecord);
                }
            }
            return records;
        }
예제 #4
0
        private int GetIntervalCount(IndexBarInfo info)
        {
            if (info.Level == 0)
            {
                int currentYear = DateTime.Now.Year;
                var startDate = new DateTime(currentYear, 1, 1);
                var endDate = new DateTime(currentYear + 1, 1, 1).AddDays(-1);

                switch (CurrentInterval)
                {
                    case DateTimeIntervals.Hourly:
                        return (int)Math.Ceiling((endDate - startDate).TotalHours);
                    case DateTimeIntervals.Shiftly:
                        return (int)Math.Ceiling((endDate - startDate).TotalDays * SoheilConstants.ShiftPerDay);
                    case DateTimeIntervals.Daily:
                        return (int)Math.Ceiling((endDate - startDate).TotalDays);
                    case DateTimeIntervals.Weekly:
                        return (int)Math.Ceiling((endDate - startDate).TotalDays / 7);
                    case DateTimeIntervals.Monthly:
                        return 12;
                    default:
                        return 12;
                }
            }
            switch (info.Filter)
            {
                case IndexFilter.None:
                    break;
                case IndexFilter.ByProduct:
                    return DataService.GetProductCount();
                case IndexFilter.ByStation:
                    return DataService.GetStationCount();
                case IndexFilter.ByActivity:
                    return DataService.GetActivityCount();
                case IndexFilter.ByOperator:
                    return DataService.GetOperatorCount();
                case IndexFilter.ByMachine:
                    return DataService.GetMachineCount();
                case IndexFilter.ByCauseL1:
                    break;
                case IndexFilter.ByCauseL2:
                    break;
                case IndexFilter.ByCauseL3:
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return 12;
        }
예제 #5
0
		public void InitializeProviders(object param)
		{

            var indexId = new IndexBarInfo();
		    if (param == null)
		        _history.Push(new IndexBarInfo());
		    else
                indexId = (IndexBarInfo)param;

            LittleWindowWidth = 20;
            int intervalCount = GetIntervalCount(indexId);

            BarSlides = new VirtualizingCollection<IndexBarSlideItemVm>(new IndexBarSlideProvider(intervalCount), 6);

            var barProvider = new IndexBarProvider(intervalCount, 600, CurrentType, CurrentInterval, DataService, indexId);
            Bars = new VirtualizingCollection<IndexBarVm>(barProvider, 6);

            Scales.Clear();
            ScaleLines.Clear();

            for (int i = barProvider.MaxScale + barProvider.StepScale; i >= 0; i -= barProvider.StepScale)
            {
                Scales.Add(i);
                ScaleLines.Add(0);
            }
            ScaleLines.RemoveAt(0);
		}