85 lines
3.2 KiB
C#
85 lines
3.2 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.Security.Cryptography.X509Certificates;
|
|
using System.Text;
|
|
using System.Web.Http;
|
|
|
|
namespace JinanCementFactoryAPI.Controllers.api
|
|
{
|
|
/// <summary>
|
|
/// 生产线负荷占比
|
|
/// </summary>
|
|
public class GetLoadProportionController : ApiController
|
|
{
|
|
DataServer.BLL.loop_distribution bll = new DataServer.BLL.loop_distribution();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get()
|
|
{
|
|
var res = new get_load_proportion();
|
|
try
|
|
{
|
|
var list = bll.GetModelList("");
|
|
var alist = new List<load_proportionData>();
|
|
var blist= new List<load_proportion>();
|
|
var model= new load_proportionData();
|
|
var model1 = new load_proportion();
|
|
decimal? num1 = 0;
|
|
decimal? num2 = 0;
|
|
decimal? num3 = 0;
|
|
decimal? num4 = 0;
|
|
var list1=list.Where(x=>x.LoopName== "总降电力室"&&x.DistributionName.Contains("#1")).ToList();
|
|
foreach (var item in list1)
|
|
{
|
|
model1.Name = "1号线";
|
|
model1.Value = item.CurrentPower;
|
|
num1 = model1.Value+ num1;
|
|
model1.Value = num1;
|
|
}
|
|
blist.Add(model1);
|
|
var model2 = new load_proportion();
|
|
var list2 = list.Where(x => x.LoopName == "总降电力室" && x.DistributionName.Contains("#2")).ToList();
|
|
foreach (var item in list2)
|
|
{
|
|
model2.Name = "2号线";
|
|
model2.Value = item.CurrentPower;
|
|
num2 = model2.Value + num2;
|
|
model2.Value = num2;
|
|
}
|
|
blist.Add(model2);
|
|
var model3 = new load_proportion();
|
|
var list3 = list.Where(x => x.LoopName == "总降电力室" && x.DistributionName.Contains("#3")).ToList();
|
|
foreach (var item in list3)
|
|
{
|
|
model3.Name = "3号线";
|
|
model3.Value = item.CurrentPower;
|
|
num3 = model3.Value + num3;
|
|
model3.Value = num3;
|
|
}
|
|
blist.Add(model3);
|
|
foreach (var item in list)
|
|
{
|
|
model.Amount = item.CurrentPower;
|
|
num4 = model.Amount + num4;
|
|
model.Amount = num4;
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
} |