82 lines
3.2 KiB
C#
82 lines
3.2 KiB
C#
using DataServer.api;
|
|
using Microsoft.Ajax.Utilities;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Text;
|
|
using System.Web.Http;
|
|
|
|
namespace JinanCementFactoryAPI.Controllers.api
|
|
{
|
|
public class GetTemperatureMonitoringTwoController : ApiController
|
|
{
|
|
DataServer.BLL.test_temperature bll = new DataServer.BLL.test_temperature();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get(string ThermometryName = "")
|
|
{
|
|
var res = new get_temperature_monitoring_two();
|
|
try
|
|
{
|
|
if (!string.IsNullOrEmpty(ThermometryName))
|
|
{
|
|
var list = bll.GetModelList("");
|
|
var alist = new List<monitoring_twoData>();
|
|
var amodel = new monitoring_twoData();
|
|
amodel.ThermometryName = ThermometryName;
|
|
var blist=list.Where(x=>x.ThermometryName== amodel.ThermometryName).ToList();
|
|
var clist = new List<monitoring_two>();
|
|
foreach (var item in blist)
|
|
{
|
|
var model = new monitoring_two();
|
|
model.TemperatureDescription = item.TemperatureDescription;
|
|
model.TemperatureValue = item.TemperatureValue;
|
|
clist.Add(model);
|
|
}
|
|
amodel.data= clist;
|
|
alist.Add(amodel);
|
|
res.code = 200;
|
|
res.msg = "成功";
|
|
res.data = alist;
|
|
}
|
|
else
|
|
{
|
|
var list = bll.GetModelList("");
|
|
var alist = new List<monitoring_twoData>();
|
|
|
|
foreach (var item in list)
|
|
{
|
|
var amodel = new monitoring_twoData();
|
|
amodel.ThermometryName =item.ThermometryName;
|
|
var blist = list.Where(x => x.ThermometryName == amodel.ThermometryName).ToList();
|
|
var clist = new List<monitoring_two>();
|
|
foreach (var aitem in blist)
|
|
{
|
|
var model = new monitoring_two();
|
|
model.TemperatureDescription = aitem.TemperatureDescription;
|
|
model.TemperatureValue = aitem.TemperatureValue;
|
|
clist.Add(model);
|
|
amodel.data = clist;
|
|
}
|
|
|
|
alist.Add(amodel);
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
} |