public IActionResult HistoryData() { string[] UserIDList = PMUser.UserMessage.Select(x => x.EmpID).ToArray(); bool UserID = UserIDList.Contains <string>(HttpContext.Request.Cookies["EmpID"]); //if (PMUser.EmpID ==string.Empty) //{ // return RedirectToAction("Index", "Index"); //} if (!UserID) { return(RedirectToAction("Index", "Index")); } else if (HttpContext.Request.Cookies["UserGuid"] != PMUser.GetuserGuid(HttpContext.Request.Cookies["EmpID"])) { return(RedirectToAction("Index", "Index")); } else { MDatacenter data = new MDatacenter(); data.Datacenterorderdelay(); Workplaninfo.GetWorkPlanInfo(string.Empty); return(View()); } }
public void Datacenterorderdelay() { DataTable table = Workplaninfo.GetWorkOrder("delayDays", "isScheduleWorkID = '1'", string.Empty); foreach (DataRow item in table.Rows) { if (item[0].ToString() == "") { //异常的数量 ErrorCount++; } else { if (Convert.ToInt32(item[0]) < 0) { EarlyConunt++; } else if (Convert.ToInt32(item[0]) > 0) { LateCount++; } else { OnTimeCount++; } } } //计算四个值的百分比,返回给前端页面显示 ErrorPercentage = Convert.ToInt32((Convert.ToDouble(ErrorCount) / Convert.ToDouble(table.Rows.Count)) * 100); EarlyPercentage = Convert.ToInt32((Convert.ToDouble(EarlyConunt) / Convert.ToDouble(table.Rows.Count)) * 100); OnTimePercentage = Convert.ToInt32((Convert.ToDouble(OnTimeCount) / Convert.ToDouble(table.Rows.Count)) * 100); LatePercentage = Convert.ToInt32((Convert.ToDouble(LateCount) / Convert.ToDouble(table.Rows.Count)) * 100); }
public List <DateTime> LiDemandDay() { List <DateTime> list = new List <DateTime>(); foreach (DataRow dr in Workplaninfo.GetWorkOrder("distinct firstDemandDay", "isScheduleWorkID = 1", "firstDemandDay").Rows) { list.Add(Convert.ToDateTime(dr[0])); } return(list); }
/// <summary> /// 获取订单列表的数据 /// </summary> /// <returns>table</returns> public DataTable WorkOrderData() { GetWorkplanBars getWorkplanBars = new GetWorkplanBars(); //查看要查询数据库中的哪些列 JObject SQLWorkOrderFileds = PMAppSettings.TableFileds.SelectToken("SQLWorkOrderFiled").ToObject <JObject>(); string SQLWorkOrderFiled = ""; foreach (var item in SQLWorkOrderFileds) { if (string.IsNullOrEmpty(SQLWorkOrderFiled)) { SQLWorkOrderFiled += item.Key; } else { SQLWorkOrderFiled += "," + item.Key; } } DataTable dt = Workplaninfo.GetWorkOrder(SQLWorkOrderFiled, "isScheduleWorkID = '1'", string.Empty); DataTable productId = Workplaninfo.GetWorkOrder("productID", "isScheduleWorkID = '1'", string.Empty); foreach (var item in SQLWorkOrderFileds) { dt.Columns[item.Key].ColumnName = item.Value.Value <string>(); } DataTable AttrTable = getWorkplanBars.GetAttrTable(productId); JObject SQLAttrFiled = PMAppSettings.TableFileds.SelectToken("SQLAttrFiled").ToObject <JObject>(); foreach (var item in SQLAttrFiled) { dt.Columns.Add(item.Value.Value <string>()); } for (int i = 0; i < dt.Rows.Count; i++) { for (int v = 0; v < AttrTable.Rows.Count; v++) { if (AttrTable.Rows[v]["itemName"].ToString() == dt.Rows[i]["产品名称"].ToString()) { foreach (DataColumn col in AttrTable.Columns) { if (col.ColumnName != "itemName") { dt.Rows[i][col.ColumnName] = AttrTable.Rows[v][col.ColumnName].ToString().Replace(" - ", " ").Replace("\"", "'"); } } } } } return(dt); }
/// <summary> /// 查询设备下的数据信息 /// </summary> /// <param name="optionPlan">设备名称</param> /// <param name="ViewName"></param> /// <returns></returns> public DataTable GetPlanBars(string optionPlan, string ViewName) { DataTable table = new DataTable(); //查看要查询数据库中的哪些列 JObject SQLWorkPlanFileds = PMAppSettings.TableFileds.SelectToken("SQLWorkPlanFiled").ToObject <JObject>(); string SQLWorkPlanFiled = ""; foreach (var item in SQLWorkPlanFileds) { if (string.IsNullOrEmpty(SQLWorkPlanFiled)) { SQLWorkPlanFiled += item.Key; } else { SQLWorkPlanFiled += "," + item.Key; } } if (ViewName == null) { table = Workplaninfo.GetWorkPlanBars(SQLWorkPlanFiled, "OperationID = '" + optionPlan + "'", string.Empty); } else if (optionPlan == null) { //table = Workplaninfo.GetWorkPlanBars("WIPID ,itemWorkID,ProductID ,userDef_str1,allQuantity ,quantity,finishedQuantity,jobFinishedQty ,firstDemandDay,State ,route ,realOpName ,OperationID ,Lock,RealWorkTime ,PlannedStart ,PlannedFinish,PlannedSetup ,setupTime,finishStatus ,useFixStartDay ,schPri", "OperationID in ( select resName from View_pmViewGroup where VIewName = '" + ViewName + "')", string.Empty); table = Workplaninfo.GetWorkPlanBars(SQLWorkPlanFiled, "OperationID in ( select resName from View_pmViewGroup where VIewName = '" + ViewName + "')", string.Empty); } foreach (var item in SQLWorkPlanFileds) { table.Columns[item.Key].ColumnName = item.Value.Value <string>(); } table.Columns.Add("temp", Type.GetType("System.Decimal")); table.Columns.Add("temp1", Type.GetType("System.Decimal")); for (int i = 0; i < table.Rows.Count; i++) { decimal productTime = Convert.ToDecimal(table.Rows[i][SQLWorkPlanFileds["RealWorkTime"].ToString()]) / 3600; productTime = Math.Round(productTime, 2); table.Rows[i]["temp"] = productTime; decimal setupTime = Convert.ToDecimal(table.Rows[i][SQLWorkPlanFileds["setupTime"].ToString()]) / 60; setupTime = Math.Round(setupTime, 2); table.Rows[i]["temp1"] = setupTime; } table.Columns.Remove(SQLWorkPlanFileds["RealWorkTime"].ToString()); table.Columns["temp"].ColumnName = SQLWorkPlanFileds["RealWorkTime"].ToString(); table.Columns.Remove(SQLWorkPlanFileds["setupTime"].ToString()); table.Columns["temp1"].ColumnName = SQLWorkPlanFileds["setupTime"].ToString(); table.AcceptChanges(); return(table); }
public void Pieorder() { List <DateTime> list = LiDemandDay(); DataTable table = Workplaninfo.GetWorkOrder("workID,productID,allQuantity,desp,planStartTime,planFinishTime,firstDemandDay,delayDays", "isScheduleWorkID = 1", string.Empty); ErrorTime = new string[list.Count]; EarlyTime = new string[list.Count]; OnTime = new string[list.Count]; LateTime = new string[list.Count]; CountTime = new string[list.Count]; Allordercount = new int[list.Count]; for (int i = 0; i < list.Count; i++) { DataRow[] row = table.Select("firstDemandDay='" + list[i] + "'"); int lateCount = 0; int earlyCount = 0; int ontimeCount = 0; int errorCount = 0; foreach (var item in row) { if (item[7].ToString() == "") { errorCount++; } else { if (Convert.ToInt32(item[7]) > 0) { lateCount++; //LateTime[i]++; } else if (Convert.ToInt32(item[7]) < 0) { earlyCount++; } else if (Convert.ToInt32(item[7]) == 0) { ontimeCount++; } } } Allordercount[i] = row.Count(); LateTime[i] = (Convert.ToDecimal(lateCount) / Convert.ToDecimal(row.Count()) * 100).ToString("0.00"); EarlyTime[i] = (Convert.ToDecimal(earlyCount) / Convert.ToDecimal(row.Count()) * 100).ToString("0.00"); OnTime[i] = (Convert.ToDecimal(ontimeCount) / Convert.ToDecimal(row.Count()) * 100).ToString("0.00"); ErrorTime[i] = (Convert.ToDecimal(errorCount) / Convert.ToDecimal(row.Count()) * 100).ToString("0.00"); } }
public IActionResult Implementation() { string[] UserIDList = PMUser.UserMessage.Select(x => x.EmpID).ToArray(); bool UserID = UserIDList.Contains <string>(HttpContext.Request.Cookies["EmpID"]); if (!UserID) { return(RedirectToAction("Index", "Index")); } else if (HttpContext.Request.Cookies["UserGuid"] != PMUser.GetuserGuid(HttpContext.Request.Cookies["EmpID"])) { return(RedirectToAction("Index", "Index")); } else { Workplaninfo.GetWorkPlanInfo(string.Empty); ViewBag.Owner = Workplaninfo.Owner; ViewBag.WorkPlanId = Workplaninfo.WorkPlanId; ViewBag.WorkPlanName = Workplaninfo.WorkPlanName; ViewBag.ReleaseTime = Workplaninfo.ReleaseTime; return(View()); } }
public IActionResult Index() { string[] UserIDList = PMUser.UserMessage.Select(x => x.EmpID).ToArray(); bool UserID = UserIDList.Contains <string>(HttpContext.Request.Cookies["EmpID"]); //if (PMUser.EmpID ==string.Empty) //{ // return RedirectToAction("Index", "Index"); //} if (!UserID) { return(RedirectToAction("Index", "Index")); } else if (HttpContext.Request.Cookies["UserGuid"] != PMUser.GetuserGuid(HttpContext.Request.Cookies["EmpID"])) { return(RedirectToAction("Index", "Index")); } else { //获取计划信息 Workplaninfo.GetWorkPlanInfo(string.Empty); ViewBag.Owner = Workplaninfo.Owner; ViewBag.WorkPlanId = Workplaninfo.WorkPlanId; ViewBag.WorkPlanName = Workplaninfo.WorkPlanName; ViewBag.ReleaseTime = Workplaninfo.ReleaseTime; //获取order统计信息 MDatacenter data = new MDatacenter(); data.Datacenterorderdelay(); ViewBag.ErrorPercentage = data.ErrorPercentage; ViewBag.LatePercentage = data.LatePercentage; ViewBag.OnTimePercentage = data.OnTimePercentage; ViewBag.EarlyPercentage = data.EarlyPercentage; OrderForm order = new OrderForm(); order.Pieorder(); return(View(data)); } }