60 lines
1.9 KiB
C#
60 lines
1.9 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.Text;
|
|
using System.Web.Http;
|
|
|
|
namespace JinanCementFactoryAPI.Controllers.api
|
|
{
|
|
public class GetDayCoalController : ApiController
|
|
{
|
|
DataServer.BLL.coal_equipment bll = new DataServer.BLL.coal_equipment();
|
|
// GET api/<controller>
|
|
public HttpResponseMessage Get()
|
|
{
|
|
var res = new get_day_coal();
|
|
try
|
|
{
|
|
var list = bll.GetModelList("");
|
|
var alist = new List<day_coalData>();
|
|
var model =new day_coalData();
|
|
decimal? num = 0;
|
|
foreach (var item in list)
|
|
{
|
|
num += item.CoalValue;
|
|
}
|
|
model.CoalValue = num;
|
|
var blist = new List<day_coal>();
|
|
for (int i = 0; i < 6; i++)
|
|
{
|
|
var amodel = new day_coal();
|
|
var date = DateTime.Now.AddDays(-i).ToString("MM-dd");
|
|
amodel.time = date;
|
|
decimal? a = 0;
|
|
foreach (var item in list)
|
|
{
|
|
a+=item.CoalValue;
|
|
}
|
|
amodel.T = a;
|
|
blist.Add(amodel);
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
} |