public IHttpActionResult GetEnergyReportListData(EquipmentEnergyModel parameter) { RetDeviceTableData info = new RetDeviceTableData(); List <RetDeviceTableList> table = new List <RetDeviceTableList>(); if (parameter.Property != null) { int i = 0; for (; i < parameter.Property.Count; i++) { DeviceDataModel model = new DeviceDataModel(); model.DeviceID = parameter.Property[i].data[0]; model.DeviceItemID = parameter.Property[i].data[1]; model.StartTime = parameter.StartTime; model.EndTime = parameter.EndTime; model.StatisticalInterval = parameter.StatisticalInterval; model.IntervalUnit = parameter.IntervalUnit; model.GetTogetherType = parameter.Type; DeviceDataBLL data = new DeviceDataBLL(); var get = data.GetEnergyReportListData(model); if (get.Data != null) { foreach (var item in get.Data.DeviceTableList) { table.Add(item); } } } } info.DeviceTableList = table.OrderByDescending(o => o.Time).ToList(); ReturnItem <RetDeviceTableData> r = new ReturnItem <RetDeviceTableData>(); r.Count = info.DeviceTableList.Count(); r.Msg = "设备数据获取成功"; r.Code = 0; r.Data = info; return(InspurJson <RetDeviceTableData>(r)); }
public IHttpActionResult GetEnergyReportChartData(EquipmentEnergyModel parameter) { List <RetDeviceTableData> devicedata = new List <RetDeviceTableData>(); RetEquipmentEnergyChart info = new RetEquipmentEnergyChart(); List <string> LineLegend = new List <string>(); List <string> PieLegend = new List <string>(); List <string> Time = new List <string>(); List <EquipmentEnergyLine> LineData = new List <EquipmentEnergyLine>(); List <EquipmentEnergyPie> PieList = new List <EquipmentEnergyPie>(); if (parameter.Property != null) { int i = 0; for (; i < parameter.Property.Count; i++) { DeviceDataModel model = new DeviceDataModel(); model.DeviceID = parameter.Property[i].data[0]; model.DeviceItemID = parameter.Property[i].data[1]; model.StartTime = parameter.StartTime; model.EndTime = parameter.EndTime; model.StatisticalInterval = parameter.StatisticalInterval; model.IntervalUnit = parameter.IntervalUnit; model.GetTogetherType = parameter.Type; DeviceDataBLL data = new DeviceDataBLL(); var get = data.GetEnergyReportListData(model); if (get.Data != null && get.Data.Data.Count != 0) { devicedata.Add(get.Data); } } } devicedata = devicedata.OrderBy(o => Convert.ToDateTime(o.Time[0])).ToList(); foreach (var item in devicedata) { if (item.Data.Count != 0) { LineLegend.Add(item.DeviceName + "/" + item.DeviceItemName); PieLegend.Add(item.DeviceName + "/" + item.DeviceItemName); } EquipmentEnergyLine line = new EquipmentEnergyLine(); line.DeviceName = item.DeviceName; line.DeviceItemName = item.DeviceItemName; List <List <object> > singledata = new List <List <object> >(); for (var j = 0; j < item.Time.Count; j++) { if (Time.Contains(item.Time[j]) == false) { Time.Add(item.Time[j]); } List <object> single = new List <object>(); single.Add(item.Time[j]); single.Add(item.Data[j]); singledata.Add(single); } line.DeviceData = singledata; LineData.Add(line); EquipmentEnergyPie pie = new EquipmentEnergyPie(); if (item.Data.Count != 0) { double value = 0; for (var k = 0; k < item.Data.Count; k++) { if (k == 0) { value = item.Data[k]; } else { value += item.Data[k]; } } pie.value = value.ToString(); pie.name = item.DeviceName + "/" + item.DeviceItemName; } PieList.Add(pie); } info.Time = Time.OrderBy(o => DateTime.Parse(o)).ToList(); info.LineLegend = LineLegend; info.PieLegend = PieLegend; info.LineData = LineData; info.PieList = PieList; ReturnItem <RetEquipmentEnergyChart> r = new ReturnItem <RetEquipmentEnergyChart>(); r.Msg = "设备数据获取成功"; r.Code = 0; r.Data = info; return(InspurJson <RetEquipmentEnergyChart>(r)); }