/// <summary> /// /// </summary> /// <param name="UnitID"></param> /// <returns></returns> public static DataTable GetSearchListS(string UnitID, string StartTime, string EndTime) { DataTable dt = null; string WorkID = KPI_UnitDal.GetWorkIDByID(UnitID); int nBaseShifts = KPI_WorkDal.GetBaseShifts(WorkID); string[] AllShifts = KPI_WorkDal.GetShift(WorkID); if (nBaseShifts != AllShifts.Length) { return(dt); } string condition = ""; for (int i = 0; i < nBaseShifts; i++) { string ShiftID = AllShifts[i]; string ShiftName = KPI_ShiftDal.GetShiftName(ShiftID); condition += "cast(avg(case TagShift when '" + ShiftID + "' then TagValue else null end) as numeric(18,4)) as '" + ShiftName + "', "; } condition = condition.Remove(condition.LastIndexOf(',')); string where = " where TagStartTime>='" + StartTime + "' and TagStartTime<'" + EndTime + "'"; string sql = @"select TagDesc As '运行参数', {0} from Race_Archive a left outer join Race_Tag b on a.TagID=b.TagID {1} group by TagDesc, TagIndex order by TagIndex"; sql = string.Format(sql, condition, where); dt = DBAccess.GetRelation().ExecuteDataset(sql).Tables[0]; return(dt); }
/// <summary> /// /// </summary> /// <param name="UnitID"></param> /// <returns></returns> public static DataTable GetSearchListC(string UnitID, string StartTime, string EndTime) { DataTable dt = null; string WorkID = KPI_UnitDal.GetWorkIDByID(UnitID); DataTable dtItems = Race_TagDal.GetTags(UnitID); if (dtItems == null && dtItems.Rows.Count <= 0) { return(dt); } string condition = ""; for (int i = 0; i < dtItems.Rows.Count; i++) { string ItemID = dtItems.Rows[i]["TagID"].ToString(); string ItemDesc = dtItems.Rows[i]["TagDesc"].ToString(); string ItemEngunit = dtItems.Rows[i]["TagEngunit"].ToString(); condition += "cast(avg(case TagID when '" + ItemID + "' then TagValue else null end) as numeric(18,4)) as '" + ItemDesc + "[" + ItemEngunit + "]', "; } condition = condition.Remove(condition.LastIndexOf(',')); string where = " where UnitID= '" + UnitID + "' and TagStartTime >='" + StartTime + "' and TagStartTime <'" + EndTime + "'"; string sql = @"select TagShift As '运行值', {0} from Race_Archive {1} group by TagShift"; sql = string.Format(sql, condition, where); dt = DBAccess.GetRelation().ExecuteDataset(sql).Tables[0]; return(dt); }