132 lines
5.6 KiB
C#
132 lines
5.6 KiB
C#
using DataServer.api;
|
|
using Microsoft.Ajax.Utilities;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Web.Http;
|
|
|
|
namespace JinanCementFactoryAPI.Controllers.api
|
|
{
|
|
/// <summary>
|
|
/// 空气污染排放
|
|
/// </summary>
|
|
public class GetAirPollutionController : ApiController
|
|
{
|
|
DataServer.BLL.environmental_protection bll = new DataServer.BLL.environmental_protection();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get(string type="")
|
|
{
|
|
var res = new get_air_pollution();
|
|
try
|
|
{
|
|
var list = bll.GetModelList("");
|
|
var alist = new List<air_pollutionData>();
|
|
if (type == "二氧化碳")
|
|
{
|
|
var list1 = list.Where(x=>x.EnvironmentalDescription.Contains("SO2")).DistinctBy(x=>x.EnvironmentalName).ToList();
|
|
var model = new air_pollutionData();
|
|
|
|
foreach (var item in list1)
|
|
{
|
|
model.type = item.EnvironmentalDescription;
|
|
var clist = new List<air_pollution>();
|
|
var blist = list.Where(x => x.EnvironmentalDescription == item.EnvironmentalDescription).ToList();
|
|
foreach (var aitem in blist)
|
|
{
|
|
var amodel = new air_pollution();
|
|
amodel.Name = aitem.EnvironmentalName;
|
|
amodel.Value = aitem.EnvironmentalValue;
|
|
clist.Add(amodel);
|
|
}
|
|
model.data = clist;
|
|
|
|
}
|
|
alist.Add(model);
|
|
|
|
}
|
|
else if (type == "氮氧化物")
|
|
{
|
|
var list1 = list.Where(x => x.EnvironmentalDescription.Contains("NOX")).DistinctBy(x => x.EnvironmentalName).ToList();
|
|
var model = new air_pollutionData();
|
|
foreach (var item in list1)
|
|
{
|
|
model.type = item.EnvironmentalDescription;
|
|
var clist = new List<air_pollution>();
|
|
var blist = list.Where(x => x.EnvironmentalDescription == item.EnvironmentalDescription).ToList();
|
|
foreach (var aitem in blist)
|
|
{
|
|
var amodel = new air_pollution();
|
|
amodel.Name = aitem.EnvironmentalName;
|
|
amodel.Value = aitem.EnvironmentalValue;
|
|
clist.Add(amodel);
|
|
}
|
|
model.data = clist;
|
|
|
|
}
|
|
alist.Add(model);
|
|
}
|
|
else if (type == "一氧化碳")
|
|
{
|
|
var list1 = list.Where(x => x.EnvironmentalDescription.Contains("CO")).DistinctBy(x => x.EnvironmentalName).ToList();
|
|
var model = new air_pollutionData();
|
|
foreach (var item in list1)
|
|
{
|
|
|
|
model.type = item.EnvironmentalDescription;
|
|
var clist = new List<air_pollution>();
|
|
var blist = list.Where(x => x.EnvironmentalDescription == item.EnvironmentalDescription).ToList();
|
|
foreach (var aitem in blist)
|
|
{
|
|
var amodel = new air_pollution();
|
|
amodel.Name = aitem.EnvironmentalName;
|
|
amodel.Value = aitem.EnvironmentalValue;
|
|
clist.Add(amodel);
|
|
|
|
|
|
}
|
|
model.data = clist;
|
|
}
|
|
alist.Add(model);
|
|
}
|
|
else if (type == "氧气")
|
|
{
|
|
var list1 = list.Where(x => x.EnvironmentalDescription.Contains("氧气")).DistinctBy(x => x.EnvironmentalName).ToList();
|
|
var model = new air_pollutionData();
|
|
foreach (var item in list1)
|
|
{
|
|
|
|
model.type = item.EnvironmentalDescription;
|
|
var clist = new List<air_pollution>();
|
|
var blist = list.Where(x => x.EnvironmentalDescription == item.EnvironmentalDescription).ToList();
|
|
foreach (var aitem in blist)
|
|
{
|
|
var amodel = new air_pollution();
|
|
amodel.Name = aitem.EnvironmentalName;
|
|
amodel.Value = aitem.EnvironmentalValue;
|
|
clist.Add(amodel);
|
|
|
|
|
|
}
|
|
model.data = clist;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
} |