public void GetTableDataByManual(string lot, string startDate, string endDate) { LotStr = lot; StartDate = startDate; EndDate = endDate; var lots = lot.Split(','); var lots_single = lots.Where(w => !w.Contains("*")); var lots_like = lots.Except(lots_single).Select(s => s.Replace('*', '%')); string condition = string.Format("where claim_time between '{0}' and '{1} 23:59:59' and ctrl_job !='' ", startDate, endDate); HisCatcher.Conditions = string.Format("{0} and ( lot_id in ('{1}') or lot_id like '{2}' )", condition, string.Join("','", lots_single), string.Join("' or lot_id like '", lots_like)); var list = HisCatcher.GetEntities().EntityList; if (!list.Any()) { throw new Exception("没有数据"); } var group = list.GroupBy(g => new { g.Lot_ID, g.Ctrl_Job }); foreach (var g in group) { var opeStart = g.Where(w => w.Ope_Category == "OperationStart").FirstOrDefault(); if (opeStart is null) { continue; } var opeEnd = g.Where(w => w.Ope_Category == "OperationComplete" || w.Ope_Category == "ForceComp").FirstOrDefault(); var entity = new ReqRpt214TableRowEntity() { LotID = g.Key.Lot_ID, FoupID = opeStart.Cast_ID, Qty = opeStart.Cur_Wafer_Qty, OperID = opeStart.ModulePD_ID, EqpID = opeStart.Eqp_ID, EqpType = opeStart.Eqp_Type, //Position = opeStart.Pos, OperName = opeStart.PD_Name, OperNo = opeStart.Ope_NO, OpeStartTime = opeStart.Claim_Time.ToString("yyyy-MM-dd HH:mm:ss"), OpeCompleteTime = (opeEnd is null) ? "" : opeEnd.Claim_Time.ToString("yyyy-MM-dd HH:mm:ss"), RecipeID = opeStart.Recipe_ID, RouteID = opeStart.MainPD_ID, RunHrs = (opeEnd is null) ? "On Running" : (opeEnd.Claim_Time - opeStart.Claim_Time).TotalHours.ToString("0.00"), UserDept = opeStart.Dept, UserFullName = opeStart.User_Full_Name, UserID = opeStart.Claim_User_ID, //Prod = opeStart.ProdSpec_ID, }; for (var i = 0; i < 25; i++) { string waferNumber = i < 10 ? "0" + i.ToString() : i.ToString(); //entity.WaferValue.Add(Str2DoubleNullable(g.Where(w => w.Wafer_ID.Length > 2 && w.Wafer_ID.Substring(w.Wafer_ID.Length - 2) == waferNumber).Select(s => s.DcItem_Value).FirstOrDefault())); entity.WaferValue.Add(""); } RowEntities.Add(entity); } }
void Initialize() { string strEqps = string.Join("','", EqpList); EdcCatcher.Conditions = string.Format("where eqp_id in ('{0}')", strEqps); var edcList = EdcCatcher.GetEntities().EntityList; if (!edcList.Any()) { throw new Exception("DB中没有找到相关EDC Plan"); } ProcCatcher.Conditions = string.Format("where proc_eqp_id in ('{0}')", strEqps); var procList = ProcCatcher.GetEntities().EntityList; foreach (var eqp in EqpList) { var row = new ReqRpt047TableRowEntity() { EqpID = eqp }; var edc_row = edcList.Where(w => w.Eqp_ID == eqp); foreach (var edc in edc_row) { var entity = new ReqRpt047TableEntity { EdcPlan = edc.Edc_Plan, Period = edc.Period, PeriodType = edc.Period_Type }; var proc = procList.Where(w => w.Proc_Eqp_ID == eqp && w.DCItem_Name == edc.Edc_Plan); if (proc.Any()) { var proc_first = proc.First(); var periodStartTime = entity.GetPeriodStartTime(); if (periodStartTime > proc_first.Proc_Time) { entity.TestTime = ""; entity.SpecResult = false; entity.Count = 0; } else { entity.TestTime = proc_first.Proc_Time.ToString("yyyy/MM/dd HH:mm:ss"); entity.SpecResult = proc_first.Spec_Result == 0 ? false : true; entity.Count = GetCount(eqp, periodStartTime.ToString("yyyy-MM-dd HH:mm:ss")); } } else { entity.TestTime = ""; entity.SpecResult = false; entity.Count = 0; } row.EdcEntities.Add(entity); } if (row.EdcEntities.Count > 0) { RowEntities.Add(row); } } }
public void GetTableData(string eqp, string startDate, string endDate) { EqpStr = eqp; StartDate = startDate; EndDate = endDate; var eqps = eqp.Split(','); var eqps_single = eqps.Where(w => !w.Contains("*")); var eqps_like = eqps.Except(eqps_single).Select(s => s.Replace('*', '%')); string condition = string.Format("where start_time between '{0}' and '{1} 23:59:59' ", startDate, endDate); condition = string.Format("{0} and (eqp_id in ('{1}') or eqp_id like '{2}' ) order by start_time desc", condition, string.Join("','", eqps_single), string.Join("' or eqp_id like '", eqps_like)); DB2DataCatcher <Eda_Eqp_HostoryModel> InlineCatcher = new DB2DataCatcher <Eda_Eqp_HostoryModel>("ISTRPT.EDA_Eqp_History") { Conditions = condition }; var list = InlineCatcher.GetEntities().EntityList; if (!list.Any()) { throw new Exception("没有数据"); } foreach (var l in list) { TimeSpan ts = l.End_Time.HasValue?(l.End_Time.Value - l.Start_Time):new TimeSpan(); var entity = new ReqRpt207RowEntity() { LotID = l.Lot_ID, EqpID = l.Eqp_ID, EqpType = l.Eqp_Type, CastID = l.Cast_ID, MainPDID = l.MainPD_ID, Dept = l.Dept, StartTime = l.Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), EndTime = l.End_Time.HasValue? l.End_Time.Value.ToString("yyyy-MM-dd HH:mm:ss"):"", OpeNo = l.Ope_No, PDID = l.PD_ID, PDName = l.PD_Name, Qty = l.Cur_Wafer_Qty, RecipeID = l.Recipe_ID, UserFullName = l.User_Full_Name, UserID = l.Owner_ID, RunDur = string.Format("{0}时{1}分{0}秒", Math.Floor(ts.TotalHours), ts.Minutes, ts.Seconds) }; RowEntities.Add(entity); } }
/// <summary> /// 获取TableData /// </summary> /// <param name="from">查询起始日期,eg:2019-07-31</param> /// <param name="to">查询结束日期,eg:2019-08-01</param> public void GetTableData(string from, string to) { From = from; To = to; #region sql string sql = string.Format(@"with t1 as( select lot_id, wafer_id, mainpd_id, ope_no, eqp_id, procrsc_id, ctrljob_id from MMVIEW.FHWCPHS where proc_time between '{0} 00:00:00' and '{1} 23:59:59' group by lot_id, wafer_id, mainpd_id, ope_no, eqp_id, procrsc_id, ctrljob_id ) select t1.*,h.pd_name,h.claim_time,h.prodspec_id,module.pd_id as modulepd_id from t1 left join mmview.fhopehs h on t1.lot_id=h.lot_id and t1.ctrljob_id=h.ctrl_job and h.ope_category='OperationStart' left join ( select pf.mainpd_id,pf.pd_level,pd.module_no,pd.pd_id from mmview.frpf pf inner join mmview.frpf_pdlist pd on pf.d_thesystemkey=pd.d_thesystemkey and pf.state=1 ) module on module.mainpd_id=t1.mainpd_id and module.module_no=substr(t1.ope_no,1,locate('.',t1.ope_no,1)-1)", from, to); #endregion EdaCatcher = new DB2DataCatcher <EDA_Compare_Process_ToolModel>("", sql); var list = EdaCatcher.GetEntities().EntityList; var gp = list.GroupBy(g => new { g.Lot_ID, g.Claim_Time }); foreach (var g in gp) { var entity = new ReqRpt212RowEntity() { EQP = g.First().EQP_ID, LotID = g.Key.Lot_ID, OpeName = g.First().PD_Name, OpeNo = g.First().Ope_NO, RouteID = g.First().MainPD_ID, OperID = g.First().ModulePD_ID, ProdID = g.First().ProdSpec_ID, OperTime = g.Key.Claim_Time.ToString("yyyy-MM-dd HH:mm:ss") }; var wafers = g.Select(s => new { wafer = s.Wafer_ID.Split('.').Last(), s.Procrsc_ID }); for (int i = 1; i < 26; i++) { string str = i < 10 ? '0' + i.ToString() : i.ToString(); var wafer = wafers.Where(w => w.wafer == str); entity.ChamberArray[i - 1] = wafer.Count() > 0 ? wafer.First().Procrsc_ID : ""; } RowEntities.Add(entity); } }
private void Initialize() { //获取查询Type对应的Eqp CurrentStatus CurStatusCatcher.Conditions = EqpTypeList.Count == 0? "where eqp_id in (select eqp_id from mmview.freqp where claim_time >'2017-01-01')" : string.Format("where eqp_id in (select eqp_id from mmview.freqp where claim_time >'2017-01-01') and eqp_type in ('{0}')", string.Join("','", EqpTypeList)); var EqpsList = CurStatusCatcher.GetEntities().EntityList; if (EqpsList.Count() == 0) { throw new Exception("所选EqpType没有找到对应实际Run的机台"); } //sql语句中eqp条件 sqlEqpListStr = string.Join("','", EqpsList.Select(s => s.Eqp_ID)); string queryEqpCondition = string.Format("where eqp_id in ('{0}') and (not end_time < '{1}') and (not start_time > '{2}')", sqlEqpListStr, sqlStartTime, sqlEndTime); string queryChamberCondition = string.Format("where owner_eqp_id in ('{0}') and (not end_time < '{1}') and (not start_time > '{2}')", sqlEqpListStr, sqlStartTime, sqlEndTime); EQPCatcher.Conditions = queryEqpCondition; ChamberCatcher.Conditions = queryChamberCondition; // LoadPortCatcher.Conditions = GetLoadPortCondition(); //DB查询 var EqpEntities = EQPCatcher.GetEntities().EntityList.ToList(); var ChamberEntities = HasChamebr? ChamberCatcher.GetEntities().EntityList.ToList():new List <Report36_Chamber>(); var EqpStateList = EqpStateCatcher.GetEntities().EntityList; // var LoadPortEntities = HasLoadPort ? LoadPortCatcher.GetEntities().EntityList.ToList() : new List<Report36_LoadPort>(); var ChamberCurList = HasChamebr ? ChamberCurStatus.GetEntities().EntityList : null; //赋值 foreach (var eqp in EqpsList) { ReqRpt036EqpEntity eqpEntity = new ReqRpt036EqpEntity(); eqpEntity.CurState = eqp.E10_State; eqpEntity.EqpID = eqp.Eqp_ID; var list = EqpEntities.Where(w => w.EQP_ID == eqp.Eqp_ID).Select(s => new ReqRpt036EqpHistoryEntity() { StartTime = s.Start_Time, E10State = s.E10_State, EqpState = s.EQP_State, EndTime = s.End_Time, Claim_Memo = s.Claim_Memo, Claim_User_ID = s.Claim_User_ID, Description = s.Description }); eqpEntity.HistoryEntities = MergedHistoryEntities(list.ToList()); // var latestEntity = list.OrderBy(o=>o.EndTime).LastOrDefault(); SetDic(eqpEntity, EqpStateList); RowEntities.Add(eqpEntity); var chamberHistoryList = ChamberEntities.Where(w => w.EQP_ID.Contains(eqp.Eqp_ID)); if (chamberHistoryList.Any()) { var chamberIDList = chamberHistoryList.Select(s => s.EQP_ID).Distinct(); foreach (var chamber in chamberIDList) { ReqRpt036EqpEntity chamberEntity = new ReqRpt036EqpEntity(); chamberEntity.EqpID = chamber; chamberEntity.CurState = ChamberCurList.Where(w => w.Eqp_ID == chamber).Select(s => s.New_E10_State).First(); var entity = chamberHistoryList.Where(w => w.EQP_ID == chamber); var clist = entity.Select(s => new ReqRpt036EqpHistoryEntity() { StartTime = s.Start_Time, E10State = s.E10_State, EqpState = s.EQP_State, EndTime = s.End_Time, Claim_Memo = s.Claim_Memo, Claim_User_ID = s.Claim_User_ID, Description = s.Description }); chamberEntity.HistoryEntities = clist.ToList(); SetDic(chamberEntity, EqpStateList); RowEntities.Add(chamberEntity); } } } }