private void SetDuration(ReqRpt036EqpEntity eqpEntity) { foreach (var item in eqpEntity.HistoryEntities) { item.SetDurationSecond(StartTime, EndTime); } }
private void SetDic(ReqRpt036EqpEntity eqpEntity, IList <FREQPST> EqpStateList) { SetDuration(eqpEntity); foreach (var item in EqpStateList) { //var list = eqpEntity.HistoryEntities.Where(w => w.EqpState == item.EqpState_ID); //int c = list.Any() ? 0 : list.Sum(s => s.DurationSecond); //eqpEntity.Dic_DetailState.Add(item.EqpState_ID, c); eqpEntity.Dic_DetailState.Add(item.EqpState_ID, eqpEntity.HistoryEntities.Where(w => w.EqpState == item.EqpState_ID).Sum(s => s.DurationSecond)); } }
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); } } } }