This commit is contained in:
parent
83af82659c
commit
7a5a4da768
|
|
@ -155,7 +155,7 @@
|
|||
</site>
|
||||
<site name="DongYingAPI" id="2">
|
||||
<application path="/" applicationPool="Clr4IntegratedAppPool">
|
||||
<virtualDirectory path="/" physicalPath="E:\林谷项目\东营两馆一宫\后端框架\DongYingAPI\DongYingAPI" />
|
||||
<virtualDirectory path="/" physicalPath="E:\林谷项目\东营两馆一宫\后端框架\DongYing\DongYingAPI" />
|
||||
</application>
|
||||
<bindings>
|
||||
<binding protocol="http" bindingInformation="*:53875:localhost" />
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 881f5b60d1e6b13295043c26c26bbed88f765d82
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
using DataServer.api;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace DongYingAPI.Controllers.api
|
||||
{
|
||||
/// <summary>
|
||||
/// 碳-碳流图1
|
||||
/// </summary>
|
||||
public class GetCarbonFluxController : ApiController
|
||||
{
|
||||
DataServer.BLL.device_data bll = new DataServer.BLL.device_data();
|
||||
// GET api/<controller>
|
||||
public HttpResponseMessage Get(string date = "")
|
||||
{
|
||||
var res = new get_carbon_flux();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(date))
|
||||
{
|
||||
var data = new List<carbon_fluxData>();
|
||||
var list = bll.GetModelList("");
|
||||
var model = new carbon_fluxData();
|
||||
var now = DateTime.Now;
|
||||
var sdate = now.ToString("yyyy-MM-dd 00:00:00");
|
||||
var edate = now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
|
||||
var alist = list.Where(x => x.CreateTime >= Convert.ToDateTime(sdate) && x.CreateTime < Convert.ToDateTime(edate)).ToList();
|
||||
decimal? num = 0;
|
||||
foreach (var item in alist)
|
||||
{
|
||||
num += item.EH;
|
||||
}
|
||||
#region 一级
|
||||
model.AggregateName = "总量";
|
||||
model.AggregateValue = Math.Round(Convert.ToDecimal(num / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
#endregion
|
||||
#region 二级
|
||||
|
||||
#endregion
|
||||
var amodel = new secondlevel();
|
||||
amodel.SecondName = "天然气";
|
||||
amodel.SecondValue = 0;
|
||||
var amodel1=new secondlevel();
|
||||
amodel1.SecondName = "电";
|
||||
amodel1.SecondValue = Math.Round(Convert.ToDecimal(num / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
model.list.Add(amodel);
|
||||
model.list.Add(amodel1);
|
||||
var bmodel=new threelevel();
|
||||
bmodel.ThreeName = "空调";
|
||||
var klist=alist.Where(x=>x.DeviceName.Contains("空调")).ToList();
|
||||
decimal? num1 = 0;
|
||||
foreach (var item in klist)
|
||||
{
|
||||
num1 += item.EH;
|
||||
}
|
||||
bmodel.ThreeValue= Math.Round(Convert.ToDecimal(num1 / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
amodel.list.Add(bmodel);
|
||||
var bmodel1=new threelevel();
|
||||
bmodel1.ThreeName = "照明";
|
||||
var zlist = alist.Where(x => x.DeviceName.Contains("照明")).ToList();
|
||||
decimal? num2 = 0;
|
||||
foreach (var item in zlist)
|
||||
{
|
||||
num2 += item.EH;
|
||||
}
|
||||
bmodel1.ThreeValue= Math.Round(Convert.ToDecimal(num2 / 1000 * Convert.ToDecimal(0.5703)), 3);
|
||||
|
||||
data.Add(model);
|
||||
res.code = 200;
|
||||
res.msg = "成功";
|
||||
res.data = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
res.code = 201;
|
||||
res.msg = "参数为空";
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue