//} /// <summary> /// 创建分割信息 /// </summary> /// <param name="line"></param> /// <param name="startTime"></param> /// <param name="range"></param> /// <param name="opArray"></param> /// <returns></returns> public static List <OPMDL> BuildOPInfo(string line, DateTime startTime, int range, string opArray) { try { List <OPMDL> opList = null; if (opArray == null) { return(null); } string[] opStrs = opArray.Split('-'); if (opStrs == null || opStrs.Length <= 0) { return(null); } int[] items = new int[opStrs.Length]; int op = 0; int seq = 0; DateTime beginTime = startTime; opList = new List <OPMDL>(); foreach (string opItem in opStrs) { Int32.TryParse(opItem, out op); OPMDL mdl = new OPMDL(); TimeRange tRange = new TimeRange(); tRange.StartTime = beginTime; //beginTime.AddHours(1); tRange.EndTime = tRange.StartTime.AddHours(1); beginTime = tRange.EndTime; //build line info mdl.LINEID = line; mdl.IIME_RANGE = tRange; mdl.OP = op; mdl.SEQ = seq; ++seq; opList.Add(mdl); } return(opList); } catch { throw; } }
public static List <OPMDL> AddOPInfo(List <OPMDL> oldOPS, OPMDL mdl) { try { List <OPMDL> opList = new List <OPMDL>(); foreach (OPMDL item in oldOPS) { opList.Add(item); } opList.Add(mdl); return(opList); } catch { throw; } }
public static PlinePlanMDL PraseDataRow(DataRow row) { PlinePlanMDL mdl = new PlinePlanMDL(); try { mdl.PLANID = Convert.ToString(row["PLANID"]); mdl.PLINE = Convert.ToString(row["PLINE"]); mdl.NAME = Convert.ToString(row["NAME"]); mdl.OP1 = Convert.ToInt32(row["OP1"]); mdl.OP1_T = Convert.ToInt32(row["OP1_T"]); mdl.OP1_BEGIN = Convert.ToDateTime(row["OP1_BEGIN"]); mdl.OP1_RANGE = Convert.ToInt32(row["OP1_RANGE"]); ///初始化早班OP List <OPMDL> op1Items = OPMDL.BuildOPInfo(mdl.PLANID, mdl.OP1_BEGIN, mdl.OP1_RANGE, Convert.ToString(row["OP1_ITEMS"])); mdl.OP1_ITEMS = op1Items; mdl.OP2 = Convert.ToInt32(row["OP2"]); mdl.OP2_T = Convert.ToInt32(row["OP2_T"]); mdl.OP2_BEGIN = Convert.ToDateTime(row["OP2_BEGIN"]); mdl.OP2_RANGE = Convert.ToInt32(row["OP2_RANGE"]); ///初始化晚班OP List <OPMDL> op2Items = OPMDL.BuildOPInfo(mdl.PLANID, mdl.OP2_BEGIN, mdl.OP2_RANGE, Convert.ToString(row["OP2_ITEMS"])); mdl.OP2_ITEMS = op2Items; mdl.CREATE_TIME = Convert.ToDateTime(row["CREATE_TIME"]); mdl.REMARK = Convert.ToString(row["REMARK"]); return(mdl); } catch { throw; } }
/// <summary> /// 构造计划 /// </summary> /// <param name="id"></param> /// <param name="time"></param> /// <returns></returns> public static PlinePlanMDL BuildedPlan(int id, DateTime time) { try { PlinePlanMDL mdl = new PlinePlanMDL(); mdl.SetPLANID(time, id); mdl.name = "LINE" + id.ToString(); mdl.PLINE = id.ToString(); //早班OP mdl.OP1 = 10; time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 30, 0); mdl.OP1_BEGIN = time; mdl.OP1_RANGE = 10; mdl.OP1_T = 1; string arrayOP = string.Empty; for (int i = 0; i < mdl.OP1_RANGE; i++) { if (i == (mdl.OP1_RANGE - 1)) { arrayOP += mdl.OP1.ToString(); } else { arrayOP += mdl.OP1.ToString() + "-"; } } mdl.OP1_ITEMS = OPMDL.BuildOPInfo(mdl.PLINE, time, mdl.OP1_RANGE, arrayOP); //晚班OP mdl.OP2 = 10; mdl.OP2_BEGIN = time.AddHours(8); mdl.OP2_RANGE = 5; mdl.OP2_T = 2; arrayOP = string.Empty; for (int i = 0; i < mdl.OP2_RANGE; i++) { if (i == (mdl.OP2_RANGE - 1)) { arrayOP += mdl.OP2.ToString(); } else { arrayOP += mdl.OP2.ToString() + "-"; } } mdl.OP2_ITEMS = OPMDL.BuildOPInfo(mdl.PLINE, time, mdl.OP2_RANGE, arrayOP); mdl.CREATE_TIME = DateTime.Now; mdl.REMARK = string.Empty; return(mdl); } catch { throw; } }
/// <summary> /// 重新加载计划 /// </summary> /// <param name="mdl"></param> /// <returns></returns> public static PlinePlanMDL ReLoadPlanMDL(PlinePlanMDL mdl) { try { PlinePlanMDL newPline = new PlinePlanMDL(); //mdl.SetPLANID(time, id); newPline.name = mdl.NAME; newPline.PLINE = mdl.PLINE; //早班OP newPline.OP1 = mdl.OP1; newPline.OP1_BEGIN = mdl.OP1_BEGIN; newPline.OP1_RANGE = mdl.OP1_RANGE; newPline.OP1_T = mdl.OP1_T; string arrayOP = string.Empty; for (int i = 0; i < mdl.OP1_RANGE; i++) { if (i == (mdl.OP1_RANGE - 1)) { arrayOP += mdl.OP1.ToString(); } else { arrayOP += mdl.OP1.ToString() + "-"; } } mdl.OP1_ITEMS = OPMDL.BuildOPInfo(mdl.PLINE, newPline.OP1_BEGIN, mdl.OP1_RANGE, arrayOP); newPline.OP2 = mdl.OP2; newPline.OP2_BEGIN = mdl.OP2_BEGIN; newPline.OP2_RANGE = mdl.OP2_RANGE; newPline.OP2_T = mdl.OP2_T; arrayOP = string.Empty; for (int i = 0; i < mdl.OP2_RANGE; i++) { if (i == (mdl.OP2_RANGE - 1)) { arrayOP += mdl.OP2.ToString(); } else { arrayOP += mdl.OP2.ToString() + "-"; } } mdl.OP2_ITEMS = OPMDL.BuildOPInfo(mdl.PLINE, newPline.OP2_BEGIN, mdl.OP2_RANGE, arrayOP); mdl.CREATE_TIME = DateTime.Now; mdl.REMARK = string.Empty; return(mdl); } catch { throw; } }
/// <summary> /// 初始化默认的产线计划 /// </summary> /// <param name="id"></param> /// <param name="type"></param> /// <param name="time"></param> /// <returns></returns> public static PlinePlanMDL BuildDefualtPlan(int id, DateTime time) { try { XmlHelper helper = new XmlHelper("App.xml"); string opsStr = helper.SelectValue("/Root/APP/OP"); string rangeStr = helper.SelectValue("/Root/APP/TempRange"); string beginTimeStr = helper.SelectValue("/Root/APP/TempDateTime"); PlinePlanMDL mdl = new PlinePlanMDL(); mdl.SetPLANID(time, id); mdl.name = "LINE" + id.ToString(); mdl.PLINE = id.ToString(); string[] opItems = opsStr.Split(','); string[] beginDate = beginTimeStr.Split(':'); int op = 21; int startHour = 8; int startMinute = 30; int range = 10; Int32.TryParse(opItems[0], out op); Int32.TryParse(beginDate[0], out startHour); Int32.TryParse(beginDate[1], out startMinute); //早班OP mdl.OP1 = op; time = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, startHour, startMinute, 0); mdl.OP1_BEGIN = time; mdl.OP1_RANGE = range; mdl.OP1_T = 1; string arrayOP = string.Empty; for (int i = 0; i < mdl.OP1_RANGE; i++) { if (i == (mdl.OP1_RANGE - 1)) { arrayOP += mdl.OP1.ToString(); } else { arrayOP += mdl.OP1.ToString() + "-"; } } mdl.OP1_ITEMS = OPMDL.BuildOPInfo(mdl.PLINE, time, mdl.OP1_RANGE, arrayOP); Int32.TryParse(opItems[1], out op); //Int32.TryParse(beginDate[1], out startHour); //Int32.TryParse(beginDate[2], out startMinute); //晚班OP mdl.OP2 = op; mdl.OP2_BEGIN = time.AddHours(range); mdl.OP2_RANGE = 5; mdl.OP2_T = 2; arrayOP = string.Empty; for (int i = 0; i < mdl.OP2_RANGE; i++) { if (i == (mdl.OP2_RANGE - 1)) { arrayOP += mdl.OP2.ToString(); } else { arrayOP += mdl.OP2.ToString() + "-"; } } mdl.OP2_ITEMS = OPMDL.BuildOPInfo(mdl.PLINE, time, mdl.OP2_RANGE, arrayOP); mdl.CREATE_TIME = DateTime.Now; mdl.REMARK = string.Empty; return(mdl); } catch { throw; } }