public static DateTime GetPlanStartTime(IExperimentResultItem result) { if (result.Experiment.GetArgument("nextShiftVer", false)) { int shift = ShopCalendar.ClassifyShift(GetPlanStartTime_OLD(result).AddHours(8)); return(ShopCalendar.GetShiftStartTime(GetPlanStartTime_OLD(result).AddHours(8), shift)); } else { var st = result.Experiment.GetArgument("start-time"); if (st == null) { return(DateTime.Now); } var planStartTime = DateTime.MinValue; try { planStartTime = st.ToString().DbToDateTime(); } catch { return(DateTime.Now); } if (planStartTime == DateTime.MinValue) { return(DateTime.Now); } return(planStartTime); } }
private void InitializeData() { var modelContext = this._result.GetCtx <ModelDataContext>(); _totalWoListDic = new Dictionary <string, List <WoData.WorkOrder> >(); string filter = Globals.CreateFilter(string.Empty, SimResultData.EqpPlan.Schema.SHOP_ID, "=", this.SelectedShopID); filter = Globals.CreateFilter(filter, SimResultData.EqpPlan.Schema.EQP_ID, "<>", Consts.NULL_ID, "AND"); filter = Globals.CreateFilter(filter, SimResultData.EqpPlan.Schema.START_TIME, ">=", this.FromTime.ToString(), "AND"); filter = Globals.CreateFilter(filter, SimResultData.EqpPlan.Schema.START_TIME, "<", this.ToTime.ToString(), "AND"); DataTable dtEqpPlan = _result.LoadOutput(SimResultData.OutputName.EqpPlan, filter); string sorter = SimResultData.EqpPlan.Schema.SHOP_ID + "," + SimResultData.EqpPlan.Schema.EQP_ID + "," + SimResultData.EqpPlan.Schema.START_TIME + "," + SimResultData.EqpPlan.Schema.PRODUCT_ID + "," + SimResultData.EqpPlan.Schema.LAYER_ID + "," + SimResultData.EqpPlan.Schema.STEP_ID; DataView eqpPlanView = new DataView(dtEqpPlan, "", sorter, DataViewRowState.CurrentRows); dtEqpPlan = eqpPlanView.ToTable(); int totalRowCnt = dtEqpPlan.Rows.Count; bool isLast = false; WoData.WorkOrder workOrder = new WoData.WorkOrder(); int rowCnt = 0; string preShopEqp = string.Empty; string preShopEqpProd = string.Empty; string preStepInfo = string.Empty; DateTime preEndTime = DateTime.MaxValue; foreach (DataRow row in dtEqpPlan.Rows) { rowCnt++; SimResultData.EqpPlan eqpPlan = new SimResultData.EqpPlan(row); if (eqpPlan.EqpID == "8APPH13") { } string shift = ShopCalendar.ClassifyShift(eqpPlan.StartTime) == 1 ? WoData.Const.DAY : WoData.Const.NIGHT; if (rowCnt == 1) { string eqpGrpIdInEqp; if (_eqpGrpInEqpDic.TryGetValue(eqpPlan.ShopID + eqpPlan.EqpID, out eqpGrpIdInEqp) == false) { eqpGrpIdInEqp = string.Empty; } workOrder.SetBaseInfo(eqpPlan.ShopID, eqpPlan.EqpID, eqpPlan.EqpGroupID, eqpGrpIdInEqp, eqpPlan.ProductID, shift, eqpPlan.StartTime, eqpPlan.LayerID, eqpPlan.StepID); } string shopEqp = eqpPlan.ShopID + eqpPlan.EqpID; string shopEqpProd = eqpPlan.ShopID + eqpPlan.EqpID + eqpPlan.ProductID; string stepInfo = eqpPlan.LayerID + eqpPlan.StepID; bool isNew = false; if (shopEqp != preShopEqp) { isNew = true; } else if (shopEqpProd != preShopEqpProd) { isNew = true; } else if (eqpPlan.StartTime > preEndTime) { isNew = true; } else if (preStepInfo != stepInfo) { isNew = true; } if (rowCnt == totalRowCnt) { isLast = true; } bool savePreVal = false; bool newWorkOrder = false; if ((isNew == false && isLast == false) || rowCnt == 1) { workOrder.AddQty(eqpPlan.Qty); } else if (isNew && isLast == false) { savePreVal = true; // 여태까지꺼 rlst에 기록 newWorkOrder = true; // workOrder 새로 만들기 + Qty추가 } else if (isNew == false && isLast) { savePreVal = true; workOrder.AddQty(eqpPlan.Qty); } else if (isNew && isLast) { savePreVal = true; // 여태까지꺼 rlst에 기록 newWorkOrder = true; // workOrder 새로 만들고 + Qty추가하고 + rlst에 기록 } if (savePreVal) { List <WoData.WorkOrder> woList; if (_totalWoListDic.TryGetValue(preShopEqp, out woList) == false) { _totalWoListDic.Add(preShopEqp, woList = new List <WoData.WorkOrder>()); } woList.Add(workOrder); } if (newWorkOrder) { string eqpGrpIdInEqp; if (_eqpGrpInEqpDic.TryGetValue(eqpPlan.ShopID + eqpPlan.EqpID, out eqpGrpIdInEqp) == false) { eqpGrpIdInEqp = string.Empty; } workOrder = new WoData.WorkOrder(); workOrder.SetBaseInfo(eqpPlan.ShopID, eqpPlan.EqpID, eqpPlan.EqpGroupID, eqpGrpIdInEqp, eqpPlan.ProductID, shift, eqpPlan.StartTime, eqpPlan.LayerID, eqpPlan.StepID); workOrder.AddQty(eqpPlan.Qty); if (isLast) { List <WoData.WorkOrder> woList; if (_totalWoListDic.TryGetValue(shopEqp, out woList) == false) { _totalWoListDic.Add(shopEqp, woList = new List <WoData.WorkOrder>()); } woList.Add(workOrder); } } preShopEqp = shopEqp; preShopEqpProd = shopEqpProd; preEndTime = eqpPlan.EndTime; preStepInfo = stepInfo; } }