57 lines
2.0 KiB
C#
57 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 GetCoalMonitoringController : ApiController
|
|
{
|
|
DataServer.BLL.coal_equipment bll = new DataServer.BLL.coal_equipment();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get()
|
|
{
|
|
var res = new get_coal_monitoring();
|
|
try
|
|
{
|
|
var list = bll.GetModelList("");
|
|
var alist = new List<coal_monitoringData>();
|
|
var model = new coal_monitoringData();
|
|
model.Amount = list.Count;
|
|
var num = 0;
|
|
var blist = new List<coal_monitoring>();
|
|
foreach (var item in list)
|
|
{
|
|
var amodel=new coal_monitoring();
|
|
num++;
|
|
amodel.SerialNumber = num;
|
|
amodel.Name = item.CoalName;
|
|
amodel.CoalConsumption = item.CoalValue;
|
|
amodel.CarbonEmission=item.CoalValue *Convert.ToDecimal(25.909) *Convert.ToDecimal(0.02610) * 44 / 12;
|
|
amodel.UnitCalorific =Convert.ToDecimal(0.02610);
|
|
blist.Add(amodel);
|
|
model.data = blist;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
} |