public ActionResult GetCustomers(string text) { 数据库处理 sjkcl = new 数据库处理(); List <资料种类> result = sjkcl.获取数据库表信息(); result.Add(new 资料种类(0, "所有", "all")); var myresult = result.Where(y => y.表名称.Contains(text)).OrderBy(y => y.序号).ToList(); return(Json(myresult, JsonRequestBehavior.AllowGet)); }
public ActionResult Orders_Read3(string[] sdatepic, string[] edatepic, string[] datazl) { 数据库处理 sjkcl = new 数据库处理(); List <资料种类> dataLists = dataLists = sjkcl.获取数据库表信息(); List <SKViewModel> result = new List <SKViewModel>(); if (datazl == null || datazl.Length == 0) { result = sjkcl.获取指定时间统计信息(Convert.ToDateTime(sdatepic[0]), Convert.ToDateTime(edatepic[0])); } else { bool bs = false; foreach (string item in datazl) { if (item.ToLower() == "all") { bs = true; } } if (bs) { result = sjkcl.获取指定时间统计信息(Convert.ToDateTime(sdatepic[0]), Convert.ToDateTime(edatepic[0])); } else { string filter = ""; foreach (string item in datazl) { filter += $"\'{item}\',"; } filter = filter.Substring(0, filter.Length - 1); result = sjkcl.获取指定时间统计信息(Convert.ToDateTime(sdatepic[0]), Convert.ToDateTime(edatepic[0]), filter); } } for (int i = 0; i < result.Count; i++) { 资料种类 item = dataLists.First(y => y.数据库表名称 == result[i].称); if (item != null) { result[i].称 = item.表名称; } } return(Json(result)); }
public ActionResult 当前小时分钟数据() { string[] datazl = "SK_Other_Minute,SK_Pre_Minute,SK_RHU_Minute,SK_PRS_Minute,SK_Tem_Minute,SK_Wind_Minute".Split(','); 数据库处理 sjkcl = new 数据库处理(); List <资料种类> dataLists = sjkcl.获取数据库表信息(); List <SKViewModel> result = new List <SKViewModel>(); string filter = ""; foreach (string item in datazl) { filter += $"\'{item}\',"; } filter = filter.Substring(0, filter.Length - 1); result = sjkcl.获取指定时间统计信息(DateTime.Now.Date.AddHours(DateTime.Now.Hour), DateTime.Now, filter); List <DateTime> dateTimes = new List <DateTime>(); foreach (var item in result) { if (!dateTimes.Exists(y => y == item.时间)) { dateTimes.Add(Convert.ToDateTime(item.时间)); } } foreach (string item in datazl) { foreach (DateTime mydt in dateTimes) { if (!result.Exists(y => y.时间 == mydt && y.称 == item)) { result.Add(new SKViewModel { 时间 = mydt, 称 = item, 统计个数 = 0 }); } } } for (int i = 0; i < result.Count; i++) { 资料种类 item = dataLists.First(y => y.数据库表名称 == result[i].称); if (item != null) { result[i].称 = item.表名称; } } return(Json(result)); }
public List <SKViewModel> getdateDefault(DateTime sdate, DateTime edate, string datazl) { 数据库处理 sjkcl = new 数据库处理(); List <资料种类> dataLists = sjkcl.获取数据库表信息(); List <SKViewModel> result = new List <SKViewModel>(); result = sjkcl.获取指定时间资料名统计信息(sdate, edate, datazl); for (int i = 0; i < result.Count; i++) { 资料种类 item = dataLists.First(y => y.数据库表名称 == result[i].称); if (item != null) { result[i].称 = item.表名称; } } return(result); }
/// <summary> /// 恢复前三天的数据 /// </summary> public void HFRk() { 数据库处理 sjkcl = new 数据库处理(adminCodes); DateTime sDateTime = DateTime.Now.Date.AddDays(-3), eDateTime = DateTime.Now.Date; ObservableCollection <资料种类> sjbg = sjkcl.获取数据库表信息(); foreach (资料种类 item in sjbg) { if (item.ID == 1) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟其他资料入库(dateTime.AddMinutes(-9), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 2) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟降水量入库(dateTime.AddMinutes(-9), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 3) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟常规气压入库(dateTime.AddMinutes(-9), dateTime); str = sjkcl.分钟其他气压入库(dateTime.AddMinutes(-9), dateTime) + str; callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 4) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟常规湿度入库(dateTime.AddMinutes(-9), dateTime); str = sjkcl.分钟其他湿度入库(dateTime.AddMinutes(-9), dateTime) + str; callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 5) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟常规温度入库(dateTime.AddMinutes(-9), dateTime); str = sjkcl.分钟其他温度入库(dateTime.AddMinutes(-9), dateTime) + str; callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 6) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddMinutes(9); int hour = -1; bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; if (myhour != hour) { hour = myhour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1[0].个数 <= 1 || mylists1[0].个数 < mylists2[0].个数 / 2) { rkbs = true; } else { rkbs = false; } } if (rkbs) { string str = sjkcl.分钟其他风入库(dateTime.AddMinutes(-9), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddMinutes(10); } }); } if (item.ID == 7) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时其他资料入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 8) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时降水量入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 9) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时气压入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 10) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时湿度入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 11) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时温度入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } if (item.ID == 12) { Task.Factory.StartNew(() => { DateTime dateTime = sDateTime.AddHours(5); bool rkbs = false; while (dateTime.CompareTo(eDateTime) <= 0) { //判断资料是否缺失 int myhour = dateTime.Hour; List <数据库处理.入库个数统计信息> mylists1 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4), dateTime.Date.AddHours(myhour)); List <数据库处理.入库个数统计信息> mylists2 = sjkcl.获取入库个数统计信息(item.SJKName, dateTime.Date.AddHours(myhour - 4).AddDays(-15), dateTime.Date.AddHours(myhour).AddDays(-15)); if (mylists1.Count == 0 || mylists2.Count == 0) { rkbs = true; } else if (mylists1.Sum(y => y.个数) <= 10 || mylists1.Sum(y => y.个数) < mylists2.Sum(y => y.个数) / 10) { rkbs = true; } else { rkbs = false; } if (rkbs) { string str = sjkcl.小时风入库(dateTime.AddHours(-4), dateTime); callDuration.Text = str + callDuration.Text; } dateTime = dateTime.AddHours(5); } }); } } }
public ActionResult 备用(string[] sdatepic, string[] edatepic, string[] datazl, [DataSourceRequest] DataSourceRequest request) { 数据库处理 sjkcl = new 数据库处理(); List <资料种类> dataLists = dataLists = sjkcl.获取数据库表信息(); List <SKViewModel> result = new List <SKViewModel>(); if (datazl == null || datazl.Length == 0) { result = sjkcl.获取指定时间统计信息(Convert.ToDateTime(sdatepic[0]), Convert.ToDateTime(edatepic[0])); } else { bool bs = false; foreach (string item in datazl) { if (item.ToLower() == "all") { bs = true; } } if (bs) { result = sjkcl.获取指定时间统计信息(Convert.ToDateTime(sdatepic[0]), Convert.ToDateTime(edatepic[0])); } else { string filter = ""; foreach (string item in datazl) { filter += $"\'{item}\',"; } filter = filter.Substring(0, filter.Length - 1); result = sjkcl.获取指定时间统计信息(Convert.ToDateTime(sdatepic[0]), Convert.ToDateTime(edatepic[0]), filter); } } for (int i = 0; i < result.Count; i++) { 资料种类 item = dataLists.First(y => y.数据库表名称 == result[i].称); if (item != null) { result[i].称 = item.表名称; if (result[i].称.Contains("分钟")) { result[i].种类 = "分钟"; } else if (result[i].称.Contains("小时")) { result[i].种类 = "小时"; } else { result[i].种类 = "其他"; } } } List <SKViewModel> result2 = new List <SKViewModel>(); foreach (var item in result) { string name = item.称.Replace("小时", "").Replace("分钟", ""); if (!result2.Exists(y => y.称 == name && y.时间 == item.时间)) { result2.Add(new SKViewModel() { 称 = name, 时间 = item.时间 });; } if (item.种类 == "分钟") { result2.First(y => y.称 == name && y.时间 == item.时间).分钟个数 = item.统计个数; } else { result2.First(y => y.称 == name && y.时间 == item.时间).小时个数 = item.统计个数; } } //result = result.Where(y => y.名称.Contains("小时")).ToList(); return(Json(result2)); }