/// <summary> /// 大数据界面,空压机能效开关数据 /// </summary> /// <param name="currtime">当前时间</param> /// <param name="begtime">之前时间</param> /// <returns></returns> public List <List <Model.ViewObject.CenSwitchStack_VO> > SwitchStackSer(DateTime currtime, DateTime begtime) { //随机数 Random rr = new Random(); var res = dal.QuerySplitPage(d => d.DateTime >= begtime && d.DateTime <= currtime, or => or.OrderByDescending(o => o.Id), 25, 1).Select(s => new { run = s.Run, id = s.Id, stationId = s.StationID, equId = s.EquipID, upi = s.UPI, time = s.DateTime }).OrderBy(o => o.id).ToList().Select(ss => new { upii = ss.upi, //upi值 equId = ss.equId, //空压机几号 time = ss.time, run = ss.run, //运行状态 id = ss.id, stationId = ss.stationId }).OrderByDescending(o => o.upii).GroupBy(g => g.stationId).OrderBy(gg => gg.Key).ToList(); var upires = upidal.QueryWhere().OrderByDescending(o => o.UPI).ToList(); int jcount = 0; //将25组查询数据分组放入集合中 List <Model.ViewObject.CenSwitchStack_VO> upiarr = new List <Model.ViewObject.CenSwitchStack_VO>(); foreach (var it in res) { foreach (var i in it) { Model.ViewObject.CenSwitchStack_VO model = new Model.ViewObject.CenSwitchStack_VO() { UPI = Math.Round((double)upires.Find(x => x.StationID == i.stationId && x.EquipID == i.equId).UPI * 1000, 2), Equid = Convert.ToInt32(Regex.Replace(i.equId, "[A-Z0]", "")), Run = Convert.ToInt32(i.run), Time = i.time.ToString() }; upiarr.Add(model); jcount++; } } //将25组数据分成7组到view List <List <Model.ViewObject.CenSwitchStack_VO> > all = new List <List <Model.ViewObject.CenSwitchStack_VO> >(); for (int i = 0; i < 7; i++) { List <Model.ViewObject.CenSwitchStack_VO> test = new List <Model.ViewObject.CenSwitchStack_VO>(); if (i < 6) { test.Add(upiarr[i]); test.Add(upiarr[i + 6 * 1]); test.Add(upiarr[i + 6 * 2]); test.Add(upiarr[i + 6 * 3]); } else { Model.ViewObject.CenSwitchStack_VO model1 = new Model.ViewObject.CenSwitchStack_VO() { UPI = 0, Equid = 0, Run = 0, Time = "" }; test.Add(model1); test.Add(model1); test.Add(model1); test.Add(upiarr[i + 6 * 3]); } all.Add(test); } return(all); }
public List <List <Model.ViewObject.CenSwitchStack_VO> > SwitchStackSer(DateTime currtime, DateTime begtime) { Random rr = new Random(); var res = dal.QuerySplitPage(d => d.DateTime >= begtime && d.DateTime <= currtime, or => or.OrderByDescending(o => o.Id), 25, 1).Select(s => new { run = s.Run, id = s.Id, stationId = s.StationID, equId = s.EquipID, upi = s.UPI, time = s.DateTime }).OrderBy(o => o.id).ToList().Select(ss => new { upii = rr.Next(0, 100) / 100.0, equId = ss.equId, time = ss.time, run = ss.run, id = ss.id, stationId = ss.stationId }).OrderByDescending(o => o.upii).GroupBy(g => g.stationId).OrderBy(gg => gg.Key).ToList(); List <Model.ViewObject.CenSwitchStack_VO> upiarr = new List <Model.ViewObject.CenSwitchStack_VO>(); foreach (var it in res) { foreach (var i in it) { Model.ViewObject.CenSwitchStack_VO model = new Model.ViewObject.CenSwitchStack_VO() { UPI = i.upii, Equid = Convert.ToInt32(Regex.Replace(i.equId, "[A-Z0]", "")), Run = Convert.ToInt32(i.run), Time = i.time.ToString() }; upiarr.Add(model); } } List <List <Model.ViewObject.CenSwitchStack_VO> > all = new List <List <Model.ViewObject.CenSwitchStack_VO> >(); for (int i = 0; i < 7; i++) { List <Model.ViewObject.CenSwitchStack_VO> test = new List <Model.ViewObject.CenSwitchStack_VO>(); if (i < 6) { test.Add(upiarr[i]); test.Add(upiarr[i + 6 * 1]); test.Add(upiarr[i + 6 * 2]); test.Add(upiarr[i + 6 * 3]); } else { Model.ViewObject.CenSwitchStack_VO model1 = new Model.ViewObject.CenSwitchStack_VO() { UPI = 0, Equid = 0, Run = 0, Time = "" }; test.Add(model1); test.Add(model1); test.Add(model1); test.Add(upiarr[i + 6 * 3]); } all.Add(test); } return(all); }