Browse Source

过站切换工单添加提示

章政 7 years ago
parent
commit
e4d3e3678d

+ 30 - 4
UAS-MES/PublicMethod/LogicHandler.cs

@@ -16,6 +16,24 @@ namespace UAS_MES.PublicMethod
         static StringBuilder sql = new StringBuilder();
         //用于存放批量执行的SQL
         static List<string> sqls = new List<string>();
+        /// <summary>
+        /// 记录复判记录
+        /// </summary>
+        /// <param name="iSN"></param>
+        /// <param name="iMakeCode"></param>
+        /// <param name="iSource"></param>
+        /// <param name="iFileName"></param>
+        /// <param name="iLineCode"></param>
+        /// <param name="iCombine"></param>
+        public static void AutoPassJudge(string iSN, string iMakeCode, string iSource, string iFileName, string iLineCode, string iCombine)
+        {
+            //插入不良判断记录
+            sql.Clear();
+            sql.Append("insert into AUTOSCAN_REJUDGE(asr_id,asr_indate,asr_filename,asr_combinecode,asr_sourcecode,");
+            sql.Append("asr_linecode,asr_makecode,asr_sncode) values(AUTOSCAN_REJUDGE_seq.nextval,sysdate,");
+            sql.Append("'" + iFileName + "','" + iCombine + "','" + iSource + "','" + iLineCode + "','" + iMakeCode + "','" + iSN + "')");
+            dh.ExecuteSql(sql.ToString(), "insert");
+        }
 
         /// <summary>
         /// 检测当前的岗位资源对应的工序
@@ -845,9 +863,15 @@ namespace UAS_MES.PublicMethod
             oErrorMessage = "";
             string StepCode = "";
             string StepName = "";
+            string ScanType = "";
+            string LineCode = "";
             if (iResult == "" || iResult == null)
                 iResult = "检查未通过";
-            GetStepCodeAndNameBySource(iSourceCode, ref StepCode, ref StepName);
+            GetStepCodeAndNameAndTypAndLineCodeBySource(iSourceCode, ref StepCode, ref StepName, ref ScanType, ref LineCode);
+            if (ScanType == "REJUDGE")
+            {
+                AutoPassJudge(iSnCode, iMakeCode, iSourceCode, "", LineCode, "");
+            }
             sql.Clear();
             sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
             sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_soncode,mb_status,mb_badremark,mb_bgname,mb_badname)");
@@ -1069,13 +1093,15 @@ namespace UAS_MES.PublicMethod
         /// <param name="Source"></param>
         /// <param name="StepCode"></param>
         /// <param name="StepName"></param>
-        private static void GetStepCodeAndNameBySource(string Source, ref string StepCode, ref string StepName)
+        private static void GetStepCodeAndNameAndTypAndLineCodeBySource(string Source, ref string StepCode, ref string StepName, ref string ScanType, ref string LineCode)
         {
-            DataTable dt = dh.getFieldsDataByCondition("source", new string[] { "sc_stepcode", "sc_stepname", "sc_linecode" }, "sc_code='" + Source + "'");
+            DataTable dt = dh.getFieldsDataByCondition("source", new string[] { "sc_scantype", "sc_stepcode", "sc_stepname", "sc_linecode" }, "sc_code='" + Source + "'");
             if (dt.Rows.Count > 0)
             {
                 StepCode = dt.Rows[0]["sc_stepcode"].ToString();
                 StepName = dt.Rows[0]["sc_stepname"].ToString();
+                ScanType = dt.Rows[0]["sc_scantype"].ToString();
+                LineCode = dt.Rows[0]["sc_linecode"].ToString();
             }
         }
 
@@ -1158,7 +1184,7 @@ namespace UAS_MES.PublicMethod
                     //若有多个,以|分割
                     string[] pres = iPrefix.Split('|');
                     bool f = false;
-                    for (int i=0;i<pres.Length;i++)
+                    for (int i = 0; i < pres.Length; i++)
                     {
                         if (pres[i] == "" ? true : iSN.StartsWith(pres[i]))
                         {

+ 20 - 5
UAS_AutoPass/AutoAnalysisXml.cs

@@ -205,7 +205,6 @@ namespace UAS_AutoPass
             string test_result = "";
             string test_sn = "";
             string imageurl = "";
-            string oMakeCode = "";
             string oMSID = "";
             string oErrMessage = "";
             XmlReader myReader = XmlReader.Create(FolderPath.Text + @"\" + e.Name);
@@ -262,10 +261,10 @@ namespace UAS_AutoPass
                 }
                 //-2-NG2017/10/2514:46:29.xml取第二位版号
                 string combinecode = e.Name.Substring(1, 1);
-                if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
+                if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out makecode, out oMSID, out oErrMessage))
                 {
                     //插入日志
-                    LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, test_result == "NG" ? "1" : "0");
+                    LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, test_result == "NG" ? "-1" : "0");
                     //如果是不良品记录日志,用于测试采集判负
                     if (test_result == "NG")
                     {
@@ -285,12 +284,25 @@ namespace UAS_AutoPass
             }
             else
             {
-                if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
+                string status = "";
+                string errmessage = "";
+                LogicHandler.GetMakeInfo(sncode, out makecode, out status, out errmessage);
+                if (ma_code.Text != makecode && makecode != "" && ma_code.Text != "" && status != "2")
+                {
+                    string ChangeMakeCode = MessageBox.Show(this.ParentForm, "序列号所属工单不同,是否切换?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
+                    //如果选择不切换赋值当前界面工单
+                    if (ChangeMakeCode != "Yes")
+                    {
+                        makecode = ma_code.Text;
+                    }
+                }
+                if (LogicHandler.CheckStepSNAndMacode(makecode, isource, sncode, iusercode, out makecode, out oMSID, out oErrMessage))
                 {
                     //获取序列号ID最大的工单
                     dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_id from makeserial where ms_sncode='" + sncode + "' order by ms_id desc", "select");
                     if (dt.Rows.Count > 0)
                     {
+                        ma_code.Text = dt.Rows[0]["ms_makecode"].ToString();
                         makecode = dt.Rows[0]["ms_makecode"].ToString();
                         switch (test_result)
                         {
@@ -368,7 +380,10 @@ namespace UAS_AutoPass
             sql.Append("where ms_sncode='" + sncode + "' and ms_makecode='" + makecode + "'");
             dh.BatchInsert(sql.ToString(), new string[] { "bc_code", "location" }, badcode, badlocation);
             //记录判断日志
-            LogicHandler.AutoPassJudge(sncode, makecode, isource, filename, ilinecode, combine);
+            if (dh.getFieldDataByCondition("source", "sc_scantype", "sc_code='" + isource + "'").ToString() == "REJUCE")
+            {
+                LogicHandler.AutoPassJudge(sncode, makecode, isource, filename, ilinecode, combine);
+            }
         }
 
         private void StopWatch_Click(object sender, EventArgs e)

+ 28 - 0
UAS_AutoPass/ToolClass/LogicHandler.cs

@@ -40,6 +40,34 @@ namespace UAS_AutoPass.ToolClass
             dh.ExecuteSql(sql.ToString(), "select");
         }
 
+        /// <summary>
+        /// 获取工单的最近一条执行记录
+        /// </summary>
+        /// <param name="iSnCode"></param>
+        /// <param name="oMakeCode"></param>
+        /// <param name="oErrorMessage"></param>
+        /// <returns></returns>
+        public static bool GetMakeInfo(string iSnCode, out string oMakeCode, out string oStatus, out string oErrorMessage)
+        {
+            //取MakeProcess表中的执行记录ID最大的一个工单的号码
+            oMakeCode = "";
+            oErrorMessage = "";
+            oStatus = "";
+            DataTable dt = dh.getFieldsDataByCondition("MakeSerial", new string[] { "ms_makecode", "ms_status" }, "ms_id=(select max(ms_id) from makeserial where ms_sncode='" + iSnCode + "')");
+            if (dt.Rows.Count > 0)
+            {
+                oMakeCode = dt.Rows[0]["ms_makecode"].ToString();
+                oStatus = dt.Rows[0]["ms_status"].ToString();
+            }
+            if (oMakeCode != "")
+                return true;
+            else
+            {
+                oErrorMessage = "序列号:" + iSnCode + " 未归属工单";
+                return false;
+            }
+        }
+
         public static void AutoPassJudge(string iSN, string iMakeCode, string iSource, string iFileName, string iLineCode, string iCombine)
         {
             //插入不良判断记录