// GET: /FMM/EquipmentConsuming/ /// <summary> /// 页面开始处理事物 /// </summary> /// <param name="year"> 年</param> /// <param name="month"> 月</param> /// <param name="locationname"> 车间</param> /// <returns></returns> public async Task <ActionResult> Index(string year, string month, string locationname) { MethodReturnResult result = new MethodReturnResult(); try { //初始化参数 string sYear = System.DateTime.Now.ToString("yyyy"); string sMonth = System.DateTime.Now.ToString("MM"); //获取设备异常耗时数据。 using (EquipmentConsumingServiceClient client = new EquipmentConsumingServiceClient()) { await Task.Run(() => { //设置查询条件 PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format(@" Key.Year = '{0}' AND Key.Month = '{1}'", sYear, sMonth ) }; //取得列表数据 MethodReturnResult <IList <EquipmentConsuming> > resultlist = client.Get(ref cfg); if (resultlist.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = resultlist.Data; } else { //数据错误 result.Code = resultlist.Code; //错误代码 result.Message = resultlist.Message; //错误信息 result.Detail = resultlist.Message; //错误明细 } }); //处理错误信息 if (result.Code > 0) { return(Json(result)); //终止并返回程序 } } EquipmentConsumingQueryViewModel model = new EquipmentConsumingQueryViewModel { //初始化参数 Year = sYear, //年 Month = sMonth, //月 }; return(View(model)); } catch (Exception ex) { result.Code = 1000; result.Message = ex.Message; result.Detail = ex.ToString(); return(Json(result)); } }
/// <summary> /// 查询 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <ActionResult> Query(EquipmentConsumingQueryViewModel model) { MethodReturnResult result = new MethodReturnResult(); try { using (EquipmentConsumingServiceClient client = new EquipmentConsumingServiceClient()) { //取得数据 await Task.Run(() => { //取数条件 StringBuilder where = new StringBuilder(); if (model != null) { //年度条件 if (!string.IsNullOrEmpty(model.Year)) { where.AppendFormat("{0} Key.Year = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.Year); } //月度条件 if (!string.IsNullOrEmpty(model.Month)) { where.AppendFormat("{0} Key.Month = '{1}'" , where.Length > 0 ? "and" : string.Empty , model.Month); } //车间条件 if (!string.IsNullOrEmpty(model.LocationName)) { where.AppendFormat("{0} Key.LocationName = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.LocationName); } //班别条件 if (!string.IsNullOrEmpty(model.ShiftName)) { where.AppendFormat("{0} Key.ShiftName = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.ShiftName); } //线别条件 if (!string.IsNullOrEmpty(model.LineCode)) { where.AppendFormat("{0} Key.LineCode = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.LineCode); } //工序条件 if (!string.IsNullOrEmpty(model.RouteStepName)) { where.AppendFormat("{0} Key.RouteStepName = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.RouteStepName); } //原因代码 if (!string.IsNullOrEmpty(model.ReasonCodeName)) { where.AppendFormat("{0} Key.ReasonCodeName = '{1}'" , where.Length > 0 ? "AND" : string.Empty , model.ReasonCodeName); } } //设置参数 PagingConfig cfg = new PagingConfig() { OrderBy = "Key", Where = where.ToString() }; //取得数据 MethodReturnResult <IList <EquipmentConsuming> > resultlist = client.Get(ref cfg); if (resultlist.Code == 0) { ViewBag.PagingConfig = cfg; ViewBag.List = resultlist.Data; } else { //数据错误 result.Code = resultlist.Code; //错误代码 result.Message = resultlist.Message; //错误信息 result.Detail = resultlist.Message; //错误明细 } }); //处理错误信息 if (result.Code > 0) { return(Json(result)); //终止并返回程序 } } return(PartialView("_ListPartial")); } catch (Exception e) { result.Code = 1002; result.Message = e.Message; result.Detail = e.ToString(); return(Json(result)); } }