using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Web.Http; using WebAPI.Models; namespace WebAPI.Controllers { public class Sc_ProductionReportsController : ApiController { public DBUtility.ClsPub.Enum_BillStatus BillStatus; private json objJsonResult = new json(); private json objJsonResultReturn = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); DataSet ds; #region 生产模块 计划达成率报表 /// /// 返回计划达成率报表 ///参数:string sql。 ///返回值:object。 /// [Route("Sc_ProductionReport/PlanAchievementRate")] [HttpGet] public object PlanAchievementRate(string sWhere, string user) { try { List columnNameList = new List(); if (sWhere == null || sWhere == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查询条件!"; objJsonResult.data = null; return objJsonResult; } Dictionary dic = Newtonsoft.Json.JsonConvert.DeserializeObject>(sWhere); string HBeginDate = dic["HBeginDate"].ToString(); string HEndDate = dic["HEndDate"].ToString(); int HDeptID = int.Parse(dic["HDeptID"].ToString()); string HSourceName = dic["HSourceName"].ToString(); string HMaterNumber = dic["HMaterNumber"].ToString(); string HMaterName = dic["HMaterName"].ToString(); string HMaterModel = dic["HMaterModel"].ToString(); string HCustomize = dic["HCustomize"].ToString(); ds = oCN.RunProcReturn("exec h_p_Sc_PlanAchievementRateReport '" + HBeginDate + "','" + HEndDate + "'," + HDeptID + ",'" + HSourceName + "','" + HMaterNumber + "','" + HMaterName + "','" + HMaterModel + "','" + HCustomize + "'", "h_p_Sc_PlanAchievementRateReport"); //添加列名 foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } }