Example #1
0
        private void ProcessData()
        {
            _stepTatRsltInf  = new Dictionary <string, TcData.StepTatRsltInf>();
            _totalTatRsltInf = new Dictionary <string, TcData.TotalTatRsltInf>();

            var seleSimTatInfoDic = _simTatInfoDic.Values.Where(x => x.ShopID == this.SelectedShopID)
                                    .Where(x => this.IsSeletectedAllProduct ? true : this.SelectedProductList.Contains(x.ProductID))
                                    .Where(x => this.FromTime <= x.TargetShift & x.TargetShift < this.ToTime);

            Dictionary <string, List <string> >    simStepListDic = new Dictionary <string, List <string> >();
            Dictionary <string, TcData.SimTatInfo> simTatInfoDic  = new Dictionary <string, TcData.SimTatInfo>();

            foreach (var info in seleSimTatInfoDic)
            {
                string key = info.ShopID + info.ProductID + info.MainProcessID + info.StepID;

                TcData.SimTatInfo simTatInfo;
                if (simTatInfoDic.TryGetValue(key, out simTatInfo) == false)
                {
                    simTatInfoDic.Add(key, simTatInfo = new TcData.SimTatInfo(info.ShopID, info.TargetShift,
                                                                              info.ProductID, info.MainProcessID, info.StepID));
                }

                simTatInfo.AddRunTatToList(info.RunTatList);
                simTatInfo.AddWaitTatToList(info.WaitTatList);

                string        key2 = CommonHelper.CreateKey(info.ShopID, info.ProductID, info.MainProcessID);
                List <string> stepList;
                if (simStepListDic.TryGetValue(key2, out stepList) == false)
                {
                    simStepListDic.Add(key2, stepList = new List <string>());
                }

                if (stepList.Contains(info.StepID) == false)
                {
                    stepList.Add(info.StepID);
                }
            }

            foreach (var info in simTatInfoDic.Values)
            {
                string key = info.ShopID + info.ProductID + info.MainProcessID + info.StepID;

                TcData.StepInfo stdStepInfo;
                _stdStepDic.TryGetValue(info.ShopID + info.StepID, out stdStepInfo);

                TcData.StepTatRsltInf stepTatRsltInf;
                if (_stepTatRsltInf.TryGetValue(key, out stepTatRsltInf) == false)
                {
                    _stepTatRsltInf.Add(key, stepTatRsltInf = new TcData.StepTatRsltInf(info.ShopID, info.ProductID,
                                                                                        info.MainProcessID, info.StepID, stdStepInfo));
                }

                stepTatRsltInf.SetSimulationTat(info.WaitTatAvg, info.RunTatAvg);
            }

            foreach (var info in _tatDic.Values)
            {
                string key = info.ShopID + info.ProdID + info.ProcID + info.StepID;

                TcData.StepTatRsltInf stepTatRsltInf;
                if (_stepTatRsltInf.TryGetValue(key, out stepTatRsltInf) == false)
                {
                    continue;
                }

                stepTatRsltInf.SetActualTat(info.WaitTat, info.RunTat);

                bool isAddTotalTat = this.IsAllStepRunChecked == false ||
                                     (this.IsAllStepRunChecked && _allStepRunProdInSimList.Contains(info.ShopID + info.ProdID));

                string key2 = CommonHelper.CreateKey(info.ShopID, info.ProdID, info.ProcID);
                TcData.TotalTatRsltInf totalTatRsltInf;
                if (_totalTatRsltInf.TryGetValue(key2, out totalTatRsltInf) == false && isAddTotalTat)
                {
                    _totalTatRsltInf.Add(key2, totalTatRsltInf = new TcData.TotalTatRsltInf(info.ShopID, info.ProdID, info.ProcID));

                    totalTatRsltInf.SetActTat(info.TotalTat);
                }
            }

            foreach (KeyValuePair <string, TcData.TotalTatRsltInf> pair in _totalTatRsltInf)
            {
                string shopID = pair.Key.Split('@')[0];
                string prodID = pair.Key.Split('@')[1];
                string procID = pair.Key.Split('@')[2];

                string          key = CommonHelper.CreateKey(shopID, procID);
                List <ProcStep> procStepList;
                if (_procStepDic.TryGetValue(key, out procStepList) == false)
                {
                    continue;
                }

                foreach (ProcStep procStep in procStepList)
                {
                    double stepTat = _defaultWaitTat + _defaultRunTat;

                    TcData.StepTatRsltInf stepTatRsltInf;
                    if (_stepTatRsltInf.TryGetValue(shopID + prodID + procID + procStep.STEP_ID, out stepTatRsltInf))
                    {
                        stepTat = stepTatRsltInf.TatSim;
                    }

                    pair.Value.AddSimTat(stepTat);
                }
            }
        }
Example #2
0
        private void InitializeData()
        {
            var modelContext = this._result.GetCtx <ModelDataContext>();

            _stdStepDic = new Dictionary <string, TcData.StepInfo>();
            var stdStep = modelContext.StdStep.Where(x => x.STEP_SEQ > 0)
                          .OrderBy(x => x.SHOP_ID);//.OrderByDescending(x => x.STEP_SEQ);

            foreach (var step in stdStep)
            {
                if (_stdStepDic.ContainsKey(step.SHOP_ID + step.STEP_ID) == false)
                {
                    _stdStepDic.Add(step.SHOP_ID + step.STEP_ID, new TcData.StepInfo(step.SHOP_ID, step.STEP_ID,
                                                                                     step.STEP_DESC, step.STEP_TYPE, (int)step.STEP_SEQ, step.LAYER_ID));
                }
            }

            try
            {
                _defaultRunTat = this.IsUseDefaultTatChecked ?
                                 Convert.ToDouble(_result.Experiment.GetArgument("DefaultRunTAT")) : 0.0;

                _defaultWaitTat = this.IsUseDefaultTatChecked ?
                                  Convert.ToDouble(_result.Experiment.GetArgument("DefaultWaitTAT")) : 0.0;
            }
            catch
            {
                _defaultWaitTat = 0;
                _defaultRunTat  = 0;
            }


            var dtProduct = modelContext.Product;

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

            foreach (var prod in dtProduct)
            {
                if (mainProcByProdDic.ContainsKey(prod.SHOP_ID + prod.PRODUCT_ID) == false)
                {
                    mainProcByProdDic.Add(prod.SHOP_ID + prod.PRODUCT_ID, prod.PROCESS_ID);
                }
            }

            var dtTat = modelContext.Tat;//modelContext.Tat.Where(x => x.PRODUCT_TYPE == Consts.Production);

            Dictionary <string, TcData.TatInfo> tatAllDic = new Dictionary <string, TcData.TatInfo>();

            foreach (var row in dtTat)
            {
                TcData.TatInfo tatInfo = new TcData.TatInfo(row.WAIT_TAT, row.RUN_TAT);
                if (tatAllDic.ContainsKey(row.SHOP_ID + row.PRODUCT_ID + row.PROCESS_ID + row.STEP_ID) == false)
                {
                    tatAllDic.Add(row.SHOP_ID + row.PRODUCT_ID + row.PROCESS_ID + row.STEP_ID, tatInfo);
                }
            }

            var dtProcStepMand = modelContext.ProcStep.OrderBy(x => x.SHOP_ID + x.PROCESS_ID).OrderBy(x => x.STEP_SEQ);

            _procStepDic = new Dictionary <string, List <ProcStep> >();
            foreach (var row in dtProcStepMand)
            {
                string key = CommonHelper.CreateKey(row.SHOP_ID, row.PROCESS_ID);

                List <ProcStep> list;
                if (_procStepDic.TryGetValue(key, out list) == false)
                {
                    _procStepDic.Add(key, list = new List <ProcStep>());
                }

                list.Add(row);
            }

            List <string> mainProcInEqpPlanList = new List <string>();
            DataTable     dtEqpPlan             = _result.LoadOutput(SimResultData.OutputName.EqpPlan);

            foreach (DataRow drow in dtEqpPlan.Rows)
            {
                SimResultData.EqpPlan eqpPlan = new SimResultData.EqpPlan(drow);

                string mainProcID = string.Empty;
                mainProcByProdDic.TryGetValue(eqpPlan.ShopID + eqpPlan.ProductID, out mainProcID);
                if (string.IsNullOrEmpty(mainProcID))
                {
                    continue;
                }

                string item = CommonHelper.CreateKey(eqpPlan.ShopID, eqpPlan.ProductID, mainProcID);
                if (mainProcInEqpPlanList.Contains(item) == false)
                {
                    mainProcInEqpPlanList.Add(item);
                }
            }

            // 기준정보 Tat 집계
            _tatDic = new Dictionary <string, TcData.ProcStepTatInfo>();
            foreach (string item in mainProcInEqpPlanList)
            {
                string shopID     = item.Split('@')[0];
                string prodID     = item.Split('@')[1];
                string mainProcID = item.Split('@')[2];

                string          key = CommonHelper.CreateKey(shopID, mainProcID);
                List <ProcStep> procStepList;
                if (_procStepDic.TryGetValue(key, out procStepList) == false)
                {
                    continue;
                }

                double        cumTat  = 0;
                List <string> keyList = new List <string>();
                foreach (ProcStep procStep in procStepList)
                {
                    double waitTat = _defaultWaitTat;
                    double runTat  = _defaultWaitTat;
                    double tat     = waitTat + runTat;

                    string         key2 = procStep.SHOP_ID + prodID + procStep.PROCESS_ID + procStep.STEP_ID;
                    TcData.TatInfo tatInfo;
                    if (tatAllDic.TryGetValue(key2, out tatInfo))
                    {
                        waitTat = tatInfo.WaitTat;
                        runTat  = tatInfo.RunTat;
                        tat     = tatInfo.Tat;
                    }

                    cumTat += tat;

                    TcData.ProcStepTatInfo psTatInfo;
                    if (_tatDic.TryGetValue(key2, out psTatInfo) == false)
                    {
                        _tatDic.Add(key2, psTatInfo = new TcData.ProcStepTatInfo(procStep.SHOP_ID, prodID, procStep.PROCESS_ID,
                                                                                 procStep.STEP_ID, procStep.STEP_SEQ, waitTat, runTat, cumTat));
                    }

                    if (keyList.Contains(key2) == false)
                    {
                        keyList.Add(key2);
                    }
                }

                double totalTat = cumTat;

                foreach (string k in keyList)
                {
                    TcData.ProcStepTatInfo psTatInfo;
                    if (_tatDic.TryGetValue(k, out psTatInfo) == false)
                    {
                        continue; // 있을 수 없음
                    }
                    psTatInfo.SetTotalTat(totalTat);
                }
            }

            // Simuation Run, Wait TAT 산출 && 시뮬레이션에서 FabIn부터 FabOut까지 흐른 Product 집계
            _simTatInfoDic           = new Dictionary <string, TcData.SimTatInfo>();
            _allStepRunProdInSimList = new List <string>();

            var eqpPlanDic = dtEqpPlan.AsEnumerable()
                             .GroupBy(x => x.GetString(SimResultData.EqpPlanSchema.LOT_ID))
                             .ToDictionary(x => x.Key);

            foreach (string lotID in eqpPlanDic.Keys)
            {
                var sortedList = eqpPlanDic[lotID].OrderBy(x => x.GetDateTime(SimResultData.EqpPlanSchema.START_TIME));
                if (sortedList.Count() >= 2)
                {
                    var firstRow = sortedList.ToList()[0];
                    foreach (var row in sortedList)
                    {
                        string rowShopID = row.GetString(SimResultData.EqpPlanSchema.SHOP_ID);
                        string rowStepID = row.GetString(SimResultData.EqpPlanSchema.STEP_ID);

                        if (_stdStepDic.ContainsKey(rowShopID + rowStepID))
                        {
                            firstRow = row;
                            break;
                        }
                    }

                    var lastRow = sortedList.ToList()[sortedList.Count() - 1];

                    string shopID = firstRow.GetString(SimResultData.EqpPlanSchema.SHOP_ID);
                    string prodID = firstRow.GetString(SimResultData.EqpPlanSchema.PRODUCT_ID);

                    string mainProcID = string.Empty;
                    mainProcByProdDic.TryGetValue(shopID + prodID, out mainProcID);
                    if (string.IsNullOrEmpty(mainProcID) == false)
                    {
                        string          key = CommonHelper.CreateKey(shopID, mainProcID);
                        List <ProcStep> procStepList;
                        if (_procStepDic.TryGetValue(key, out procStepList) && procStepList.Count() >= 2)
                        {
                            string firstStepReal = procStepList[0].STEP_ID;
                            string lastStepReal  = procStepList[procStepList.Count() - 1].STEP_ID;

                            string firstStepLot = firstRow.GetString(SimResultData.EqpPlanSchema.STEP_ID);
                            string lastStepLot  = lastRow.GetString(SimResultData.EqpPlanSchema.STEP_ID);

                            if (firstStepReal == firstStepLot && lastStepReal == lastStepLot)
                            {
                                if (_allStepRunProdInSimList.Contains(shopID + prodID) == false)
                                {
                                    _allStepRunProdInSimList.Add(shopID + prodID);
                                }
                            }
                        }
                    }
                }

                DateTime preRowEndTime = DateTime.MinValue;
                foreach (var row in sortedList)
                {
                    string   shopID    = row.GetString(SimResultData.EqpPlanSchema.SHOP_ID);
                    string   prodID    = row.GetString(SimResultData.EqpPlanSchema.PRODUCT_ID);
                    string   procID    = row.GetString(SimResultData.EqpPlanSchema.PROCESS_ID);
                    string   stepID    = row.GetString(SimResultData.EqpPlanSchema.STEP_ID);
                    DateTime startTime = row.GetDateTime(SimResultData.EqpPlanSchema.START_TIME);
                    DateTime endTime   = row.GetDateTime(SimResultData.EqpPlanSchema.END_TIME);

                    // 시뮬레이션 투입 Lot은 EqpPlan에 ARRAY/ARRAY00000 이런 식으로 정보가 한 줄 더 찍힘 -> 이에 대한 예외처리
                    if (_stdStepDic.ContainsKey(shopID + stepID) == false)
                    {
                        continue;
                    }

                    string mainChecker = CommonHelper.CreateKey(shopID, prodID, procID);
                    if (mainProcInEqpPlanList.Contains(mainChecker) == false)
                    {
                        preRowEndTime = endTime;
                        continue;
                    }

                    double runTAT  = endTime > startTime ? (endTime - startTime).TotalSeconds : 0;
                    double waitTAT = preRowEndTime == DateTime.MinValue ? 0
                        : startTime > preRowEndTime ? (startTime - preRowEndTime).TotalSeconds : 0;

                    if (runTAT <= 0 && preRowEndTime == DateTime.MinValue)
                    {
                        preRowEndTime = endTime;
                        continue;
                    }

                    DateTime targetShift = ShopCalendar.ShiftStartTimeOfDayT(startTime);

                    TcData.SimTatInfo simTatInfo;
                    if (_simTatInfoDic.TryGetValue(shopID + targetShift + prodID + procID + stepID, out simTatInfo) == false)
                    {
                        _simTatInfoDic.Add(shopID + targetShift + prodID + procID + stepID,
                                           simTatInfo = new TcData.SimTatInfo(shopID, targetShift, prodID, procID, stepID));
                    }

                    if (runTAT > 0)
                    {
                        simTatInfo.AddRunTatToList(runTAT);
                    }

                    if (preRowEndTime != DateTime.MinValue)
                    {
                        simTatInfo.AddWaitTatToList(waitTAT);
                    }

                    preRowEndTime = endTime;
                }
            }
        }