public override void DataBind() { string SpecialField = Request.Params["ecweb"]; string queryTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00"); String PlantCode = Request.Params["plantcode"]; String UnitCode = Request.Params["unitcode"]; String PlantID = KPI_PlantDal.GetPlantIDByCode(PlantCode); String UnitID = KPI_UnitDal.GetUnitIDByCode(UnitCode); ECValueRepeater.DataSource = ECSSSnapshotDal.GetSearchList(SpecialField, queryTime, PlantID, ""); base.DataBind(); ColSpan(); //String CurrentTimeStr = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00"); nowtime.Text = "计算时间:" + queryTime; nowshift.Text = "轮班值次:"; if (!String.IsNullOrWhiteSpace(UnitID)) { string workid = KPI_UnitDal.GetWorkIDByID(UnitID); string ShiftName = ""; string PeriodName = ""; string StartTime = ""; string EndTime = ""; bool bGood = KPI_WorkDal.GetShiftAndPeriod(workid, queryTime, ref ShiftName, ref PeriodName, ref StartTime, ref EndTime); nowshift.Text = "轮班值次:" + ShiftName + "值"; } }
public static object GetAnalyzeData() { DataTable dt = ECSSSnapshotDal.GetSearchList(ecweb, queryTime, "", ""); var totalQuery = from q in dt.AsEnumerable() group q by new { uid = q.Field <string>("UnitID"), uname = q.Field <string>("UnitName") } into result select new { name = result.Key.uname, value = result.Count() }; List <BarModel> barModelList = new List <BarModel>(); foreach (var item in totalQuery) { barModelList.Add(new BarModel { name = item.name, value = item.value.ToString(), group = "总数" }); } var errorQuery = from q in dt.AsEnumerable().Where(d => d.Field <int>("ECQulity") == 1) group q by new { uid = q.Field <string>("UnitID"), uname = q.Field <string>("UnitName") } into result select new { name = result.Key.uname, value = result.Count() }; foreach (var item in errorQuery) { barModelList.Add(new BarModel { name = item.name, value = item.value.ToString(), group = "异常" }); } return(barModelList); }
/// <summary> /// /// </summary> void BindValues() { //需要显示的集合 //string WebID = ViewState["webid"].ToString(); //if (WebID.Equals("")) //{ // return; //} //选择的时间 //DateTime SelectDate = DateTime.Parse(txt_Month.Value); ////查询的时间,今天为 //string ValueDate = ""; //string ValueLMonth = ""; //string ValueSMonth = ""; //if (SelectDate.Year == DateTime.Now.Year && SelectDate.Month == DateTime.Now.Month) //{ // //本月今日 // ValueDate = DateTime.Now.ToString("yyyy-MM-dd"); // //今年上月 // ValueLMonth = DateTime.Parse(ValueDate).AddDays(-DateTime.Parse(ValueDate).Day).ToString("yyyy-MM-dd"); // //去年同月 // ValueSMonth = DateTime.Parse(ValueDate).AddDays(-DateTime.Parse(ValueDate).Day).AddMonths(-11).ToString("yyyy-MM-dd"); //} //else // ////if (SelectDate.Year < DateTime.Now.Year // ////|| (SelectDate.Year == DateTime.Now.Year && SelectDate.Month < DateTime.Now.Month)) //{ // //历史月最后一天 // ValueDate = SelectDate.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd"); // //今年上月 // ValueLMonth = DateTime.Parse(ValueDate).AddMonths(-1).ToString("yyyy-MM-dd"); // //去年同月 // ValueSMonth = DateTime.Parse(ValueDate).AddYears(-1).ToString("yyyy-MM-dd"); //} ////else ////{ //// MessageBox.popupClientMessage(this.Page, "实时库连接错误!", "call();"); //// //ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "", //// // "alert('月份选择错误!请重新选择!')", true); //// return; ////} ////本月 //DataTable dt = Ana_ParamDal.GetKPIListForValue(WebID, ValueDate); ////今年上月 //DataTable dtL = Ana_ParamDal.GetHistoryValue(WebID, ValueLMonth); ////去年同月 //DataTable dtS = Ana_ParamDal.GetHistoryValue(WebID, ValueSMonth); //// @"select a.KeyID, c.UnitDesc, a.KeyName, a.KeyEngunit, //// ValueDate, ''BKColor, ''BKGood, //// ValueMonthRMW, ValueMonthR, //// ''ValueLMonthRMW, ''ValueLMonthR, ''ValueLMonthD, ''ValueLMonthB, //// ''ValueSMonthRMW, ''ValueSMonthR, ''ValueSMonthD, ''ValueSMonthB, //// KeyIsCalc //// from Ana_Param a, Ana_Value b,OPM_Unit c //// where a.KeyID=b.KeyID and a.UnitID=c.UnitID and KeyIsValid=1 and a.WebID='{0}' and ValueDate='{1}' //// order by KeyIndex "; string ValueDate = DateTime.Now.ToString(); DataTable dt = ECSSSnapshotDal.GetSearchList("", ValueDate); ////绑定实时参数 及 计算参数 foreach (DataRow dr in dt.Rows) { string keyid = dr["KeyID"].ToString(); //是否计算煤耗 int calc = int.Parse(dr["KeyIsCalc"].ToString()); double valueb = double.Parse(dr["XLineType1Unit"].ToString()); //今年上月 //DataRow[] drl = dtL.Select("KeyID='" + keyid + "'"); //if (drl.Length == 1) //{ // dr["ValueLMonthR"] = drl[0]["ValueMonthR"]; //} ////去年同月 //DataRow[] drs = dtS.Select("KeyID='" + keyid + "'"); //if (drs.Length == 1) //{ // dr["ValueSMonthR"] = drs[0]["ValueMonthR"]; //} //偏差及煤耗计算 //if (dr["ValueLMonthR"].ToString() != "" && dr["ValueMonthR"].ToString() != "") //{ // double lmonthd = double.Parse(dr["ValueMonthR"].ToString()) - double.Parse(dr["ValueLMonthR"].ToString()); // if (lmonthd != double.MinValue) dr["ValueLMonthD"] = lmonthd.ToString("0.000"); // if (calc == 1) // { // double lmonthb = lmonthd * valueb; // if (lmonthb != double.MinValue) dr["ValueLMonthB"] = lmonthb.ToString("0.000"); // } //} //if (dr["ValueSMonthR"].ToString() != "" && dr["ValueMonthR"].ToString() != "") //{ // double smonthd = double.Parse(dr["ValueMonthR"].ToString()) - double.Parse(dr["ValueSMonthR"].ToString()); // if (smonthd != double.MinValue) dr["ValueSMonthD"] = smonthd.ToString("0.000"); // if (calc == 1) // { // double smonthb = smonthd * valueb; // if (smonthb != double.MinValue) dr["ValueSMonthB"] = smonthb.ToString("0.000"); // } //} //赋值 } #region DataTable排序方法 // //dt.Columns.Add("SortValue", typeof(Double)); //foreach (DataRow dr in dt.Rows) //{ // if (dr["KeyBValue"].ToString() == "--") // { // dr["SortValue"] = 0; // } // else // { // dr["SortValue"] = Convert.ToDouble(dr["KeyBValue"].ToString()); // } //} //// //dt.DefaultView.Sort = "KeyIsMan, SortValue desc"; #endregion //绑定最优参数 gvReal.DataSource = dt; gvReal.DataBind(); }