73 lines
2.6 KiB
C#
73 lines
2.6 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.Reflection;
|
|
using System.Text;
|
|
using System.Web.Http;
|
|
|
|
namespace JinanCementFactoryAPI.Controllers.api
|
|
{
|
|
/// <summary>
|
|
/// 负荷分类
|
|
/// </summary>
|
|
public class GetLoadClassificationController : ApiController
|
|
{
|
|
DataServer.BLL.adjustable_load bll = new DataServer.BLL.adjustable_load();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get()
|
|
{
|
|
var res = new get_load_classification();
|
|
try
|
|
{
|
|
var list = bll.GetModelList("");
|
|
var blist = new List<load_classificationData>();
|
|
var alist=new List<load_classification>();
|
|
var list1=list.Where(x=>x.LoadLevel==1).ToList();
|
|
var model1 = new load_classification();
|
|
foreach (var item in list1)
|
|
{
|
|
model1.Name = "一级";
|
|
model1.Value +=Convert.ToInt32(item.RealIoad);
|
|
}
|
|
alist.Add(model1);
|
|
var list2 = list.Where(x => x.LoadLevel == 2).ToList();
|
|
var model2 = new load_classification();
|
|
foreach (var item in list2)
|
|
{
|
|
model2.Name = "二级";
|
|
model2.Value += Convert.ToInt32(item.RealIoad);
|
|
}
|
|
alist.Add(model2);
|
|
var list3 = list.Where(x => x.LoadLevel == 3).ToList();
|
|
var model3 = new load_classification();
|
|
foreach (var item in list3)
|
|
{
|
|
model3.Name = "三级";
|
|
model3.Value += Convert.ToInt32(item.RealIoad);
|
|
}
|
|
alist.Add(model3);
|
|
var model4 = new load_classificationData();
|
|
foreach (var item in list)
|
|
{
|
|
model4.Amount += Convert.ToInt32(item.RealIoad);
|
|
}
|
|
model4.data = alist;
|
|
blist.Add(model4);
|
|
res.code = 200;
|
|
res.msg = "成功";
|
|
res.data = blist;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
} |