JinanCementFactory/JinanCementFactoryAPI/Controllers/api/GetAdjustableLoadAnalysisCo...

58 lines
2.0 KiB
C#

using DataServer.api;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
namespace JinanCementFactoryAPI.Controllers.api
{
/// <summary>
/// 可调负荷分析
/// </summary>
public class GetAdjustableLoadAnalysisController : ApiController
{
DataServer.BLL.adjustable_load bll = new DataServer.BLL.adjustable_load();
// GET api/<controller>
public HttpResponseMessage Get()
{
var res = new get_adjustable_load_analysis();
try
{
var list = bll.GetModelList("");
var alist = new List<adjustable_load_analysisData>();
var model = new adjustable_load_analysisData();
foreach (var item in list)
{
if (item.AdjustableloadType == 1)
{
model.PeakClipping += Convert.ToInt32(item.NumericalValue);
}
else
{
model.ValleyFilling += Convert.ToInt32(item.NumericalValue);
}
}
model.PeakingAmount = model.PeakClipping * 1.99 * 1 / 1 + model.PeakClipping * 3 * 1 * 4;
model.ValleyFillingAmount = model.ValleyFilling * 1.2 + model.ValleyFilling * 1.99 * 1 / 1;
model.BaseLoad = model.PeakClipping + model.ValleyFilling;
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;
}
}
}