47 lines
1.5 KiB
C#
47 lines
1.5 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 GetPlantConsumptionController : ApiController
|
|
{
|
|
DataServer.BLL.loop_distribution bll = new DataServer.BLL.loop_distribution();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get()
|
|
{
|
|
var res = new get_plant_consumption();
|
|
try
|
|
{
|
|
var list = bll.GetModelList("").Where(x=>x.LoopName=="总降电力室");
|
|
var alist = new List<plant_consumptionData>();
|
|
foreach (var item in list)
|
|
{
|
|
var model=new plant_consumptionData();
|
|
model.DeviceName= item.DistributionName;
|
|
model.EH=item.EH;
|
|
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;
|
|
}
|
|
}
|
|
} |