/// <summary> /// 更新产线计划 /// </summary> /// <param name="mdl"></param> /// <returns></returns> public int UpdatePlinePlan(PlinePlanMDL mdl) { int ret = 0; string strSql = string.Empty; try { strSql = "UPDATE tlb_product_plan SET PLINE='{0}' ,NAME='{1}',OP1={2},OP1_T={3},OP1_BEGIN='{4}',OP1_RANGE={5},OP1_ITEMS='{6}',OP2={7}," + "OP2_T={8},OP2_BEGIN='{9}',OP2_RANGE={10},OP2_ITEMS='{11}',REMARK='{12}' WHERE PLANID='{13}'"; strSql = string.Format(strSql, mdl.PLINE, mdl.NAME, mdl.OP1, mdl.OP1_T, mdl.OP1_BEGIN.ToString("yyyy-MM-dd HH:mm:ss"), mdl.OP1_RANGE, OPMDL.BuildOPString(mdl.OP1_ITEMS), mdl.OP2, mdl.OP2_T, mdl.OP2_BEGIN.ToString("yyyy-MM-dd HH:mm:ss"), mdl.OP2_RANGE, OPMDL.BuildOPString(mdl.OP2_ITEMS), mdl.REMARK, mdl.PLANID); ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql, null); return(ret); } catch { throw; } }
public List <PlinePlanMDL> GetPlanInfos(DateTime datetime) { List <PlinePlanMDL> list = null; try { DataSet dataSet = null; string strSql = "SELECT * FROM tlb_product_plan WHERE PLANID LIKE '{0}%'"; strSql = string.Format(strSql, datetime.ToString("yyyyMMdd")); dataSet = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, strSql); if (dataSet == null || dataSet.Tables[0].Rows.Count <= 0) { return(null); } list = new List <PlinePlanMDL>(); foreach (DataRow row in dataSet.Tables[0].Rows) { list.Add(PlinePlanMDL.PraseDataRow(row)); } return(list); } catch { throw; } }
/// <summary> /// 添加采集数据单元 /// </summary> /// <param name="mdl"></param> /// <returns></returns> public int AddPlinePlan(PlinePlanMDL mdl) { int ret = 0; string strSql = string.Empty; try { strSql = "INSERT INTO tlb_product_plan ( PLANID,PLINE,NAME,OP1,OP1_T,OP1_BEGIN,OP1_RANGE,OP1_ITEMS,OP2,OP2_T,OP2_BEGIN,OP2_RANGE,OP2_ITEMS,CREATE_TIME,REMARK)" + " VALUES ('{0}','{1}','{2}',{3},{4},'{5}',{6},'{7}',{8},{9},'{10}',{11},'{12}','{13}','{14}')"; //"values('{0}','{1}','{2}',{3},{4},'{5}',{6},{7},{8},'{9}',{10},'{11}','{12}')"; strSql = string.Format(strSql, mdl.PLANID, mdl.PLINE, mdl.NAME, mdl.OP1, mdl.OP1_T, mdl.OP1_BEGIN.ToString("yyyy-MM-dd HH:mm:ss"), mdl.OP1_RANGE, OPMDL.BuildOPString(mdl.OP1_ITEMS), mdl.OP2, mdl.OP2_T, mdl.OP2_BEGIN.ToString("yyyy-MM-dd HH:mm:ss"), mdl.OP2_RANGE, OPMDL.BuildOPString(mdl.OP2_ITEMS), mdl.CREATE_TIME.ToString("yyyy-MM-dd HH:mm:ss"), mdl.REMARK); ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql, null); return(ret); } catch { throw; } }
/// <summary> /// 获取记录 /// </summary> /// <param name="lineID"></param> /// <param name="range"></param> /// <returns>minutes</returns> public PlinePlanMDL GetPlanInfo(string lineID) { PlinePlanMDL mdl = null; try { DataSet dataSet = null; string strSql = "SELECT * FROM tlb_product_plan WHERE PLANID='{0}'"; strSql = string.Format(strSql, lineID); dataSet = MySqlDBHelper.ExecuteDataSet(MySqlDBHelper.Conn, CommandType.Text, strSql); if (dataSet == null || dataSet.Tables[0].Rows.Count <= 0) { return(null); } mdl = PlinePlanMDL.PraseDataRow(dataSet.Tables[0].Rows[0]); return(mdl); } catch { throw; } }
private void LoadRangeChange(int index) { if (this.comboBox1.DataSource != null && index == 1) { if (loadPlan) { this.plineMDL.OP1_RANGE = this.comboBox1.SelectedIndex + 1; this.plineMDL = PlinePlanMDL.ReLoadPlanMDL(this.plineMDL); } TimeRange range1 = this.plineMDL.GetTimeRange(1); this.dateTimePicker1.Value = range1.StartTime; this.lbEndTime1.Text = range1.EndTime.ToString("HH:mm:ss"); } if (this.comboBox2.DataSource != null && index == 2) { if (loadPlan) { this.plineMDL.OP2_RANGE = this.comboBox2.SelectedIndex + 1; this.plineMDL = PlinePlanMDL.ReLoadPlanMDL(this.plineMDL); } TimeRange range2 = this.plineMDL.GetTimeRange(2); this.dateTimePicker2.Value = range2.StartTime; this.LbEndTime2.Text = range2.EndTime.ToString("HH:mm:ss"); } }
/// <summary> /// 加载新计划 /// </summary> /// <returns></returns> public static PlinePlanMDL ReloadNewPlan(string pId) { PlinePlanMDL mdl = null; try { PlinePlanDAL dal = new PlinePlanDAL(); if (dal.PlanExists(pId) <= 0) { mdl = PlinePlanMDL.BuildDefualtPlan(Convert.ToInt32(BaseVariable.LineID), DateTime.Now); if (dal.AddPlinePlan(mdl) > 0) { return(mdl); } return(null); } else { mdl = dal.GetPlanInfo(pId); return(mdl); } return(null); } catch (Exception ex) { CLog.WriteErrLog(ex.Message.ToString()); } return(null); }
private void DoAssemblyPlan() { try { PlanInfoForm dialog = new PlanInfoForm(); PlinePlanDAL dal = new PlinePlanDAL(); string plineid = DateTime.Now.ToString("yyyyMMdd") + BaseVariable.LineID; if (dal.PlanExists(plineid) <= 0) { if (dal.AddPlinePlan(PlinePlanMDL.BuildedPlan(Convert.ToInt32(BaseVariable.LineID) , DateTime.Now)) <= 0) { MessageBox.Show("加载产线配置失败,请检查配置文件信息!", "提示", MessageBoxButtons.OK); return; } } PlinePlanMDL mdl = dal.GetPlanInfo(plineid); if (mdl == null) { MessageBox.Show("加载产线配置失败,请检查配置文件信息!", "提示", MessageBoxButtons.OK); return; } dialog.PLAN = mdl; if (dialog.ShowDialog() == DialogResult.OK) { if (dal.UpdatePlinePlan(dialog.PLAN) > 0) { MessageBox.Show("修改产线配置信息成功!", "提示", MessageBoxButtons.OK); return; } else { MessageBox.Show("修改产线配置信息失败!", "提示", MessageBoxButtons.OK); return; } } } catch (System.Exception ex) { MessageBox.Show(ex.Message.ToString(), "提示", MessageBoxButtons.OK); } }
/// <summary> /// 加载模板计划 /// </summary> public void LoadTempPlan() { try { List <PlinePlanMDL> lists = PlinePlanMDL.InitialPlans(BaseVariable.LineNames, DateTime.Now); PlinePlanDAL dal = new PlinePlanDAL(); foreach (PlinePlanMDL mdl in lists) { if (dal.PlanExists(mdl.PLANID) <= 0) { dal.AddPlinePlan(mdl); } } } catch { throw; } }
/// <summary> /// 加载默认计划 /// </summary> /// <returns></returns> public bool LoadSystemDefualtPlan() { try { // List<PlinePlanMDL> lists = PlinePlanMDL.InitialPlans(BaseVariable.LineNames, DateTime.Now); int linid = Convert.ToInt32(BaseVariable.LineID); PlinePlanMDL mdl = PlinePlanMDL.BuildDefualtPlan(linid, DateTime.Now); PlinePlanDAL dal = new PlinePlanDAL(); if (dal.PlanExists(mdl.PLANID) <= 0) { if (dal.AddPlinePlan(mdl) > 0) { this.curPlan = mdl; return(true); } } else { curPlan = dal.GetPlanInfo(mdl.PLANID); if (curPlan != null) { return(true); } } return(false); } catch { throw; } }
private void IntialPalnData() { ProductLineCaculator plc = new ProductLineCaculator(); plc.ReLoad(); int line = Convert.ToInt32(BaseVariable.LineID); string plainid = DateTime.Now.ToString("yyyyMMdd") + string.Format("{0:D2}", line); this.planMDL = ReloadNewPlan(plainid); this.planMDL.PLINE = string.Format("{0:D2}", line); GraphPane myPane = zg1.GraphPane; myPane.Fill = new Fill(Color.Black); myPane.XAxis.Title.Text = "Section of plan"; myPane.XAxis.Title.FontSpec.FontColor = Color.White; myPane.XAxis.Type = AxisType.Date; myPane.XAxis.Scale.Format = "HH:mm"; myPane.YAxis.Title.Text = "Changeover Time"; myPane.YAxis.Title.FontSpec.FontColor = Color.White; int type = 1; List <OPMDL> opItems = null; if (!planMDL.GetTimeRange(1).IsInRange(DateTime.Now)) { opItems = this.planMDL.OP2_ITEMS; type = 2; } else { opItems = this.planMDL.OP1_ITEMS; } LineDTDAL dtDal = new LineDTDAL(); ChangeTimeDAL ctDal = new ChangeTimeDAL(); TimeRange tRange = new TimeRange(opItems[0].IIME_RANGE.StartTime, opItems[opItems.Count - 1].IIME_RANGE.EndTime); List <TimeRange> dtrangs = dtDal.GetTimeRangeByRange(this.planMDL.PLINE, tRange); PointPairList list = new PointPairList(); PointPairList changelist = new PointPairList(); Color changeColor = Color.White; for (int i = 0; i < opItems.Count; i++) { int haveDt = 0; if (dtrangs != null && dtrangs.Count > 0) { foreach (TimeRange item in dtrangs) { if (item.IsInFullRange(opItems[i].IIME_RANGE.StartTime, opItems[i].IIME_RANGE.EndTime)) { haveDt = 1; continue; } } } // double x = (double)i * 5.0; double x = (double)new XDate(opItems[i].IIME_RANGE.StartTime); int count = 0; if (haveDt <= 0) { count = ctDal.GetChangeTime(opItems[i].LINEID.Substring(opItems[i].LINEID.Length - 2, 2), opItems[i].IIME_RANGE); } double changeOver = 0; if (count > 0) { //除以分钟 changeOver = Math.Round((double)count / (double)60, 2); if (changeOver > 18) { changeOver = 18; } if (changeOver > 10) { changeColor = Color.Red; } } double y = 5; changelist.Add(x, changeOver); list.Add(x, y); } LineItem defualtCurve = myPane.AddCurve("Standard", list, Color.Yellow, SymbolType.None); LineItem changeOverCurve = myPane.AddCurve("ChangeOver", changelist, changeColor, SymbolType.Circle); // changeOverCurve.Symbol.Fill.Color = Color.White; changeOverCurve.Line.Width = 2; changeOverCurve.Symbol.Fill = new Fill(changeColor); defualtCurve.Label.IsVisible = false; changeOverCurve.Label.IsVisible = false; myPane.XAxis.Scale.FontSpec.FontColor = Color.White; myPane.XAxis.Title.FontSpec.FontColor = Color.White; myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.Scale.FontSpec.FontColor = Color.White; myPane.YAxis.Title.FontSpec.FontColor = Color.White; myPane.YAxis.Scale.Max = 18; myPane.YAxis.Scale.Min = -1; //// Fill the axis background with a gradient myPane.Chart.Fill = new Fill(Color.Black, Color.Black, 45.0f); //// Enable scrollbars if needed zg1.IsShowHScrollBar = false; zg1.IsShowVScrollBar = false; zg1.IsAutoScrollRange = true; zg1.IsScrollY2 = true; //// OPTIONAL: Show tooltips when the mouse hovers over a point zg1.IsShowPointValues = true; zg1.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler); SetSize(); //// Tell ZedGraph to calculate the axis ranges //// Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets //// up the proper scrolling parameters zg1.AxisChange(); zg1.IsEnableHZoom = false; zg1.IsEnableVZoom = false; zg1.IsEnableWheelZoom = false; //// Make sure the Graph gets redrawn zg1.Invalidate(); }