Browse Source

优化预加工组装,解决主板第一次扫描2次问题

callm 5 years ago
parent
commit
af745519ce
1 changed files with 26 additions and 20 deletions
  1. 26 20
      UAS_MES_ODLF/FunctionCode/Make/Make_PreFeedingCollection.cs

+ 26 - 20
UAS_MES_ODLF/FunctionCode/Make/Make_PreFeedingCollection.cs

@@ -15,19 +15,7 @@ namespace UAS_MES_NEW.Make
 {
     public partial class Make_PreFeedingCollection : Form
     {
-        //MakeSerial表主键
-        string ms_id;
-        //制造单号                                                                             
-        string make_code;
-        //产品编号
-        string make_prodcode;
-        //工序编号
-        string nextstepcode;
-        //完工状态
-        string ms_status;
         //工艺路线编号
-        //Bom版本
-        string mabomversion;
         string ErrorMessage = "";
 
         List<string> TSN = new List<string>();
@@ -39,11 +27,6 @@ namespace UAS_MES_NEW.Make
         //提醒序列的索引
         int RemainIndex = 0;
 
-        string oMakeCode = "";
-        string oMsid = "";
-
-        string ms_firstsn = "";
-
         DataHelper dh;
         LogStringBuilder sql = new LogStringBuilder();
         DataTable DBFind;
@@ -113,6 +96,8 @@ namespace UAS_MES_NEW.Make
             code_KeyDown(sender, e2);
         }
 
+        bool GetMainCode = false;
+
         private void code_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)
@@ -131,10 +116,15 @@ namespace UAS_MES_NEW.Make
                             if (mainbarcode.Text == "")
                             {
                                 mainbarcode.Text = code.Text;
+                                GetMainCode = true;
                                 OperateResult.AppendText(">> 获取条码" + code.Text + "成功\n");
                                 GetItem();
-                                code.Clear();
-                                return;
+                                //code.Clear();
+                                //return;
+                            }
+                            else
+                            {
+                                GetMainCode = false;
                             }
                             string sp_soncode = "";
                             string sp_fsoncode = "";
@@ -147,12 +137,14 @@ namespace UAS_MES_NEW.Make
                             string sp_barcoderule = "";
                             string sp_checkbarcode = "";
                             string sp_checksalecode = "";
+                            bool needload = false;
                             for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
                             {
                                 object value = LabelDataGridView.Rows[i].Cells["BarCode"].Value;
                                 if (value == null || (value != null && value.ToString() == ""))
                                 {
                                     RemainIndex = i;
+                                    needload = true;
                                     sp_soncode = dt1.Rows[i]["sp_soncode"].ToString();
                                     sp_fsoncode = dt1.Rows[i]["sp_fsoncode"].ToString();
                                     sp_prefix = dt1.Rows[i]["sp_prefix"].ToString();
@@ -167,6 +159,20 @@ namespace UAS_MES_NEW.Make
                                     break;
                                 }
                             }
+                            if (GetMainCode && RemainIndex != 0)
+                            {
+                                code.Clear();
+                                return;
+                            }
+                            if (!needload)
+                            {
+                                OperateResult.AppendText(">>没有需要采集的物料,请重新采集\n", Color.Red, code);
+                                mainbarcode.Clear();
+                                SetCheck set = new SetCheck("NG", Color.Red);
+                                BaseUtil.SetFormCenter(set);
+                                set.ShowDialog();
+                                return;
+                            }
                             if (LogicHandler.CheckSNBeforeLoad(ma_code.Text, code.Text, sp_fsoncode, sp_soncode, sp_barcoderule, sp_prefix, length, sp_ifrepeat, sp_checksalecode, out ErrorMessage))
                             {
                                 //查询条码是否存在预加工列表
@@ -196,7 +202,7 @@ namespace UAS_MES_NEW.Make
                                 OperateResult.AppendText(">> 条码" + code.Text + "上料成功\n", Color.Green, code);
                                 code.Clear();
                                 CollectCount = CollectCount + 1;
-                                if (CollectCount == ProdNum.Value)
+                                if (CollectCount == ProdNum.Value || RemainIndex == LabelDataGridView.Rows.Count - 1)
                                 {
                                     mainbarcode.Text = "";
                                     CollectCount = 0;