using DataServer.api; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Net; using System.Net.Http; using System.Text; using System.Web.Http; namespace JinanCementFactoryAPI.Controllers.api { /// /// 可调负荷资源 /// public class GetAdjustableloadController : ApiController { DataServer.BLL.adjustable_load bll = new DataServer.BLL.adjustable_load(); // GET api/ public HttpResponseMessage Get() { var res = new get_adjustable_ioad(); try { var list = bll.GetModelList(""); var alist = new List(); var model=new adjustable_ioadData(); foreach (var item in list) { if (item.AdjustableloadType == 1) { model.PeakClipping +=Convert.ToInt32(item.NumericalValue); if (item.LoadLevel == 1) { model.SecondPeakClipping+= Convert.ToInt32(item.NumericalValue); } else if(item.LoadLevel == 2) { model.MinutePeakClipping+=Convert.ToInt32(item.NumericalValue); } else { model.HourlyPeakClipping += Convert.ToInt32(item.NumericalValue); } model.DayPeakClipping += Convert.ToInt32(item.NumericalValue); } else { model.ValleyFilling += Convert.ToInt32(item.NumericalValue); if (item.LoadLevel == 1) { model.SecondValleyFilling += Convert.ToInt32(item.NumericalValue); } else if (item.LoadLevel == 2) { model.MinuteValleyFilling += Convert.ToInt32(item.NumericalValue); } else { model.HourlyValleyFilling += Convert.ToInt32(item.NumericalValue); } model.DayValleyFilling+= Convert.ToInt32(item.NumericalValue); } model.Amount +=Convert.ToInt32(item.NumericalValue); } alist.Add(model); res.code = 200; res.msg = "成功"; res.data = alist; } catch (Exception ex) { res.code = 500; res.msg = ex.Message; } HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(JsonConvert.SerializeObject(res), Encoding.GetEncoding("UTF-8"), "application/json") }; return result; } } }