Ver Fonte

完善功能

章政 há 8 anos atrás
pai
commit
395d51d178

+ 9 - 9
UAS_AutoPass/AutoAnalysisXml.Designer.cs

@@ -44,7 +44,7 @@
             this.label4 = new System.Windows.Forms.Label();
             this.label4 = new System.Windows.Forms.Label();
             this.Master = new System.Windows.Forms.ComboBox();
             this.Master = new System.Windows.Forms.ComboBox();
             this.AutoStart = new System.Windows.Forms.CheckBox();
             this.AutoStart = new System.Windows.Forms.CheckBox();
-            this.MakeCode = new System.Windows.Forms.TextBox();
+            this.ma_code = new System.Windows.Forms.TextBox();
             ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).BeginInit();
             this.SuspendLayout();
             this.SuspendLayout();
             // 
             // 
@@ -204,20 +204,20 @@
             this.AutoStart.UseVisualStyleBackColor = true;
             this.AutoStart.UseVisualStyleBackColor = true;
             this.AutoStart.CheckedChanged += new System.EventHandler(this.AutoStart_CheckedChanged);
             this.AutoStart.CheckedChanged += new System.EventHandler(this.AutoStart_CheckedChanged);
             // 
             // 
-            // MakeCode
+            // ma_code
             // 
             // 
-            this.MakeCode.Location = new System.Drawing.Point(149, 100);
-            this.MakeCode.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.MakeCode.Name = "MakeCode";
-            this.MakeCode.Size = new System.Drawing.Size(292, 25);
-            this.MakeCode.TabIndex = 17;
+            this.ma_code.Location = new System.Drawing.Point(149, 100);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.ma_code.Name = "ma_code";
+            this.ma_code.Size = new System.Drawing.Size(292, 25);
+            this.ma_code.TabIndex = 17;
             // 
             // 
             // AutoAnalysisXml
             // AutoAnalysisXml
             // 
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(887, 395);
             this.ClientSize = new System.Drawing.Size(887, 395);
-            this.Controls.Add(this.MakeCode);
+            this.Controls.Add(this.ma_code);
             this.Controls.Add(this.AutoStart);
             this.Controls.Add(this.AutoStart);
             this.Controls.Add(this.Master);
             this.Controls.Add(this.Master);
             this.Controls.Add(this.label4);
             this.Controls.Add(this.label4);
@@ -262,7 +262,7 @@
         private System.Windows.Forms.ComboBox Master;
         private System.Windows.Forms.ComboBox Master;
         private System.Windows.Forms.Label label4;
         private System.Windows.Forms.Label label4;
         private System.Windows.Forms.CheckBox AutoStart;
         private System.Windows.Forms.CheckBox AutoStart;
-        private System.Windows.Forms.TextBox MakeCode;
+        private System.Windows.Forms.TextBox ma_code;
     }
     }
 }
 }
 
 

+ 58 - 52
UAS_AutoPass/AutoAnalysisXml.cs

@@ -37,6 +37,10 @@ namespace UAS_AutoPass
         /// </summary>
         /// </summary>
         string ilinecode;
         string ilinecode;
         /// <summary>
         /// <summary>
+        /// 不良代码组
+        /// </summary>
+        string ibadgroup;
+        /// <summary>
         /// 当前工序
         /// 当前工序
         /// </summary>
         /// </summary>
         string istepcode;
         string istepcode;
@@ -88,12 +92,21 @@ namespace UAS_AutoPass
                 AutoStart.Checked = (bool)BaseUtil.GetCacheData("AutoStart");
                 AutoStart.Checked = (bool)BaseUtil.GetCacheData("AutoStart");
             }
             }
             catch (Exception ex) { Console.WriteLine(ex.Message); }
             catch (Exception ex) { Console.WriteLine(ex.Message); }
+            for (int i = 0; i < DB.Rows.Count; i++)
+            {
+                if (Master.Text == DB.Rows[i]["ma_user"].ToString())
+                {
+                    DataHelper.DBConnectionString = "Data Source=" + DB.Rows[i]["ma_address"] + ";User ID=" + DB.Rows[i]["ma_user"] + ";PassWord=" + DB.Rows[i]["ms_pwd"]; ;
+                    dh = new DataHelper();
+                }
+            }
             //获取岗位资源相关信息
             //获取岗位资源相关信息
-            dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode from source where sc_code='" + isource + "'", "select");
+            DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
             if (dt.Rows.Count > 0)
             if (dt.Rows.Count > 0)
             {
             {
                 ilinecode = dt.Rows[0]["sc_linecode"].ToString();
                 ilinecode = dt.Rows[0]["sc_linecode"].ToString();
                 istepcode = dt.Rows[0]["sc_stepcode"].ToString();
                 istepcode = dt.Rows[0]["sc_stepcode"].ToString();
+                ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
             }
             }
         }
         }
 
 
@@ -135,12 +148,12 @@ namespace UAS_AutoPass
                     dh = new DataHelper();
                     dh = new DataHelper();
                 }
                 }
             }
             }
-            //暂时不用归属工单
-            //if (!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + MakeCode.Text + "'"))
-            //{
-            //    OperateResult.AppendText("工单不存在或者未下放\n");
-            //    return;
-            //}
+            //存在工单必须是已下放状态
+            if (!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + ma_code.Text + "'") && ma_code.Text != "")
+            {
+                OperateResult.AppendText("工单不存在或者未下放\n");
+                return;
+            }
             XmlWatcher.Path = FolderPath.Text;
             XmlWatcher.Path = FolderPath.Text;
             XmlWatcher.Filter = "*.xml";
             XmlWatcher.Filter = "*.xml";
             XmlWatcher.EnableRaisingEvents = true;
             XmlWatcher.EnableRaisingEvents = true;
@@ -152,7 +165,7 @@ namespace UAS_AutoPass
             //设置按钮不可点击
             //设置按钮不可点击
             StartWatch.Enabled = false;
             StartWatch.Enabled = false;
             ChooseFolder.Enabled = false;
             ChooseFolder.Enabled = false;
-            MakeCode.Enabled = false;
+            ma_code.Enabled = false;
             ChooseBackUpFolder.Enabled = false;
             ChooseBackUpFolder.Enabled = false;
             StopWatch.Enabled = true;
             StopWatch.Enabled = true;
             OperateResult.AppendText("开始执行监控\n");
             OperateResult.AppendText("开始执行监控\n");
@@ -223,9 +236,8 @@ namespace UAS_AutoPass
             //获取文件名的序列号,如SA123456.xml,如果开头为-表示无条码需要自动获取
             //获取文件名的序列号,如SA123456.xml,如果开头为-表示无条码需要自动获取
             string sncode = e.Name.Substring(0, 1) == "-" ? "" : e.Name.Split('.')[0];
             string sncode = e.Name.Substring(0, 1) == "-" ? "" : e.Name.Split('.')[0];
             string makecode = "";
             string makecode = "";
-            string ErrMessage = "";
-            //获取序列号ID最大的工单号,测试良品时才进行分配
-            if (sncode == "" && test_result == "OK")
+            //获取序列号ID最大的工单号,所有序列号都测试为良品
+            if (sncode == "")
             {
             {
                 //获取资源,线别,工序相等,并且状态在线的序列号进行分配
                 //获取资源,线别,工序相等,并且状态在线的序列号进行分配
                 sql.Clear();
                 sql.Clear();
@@ -239,82 +251,63 @@ namespace UAS_AutoPass
                 }
                 }
                 //-2-NG2017/10/2514:46:29.xml取第二位版号
                 //-2-NG2017/10/2514:46:29.xml取第二位版号
                 string combinecode = e.Name.Substring(1, 1);
                 string combinecode = e.Name.Substring(1, 1);
-                if (LogicHandler.CheckStepSNAndMacode(makecode, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
+                if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
                 {
                 {
-                    LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, "0");
-                    if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out ErrMessage))
+                    //插入日志
+                    LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, test_result == "NG" ? "1" : "0");
+                    //如果是不良品记录日志,用于测试采集判负
+                    if (test_result == "NG")
+                    {
+                        RecordBadInfo(sncode, makecode, e.Name, combinecode, badcode.ToArray(), badlocation.ToArray());
+                    }
+                    if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
                     {
                     {
-                        OperateResult.AppendText(ErrMessage + "\n");
+                        OperateResult.AppendText(oErrMessage + "\n");
                         return;
                         return;
                     }
                     }
                 }
                 }
                 else
                 else
                 {
                 {
-                    OperateResult.AppendText(ErrMessage + "\n");
+                    OperateResult.AppendText(oErrMessage + "\n");
                     return;
                     return;
                 }
                 }
             }
             }
-            //没有条码并且不良进行记录
-            else if (sncode == "" && test_result == "NG")
-            {
-                LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, "1");
-            }
-            else if (sncode != "")
+            else
             {
             {
-                if (LogicHandler.CheckStepSNAndMacode(makecode, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
+                if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
                 {
                 {
                     //获取序列号ID最大的工单
                     //获取序列号ID最大的工单
-                    string msid = "";
                     dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_id from makeserial where ms_sncode='" + sncode + "' order by ms_id desc", "select");
                     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)
                     if (dt.Rows.Count > 0)
                     {
                     {
-                        msid = dt.Rows[0]["ms_id"].ToString();
                         makecode = dt.Rows[0]["ms_makecode"].ToString();
                         makecode = dt.Rows[0]["ms_makecode"].ToString();
                         switch (test_result)
                         switch (test_result)
                         {
                         {
                             case "OK":
                             case "OK":
-                                if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out ErrMessage))
+                                if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out oErrMessage))
                                 {
                                 {
-                                    OperateResult.AppendText(ErrMessage + "\n");
+                                    OperateResult.AppendText(oErrMessage + "\n");
                                     return;
                                     return;
                                 }
                                 }
                                 break;
                                 break;
                             case "NG":
                             case "NG":
-                                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_badtable,mb_soncode,mb_status) select makebad_seq.nextval");
-                                sql.Append(",ma_code,ms_code,ms_sncode,'" + iusercode + "',sysdate,'" + istepcode + "','" + isource + "',:bc_code,'',");
-                                sql.Append("sp_soncode,'0' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on sp_mothercode");
-                                sql.Append("=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + sncode + "' and ms_makecode='" + makecode + "'");
-                                dh.BatchInsert(sql.ToString(), new string[] { "bc_code" }, badcode.ToArray());
-                                //更新序列号不良状态
-                                dh.UpdateByCondition("makeserial", "ms_status=3", "ms_id='" + msid + "'");
-                                for (int i = 0; i < badcode.Count; i++)
+                                RecordBadInfo(sncode, makecode, e.Name, "", badcode.ToArray(), badlocation.ToArray());
+                                //所有的序列号均采集为良品
+                                if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
                                 {
                                 {
-                                    //保存不良位置
-                                    string[] location = badlocation[i].Split(',');
-                                    sql.Clear();
-                                    sql.Append("insert into makebadrsloc(mbl_id,mbl_loc,mbl_badcode,mbl_sncode,mbl_makecode,");
-                                    sql.Append("mbl_indate ,mbl_inman) select makebadrsloc_seq.nextval,");
-                                    sql.Append(":location,'" + badcode[i] + "','" + sncode + "','" + makecode + "',");
-                                    sql.Append("sysdate,'" + iusercode + "' from dual");
-                                    dh.BatchInsert(sql.ToString(), new string[] { "location" }, location);
-                                }
-                                if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out ErrMessage))
-                                {
-                                    OperateResult.AppendText(ErrMessage + "\n");
+                                    OperateResult.AppendText(oErrMessage + "\n");
                                     return;
                                     return;
                                 }
                                 }
                                 break;
                                 break;
                             default:
                             default:
                                 break;
                                 break;
                         }
                         }
-                        LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, "0");
+                        LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, test_result == "NG" ? "1" : "0");
                     }
                     }
                 }
                 }
                 else
                 else
                 {
                 {
-                    OperateResult.AppendText(ErrMessage + "\n");
+                    OperateResult.AppendText(oErrMessage + "\n");
                     return;
                     return;
                 }
                 }
             }
             }
@@ -346,11 +339,24 @@ namespace UAS_AutoPass
             }
             }
         }
         }
 
 
+        private void RecordBadInfo(string sncode, string makecode, string filename, string combine, string[] badcode, string[] badlocation)
+        {
+            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_status,mb_badremark) select makebad_seq.nextval");
+            sql.Append(",ma_code,ms_code,ms_sncode,'" + iusercode + "',sysdate,'" + istepcode + "','" + isource + "',");
+            sql.Append(":bc_code,'" + ibadgroup + "','','0',:location from make left join makeSerial on ms_makecode=ma_code ");
+            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);
+        }
+
         private void StopWatch_Click(object sender, EventArgs e)
         private void StopWatch_Click(object sender, EventArgs e)
         {
         {
             XmlWatcher.EnableRaisingEvents = false;
             XmlWatcher.EnableRaisingEvents = false;
             StartWatch.Enabled = true;
             StartWatch.Enabled = true;
-            MakeCode.Enabled = true;
+            ma_code.Enabled = true;
             ChooseFolder.Enabled = true;
             ChooseFolder.Enabled = true;
             ChooseBackUpFolder.Enabled = true;
             ChooseBackUpFolder.Enabled = true;
             StopWatch.Enabled = false;
             StopWatch.Enabled = false;

+ 13 - 3
UAS_AutoPass/ToolClass/LogicHandler.cs

@@ -29,16 +29,26 @@ namespace UAS_AutoPass.ToolClass
                 return false;
                 return false;
         }
         }
 
 
-        public static void AutoPassLog(string iSN,string iSource,string iMakeCode,string iDate,string iStepCode,string iLineCode,string iFileName,string iIFNG)
+        public static void AutoPassLog(string iSN, string iSource, string iMakeCode, string iDate, string iStepCode, string iLineCode, string iFileName, string iIFNG)
         {
         {
             sql.Clear();
             sql.Clear();
             sql.Append("insert into AUTOSCANLOG(as_id,as_indate,as_testdate,as_sourcecode,as_stepcode,");
             sql.Append("insert into AUTOSCANLOG(as_id,as_indate,as_testdate,as_sourcecode,as_stepcode,");
             sql.Append("as_linecode,as_makecode,as_sncode,as_filename,as_ifng)values(AUTOSCANLOG_seq.nextval,");
             sql.Append("as_linecode,as_makecode,as_sncode,as_filename,as_ifng)values(AUTOSCANLOG_seq.nextval,");
-            sql.Append("sysdate,to_date('"+ iDate + "','yyyy-mm-dd,hh24:mi:ss'),'" + iSource+"','"+iStepCode+"','"+iLineCode+"','"+iMakeCode+"',");
-            sql.Append("'"+iSN+"','"+ iFileName + "','"+ iIFNG + "')");
+            sql.Append("sysdate,to_date('" + iDate + "','yyyy-mm-dd,hh24:mi:ss'),'" + iSource + "','" + iStepCode + "','" + iLineCode + "','" + iMakeCode + "',");
+            sql.Append("'" + iSN + "','" + iFileName + "','" + iIFNG + "')");
             dh.ExecuteSql(sql.ToString(), "select");
             dh.ExecuteSql(sql.ToString(), "select");
         }
         }
 
 
+        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");
+        }
+
         public static bool SetStepResult(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, out string oErrorMessage)
         public static bool SetStepResult(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, out string oErrorMessage)
         {
         {
             return CS_SetResult(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrorMessage);
             return CS_SetResult(iMakeCode, iSourceCode, iSN, iUserCode, iResult, out oErrorMessage);