using System; using System.Collections.Generic; using System.Linq; using System.Text; using CoreFS.CA06; using System.Data; using Core.Mes.Client.Comm.Server; using System.Collections; using Core.StlMes.Client.ZGMil.Entity; namespace Core.StlMes.Client.ZGMil.Common { class HOTMethod : FrmBase { private OpeBase _ob; public OpeBase OB { get { return _ob; } set { _ob = value; } } public HOTMethod(OpeBase ob) { OB = ob; } public HOTMethod() { // TODO: Complete member initialization } /// /// 判断炉号是否结炉 /// /// /// 0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热 5-定径 6-管排锯 7-矫直 8-探伤 9-质检 /// public bool isNode(string JudgeStoveNo, string ResultNo, int ProcessNo, string PlineCode) { bool isnode = false; DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.isNode", new object[] { JudgeStoveNo, ResultNo, ProcessNo, PlineCode }, this._ob); if (dt.Rows.Count > 0) { if (dt.Rows[0][0].ToString() == "1") { isnode = true; } } return isnode; } /// /// 查询炉内是否有正在装炉或正在出炉的计划 /// /// 0-正在装炉,2-正在出炉 /// 0-加热炉,2-再加热炉 /// isInOrOut true-有 false-没有 public DataTable InFurIsEnd(string Falg, string PlineCode, int FurType = 0) { DataTable dt = null; if (FurType == 0) { dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FurResult.getINFurNonEndIN", new object[] { Falg, PlineCode }, this._ob); } else { dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FrmReFurResult.getINFurNonEndIN", new object[] { Falg, PlineCode }, this._ob); } return dt; } /// /// 查询当前炉次炉内状态 /// /// /// public DataTable InFurStatus(string JudgeStoveNo) { DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FurResult.getInFurStatus", new object[] { JudgeStoveNo }, this._ob); return dt; } /// /// 查询上个班班次班组 /// 天管白夜两班制,天淮早中晚三班制 /// /// /// /// public static string GetShiftBefore(string Shift, string Group, string Date, string PlineCode) { ArrayList ShiftList = new ArrayList(); string ShiftBefore = ""; string[] ShiftD = new string[4] { "甲", "乙", "丙", "丁" }; int[] ShiftNo = new int[4] { 3, 0, 1, 2 }; //通过修改此数组得到指定日期的班组 起始点为2015年12月31日排班顺序 int[] MouseDay = new int[13] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29 }; int LoopCount = 0; //循环次数 //算出当前日期与起始点相差天数 int Days = 0; string DYear = Date.Substring(0, 4); for (int i = 2016; i < int.Parse(DYear); i++) { if (i % 4 == 0) { Days += 366; } else { Days += 365; } } string DMouse = Date.Substring(4, 2); for (int i = 1; i < int.Parse(DMouse); i++) { if (i == 2) { if (int.Parse(DYear) % 4 == 0) { Days += MouseDay[12]; } else { Days += MouseDay[i - 1]; } } else { Days += MouseDay[i - 1]; } } string DDay = Date.Substring(6, 2); Days += int.Parse(DDay); if (Days > 0) { if (Days % 2 == 0) { LoopCount = (Days / 2) % 4; } else { LoopCount = ((Days - 1) / 2 + 1) % 4; } } ShiftNo[0] = (ShiftNo[0] + 4 - LoopCount) % 4; ShiftNo[1] = (ShiftNo[1] + 4 - LoopCount) % 4; ShiftNo[2] = (ShiftNo[2] + 4 - LoopCount) % 4; ShiftNo[3] = (ShiftNo[3] + 4 - LoopCount) % 4; ShiftList.Add(ShiftD[ShiftNo[0]]); //早 ShiftList.Add(ShiftD[ShiftNo[1]]); //中 ShiftList.Add(ShiftD[ShiftNo[2]]); //晚 ShiftList.Add(ShiftD[ShiftNo[3]]); //休 //ShiftList.Add//2016年 1月1日 1月2日 配班表 if (PlineCode.Equals("C072")) { //早中晚三班制 switch (Shift) { case "1": ShiftBefore = "3"; break; case "2": ShiftBefore = "1"; break; case "3": ShiftBefore = "2"; break; } if (Shift == "1") { switch (ShiftList[2].ToString()) { case "甲": ShiftBefore += "1"; break; case "乙": ShiftBefore += "2"; break; case "丙": ShiftBefore += "3"; break; case "丁": ShiftBefore += "4"; break; } } else { for (int i = 0; i < ShiftNo.Count(); i++) { if (ShiftNo[i] == int.Parse(Group) - 1) { ShiftBefore += (int.Parse((ShiftNo[(i + 3) % 4]).ToString()) + 1).ToString(); } } } } else { //白夜两班制 switch (Shift) { case "3": ShiftBefore = "0"; switch (Group) { case "1": ShiftBefore += "4"; break; case "2": ShiftBefore += "1"; break; case "3": ShiftBefore += "2"; break; case "4": ShiftBefore += "3"; break; } break; case "0": ShiftBefore = "3"; switch (Group) { case "1": ShiftBefore += "3"; break; case "2": ShiftBefore += "4"; break; case "3": ShiftBefore += "1"; break; case "4": ShiftBefore += "2"; break; } break; } } return ShiftBefore; } /// /// 查询上个班班次班组 /// /// 当前班次 /// 当前班组 /// // 0-上道班次 班组 1-下道班次班组 /// /// public static string GetShiftBefore(string Shift, string Group, string Date) { ArrayList ShiftList = new ArrayList(); string ShiftBefore = ""; string[] ShiftD = new string[4] { "甲", "乙", "丙", "丁" }; int[] ShiftNo = new int[4] { 3, 0, 1, 2 }; //通过修改此数组得到指定日期的班组 起始点为2015年12月31日排班顺序 int[] MouseDay = new int[13] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29 }; int LoopCount = 0; //循环次数 //算出当前日期与起始点相差天数 int Days = 0; string DYear = Date.Substring(0, 4); for (int i = 2016; i < int.Parse(DYear); i++) { if (i % 4 == 0) { Days += 366; } else { Days += 365; } } string DMouse = Date.Substring(4, 2); for (int i = 1; i < int.Parse(DMouse); i++) { if (i == 2) { if (int.Parse(DYear) % 4 == 0) { Days += MouseDay[12]; } else { Days += MouseDay[i - 1]; } } else { Days += MouseDay[i - 1]; } } string DDay = Date.Substring(6, 2); Days += int.Parse(DDay); if (Days > 0) { if (Days % 2 == 0) { LoopCount = (Days / 2) % 4; } else { LoopCount = ((Days - 1) / 2 + 1) % 4; } } ShiftNo[0] = (ShiftNo[0] + 4 - LoopCount) % 4; ShiftNo[1] = (ShiftNo[1] + 4 - LoopCount) % 4; ShiftNo[2] = (ShiftNo[2] + 4 - LoopCount) % 4; ShiftNo[3] = (ShiftNo[3] + 4 - LoopCount) % 4; ShiftList.Add(ShiftD[ShiftNo[0]]); //早 ShiftList.Add(ShiftD[ShiftNo[1]]); //中 ShiftList.Add(ShiftD[ShiftNo[2]]); //晚 ShiftList.Add(ShiftD[ShiftNo[3]]); //休 //ShiftList.Add//2016年 1月1日 1月2日 配班表 switch (Shift) { case "1": ShiftBefore = "3"; break; case "2": ShiftBefore = "1"; break; case "3": ShiftBefore = "2"; break; } if (Shift == "1") { switch (ShiftList[2].ToString()) { case "甲": ShiftBefore += "1"; break; case "乙": ShiftBefore += "2"; break; case "丙": ShiftBefore += "3"; break; case "丁": ShiftBefore += "4"; break; } } else { for (int i = 0; i < ShiftNo.Count(); i++) { if (ShiftNo[i] == int.Parse(Group) - 1) { ShiftBefore += (int.Parse((ShiftNo[(i + 3) % 4]).ToString()) + 1).ToString(); } } } return ShiftBefore; } /// /// 查询下个班班次班组 /// /// 当前班次 /// 当前班组 /// /// public static string GetShiftAfter(string Shift, string Group, string Date) { ArrayList ShiftList = new ArrayList(); string ShiftAfter = ""; string[] ShiftD = new string[4] { "甲", "乙", "丙", "丁" }; int[] ShiftNo = new int[4] { 3, 0, 1, 2 }; //通过修改此数组得到指定日期的班组 起始点为2015年12月31日排班顺序 int[] MouseDay = new int[13] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 29 }; int LoopCount = 0; //循环次数 //算出当前日期与起始点相差天数 int Days = 0; string DYear = Date.Substring(0, 4); for (int i = 2016; i < int.Parse(DYear); i++) { if (i % 4 == 0) { Days += 366; } else { Days += 365; } } string DMouse = Date.Substring(4, 2); for (int i = 1; i < int.Parse(DMouse); i++) { if (i == 2) { if (int.Parse(DYear) % 4 == 0) { Days += MouseDay[12]; } else { Days += MouseDay[i - 1]; } } else { Days += MouseDay[i - 1]; } } string DDay = Date.Substring(6, 2); Days += int.Parse(DDay); if (Days > 0) { if (Days % 2 == 0) { LoopCount = (Days / 2) % 4; } else { LoopCount = ((Days - 1) / 2 + 1) % 4; } } ShiftNo[0] = (ShiftNo[0] + 4 - LoopCount) % 4; ShiftNo[1] = (ShiftNo[1] + 4 - LoopCount) % 4; ShiftNo[2] = (ShiftNo[2] + 4 - LoopCount) % 4; ShiftNo[3] = (ShiftNo[3] + 4 - LoopCount) % 4; ShiftList.Add(ShiftD[ShiftNo[0]]); //早 ShiftList.Add(ShiftD[ShiftNo[1]]); //中 ShiftList.Add(ShiftD[ShiftNo[2]]); //晚 ShiftList.Add(ShiftD[ShiftNo[3]]); //休 //ShiftList.Add//2016年 1月1日 1月2日 配班表 switch (Shift) { case "1": ShiftAfter = "2"; break; case "2": ShiftAfter = "3"; break; case "3": ShiftAfter = "1"; break; } if (Shift == "3") { switch (ShiftList[0].ToString()) { case "甲": ShiftAfter += "1"; break; case "乙": ShiftAfter += "2"; break; case "丙": ShiftAfter += "3"; break; case "丁": ShiftAfter += "4"; break; } } else { for (int i = 0; i < ShiftNo.Count(); i++) { if (ShiftNo[i] == int.Parse(Group) - 1) { ShiftAfter += ((int.Parse((ShiftNo[(i + 3) % 4]).ToString()) + 3)%4).ToString(); } } } return ShiftAfter; } /// /// 修改交班标识 /// 0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热 5-定径 6-管排锯 7-矫直 8-探伤 9-质检 /// 0-入炉 1-出炉 /// public void UpdateChangeFlag(string JudgeStvoeNo, string ResultNo, string FeedRowNo, int ProcessNo, int Seq, int FurFlag) { int count = ServerHelper.SetData("com.steering.mes.zgmil.coup.FeedSawResult.UpdateChangeFlag", new object[] { JudgeStvoeNo, ResultNo, FeedRowNo, ProcessNo, Seq, FurFlag }, this._ob); } /// /// 查询待接班确认Seq /// 0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热 5-定径 6-管排锯 7-矫直 8-探伤 9-质检 /// public int GetWaitChangeSeq(string JudgeStvoeNo, string ResultNo, string FeedRowNo, int ProcessNo, int FurFlag, string proPlanId, string gxPlanNo) { int Seq = 0; DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.GetWaitChangeSeq", new object[] { JudgeStvoeNo, ResultNo, FeedRowNo, ProcessNo, FurFlag, proPlanId, gxPlanNo }, this._ob); if (dt.Rows.Count > 0) { Seq = int.Parse(dt.Rows[0][0].ToString()); } return Seq; } /// /// 结炉前判断是否有待交班确认的管 /// /// /// /// 工序号 0-锯切 1-环形加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-管排锯 7-矫直 8-探伤 9-质检 /// public int NodeGetWaitChangeMat(string JudgeStoveNo, string ResultNo, int ProcessNo) { int MatNo = 0; DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.NodeGetWaitChangeMat", new object[] { JudgeStoveNo, ResultNo, ProcessNo }, this._ob); if (dt.Rows.Count > 0) { MatNo = int.Parse(dt.Rows[0][0].ToString()); } return MatNo; } /// /// 查询当班是否有完成的炉次 /// /// /// /// Result 0-未完成 1-已完成 public int IsFirstFur(string DateTime, string Group, string Shift) { int Result = 0; return Result; } /// /// 查询是否已经接班登录 /// /// /// /// /// /// 工序号(0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-分切 7矫直 8-探伤 9-人工质检) /// /// public bool IsChanged(string StartTime, string EndTime, string Shift, string Group, string ProcessNo, string PlineCode) { bool Result = false; DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.GetIsChanged", new object[] { StartTime, EndTime, Shift, Group, ProcessNo, PlineCode }, this._ob); if (dt.Rows.Count > 0) { Result = true; } return Result; } /// /// 接班后插入履历 /// /// /// /// /// /// 工序号(0-锯切 1-加热炉 2-穿孔 3-连轧 4-再加热炉 5-定径 6-分切 7矫直 8-探伤 9-人工质检) /// /// public void InsertChangeRemuse(string Shift, string Group, string User, string ProcessNo, string PlineCode) { ArrayList arry = new ArrayList(); arry.Add(Shift); arry.Add(Group); arry.Add(User); arry.Add(ProcessNo); arry.Add(PlineCode); //bool Result = false; //string time = DateTime.Now.ToString(); //int dt = ServerHelper.SetData("com.steering.mes.zgmil.coup.FeedSawResult.InsertChangeRemuse", new object[] {arry }, this._ob); //if (dt.Rows.Count > 0) //{ // Result = true; //} } /// /// 获取前道班UserID /// /// 开始时间 /// 结束时间 /// 前道班次 /// 前道班组 /// 工序号 /// UserID public string GetUserIDBefore(string StartTime, string EndTime, string Shift, string Group, int ProcessNo, string PlineCode) { string UserID = ""; DataTable dt = ServerHelper.GetData("com.steering.mes.zgmil.coup.FeedSawResult.GetUserIDBefore", new object[] { StartTime, EndTime, Shift, Group, ProcessNo, PlineCode }, this._ob); if (dt.Rows.Count > 0) { UserID = dt.Rows[0][0].ToString(); } return UserID; } } }